From 3049cd5c8ded0d046612d9f4ae369ec3c9e7d3de Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 26 Jan 2010 18:20:09 +0000 Subject: [PATCH] try this Vagabond git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16517 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_module_interfaces.h | 1 + .../formats/mod_file_string/mod_file_string.c | 21 +++++++++++++-- src/switch_ivr_play_say.c | 24 +++++++++++------ src/switch_utils.c | 26 +++++++++---------- 4 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index aa3cde37e6..7af9f000f2 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -338,6 +338,7 @@ struct switch_file_handle { int line; char *file_path; char *spool_path; + const char *prefix; }; /*! \brief Abstract interface to an asr module */ diff --git a/src/mod/formats/mod_file_string/mod_file_string.c b/src/mod/formats/mod_file_string/mod_file_string.c index 20a6bbfe3e..148d5ef711 100644 --- a/src/mod/formats/mod_file_string/mod_file_string.c +++ b/src/mod/formats/mod_file_string/mod_file_string.c @@ -60,6 +60,10 @@ typedef struct file_string_context file_string_context_t; static int next_file(switch_file_handle_t *handle) { file_string_context_t *context = handle->private_info; + char *file; + const char *prefix = handle->prefix; + + top: context->index++; @@ -71,12 +75,25 @@ static int next_file(switch_file_handle_t *handle) return 0; } + + if (!prefix) { + if (!(prefix = switch_core_get_variable("sound_prefix"))) { + prefix = SWITCH_GLOBAL_dirs.sounds_dir; + } + } + + if (!prefix || switch_is_file_path(context->argv[context->index])) { + file = context->argv[context->index]; + } else { + file = switch_core_sprintf(handle->memory_pool, "%s%s%s", prefix, SWITCH_PATH_SEPARATOR, context->argv[context->index]); + } + if (switch_core_file_open(&context->fh, - context->argv[context->index], + file, handle->channels, handle->samplerate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) { - return 0; + goto top; } handle->samples = context->fh.samples; diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 17ba412efb..8c53f372df 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -399,6 +399,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se switch_event_t *event; int divisor = 0; int file_flags = SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT; + const char *prefix; + + prefix = switch_channel_get_variable(channel, "sound_prefix"); + + if (!prefix) { + prefix = SWITCH_GLOBAL_dirs.sounds_dir; + } switch_core_session_get_read_impl(session, &read_impl); @@ -468,14 +475,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se if (!strstr(file, SWITCH_URL_SEPARATOR)) { char *ext; - const char *prefix; - prefix = switch_channel_get_variable(channel, "sound_prefix"); - - if (!prefix) { - prefix = SWITCH_GLOBAL_dirs.base_dir; - } - if (!switch_is_file_path(file)) { char *tfile = NULL; char *e; @@ -510,7 +510,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se file_flags |= SWITCH_FILE_WRITE_APPEND; } - + if (!fh->prefix) { + fh->prefix = prefix; + } + if (switch_core_file_open(fh, file, fh->channels, @@ -1076,6 +1079,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess } } + + if (!fh->prefix) { + fh->prefix = prefix; + } + if (switch_core_file_open(fh, file, read_impl.number_of_channels, diff --git a/src/switch_utils.c b/src/switch_utils.c index 5bc915302c..7347320dc3 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -1571,9 +1571,6 @@ static char unescape_char(char escaped) case 's': unescaped = ' '; break; - case '\\': - unescaped = 1; /* 1 means double esc */ - break; default: unescaped = escaped; } @@ -1642,16 +1639,12 @@ static char *cleanup_separated_string(char *str, char delim) for (start = dest = ptr; *ptr; ++ptr) { char e; int esc = 0; - + if (*ptr == ESCAPE_META) { e = *(ptr + 1); - if (e == '\'' || e == '"' || (delim && e == delim) || (e = unescape_char(*(ptr + 1))) != *(ptr + 1)) { + if (e == '\'' || e == '"' || (delim && e == delim) || e == ESCAPE_META || (e = unescape_char(*(ptr + 1))) != *(ptr + 1)) { ++ptr; - if (e == 1) { - *dest++ = '\\'; - } else { - *dest++ = e; - } + *dest++ = e; end = dest; esc++; } @@ -1670,6 +1663,7 @@ static char *cleanup_separated_string(char *str, char delim) if (end) { *end = '\0'; } + return start; } @@ -1727,8 +1721,10 @@ static unsigned int separate_string_char_delim(char *buf, char delim, char **arr } } /* strip quotes, escaped chars and leading / trailing spaces */ - for (i = 0; i < count; ++i) { - array[i] = cleanup_separated_string(array[i], delim); + if (count > 1) { + for (i = 0; i < count; ++i) { + array[i] = cleanup_separated_string(array[i], delim); + } } return count; } @@ -1785,8 +1781,10 @@ static unsigned int separate_string_blank_delim(char *buf, char **array, unsigne } } /* strip quotes, escaped chars and leading / trailing spaces */ - for (i = 0; i < count; ++i) { - array[i] = cleanup_separated_string(array[i], 0); + if (count > 1) { + for (i = 0; i < count; ++i) { + array[i] = cleanup_separated_string(array[i], 0); + } } return count; }