Asterisk - The Open Source Telephony Project GIT-master-d856a3e
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
6typedef enum
7{
8 PV_WORD, /* an ident, string, name, label, etc. A user-supplied string. */ /* 0 */
9 PV_MACRO, /* 1 */
10 PV_CONTEXT, /* 2 */
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 */
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
48struct pval
49{
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
101typedef 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 */
110struct argapp
111{
112 struct argapp *next;
113};
114
115#endif
116
117struct ast_context;
118
119#ifdef AAL_ARGCHECK
120int option_matches_j( struct argdesc *should, pval *is, struct argapp *app);
121int option_matches( struct argdesc *should, pval *is, struct argapp *app);
122int ael_is_funcname(char *name);
123#endif
124
127int check_app_args(pval *appcall, pval *arglist, struct argapp *app);
128void check_pval(pval *item, struct argapp *apps, int in_globals);
129void check_pval_item(pval *item, struct argapp *apps, int in_globals);
130void check_switch_expr(pval *item, struct argapp *apps);
131void ast_expr_register_extra_error_info(char *errmsg);
133int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan);
134struct pval *find_macro(char *name);
135struct pval *find_context(char *name);
136struct pval *find_context(char *name);
137struct pval *find_macro(char *name);
138struct ael_priority *new_prio(void);
139struct ael_extension *new_exten(void);
140void linkprio(struct ael_extension *exten, struct ael_priority *prio, struct ael_extension *mother_exten);
141void destroy_extensions(struct ael_extension *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 ); */
144void set_priorities(struct ael_extension *exten);
145void add_extensions(struct ael_extension *exten);
146int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *local_table, struct pval *root);
147void destroy_pval(pval *item);
149int is_float(char *arg );
150int is_int(char *arg );
151int is_empty(char *arg);
152
153/* PVAL PI */
154
155
158
159void pvalWordSetString( pval *p, char *str);
160char *pvalWordGetString( pval *p );
161
162void pvalMacroSetName( pval *p, char *name);
163char *pvalMacroGetName( pval *p );
164void pvalMacroSetArglist( pval *p, pval *arglist );
165void pvalMacroAddArg( pval *p, pval *arg );
166pval *pvalMacroWalkArgs( pval *p, pval **arg );
167void pvalMacroAddStatement( pval *p, pval *statement );
168pval *pvalMacroWalkStatements( pval *p, pval **next_statement );
169
170void pvalContextSetName( pval *p, char *name);
171char *pvalContextGetName( pval *p );
175void pvalContextAddStatement( pval *p, pval *statement);
176pval *pvalContextWalkStatements( pval *p, pval **statements );
177
178void pvalMacroCallSetMacroName( pval *p, char *name );
180void pvalMacroCallSetArglist( pval *p, pval *arglist );
181void pvalMacroCallAddArg( pval *p, pval *arg );
183
184void pvalAppCallSetAppName( pval *p, char *name );
185char* pvalAppCallGetAppName( pval *p );
186void pvalAppCallSetArglist( pval *p, pval *arglist );
187void pvalAppCallAddArg( pval *p, pval *arg );
189
190void pvalCasePatSetVal( pval *p, char *val );
191char* pvalCasePatGetVal( pval *p );
192void pvalCasePatDefAddStatement( pval *p, pval *statement );
193pval *pvalCasePatDefWalkStatements( pval *p, pval **statement );
194
195void pvalCatchSetExtName( pval *p, char *name );
196char* pvalCatchGetExtName( pval *p );
197void pvalCatchSetStatement( pval *p, pval *statement );
199
200void pvalSwitchesAddSwitch( pval *p, char *name );
202void pvalESwitchesAddSwitch( pval *p, char *name );
204
205void pvalIncludesAddInclude( pval *p, const char *include );
206
207void pvalIncludesAddIncludeWithTimeConstraints( pval *p, const char *include, char *hour_range, char *dom_range, char *dow_range, char *month_range );
208void pvalIncludeGetTimeConstraints( pval *p, char **hour_range, char **dom_range, char **dow_range, char **month_range );
209char* pvalIncludesWalk( pval *p, pval **next_item );
210
211void pvalStatementBlockAddStatement( pval *p, pval *statement);
212pval *pvalStatementBlockWalkStatements( pval *p, pval **next_statement);
213
214void pvalVarDecSetVarname( pval *p, char *name );
215void pvalVarDecSetValue( pval *p, char *value );
216char* pvalVarDecGetVarname( pval *p );
217char* pvalVarDecGetValue( pval *p );
218
219void pvalGotoSetTarget( pval *p, char *context, char *exten, char *label );
220void pvalGotoGetTarget( pval *p, char **context, char **exten, char **label );
221
222void pvalLabelSetName( pval *p, char *name );
223char* pvalLabelGetName( pval *p );
224
225void pvalForSetInit( pval *p, char *init );
226void pvalForSetTest( pval *p, char *test );
227void pvalForSetInc( pval *p, char *inc );
228void pvalForSetStatement( pval *p, pval *statement );
229char* pvalForGetInit( pval *p );
230char* pvalForGetTest( pval *p );
231char* pvalForGetInc( pval *p );
233
234
235void pvalIfSetCondition( pval *p, char *expr );
236char* pvalIfGetCondition( pval *p );
237void 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 */
238void pvalIfTimeGetCondition( pval *p, char **hour_range, char **dow_range, char **dom_range, char **month_range );
239void pvalRandomSetCondition( pval *p, char *percent );
240char* pvalRandomGetCondition( pval *p );
241void pvalConditionalSetThenStatement( pval *p, pval *statement );
242void pvalConditionalSetElseStatement( pval *p, pval *statement );
245
246void pvalSwitchSetTestexpr( pval *p, char *expr );
247char* pvalSwitchGetTestexpr( pval *p );
248void pvalSwitchAddCase( pval *p, pval *Case );
249pval* pvalSwitchWalkCases( pval *p, pval **next_case );
250
251void pvalExtenSetName( pval *p, char *name );
252char *pvalExtenGetName( pval *p );
253void pvalExtenSetRegexten( pval *p );
255int pvalExtenGetRegexten( pval *p );
256void pvalExtenSetHints( pval *p, char *hints );
257char* pvalExtenGetHints( pval *p );
258void pvalExtenSetStatement( pval *p, pval *statement );
260
261void pvalIgnorePatSetPattern( pval *p, char *pat );
262char* pvalIgnorePatGetPattern( pval *p );
263
264void pvalGlobalsAddStatement( pval *p, pval *statement );
265pval* pvalGlobalsWalkStatements( pval *p, pval **next_statement );
266
267void pvalTopLevAddObject( pval *p, pval *contextOrObj );
268pval* pvalTopLevWalkObjects( pval *p, pval **next_obj );
269
270int pvalCheckType( pval *p, char *funcname, pvaltype type );
271
272
273#endif
static const char app[]
Definition: app_adsiprog.c:56
const char * str
Definition: app_jack.c:147
static const char type[]
Definition: chan_ooh323.c:109
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static const char name[]
Definition: format_mp3.c:68
static struct ast_context * local_contexts
Definition: pbx_config.c:113
static struct ast_hashtab * local_table
Definition: pbx_config.c:114
int ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *local_table, struct pval *root)
Definition: pval.c:4413
void check_switch_expr(pval *item, struct argapp *apps)
Definition: pval.c:2184
void pvalStatementBlockAddStatement(pval *p, pval *statement)
Definition: pval.c:5480
int pvalCheckType(pval *p, char *funcname, pvaltype type)
Definition: pval.c:5031
char * pvalLabelGetName(pval *p)
Definition: pval.c:5597
void pvalExtenSetRegexten(pval *p)
Definition: pval.c:5809
int count_labels_in_current_context(char *label)
void pvalIncludesAddIncludeWithTimeConstraints(pval *p, const char *include, char *hour_range, char *dom_range, char *dow_range, char *month_range)
Definition: pval.c:5407
struct ael_priority * new_prio(void)
Definition: pval.c:2924
char * pvalESwitchesWalkNames(pval *p, pval **next_item)
Definition: pval.c:5383
char * pvalForGetTest(pval *p)
Definition: pval.c:5640
void pvalContextAddStatement(pval *p, pval *statement)
Definition: pval.c:5180
void pvalMacroSetArglist(pval *p, pval *arglist)
Definition: pval.c:5087
void pvalContextUnsetAbstract(pval *p)
Definition: pval.c:5164
void pvalIfSetCondition(pval *p, char *expr)
Definition: pval.c:5663
void pvalESwitchesAddSwitch(pval *p, char *name)
Definition: pval.c:5373
char * pvalSwitchesWalkNames(pval *p, pval **next_item)
Definition: pval.c:5361
void destroy_pval_item(pval *item)
Definition: pval.c:4672
void pvalExtenSetName(pval *p, char *name)
Definition: pval.c:5795
char * pvalIgnorePatGetPattern(pval *p)
Definition: pval.c:5866
void pvalMacroAddStatement(pval *p, pval *statement)
Definition: pval.c:5117
int is_empty(char *arg)
Definition: pval.c:1981
pval * pvalConditionalGetThenStatement(pval *p)
Definition: pval.c:5746
char * pvalForGetInit(pval *p)
Definition: pval.c:5633
pval * pvalCreateNode(pvaltype type)
Definition: pval.c:5042
char * pvalIncludesWalk(pval *p, pval **next_item)
Definition: pval.c:5467
void pvalGotoGetTarget(pval *p, char **context, char **exten, char **label)
Definition: pval.c:5563
void check_pval_item(pval *item, struct argapp *apps, int in_globals)
Definition: pval.c:2357
char * pvalCatchGetExtName(pval *p)
Definition: pval.c:5329
void pvalForSetInit(pval *p, char *init)
Definition: pval.c:5605
char * pvalContextGetName(pval *p)
Definition: pval.c:5150
void pvalMacroCallSetMacroName(pval *p, char *name)
Definition: pval.c:5203
char * pvalIfGetCondition(pval *p)
Definition: pval.c:5670
char * pvalMacroCallGetMacroName(pval *p)
Definition: pval.c:5210
char * pvalVarDecGetVarname(pval *p)
Definition: pval.c:5513
pval * pvalGlobalsWalkStatements(pval *p, pval **next_statement)
Definition: pval.c:5887
pval * pvalMacroWalkStatements(pval *p, pval **next_statement)
Definition: pval.c:5129
struct pval * find_macro(char *name)
Definition: pval.c:1943
void pvalSwitchesAddSwitch(pval *p, char *name)
Definition: pval.c:5351
pval * pvalStatementBlockWalkStatements(pval *p, pval **next_statement)
Definition: pval.c:5487
void pvalCasePatDefAddStatement(pval *p, pval *statement)
Definition: pval.c:5303
void pvalMacroAddArg(pval *p, pval *arg)
Definition: pval.c:5094
void pvalIncludeGetTimeConstraints(pval *p, char **hour_range, char **dom_range, char **dow_range, char **month_range)
Definition: pval.c:5450
pval * pvalAppCallWalkArgs(pval *p, pval **args)
Definition: pval.c:5278
pval * pvalCatchGetStatement(pval *p)
Definition: pval.c:5343
int check_app_args(pval *appcall, pval *arglist, struct argapp *app)
Definition: pval.c:2130
char * pvalForGetInc(pval *p)
Definition: pval.c:5647
void pvalAppCallAddArg(pval *p, pval *arg)
Definition: pval.c:5268
pval * pvalConditionalGetElseStatement(pval *p)
Definition: pval.c:5751
void pvalRandomSetCondition(pval *p, char *percent)
Definition: pval.c:5722
int is_float(char *arg)
Definition: pval.c:1963
void pvalExtenSetStatement(pval *p, pval *statement)
Definition: pval.c:5844
void pvalExtenSetHints(pval *p, char *hints)
Definition: pval.c:5830
void set_priorities(struct ael_extension *exten)
Definition: pval.c:4187
char * pvalMacroGetName(pval *p)
Definition: pval.c:5080
void ast_expr_clear_extra_error_info(void)
Definition: ast_expr2f.c:2469
pval * pvalContextWalkStatements(pval *p, pval **statements)
Definition: pval.c:5190
void pvalIgnorePatSetPattern(pval *p, char *pat)
Definition: pval.c:5859
int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
Evaluate the given expression.
Definition: ast_expr2f.c:2391
void pvalVarDecSetValue(pval *p, char *value)
Definition: pval.c:5506
char * pvalExtenGetHints(pval *p)
Definition: pval.c:5837
pvaltype pvalObjectGetType(pval *p)
Definition: pval.c:5052
void pvalForSetTest(pval *p, char *test)
Definition: pval.c:5612
void pvalConditionalSetThenStatement(pval *p, pval *statement)
Definition: pval.c:5736
pvaltype
Definition: pval.h:7
@ PV_CATCH
Definition: pval.h:16
@ PV_WORD
Definition: pval.h:8
@ PV_GLOBALS
Definition: pval.h:35
@ PV_LOCALVARDEC
Definition: pval.h:36
@ PV_CONTEXT
Definition: pval.h:10
@ PV_DEFAULT
Definition: pval.h:15
@ PV_INCLUDES
Definition: pval.h:19
@ PV_MACRO
Definition: pval.h:9
@ PV_SWITCHES
Definition: pval.h:17
@ PV_IGNOREPAT
Definition: pval.h:34
@ PV_CASE
Definition: pval.h:13
@ PV_CONTINUE
Definition: pval.h:28
@ PV_SWITCH
Definition: pval.h:32
@ PV_BREAK
Definition: pval.h:26
@ PV_APPLICATION_CALL
Definition: pval.h:12
@ PV_IFTIME
Definition: pval.h:30
@ PV_PATTERN
Definition: pval.h:14
@ PV_RETURN
Definition: pval.h:27
@ PV_IF
Definition: pval.h:29
@ PV_VARDEC
Definition: pval.h:21
@ PV_MACRO_CALL
Definition: pval.h:11
@ PV_GOTO
Definition: pval.h:22
@ PV_LABEL
Definition: pval.h:23
@ PV_ESWITCHES
Definition: pval.h:18
@ PV_FOR
Definition: pval.h:24
@ PV_RANDOM
Definition: pval.h:31
@ PV_STATEMENTBLOCK
Definition: pval.h:20
@ PV_EXTENSION
Definition: pval.h:33
@ PV_WHILE
Definition: pval.h:25
void check_pval(pval *item, struct argapp *apps, int in_globals)
Definition: pval.c:2865
void pvalSwitchAddCase(pval *p, pval *Case)
Definition: pval.c:5770
struct ael_extension * new_exten(void)
Definition: pval.c:2930
struct pval * find_context(char *name)
Definition: pval.c:1953
void pvalLabelSetName(pval *p, char *name)
Definition: pval.c:5590
int do_pbx_load_module(void)
void pvalCatchSetExtName(pval *p, char *name)
Definition: pval.c:5322
void pvalContextSetAbstract(pval *p)
Definition: pval.c:5157
pval * pvalTopLevWalkObjects(pval *p, pval **next_obj)
Definition: pval.c:5910
void destroy_pval(pval *item)
Definition: pval.c:4940
void destroy_extensions(struct ael_extension *exten)
Definition: pval.c:2978
void pvalIncludesAddInclude(pval *p, const char *include)
Definition: pval.c:5396
pval * pvalExtenGetStatement(pval *p)
Definition: pval.c:5851
void pvalGotoSetTarget(pval *p, char *context, char *exten, char *label)
Definition: pval.c:5527
pval * pvalMacroWalkArgs(pval *p, pval **arg)
Definition: pval.c:5105
void pvalVarDecSetVarname(pval *p, char *name)
Definition: pval.c:5499
void pvalCatchSetStatement(pval *p, pval *statement)
Definition: pval.c:5336
void linkprio(struct ael_extension *exten, struct ael_priority *prio, struct ael_extension *mother_exten)
Definition: pval.c:2936
void pvalIfTimeSetCondition(pval *p, char *hour_range, char *dow_range, char *dom_range, char *mon_range)
Definition: pval.c:5677
int pvalExtenGetRegexten(pval *p)
Definition: pval.c:5823
char * pvalWordGetString(pval *p)
Definition: pval.c:5065
void pvalForSetInc(pval *p, char *inc)
Definition: pval.c:5619
void pvalForSetStatement(pval *p, pval *statement)
Definition: pval.c:5626
char * pvalSwitchGetTestexpr(pval *p)
Definition: pval.c:5763
pval * pvalSwitchWalkCases(pval *p, pval **next_case)
Definition: pval.c:5782
void pvalIfTimeGetCondition(pval *p, char **hour_range, char **dow_range, char **dom_range, char **month_range)
Definition: pval.c:5712
pval * pvalForGetStatement(pval *p)
Definition: pval.c:5654
void pvalMacroCallSetArglist(pval *p, pval *arglist)
Definition: pval.c:5217
char * pvalExtenGetName(pval *p)
Definition: pval.c:5802
void add_extensions(struct ael_extension *exten)
Definition: pval.c:4213
void pvalConditionalSetElseStatement(pval *p, pval *statement)
Definition: pval.c:5741
int pvalContextGetAbstract(pval *p)
Definition: pval.c:5171
void pvalAppCallSetAppName(pval *p, char *name)
Definition: pval.c:5247
void pvalMacroSetName(pval *p, char *name)
Definition: pval.c:5073
char * pvalVarDecGetValue(pval *p)
Definition: pval.c:5520
void pvalWordSetString(pval *p, char *str)
Definition: pval.c:5058
void pvalGlobalsAddStatement(pval *p, pval *statement)
Definition: pval.c:5874
void pvalContextSetName(pval *p, char *name)
Definition: pval.c:5143
char * pvalAppCallGetAppName(pval *p)
Definition: pval.c:5254
void pvalCasePatSetVal(pval *p, char *val)
Definition: pval.c:5291
void pvalSwitchSetTestexpr(pval *p, char *expr)
Definition: pval.c:5756
int is_int(char *arg)
Definition: pval.c:1972
pval * pvalCasePatDefWalkStatements(pval *p, pval **statement)
Definition: pval.c:5311
char * pvalCasePatGetVal(pval *p)
Definition: pval.c:5298
char * pvalRandomGetCondition(pval *p)
Definition: pval.c:5729
void pvalTopLevAddObject(pval *p, pval *contextOrObj)
Definition: pval.c:5901
void pvalAppCallSetArglist(pval *p, pval *arglist)
Definition: pval.c:5261
pval * pvalMacroCallWalkArgs(pval *p, pval **args)
Definition: pval.c:5234
void ast_expr_register_extra_error_info(char *errmsg)
Definition: ast_expr2f.c:2463
void pvalExtenUnSetRegexten(pval *p)
Definition: pval.c:5816
void pvalMacroCallAddArg(pval *p, pval *arg)
Definition: pval.c:5224
static char next_item(const char *format)
Definition: say.c:4667
Registered applications container.
Definition: pbx_app.c:67
Definition: pval.h:111
struct argapp * next
Definition: pval.h:112
Main Channel structure associated with a channel.
ast_context: An extension context
Definition: pbx.c:284
Definition: pval.h:49
struct pval * u1_last
Definition: pval.h:64
struct pval * extend
Definition: pval.h:84
struct pval * arglist
Definition: pval.h:68
struct pval * prev
Definition: pval.h:97
char * val
Definition: pval.h:70
struct pval * dad
Definition: pval.h:96
int endline
Definition: pval.h:52
int goto_target_in_case
Definition: pval.h:82
struct pval * next
Definition: pval.h:93
char * for_init
Definition: pval.h:62
int startcol
Definition: pval.h:53
int abstract
Definition: pval.h:80
struct pval * goto_target
Definition: pval.h:72
struct pval * for_statements
Definition: pval.h:89
int endcol
Definition: pval.h:54
struct pval * else_statements
Definition: pval.h:78
char * hints
Definition: pval.h:81
char * for_inc
Definition: pval.h:77
struct pval * statements
Definition: pval.h:61
struct pval * macro_statements
Definition: pval.h:79
union pval::@248 u3
union pval::@246 u1
char * str
Definition: pval.h:59
union pval::@247 u2
union pval::@249 u4
struct ael_extension * compiled_label
Definition: pval.h:83
pvaltype type
Definition: pval.h:50
char * filename
Definition: pval.h:55
int regexten
Definition: pval.h:90
struct pval * list
Definition: pval.h:60
char * for_test
Definition: pval.h:71
int startline
Definition: pval.h:51
Definition: ast_expr2.c:325
int value
Definition: syslog.c:37
static struct aco_type item
Definition: test_config.c:1463
const char * args