[asterisk-commits] murf: branch murf/bug_7638 r52203 - in
/team/murf/bug_7638: include/asterisk/...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Jan 24 19:44:18 MST 2007
Author: murf
Date: Wed Jan 24 20:44:17 2007
New Revision: 52203
URL: http://svn.digium.com/view/asterisk?view=rev&rev=52203
Log:
Got it working under the new PI. The crash I saw was a bug in the config code; it was fixed in the original code after I stole it.
Modified:
team/murf/bug_7638/include/asterisk/pval.h
team/murf/bug_7638/main/pval.c
team/murf/bug_7638/utils/check_expr.c
team/murf/bug_7638/utils/conf2ael.c
team/murf/bug_7638/utils/config_external.c
Modified: team/murf/bug_7638/include/asterisk/pval.h
URL: http://svn.digium.com/view/asterisk/team/murf/bug_7638/include/asterisk/pval.h?view=diff&rev=52203&r1=52202&r2=52203
==============================================================================
--- team/murf/bug_7638/include/asterisk/pval.h (original)
+++ team/murf/bug_7638/include/asterisk/pval.h Wed Jan 24 20:44:17 2007
@@ -149,4 +149,124 @@
int is_int(char *arg );
int is_empty(char *arg);
+/* PVAL PI */
+
+
+pval *pvalCreateNode( pvaltype type );
+pvaltype pvalObjectGetType( pval *p );
+
+void pvalWordSetString( pval *p, char *str);
+char *pvalWordGetString( pval *p );
+
+void pvalMacroSetName( pval *p, char *name);
+char *pvalMacroGetName( pval *p );
+void pvalMacroSetArglist( pval *p, pval *arglist );
+void pvalMacroAddArg( pval *p, pval *arg );
+pval *pvalMacroWalkArgs( pval *p, pval **arg );
+void pvalMacroAddStatement( pval *p, pval *statement );
+pval *pvalMacroWalkStatements( pval *p, pval **next_statement );
+
+void pvalContextSetName( pval *p, char *name);
+char *pvalContextGetName( pval *p );
+void pvalContextSetAbstract( pval *p );
+void pvalContextUnsetAbstract( pval *p );
+int pvalContextGetAbstract( pval *p );
+void pvalContextAddStatement( pval *p, pval *statement);
+pval *pvalContextWalkStatements( pval *p, pval **statements );
+
+void pvalMacroCallSetMacroName( pval *p, char *name );
+char* pvalMacroCallGetMacroName( pval *p );
+void pvalMacroCallSetArglist( pval *p, pval *arglist );
+void pvalMacroCallAddArg( pval *p, pval *arg );
+pval *pvalMacroCallWalkArgs( pval *p, pval **args );
+
+void pvalAppCallSetAppName( pval *p, char *name );
+char* pvalAppCallGetAppName( pval *p );
+void pvalAppCallSetArglist( pval *p, pval *arglist );
+void pvalAppCallAddArg( pval *p, pval *arg );
+pval *pvalAppCallWalkArgs( pval *p, pval **args );
+
+void pvalCasePatSetVal( pval *p, char *val );
+char* pvalCasePatGetVal( pval *p );
+void pvalCasePatDefAddStatement( pval *p, pval *statement );
+pval *pvalCasePatDefWalkStatements( pval *p, pval **statement );
+
+void pvalCatchSetExtName( pval *p, char *name );
+char* pvalCatchGetExtName( pval *p );
+void pvalCatchSetStatement( pval *p, pval *statement );
+pval *pvalCatchGetStatement( pval *p );
+
+void pvalSwitchesAddSwitch( pval *p, char *name );
+char* pvalSwitchesWalkNames( pval *p, pval **next_item );
+void pvalESwitchesAddSwitch( pval *p, char *name );
+char* pvalESwitchesWalkNames( pval *p, pval **next_item );
+
+void pvalIncludesAddInclude( pval *p, char *include );
+
+void pvalIncludeAddIncludeWithTimeConstraints( pval *p, char *include, char *hour_range, char *dom_range, char *dow_range, char *month_range );
+void pvalIncludeGetTimeConstraints( pval *p, char **hour_range, char **dom_range, char **dow_range, char **month_range );
+char* pvalIncludesWalk( pval *p, pval **next_item );
+
+void pvalStatementBlockAddStatement( pval *p, pval *statement);
+pval *pvalStatementBlockWalkStatements( pval *p, pval **next_statement);
+
+void pvalVarDecSetVarname( pval *p, char *name );
+void pvalVarDecSetValue( pval *p, char *value );
+char* pvalVarDecGetVarname( pval *p );
+char* pvalVarDecGetValue( pval *p );
+
+void pvalGotoSetTarget( pval *p, char *context, char *exten, char *label );
+void pvalGotoGetTarget( pval *p, char **context, char **exten, char **label );
+
+void pvalLabelSetName( pval *p, char *name );
+char* pvalLabelGetName( pval *p );
+
+void pvalForSetInit( pval *p, char *init );
+void pvalForSetTest( pval *p, char *test );
+void pvalForSetInc( pval *p, char *inc );
+void pvalForSetStatement( pval *p, pval *statement );
+char* pvalForGetInit( pval *p );
+char* pvalForGetTest( pval *p );
+char* pvalForGetInc( pval *p );
+pval* pvalForGetStatement( pval *p );
+
+
+void pvalIfSetCondition( pval *p, char *expr );
+char* pvalIfGetCondition( pval *p );
+void pvalIfTimeSetCondition( pval *p, char *hour_range, char *dow_range, char *dom_range, char *mon_range ); /* time range format: 24-hour format begin-end|dow range|dom range|month range */
+void pvalIfTimeGetCondition( pval *p, char **hour_range, char **dow_range, char **dom_range, char **month_range );
+void pvalRandomSetCondition( pval *p, char *percent );
+char* pvalRandomGetCondition( pval *p );
+void pvalConditionalSetThenStatement( pval *p, pval *statement );
+void pvalConditionalSetElseStatement( pval *p, pval *statement );
+pval* pvalConditionalGetThenStatement( pval *p );
+pval* pvalConditionalGetElseStatement( pval *p );
+
+void pvalSwitchSetTestexpr( pval *p, char *expr );
+char* pvalSwitchGetTestexpr( pval *p );
+void pvalSwitchAddCase( pval *p, pval *Case );
+pval* pvalSwitchWalkCases( pval *p, pval **next_case );
+
+void pvalExtenSetName( pval *p, char *name );
+char *pvalExtenGetName( pval *p );
+void pvalExtenSetRegexten( pval *p );
+void pvalExtenUnSetRegexten( pval *p );
+int pvalExtenGetRegexten( pval *p );
+void pvalExtenSetHints( pval *p, char *hints );
+char* pvalExtenGetHints( pval *p );
+void pvalExtenSetStatement( pval *p, pval *statement );
+pval* pvalExtenGetStatement( pval *p );
+
+void pvalIgnorePatSetPattern( pval *p, char *pat );
+char* pvalIgnorePatGetPattern( pval *p );
+
+void pvalGlobalsAddStatement( pval *p, pval *statement );
+pval* pvalGlobalsWalkStatements( pval *p, pval **next_statement );
+
+void pvalTopLevAddObject( pval *p, pval *contextOrObj );
+pval* pvalTopLevWalkObjects( pval *p, pval **next_obj );
+
+int pvalCheckType( pval *p, char *funcname, pvaltype type );
+
+
#endif
Modified: team/murf/bug_7638/main/pval.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_7638/main/pval.c?view=diff&rev=52203&r1=52202&r2=52203
==============================================================================
--- team/murf/bug_7638/main/pval.c (original)
+++ team/murf/bug_7638/main/pval.c Wed Jan 24 20:44:17 2007
@@ -4298,8 +4298,8 @@
void pvalContextSetAbstract( pval *p );
void pvalContextUnsetAbstract( pval *p );
int pvalContextGetAbstract( pval *p );
-void pvalContextSetStatement( pval *p, pval *statement);
-pval *pvalContextGetStatement( pval *p );
+void pvalContextAddStatement( pval *p, pval *statement);
+pval *pvalContextWalkStatements( pval *p, pval **statements );
void pvalMacroCallSetMacroName( pval *p, char *name );
char* pvalMacroCallGetMacroName( pval *p );
@@ -4544,18 +4544,28 @@
return p->u3.abstract;
}
-void pvalContextSetStatement( pval *p, pval *statement)
-{
- if (!pvalCheckType(p, "pvalContextSetStatement", PV_CONTEXT))
- return;
- p->u2.statements = statement;
-}
-
-pval *pvalContextGetStatement( pval *p )
-{
- if (!pvalCheckType(p, "pvalContextGetStatement", PV_CONTEXT))
+
+
+void pvalContextAddStatement( pval *p, pval *statement)
+{
+ if (!pvalCheckType(p, "pvalContextAddStatement", PV_CONTEXT))
+ return;
+ if (!p->u2.statements)
+ p->u2.statements = statement;
+ else
+ linku1(p->u2.statements, statement);
+}
+
+pval *pvalContextWalkStatements( pval *p, pval **statements )
+{
+ if (!pvalCheckType(p, "pvalContextWalkStatements", PV_CONTEXT))
return 0;
- return p->u2.statements;
+ if (!(*statements))
+ *statements = p->u2.statements;
+ else {
+ *statements = (*statements)->next;
+ }
+ return *statements;
}
Modified: team/murf/bug_7638/utils/check_expr.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_7638/utils/check_expr.c?view=diff&rev=52203&r1=52202&r2=52203
==============================================================================
--- team/murf/bug_7638/utils/check_expr.c (original)
+++ team/murf/bug_7638/utils/check_expr.c Wed Jan 24 20:44:17 2007
@@ -55,6 +55,8 @@
va_end(vars);
}
+char *find_var(const char *varname);
+
char *find_var(const char *varname) /* the list should be pretty short, if there's any list at all */
{
struct varz *t;
@@ -65,6 +67,8 @@
}
return 0;
}
+
+void set_var(const char *varname, const char *varval);
void set_var(const char *varname, const char *varval)
{
@@ -76,6 +80,8 @@
t->next = global_varlist;
global_varlist = t;
}
+
+int check_expr(char *buffer, char *error_report);
int check_expr(char *buffer, char *error_report)
{
@@ -139,6 +145,8 @@
return warn_found;
}
+int check_eval(char *buffer, char *error_report);
+
int check_eval(char *buffer, char *error_report)
{
char *cp, *ep, *xp;
@@ -211,6 +219,8 @@
}
}
+
+void parse_file(const char *fname);
void parse_file(const char *fname)
{
Modified: team/murf/bug_7638/utils/conf2ael.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_7638/utils/conf2ael.c?view=diff&rev=52203&r1=52202&r2=52203
==============================================================================
--- team/murf/bug_7638/utils/conf2ael.c (original)
+++ team/murf/bug_7638/utils/conf2ael.c Wed Jan 24 20:44:17 2007
@@ -53,6 +53,7 @@
#include "asterisk/devicestate.h"
#include "asterisk/stringfields.h"
#include "asterisk/ael_structs.h"
+#include "asterisk/pval.h"
static char *config = "extensions.conf";
@@ -2824,43 +2825,49 @@
tmp = 0;
while ((tmp = ast_walk_contexts(tmp)) ) {
printf("Context: %s\n", tmp->name);
- tmptree = npval(PV_CONTEXT, 1,1,1,1);
- tree = linku1(tree,tmptree);
- tmptree->u1.str = ast_strdup(tmp->name);
+ tmptree = pvalCreateNode(PV_CONTEXT);
+ if (!tree)
+ tree = tmptree;
+ else
+ pvalTopLevAddObject(tree, tmptree);
+
+ pvalContextSetName(tmptree, ast_strdup(tmp->name));
eroot=0;
while ( (eroot = ast_walk_context_extensions(tmp, eroot)) ) {
- pval *exten = npval(PV_EXTENSION, 1,1,1,1);
- tmptree->u2.statements = linku1(tmptree->u2.statements, exten);
- exten->u1.str = ast_strdup(eroot->exten);
-
+ pval *exten = pvalCreateNode(PV_EXTENSION);
+ pvalContextAddStatement(tmptree, exten);
+ pvalExtenSetName(exten, ast_strdup(eroot->exten));
+
if (eroot->peer) {
- pval *block = npval(PV_STATEMENTBLOCK, 1,1,1,1);
- exten->u2.statements = linku1(exten->u2.statements, block);
+ pval *block = pvalCreateNode(PV_STATEMENTBLOCK);
+ pvalExtenSetStatement(exten, block);
e = 0;
while ( (e = ast_walk_extension_priorities(eroot, e)) ) {
printf(" %s(%s)\n", e->app, (char*)e->data);
- pval *statemnt = npval(PV_APPLICATION_CALL, 1,1,1,1);
- pval *args = npval(PV_WORD, 1,1,1,1);
+ pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
+ pval *args = pvalCreateNode(PV_WORD);
- statemnt->u1.str = ast_strdup(e->app);
- args->u1.str = ast_strdup(e->data);
+ pvalAppCallSetAppName(statemnt, ast_strdup(e->app));
+ pvalWordSetString(args, ast_strdup(e->data));
+ pvalAppCallAddArg(statemnt, args);
- block->u1.list = linku1(block->u1.list, statemnt);
- statemnt->u2.arglist = linku1(statemnt->u2.arglist, args);
+ pvalStatementBlockAddStatement(block, statemnt);
}
} else {
- pval *statemnt = npval(PV_APPLICATION_CALL, 1,1,1,1);
- pval *args = npval(PV_WORD, 1,1,1,1);
+ pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
+ pval *args = pvalCreateNode(PV_WORD);
+
printf(" %s (%s)\n", eroot->app, (char *)eroot->data);
- statemnt->u1.str = ast_strdup(eroot->app);
- args->u1.str = ast_strdup(eroot->data);
+ pvalAppCallSetAppName(statemnt, ast_strdup(eroot->app));
+ pvalWordSetString(args, ast_strdup(eroot->data));
+
- exten->u2.statements = linku1(exten->u2.statements, statemnt);
- statemnt->u2.arglist = linku1(statemnt->u2.arglist, args);
+ pvalAppCallAddArg(statemnt, args);
+ pvalExtenSetStatement(exten, statemnt);
}
printf(" extension: %s\n", eroot->exten);
Modified: team/murf/bug_7638/utils/config_external.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_7638/utils/config_external.c?view=diff&rev=52203&r1=52202&r2=52203
==============================================================================
--- team/murf/bug_7638/utils/config_external.c (original)
+++ team/murf/bug_7638/utils/config_external.c Wed Jan 24 20:44:17 2007
@@ -797,12 +797,15 @@
} else
exec_file[0] = '\0';
/* A #include */
+ ast_log(LOG_WARNING, "Reading in included file %s withcomments=%d\n", cur, withcomments);
+
do_include = ast_config_internal_load(cur, cfg, withcomments) ? 1 : 0;
if(!ast_strlen_zero(exec_file))
unlink(exec_file);
if(!do_include)
return 0;
-
+ ast_log(LOG_WARNING, "Done reading in included file %s withcomments=%d\n", cur, withcomments);
+
} else {
ast_log(LOG_WARNING, "Directive '#%s' needs an argument (%s) at line %d of %s\n",
do_exec ? "exec" : "include",
@@ -876,7 +879,9 @@
snprintf(fn, sizeof(fn), "%s/%s", (char *)ast_config_AST_CONFIG_DIR, filename);
}
- if (withcomments) {
+ ast_log(LOG_WARNING, "textfile load %s \n", fn);
+
+ if (withcomments && cfg && cfg->include_level < 2 ) {
CB_INIT();
}
@@ -884,6 +889,8 @@
{
int glob_ret;
glob_t globbuf;
+ ast_log(LOG_WARNING, "textfile load %s glob\n", fn);
+
globbuf.gl_offs = 0; /* initialize it to silence gcc */
#ifdef SOLARIS
glob_ret = glob(fn, GLOB_NOCHECK, NULL, &globbuf);
@@ -1019,8 +1026,10 @@
}
}
#endif
- if (withcomments) {
+ ast_log(LOG_WARNING, "textfile load %s almost done\n", fn);
+ if (cfg && cfg->include_level == 1 && withcomments && comment_buffer) {
if (comment_buffer) {
+ ast_log(LOG_WARNING, "textfile load %s almost almost done\n", fn);
free(comment_buffer);
free(lline_buffer);
comment_buffer=0;
@@ -1032,6 +1041,7 @@
if (count == 0)
return NULL;
+ ast_log(LOG_WARNING, "textfile load %s done\n", fn);
return cfg;
}
@@ -1237,7 +1247,6 @@
return 0;
}
-
/*! \brief Find realtime engine for realtime family */
static struct ast_config_engine *find_engine(const char *family, char *database, int dbsiz, char *table, int tabsiz)
{
@@ -1289,6 +1298,7 @@
}
cfg->include_level++;
+ ast_log(LOG_WARNING, "internal loading file %s level=%d\n", filename, cfg->include_level);
if (strcmp(filename, extconfig_conf) && strcmp(filename, "asterisk.conf") && config_engine_list) {
struct ast_config_engine *eng;
@@ -1306,6 +1316,7 @@
}
result = loader->load_func(db, table, filename, cfg, withcomments);
+ ast_log(LOG_WARNING, "finished internal loading file %s level=%d\n", filename, cfg->include_level);
if (result)
result->include_level--;
More information about the asterisk-commits
mailing list