diff options
author | Russell Bryant <russell@russellbryant.com> | 2005-09-23 02:57:14 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2005-09-23 02:57:14 +0000 |
commit | 779d033f21780d958990f044f1663367360981a6 (patch) | |
tree | 87afb376f33b66926ff2cf66321280b37768c8a4 /utils.c | |
parent | afb00fce12ca90ab8af372b5f867d428be3e4386 (diff) |
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
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6630 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'utils.c')
-rwxr-xr-x | utils.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -799,3 +799,29 @@ uint64_t strtoq(const char *nptr, char **endptr, int base) return acc; } #endif + +char *ast_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; +} |