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:
parent
8aa3763986
commit
fb274514df
|
@ -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);
|
||||
|
||||
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;
|
||||
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
|
||||
|
|
|
@ -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, ¶ms_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;
|
||||
|
|
Loading…
Reference in New Issue