[asterisk-commits] murf: branch murf/bug_7638 r52461 - in
/team/murf/bug_7638: main/ utils/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Jan 26 22:44:46 MST 2007
Author: murf
Date: Fri Jan 26 23:44:45 2007
New Revision: 52461
URL: http://svn.digium.com/view/asterisk?view=rev&rev=52461
Log:
There. Now there's code to handle includes, ignorepats, switches. Now to the juicy stuff.
Modified:
team/murf/bug_7638/main/Makefile
team/murf/bug_7638/main/pval.c
team/murf/bug_7638/utils/Makefile
team/murf/bug_7638/utils/conf2ael.c
Modified: team/murf/bug_7638/main/Makefile
URL: http://svn.digium.com/view/asterisk/team/murf/bug_7638/main/Makefile?view=diff&rev=52461&r1=52460&r2=52461
==============================================================================
--- team/murf/bug_7638/main/Makefile (original)
+++ team/murf/bug_7638/main/Makefile Fri Jan 26 23:44:45 2007
@@ -26,7 +26,7 @@
utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
- strcompat.o threadstorage.o ../pbx/ael/ael_lex.o ../pbx/ael/ael.tab.o
+ strcompat.o threadstorage.o ../pbx/ael/ael_lex.o ../pbx/ael/ael.tab.o \
strcompat.o threadstorage.o dial.o
# we need to link in the objects statically, not as a library, because
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=52461&r1=52460&r2=52461
==============================================================================
--- team/murf/bug_7638/main/pval.c (original)
+++ team/murf/bug_7638/main/pval.c Fri Jan 26 23:44:45 2007
@@ -230,7 +230,7 @@
}
fprintf(fin,"%s", lp->u1.str); /* usually, words are encapsulated in something else */
if (lp->u2.arglist)
- fprintf(fin,"-|'%s'|'%s'|'%s'|'%s'",
+ fprintf(fin,"|%s|%s|%s|%s",
lp->u2.arglist->u1.str,
lp->u2.arglist->next->u1.str,
lp->u2.arglist->next->next->u1.str,
@@ -358,7 +358,7 @@
break;
case PV_IGNOREPAT:
- fprintf(fin,"ignorepat => %s\n", item->u1.str);
+ fprintf(fin,"ignorepat => %s;\n", item->u1.str);
break;
case PV_GLOBALS:
@@ -4426,7 +4426,7 @@
-void pvalContextAddStatement( pval *p, pval *statement)
+void pvalContextAddStatement( pval *p, pval *statement) /* this includes SWITCHES, INCLUDES, IGNOREPAT, etc */
{
if (!pvalCheckType(p, "pvalContextAddStatement", PV_CONTEXT))
return;
Modified: team/murf/bug_7638/utils/Makefile
URL: http://svn.digium.com/view/asterisk/team/murf/bug_7638/utils/Makefile?view=diff&rev=52461&r1=52460&r2=52461
==============================================================================
--- team/murf/bug_7638/utils/Makefile (original)
+++ team/murf/bug_7638/utils/Makefile Fri Jan 26 23:44:45 2007
@@ -14,7 +14,7 @@
.PHONY: clean all uninstall
# to get check_expr, add it to the ALL_UTILS list
-ALL_UTILS:=astman smsq stereorize streamplayer aelparse muted check_expr
+ALL_UTILS:=astman smsq stereorize streamplayer aelparse muted check_expr conf2ael
UTILS:=$(ALL_UTILS)
include $(ASTTOPDIR)/Makefile.rules
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=52461&r1=52460&r2=52461
==============================================================================
--- team/murf/bug_7638/utils/conf2ael.c (original)
+++ team/murf/bug_7638/utils/conf2ael.c Fri Jan 26 23:44:45 2007
@@ -1,4 +1,4 @@
-/*
+/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2006, Digium, Inc.
@@ -2846,7 +2846,7 @@
{
struct ast_context *tmp;
struct ast_exten *e, *eroot;
- pval *tree, *tmptree;
+ pval *tree, *tmptree, *sws;
struct ast_include *tmpi;
struct ast_sw *sw = 0;
struct ast_ignorepat *ipi;
@@ -2875,7 +2875,7 @@
tmp = 0;
while ((tmp = ast_walk_contexts(tmp)) ) {
- printf("Context: %s\n", tmp->name);
+ /* printf("Context: %s\n", tmp->name); */
tmptree = pvalCreateNode(PV_CONTEXT);
if (!tree)
tree = tmptree;
@@ -2884,6 +2884,109 @@
pvalContextSetName(tmptree, ast_strdup(tmp->name));
+ if (tmp->includes) {
+ incl = pvalCreateNode(PV_INCLUDES);
+ pvalContextAddStatement(tmptree, incl);
+ for (tmpi = tmp->includes; tmpi; ) { /* includes */
+ if (strchr(tmpi->name,'|')==0) {
+ if (tmpi->hastime)
+ {
+ char timerange[15];
+ char dowrange[10];
+ char domrange[10];
+ char monrange[10];
+ int startbit=0, endbit=0;
+
+ if (all_bits_set(tmpi->timing.minmask, 30, 720))
+ strcpy(timerange, "*");
+ else {
+ int hr, min;
+ char tbuf[20];
+ get_start_stop(tmpi->timing.minmask, 30, 720, &startbit, &endbit);
+ hr = startbit/30;
+ min = (startbit % 30) * 2;
+ sprintf(tbuf,"%02d:%02d", hr, min);
+ strcpy(timerange, tbuf);
+ hr = endbit/30;
+ min = (endbit % 30) * 2;
+ sprintf(tbuf,"%02d:%02d", hr, min);
+ strcat(timerange,"-");
+ strcat(timerange,tbuf);
+ }
+
+ if (all_bits_set(&tmpi->timing.dowmask, 7, 7))
+ strcpy(dowrange, "*");
+ else {
+ get_start_stop(&tmpi->timing.dowmask, 7, 7, &startbit, &endbit);
+ strcpy(dowrange, days[startbit]);
+ strcat(dowrange,"-");
+ strcat(dowrange, days[endbit]);
+ }
+
+ if (all_bits_set(&tmpi->timing.monthmask, 12, 12))
+ strcpy(monrange, "*");
+ else {
+ get_start_stop(&tmpi->timing.monthmask, 12, 12, &startbit, &endbit);
+ strcpy(monrange, months[startbit]);
+ strcat(monrange,"-");
+ strcat(monrange, months[endbit]);
+ }
+
+ if (all_bits_set(&tmpi->timing.daymask, 31, 31))
+ strcpy(domrange, "*");
+ else {
+ char tbuf[20];
+ get_start_stop(&tmpi->timing.daymask, 31, 31, &startbit, &endbit);
+ sprintf(tbuf,"%d", startbit);
+ strcpy(domrange, tbuf);
+ strcat(domrange,"-");
+ sprintf(tbuf,"%d", endbit);
+ strcat(domrange, tbuf);
+ }
+ /* now all 4 fields are set; what do we do? */
+ pvalIncludesAddIncludeWithTimeConstraints(incl, strdup(tmpi->name), strdup(timerange), strdup(domrange), strdup(dowrange), strdup(monrange));
+
+ } else {
+ pvalIncludesAddInclude(incl, strdup(tmpi->name));
+ }
+ } else { /* it appears the timing constraint info is tacked onto the name, carve it up and divvy it out */
+ char *dow,*dom,*mon;
+ char *all = strdup(tmpi->name);
+ char *hr = strchr(all,'|');
+ if (hr) {
+ *hr++ = 0;
+ dow = strchr(hr,'|');
+ if (dow) {
+ *dow++ = 0;
+ dom = strchr(dow,'|');
+ if (dom) {
+ *dom++ = 0;
+ mon = strchr(dom,'|');
+ if (mon) {
+ *mon++ = 0;
+ /* now all 4 fields are set; what do we do? */
+ pvalIncludesAddIncludeWithTimeConstraints(incl, all, hr, dow, dom, mon);
+ /* the original data is always best to keep (no 2-min rounding) */
+ } else {
+ ast_log(LOG_ERROR,"No month spec attached to include!\n");
+ }
+ } else {
+ ast_log(LOG_ERROR,"No day of month spec attached to include!\n");
+ }
+ } else {
+ ast_log(LOG_ERROR,"No day of week spec attached to include!\n");
+ }
+ }
+ }
+ tmpi = tmpi->next;
+ }
+ }
+ for (ipi = tmp->ignorepats; ipi; ) { /* ignorepats */
+ incl = pvalCreateNode(PV_IGNOREPAT);
+ pvalIgnorePatSetPattern(incl,(char *)ipi->pattern);
+ pvalContextAddStatement(tmptree, incl);
+ ipi = ipi->next;
+ }
eroot=0;
while ( (eroot = ast_walk_context_extensions(tmp, eroot)) ) {
pval *exten = pvalCreateNode(PV_EXTENSION);
@@ -2896,7 +2999,7 @@
e = 0;
while ( (e = ast_walk_extension_priorities(eroot, e)) ) {
- printf(" %s(%s)\n", e->app, (char*)e->data);
+ /* printf(" %s(%s)\n", e->app, (char*)e->data); */
pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
pval *args = pvalCreateNode(PV_WORD);
@@ -2911,7 +3014,7 @@
pval *statemnt = pvalCreateNode(PV_APPLICATION_CALL);
pval *args = pvalCreateNode(PV_WORD);
- printf(" %s (%s)\n", eroot->app, (char *)eroot->data);
+ /* printf(" %s (%s)\n", eroot->app, (char *)eroot->data); */
pvalAppCallSetAppName(statemnt, ast_strdup(eroot->app));
pvalWordSetString(args, ast_strdup(eroot->data));
@@ -2921,87 +3024,21 @@
pvalExtenSetStatement(exten, statemnt);
}
- printf(" extension: %s\n", eroot->exten);
- }
- if (tmp->includes) {
- incl = pvalCreateNode(PV_INCLUDES);
- pvalContextAddStatement(tmptree, incl);
- }
- for (tmpi = tmp->includes; tmpi; ) { /* includes */
- if (tmpi->hastime)
- {
- char timerange[15];
- char dowrange[10];
- char domrange[10];
- char monrange[10];
- int startbit=0, endbit=0;
-
- if (all_bits_set(tmpi->timing.minmask, 30, 720))
- strcpy(timerange, "*");
- else {
- int hr, min;
- char tbuf[20];
- get_start_stop(tmpi->timing.minmask, 30, 720, &startbit, &endbit);
- hr = startbit/30;
- min = (startbit % 30) * 2;
- sprintf(tbuf,"%02d:%02d", hr, min);
- strcpy(timerange, tbuf);
- hr = endbit/30;
- min = (endbit % 30) * 2;
- sprintf(tbuf,"%02d:%02d", hr, min);
- strcat(timerange,"-");
- strcat(timerange,tbuf);
- }
-
- if (all_bits_set(&tmpi->timing.dowmask, 7, 7))
- strcpy(dowrange, "*");
- else {
- get_start_stop(&tmpi->timing.dowmask, 7, 7, &startbit, &endbit);
- strcpy(dowrange, days[startbit]);
- strcat(dowrange,"-");
- strcat(dowrange, days[endbit]);
- }
-
- if (all_bits_set(&tmpi->timing.monthmask, 12, 12))
- strcpy(monrange, "*");
- else {
- get_start_stop(&tmpi->timing.monthmask, 12, 12, &startbit, &endbit);
- strcpy(monrange, months[startbit]);
- strcat(monrange,"-");
- strcat(monrange, months[endbit]);
- }
-
- if (all_bits_set(&tmpi->timing.daymask, 31, 31))
- strcpy(domrange, "*");
- else {
- char tbuf[20];
- get_start_stop(&tmpi->timing.daymask, 31, 31, &startbit, &endbit);
- sprintf(tbuf,"%d", startbit);
- strcpy(domrange, tbuf);
- strcat(domrange,"-");
- sprintf(tbuf,"%d", endbit);
- strcat(domrange, tbuf);
- }
- /* now all 4 fields are set; what do we do? */
- pvalIncludesAddIncludeWithTimeConstraints(incl, tmpi->name, timerange, domrange, dowrange, monrange);
-
- } else {
- pvalIncludesAddInclude(incl, tmpi->name);
+ /* printf(" extension: %s\n", eroot->exten); */
+ }
+ if (AST_LIST_FIRST(&tmp->alts)) {
+ sws = pvalCreateNode(PV_SWITCHES);
+ pvalContextAddStatement(tmptree,sws);
+
+ AST_LIST_TRAVERSE(&tmp->alts, sw, list) {
+ pvalSwitchesAddSwitch(sws, ast_strdup(sw->name));
}
-
-
- tmpi = tmpi->next;
- }
- for (ipi = tmp->ignorepats; ipi; ) { /* ignorepats */
- incl = pvalCreateNode(PV_IGNOREPAT);
- pvalIgnorePatSetPattern(incl,(char *)ipi->pattern);
- pvalContextAddStatement(tmptree, incl);
- ipi = ipi->next;
- }
- sw = 0;
- }
+ }
+ }
+ printf("Generating aelout.ael file...\n");
ael2_print("aelout.ael", tree);
+ printf("...Done!\n");
return 0;
}
More information about the asterisk-commits
mailing list