centralize api interface

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@197 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2005-12-23 02:55:25 +00:00
parent 32273a0c3f
commit f52b45c2c9
4 changed files with 25 additions and 23 deletions
+3 -13
View File
@@ -206,11 +206,10 @@ int on_stream (struct session *sess, int type, iks *node)
int on_msg (void *user_data, ikspak *pak)
{
switch_api_interface *api;
switch_event *event;
char *cmd = iks_find_cdata (pak->x, "body");
char *arg = NULL;
switch_event *event;
char retbuf[512] = "";
char retbuf[1024] = "";
char *p;
if ((p = strchr(cmd, '\r'))) {
@@ -222,17 +221,8 @@ int on_msg (void *user_data, ikspak *pak)
if ((arg = strchr(cmd, ' '))) {
*arg++ = '\0';
}
if (arg && (p = strchr(arg, '\r'))) {
*p++ = '\0';
} else if ((p = strchr(cmd, '\n'))) {
*p++ = '\0';
}
if ((api = loadable_module_get_api_interface(cmd))) {
api->function(arg, retbuf, sizeof(retbuf));
} else {
snprintf(retbuf, sizeof(retbuf), "INVALID COMMAND [%s]", cmd);
}
switch_api_execute(cmd, arg, retbuf, sizeof(retbuf));
if (switch_event_create(&event, SWITCH_EVENT_API) == SWITCH_STATUS_SUCCESS) {
if (cmd) {