{
switch_api_interface_t *api;
switch_status_t status;
+ char *arg_no_spaces;
+ char *cmd_no_spaces;
switch_assert(stream != NULL);
switch_assert(stream->data != NULL);
switch_assert(stream->write_function != NULL);
+
+ cmd_no_spaces = switch_strip_whitespace(cmd);
+ arg_no_spaces = switch_strip_whitespace(arg);
+
+
if (!stream->param_event) {
switch_event_create(&stream->param_event, SWITCH_EVENT_API);
}
if (stream->param_event) {
- if (cmd) {
- switch_event_add_header_string(stream->param_event, SWITCH_STACK_BOTTOM, "API-Command", cmd);
+ if (cmd_no_spaces) {
+ switch_event_add_header_string(stream->param_event, SWITCH_STACK_BOTTOM, "API-Command", cmd_no_spaces);
}
- if (arg) {
- switch_event_add_header_string(stream->param_event, SWITCH_STACK_BOTTOM, "API-Command-Argument", arg);
+ if (arg_no_spaces) {
+ switch_event_add_header_string(stream->param_event, SWITCH_STACK_BOTTOM, "API-Command-Argument", arg_no_spaces);
}
}
- if (cmd && (api = switch_loadable_module_get_api_interface(cmd)) != 0) {
- if ((status = api->function(arg, session, stream)) != SWITCH_STATUS_SUCCESS) {
+ if (cmd_no_spaces && (api = switch_loadable_module_get_api_interface(cmd_no_spaces)) != 0) {
+ if ((status = api->function(arg_no_spaces, session, stream)) != SWITCH_STATUS_SUCCESS) {
stream->write_function(stream, "COMMAND RETURNED ERROR!\n");
}
UNPROTECT_INTERFACE(api);
switch_event_fire(&stream->param_event);
}
+ switch_safe_free(cmd_no_spaces);
+ switch_safe_free(arg_no_spaces);
return status;
}