Asterisk - The Open Source Telephony Project  18.5.0
pval.h
Go to the documentation of this file.
1 #ifndef _ASTERISK_PVAL_H
2 #define _ASTERISK_PVAL_H
3 
4 /* whatever includes this, better include asterisk/lock.h and asterisk/hashtab.h */
5 
6 typedef enum
7 {
8  PV_WORD, /* an ident, string, name, label, etc. A user-supplied string. */ /* 0 */
9  PV_MACRO, /* 1 */
10  PV_CONTEXT, /* 2 */
11  PV_MACRO_CALL, /* 3 */
13  PV_CASE, /* 5 */
14  PV_PATTERN, /* 6 */
15  PV_DEFAULT, /* 7 */
16  PV_CATCH, /* 8 */
17  PV_SWITCHES, /* 9 */
18  PV_ESWITCHES, /* 10 */
19  PV_INCLUDES, /* 11 */
21  PV_VARDEC, /* you know, var=val; */ /* 13 */
22  PV_GOTO, /* 14 */
23  PV_LABEL, /* 15 */
24  PV_FOR, /* 16 */
25  PV_WHILE, /* 17 */
26  PV_BREAK, /* 18 */
27  PV_RETURN, /* 19 */
28  PV_CONTINUE, /* 20 */
29  PV_IF, /* 21 */
30  PV_IFTIME, /* 22 */
31  PV_RANDOM, /* 23 */
32  PV_SWITCH, /* 24 */
33  PV_EXTENSION, /* 25 */
34  PV_IGNOREPAT, /* 26 */
35  PV_GLOBALS, /* 27 */
36  PV_LOCALVARDEC, /* 28 */
37 } pvaltype;
38 
39 /* why this horrible mess? It's always been a tradeoff-- tons of structs,
40  each storing it's specific lists of goodies, or a 'simple' single struct,
41  with lots of fields, that catches all uses at once. Either you have a long
42  list of struct names and subnames, or you have a long list of field names,
43  and where/how they are used. I'm going with a single struct, using unions
44  to reduce storage. Some simple generalizations, and a long list of types,
45  and a book about what is used with what types.... Sorry!
46 */
47 
48 struct pval
49 {
51  int startline;
52  int endline;
53  int startcol;
54  int endcol;
55  char *filename;
56 
57  union
58  {
59  char *str; /* wow, used almost everywhere! */
60  struct pval *list; /* used in SWITCHES, ESWITCHES, INCLUDES, STATEMENTBLOCK, GOTO */
61  struct pval *statements;/* used in EXTENSION */
62  char *for_init; /* used in FOR */
63  } u1;
64  struct pval *u1_last; /* to build in-order lists -- looks like we only need one */
65 
66  union
67  {
68  struct pval *arglist; /* used in macro_call, application_call, MACRO def, also attached to PWORD, the 4 timevals for includes */
69  struct pval *statements; /* used in case, default, catch, while's statement, CONTEXT elements, GLOBALS */
70  char *val; /* used in VARDEC */
71  char *for_test; /* used in FOR */
72  struct pval *goto_target; /* used in GOTO */
73  } u2;
74 
75  union
76  {
77  char *for_inc; /* used in FOR */
78  struct pval *else_statements; /* used in IF */
79  struct pval *macro_statements; /* used in MACRO */
80  int abstract; /* used for context 1=abstract; 2=extend; 3=both */
81  char *hints; /* used in EXTENSION */
82  int goto_target_in_case; /* used in GOTO */
84  struct pval *extend; /* to link extended contexts to the 'original' */
85  } u3;
86 
87  union
88  {
89  struct pval *for_statements; /* used in PV_FOR */
90  int regexten; /* used in EXTENSION */
91  } u4;
92 
93  struct pval *next; /* the pval at the end of this ptr will ALWAYS be of the same type as this one!
94  EXCEPT for objects of the different types, that are in the same list, like contexts & macros, etc */
95 
96  struct pval *dad; /* the 'container' of this struct instance */
97  struct pval *prev; /* the opposite of the 'next' pointer */
98 } ;
99 
100 
101 typedef struct pval pval;
102 
103 #ifndef AAL_ARGCHECK
104 /* for the time being, short circuit all the AAL related structures
105  without permanently removing the code; after/during the AAL
106  development, this code can be properly re-instated
107 */
108 
109 /* null definitions for structs passed down the infrastructure */
110 struct argapp
111 {
112  struct argapp *next;
113 };
114 
115 #endif
116 
117 struct ast_context;
118 
119 #ifdef AAL_ARGCHECK
120 int option_matches_j( struct argdesc *should, pval *is, struct argapp *app);
121 int option_matches( struct argdesc *should, pval *is, struct argapp *app);
122 int ael_is_funcname(char *name);
123 #endif
124 
125 int do_pbx_load_module(void);
126 int count_labels_in_current_context(char *label);
127 int check_app_args(pval *appcall, pval *arglist, struct argapp *app);
128 void check_pval(pval *item, struct argapp *apps, int in_globals);
129 void check_pval_item(pval *item, struct argapp *apps, int in_globals);
130 void check_switch_expr(pval *item, struct argapp *apps);
131 void ast_expr_register_extra_error_info(char *errmsg);
133 int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan);
134 struct pval *find_macro(char *name);
135 struct pval *find_context(char *name);
136 struct pval *find_context(char *name);
137 struct pval *find_macro(char *name);
138 struct ael_priority *new_prio(void);
139 struct ael_extension *new_exten(void);
140 void linkprio(struct ael_extension *exten, struct ael_priority *prio, struct ael_extension *mother_exten);
142 /* static void linkexten(struct ael_extension *exten, struct ael_extension *add);
143  static void gen_prios(struct ael_extension *exten, char *label, pval *statement, struct ael_extension *mother_exten, struct ast_context *context ); */
144 void set_priorities(struct ael_extension *exten);
145 void add_extensions(struct ael_extension *exten);
146 int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *local_table, struct pval *root);
147 void destroy_pval(pval *item);
149 int is_float(char *arg );
150 int is_int(char *arg );
151 int is_empty(char *arg);
152 
153 /* PVAL PI */
154 
155 
158 
159 void pvalWordSetString( pval *p, char *str);
160 char *pvalWordGetString( pval *p );
161 
162 void pvalMacroSetName( pval *p, char *name);
163 char *pvalMacroGetName( pval *p );
164 void pvalMacroSetArglist( pval *p, pval *arglist );
165 void pvalMacroAddArg( pval *p, pval *arg );
166 pval *pvalMacroWalkArgs( pval *p, pval **arg );
167 void pvalMacroAddStatement( pval *p, pval *statement );
168 pval *pvalMacroWalkStatements( pval *p, pval **next_statement );
169 
170 void pvalContextSetName( pval *p, char *name);
171 char *pvalContextGetName( pval *p );
172 void pvalContextSetAbstract( pval *p );
173 void pvalContextUnsetAbstract( pval *p );
174 int pvalContextGetAbstract( pval *p );
175 void pvalContextAddStatement( pval *p, pval *statement);
177 
178 void pvalMacroCallSetMacroName( pval *p, char *name );
179 char* pvalMacroCallGetMacroName( pval *p );
181 void pvalMacroCallAddArg( pval *p, pval *arg );
183 
184 void pvalAppCallSetAppName( pval *p, char *name );
185 char* pvalAppCallGetAppName( pval *p );
187 void pvalAppCallAddArg( pval *p, pval *arg );
189 
190 void pvalCasePatSetVal( pval *p, char *val );
191 char* pvalCasePatGetVal( pval *p );
192 void pvalCasePatDefAddStatement( pval *p, pval *statement );
193 pval *pvalCasePatDefWalkStatements( pval *p, pval **statement );
194 
195 void pvalCatchSetExtName( pval *p, char *name );
196 char* pvalCatchGetExtName( pval *p );
197 void pvalCatchSetStatement( pval *p, pval *statement );
199 
200 void pvalSwitchesAddSwitch( pval *p, char *name );
202 void pvalESwitchesAddSwitch( pval *p, char *name );
204 
205 void pvalIncludesAddInclude( pval *p, const char *include );
206 
207 void pvalIncludesAddIncludeWithTimeConstraints( pval *p, const char *include, char *hour_range, char *dom_range, char *dow_range, char *month_range );
208 void pvalIncludeGetTimeConstraints( pval *p, char **hour_range, char **dom_range, char **dow_range, char **month_range );
209 char* pvalIncludesWalk( pval *p, pval **next_item );
210 
211 void pvalStatementBlockAddStatement( pval *p, pval *statement);
212 pval *pvalStatementBlockWalkStatements( pval *p, pval **next_statement);
213 
214 void pvalVarDecSetVarname( pval *p, char *name );
215 void pvalVarDecSetValue( pval *p, char *value );
216 char* pvalVarDecGetVarname( pval *p );
217 char* pvalVarDecGetValue( pval *p );
218 
219 void pvalGotoSetTarget( pval *p, char *context, char *exten, char *label );
220 void pvalGotoGetTarget( pval *p, char **context, char **exten, char **label );
221 
222 void pvalLabelSetName( pval *p, char *name );
223 char* pvalLabelGetName( pval *p );
224 
225 void pvalForSetInit( pval *p, char *init );
226 void pvalForSetTest( pval *p, char *test );
227 void pvalForSetInc( pval *p, char *inc );
228 void pvalForSetStatement( pval *p, pval *statement );
229 char* pvalForGetInit( pval *p );
230 char* pvalForGetTest( pval *p );
231 char* pvalForGetInc( pval *p );
233 
234 
235 void pvalIfSetCondition( pval *p, char *expr );
236 char* pvalIfGetCondition( pval *p );
237 void pvalIfTimeSetCondition( pval *p, char *hour_range, char *dow_range, char *dom_range, char *mon_range ); /* time range format: 24-hour format begin-end|dow range|dom range|month range */
238 void pvalIfTimeGetCondition( pval *p, char **hour_range, char **dow_range, char **dom_range, char **month_range );
239 void pvalRandomSetCondition( pval *p, char *percent );
240 char* pvalRandomGetCondition( pval *p );
241 void pvalConditionalSetThenStatement( pval *p, pval *statement );
242 void pvalConditionalSetElseStatement( pval *p, pval *statement );
245 
246 void pvalSwitchSetTestexpr( pval *p, char *expr );
247 char* pvalSwitchGetTestexpr( pval *p );
248 void pvalSwitchAddCase( pval *p, pval *Case );
249 pval* pvalSwitchWalkCases( pval *p, pval **next_case );
250 
251 void pvalExtenSetName( pval *p, char *name );
252 char *pvalExtenGetName( pval *p );
253 void pvalExtenSetRegexten( pval *p );
254 void pvalExtenUnSetRegexten( pval *p );
255 int pvalExtenGetRegexten( pval *p );
256 void pvalExtenSetHints( pval *p, char *hints );
257 char* pvalExtenGetHints( pval *p );
258 void pvalExtenSetStatement( pval *p, pval *statement );
260 
261 void pvalIgnorePatSetPattern( pval *p, char *pat );
262 char* pvalIgnorePatGetPattern( pval *p );
263 
264 void pvalGlobalsAddStatement( pval *p, pval *statement );
265 pval* pvalGlobalsWalkStatements( pval *p, pval **next_statement );
266 
267 void pvalTopLevAddObject( pval *p, pval *contextOrObj );
268 pval* pvalTopLevWalkObjects( pval *p, pval **next_obj );
269 
270 int pvalCheckType( pval *p, char *funcname, pvaltype type );
271 
272 
273 #endif
pval * pvalCasePatDefWalkStatements(pval *p, pval **statement)
Definition: pval.c:5311
char * pvalSwitchGetTestexpr(pval *p)
Definition: pval.c:5763
void pvalContextUnsetAbstract(pval *p)
Definition: pval.c:5164
pval * pvalMacroWalkStatements(pval *p, pval **next_statement)
Definition: pval.c:5129
void pvalGotoSetTarget(pval *p, char *context, char *exten, char *label)
Definition: pval.c:5527
void pvalConditionalSetThenStatement(pval *p, pval *statement)
Definition: pval.c:5736
void pvalTopLevAddObject(pval *p, pval *contextOrObj)
Definition: pval.c:5901
char * pvalCasePatGetVal(pval *p)
Definition: pval.c:5298
void pvalForSetInit(pval *p, char *init)
Definition: pval.c:5605
void check_pval_item(pval *item, struct argapp *apps, int in_globals)
Definition: pval.c:2357
static char exten[AST_MAX_EXTENSION]
Definition: chan_alsa.c:118
Main Channel structure associated with a channel.
int regexten
Definition: pval.h:90
char * for_inc
Definition: pval.h:77
union pval::@285 u1
void destroy_pval_item(pval *item)
Definition: pval.c:4672
void pvalAppCallAddArg(pval *p, pval *arg)
Definition: pval.c:5268
void check_switch_expr(pval *item, struct argapp *apps)
Definition: pval.c:2184
void pvalVarDecSetValue(pval *p, char *value)
Definition: pval.c:5506
void check_pval(pval *item, struct argapp *apps, int in_globals)
Definition: pval.c:2865
struct ael_priority * new_prio(void)
Definition: pval.c:2924
struct pval * list
Definition: pval.h:60
char * pvalMacroCallGetMacroName(pval *p)
Definition: pval.c:5210
void pvalExtenSetName(pval *p, char *name)
Definition: pval.c:5795
Definition: ast_expr2.c:325
Definition: pval.h:32
Registered applications container.
Definition: pbx_app.c:67
void pvalESwitchesAddSwitch(pval *p, char *name)
Definition: pval.c:5373
struct pval * dad
Definition: pval.h:96
void pvalMacroAddArg(pval *p, pval *arg)
Definition: pval.c:5094
void pvalExtenUnSetRegexten(pval *p)
Definition: pval.c:5816
void pvalCasePatSetVal(pval *p, char *val)
Definition: pval.c:5291
char * pvalMacroGetName(pval *p)
Definition: pval.c:5080
void pvalLabelSetName(pval *p, char *name)
Definition: pval.c:5590
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
Definition: pval.h:29
void pvalIfSetCondition(pval *p, char *expr)
Definition: pval.c:5663
void pvalExtenSetRegexten(pval *p)
Definition: pval.c:5809
void pvalMacroSetArglist(pval *p, pval *arglist)
Definition: pval.c:5087
void pvalContextSetName(pval *p, char *name)
Definition: pval.c:5143
char * pvalIncludesWalk(pval *p, pval **next_item)
Definition: pval.c:5467
void pvalWordSetString(pval *p, char *str)
Definition: pval.c:5058
void add_extensions(struct ael_extension *exten)
Definition: pval.c:4213
struct pval * statements
Definition: pval.h:61
char * pvalAppCallGetAppName(pval *p)
Definition: pval.c:5254
char * pvalExtenGetHints(pval *p)
Definition: pval.c:5837
void pvalIncludeGetTimeConstraints(pval *p, char **hour_range, char **dom_range, char **dow_range, char **month_range)
Definition: pval.c:5450
static struct aco_type item
Definition: test_config.c:1463
void pvalIgnorePatSetPattern(pval *p, char *pat)
Definition: pval.c:5859
void pvalAppCallSetAppName(pval *p, char *name)
Definition: pval.c:5247
int pvalContextGetAbstract(pval *p)
Definition: pval.c:5171
char * pvalLabelGetName(pval *p)
Definition: pval.c:5597
struct pval * extend
Definition: pval.h:84
void pvalSwitchSetTestexpr(pval *p, char *expr)
Definition: pval.c:5756
Definition: pval.h:22
int startline
Definition: pval.h:51
const char * args
struct ast_context * local_contexts
pval * pvalCreateNode(pvaltype type)
Definition: pval.c:5042
char * pvalVarDecGetValue(pval *p)
Definition: pval.c:5520
int value
Definition: syslog.c:37
int is_float(char *arg)
Definition: pval.c:1963
void pvalMacroCallAddArg(pval *p, pval *arg)
Definition: pval.c:5224
Definition: pval.h:8
Definition: pval.h:110
char * pvalForGetInc(pval *p)
Definition: pval.c:5647
int pvalExtenGetRegexten(pval *p)
Definition: pval.c:5823
struct ael_extension * new_exten(void)
Definition: pval.c:2930
void pvalGotoGetTarget(pval *p, char **context, char **exten, char **label)
Definition: pval.c:5563
char * val
Definition: pval.h:70
void pvalForSetStatement(pval *p, pval *statement)
Definition: pval.c:5626
pval * pvalSwitchWalkCases(pval *p, pval **next_case)
Definition: pval.c:5782
char * pvalESwitchesWalkNames(pval *p, pval **next_item)
Definition: pval.c:5383
pval * pvalTopLevWalkObjects(pval *p, pval **next_obj)
Definition: pval.c:5910
char * pvalVarDecGetVarname(pval *p)
Definition: pval.c:5513
int do_pbx_load_module(void)
Definition: pval.h:13
char * pvalIfGetCondition(pval *p)
Definition: pval.c:5670
void pvalConditionalSetElseStatement(pval *p, pval *statement)
Definition: pval.c:5741
char * filename
Definition: pval.h:55
char * pvalWordGetString(pval *p)
Definition: pval.c:5065
void pvalForSetTest(pval *p, char *test)
Definition: pval.c:5612
struct pval * goto_target
Definition: pval.h:72
pval * pvalAppCallWalkArgs(pval *p, pval **args)
Definition: pval.c:5278
pvaltype pvalObjectGetType(pval *p)
Definition: pval.c:5052
Definition: pval.h:21
static char next_item(const char *format)
Definition: say.c:4486
void pvalVarDecSetVarname(pval *p, char *name)
Definition: pval.c:5499
pval * pvalConditionalGetElseStatement(pval *p)
Definition: pval.c:5751
char * str
Definition: pval.h:59
pval * pvalConditionalGetThenStatement(pval *p)
Definition: pval.c:5746
void pvalIfTimeSetCondition(pval *p, char *hour_range, char *dow_range, char *dom_range, char *mon_range)
Definition: pval.c:5677
Definition: pval.h:48
void pvalGlobalsAddStatement(pval *p, pval *statement)
Definition: pval.c:5874
char * for_test
Definition: pval.h:71
void pvalSwitchesAddSwitch(pval *p, char *name)
Definition: pval.c:5351
int count_labels_in_current_context(char *label)
struct ael_extension * compiled_label
Definition: pval.h:83
int goto_target_in_case
Definition: pval.h:82
char * hints
Definition: pval.h:81
void ast_expr_clear_extra_error_info(void)
Definition: ast_expr2f.c:2483
char * pvalRandomGetCondition(pval *p)
Definition: pval.c:5729
struct pval * else_statements
Definition: pval.h:78
int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *local_table, struct pval *root)
Definition: pval.c:4413
Definition: pval.h:24
struct pval * arglist
Definition: pval.h:68
int endcol
Definition: pval.h:54
void pvalMacroSetName(pval *p, char *name)
Definition: pval.c:5073
struct pval * u1_last
Definition: pval.h:64
void destroy_pval(pval *item)
Definition: pval.c:4940
char * pvalCatchGetExtName(pval *p)
Definition: pval.c:5329
static struct ast_hashtab * local_table
Definition: pbx_config.c:112
pvaltype
Definition: pval.h:6
void pvalExtenSetStatement(pval *p, pval *statement)
Definition: pval.c:5844
char * pvalExtenGetName(pval *p)
Definition: pval.c:5802
Definition: pval.h:9
union pval::@287 u3
Definition: pval.h:31
static const char name[]
Definition: cdr_mysql.c:74
pval * pvalMacroCallWalkArgs(pval *p, pval **args)
Definition: pval.c:5234
Definition: pval.h:25
pval * pvalCatchGetStatement(pval *p)
Definition: pval.c:5343
void pvalIncludesAddIncludeWithTimeConstraints(pval *p, const char *include, char *hour_range, char *dom_range, char *dow_range, char *month_range)
Definition: pval.c:5407
void pvalContextSetAbstract(pval *p)
Definition: pval.c:5157
char * pvalIgnorePatGetPattern(pval *p)
Definition: pval.c:5866
pvaltype type
Definition: pval.h:50
void pvalRandomSetCondition(pval *p, char *percent)
Definition: pval.c:5722
int is_int(char *arg)
Definition: pval.c:1972
char * pvalContextGetName(pval *p)
Definition: pval.c:5150
struct pval * find_context(char *name)
Definition: pval.c:1953
void pvalCatchSetStatement(pval *p, pval *statement)
Definition: pval.c:5336
void ast_expr_register_extra_error_info(char *errmsg)
Definition: ast_expr2f.c:2477
pval * pvalGlobalsWalkStatements(pval *p, pval **next_statement)
Definition: pval.c:5887
char * pvalSwitchesWalkNames(pval *p, pval **next_item)
Definition: pval.c:5361
void destroy_extensions(struct ael_extension *exten)
Definition: pval.c:2978
void pvalStatementBlockAddStatement(pval *p, pval *statement)
Definition: pval.c:5480
Definition: pval.h:30
Definition: pval.h:23
void set_priorities(struct ael_extension *exten)
Definition: pval.c:4187
void pvalIncludesAddInclude(pval *p, const char *include)
Definition: pval.c:5396
int check_app_args(pval *appcall, pval *arglist, struct argapp *app)
Definition: pval.c:2130
pval * pvalMacroWalkArgs(pval *p, pval **arg)
Definition: pval.c:5105
struct pval * prev
Definition: pval.h:97
struct argapp * next
Definition: pval.h:112
void pvalCasePatDefAddStatement(pval *p, pval *statement)
Definition: pval.c:5303
void pvalMacroAddStatement(pval *p, pval *statement)
Definition: pval.c:5117
int is_empty(char *arg)
Definition: pval.c:1981
struct pval * find_macro(char *name)
Definition: pval.c:1943
pval * pvalStatementBlockWalkStatements(pval *p, pval **next_statement)
Definition: pval.c:5487
pval * pvalForGetStatement(pval *p)
Definition: pval.c:5654
struct pval * next
Definition: pval.h:93
void pvalSwitchAddCase(pval *p, pval *Case)
Definition: pval.c:5770
void pvalMacroCallSetArglist(pval *p, pval *arglist)
Definition: pval.c:5217
void pvalExtenSetHints(pval *p, char *hints)
Definition: pval.c:5830
int pvalCheckType(pval *p, char *funcname, pvaltype type)
Definition: pval.c:5031
void pvalAppCallSetArglist(pval *p, pval *arglist)
Definition: pval.c:5261
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
Evaluate the given expression.
Definition: ast_expr2f.c:2405
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
Definition: pval.h:27
struct pval * for_statements
Definition: pval.h:89
char * pvalForGetTest(pval *p)
Definition: pval.c:5640
void linkprio(struct ael_extension *exten, struct ael_priority *prio, struct ael_extension *mother_exten)
Definition: pval.c:2936
void pvalCatchSetExtName(pval *p, char *name)
Definition: pval.c:5322
pval * pvalExtenGetStatement(pval *p)
Definition: pval.c:5851
void pvalMacroCallSetMacroName(pval *p, char *name)
Definition: pval.c:5203
static const char app[]
Definition: app_mysql.c:62
pval * pvalContextWalkStatements(pval *p, pval **statements)
Definition: pval.c:5190
int endline
Definition: pval.h:52
int startcol
Definition: pval.h:53
void pvalForSetInc(pval *p, char *inc)
Definition: pval.c:5619
ast_context: An extension context - must remain in sync with fake_context
Definition: pbx.c:284
char * pvalForGetInit(pval *p)
Definition: pval.c:5633
Definition: pval.h:26
char * for_init
Definition: pval.h:62
Definition: pval.h:16
struct pval * macro_statements
Definition: pval.h:79
union pval::@288 u4
union pval::@286 u2
void pvalContextAddStatement(pval *p, pval *statement)
Definition: pval.c:5180
void pvalIfTimeGetCondition(pval *p, char **hour_range, char **dow_range, char **dom_range, char **month_range)
Definition: pval.c:5712