git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@1425 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2006-05-10 19:07:38 +00:00
parent 3230f6ef20
commit 295424544d
6 changed files with 129 additions and 11 deletions
+15 -10
View File
@@ -671,12 +671,24 @@ SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_
{
switch_api_interface_t *api;
switch_status_t status;
switch_event_t *event;
assert(stream != NULL);
assert(stream->data != NULL);
assert(stream->write_function != NULL);
if (!stream->event) {
switch_event_create(&stream->event, SWITCH_EVENT_API);
}
if (stream->event) {
if (cmd) {
switch_event_add_header(stream->event, SWITCH_STACK_BOTTOM, "API-Command", cmd);
}
if (arg) {
switch_event_add_header(stream->event, SWITCH_STACK_BOTTOM, "API-Command-Arguement", arg);
}
}
if ((api = switch_loadable_module_get_api_interface(cmd)) != 0) {
status = api->function(arg, stream);
} else {
@@ -685,15 +697,8 @@ SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, switch_
//snprintf(retbuf, len, "INVALID COMMAND [%s]", cmd);
}
if (switch_event_create(&event, SWITCH_EVENT_API) == SWITCH_STATUS_SUCCESS) {
if (cmd) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "API-Command", cmd);
}
if (arg) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "API-Command-Arguement", arg);
}
//switch_event_add_body(event, retbuf);
switch_event_fire(&event);
if (stream->event) {
switch_event_fire(&stream->event);
}