]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add switch_separate_file_params function so when using relative paths with bracketed...
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 1 Aug 2014 17:57:35 +0000 (22:57 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 1 Aug 2014 17:57:40 +0000 (22:57 +0500)
src/include/switch_utils.h
src/mod/applications/mod_conference/mod_conference.c

index f1903c8c298d276b1376a22814683a403841da7a..8e019f1fb300f74d8466ba95bc65f1e6781d97fb 100644 (file)
@@ -955,8 +955,40 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
                                                                                                  const char *body, const char *file, const char *convert_cmd, const char *convert_ext);
 SWITCH_DECLARE(char *) switch_find_end_paren(const char *s, char open, char close);
 
+static inline void switch_separate_file_params(const char *file, char **file_portion, char **params_portion)
+{
+       char *e = NULL;
+       int x;
+       char *space = strdup(file);
+
+       file = space;
 
-        static inline switch_bool_t switch_is_file_path(const char *file)
+       *file_portion = NULL;
+       *params_portion = NULL;
+       
+       for (x = 0; x < 2; x++) {
+               if (*file == '[' && *(file + 1) == *SWITCH_PATH_SEPARATOR) {
+                       e = switch_find_end_paren(file, '[', ']');
+               } else if (*file == '{') {
+                       e = switch_find_end_paren(file, '{', '}');
+               } else {
+                       break;
+               }
+       }
+
+       if (e) {
+               file = e + 1;
+               *file_portion = strdup((char *)file);
+               *++e = '\0';
+               *params_portion = (char *)space;
+       } else {
+               *file_portion = (char *)space;
+       }
+       
+       return;
+}
+
+static inline switch_bool_t switch_is_file_path(const char *file)
 {
        const char *e;
        int r, x;
@@ -974,6 +1006,7 @@ SWITCH_DECLARE(char *) switch_find_end_paren(const char *s, char open, char clos
                        break;
                }
        }
+
 #ifdef WIN32
        r = (file && (*file == '\\' || *(file + 1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR)));
 #else
index f4a6757572156ebf8ac54f4ee3cfd1d3f33d83f0..4d2478ce7cd7c2a49c659ea80ba8835aac916d09 100644 (file)
@@ -5443,10 +5443,20 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char *
 
        if (!switch_is_file_path(file)) {
                if (!say && conference->sound_prefix) {
-                       if (!(dfile = switch_mprintf("%s%s%s", conference->sound_prefix, SWITCH_PATH_SEPARATOR, file))) {
-                               goto done;
+                       char *params_portion = NULL;
+                       char *file_portion = NULL;
+                       switch_separate_file_params(file, &file_portion, &params_portion);
+
+                       if (params_portion) {
+                               dfile = switch_mprintf("%s%s%s%s", params_portion, conference->sound_prefix, SWITCH_PATH_SEPARATOR, file_portion);
+                       } else {
+                               dfile = switch_mprintf("%s%s%s", conference->sound_prefix, SWITCH_PATH_SEPARATOR, file_portion);
                        }
+
                        file = dfile;
+                       switch_safe_free(file_portion);
+                       switch_safe_free(params_portion);
+
                } else if (!async) {
                        status = conference_say(conference, file, leadin);
                        goto done;