]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
try this Vagabond
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 26 Jan 2010 18:20:09 +0000 (18:20 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 26 Jan 2010 18:20:09 +0000 (18:20 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16517 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_module_interfaces.h
src/mod/formats/mod_file_string/mod_file_string.c
src/switch_ivr_play_say.c
src/switch_utils.c

index aa3cde37e65a575ce73cd8243053a5dc0cc8e763..7af9f000f27103e1be9820edb354199c8255b4ea 100644 (file)
@@ -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 */
index 20a6bbfe3e9a1da8e23040931bf82beeda591de6..148d5ef7112bf12e146c5e80a4b035300a8a5145 100644 (file)
@@ -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;
index 17ba412efb19acb35e892aac21c57c0c0d5fad19..8c53f372df66fda76f731513f775408817746f92 100644 (file)
@@ -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,
index 5bc915302c5c2893d5aa8d4243d21594ed63d0c1..7347320dc33ccb581d9e63e115742fd0b3b71ca6 100644 (file)
@@ -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;
 }