[Asterisk-cvs] asterisk/pbx pbx_ael.c, 1.12, 1.13 pbx_config.c, 1.68, 1.69

russell russell
Thu Sep 22 22:59:46 CDT 2005


Update of /usr/cvsroot/asterisk/pbx
In directory mongoose.digium.com:/tmp/cvs-serv15227/pbx

Modified Files:
	pbx_ael.c pbx_config.c 
Log Message:
move process_quotes_and_slashes to utils.c since it is used by both pbx_ael and pbx_config
clean up some formatting
remove some commented out reference code
move unload_module in pbx_ael down to be with the rest of the standard module functions


Index: pbx_ael.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx/pbx_ael.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- pbx_ael.c	23 Sep 2005 02:53:53 -0000	1.12
+++ pbx_ael.c	23 Sep 2005 02:57:14 -0000	1.13
@@ -75,44 +75,6 @@
 static char *config = "extensions.ael";
 static char *registrar = "pbx_ael";
 
-/*
- * Static code
- */
-static char *process_quotes_and_slashes(char *start, char find, char replace_with)
-{
- 	char *dataPut = start;
-	int inEscape = 0;
-	int inQuotes = 0;
-
-	for (; *start; start++) {
-		if (inEscape) {
-			*dataPut++ = *start;       /* Always goes verbatim */
-			inEscape = 0;
-    		} else {
-			if (*start == '\\') {
-				inEscape = 1;      /* Do not copy \ into the data */
-			} else if (*start == '\'') {
-				inQuotes = 1-inQuotes;   /* Do not copy ' into the data */
-			} else {
-				/* Replace , with |, unless in quotes */
-				*dataPut++ = inQuotes ? *start : ((*start==find) ? replace_with : *start);
-			}
-		}
-	}
-	if (start != dataPut)
-		*dataPut = 0;
-	return dataPut;
-}
-
-/*
- * Standard module functions ...
- */
-int unload_module(void)
-{
-	ast_context_destroy(NULL, registrar);
-	return 0;
-}
-
 static char *__grab_token(char *src, const char *filename, int lineno, int link)
 {
 	char *c;
@@ -449,18 +411,18 @@
 	int inpar = 0;
 	c = variable;
 	
-	while(*c && (*c > 32)) {
-	  if(*c == ')' && (inpar > 0)) {
-	    inpar--;
-	  } else if(*c == '(' && (inpar >= 0)) {
-	    inpar++;
-	  } else if(*c == '=' && (inpar == 0)) {
-	    break;
-	  }
-	  c++;
+	while (*c && (*c > 32)) {
+		if(*c == ')' && (inpar > 0)) {
+			inpar--;
+		} else if(*c == '(' && (inpar >= 0)) {
+			inpar++;
+		} else if(*c == '=' && (inpar == 0)) {
+			break;
+		}
+		c++;
 	} 
 	ws = c;
-	while(*c && (*c < 33)) c++;
+	while (*c && (*c < 33)) c++;
 	if (*c == '=') {
 		*ws = '\0';
 		*c = '\0';
@@ -533,7 +495,7 @@
 			margs = alloca(mlen);
 			app = "Goto";
 			sprintf(margs, "sw-%s-%d-%s|1", name, *pos, args);
-			process_quotes_and_slashes(margs, ',', '|');
+			ast_process_quotes_and_slashes(margs, ',', '|');
 			oargs = args;
 			args = margs;
 			if (ast_add_extension2(con, 0, exten, *pos, *label, NULL, app, strdup(args), FREE, registrar))
@@ -863,7 +825,7 @@
 			if ((c >= args) && (*c == ')')) *c = '\0';
 		} else
 			args = "";
-		process_quotes_and_slashes(args, ',', '|');
+		ast_process_quotes_and_slashes(args, ',', '|');
 		if (app[0] == '&') {
 			app++;
 			margs = alloca(strlen(args) + strlen(app) + 10);
@@ -1204,6 +1166,15 @@
 	return 0;
 }
 
+/*
+ * Standard module functions ...
+ */
+int unload_module(void)
+{
+	ast_context_destroy(NULL, registrar);
+	return 0;
+}
+
 static int pbx_load_module(void)
 {
 	struct ast_context *local_contexts=NULL, *con;
@@ -1212,160 +1183,6 @@
 	for (con = ast_walk_contexts(NULL); con; con = ast_walk_contexts(con))
 		ast_context_verify_includes(con);
 
-#if 0
-		v = ast_variable_browse(cfg, "globals");
-		while(v) {
-			memset(realvalue, 0, sizeof(realvalue));
-			pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
-			pbx_builtin_setvar_helper(NULL, v->name, realvalue);
-			v = v->next;
-		}
-		cxt = ast_category_browse(cfg, NULL);
-		while(cxt) {
-			/* All categories but "general" or "globals" are considered contexts */
-			if (!strcasecmp(cxt, "general") || !strcasecmp(cxt, "globals")) {
-				cxt = ast_category_browse(cfg, cxt);
-				continue;
-			}
-			if ((con=ast_context_create(&local_contexts,cxt, registrar))) {
-				v = ast_variable_browse(cfg, cxt);
-				while(v) {
-					if (!strcasecmp(v->name, "exten")) {
-						char *stringp=NULL;
-						int ipri = -2;
-						char realext[256]="";
-						char *plus;
-						tc = strdup(v->value);
-						if(tc!=NULL){
-							stringp=tc;
-							ext = strsep(&stringp, ",");
-							if (!ext)
-								ext="";
-							cidmatch = strchr(ext, '/');
-							if (cidmatch) {
-								*cidmatch = '\0';
-								cidmatch++;
-								ast_shrink_phone_number(cidmatch);
-							}
-							pri = strsep(&stringp, ",");
-							if (!pri)
-								pri="";
-							label = strchr(pri, '(');
-							if (label) {
-								*label = '\0';
-								label++;
-								end = strchr(label, ')');
-								if (end)
-									*end = '\0';
-								else
-									ast_log(LOG_WARNING, "Label missing trailing ')' at line %d\n", v->lineno);
-							}
-							plus = strchr(pri, '+');
-							if (plus) {
-								*plus = '\0';
-								plus++;
-							}
-							if (!strcmp(pri,"hint"))
-								ipri=PRIORITY_HINT;
-							else if (!strcmp(pri, "next") || !strcmp(pri, "n")) {
-								if (lastpri > -2)
-									ipri = lastpri + 1;
-								else
-									ast_log(LOG_WARNING, "Can't use 'next' priority on the first entry!\n");
-							} else if (!strcmp(pri, "same") || !strcmp(pri, "s")) {
-								if (lastpri > -2)
-									ipri = lastpri;
-								else
-									ast_log(LOG_WARNING, "Can't use 'same' priority on the first entry!\n");
-							} else  {
-								if (sscanf(pri, "%i", &ipri) != 1) {
-									if ((ipri = ast_findlabel_extension2(NULL, con, ext, pri, cidmatch)) < 1) {
-										ast_log(LOG_WARNING, "Invalid priority/label '%s' at line %d\n", pri, v->lineno);
-										ipri = 0;
-									}
-								}
-							}
-							appl = stringp;
-							if (!appl)
-								appl="";
-							if (!(start = strchr(appl, '('))) {
-								if (stringp)
-									appl = strsep(&stringp, ",");
-								else
-									appl = "";
-							}
-							if (start && (end = strrchr(appl, ')'))) {
-								*start = *end = '\0';
-								data = start + 1;
-								process_quotes_and_slashes(data, ',', '|');
-							} else if (stringp!=NULL && *stringp=='"') {
-								stringp++;
-								data = strsep(&stringp, "\"");
-								stringp++;
-							} else {
-								if (stringp)
-									data = strsep(&stringp, ",");
-								else
-									data = "";
-							}
-
-							if (!data)
-								data="";
-							while(*appl && (*appl < 33)) appl++;
-							pbx_substitute_variables_helper(NULL, ext, realext, sizeof(realext) - 1);
-							if (ipri) {
-								if (plus)
-									ipri += atoi(plus);
-								lastpri = ipri;
-								if (!strcmp(realext, "_."))
-									ast_log(LOG_WARNING, "The use of '_.' for an extension is strongly discouraged and can have unexpected behavior.  Please use '_X.' instead at line %d\n", v->lineno);
-								if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, strdup(data), FREE, registrar)) {
-									ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno);
-								}
-							}
-							free(tc);
-						} else fprintf(stderr,"Error strdup returned NULL in %s\n",__PRETTY_FUNCTION__);
-					} else if(!strcasecmp(v->name, "include")) {
-						memset(realvalue, 0, sizeof(realvalue));
-						pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
-						if (ast_context_add_include2(con, realvalue, registrar))
-							ast_log(LOG_WARNING, "Unable to include context '%s' in context '%s'\n", v->value, cxt);
-					} else if(!strcasecmp(v->name, "ignorepat")) {
-						memset(realvalue, 0, sizeof(realvalue));
-						pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
-						if (ast_context_add_ignorepat2(con, realvalue, registrar))
-							ast_log(LOG_WARNING, "Unable to include ignorepat '%s' in context '%s'\n", v->value, cxt);
-					} else if (!strcasecmp(v->name, "switch") || !strcasecmp(v->name, "lswitch") || !strcasecmp(v->name, "eswitch")) {
-						char *stringp=NULL;
-						memset(realvalue, 0, sizeof(realvalue));
-						if (!strcasecmp(v->name, "switch"))
-							pbx_substitute_variables_helper(NULL, v->value, realvalue, sizeof(realvalue) - 1);
-						else
-							strncpy(realvalue, v->value, sizeof(realvalue) - 1);
-						tc = realvalue;
-						stringp=tc;
-						appl = strsep(&stringp, "/");
-						data = strsep(&stringp, "");
-						if (!data)
-							data = "";
-						if (ast_context_add_switch2(con, appl, data, !strcasecmp(v->name, "eswitch"), registrar))
-							ast_log(LOG_WARNING, "Unable to include switch '%s' in context '%s'\n", v->value, cxt);
-					}
-					v = v->next;
-				}
-			}
-			cxt = ast_category_browse(cfg, cxt);
-		}
-		ast_config_destroy(cfg);
-	}
-	ast_merge_contexts_and_delete(&local_contexts,registrar);
-
-	for (con = ast_walk_contexts(NULL); con; con = ast_walk_contexts(con))
-		ast_context_verify_includes(con);
-
-	pbx_set_autofallthrough(autofallthrough_config);
-#endif
-
 	return 0;
 }
 

Index: pbx_config.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx/pbx_config.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- pbx_config.c	14 Sep 2005 20:46:50 -0000	1.68
+++ pbx_config.c	23 Sep 2005 02:57:14 -0000	1.69
@@ -117,34 +117,6 @@
 "Example: extensions reload\n";
 
 /*
- * Static code
- */
-static char *process_quotes_and_slashes(char *start, char find, char replace_with)
-{
- 	char *dataPut = start;
-	int inEscape = 0;
-	int inQuotes = 0;
-
-	for (; *start; start++) {
-		if (inEscape) {
-			*dataPut++ = *start;       /* Always goes verbatim */
-			inEscape = 0;
-    		} else {
-			if (*start == '\\') {
-				inEscape = 1;      /* Do not copy \ into the data */
-			} else if (*start == '\'') {
-				inQuotes = 1-inQuotes;   /* Do not copy ' into the data */
-			} else {
-				/* Replace , with |, unless in quotes */
-				*dataPut++ = inQuotes ? *start : ((*start==find) ? replace_with : *start);
-			}
-		}
-	}
-	*dataPut = 0;
-	return dataPut;
-}
-
-/*
  * Implementation of functions provided by this module
  */
 
@@ -1218,7 +1190,7 @@
 	if (app && (start = strchr(app, '(')) && (end = strrchr(app, ')'))) {
 		*start = *end = '\0';
 		app_data = start + 1;
-		process_quotes_and_slashes(app_data, ',', '|');
+		ast_process_quotes_and_slashes(app_data, ',', '|');
 	} else {
 		if (app) {
 			app_data = strchr(app, ',');
@@ -1751,7 +1723,7 @@
 								} else {
 									ast_log(LOG_WARNING, "No closing parenthesis found? '%s(%s'\n", appl, data);
 								}
-								process_quotes_and_slashes(data, ',', '|');
+								ast_process_quotes_and_slashes(data, ',', '|');
 							}
 
 							if (!data)




More information about the svn-commits mailing list