int line;
char *file_path;
char *spool_path;
+ const char *prefix;
};
/*! \brief Abstract interface to an asr module */
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++;
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;
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);
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;
file_flags |= SWITCH_FILE_WRITE_APPEND;
}
-
+ if (!fh->prefix) {
+ fh->prefix = prefix;
+ }
+
if (switch_core_file_open(fh,
file,
fh->channels,
}
}
+
+ if (!fh->prefix) {
+ fh->prefix = prefix;
+ }
+
if (switch_core_file_open(fh,
file,
read_impl.number_of_channels,
case 's':
unescaped = ' ';
break;
- case '\\':
- unescaped = 1; /* 1 means double esc */
- break;
default:
unescaped = escaped;
}
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++;
}
if (end) {
*end = '\0';
}
+
return start;
}
}
}
/* 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;
}
}
}
/* 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;
}