Thu Oct 8 21:55:52 2009

Asterisk developer's documentation


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 1=abstract; 2=extend; 3=both */
00101       char *hints; /* used in EXTENSION */
00102       int goto_target_in_case; /* used in GOTO */
00103       struct ael_extension *compiled_label;
00104       struct pval *extend; /* to link extended contexts to the 'original' */
00105    } u3;
00106    
00107    union
00108    {
00109       struct pval *for_statements; /* used in PV_FOR */
00110       int regexten;                /* used in EXTENSION */
00111    } u4;
00112    
00113    struct pval *next; /* the pval at the end of this ptr will ALWAYS be of the same type as this one! 
00114                     EXCEPT for objects of the different types, that are in the same list, like contexts & macros, etc */
00115    
00116    struct pval *dad; /* the 'container' of this struct instance */
00117    struct pval *prev; /* the opposite of the 'next' pointer */
00118 } ;
00119 
00120 
00121 typedef struct pval pval;
00122 
00123 #if 0
00124 pval *npval(pvaltype type, int first_line, int last_line, int first_column, int last_column);
00125 void linku1(pval *head, pval *tail);
00126 void print_pval_list(FILE *f, pval *item, int depth);
00127 void print_pval(FILE *f, pval *item, int depth);
00128 void ael2_semantic_check(pval *item, int *errs, int *warns, int *notes);
00129 struct pval *find_label_in_current_context(char *exten, char *label);
00130 struct pval *find_label_in_current_extension(char *label);
00131 int count_labels_in_current_context(char *label);
00132 struct pval *find_label_in_current_db(char *context, char *exten, char *label);
00133 void ael2_print(char *fname, pval *tree);
00134 #endif
00135 struct pval *ael2_parse(char *fname, int *errs);   /* in ael.flex */
00136 void destroy_pval(pval *item);
00137 
00138 extern char *prev_word; /* in ael.flex */
00139 
00140 #ifndef YY_TYPEDEF_YY_SCANNER_T
00141 #define YY_TYPEDEF_YY_SCANNER_T
00142 typedef void* yyscan_t;
00143 #endif
00144 
00145 /* for passing info into and out of yyparse */
00146 struct parse_io
00147 {
00148    struct pval *pval; /* yyparse will set this to point to the parse tree */
00149    yyscan_t scanner;       /* yylex needs a scanner. Set it up, and pass it in */
00150    int syntax_error_count;  /* the count of syntax errors encountered */
00151 };
00152 
00153 /* for CODE GENERATION */
00154    
00155 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;
00156 
00157 
00158 struct ael_priority
00159 {
00160    int priority_num;
00161    ael_priority_type type;
00162    
00163    char *app;
00164    char *appargs;
00165    
00166    struct pval *origin;
00167    struct ael_extension *exten;
00168    
00169    struct ael_priority *goto_true;
00170    struct ael_priority *goto_false;
00171    struct ael_priority *next;
00172 };
00173 
00174 struct ael_extension
00175 {
00176    char *name;
00177    char *cidmatch;
00178    char *hints;
00179    int regexten;
00180    int is_switch;
00181    int has_switch;
00182    
00183    struct ast_context *context;
00184    
00185    struct ael_priority *plist;
00186    struct ael_priority *plist_last;
00187    struct ael_extension *next_exten;
00188 
00189    struct ael_priority *loop_break;  /* set by latest loop for breaks */
00190    struct ael_priority *loop_continue; /* set by lastest loop for continuing */
00191    struct ael_priority *return_target;
00192    int return_needed;
00193 };
00194 
00195 #endif /* _ASTERISK_AEL_STRUCTS_H */

Generated on Thu Oct 8 21:55:52 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6