add group param to shed_api

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4800 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-03-30 00:36:02 +00:00
parent c15d7892c0
commit d518bc2119
1 changed files with 21 additions and 13 deletions

View File

@ -707,29 +707,37 @@ static void sch_api_callback(switch_scheduler_task_t *task)
static switch_status_t sched_api_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream) static switch_status_t sched_api_function(char *cmd, switch_core_session_t *isession, switch_stream_handle_t *stream)
{ {
char *tm = NULL, *dcmd; char *tm = NULL, *dcmd, *group;
time_t when; time_t when;
assert(cmd != NULL); assert(cmd != NULL);
tm = strdup(cmd); tm = strdup(cmd);
assert(tm != NULL); assert(tm != NULL);
if ((dcmd = strchr(tm, ' '))) { if ((group = strchr(tm, ' '))) {
uint32_t id; uint32_t id;
*dcmd++ = '\0'; *group++ = '\0';
if (*tm == '+') { if ((dcmd = strchr(group, ' '))) {
when = time(NULL) + atol(tm + 1); *dcmd++ = '\0';
} else {
when = atol(tm); if (*tm == '+') {
} when = time(NULL) + atol(tm + 1);
id = switch_scheduler_add_task(when, sch_api_callback, (char *) __SWITCH_FUNC__, dcmd, 0, strdup(dcmd), SSHF_FREE_ARG); } else {
stream->write_function(stream, "Added task %u\n", id); when = atol(tm);
} else { }
stream->write_function(stream, "Invalid syntax\n");
id = switch_scheduler_add_task(when, sch_api_callback, (char *) __SWITCH_FUNC__, group, 0, strdup(dcmd), SSHF_FREE_ARG);
stream->write_function(stream, "Added task %u for command [%s] group [%s]\n", id, dcmd, group);
goto good;
}
} }
stream->write_function(stream, "Invalid syntax\n");
good:
switch_safe_free(tm); switch_safe_free(tm);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
@ -891,7 +899,7 @@ static switch_api_interface_t sched_api_api_interface = {
/*.interface_name */ "sched_api", /*.interface_name */ "sched_api",
/*.desc */ "Schedule an api command", /*.desc */ "Schedule an api command",
/*.function */ sched_api_function, /*.function */ sched_api_function,
/*.syntax */ "[+]<time> <command string>", /*.syntax */ "[+]<time> <group_name> <command_string>",
/*.next */ NULL /*.next */ NULL
}; };