Fri Jul 24 00:41:01 2009

Asterisk developer's documentation


pval.h

Go to the documentation of this file.
00001 #ifndef _ASTERISK_PVAL_H
00002 #define _ASTERISK_PVAL_H
00003 
00004 /* whatever includes this, better include asterisk/lock.h and asterisk/hashtab.h */
00005 
00006 typedef enum 
00007 {
00008    PV_WORD, /* an ident, string, name, label, etc. A user-supplied string. */ /* 0 */
00009    PV_MACRO,             /* 1 */
00010    PV_CONTEXT,           /* 2 */
00011    PV_MACRO_CALL,        /* 3 */
00012    PV_APPLICATION_CALL,  /* 4 */
00013    PV_CASE,              /* 5 */
00014    PV_PATTERN,           /* 6 */
00015    PV_DEFAULT,           /* 7 */
00016    PV_CATCH,             /* 8 */
00017    PV_SWITCHES,          /* 9 */
00018    PV_ESWITCHES,         /* 10 */
00019    PV_INCLUDES,          /* 11 */
00020    PV_STATEMENTBLOCK,    /* 12 */
00021    PV_VARDEC, /* you know, var=val; */  /* 13 */
00022    PV_GOTO,              /* 14 */
00023    PV_LABEL,             /* 15 */
00024    PV_FOR,               /* 16 */
00025    PV_WHILE,             /* 17 */
00026    PV_BREAK,             /* 18 */
00027    PV_RETURN,            /* 19 */
00028    PV_CONTINUE,          /* 20 */
00029    PV_IF,                /* 21 */
00030    PV_IFTIME,            /* 22 */
00031    PV_RANDOM,            /* 23 */
00032    PV_SWITCH,            /* 24 */
00033    PV_EXTENSION,         /* 25 */
00034    PV_IGNOREPAT,         /* 26 */
00035    PV_GLOBALS,           /* 27 */
00036    PV_LOCALVARDEC,       /* 28 */
00037 } pvaltype;
00038 
00039 /* why this horrible mess? It's always been a tradeoff-- tons of structs,
00040    each storing it's specific lists of goodies, or a 'simple' single struct,
00041    with lots of fields, that catches all uses at once. Either you have a long
00042    list of struct names and subnames, or you have a long list of field names,
00043    and where/how they are used. I'm going with a single struct, using unions
00044    to reduce storage. Some simple generalizations, and a long list of types,
00045    and a book about what is used with what types.... Sorry!
00046 */
00047 
00048 struct pval
00049 {
00050    pvaltype type;
00051    int startline;
00052    int endline;
00053    int startcol;
00054    int endcol;
00055    char *filename;
00056    
00057    union
00058    {
00059       char *str; /* wow, used almost everywhere! */
00060       struct pval *list; /* used in SWITCHES, ESWITCHES, INCLUDES, STATEMENTBLOCK, GOTO */
00061       struct pval *statements;/*  used in EXTENSION */
00062       char *for_init;  /* used in FOR */
00063    } u1;
00064    struct pval *u1_last; /* to build in-order lists -- looks like we only need one */
00065    
00066    union
00067    {
00068       struct pval *arglist; /* used in macro_call, application_call, MACRO def, also attached to PWORD, the 4 timevals for includes  */
00069       struct pval *statements; /* used in case, default, catch, while's statement, CONTEXT elements, GLOBALS */
00070       char *val;  /* used in VARDEC */
00071       char *for_test; /* used in FOR */
00072       struct pval *goto_target;  /* used in GOTO */
00073    } u2;
00074    
00075    union
00076    {
00077       char *for_inc; /* used in FOR */
00078       struct pval *else_statements; /* used in IF */
00079       struct pval *macro_statements; /* used in MACRO */
00080       int abstract;  /* used for context 1=abstract; 2=extend; 3=both */
00081       char *hints; /* used in EXTENSION */
00082       int goto_target_in_case; /* used in GOTO */
00083       struct ael_extension *compiled_label;
00084       struct pval *extend; /* to link extended contexts to the 'original' */
00085    } u3;
00086    
00087    union
00088    {
00089       struct pval *for_statements; /* used in PV_FOR */
00090       int regexten;                /* used in EXTENSION */
00091    } u4;
00092    
00093    struct pval *next; /* the pval at the end of this ptr will ALWAYS be of the same type as this one! 
00094                     EXCEPT for objects of the different types, that are in the same list, like contexts & macros, etc */
00095    
00096    struct pval *dad; /* the 'container' of this struct instance */
00097    struct pval *prev; /* the opposite of the 'next' pointer */
00098 } ;
00099 
00100 
00101 typedef struct pval pval;
00102 
00103 #ifndef AAL_ARGCHECK
00104 /* for the time being, short circuit all the AAL related structures
00105    without permanently removing the code; after/during the AAL 
00106    development, this code can be properly re-instated 
00107 */
00108 
00109 /* null definitions for structs passed down the infrastructure */
00110 struct argapp
00111 {
00112    struct argapp *next;
00113 };
00114 
00115 #endif
00116 
00117 struct ast_context;
00118 
00119 #ifdef AAL_ARGCHECK
00120 int option_matches_j( struct argdesc *should, pval *is, struct argapp *app);
00121 int option_matches( struct argdesc *should, pval *is, struct argapp *app);
00122 int ael_is_funcname(char *name);
00123 #endif
00124 
00125 int do_pbx_load_module(void);
00126 int count_labels_in_current_context(char *label);
00127 int check_app_args(pval *appcall, pval *arglist, struct argapp *app);
00128 void check_pval(pval *item, struct argapp *apps, int in_globals);
00129 void check_pval_item(pval *item, struct argapp *apps, int in_globals);
00130 void check_switch_expr(pval *item, struct argapp *apps);
00131 void ast_expr_register_extra_error_info(char *errmsg);
00132 void ast_expr_clear_extra_error_info(void);
00133 int  ast_expr(char *expr, char *buf, int length, struct ast_channel *chan);
00134 struct pval *find_macro(char *name);
00135 struct pval *find_context(char *name);
00136 struct pval *find_context(char *name);
00137 struct pval *find_macro(char *name);
00138 struct ael_priority *new_prio(void);
00139 struct ael_extension *new_exten(void);
00140 void linkprio(struct ael_extension *exten, struct ael_priority *prio, struct ael_extension *mother_exten);
00141 void destroy_extensions(struct ael_extension *exten);
00142 /* static void linkexten(struct ael_extension *exten, struct ael_extension *add);
00143    static void gen_prios(struct ael_extension *exten, char *label, pval *statement, struct ael_extension *mother_exten, struct ast_context *context ); */
00144 void set_priorities(struct ael_extension *exten);
00145 void add_extensions(struct ael_extension *exten);
00146 void ast_compile_ael2(struct ast_context **local_contexts, struct ast_hashtab *local_table, struct pval *root);
00147 void destroy_pval(pval *item);
00148 void destroy_pval_item(pval *item);
00149 int is_float(char *arg );
00150 int is_int(char *arg );
00151 int is_empty(char *arg);
00152 
00153 /* PVAL PI */
00154 
00155 
00156 pval *pvalCreateNode( pvaltype type );
00157 pvaltype pvalObjectGetType( pval *p );
00158 
00159 void pvalWordSetString( pval *p, char *str);
00160 char *pvalWordGetString( pval *p );
00161 
00162 void pvalMacroSetName( pval *p, char *name);
00163 char *pvalMacroGetName( pval *p );
00164 void pvalMacroSetArglist( pval *p, pval *arglist );
00165 void pvalMacroAddArg( pval *p, pval *arg );
00166 pval *pvalMacroWalkArgs( pval *p, pval **arg );
00167 void pvalMacroAddStatement( pval *p, pval *statement );
00168 pval *pvalMacroWalkStatements( pval *p, pval **next_statement );
00169 
00170 void pvalContextSetName( pval *p, char *name);
00171 char *pvalContextGetName( pval *p );
00172 void pvalContextSetAbstract( pval *p );
00173 void pvalContextUnsetAbstract( pval *p );
00174 int  pvalContextGetAbstract( pval *p );
00175 void pvalContextAddStatement( pval *p, pval *statement);
00176 pval *pvalContextWalkStatements( pval *p, pval **statements );
00177 
00178 void pvalMacroCallSetMacroName( pval *p, char *name );
00179 char* pvalMacroCallGetMacroName( pval *p );
00180 void pvalMacroCallSetArglist( pval *p, pval *arglist );
00181 void pvalMacroCallAddArg( pval *p, pval *arg );
00182 pval *pvalMacroCallWalkArgs( pval *p, pval **args );
00183 
00184 void pvalAppCallSetAppName( pval *p, char *name );
00185 char* pvalAppCallGetAppName( pval *p );
00186 void pvalAppCallSetArglist( pval *p, pval *arglist );
00187 void pvalAppCallAddArg( pval *p, pval *arg );
00188 pval *pvalAppCallWalkArgs( pval *p, pval **args );
00189 
00190 void pvalCasePatSetVal( pval *p, char *val );
00191 char* pvalCasePatGetVal( pval *p );
00192 void pvalCasePatDefAddStatement( pval *p, pval *statement );
00193 pval *pvalCasePatDefWalkStatements( pval *p, pval **statement );
00194 
00195 void pvalCatchSetExtName( pval *p, char *name );
00196 char* pvalCatchGetExtName( pval *p );
00197 void pvalCatchSetStatement( pval *p, pval *statement );
00198 pval *pvalCatchGetStatement( pval *p );
00199 
00200 void pvalSwitchesAddSwitch( pval *p, char *name );
00201 char* pvalSwitchesWalkNames( pval *p, pval **next_item );
00202 void pvalESwitchesAddSwitch( pval *p, char *name );
00203 char* pvalESwitchesWalkNames( pval *p, pval **next_item );
00204 
00205 void pvalIncludesAddInclude( pval *p, const char *include );
00206 
00207 void pvalIncludesAddIncludeWithTimeConstraints( pval *p, const char *include, char *hour_range, char *dom_range, char *dow_range, char *month_range );
00208 void pvalIncludeGetTimeConstraints( pval *p, char **hour_range, char **dom_range, char **dow_range, char **month_range );
00209 char* pvalIncludesWalk( pval *p, pval **next_item );
00210 
00211 void pvalStatementBlockAddStatement( pval *p, pval *statement);
00212 pval *pvalStatementBlockWalkStatements( pval *p, pval **next_statement);
00213 
00214 void pvalVarDecSetVarname( pval *p, char *name );
00215 void pvalVarDecSetValue( pval *p, char *value );
00216 char* pvalVarDecGetVarname( pval *p );
00217 char* pvalVarDecGetValue( pval *p );
00218 
00219 void pvalGotoSetTarget( pval *p, char *context, char *exten, char *label );
00220 void pvalGotoGetTarget( pval *p, char **context, char **exten, char **label );
00221 
00222 void pvalLabelSetName( pval *p, char *name );
00223 char* pvalLabelGetName( pval *p );
00224 
00225 void pvalForSetInit( pval *p, char *init );
00226 void pvalForSetTest( pval *p, char *test );
00227 void pvalForSetInc( pval *p, char *inc );
00228 void pvalForSetStatement( pval *p, pval *statement );
00229 char* pvalForGetInit( pval *p );
00230 char* pvalForGetTest( pval *p );
00231 char* pvalForGetInc( pval *p );
00232 pval* pvalForGetStatement( pval *p );
00233 
00234 
00235 void pvalIfSetCondition( pval *p, char *expr );
00236 char* pvalIfGetCondition( pval *p );
00237 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 */
00238 void pvalIfTimeGetCondition( pval *p, char **hour_range, char **dow_range, char **dom_range, char **month_range );
00239 void pvalRandomSetCondition( pval *p, char *percent );
00240 char* pvalRandomGetCondition( pval *p );
00241 void pvalConditionalSetThenStatement( pval *p, pval *statement );
00242 void pvalConditionalSetElseStatement( pval *p, pval *statement );
00243 pval* pvalConditionalGetThenStatement( pval *p );
00244 pval* pvalConditionalGetElseStatement( pval *p );
00245 
00246 void pvalSwitchSetTestexpr( pval *p, char *expr );
00247 char* pvalSwitchGetTestexpr( pval *p );
00248 void pvalSwitchAddCase( pval *p, pval *Case );
00249 pval* pvalSwitchWalkCases( pval *p, pval **next_case );
00250 
00251 void pvalExtenSetName( pval *p, char *name );
00252 char *pvalExtenGetName( pval *p );
00253 void pvalExtenSetRegexten( pval *p );
00254 void pvalExtenUnSetRegexten( pval *p );
00255 int pvalExtenGetRegexten( pval *p );
00256 void pvalExtenSetHints( pval *p, char *hints );
00257 char* pvalExtenGetHints( pval *p );
00258 void pvalExtenSetStatement( pval *p, pval *statement );
00259 pval* pvalExtenGetStatement( pval *p );
00260 
00261 void pvalIgnorePatSetPattern( pval *p, char *pat );
00262 char* pvalIgnorePatGetPattern( pval *p );
00263 
00264 void pvalGlobalsAddStatement( pval *p, pval *statement );
00265 pval* pvalGlobalsWalkStatements( pval *p, pval **next_statement );
00266 
00267 void pvalTopLevAddObject( pval *p, pval *contextOrObj );
00268 pval* pvalTopLevWalkObjects( pval *p, pval **next_obj );
00269 
00270 int  pvalCheckType( pval *p, char *funcname, pvaltype type );
00271 
00272 
00273 #endif

Generated on Fri Jul 24 00:41:01 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7