Wed Nov 28 2012 04:19:17

Asterisk developer's documentation


pval.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  argapp
struct  pval

Typedefs

typedef struct pval pval

Enumerations

enum  pvaltype {
  PV_WORD, PV_MACRO, PV_CONTEXT, PV_MACRO_CALL,
  PV_APPLICATION_CALL, PV_CASE, PV_PATTERN, PV_DEFAULT,
  PV_CATCH, PV_SWITCHES, PV_ESWITCHES, PV_INCLUDES,
  PV_STATEMENTBLOCK, PV_VARDEC, PV_GOTO, PV_LABEL,
  PV_FOR, PV_WHILE, PV_BREAK, PV_RETURN,
  PV_CONTINUE, PV_IF, PV_IFTIME, PV_RANDOM,
  PV_SWITCH, PV_EXTENSION, PV_IGNOREPAT, PV_GLOBALS,
  PV_LOCALVARDEC
}

Functions

void add_extensions (struct ael_extension *exten)
int ast_compile_ael2 (struct ast_context **local_contexts, struct ast_hashtab *local_table, struct pval *root)
int ast_expr (char *expr, char *buf, int length, struct ast_channel *chan)
 Evaluate the given expression.
void ast_expr_clear_extra_error_info (void)
void ast_expr_register_extra_error_info (char *errmsg)
int check_app_args (pval *appcall, pval *arglist, struct argapp *app)
void check_pval (pval *item, struct argapp *apps, int in_globals)
void check_pval_item (pval *item, struct argapp *apps, int in_globals)
void check_switch_expr (pval *item, struct argapp *apps)
int count_labels_in_current_context (char *label)
void destroy_extensions (struct ael_extension *exten)
void destroy_pval (pval *item)
void destroy_pval_item (pval *item)
int do_pbx_load_module (void)
struct pval * find_context (char *name)
struct pval * find_macro (char *name)
int is_empty (char *arg)
int is_float (char *arg)
int is_int (char *arg)
void linkprio (struct ael_extension *exten, struct ael_priority *prio, struct ael_extension *mother_exten)
struct ael_extension * new_exten (void)
struct ael_priority * new_prio (void)
void pvalAppCallAddArg (pval *p, pval *arg)
char * pvalAppCallGetAppName (pval *p)
void pvalAppCallSetAppName (pval *p, char *name)
void pvalAppCallSetArglist (pval *p, pval *arglist)
pval * pvalAppCallWalkArgs (pval *p, pval **args)
void pvalCasePatDefAddStatement (pval *p, pval *statement)
pval * pvalCasePatDefWalkStatements (pval *p, pval **statement)
char * pvalCasePatGetVal (pval *p)
void pvalCasePatSetVal (pval *p, char *val)
char * pvalCatchGetExtName (pval *p)
pval * pvalCatchGetStatement (pval *p)
void pvalCatchSetExtName (pval *p, char *name)
void pvalCatchSetStatement (pval *p, pval *statement)
int pvalCheckType (pval *p, char *funcname, pvaltype type)
pval * pvalConditionalGetElseStatement (pval *p)
pval * pvalConditionalGetThenStatement (pval *p)
void pvalConditionalSetElseStatement (pval *p, pval *statement)
void pvalConditionalSetThenStatement (pval *p, pval *statement)
void pvalContextAddStatement (pval *p, pval *statement)
int pvalContextGetAbstract (pval *p)
char * pvalContextGetName (pval *p)
void pvalContextSetAbstract (pval *p)
void pvalContextSetName (pval *p, char *name)
void pvalContextUnsetAbstract (pval *p)
pval * pvalContextWalkStatements (pval *p, pval **statements)
pval * pvalCreateNode (pvaltype type)
void pvalESwitchesAddSwitch (pval *p, char *name)
char * pvalESwitchesWalkNames (pval *p, pval **next_item)
char * pvalExtenGetHints (pval *p)
char * pvalExtenGetName (pval *p)
int pvalExtenGetRegexten (pval *p)
pval * pvalExtenGetStatement (pval *p)
void pvalExtenSetHints (pval *p, char *hints)
void pvalExtenSetName (pval *p, char *name)
void pvalExtenSetRegexten (pval *p)
void pvalExtenSetStatement (pval *p, pval *statement)
void pvalExtenUnSetRegexten (pval *p)
char * pvalForGetInc (pval *p)
char * pvalForGetInit (pval *p)
pval * pvalForGetStatement (pval *p)
char * pvalForGetTest (pval *p)
void pvalForSetInc (pval *p, char *inc)
void pvalForSetInit (pval *p, char *init)
void pvalForSetStatement (pval *p, pval *statement)
void pvalForSetTest (pval *p, char *test)
void pvalGlobalsAddStatement (pval *p, pval *statement)
pval * pvalGlobalsWalkStatements (pval *p, pval **next_statement)
void pvalGotoGetTarget (pval *p, char **context, char **exten, char **label)
void pvalGotoSetTarget (pval *p, char *context, char *exten, char *label)
char * pvalIfGetCondition (pval *p)
void pvalIfSetCondition (pval *p, char *expr)
void pvalIfTimeGetCondition (pval *p, char **hour_range, char **dow_range, char **dom_range, char **month_range)
void pvalIfTimeSetCondition (pval *p, char *hour_range, char *dow_range, char *dom_range, char *mon_range)
char * pvalIgnorePatGetPattern (pval *p)
void pvalIgnorePatSetPattern (pval *p, char *pat)
void pvalIncludeGetTimeConstraints (pval *p, char **hour_range, char **dom_range, char **dow_range, char **month_range)
void pvalIncludesAddInclude (pval *p, const char *include)
void pvalIncludesAddIncludeWithTimeConstraints (pval *p, const char *include, char *hour_range, char *dom_range, char *dow_range, char *month_range)
char * pvalIncludesWalk (pval *p, pval **next_item)
char * pvalLabelGetName (pval *p)
void pvalLabelSetName (pval *p, char *name)
void pvalMacroAddArg (pval *p, pval *arg)
void pvalMacroAddStatement (pval *p, pval *statement)
void pvalMacroCallAddArg (pval *p, pval *arg)
char * pvalMacroCallGetMacroName (pval *p)
void pvalMacroCallSetArglist (pval *p, pval *arglist)
void pvalMacroCallSetMacroName (pval *p, char *name)
pval * pvalMacroCallWalkArgs (pval *p, pval **args)
char * pvalMacroGetName (pval *p)
void pvalMacroSetArglist (pval *p, pval *arglist)
void pvalMacroSetName (pval *p, char *name)
pval * pvalMacroWalkArgs (pval *p, pval **arg)
pval * pvalMacroWalkStatements (pval *p, pval **next_statement)
pvaltype pvalObjectGetType (pval *p)
char * pvalRandomGetCondition (pval *p)
void pvalRandomSetCondition (pval *p, char *percent)
void pvalStatementBlockAddStatement (pval *p, pval *statement)
pval * pvalStatementBlockWalkStatements (pval *p, pval **next_statement)
void pvalSwitchAddCase (pval *p, pval *Case)
void pvalSwitchesAddSwitch (pval *p, char *name)
char * pvalSwitchesWalkNames (pval *p, pval **next_item)
char * pvalSwitchGetTestexpr (pval *p)
void pvalSwitchSetTestexpr (pval *p, char *expr)
pval * pvalSwitchWalkCases (pval *p, pval **next_case)
void pvalTopLevAddObject (pval *p, pval *contextOrObj)
pval * pvalTopLevWalkObjects (pval *p, pval **next_obj)
char * pvalVarDecGetValue (pval *p)
char * pvalVarDecGetVarname (pval *p)
void pvalVarDecSetValue (pval *p, char *value)
void pvalVarDecSetVarname (pval *p, char *name)
char * pvalWordGetString (pval *p)
void pvalWordSetString (pval *p, char *str)
void set_priorities (struct ael_extension *exten)

Typedef Documentation

typedef struct pval pval

Definition at line 101 of file pval.h.


Enumeration Type Documentation

enum pvaltype
Enumerator:
PV_WORD 
PV_MACRO 
PV_CONTEXT 
PV_MACRO_CALL 
PV_APPLICATION_CALL 
PV_CASE 
PV_PATTERN 
PV_DEFAULT 
PV_CATCH 
PV_SWITCHES 
PV_ESWITCHES 
PV_INCLUDES 
PV_STATEMENTBLOCK 
PV_VARDEC 
PV_GOTO 
PV_LABEL 
PV_FOR 
PV_WHILE 
PV_BREAK 
PV_RETURN 
PV_CONTINUE 
PV_IF 
PV_IFTIME 
PV_RANDOM 
PV_SWITCH 
PV_EXTENSION 
PV_IGNOREPAT 
PV_GLOBALS 
PV_LOCALVARDEC 

Definition at line 6 of file pval.h.

{
   PV_WORD, /* an ident, string, name, label, etc. A user-supplied string. */ /* 0 */
   PV_MACRO,             /* 1 */
   PV_CONTEXT,           /* 2 */
   PV_MACRO_CALL,        /* 3 */
   PV_APPLICATION_CALL,  /* 4 */
   PV_CASE,              /* 5 */
   PV_PATTERN,           /* 6 */
   PV_DEFAULT,           /* 7 */
   PV_CATCH,             /* 8 */
   PV_SWITCHES,          /* 9 */
   PV_ESWITCHES,         /* 10 */
   PV_INCLUDES,          /* 11 */
   PV_STATEMENTBLOCK,    /* 12 */
   PV_VARDEC, /* you know, var=val; */  /* 13 */
   PV_GOTO,              /* 14 */
   PV_LABEL,             /* 15 */
   PV_FOR,               /* 16 */
   PV_WHILE,             /* 17 */
   PV_BREAK,             /* 18 */
   PV_RETURN,            /* 19 */
   PV_CONTINUE,          /* 20 */
   PV_IF,                /* 21 */
   PV_IFTIME,            /* 22 */
   PV_RANDOM,            /* 23 */
   PV_SWITCH,            /* 24 */
   PV_EXTENSION,         /* 25 */
   PV_IGNOREPAT,         /* 26 */
   PV_GLOBALS,           /* 27 */
   PV_LOCALVARDEC,       /* 28 */
} pvaltype;

Function Documentation

void add_extensions ( struct ael_extension *  exten)

Definition at line 4252 of file pval.c.

Referenced by ast_compile_ael2().

{
   struct ael_priority *pr;
   char *label=0;
   char realext[AST_MAX_EXTENSION];
   if (!exten) {
      ast_log(LOG_WARNING, "This file is Empty!\n" );
      return;
   }
   do {
      struct ael_priority *last = 0;
      
      pbx_substitute_variables_helper(NULL, exten->name, realext, sizeof(realext) - 1);
      if (exten->hints) {
         if (ast_add_extension2(exten->context, 0 /*no replace*/, realext, PRIORITY_HINT, NULL, exten->cidmatch, 
                          exten->hints, NULL, ast_free_ptr, registrar)) {
            ast_log(LOG_WARNING, "Unable to add step at priority 'hint' of extension '%s'\n",
                  exten->name);
         }
      }
      
      for (pr=exten->plist; pr; pr=pr->next) {
         char app[2000];
         char appargs[2000];

         /* before we can add the extension, we need to prep the app/appargs;
            the CONTROL types need to be done after the priority numbers are calculated.
         */
         if (pr->type == AEL_LABEL) /* don't try to put labels in the dialplan! */ {
            last = pr;
            continue;
         }
         
         if (pr->app)
            strcpy(app, pr->app);
         else
            app[0] = 0;
         if (pr->appargs )
            strcpy(appargs, pr->appargs);
         else
            appargs[0] = 0;
         switch( pr->type ) {
         case AEL_APPCALL:
            /* easy case. Everything is all set up */
            break;
            
         case AEL_CONTROL1: /* FOR loop, WHILE loop, BREAK, CONTINUE, IF, IFTIME */
            /* simple, unconditional goto. */
            strcpy(app,"Goto");
            if (pr->goto_true->origin && pr->goto_true->origin->type == PV_SWITCH ) {
               snprintf(appargs,sizeof(appargs),"%s,%d", pr->goto_true->exten->name, pr->goto_true->priority_num);
            } else if (pr->goto_true->origin && pr->goto_true->origin->type == PV_IFTIME && pr->goto_true->origin->u3.else_statements ) {
               snprintf(appargs,sizeof(appargs),"%d", pr->goto_true->priority_num+1);
            } else
               snprintf(appargs,sizeof(appargs),"%d", pr->goto_true->priority_num);
            break;
            
         case AEL_FOR_CONTROL:  /* WHILE loop test, FOR loop test */
            strcpy(app,"GotoIf");
            snprintf(appargs,sizeof(appargs),"%s?%d:%d", pr->appargs, pr->priority_num+1, pr->goto_false->priority_num);
            break;
            
         case AEL_IF_CONTROL:
            strcpy(app,"GotoIf");
            if (pr->origin->u3.else_statements )
               snprintf(appargs,sizeof(appargs),"%s?%d:%d", pr->appargs, pr->priority_num+1, pr->goto_false->priority_num+1);
            else
               snprintf(appargs,sizeof(appargs),"%s?%d:%d", pr->appargs, pr->priority_num+1, pr->goto_false->priority_num);
            break;

         case AEL_RAND_CONTROL:
            strcpy(app,"Random");
            snprintf(appargs,sizeof(appargs),"%s:%d", pr->appargs, pr->goto_true->priority_num+1);
            break;

         case AEL_IFTIME_CONTROL:
            strcpy(app,"GotoIfTime");
            snprintf(appargs,sizeof(appargs),"%s?%d", pr->appargs, pr->priority_num+2);
            break;

         case AEL_RETURN:
            strcpy(app,"Return");
            appargs[0] = 0;
            break;
            
         default:
            break;
         }
         if (last && last->type == AEL_LABEL ) {
            label = last->origin->u1.str;
         }
         else
            label = 0;
         
         if (ast_add_extension2(exten->context, 0 /*no replace*/, realext, pr->priority_num, (label?label:NULL), exten->cidmatch, 
                          app, strdup(appargs), ast_free_ptr, registrar)) {
            ast_log(LOG_WARNING, "Unable to add step at priority '%d' of extension '%s'\n", pr->priority_num, 
                  exten->name);
         }
         last = pr;
      }
      exten = exten->next_exten;
   } while ( exten );
}
int ast_compile_ael2 ( struct ast_context **  local_contexts,
struct ast_hashtab *  local_table,
struct pval *  root 
)

Definition at line 4452 of file pval.c.

Referenced by pbx_load_module().

{
   pval *p,*p2;
   struct ast_context *context;
   char buf[2000];
   struct ael_extension *exten;
   struct ael_extension *exten_list = 0;

   for (p=root; p; p=p->next ) { /* do the globals first, so they'll be there
                            when we try to eval them */
      switch (p->type) {
      case PV_GLOBALS:
         /* just VARDEC elements */
         for (p2=p->u1.list; p2; p2=p2->next) {
            char buf2[2000];
            snprintf(buf2,sizeof(buf2),"%s=%s", p2->u1.str, p2->u2.val);
            pbx_builtin_setvar(NULL, buf2);
         }
         break;
      default:
         break;
      }
   }

   for (p=root; p; p=p->next ) {
      pval *lp;
      int argc;
      
      switch (p->type) {
      case PV_MACRO:
         
         context = ast_context_find_or_create(local_contexts, local_table, p->u1.str, registrar);
         
         exten = new_exten();
         exten->context = context;
         exten->name = strdup("~~s~~");
         argc = 1;
         for (lp=p->u2.arglist; lp; lp=lp->next) {
            /* for each arg, set up a "Set" command */
            struct ael_priority *np2 = new_prio();
            np2->type = AEL_APPCALL;
            if (!ast_compat_app_set) {
               np2->app = strdup("MSet");
            } else {
               np2->app = strdup("Set");
            }
            snprintf(buf,sizeof(buf),"LOCAL(%s)=${ARG%d}", lp->u1.str, argc++);
            remove_spaces_before_equals(buf);
            np2->appargs = strdup(buf);
            linkprio(exten, np2, NULL);
         }
         
         /* CONTAINS APPCALLS, CATCH, just like extensions... */
         if (gen_prios(exten, p->u1.str, p->u3.macro_statements, 0, context)) {
            return -1;
         }
         if (exten->return_needed) {  /* most likely, this will go away */
            struct ael_priority *np2 = new_prio();
            np2->type = AEL_APPCALL;
            np2->app = strdup("NoOp");
            snprintf(buf,sizeof(buf),"End of Macro %s-%s",p->u1.str, exten->name);
            np2->appargs = strdup(buf);
            linkprio(exten, np2, NULL);
            exten-> return_target = np2;
         }
         
         set_priorities(exten);
         attach_exten(&exten_list, exten);
         break;
         
      case PV_GLOBALS:
         /* already done */
         break;
         
      case PV_CONTEXT:
         context = ast_context_find_or_create(local_contexts, local_table, p->u1.str, registrar);
         
         /* contexts contain: ignorepat, includes, switches, eswitches, extensions,  */
         for (p2=p->u2.statements; p2; p2=p2->next) {
            pval *p3;
            char *s3;
            
            switch (p2->type) {
            case PV_EXTENSION:
               exten = new_exten();
               exten->name = strdup(p2->u1.str);
               exten->context = context;
               
               if( (s3=strchr(exten->name, '/') ) != 0 )
               {
                  *s3 = 0;
                  exten->cidmatch = s3+1;
               }
               
               if ( p2->u3.hints )
                  exten->hints = strdup(p2->u3.hints);
               exten->regexten = p2->u4.regexten;
               if (gen_prios(exten, p->u1.str, p2->u2.statements, 0, context)) {
                  return -1;
               }
               if (exten->return_needed) { /* returns don't generate a goto eoe (end of extension) any more, just a Return() app call) */
                  struct ael_priority *np2 = new_prio();
                  np2->type = AEL_APPCALL;
                  np2->app = strdup("NoOp");
                  snprintf(buf,sizeof(buf),"End of Extension %s", exten->name);
                  np2->appargs = strdup(buf);
                  linkprio(exten, np2, NULL);
                  exten-> return_target = np2;
               }
               /* is the last priority in the extension a label? Then add a trailing no-op */
               if ( exten->plist_last && exten->plist_last->type == AEL_LABEL ) {
                  struct ael_priority *np2 = new_prio();
                  np2->type = AEL_APPCALL;
                  np2->app = strdup("NoOp");
                  snprintf(buf,sizeof(buf),"A NoOp to follow a trailing label %s", exten->plist_last->origin->u1.str);
                  np2->appargs = strdup(buf);
                  linkprio(exten, np2, NULL);
               }

               set_priorities(exten);
               attach_exten(&exten_list, exten);
               break;
               
            case PV_IGNOREPAT:
               ast_context_add_ignorepat2(context, p2->u1.str, registrar);
               break;
               
            case PV_INCLUDES:
               for (p3 = p2->u1.list; p3 ;p3=p3->next) {
                  if ( p3->u2.arglist ) {
                     snprintf(buf,sizeof(buf), "%s,%s,%s,%s,%s", 
                            p3->u1.str,
                            p3->u2.arglist->u1.str,
                            p3->u2.arglist->next->u1.str,
                            p3->u2.arglist->next->next->u1.str,
                            p3->u2.arglist->next->next->next->u1.str);
                     ast_context_add_include2(context, buf, registrar);
                  } else
                     ast_context_add_include2(context, p3->u1.str, registrar);
               }
               break;
               
            case PV_SWITCHES:
               for (p3 = p2->u1.list; p3 ;p3=p3->next) {
                  char *c = strchr(p3->u1.str, '/');
                  if (c) {
                     *c = '\0';
                     c++;
                  } else
                     c = "";

                  ast_context_add_switch2(context, p3->u1.str, c, 0, registrar);
               }
               break;

            case PV_ESWITCHES:
               for (p3 = p2->u1.list; p3 ;p3=p3->next) {
                  char *c = strchr(p3->u1.str, '/');
                  if (c) {
                     *c = '\0';
                     c++;
                  } else
                     c = "";

                  ast_context_add_switch2(context, p3->u1.str, c, 1, registrar);
               }
               break;
            default:
               break;
            }
         }
         
         break;
         
      default:
         /* huh? what? */
         break;
         
      }
   }

   /* Create default "h" bubble context */
   if (ast_custom_function_find("DIALPLAN_EXISTS") && ast_custom_function_find("STACK_PEEK")) {
      int i;
      const char *h_context = "ael-builtin-h-bubble";
      struct ael_priority *np;
      struct {
         int priority;
         const char *app;
         const char *arg;
      } steps[] = {
         /* Start high, to avoid conflict with existing h extensions */
         { 1, "Goto", "9991" },
         /* Save the context, because after the StackPop, it disappears */
         { 9991, "Set", "~~parentcxt~~=${STACK_PEEK(1,c,1)}" },
         /* If we're not in a Gosub frame, exit */
         { 9992, "GotoIf", "$[\"${~~parentcxt~~}\"=\"\"]?9996" },
         /* Check for an "h" extension in that context */
         { 9993, "GotoIf", "${DIALPLAN_EXISTS(${~~parentcxt~~},h,1)}?9994:9996" },
         /* Pop off the stack frame to prevent an infinite loop */
         { 9994, "StackPop", "" },
         /* Finally, go there. */
         { 9995, "Goto", "${~~parentcxt~~},h,1" },
         /* Just an empty priority for jumping out early */
         { 9996, "NoOp", "" }
      };
      context = ast_context_find_or_create(local_contexts, local_table, h_context, registrar);
      if (context_used(exten_list, context)) {
         int found = 0;
         while (!found) {
            /* Pick a new context name that is not used. */
            char h_context_template[] = "/tmp/ael-builtin-h-bubble-XXXXXX";
            int fd = mkstemp(h_context_template);
            unlink(h_context_template);
            close(fd);
            context = ast_context_find_or_create(local_contexts, local_table, h_context_template + 5, registrar);
            found = !context_used(exten_list, context);
         }
         h_context = ast_get_context_name(context);
      }
      exten = new_exten();
      exten->context = context;
      exten->name = strdup("h");

      for (i = 0; i < ARRAY_LEN(steps); i++) {
         np = new_prio();
         np->type = AEL_APPCALL;
         np->priority_num = steps[i].priority;
         np->app = strdup(steps[i].app);
         np->appargs = strdup(steps[i].arg);
         linkprio(exten, np, NULL);
      }
      attach_exten(&exten_list, exten);

      /* Include the default "h" bubble context in each macro context */
      for (exten = exten_list; exten; exten = exten->next_exten) {
         /* All macros contain a "~~s~~" extension, and it's the first created.  If
          * we perchance get a non-macro context, it's no big deal; the logic is
          * designed to exit out smoothly if not called from within a Gosub. */
         if (!strcmp(exten->name, "~~s~~")) {
            ast_context_add_include2(exten->context, h_context, registrar);
         }
      }
   }

   /* moved these from being done after a macro or extension were processed,
      to after all processing is done, for the sake of fixing gotos to labels inside cases... */
   /* I guess this would be considered 2nd pass of compiler now... */
   fix_gotos_in_extensions(exten_list); /* find and fix extension ref in gotos to labels that are in case statements */
   add_extensions(exten_list);   /* actually makes calls to create priorities in ast_contexts -- feeds dialplan to asterisk */
   destroy_extensions(exten_list);  /* all that remains is an empty husk, discard of it as is proper */
   
   return 0;
}
int ast_expr ( char *  expr,
char *  buf,
int  length,
struct ast_channel *  chan 
)

Evaluate the given expression.

Parameters:
exprAn expression
bufResult buffer
lengthSize of the result buffer, in bytes
chanChannel to use for evaluating included dialplan functions, if any
Returns:
Length of the result string, in bytes

Definition at line 2396 of file ast_expr2f.c.

References parse_io::string, ast_yylex_init(), parse_io::scanner, ast_yy_scan_string(), ast_yyparse(), ast_yylex_destroy(), AST_EXPR_number, FP___PRINTF, ast_copy_string(), and free.

{
   struct parse_io io = { .string = expr, .chan = chan };
   int return_value = 0;

   ast_yylex_init(&io.scanner);

   ast_yy_scan_string(expr, io.scanner);

   ast_yyparse ((void *) &io);

   ast_yylex_destroy(io.scanner);

   if (!io.val) {
      if (length > 1) {
         strcpy(buf, "0");
         return_value = 1;
      }
   } else {
      if (io.val->type == AST_EXPR_number) {
         int res_length;

         res_length = snprintf(buf, length, FP___PRINTF, io.val->u.i);
         return_value = (res_length <= length) ? res_length : length;
      } else {
         if (io.val->u.s)
#if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE)
            strncpy(buf, io.val->u.s, length - 1);
#else /* !STANDALONE && !LOW_MEMORY */
            ast_copy_string(buf, io.val->u.s, length);
#endif /* STANDALONE || LOW_MEMORY */
         else
            buf[0] = 0;
         return_value = strlen(buf);
         free(io.val->u.s);
      }
      free(io.val);
   }
   return return_value;
}
void ast_expr_clear_extra_error_info ( void  )

Definition at line 2475 of file ast_expr2f.c.

Referenced by check_pval_item().

void ast_expr_register_extra_error_info ( char *  errmsg)

Definition at line 2469 of file ast_expr2f.c.

Referenced by check_pval_item().

int check_app_args ( pval *  appcall,
pval *  arglist,
struct argapp *  app 
)

Definition at line 2138 of file pval.c.

Referenced by check_pval_item().

{
#ifdef AAL_ARGCHECK
   struct argdesc *ad = app->args;
   pval *pa;
   int z;
   
   for (pa = arglist; pa; pa=pa->next) {
      if (!ad) {
         ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: Extra argument %s not in application call to %s !\n",
               arglist->filename, arglist->startline, arglist->endline, pa->u1.str, app->name);
         warns++;
         return 1;
      } else {
         /* find the first entry in the ad list that will match */
         do {
            if ( ad->dtype == ARGD_VARARG ) /* once we hit the VARARG, all bets are off. Discontinue the comparisons */
               break;
            
            z= option_matches( ad, pa, app);
            if (!z) {
               if ( !arglist )
                  arglist=appcall;
               
               if (ad->type == ARGD_REQUIRED) {
                  ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: Required argument %s not in application call to %s !\n",
                        arglist->filename, arglist->startline, arglist->endline, ad->dtype==ARGD_OPTIONSET?"options":ad->name, app->name);
                  warns++;
                  return 1;
               }
            } else if (z && ad->dtype == ARGD_OPTIONSET) {
               option_matches_j( ad, pa, app);
            }
            ad = ad->next;
         } while (ad && !z);
      }
   }
   /* any app nodes left, that are not optional? */
   for ( ; ad; ad=ad->next) {
      if (ad->type == ARGD_REQUIRED && ad->dtype != ARGD_VARARG) {
         if ( !arglist ) 
            arglist=appcall;
         ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: Required argument %s not in application call to %s !\n",
               arglist->filename, arglist->startline, arglist->endline, ad->dtype==ARGD_OPTIONSET?"options":ad->name, app->name);
         warns++;
         return 1;
      }
   }
   return 0;
#else
   return 0;
#endif
}
void check_pval ( pval *  item,
struct argapp *  apps,
int  in_globals 
)

Definition at line 2873 of file pval.c.

Referenced by check_pval_item(), and ael2_semantic_check().

{
   pval *i;

   /* checks to do:
      1. Do goto's point to actual labels? 
      2. Do macro calls reference a macro?
      3. Does the number of macro args match the definition?
      4. Is a macro call missing its & at the front?
      5. Application calls-- we could check syntax for existing applications,
         but I need some some sort of universal description bnf for a general
        sort of method for checking arguments, in number, maybe even type, at least. 
        Don't want to hand code checks for hundreds of applications.
   */
   
   for (i=item; i; i=i->next) {
      check_pval_item(i,apps,in_globals);
   }
}
void check_pval_item ( pval *  item,
struct argapp *  apps,
int  in_globals 
)

Definition at line 2365 of file pval.c.

Referenced by check_pval().

{
   pval *lp;
#ifdef AAL_ARGCHECK
   struct argapp *app, *found;
#endif
   struct pval *macro_def;
   struct pval *app_def;

   char errmsg[4096];
   char *strp;
   
   switch (item->type) {
   case PV_WORD:
      /* fields: item->u1.str == string associated with this (word).
                 item->u2.arglist  == pval list of 4 PV_WORD elements for time values (only in PV_INCLUDES) */
      break;
      
   case PV_MACRO:
      /* fields: item->u1.str     == name of macro
                 item->u2.arglist == pval list of PV_WORD arguments of macro, as given by user
               item->u2.arglist->u1.str  == argument
               item->u2.arglist->next   == next arg

               item->u3.macro_statements == pval list of statements in macro body.
      */
      in_abstract_context = 0;
      current_context = item;
      current_extension = 0;

      check_macro_returns(item);
      
      for (lp=item->u2.arglist; lp; lp=lp->next) {
      
      }
      check_pval(item->u3.macro_statements, apps,in_globals);
      break;
         
   case PV_CONTEXT:
      /* fields: item->u1.str     == name of context
                 item->u2.statements == pval list of statements in context body
               item->u3.abstract == int 1 if an abstract keyword were present
      */
      current_context = item;
      current_extension = 0;
      if ( item->u3.abstract ) {
         in_abstract_context = 1;
         check_abstract_reference(item);
      } else
         in_abstract_context = 0;
      check_pval(item->u2.statements, apps,in_globals);
      break;
         
   case PV_MACRO_CALL:
      /* fields: item->u1.str     == name of macro to call
                 item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user
               item->u2.arglist->u1.str  == argument
               item->u2.arglist->next   == next arg
      */
#ifdef STANDALONE
      /* if this is a standalone, we will need to make sure the 
         localized load of extensions.conf is done */
      if (!extensions_dot_conf_loaded) {
         localized_pbx_load_module();
         extensions_dot_conf_loaded++;
      }
#endif
      macro_def = find_macro(item->u1.str);
      if (!macro_def) {
#ifdef STANDALONE
         struct pbx_find_info pfiq = {.stacklen = 0 };
         struct pbx_find_info pfiq2 = {.stacklen = 0 };

         /* look for the macro in the extensions.conf world */
         pbx_find_extension(NULL, NULL, &pfiq, item->u1.str, "s", 1, NULL, NULL, E_MATCH);
         
         if (pfiq.status != STATUS_SUCCESS) {
            char namebuf2[256];
            snprintf(namebuf2, 256, "macro-%s", item->u1.str);
            
            /* look for the macro in the extensions.conf world */
            pbx_find_extension(NULL, NULL, &pfiq2, namebuf2, "s", 1, NULL, NULL, E_MATCH);
            
            if (pfiq2.status == STATUS_SUCCESS) {
               ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: macro call to non-existent %s! (macro-%s was found in the extensions.conf stuff, but we are using gosubs!)\n",
                     item->filename, item->startline, item->endline, item->u1.str, item->u1.str);
               warns++;
            } else {
               ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: macro call to non-existent %s! (Not even in the extensions.conf stuff!)\n",
                     item->filename, item->startline, item->endline, item->u1.str);
               warns++;
            }
         }
#else
         ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: macro call to %s cannot be found in the AEL code!\n",
               item->filename, item->startline, item->endline, item->u1.str);
         warns++;
         
#endif
#ifdef THIS_IS_1DOT4
         char namebuf2[256];
         snprintf(namebuf2, 256, "macro-%s", item->u1.str);

         /* look for the macro in the extensions.conf world */
         pbx_find_extension(NULL, NULL, &pfiq, namebuf2, "s", 1, NULL, NULL, E_MATCH);
         
         if (pfiq.status != STATUS_SUCCESS) {
            ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: macro call to %s was not found in the AEL, nor the extensions.conf !\n",
                  item->filename, item->startline, item->endline, item->u1.str);
            warns++;
         }
         
#endif

      } else if (macro_def->type != PV_MACRO) {
         ast_log(LOG_ERROR,"Error: file %s, line %d-%d: macro call to %s references a context, not a macro!\n",
               item->filename, item->startline, item->endline, item->u1.str);
         errs++;
      } else {
         /* macro_def is a MACRO, so do the args match in number? */
         int hereargs = 0;
         int thereargs = 0;
         
         for (lp=item->u2.arglist; lp; lp=lp->next) {
            hereargs++;
         }
         for (lp=macro_def->u2.arglist; lp; lp=lp->next) {
            thereargs++;
         }
         if (hereargs != thereargs ) {
            ast_log(LOG_ERROR, "Error: file %s, line %d-%d: The macro call to %s has %d arguments, but the macro definition has %d arguments\n",
                  item->filename, item->startline, item->endline, item->u1.str, hereargs, thereargs);
            errs++;
         }
      }
      break;
         
   case PV_APPLICATION_CALL:
      /* fields: item->u1.str     == name of application to call
                 item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user
               item->u2.arglist->u1.str  == argument
               item->u2.arglist->next   == next arg
      */
      /* Need to check to see if the application is available! */
      app_def = find_context(item->u1.str);
      if (app_def && app_def->type == PV_MACRO) {
         ast_log(LOG_ERROR,"Error: file %s, line %d-%d: application call to %s references an existing macro, but had no & preceding it!\n",
               item->filename, item->startline, item->endline, item->u1.str);
         errs++;
      }
      if (strcasecmp(item->u1.str,"GotoIf") == 0
         || strcasecmp(item->u1.str,"GotoIfTime") == 0
         || strcasecmp(item->u1.str,"while") == 0
         || strcasecmp(item->u1.str,"endwhile") == 0
         || strcasecmp(item->u1.str,"random") == 0
         || strcasecmp(item->u1.str,"gosub") == 0
         || strcasecmp(item->u1.str,"gosubif") == 0
         || strcasecmp(item->u1.str,"continuewhile") == 0
         || strcasecmp(item->u1.str,"endwhile") == 0
         || strcasecmp(item->u1.str,"execif") == 0
         || strcasecmp(item->u1.str,"execiftime") == 0
         || strcasecmp(item->u1.str,"exitwhile") == 0
         || strcasecmp(item->u1.str,"goto") == 0
         || strcasecmp(item->u1.str,"macro") == 0
         || strcasecmp(item->u1.str,"macroexclusive") == 0
         || strcasecmp(item->u1.str,"macroif") == 0
         || strcasecmp(item->u1.str,"stackpop") == 0
         || strcasecmp(item->u1.str,"execIf") == 0 ) {
         ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: application call to %s affects flow of control, and needs to be re-written using AEL if, while, goto, etc. keywords instead!\n",
               item->filename, item->startline, item->endline, item->u1.str);
         warns++;
      }
      if (strcasecmp(item->u1.str,"macroexit") == 0) {
            ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: I am converting the MacroExit call here to a return statement.\n",
                  item->filename, item->startline, item->endline);
            item->type = PV_RETURN;
            free(item->u1.str);
            item->u1.str = 0;
      }
      
#ifdef AAL_ARGCHECK
      found = 0;
      for (app=apps; app; app=app->next) {
         if (strcasecmp(app->name, item->u1.str) == 0) {
            found =app;
            break;
         }
      }
      if (!found) {
         ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: application call to %s not listed in applist database!\n",
               item->filename, item->startline, item->endline, item->u1.str);
         warns++;
      } else
         check_app_args(item, item->u2.arglist, app);
#endif
      break;
      
   case PV_CASE:
      /* fields: item->u1.str     == value of case
                 item->u2.statements == pval list of statements under the case
      */
      /* Make sure sequence of statements under case is terminated with  goto, return, or break */
      /* find the last statement */
      check_pval(item->u2.statements, apps,in_globals);
      break;
         
   case PV_PATTERN:
      /* fields: item->u1.str     == value of case
                 item->u2.statements == pval list of statements under the case
      */
      /* Make sure sequence of statements under case is terminated with  goto, return, or break */
      /* find the last statement */
      
      check_pval(item->u2.statements, apps,in_globals);
      break;
         
   case PV_DEFAULT:
      /* fields: 
                 item->u2.statements == pval list of statements under the case
      */

      check_pval(item->u2.statements, apps,in_globals);
      break;
         
   case PV_CATCH:
      /* fields: item->u1.str     == name of extension to catch
                 item->u2.statements == pval list of statements in context body
      */
      check_pval(item->u2.statements, apps,in_globals);
      break;
         
   case PV_SWITCHES:
      /* fields: item->u1.list     == pval list of PV_WORD elements, one per entry in the list
      */
      check_pval(item->u1.list, apps,in_globals);
      break;
         
   case PV_ESWITCHES:
      /* fields: item->u1.list     == pval list of PV_WORD elements, one per entry in the list
      */
      check_pval(item->u1.list, apps,in_globals);
      break;
         
   case PV_INCLUDES:
      /* fields: item->u1.list     == pval list of PV_WORD elements, one per entry in the list
      */
      check_pval(item->u1.list, apps,in_globals);
      check_includes(item);
      for (lp=item->u1.list; lp; lp=lp->next){
         char *incl_context = lp->u1.str;
         struct pval *that_context = find_context(incl_context);

         if ( lp->u2.arglist ) {
            check_timerange(lp->u2.arglist);
            check_dow(lp->u2.arglist->next);
            check_day(lp->u2.arglist->next->next);
            check_month(lp->u2.arglist->next->next->next);
         }
         
         if (that_context) {
            find_pval_gotos(that_context->u2.statements,0);
            
         }
      }
      break;
         
   case PV_STATEMENTBLOCK:
      /* fields: item->u1.list     == pval list of statements in block, one per entry in the list
      */
      check_pval(item->u1.list, apps,in_globals);
      break;
         
   case PV_VARDEC:
      /* fields: item->u1.str     == variable name
                 item->u2.val     == variable value to assign
      */
      /* the RHS of a vardec is encapsulated in a $[] expr. Is it legal? */
      if( !in_globals ) { /* don't check stuff inside the globals context; no wrapping in $[ ] there... */
         snprintf(errmsg,sizeof(errmsg), "file %s, line %d, columns %d-%d, variable declaration expr '%s':", item->filename, item->startline, item->startcol, item->endcol, item->u2.val);
         ast_expr_register_extra_error_info(errmsg);
         ast_expr(item->u2.val, expr_output, sizeof(expr_output),NULL);
         ast_expr_clear_extra_error_info();
         if ( strpbrk(item->u2.val,"~!-+<>=*/&^") && !strstr(item->u2.val,"${") ) {
            ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: expression %s has operators, but no variables. Interesting...\n",
                  item->filename, item->startline, item->endline, item->u2.val);
            warns++;
         }
         check_expr2_input(item,item->u2.val);
      }
      break;
         
   case PV_LOCALVARDEC:
      /* fields: item->u1.str     == variable name
                 item->u2.val     == variable value to assign
      */
      /* the RHS of a vardec is encapsulated in a $[] expr. Is it legal? */
      snprintf(errmsg,sizeof(errmsg), "file %s, line %d, columns %d-%d, variable declaration expr '%s':", item->filename, item->startline, item->startcol, item->endcol, item->u2.val);
      ast_expr_register_extra_error_info(errmsg);
      ast_expr(item->u2.val, expr_output, sizeof(expr_output),NULL);
      ast_expr_clear_extra_error_info();
      if ( strpbrk(item->u2.val,"~!-+<>=*/&^") && !strstr(item->u2.val,"${") ) {
         ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: expression %s has operators, but no variables. Interesting...\n",
               item->filename, item->startline, item->endline, item->u2.val);
         warns++;
      }
      check_expr2_input(item,item->u2.val);
      break;
         
   case PV_GOTO:
      /* fields: item->u1.list     == pval list of PV_WORD target names, up to 3, in order as given by user.
                 item->u1.list->u1.str  == where the data on a PV_WORD will always be.
      */
      /* don't check goto's in abstract contexts */
      if ( in_abstract_context )
         break;
      
      check_goto(item);
      break;
         
   case PV_LABEL:
      /* fields: item->u1.str     == label name
      */
      if ( strspn(item->u1.str, "0123456789") == strlen(item->u1.str) ) {
         ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: label '%s' is numeric, this is bad practice!\n",
               item->filename, item->startline, item->endline, item->u1.str);
         warns++;
      }

      check_label(item);
      break;
         
   case PV_FOR:
      /* fields: item->u1.for_init     == a string containing the initalizer
                 item->u2.for_test     == a string containing the loop test
                 item->u3.for_inc      == a string containing the loop increment

               item->u4.for_statements == a pval list of statements in the for ()
      */
      snprintf(errmsg,sizeof(errmsg),"file %s, line %d, columns %d-%d, for test expr '%s':", item->filename, item->startline, item->startcol, item->endcol, item->u2.for_test);
      ast_expr_register_extra_error_info(errmsg);

      strp = strchr(item->u1.for_init, '=');
      if (strp) {
         ast_expr(strp+1, expr_output, sizeof(expr_output),NULL);
      }
      ast_expr(item->u2.for_test, expr_output, sizeof(expr_output),NULL);
      strp = strchr(item->u3.for_inc, '=');
      if (strp) {
         ast_expr(strp+1, expr_output, sizeof(expr_output),NULL);
      }
      if ( strpbrk(item->u2.for_test,"~!-+<>=*/&^") && !strstr(item->u2.for_test,"${") ) {
         ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: expression %s has operators, but no variables. Interesting...\n",
               item->filename, item->startline, item->endline, item->u2.for_test);
         warns++;
      }
      if ( strpbrk(item->u3.for_inc,"~!-+<>=*/&^") && !strstr(item->u3.for_inc,"${") ) {
         ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: expression %s has operators, but no variables. Interesting...\n",
               item->filename, item->startline, item->endline, item->u3.for_inc);
         warns++;
      }
      check_expr2_input(item,item->u2.for_test);
      check_expr2_input(item,item->u3.for_inc);
      
      ast_expr_clear_extra_error_info();
      check_pval(item->u4.for_statements, apps,in_globals);
      break;
         
   case PV_WHILE:
      /* fields: item->u1.str        == the while conditional, as supplied by user

               item->u2.statements == a pval list of statements in the while ()
      */
      snprintf(errmsg,sizeof(errmsg),"file %s, line %d, columns %d-%d, while expr '%s':", item->filename, item->startline, item->startcol, item->endcol, item->u1.str);
      ast_expr_register_extra_error_info(errmsg);
      ast_expr(item->u1.str, expr_output, sizeof(expr_output),NULL);
      ast_expr_clear_extra_error_info();
      if ( strpbrk(item->u1.str,"~!-+<>=*/&^") && !strstr(item->u1.str,"${") ) {
         ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: expression %s has operators, but no variables. Interesting...\n",
               item->filename, item->startline, item->endline, item->u1.str);
         warns++;
      }
      check_expr2_input(item,item->u1.str);
      check_pval(item->u2.statements, apps,in_globals);
      break;
         
   case PV_BREAK:
      /* fields: none
      */
      check_break(item);
      break;
         
   case PV_RETURN:
      /* fields: none
      */
      break;
         
   case PV_CONTINUE:
      /* fields: none
      */
      check_continue(item);
      break;
         
   case PV_RANDOM:
      /* fields: item->u1.str        == the random number expression, as supplied by user

               item->u2.statements == a pval list of statements in the if ()
               item->u3.else_statements == a pval list of statements in the else
                                    (could be zero)
      */
      snprintf(errmsg,sizeof(errmsg),"file %s, line %d, columns %d-%d, random expr '%s':", item->filename, item->startline, item->startcol, item->endcol, item->u1.str);
      ast_expr_register_extra_error_info(errmsg);
      ast_expr(item->u1.str, expr_output, sizeof(expr_output),NULL);
      ast_expr_clear_extra_error_info();
      if ( strpbrk(item->u1.str,"~!-+<>=*/&^") && !strstr(item->u1.str,"${") ) {
         ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: random expression '%s' has operators, but no variables. Interesting...\n",
               item->filename, item->startline, item->endline, item->u1.str);
         warns++;
      }
      check_expr2_input(item,item->u1.str);
      check_pval(item->u2.statements, apps,in_globals);
      if (item->u3.else_statements) {
         check_pval(item->u3.else_statements, apps,in_globals);
      }
      break;

   case PV_IFTIME:
      /* fields: item->u1.list        == the if time values, 4 of them, each in PV_WORD, linked list 

               item->u2.statements == a pval list of statements in the if ()
               item->u3.else_statements == a pval list of statements in the else
                                    (could be zero)
      */
      if ( item->u2.arglist ) {
         check_timerange(item->u1.list);
         check_dow(item->u1.list->next);
         check_day(item->u1.list->next->next);
         check_month(item->u1.list->next->next->next);
      }

      check_pval(item->u2.statements, apps,in_globals);
      if (item->u3.else_statements) {
         check_pval(item->u3.else_statements, apps,in_globals);
      }
      break;
         
   case PV_IF:
      /* fields: item->u1.str        == the if conditional, as supplied by user

               item->u2.statements == a pval list of statements in the if ()
               item->u3.else_statements == a pval list of statements in the else
                                    (could be zero)
      */
      snprintf(errmsg,sizeof(errmsg),"file %s, line %d, columns %d-%d, if expr '%s':", item->filename, item->startline, item->startcol, item->endcol, item->u1.str);
      ast_expr_register_extra_error_info(errmsg);
      ast_expr(item->u1.str, expr_output, sizeof(expr_output),NULL);
      ast_expr_clear_extra_error_info();
      if ( strpbrk(item->u1.str,"~!-+<>=*/&^") && !strstr(item->u1.str,"${") ) {
         ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: expression '%s' has operators, but no variables. Interesting...\n",
               item->filename, item->startline, item->endline, item->u1.str);
         warns++;
      }
      check_expr2_input(item,item->u1.str);
      check_pval(item->u2.statements, apps,in_globals);
      if (item->u3.else_statements) {
         check_pval(item->u3.else_statements, apps,in_globals);
      }
      break;
         
   case PV_SWITCH:
      /* fields: item->u1.str        == the switch expression

               item->u2.statements == a pval list of statements in the switch, 
                                    (will be case statements, most likely!)
      */
      /* we can check the switch expression, see if it matches any of the app variables...
           if it does, then, are all the possible cases accounted for? */
      check_switch_expr(item, apps);
      check_pval(item->u2.statements, apps,in_globals);
      break;
         
   case PV_EXTENSION:
      /* fields: item->u1.str        == the extension name, label, whatever it's called

               item->u2.statements == a pval list of statements in the extension
               item->u3.hints      == a char * hint argument
               item->u4.regexten   == an int boolean. non-zero says that regexten was specified
      */
      current_extension = item ;
      
      check_pval(item->u2.statements, apps,in_globals);
      break;
         
   case PV_IGNOREPAT:
      /* fields: item->u1.str        == the ignorepat data
      */
      break;
         
   case PV_GLOBALS:
      /* fields: item->u1.statements     == pval list of statements, usually vardecs
      */
      in_abstract_context = 0;
      check_pval(item->u1.statements, apps, 1);
      break;
   default:
      break;
   }
}
void check_switch_expr ( pval *  item,
struct argapp *  apps 
)

Definition at line 2192 of file pval.c.

Referenced by check_pval_item().

{
#ifdef AAL_ARGCHECK
   /* get and clean the variable name */
   char *buff1, *p;
   struct argapp *a,*a2;
   struct appsetvar *v,*v2;
   struct argchoice *c;
   pval *t;
   
   p = item->u1.str;
   while (p && *p && (*p == ' ' || *p == '\t' || *p == '$' || *p == '{' ) )
      p++;
   
   buff1 = ast_strdupa(p);

   while (strlen(buff1) > 0 && ( buff1[strlen(buff1)-1] == '}' || buff1[strlen(buff1)-1] == ' ' || buff1[strlen(buff1)-1] == '\t'))
      buff1[strlen(buff1)-1] = 0;
   /* buff1 now contains the variable name */
   v = 0;
   for (a=apps; a; a=a->next) {
      for (v=a->setvars;v;v=v->next) {
         if (strcmp(v->name,buff1) == 0) {
            break;
         }
      }
      if ( v )
         break;
   }
   if (v && v->vals) {
      /* we have a match, to a variable that has a set of determined values */
      int def= 0;
      int pat = 0;
      int f1 = 0;
      
      /* first of all, does this switch have a default case ? */
      for (t=item->u2.statements; t; t=t->next) {
         if (t->type == PV_DEFAULT) {
            def =1;
            break;
         }
         if (t->type == PV_PATTERN) {
            pat++;
         }
      }
      if (def || pat) /* nothing to check. All cases accounted for! */
         return;
      for (c=v->vals; c; c=c->next) {
         f1 = 0;
         for (t=item->u2.statements; t; t=t->next) {
            if (t->type == PV_CASE || t->type == PV_PATTERN) {
               if (!strcmp(t->u1.str,c->name)) {
                  f1 = 1;
                  break;
               }
            }
         }
         if (!f1) {
            ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: switch with expression(%s) does not handle the case of %s !\n",
                  item->filename, item->startline, item->endline, item->u1.str, c->name);
            warns++;
         }
      }
      /* next, is there an app call in the current exten, that would set this var? */
      f1 = 0;
      t = current_extension->u2.statements;
      if ( t && t->type == PV_STATEMENTBLOCK )
         t = t->u1.statements;
      for (; t && t != item; t=t->next) {
         if (t->type == PV_APPLICATION_CALL) {
            /* find the application that matches the u1.str */
            for (a2=apps; a2; a2=a2->next) {
               if (strcasecmp(a2->name, t->u1.str)==0) {
                  for (v2=a2->setvars; v2; v2=v2->next) {
                     if (strcmp(v2->name, buff1) == 0) {
                        /* found an app that sets the var */
                        f1 = 1;
                        break;
                     }
                  }
               }
               if (f1)
                  break;
            }
         }
         if (f1)
            break;
      }
            
      /* see if it sets the var */
      if (!f1) {
         ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: Couldn't find an application call in this extension that sets the  expression (%s) value!\n",
               item->filename, item->startline, item->endline, item->u1.str);
         warns++;
      }
   }
#else
   pval *t,*tl=0,*p2;
   int def= 0;
   
   /* first of all, does this switch have a default case ? */
   for (t=item->u2.statements; t; t=t->next) {
      if (t->type == PV_DEFAULT) {
         def =1;
         break;
      }
      tl = t;
   }
   if (def) /* nothing to check. All cases accounted for! */
      return;
   /* if no default, warn and insert a default case at the end */
   p2 = tl->next = calloc(1, sizeof(struct pval));
   
   p2->type = PV_DEFAULT;
   p2->startline = tl->startline;
   p2->endline = tl->endline;
   p2->startcol = tl->startcol;
   p2->endcol = tl->endcol;
   p2->filename = strdup(tl->filename);
   ast_log(LOG_WARNING,"Warning: file %s, line %d-%d: A default case was automatically added to the switch.\n",
         p2->filename, p2->startline, p2->endline);
   warns++;
   
#endif
}
int count_labels_in_current_context ( char *  label)
void destroy_extensions ( struct ael_extension *  exten)

Definition at line 2986 of file pval.c.

Referenced by ast_compile_ael2().

{
   struct ael_extension *ne, *nen;
   for (ne=exten; ne; ne=nen) {
      struct ael_priority *pe, *pen;
      
      if (ne->name)
         free(ne->name);
      
      /* cidmatch fields are allocated with name, and freed when
         the name field is freed. Don't do a free for this field,
         unless you LIKE to see a crash! */

      if (ne->hints)
         free(ne->hints);
      
      for (pe=ne->plist; pe; pe=pen) {
         pen = pe->next;
         if (pe->app)
            free(pe->app);
         pe->app = 0;
         if (pe->appargs)
            free(pe->appargs);
         pe->appargs = 0;
         pe->origin = 0;
         pe->goto_true = 0;
         pe->goto_false = 0;
         free(pe);
      }
      nen = ne->next_exten;
      ne->next_exten = 0;
      ne->plist =0;
      ne->plist_last = 0;
      ne->next_exten = 0;
      ne->loop_break = 0;
      ne->loop_continue = 0;
      free(ne);
   }
}
void destroy_pval ( pval *  item)

Definition at line 4980 of file pval.c.

{
   pval *i,*nxt;
   
   for (i=item; i; i=nxt) {
      nxt = i->next;
      
      destroy_pval_item(i);
   }
}
void destroy_pval_item ( pval *  item)

Definition at line 4712 of file pval.c.

Referenced by destroy_pval().

{
   if (item == NULL) {
      ast_log(LOG_WARNING, "null item\n");
      return;
   }

   if (item->filename)
      free(item->filename);
   
   switch (item->type) {
   case PV_WORD:
      /* fields: item->u1.str == string associated with this (word). */
      if (item->u1.str )
         free(item->u1.str);
      if ( item->u2.arglist )
         destroy_pval(item->u2.arglist);
      break;
      
   case PV_MACRO:
      /* fields: item->u1.str     == name of macro
                 item->u2.arglist == pval list of PV_WORD arguments of macro, as given by user
               item->u2.arglist->u1.str  == argument
               item->u2.arglist->next   == next arg

               item->u3.macro_statements == pval list of statements in macro body.
      */
      destroy_pval(item->u2.arglist);
      if (item->u1.str )
         free(item->u1.str);
      destroy_pval(item->u3.macro_statements);
      break;
         
   case PV_CONTEXT:
      /* fields: item->u1.str     == name of context
                 item->u2.statements == pval list of statements in context body
               item->u3.abstract == int 1 if an abstract keyword were present
      */
      if (item->u1.str)
         free(item->u1.str);
      destroy_pval(item->u2.statements);
      break;
         
   case PV_MACRO_CALL:
      /* fields: item->u1.str     == name of macro to call
                 item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user
               item->u2.arglist->u1.str  == argument
               item->u2.arglist->next   == next arg
      */
      if (item->u1.str)
         free(item->u1.str);
      destroy_pval(item->u2.arglist);
      break;
         
   case PV_APPLICATION_CALL:
      /* fields: item->u1.str     == name of application to call
                 item->u2.arglist == pval list of PV_WORD arguments of macro call, as given by user
               item->u2.arglist->u1.str  == argument
               item->u2.arglist->next   == next arg
      */
      if (item->u1.str)
         free(item->u1.str);
      destroy_pval(item->u2.arglist);
      break;
         
   case PV_CASE:
      /* fields: item->u1.str     == value of case
                 item->u2.statements == pval list of statements under the case
      */
      if (item->u1.str)
         free(item->u1.str);
      destroy_pval(item->u2.statements);
      break;
         
   case PV_PATTERN:
      /* fields: item->u1.str     == value of case
                 item->u2.statements == pval list of statements under the case
      */
      if (item->u1.str)
         free(item->u1.str);
      destroy_pval(item->u2.statements);
      break;
         
   case PV_DEFAULT:
      /* fields: 
                 item->u2.statements == pval list of statements under the case
      */
      destroy_pval(item->u2.statements);
      break;
         
   case PV_CATCH:
      /* fields: item->u1.str     == name of extension to catch
                 item->u2.statements == pval list of statements in context body
      */
      if (item->u1.str)
         free(item->u1.str);
      destroy_pval(item->u2.statements);
      break;
         
   case PV_SWITCHES:
      /* fields: item->u1.list     == pval list of PV_WORD elements, one per entry in the list
      */
      destroy_pval(item->u1.list);
      break;
         
   case PV_ESWITCHES:
      /* fields: item->u1.list     == pval list of PV_WORD elements, one per entry in the list
      */
      destroy_pval(item->u1.list);
      break;
         
   case PV_INCLUDES:
      /* fields: item->u1.list     == pval list of PV_WORD elements, one per entry in the list
                 item->u2.arglist  == pval list of 4 PV_WORD elements for time values
      */
      destroy_pval(item->u1.list);
      break;
         
   case PV_STATEMENTBLOCK:
      /* fields: item->u1.list     == pval list of statements in block, one per entry in the list
      */
      destroy_pval(item->u1.list);
      break;
         
   case PV_LOCALVARDEC:
   case PV_VARDEC:
      /* fields: item->u1.str     == variable name
                 item->u2.val     == variable value to assign
      */
      if (item->u1.str)
         free(item->u1.str);
      if (item->u2.val)
         free(item->u2.val);
      break;
         
   case PV_GOTO:
      /* fields: item->u1.list     == pval list of PV_WORD target names, up to 3, in order as given by user.
                 item->u1.list->u1.str  == where the data on a PV_WORD will always be.
      */
      
      destroy_pval(item->u1.list);
      break;
         
   case PV_LABEL:
      /* fields: item->u1.str     == label name
      */
      if (item->u1.str)
         free(item->u1.str);
      break;
         
   case PV_FOR:
      /* fields: item->u1.for_init     == a string containing the initalizer
                 item->u2.for_test     == a string containing the loop test
                 item->u3.for_inc      == a string containing the loop increment

               item->u4.for_statements == a pval list of statements in the for ()
      */
      if (item->u1.for_init)
         free(item->u1.for_init);
      if (item->u2.for_test)
         free(item->u2.for_test);
      if (item->u3.for_inc)
         free(item->u3.for_inc);
      destroy_pval(item->u4.for_statements);
      break;
         
   case PV_WHILE:
      /* fields: item->u1.str        == the while conditional, as supplied by user

               item->u2.statements == a pval list of statements in the while ()
      */
      if (item->u1.str)
         free(item->u1.str);
      destroy_pval(item->u2.statements);
      break;
         
   case PV_BREAK:
      /* fields: none
      */
      break;
         
   case PV_RETURN:
      /* fields: none
      */
      break;
         
   case PV_CONTINUE:
      /* fields: none
      */
      break;
         
   case PV_IFTIME:
      /* fields: item->u1.list        == the 4 time values, in PV_WORD structs, linked list

               item->u2.statements == a pval list of statements in the if ()
               item->u3.else_statements == a pval list of statements in the else
                                    (could be zero)
      */
      destroy_pval(item->u1.list);
      destroy_pval(item->u2.statements);
      if (item->u3.else_statements) {
         destroy_pval(item->u3.else_statements);
      }
      break;
         
   case PV_RANDOM:
      /* fields: item->u1.str        == the random percentage, as supplied by user

               item->u2.statements == a pval list of statements in the true part ()
               item->u3.else_statements == a pval list of statements in the else
                                    (could be zero)
      fall thru to If */
   case PV_IF:
      /* fields: item->u1.str        == the if conditional, as supplied by user

               item->u2.statements == a pval list of statements in the if ()
               item->u3.else_statements == a pval list of statements in the else
                                    (could be zero)
      */
      if (item->u1.str)
         free(item->u1.str);
      destroy_pval(item->u2.statements);
      if (item->u3.else_statements) {
         destroy_pval(item->u3.else_statements);
      }
      break;
         
   case PV_SWITCH:
      /* fields: item->u1.str        == the switch expression

               item->u2.statements == a pval list of statements in the switch, 
                                    (will be case statements, most likely!)
      */
      if (item->u1.str)
         free(item->u1.str);
      destroy_pval(item->u2.statements);
      break;
         
   case PV_EXTENSION:
      /* fields: item->u1.str        == the extension name, label, whatever it's called

               item->u2.statements == a pval list of statements in the extension
               item->u3.hints      == a char * hint argument
               item->u4.regexten   == an int boolean. non-zero says that regexten was specified
      */
      if (item->u1.str)
         free(item->u1.str);
      if (item->u3.hints)
         free(item->u3.hints);
      destroy_pval(item->u2.statements);
      break;
         
   case PV_IGNOREPAT:
      /* fields: item->u1.str        == the ignorepat data
      */
      if (item->u1.str)
         free(item->u1.str);
      break;
         
   case PV_GLOBALS:
      /* fields: item->u1.statements     == pval list of statements, usually vardecs
      */
      destroy_pval(item->u1.statements);
      break;
   }
   free(item);
}
int do_pbx_load_module ( void  )
struct pval * find_context ( char *  name) [read]
struct pval * find_macro ( char *  name) [read]

Definition at line 1951 of file pval.c.

Referenced by check_pval_item().

{
   return_on_context_match = 1;
   count_labels = 0;
   match_context = name;
   match_exten = "*";  /* don't really need to set these, shouldn't be reached */
   match_label = "*";
   return match_pval(current_db);
}
int is_empty ( char *  arg)

Definition at line 1989 of file pval.c.

{
   if (!arg)
      return 1;
   if (*arg == 0)
      return 1;
   while (*arg) {
      if (*arg != ' ' && *arg != '\t')
         return 0;
      arg++;
   }
   return 1;
}
int is_float ( char *  arg)

Definition at line 1971 of file pval.c.

{
   char *s;
   for (s=arg; *s; s++) {
      if (*s != '.' && (*s < '0' || *s > '9'))
         return 0;
   }
   return 1;
}
int is_int ( char *  arg)

Definition at line 1980 of file pval.c.

{
   char *s;
   for (s=arg; *s; s++) {
      if (*s < '0' || *s > '9')
         return 0;
   }
   return 1;
}
void linkprio ( struct ael_extension *  exten,
struct ael_priority *  prio,
struct ael_extension *  mother_exten 
)

Definition at line 2944 of file pval.c.

References ael_extension::plist, ael_extension::plist_last, ael_priority::next, ael_priority::exten, exten, ael_priority::appargs, ael_extension::has_switch, malloc, and free.

Referenced by gen_prios(), and ast_compile_ael2().

{
   char *p1, *p2;
   
   if (!exten->plist) {
      exten->plist = prio;
      exten->plist_last = prio;
   } else {
      exten->plist_last->next = prio;
      exten->plist_last = prio;
   }
   if( !prio->exten )
      prio->exten = exten; /* don't override the switch value */
   /* The following code will cause all priorities within an extension 
      to have ${EXTEN} or ${EXTEN: replaced with ~~EXTEN~~, which is
      set just before the first switch in an exten. The switches
      will muck up the original ${EXTEN} value, so we save it away
      and the user accesses this copy instead. */
   if (prio->appargs && ((mother_exten && mother_exten->has_switch) || exten->has_switch) ) {
      while ((p1 = strstr(prio->appargs, "${EXTEN}"))) {
         p2 = malloc(strlen(prio->appargs)+5);
         *p1 = 0;
         strcpy(p2, prio->appargs);
         strcat(p2, "${~~EXTEN~~}");
         if (*(p1+8))
            strcat(p2, p1+8);
         free(prio->appargs);
         prio->appargs = p2;
      }
      while ((p1 = strstr(prio->appargs, "${EXTEN:"))) {
         p2 = malloc(strlen(prio->appargs)+5);
         *p1 = 0;
         strcpy(p2, prio->appargs);
         strcat(p2, "${~~EXTEN~~:");
         if (*(p1+8))
            strcat(p2, p1+8);
         free(prio->appargs);
         prio->appargs = p2;
      }
   }
}
struct ael_extension* new_exten ( void  ) [read]

Definition at line 2938 of file pval.c.

Referenced by gen_prios(), and ast_compile_ael2().

{
   struct ael_extension *x = (struct ael_extension *)calloc(sizeof(struct ael_extension),1);
   return x;
}
struct ael_priority* new_prio ( void  ) [read]

Definition at line 2932 of file pval.c.

Referenced by gen_prios(), and ast_compile_ael2().

{
   struct ael_priority *x = (struct ael_priority *)calloc(sizeof(struct ael_priority),1);
   return x;
}
void pvalAppCallAddArg ( pval *  p,
pval *  arg 
)

Definition at line 5305 of file pval.c.

References pvalCheckType(), PV_APPLICATION_CALL, pval::u2, pval::arglist, and linku1().

{
   if (!pvalCheckType(p, "pvalAppCallAddArg", PV_APPLICATION_CALL))
      return;
   if (!p->u2.arglist)
      p->u2.arglist = arg;
   else
      linku1(p->u2.arglist, arg);
}
char* pvalAppCallGetAppName ( pval *  p)

Definition at line 5291 of file pval.c.

References pvalCheckType(), PV_APPLICATION_CALL, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalAppCallGetAppName", PV_APPLICATION_CALL))
      return 0;
   return p->u1.str;
}
void pvalAppCallSetAppName ( pval *  p,
char *  name 
)

Definition at line 5284 of file pval.c.

References pvalCheckType(), PV_APPLICATION_CALL, pval::u1, pval::str, and name.

{
   if (!pvalCheckType(p, "pvalAppCallSetAppName", PV_APPLICATION_CALL))
      return;
   p->u1.str = name;
}
void pvalAppCallSetArglist ( pval *  p,
pval *  arglist 
)

Definition at line 5298 of file pval.c.

References pvalCheckType(), PV_APPLICATION_CALL, pval::u2, and pval::arglist.

{
   if (!pvalCheckType(p, "pvalAppCallSetArglist", PV_APPLICATION_CALL))
      return;
   p->u2.arglist = arglist;
}
pval* pvalAppCallWalkArgs ( pval *  p,
pval **  args 
)

Definition at line 5315 of file pval.c.

References pvalCheckType(), PV_APPLICATION_CALL, pval::u2, pval::arglist, pval::next, and args.

{
   if (!pvalCheckType(p, "pvalAppCallWalkArgs", PV_APPLICATION_CALL))
      return 0;
   if (!(*args))
      *args = p->u2.arglist;
   else {
      *args = (*args)->next;
   }
   return *args;
}
void pvalCasePatDefAddStatement ( pval *  p,
pval *  statement 
)

Definition at line 5340 of file pval.c.

References pval::u2, pval::arglist, pval::statements, and linku1().

{
   if (!p->u2.arglist)
      p->u2.statements = statement;
   else
      linku1(p->u2.statements, statement);
}
pval* pvalCasePatDefWalkStatements ( pval *  p,
pval **  statement 
)

Definition at line 5348 of file pval.c.

References pval::u2, pval::statements, and pval::next.

{
   if (!(*statement))
      *statement = p->u2.statements;
   else {
      *statement = (*statement)->next;
   }
   return *statement;
}
char* pvalCasePatGetVal ( pval *  p)

Definition at line 5335 of file pval.c.

References pval::u1, and pval::str.

{
   return p->u1.str;
}
void pvalCasePatSetVal ( pval *  p,
char *  val 
)

Definition at line 5328 of file pval.c.

References pvalCheckType(), PV_APPLICATION_CALL, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalAppCallWalkArgs", PV_APPLICATION_CALL))
      return;
   p->u1.str = val;
}
char* pvalCatchGetExtName ( pval *  p)

Definition at line 5366 of file pval.c.

References pvalCheckType(), PV_CATCH, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalCatchGetExtName", PV_CATCH))
      return 0;
   return p->u1.str;
}
pval* pvalCatchGetStatement ( pval *  p)

Definition at line 5380 of file pval.c.

References pvalCheckType(), PV_CATCH, pval::u2, and pval::statements.

{
   if (!pvalCheckType(p, "pvalCatchGetStatement", PV_CATCH))
      return 0;
   return p->u2.statements;
}
void pvalCatchSetExtName ( pval *  p,
char *  name 
)

Definition at line 5359 of file pval.c.

References pvalCheckType(), PV_CATCH, pval::u1, pval::str, and name.

{
   if (!pvalCheckType(p, "pvalCatchSetExtName", PV_CATCH))
      return;
   p->u1.str = name;
}
void pvalCatchSetStatement ( pval *  p,
pval *  statement 
)

Definition at line 5373 of file pval.c.

References pvalCheckType(), PV_CATCH, pval::u2, and pval::statements.

{
   if (!pvalCheckType(p, "pvalCatchSetStatement", PV_CATCH))
      return;
   p->u2.statements = statement;
}
int pvalCheckType ( pval *  p,
char *  funcname,
pvaltype  type 
)

Definition at line 5071 of file pval.c.

References pval::type, ast_log(), and LOG_ERROR.

Referenced by pvalWordSetString(), pvalWordGetString(), pvalMacroSetName(), pvalMacroGetName(), pvalMacroSetArglist(), pvalMacroAddArg(), pvalMacroWalkArgs(), pvalMacroAddStatement(), pvalMacroWalkStatements(), pvalContextSetName(), pvalContextGetName(), pvalContextSetAbstract(), pvalContextUnsetAbstract(), pvalContextGetAbstract(), pvalContextAddStatement(), pvalContextWalkStatements(), pvalMacroCallSetMacroName(), pvalMacroCallGetMacroName(), pvalMacroCallSetArglist(), pvalMacroCallAddArg(), pvalMacroCallWalkArgs(), pvalAppCallSetAppName(), pvalAppCallGetAppName(), pvalAppCallSetArglist(), pvalAppCallAddArg(), pvalAppCallWalkArgs(), pvalCasePatSetVal(), pvalCatchSetExtName(), pvalCatchGetExtName(), pvalCatchSetStatement(), pvalCatchGetStatement(), pvalSwitchesAddSwitch(), pvalSwitchesWalkNames(), pvalESwitchesAddSwitch(), pvalESwitchesWalkNames(), pvalIncludesAddInclude(), pvalIncludesAddIncludeWithTimeConstraints(), pvalIncludeGetTimeConstraints(), pvalIncludesWalk(), pvalStatementBlockAddStatement(), pvalStatementBlockWalkStatements(), pvalVarDecSetVarname(), pvalVarDecSetValue(), pvalVarDecGetVarname(), pvalVarDecGetValue(), pvalGotoSetTarget(), pvalGotoGetTarget(), pvalLabelSetName(), pvalLabelGetName(), pvalForSetInit(), pvalForSetTest(), pvalForSetInc(), pvalForSetStatement(), pvalForGetInit(), pvalForGetTest(), pvalForGetInc(), pvalForGetStatement(), pvalIfSetCondition(), pvalIfGetCondition(), pvalIfTimeSetCondition(), pvalIfTimeGetCondition(), pvalRandomSetCondition(), pvalRandomGetCondition(), pvalSwitchSetTestexpr(), pvalSwitchGetTestexpr(), pvalSwitchAddCase(), pvalSwitchWalkCases(), pvalExtenSetName(), pvalExtenGetName(), pvalExtenSetRegexten(), pvalExtenUnSetRegexten(), pvalExtenGetRegexten(), pvalExtenSetHints(), pvalExtenGetHints(), pvalExtenSetStatement(), pvalExtenGetStatement(), pvalIgnorePatSetPattern(), pvalIgnorePatGetPattern(), and pvalGlobalsWalkStatements().

{
   if (p->type != type)
   {
      ast_log(LOG_ERROR, "Func: %s the pval passed is not appropriate for this function!\n", funcname);
      return 0;
   }
   return 1;
}
pval* pvalConditionalGetElseStatement ( pval *  p)

Definition at line 5756 of file pval.c.

References pval::u3, and pval::else_statements.

{
   return p->u3.else_statements;
}
pval* pvalConditionalGetThenStatement ( pval *  p)

Definition at line 5751 of file pval.c.

References pval::u2, and pval::statements.

{
   return p->u2.statements;
}
void pvalConditionalSetElseStatement ( pval *  p,
pval *  statement 
)

Definition at line 5746 of file pval.c.

References pval::u3, and pval::else_statements.

{
   p->u3.else_statements = statement;
}
void pvalConditionalSetThenStatement ( pval *  p,
pval *  statement 
)

Definition at line 5741 of file pval.c.

References pval::u2, and pval::statements.

{
   p->u2.statements = statement;
}
void pvalContextAddStatement ( pval *  p,
pval *  statement 
)

Definition at line 5217 of file pval.c.

References pvalCheckType(), PV_CONTEXT, pval::u2, pval::statements, and linku1().

{
   if (!pvalCheckType(p, "pvalContextAddStatement", PV_CONTEXT))
      return;
   if (!p->u2.statements)
      p->u2.statements = statement;
   else
      linku1(p->u2.statements, statement);
}
int pvalContextGetAbstract ( pval *  p)

Definition at line 5208 of file pval.c.

References pvalCheckType(), PV_CONTEXT, pval::u3, and pval::abstract.

{
   if (!pvalCheckType(p, "pvalContextGetAbstract", PV_CONTEXT))
      return 0;
   return p->u3.abstract;
}
char* pvalContextGetName ( pval *  p)

Definition at line 5187 of file pval.c.

References pvalCheckType(), PV_CONTEXT, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalContextGetName", PV_CONTEXT))
      return 0;
   return p->u1.str;
}
void pvalContextSetAbstract ( pval *  p)

Definition at line 5194 of file pval.c.

References pvalCheckType(), PV_CONTEXT, pval::u3, and pval::abstract.

{
   if (!pvalCheckType(p, "pvalContextSetAbstract", PV_CONTEXT))
      return;
   p->u3.abstract = 1;
}
void pvalContextSetName ( pval *  p,
char *  name 
)

Definition at line 5180 of file pval.c.

References pvalCheckType(), PV_CONTEXT, pval::u1, pval::str, and name.

{
   if (!pvalCheckType(p, "pvalContextSetName", PV_CONTEXT))
      return;
   p->u1.str = name;
}
void pvalContextUnsetAbstract ( pval *  p)

Definition at line 5201 of file pval.c.

References pvalCheckType(), PV_CONTEXT, pval::u3, and pval::abstract.

{
   if (!pvalCheckType(p, "pvalContextUnsetAbstract", PV_CONTEXT))
      return;
   p->u3.abstract = 0;
}
pval* pvalContextWalkStatements ( pval *  p,
pval **  statements 
)

Definition at line 5227 of file pval.c.

References pvalCheckType(), PV_CONTEXT, pval::u2, pval::statements, and pval::next.

{
   if (!pvalCheckType(p, "pvalContextWalkStatements", PV_CONTEXT))
      return 0;
   if (!(*statements))
      *statements = p->u2.statements;
   else {
      *statements = (*statements)->next;
   }
   return *statements;
}
pval* pvalCreateNode ( pvaltype  type)

Definition at line 5082 of file pval.c.

References calloc, pval::type, and type.

Referenced by pvalSwitchesAddSwitch(), pvalESwitchesAddSwitch(), pvalIncludesAddInclude(), pvalIncludesAddIncludeWithTimeConstraints(), pvalGotoSetTarget(), and pvalIfTimeSetCondition().

{
   pval *p = calloc(1,sizeof(pval)); /* why, oh why, don't I use ast_calloc? Way, way, way too messy if I do! */
   p->type = type;                   /* remember, this can be used externally or internally to asterisk */
   return p;
}
void pvalESwitchesAddSwitch ( pval *  p,
char *  name 
)

Definition at line 5410 of file pval.c.

References pvalCheckType(), PV_ESWITCHES, pvalCreateNode(), PV_WORD, pval::u1, pval::str, name, pval::list, and linku1().

{
   pval *s;
   if (!pvalCheckType(p, "pvalESwitchesAddSwitch", PV_ESWITCHES))
      return;
   s = pvalCreateNode(PV_WORD);
   s->u1.str = name;
   p->u1.list = linku1(p->u1.list, s);
}
char* pvalESwitchesWalkNames ( pval *  p,
pval **  next_item 
)

Definition at line 5420 of file pval.c.

References pvalCheckType(), PV_ESWITCHES, pval::u1, pval::list, pval::next, and pval::str.

{
   if (!pvalCheckType(p, "pvalESwitchesWalkNames", PV_ESWITCHES))
      return 0;
   if (!(*next_item))
      *next_item = p->u1.list;
   else {
      *next_item = (*next_item)->next;
   }
   return (*next_item)->u1.str;
}
char* pvalExtenGetHints ( pval *  p)

Definition at line 5842 of file pval.c.

References pvalCheckType(), PV_EXTENSION, pval::u3, and pval::hints.

{
   if (!pvalCheckType(p, "pvalExtenGetHints", PV_EXTENSION))
      return 0;
   return p->u3.hints;
}
char* pvalExtenGetName ( pval *  p)

Definition at line 5807 of file pval.c.

References pvalCheckType(), PV_EXTENSION, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalExtenGetName", PV_EXTENSION))
      return 0;
   return p->u1.str;
}
int pvalExtenGetRegexten ( pval *  p)

Definition at line 5828 of file pval.c.

References pvalCheckType(), PV_EXTENSION, pval::u4, and pval::regexten.

{
   if (!pvalCheckType(p, "pvalExtenGetRegexten", PV_EXTENSION))
      return 0;
   return p->u4.regexten;
}
pval* pvalExtenGetStatement ( pval *  p)

Definition at line 5856 of file pval.c.

References pvalCheckType(), PV_EXTENSION, pval::u2, and pval::statements.

{
   if (!pvalCheckType(p, "pvalExtenGetStatement", PV_EXTENSION))
      return 0;
   return p->u2.statements;
}
void pvalExtenSetHints ( pval *  p,
char *  hints 
)

Definition at line 5835 of file pval.c.

References pvalCheckType(), PV_EXTENSION, pval::u3, pval::hints, and hints.

{
   if (!pvalCheckType(p, "pvalExtenSetHints", PV_EXTENSION))
      return;
   p->u3.hints = hints;
}
void pvalExtenSetName ( pval *  p,
char *  name 
)

Definition at line 5800 of file pval.c.

References pvalCheckType(), PV_EXTENSION, pval::u1, pval::str, and name.

{
   if (!pvalCheckType(p, "pvalExtenSetName", PV_EXTENSION))
      return;
   p->u1.str = name;
}
void pvalExtenSetRegexten ( pval *  p)

Definition at line 5814 of file pval.c.

References pvalCheckType(), PV_EXTENSION, pval::u4, and pval::regexten.

{
   if (!pvalCheckType(p, "pvalExtenSetRegexten", PV_EXTENSION))
      return;
   p->u4.regexten = 1;
}
void pvalExtenSetStatement ( pval *  p,
pval *  statement 
)

Definition at line 5849 of file pval.c.

References pvalCheckType(), PV_EXTENSION, pval::u2, and pval::statements.

{
   if (!pvalCheckType(p, "pvalExtenSetStatement", PV_EXTENSION))
      return;
   p->u2.statements = statement;
}
void pvalExtenUnSetRegexten ( pval *  p)

Definition at line 5821 of file pval.c.

References pvalCheckType(), PV_EXTENSION, pval::u4, and pval::regexten.

{
   if (!pvalCheckType(p, "pvalExtenUnSetRegexten", PV_EXTENSION))
      return;
   p->u4.regexten = 0;
}
char* pvalForGetInc ( pval *  p)

Definition at line 5668 of file pval.c.

References pvalCheckType(), PV_FOR, pval::u3, and pval::for_inc.

{
   if (!pvalCheckType(p, "pvalForGetInc", PV_FOR))
      return 0;
   return p->u3.for_inc;
}
char* pvalForGetInit ( pval *  p)

Definition at line 5654 of file pval.c.

References pvalCheckType(), PV_FOR, pval::u1, and pval::for_init.

{
   if (!pvalCheckType(p, "pvalForGetInit", PV_FOR))
      return 0;
   return p->u1.for_init;
}
pval* pvalForGetStatement ( pval *  p)

Definition at line 5675 of file pval.c.

References pvalCheckType(), PV_FOR, pval::u4, and pval::for_statements.

{
   if (!pvalCheckType(p, "pvalForGetStatement", PV_FOR))
      return 0;
   return p->u4.for_statements;
}
char* pvalForGetTest ( pval *  p)

Definition at line 5661 of file pval.c.

References pvalCheckType(), PV_FOR, pval::u2, and pval::for_test.

{
   if (!pvalCheckType(p, "pvalForGetTest", PV_FOR))
      return 0;
   return p->u2.for_test;
}
void pvalForSetInc ( pval *  p,
char *  inc 
)

Definition at line 5640 of file pval.c.

References pvalCheckType(), PV_FOR, pval::u3, and pval::for_inc.

{
   if (!pvalCheckType(p, "pvalForSetInc", PV_FOR))
      return;
   p->u3.for_inc = inc;
}
void pvalForSetInit ( pval *  p,
char *  init 
)

Definition at line 5626 of file pval.c.

References pvalCheckType(), PV_FOR, pval::u1, and pval::for_init.

{
   if (!pvalCheckType(p, "pvalForSetInit", PV_FOR))
      return;
   p->u1.for_init = init;
}
void pvalForSetStatement ( pval *  p,
pval *  statement 
)

Definition at line 5647 of file pval.c.

References pvalCheckType(), PV_FOR, pval::u4, and pval::for_statements.

{
   if (!pvalCheckType(p, "pvalForSetStatement", PV_FOR))
      return;
   p->u4.for_statements = statement;
}
void pvalForSetTest ( pval *  p,
char *  test 
)

Definition at line 5633 of file pval.c.

References pvalCheckType(), PV_FOR, pval::u2, and pval::for_test.

{
   if (!pvalCheckType(p, "pvalForSetTest", PV_FOR))
      return;
   p->u2.for_test = test;
}
void pvalGlobalsAddStatement ( pval *  p,
pval *  statement 
)

Definition at line 5879 of file pval.c.

References pval::type, PV_GLOBALS, ast_log(), LOG_ERROR, pval::u1, pval::statements, and linku1().

{
   if (p->type != PV_GLOBALS) {
      ast_log(LOG_ERROR, "pvalGlobalsAddStatement called where first arg is not a Globals!\n");
   } else {
      if (!p->u1.statements) {
         p->u1.statements = statement;
      } else {
         p->u1.statements = linku1(p->u1.statements,statement);
      }
   }
}
pval* pvalGlobalsWalkStatements ( pval *  p,
pval **  next_statement 
)

Definition at line 5892 of file pval.c.

References pvalCheckType(), PV_GLOBALS, and pval::next.

{
   if (!pvalCheckType(p, "pvalGlobalsWalkStatements", PV_GLOBALS))
      return 0;
   if (!*next_statement) {
      *next_statement = p;
      return p;
   } else {
      *next_statement = (*next_statement)->next;
      return (*next_statement)->next;
   }
}
void pvalGotoGetTarget ( pval *  p,
char **  context,
char **  exten,
char **  label 
)

Definition at line 5584 of file pval.c.

References pvalCheckType(), PV_GOTO, pval::u1, pval::list, pval::next, and pval::str.

{
   if (!pvalCheckType(p, "pvalGotoGetTarget", PV_GOTO))
      return;
   if (p->u1.list && p->u1.list->next && p->u1.list->next->next) {
      *context = p->u1.list->u1.str;
      *exten = p->u1.list->next->u1.str;
      *label = p->u1.list->next->next->u1.str;
      
   } else if (p->u1.list && p->u1.list->next ) {
      *exten = p->u1.list->u1.str;
      *label = p->u1.list->next->u1.str;
      *context = 0;

   } else if (p->u1.list) {
      *label = p->u1.list->u1.str;
      *context = 0;
      *exten = 0;
      
   } else {
      *context = 0;
      *exten = 0;
      *label = 0;
   }
}
void pvalGotoSetTarget ( pval *  p,
char *  context,
char *  exten,
char *  label 
)

Definition at line 5548 of file pval.c.

References ext, pvalCheckType(), PV_GOTO, pvalCreateNode(), PV_WORD, pval::u1, pval::str, context, exten, pval::next, and pval::list.

{
   pval *con, *ext, *pri;
   
   if (!pvalCheckType(p, "pvalGotoSetTarget", PV_GOTO))
      return;
   if (context && strlen(context)) {
      con = pvalCreateNode(PV_WORD);
      ext = pvalCreateNode(PV_WORD);
      pri = pvalCreateNode(PV_WORD);
      
      con->u1.str = context;
      ext->u1.str = exten;
      pri->u1.str = label;
      
      con->next = ext;
      ext->next = pri;
      p->u1.list = con;
   } else if (exten && strlen(exten)) {
      ext = pvalCreateNode(PV_WORD);
      pri = pvalCreateNode(PV_WORD);
      
      ext->u1.str = exten;
      pri->u1.str = label;
      
      ext->next = pri;
      p->u1.list = ext;
   } else {
      pri = pvalCreateNode(PV_WORD);
      
      pri->u1.str = label;
      
      p->u1.list = pri;
   }
}
char* pvalIfGetCondition ( pval *  p)

Definition at line 5691 of file pval.c.

References pvalCheckType(), PV_IFTIME, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalIfGetCondition", PV_IFTIME))
      return 0;
   return p->u1.str;
}
void pvalIfSetCondition ( pval *  p,
char *  expr 
)

Definition at line 5684 of file pval.c.

References pvalCheckType(), PV_IF, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalIfSetCondition", PV_IF))
      return;
   p->u1.str = expr;
}
void pvalIfTimeGetCondition ( pval *  p,
char **  hour_range,
char **  dow_range,
char **  dom_range,
char **  month_range 
)

Definition at line 5717 of file pval.c.

References pvalCheckType(), PV_IFTIME, pval::u1, pval::list, pval::str, and pval::next.

{
   if (!pvalCheckType(p, "pvalIfTimeGetCondition", PV_IFTIME))
      return;
   *hour_range = p->u1.list->u1.str;
   *dow_range = p->u1.list->next->u1.str;
   *dom_range = p->u1.list->next->next->u1.str;
   *month_range = p->u1.list->next->next->next->u1.str;
}
void pvalIfTimeSetCondition ( pval *  p,
char *  hour_range,
char *  dow_range,
char *  dom_range,
char *  mon_range 
)

Definition at line 5698 of file pval.c.

References pvalCreateNode(), PV_WORD, pvalCheckType(), PV_IFTIME, pvalWordSetString(), pval::next, pval::u1, and pval::list.

{
   pval *hr = pvalCreateNode(PV_WORD);
   pval *dow = pvalCreateNode(PV_WORD);
   pval *dom = pvalCreateNode(PV_WORD);
   pval *mon = pvalCreateNode(PV_WORD);
   if (!pvalCheckType(p, "pvalIfTimeSetCondition", PV_IFTIME))
      return;
   pvalWordSetString(hr, hour_range);
   pvalWordSetString(dow, dow_range);
   pvalWordSetString(dom, dom_range);
   pvalWordSetString(mon, mon_range);
   dom->next = mon;
   dow->next = dom;
   hr->next = dow;
   p->u1.list = hr;
}
char* pvalIgnorePatGetPattern ( pval *  p)

Definition at line 5871 of file pval.c.

References pvalCheckType(), PV_IGNOREPAT, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalIgnorePatGetPattern", PV_IGNOREPAT))
      return 0;
   return p->u1.str;
}
void pvalIgnorePatSetPattern ( pval *  p,
char *  pat 
)

Definition at line 5864 of file pval.c.

References pvalCheckType(), PV_IGNOREPAT, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalIgnorePatSetPattern", PV_IGNOREPAT))
      return;
   p->u1.str = pat;
}
void pvalIncludeGetTimeConstraints ( pval *  p,
char **  hour_range,
char **  dom_range,
char **  dow_range,
char **  month_range 
)

Definition at line 5471 of file pval.c.

References pvalCheckType(), PV_WORD, pval::u2, pval::arglist, pval::u1, pval::str, and pval::next.

{
   if (!pvalCheckType(p, "pvalIncludeGetTimeConstraints", PV_WORD))
      return;
   if (p->u2.arglist) {
      *hour_range = p->u2.arglist->u1.str;
      *dom_range = p->u2.arglist->next->u1.str;
      *dow_range = p->u2.arglist->next->next->u1.str;
      *month_range = p->u2.arglist->next->next->next->u1.str;
   } else {
      *hour_range = 0;
      *dom_range = 0;
      *dow_range = 0;
      *month_range = 0;
   }
}
void pvalIncludesAddInclude ( pval *  p,
const char *  include 
)

Definition at line 5433 of file pval.c.

References pvalCheckType(), PV_INCLUDES, pvalCreateNode(), PV_WORD, pval::u1, pval::str, pval::list, and linku1().

{
   pval *s;
   if (!pvalCheckType(p, "pvalIncludesAddSwitch", PV_INCLUDES))
      return;
   s = pvalCreateNode(PV_WORD);
   s->u1.str = (char *)include;
   p->u1.list = linku1(p->u1.list, s);
}
void pvalIncludesAddIncludeWithTimeConstraints ( pval *  p,
const char *  include,
char *  hour_range,
char *  dom_range,
char *  dow_range,
char *  month_range 
)

Definition at line 5444 of file pval.c.

References pvalCreateNode(), PV_WORD, pvalCheckType(), PV_INCLUDES, pval::u1, pval::str, pval::list, linku1(), pval::u2, pval::arglist, and pval::next.

{
   pval *hr = pvalCreateNode(PV_WORD);
   pval *dom = pvalCreateNode(PV_WORD);
   pval *dow = pvalCreateNode(PV_WORD);
   pval *mon = pvalCreateNode(PV_WORD);
   pval *s = pvalCreateNode(PV_WORD);
   
   if (!pvalCheckType(p, "pvalIncludeAddIncludeWithTimeConstraints", PV_INCLUDES))
      return;

   s->u1.str = (char *)include;
   p->u1.list = linku1(p->u1.list, s);

   hr->u1.str = hour_range;
   dom->u1.str = dom_range;
   dow->u1.str = dow_range;
   mon->u1.str = month_range;

   s->u2.arglist = hr;

   hr->next = dom;
   dom->next = dow;
   dow->next = mon;
   mon->next = 0;
}
char* pvalIncludesWalk ( pval *  p,
pval **  next_item 
)

Definition at line 5488 of file pval.c.

References pvalCheckType(), PV_INCLUDES, pval::u1, pval::list, pval::next, and pval::str.

{
   if (!pvalCheckType(p, "pvalIncludesWalk", PV_INCLUDES))
      return 0;
   if (!(*next_item))
      *next_item = p->u1.list;
   else {
      *next_item = (*next_item)->next;
   }
   return (*next_item)->u1.str;
}
char* pvalLabelGetName ( pval *  p)

Definition at line 5618 of file pval.c.

References pvalCheckType(), PV_LABEL, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalLabelGetName", PV_LABEL))
      return 0;
   return p->u1.str;
}
void pvalLabelSetName ( pval *  p,
char *  name 
)

Definition at line 5611 of file pval.c.

References pvalCheckType(), PV_LABEL, pval::u1, pval::str, and name.

{
   if (!pvalCheckType(p, "pvalLabelSetName", PV_LABEL))
      return;
   p->u1.str = name;
}
void pvalMacroAddArg ( pval *  p,
pval *  arg 
)

Definition at line 5131 of file pval.c.

References pvalCheckType(), PV_MACRO, pval::u2, pval::arglist, and linku1().

{
   if (!pvalCheckType(p, "pvalMacroAddArg", PV_MACRO))
      return;
   if (!p->u2.arglist)
      p->u2.arglist = arg;
   else
      linku1(p->u2.arglist, arg);

}
void pvalMacroAddStatement ( pval *  p,
pval *  statement 
)

Definition at line 5154 of file pval.c.

References pvalCheckType(), PV_MACRO, pval::u3, pval::macro_statements, and linku1().

{
   if (!pvalCheckType(p, "pvalMacroAddStatement", PV_MACRO))
      return;
   if (!p->u3.macro_statements)
      p->u3.macro_statements = statement;
   else
      linku1(p->u3.macro_statements, statement);

   
}
void pvalMacroCallAddArg ( pval *  p,
pval *  arg 
)

Definition at line 5261 of file pval.c.

References pvalCheckType(), PV_MACRO_CALL, pval::u2, pval::arglist, and linku1().

{
   if (!pvalCheckType(p, "pvalMacroCallGetAddArg", PV_MACRO_CALL))
      return;
   if (!p->u2.arglist)
      p->u2.arglist = arg;
   else
      linku1(p->u2.arglist, arg);
}
char* pvalMacroCallGetMacroName ( pval *  p)

Definition at line 5247 of file pval.c.

References pvalCheckType(), PV_MACRO_CALL, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalMacroCallGetMacroName", PV_MACRO_CALL))
      return 0;
   return p->u1.str;
}
void pvalMacroCallSetArglist ( pval *  p,
pval *  arglist 
)

Definition at line 5254 of file pval.c.

References pvalCheckType(), PV_MACRO_CALL, pval::u2, and pval::arglist.

{
   if (!pvalCheckType(p, "pvalMacroCallSetArglist", PV_MACRO_CALL))
      return;
   p->u2.arglist = arglist;
}
void pvalMacroCallSetMacroName ( pval *  p,
char *  name 
)

Definition at line 5240 of file pval.c.

References pvalCheckType(), PV_MACRO_CALL, pval::u1, pval::str, and name.

{
   if (!pvalCheckType(p, "pvalMacroCallSetMacroName", PV_MACRO_CALL))
      return;
   p->u1.str = name;
}
pval* pvalMacroCallWalkArgs ( pval *  p,
pval **  args 
)

Definition at line 5271 of file pval.c.

References pvalCheckType(), PV_MACRO_CALL, pval::u2, pval::arglist, pval::next, and args.

{
   if (!pvalCheckType(p, "pvalMacroCallWalkArgs", PV_MACRO_CALL))
      return 0;
   if (!(*args))
      *args = p->u2.arglist;
   else {
      *args = (*args)->next;
   }
   return *args;
}
char* pvalMacroGetName ( pval *  p)

Definition at line 5117 of file pval.c.

References pvalCheckType(), PV_MACRO, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalMacroGetName", PV_MACRO))
      return 0;
   return p->u1.str;
}
void pvalMacroSetArglist ( pval *  p,
pval *  arglist 
)

Definition at line 5124 of file pval.c.

References pvalCheckType(), PV_MACRO, pval::u2, and pval::arglist.

{
   if (!pvalCheckType(p, "pvalMacroSetArglist", PV_MACRO))
      return;
   p->u2.arglist = arglist;
}
void pvalMacroSetName ( pval *  p,
char *  name 
)

Definition at line 5110 of file pval.c.

References pvalCheckType(), PV_MACRO, pval::u1, pval::str, and name.

{
   if (!pvalCheckType(p, "pvalMacroSetName", PV_MACRO))
      return;
   p->u1.str = name;
}
pval* pvalMacroWalkArgs ( pval *  p,
pval **  arg 
)

Definition at line 5142 of file pval.c.

References pvalCheckType(), PV_MACRO, pval::u2, pval::arglist, and pval::next.

{
   if (!pvalCheckType(p, "pvalMacroWalkArgs", PV_MACRO))
      return 0;
   if (!(*arg))
      *arg = p->u2.arglist;
   else {
      *arg = (*arg)->next;
   }
   return *arg;
}
pval* pvalMacroWalkStatements ( pval *  p,
pval **  next_statement 
)

Definition at line 5166 of file pval.c.

References pvalCheckType(), PV_MACRO, pval::u3, pval::macro_statements, and pval::next.

{
   if (!pvalCheckType(p, "pvalMacroWalkStatements", PV_MACRO))
      return 0;
   if (!(*next_statement))
      *next_statement = p->u3.macro_statements;
   else {
      *next_statement = (*next_statement)->next;
   }
   return *next_statement;
}
pvaltype pvalObjectGetType ( pval *  p)

Definition at line 5089 of file pval.c.

References pval::type.

{
   return p->type;
}
char* pvalRandomGetCondition ( pval *  p)

Definition at line 5734 of file pval.c.

References pvalCheckType(), PV_RANDOM, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalRandomGetCondition", PV_RANDOM))
      return 0;
   return p->u1.str;
}
void pvalRandomSetCondition ( pval *  p,
char *  percent 
)

Definition at line 5727 of file pval.c.

References pvalCheckType(), PV_RANDOM, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalRandomSetCondition", PV_RANDOM))
      return;
   p->u1.str = percent;
}
void pvalStatementBlockAddStatement ( pval *  p,
pval *  statement 
)

Definition at line 5501 of file pval.c.

References pvalCheckType(), PV_STATEMENTBLOCK, pval::u1, pval::list, and linku1().

{
   if (!pvalCheckType(p, "pvalStatementBlockAddStatement", PV_STATEMENTBLOCK))
      return;
   p->u1.list = linku1(p->u1.list, statement);
}
pval* pvalStatementBlockWalkStatements ( pval *  p,
pval **  next_statement 
)

Definition at line 5508 of file pval.c.

References pvalCheckType(), PV_STATEMENTBLOCK, pval::u1, pval::list, and pval::next.

{
   if (!pvalCheckType(p, "pvalStatementBlockWalkStatements", PV_STATEMENTBLOCK))
      return 0;
   if (!(*next_statement))
      *next_statement = p->u1.list;
   else {
      *next_statement = (*next_statement)->next;
   }
   return *next_statement;
}
void pvalSwitchAddCase ( pval *  p,
pval *  Case 
)

Definition at line 5775 of file pval.c.

References pvalCheckType(), PV_SWITCH, PV_CASE, pval::u2, pval::statements, and linku1().

{
   if (!pvalCheckType(p, "pvalSwitchAddCase", PV_SWITCH))
      return;
   if (!pvalCheckType(Case, "pvalSwitchAddCase", PV_CASE))
      return;
   if (!p->u2.statements)
      p->u2.statements = Case;
   else
      linku1(p->u2.statements, Case);
}
void pvalSwitchesAddSwitch ( pval *  p,
char *  name 
)

Definition at line 5388 of file pval.c.

References pvalCheckType(), PV_SWITCHES, pvalCreateNode(), PV_WORD, pval::u1, pval::str, name, pval::list, and linku1().

{
   pval *s;
   if (!pvalCheckType(p, "pvalSwitchesAddSwitch", PV_SWITCHES))
      return;
   s = pvalCreateNode(PV_WORD);
   s->u1.str = name;
   p->u1.list = linku1(p->u1.list, s);
}
char* pvalSwitchesWalkNames ( pval *  p,
pval **  next_item 
)

Definition at line 5398 of file pval.c.

References pvalCheckType(), PV_SWITCHES, pval::u1, pval::list, pval::next, and pval::str.

{
   if (!pvalCheckType(p, "pvalSwitchesWalkNames", PV_SWITCHES))
      return 0;
   if (!(*next_item))
      *next_item = p->u1.list;
   else {
      *next_item = (*next_item)->next;
   }
   return (*next_item)->u1.str;
}
char* pvalSwitchGetTestexpr ( pval *  p)

Definition at line 5768 of file pval.c.

References pvalCheckType(), PV_SWITCH, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalSwitchGetTestexpr", PV_SWITCH))
      return 0;
   return p->u1.str;
}
void pvalSwitchSetTestexpr ( pval *  p,
char *  expr 
)

Definition at line 5761 of file pval.c.

References pvalCheckType(), PV_SWITCH, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalSwitchSetTestexpr", PV_SWITCH))
      return;
   p->u1.str = expr;
}
pval* pvalSwitchWalkCases ( pval *  p,
pval **  next_case 
)

Definition at line 5787 of file pval.c.

References pvalCheckType(), PV_SWITCH, pval::u2, pval::statements, and pval::next.

{
   if (!pvalCheckType(p, "pvalSwitchWalkCases", PV_SWITCH))
      return 0;
   if (!(*next_case))
      *next_case = p->u2.statements;
   else {
      *next_case = (*next_case)->next;
   }
   return *next_case;
}
void pvalTopLevAddObject ( pval *  p,
pval *  contextOrObj 
)

Definition at line 5906 of file pval.c.

References linku1(), ast_log(), and LOG_ERROR.

{
   if (p) {
      linku1(p,contextOrObj);
   } else {
      ast_log(LOG_ERROR, "First arg to pvalTopLevel is NULL!\n");
   }
}
pval* pvalTopLevWalkObjects ( pval *  p,
pval **  next_obj 
)

Definition at line 5915 of file pval.c.

References pval::next.

{
   if (!*next_obj) {
      *next_obj = p;
      return p;
   } else {
      *next_obj = (*next_obj)->next;
      return (*next_obj)->next;
   }
}
char* pvalVarDecGetValue ( pval *  p)

Definition at line 5541 of file pval.c.

References pvalCheckType(), PV_VARDEC, pval::u2, and pval::val.

{
   if (!pvalCheckType(p, "pvalVarDecGetValue", PV_VARDEC))
      return 0;
   return p->u2.val;
}
char* pvalVarDecGetVarname ( pval *  p)

Definition at line 5534 of file pval.c.

References pvalCheckType(), PV_VARDEC, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalVarDecGetVarname", PV_VARDEC))
      return 0;
   return p->u1.str;
}
void pvalVarDecSetValue ( pval *  p,
char *  value 
)

Definition at line 5527 of file pval.c.

References pvalCheckType(), PV_VARDEC, pval::u2, pval::val, and value.

{
   if (!pvalCheckType(p, "pvalVarDecSetValue", PV_VARDEC))
      return;
   p->u2.val = value;
}
void pvalVarDecSetVarname ( pval *  p,
char *  name 
)

Definition at line 5520 of file pval.c.

References pvalCheckType(), PV_VARDEC, pval::u1, pval::str, and name.

{
   if (!pvalCheckType(p, "pvalVarDecSetVarname", PV_VARDEC))
      return;
   p->u1.str = name;
}
char* pvalWordGetString ( pval *  p)

Definition at line 5102 of file pval.c.

References pvalCheckType(), PV_WORD, pval::u1, and pval::str.

{
   if (!pvalCheckType(p, "pvalWordGetString", PV_WORD))
      return 0;
   return p->u1.str;
}
void pvalWordSetString ( pval *  p,
char *  str 
)

Definition at line 5095 of file pval.c.

References pvalCheckType(), PV_WORD, pval::u1, pval::str, and str.

Referenced by pvalIfTimeSetCondition().

{
   if (!pvalCheckType(p, "pvalWordSetString", PV_WORD))
      return;
   p->u1.str = str;
}
void set_priorities ( struct ael_extension *  exten)

Definition at line 4226 of file pval.c.

Referenced by ast_compile_ael2().

{
   int i;
   struct ael_priority *pr;
   do {
      if (exten->is_switch)
         i = 10;
      else if (exten->regexten)
         i=2;
      else
         i=1;
      
      for (pr=exten->plist; pr; pr=pr->next) {
         pr->priority_num = i;
         
         if (!pr->origin || (pr->origin && pr->origin->type != PV_LABEL) ) /* Labels don't show up in the dialplan,
                                      but we want them to point to the right
                                      priority, which would be the next line
                                      after the label; */
            i++;
      }
      
      exten = exten->next_exten;
   } while ( exten );
}