[Asterisk-cvs] asterisk/pbx pbx_config.c,1.38,1.39
markster at lists.digium.com
markster at lists.digium.com
Mon Jun 14 16:38:38 CDT 2004
Update of /usr/cvsroot/asterisk/pbx
In directory mongoose.digium.com:/tmp/cvs-serv5162/pbx
Modified Files:
pbx_config.c
Log Message:
Allow escaping of commas as well as ability to use quotes (bug #1826)
Index: pbx_config.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx/pbx_config.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- pbx_config.c 9 Jun 2004 01:45:08 -0000 1.38
+++ pbx_config.c 14 Jun 2004 21:43:16 -0000 1.39
@@ -98,6 +98,36 @@
"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
*/
@@ -1144,9 +1174,7 @@
if (app && (start = strchr(app, '(')) && (end = strrchr(app, ')'))) {
*start = *end = '\0';
app_data = start + 1;
- for (start = app_data; *start; start++)
- if (*start == ',')
- *start = '|';
+ process_quotes_and_slashes(app_data,',','|');
} else
app_data = whole_exten;
@@ -1615,9 +1643,7 @@
if (start && (end = strrchr(appl, ')'))) {
*start = *end = '\0';
data = start + 1;
- for (start = data; *start; start++)
- if (*start == ',')
- *start = '|';
+ process_quotes_and_slashes(data,',','|');
} else if (stringp!=NULL && *stringp=='"') {
stringp++;
data = strsep(&stringp, "\"");
More information about the svn-commits
mailing list