add switch_separate_file_params function so when using relative paths with bracketed params the full path can be constructed with the params in tact

This commit is contained in:
Anthony Minessale 2014-08-01 22:57:35 +05:00
parent 8aa3763986
commit fb274514df
2 changed files with 46 additions and 3 deletions

View 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); 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); 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);
static inline switch_bool_t switch_is_file_path(const char *file) file = space;
*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; const char *e;
int r, x; int r, x;
@ -974,6 +1006,7 @@ SWITCH_DECLARE(char *) switch_find_end_paren(const char *s, char open, char clos
break; break;
} }
} }
#ifdef WIN32 #ifdef WIN32
r = (file && (*file == '\\' || *(file + 1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR))); r = (file && (*file == '\\' || *(file + 1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR)));
#else #else

View File

@ -5443,10 +5443,20 @@ static switch_status_t conference_play_file(conference_obj_t *conference, char *
if (!switch_is_file_path(file)) { if (!switch_is_file_path(file)) {
if (!say && conference->sound_prefix) { if (!say && conference->sound_prefix) {
if (!(dfile = switch_mprintf("%s%s%s", conference->sound_prefix, SWITCH_PATH_SEPARATOR, file))) { char *params_portion = NULL;
goto done; 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; file = dfile;
switch_safe_free(file_portion);
switch_safe_free(params_portion);
} else if (!async) { } else if (!async) {
status = conference_say(conference, file, leadin); status = conference_say(conference, file, leadin);
goto done; goto done;