![]() |
Home page |
Mailing list |
Docs
Asterisk developer's documentation :: Codename Pineapple
ael_structs.h
Go to the documentation of this file.
00001 #ifndef _ASTERISK_AEL_STRUCTS_H 00002 #define _ASTERISK_AEL_STRUCTS_H 00003 00004 #if !defined(SOLARIS) && !defined(__CYGWIN__) 00005 /* #include <err.h> */ 00006 #else 00007 #define quad_t int64_t 00008 #endif 00009 00010 #if defined(LONG_LONG_MIN) && !defined(QUAD_MIN) 00011 #define QUAD_MIN LONG_LONG_MIN 00012 #endif 00013 #if defined(LONG_LONG_MAX) && !defined(QUAD_MAX) 00014 #define QUAD_MAX LONG_LONG_MAX 00015 #endif 00016 00017 # if ! defined(QUAD_MIN) 00018 # define QUAD_MIN (-0x7fffffffffffffffLL-1) 00019 # endif 00020 # if ! defined(QUAD_MAX) 00021 # define QUAD_MAX (0x7fffffffffffffffLL) 00022 # endif 00023 00024 00025 typedef enum 00026 { 00027 PV_WORD, /* an ident, string, name, label, etc. A user-supplied string. */ /* 0 */ 00028 PV_MACRO, /* 1 */ 00029 PV_CONTEXT, /* 2 */ 00030 PV_MACRO_CALL, /* 3 */ 00031 PV_APPLICATION_CALL, /* 4 */ 00032 PV_CASE, /* 5 */ 00033 PV_PATTERN, /* 6 */ 00034 PV_DEFAULT, /* 7 */ 00035 PV_CATCH, /* 8 */ 00036 PV_SWITCHES, /* 9 */ 00037 PV_ESWITCHES, /* 10 */ 00038 PV_INCLUDES, /* 11 */ 00039 PV_STATEMENTBLOCK, /* 12 */ 00040 PV_VARDEC, /* you know, var=val; */ /* 13 */ 00041 PV_GOTO, /* 14 */ 00042 PV_LABEL, /* 15 */ 00043 PV_FOR, /* 16 */ 00044 PV_WHILE, /* 17 */ 00045 PV_BREAK, /* 18 */ 00046 PV_RETURN, /* 19 */ 00047 PV_CONTINUE, /* 20 */ 00048 PV_IF, /* 21 */ 00049 PV_IFTIME, /* 22 */ 00050 PV_RANDOM, /* 23 */ 00051 PV_SWITCH, /* 24 */ 00052 PV_EXTENSION, /* 25 */ 00053 PV_IGNOREPAT, /* 26 */ 00054 PV_GLOBALS, /* 27 */ 00055 00056 } pvaltype; 00057 00058 /* why this horrible mess? It's always been a tradeoff-- tons of structs, 00059 each storing it's specific lists of goodies, or a 'simple' single struct, 00060 with lots of fields, that catches all uses at once. Either you have a long 00061 list of struct names and subnames, or you have a long list of field names, 00062 and where/how they are used. I'm going with a single struct, using unions 00063 to reduce storage. Some simple generalizations, and a long list of types, 00064 and a book about what is used with what types.... Sorry! 00065 */ 00066 00067 struct pval 00068 { 00069 pvaltype type; 00070 int startline; 00071 int endline; 00072 int startcol; 00073 int endcol; 00074 char *filename; 00075 00076 union 00077 { 00078 char *str; /* wow, used almost everywhere! */ 00079 struct pval *list; /* used in SWITCHES, ESWITCHES, INCLUDES, STATEMENTBLOCK, GOTO */ 00080 struct pval *statements;/* used in EXTENSION */ 00081 char *for_init; /* used in FOR */ 00082 } u1; 00083 struct pval *u1_last; /* to build in-order lists -- looks like we only need one */ 00084 00085 union 00086 { 00087 struct pval *arglist; /* used in macro_call, application_call, MACRO def, also attached to PWORD, the 4 timevals for includes */ 00088 struct pval *statements; /* used in case, default, catch, while's statement, CONTEXT elements, GLOBALS */ 00089 char *val; /* used in VARDEC */ 00090 char *for_test; /* used in FOR */ 00091 int label_in_case; /* a boolean for LABELs */ 00092 struct pval *goto_target; /* used in GOTO */ 00093 } u2; 00094 00095 union 00096 { 00097 char *for_inc; /* used in FOR */ 00098 struct pval *else_statements; /* used in IF */ 00099 struct pval *macro_statements; /* used in MACRO */ 00100 int abstract; /* used for context */ 00101 char *hints; /* used in EXTENSION */ 00102 int goto_target_in_case; /* used in GOTO */ 00103 struct ael_extension *compiled_label; 00104 } u3; 00105 00106 union 00107 { 00108 struct pval *for_statements; /* used in PV_FOR */ 00109 int regexten; /* used in EXTENSION */ 00110 } u4; 00111 00112 struct pval *next; /* the pval at the end of this ptr will ALWAYS be of the same type as this one! 00113 EXCEPT for objects of the different types, that are in the same list, like contexts & macros, etc */ 00114 00115 struct pval *dad; /* the 'container' of this struct instance */ 00116 struct pval *prev; /* the opposite of the 'next' pointer */ 00117 } ; 00118 00119 00120 typedef struct pval pval; 00121 00122 #if 0 00123 pval *npval(pvaltype type, int first_line, int last_line, int first_column, int last_column); 00124 void linku1(pval *head, pval *tail); 00125 void print_pval_list(FILE *f, pval *item, int depth); 00126 void print_pval(FILE *f, pval *item, int depth); 00127 void ael2_semantic_check(pval *item, int *errs, int *warns, int *notes); 00128 struct pval *find_label_in_current_context(char *exten, char *label); 00129 struct pval *find_label_in_current_extension(char *label); 00130 int count_labels_in_current_context(char *label); 00131 struct pval *find_label_in_current_db(char *context, char *exten, char *label); 00132 void ael2_print(char *fname, pval *tree); 00133 #endif 00134 struct pval *ael2_parse(char *fname, int *errs); /* in ael.flex */ 00135 void destroy_pval(pval *item); 00136 00137 extern char *prev_word; /* in ael.flex */ 00138 00139 #ifndef YY_TYPEDEF_YY_SCANNER_T 00140 #define YY_TYPEDEF_YY_SCANNER_T 00141 typedef void* yyscan_t; 00142 #endif 00143 00144 /* for passing info into and out of yyparse */ 00145 struct parse_io 00146 { 00147 struct pval *pval; /* yyparse will set this to point to the parse tree */ 00148 yyscan_t scanner; /* yylex needs a scanner. Set it up, and pass it in */ 00149 int syntax_error_count; /* the count of syntax errors encountered */ 00150 }; 00151 00152 /* for CODE GENERATION */ 00153 00154 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; 00155 00156 00157 struct ael_priority 00158 { 00159 int priority_num; 00160 ael_priority_type type; 00161 00162 char *app; 00163 char *appargs; 00164 00165 struct pval *origin; 00166 struct ael_extension *exten; 00167 00168 struct ael_priority *goto_true; 00169 struct ael_priority *goto_false; 00170 struct ael_priority *next; 00171 }; 00172 00173 struct ael_extension 00174 { 00175 char *name; 00176 char *cidmatch; 00177 char *hints; 00178 int regexten; 00179 00180 struct ast_context *context; 00181 00182 struct ael_priority *plist; 00183 struct ael_priority *plist_last; 00184 struct ael_extension *next_exten; 00185 00186 struct ael_priority *loop_break; /* set by latest loop for breaks */ 00187 struct ael_priority *loop_continue; /* set by lastest loop for continuing */ 00188 struct ael_priority *return_target; 00189 int return_needed; 00190 }; 00191 00192 #endif /* _ASTERISK_AEL_STRUCTS_H */