Properly play a holdtime message if the announce-holdtime option is
[asterisk-bristuff.git] / include / asterisk / ael_structs.h
blob01a4244e1f080c96c98997bc1a1ab0a0cd809c36
1 #ifndef _ASTERISK_AEL_STRUCTS_H
2 #define _ASTERISK_AEL_STRUCTS_H
4 #if !defined(SOLARIS) && !defined(__CYGWIN__)
5 /* #include <err.h> */
6 #else
7 #define quad_t int64_t
8 #endif
10 #if defined(LONG_LONG_MIN) && !defined(QUAD_MIN)
11 #define QUAD_MIN LONG_LONG_MIN
12 #endif
13 #if defined(LONG_LONG_MAX) && !defined(QUAD_MAX)
14 #define QUAD_MAX LONG_LONG_MAX
15 #endif
17 # if ! defined(QUAD_MIN)
18 # define QUAD_MIN (-0x7fffffffffffffffLL-1)
19 # endif
20 # if ! defined(QUAD_MAX)
21 # define QUAD_MAX (0x7fffffffffffffffLL)
22 # endif
25 typedef enum
27 PV_WORD, /* an ident, string, name, label, etc. A user-supplied string. */ /* 0 */
28 PV_MACRO, /* 1 */
29 PV_CONTEXT, /* 2 */
30 PV_MACRO_CALL, /* 3 */
31 PV_APPLICATION_CALL, /* 4 */
32 PV_CASE, /* 5 */
33 PV_PATTERN, /* 6 */
34 PV_DEFAULT, /* 7 */
35 PV_CATCH, /* 8 */
36 PV_SWITCHES, /* 9 */
37 PV_ESWITCHES, /* 10 */
38 PV_INCLUDES, /* 11 */
39 PV_STATEMENTBLOCK, /* 12 */
40 PV_VARDEC, /* you know, var=val; */ /* 13 */
41 PV_GOTO, /* 14 */
42 PV_LABEL, /* 15 */
43 PV_FOR, /* 16 */
44 PV_WHILE, /* 17 */
45 PV_BREAK, /* 18 */
46 PV_RETURN, /* 19 */
47 PV_CONTINUE, /* 20 */
48 PV_IF, /* 21 */
49 PV_IFTIME, /* 22 */
50 PV_RANDOM, /* 23 */
51 PV_SWITCH, /* 24 */
52 PV_EXTENSION, /* 25 */
53 PV_IGNOREPAT, /* 26 */
54 PV_GLOBALS, /* 27 */
56 } pvaltype;
58 /* why this horrible mess? It's always been a tradeoff-- tons of structs,
59 each storing it's specific lists of goodies, or a 'simple' single struct,
60 with lots of fields, that catches all uses at once. Either you have a long
61 list of struct names and subnames, or you have a long list of field names,
62 and where/how they are used. I'm going with a single struct, using unions
63 to reduce storage. Some simple generalizations, and a long list of types,
64 and a book about what is used with what types.... Sorry!
67 struct pval
69 pvaltype type;
70 int startline;
71 int endline;
72 int startcol;
73 int endcol;
74 char *filename;
76 union
78 char *str; /* wow, used almost everywhere! */
79 struct pval *list; /* used in SWITCHES, ESWITCHES, INCLUDES, STATEMENTBLOCK, GOTO */
80 struct pval *statements;/* used in EXTENSION */
81 char *for_init; /* used in FOR */
82 } u1;
83 struct pval *u1_last; /* to build in-order lists -- looks like we only need one */
85 union
87 struct pval *arglist; /* used in macro_call, application_call, MACRO def, also attached to PWORD, the 4 timevals for includes */
88 struct pval *statements; /* used in case, default, catch, while's statement, CONTEXT elements, GLOBALS */
89 char *val; /* used in VARDEC */
90 char *for_test; /* used in FOR */
91 int label_in_case; /* a boolean for LABELs */
92 struct pval *goto_target; /* used in GOTO */
93 } u2;
95 union
97 char *for_inc; /* used in FOR */
98 struct pval *else_statements; /* used in IF */
99 struct pval *macro_statements; /* used in MACRO */
100 int abstract; /* used for context 1=abstract; 2=extend; 3=both */
101 char *hints; /* used in EXTENSION */
102 int goto_target_in_case; /* used in GOTO */
103 struct ael_extension *compiled_label;
104 struct pval *extend; /* to link extended contexts to the 'original' */
105 } u3;
107 union
109 struct pval *for_statements; /* used in PV_FOR */
110 int regexten; /* used in EXTENSION */
111 } u4;
113 struct pval *next; /* the pval at the end of this ptr will ALWAYS be of the same type as this one!
114 EXCEPT for objects of the different types, that are in the same list, like contexts & macros, etc */
116 struct pval *dad; /* the 'container' of this struct instance */
117 struct pval *prev; /* the opposite of the 'next' pointer */
121 typedef struct pval pval;
123 #if 0
124 pval *npval(pvaltype type, int first_line, int last_line, int first_column, int last_column);
125 void linku1(pval *head, pval *tail);
126 void print_pval_list(FILE *f, pval *item, int depth);
127 void print_pval(FILE *f, pval *item, int depth);
128 void ael2_semantic_check(pval *item, int *errs, int *warns, int *notes);
129 struct pval *find_label_in_current_context(char *exten, char *label);
130 struct pval *find_label_in_current_extension(char *label);
131 int count_labels_in_current_context(char *label);
132 struct pval *find_label_in_current_db(char *context, char *exten, char *label);
133 void ael2_print(char *fname, pval *tree);
134 #endif
135 struct pval *ael2_parse(char *fname, int *errs); /* in ael.flex */
136 void destroy_pval(pval *item);
138 extern char *prev_word; /* in ael.flex */
140 #ifndef YY_TYPEDEF_YY_SCANNER_T
141 #define YY_TYPEDEF_YY_SCANNER_T
142 typedef void* yyscan_t;
143 #endif
145 /* for passing info into and out of yyparse */
146 struct parse_io
148 struct pval *pval; /* yyparse will set this to point to the parse tree */
149 yyscan_t scanner; /* yylex needs a scanner. Set it up, and pass it in */
150 int syntax_error_count; /* the count of syntax errors encountered */
153 /* for CODE GENERATION */
155 typedef enum { AEL_APPCALL, AEL_CONTROL1, AEL_FOR_CONTROL, AEL_IF_CONTROL, AEL_IFTIME_CONTROL, AEL_RAND_CONTROL, AEL_LABEL, AEL_RETURN } ael_priority_type;
158 struct ael_priority
160 int priority_num;
161 ael_priority_type type;
163 char *app;
164 char *appargs;
166 struct pval *origin;
167 struct ael_extension *exten;
169 struct ael_priority *goto_true;
170 struct ael_priority *goto_false;
171 struct ael_priority *next;
174 struct ael_extension
176 char *name;
177 char *cidmatch;
178 char *hints;
179 int regexten;
180 int is_switch;
181 int has_switch;
183 struct ast_context *context;
185 struct ael_priority *plist;
186 struct ael_priority *plist_last;
187 struct ael_extension *next_exten;
189 struct ael_priority *loop_break; /* set by latest loop for breaks */
190 struct ael_priority *loop_continue; /* set by lastest loop for continuing */
191 struct ael_priority *return_target;
192 int return_needed;
195 #endif /* _ASTERISK_AEL_STRUCTS_H */