From ec2f4a5b9bffcebbbe664596da1942b5f1cc8e28 Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 29 Jul 2008 17:32:30 +0000 Subject: [PATCH] fix voicemail_inject usage api call git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9202 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../mod_voicemail/mod_voicemail.c | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index bce8565dba..6721df3247 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -2076,14 +2076,19 @@ static void deliver_vm(vm_profile_t *profile, static switch_status_t voicemail_inject(const char *data) { vm_profile_t *profile; - char *dup, *user = NULL, *domain = NULL; - switch_status_t status = SWITCH_STATUS_FALSE; + char *dup = NULL, *user = NULL, *domain = NULL; + switch_status_t status = SWITCH_STATUS_SUCCESS; int istag = 0, isall = 0; int argc = 0; char *argv[4]; char *box, *path, *cid_num, *cid_name; switch_memory_pool_t *pool = NULL; + if (switch_strlen_zero(data)) { + status = SWITCH_STATUS_FALSE; + goto end; + } + dup = strdup(data); switch_assert(dup); @@ -2163,16 +2168,13 @@ static switch_status_t voicemail_inject(const char *data) switch_core_destroy_memory_pool(&pool); switch_xml_free(xml_root); - } - end: switch_safe_free(dup); return status; - } static switch_status_t voicemail_leave_main(switch_core_session_t *session, const char *profile_name, const char *domain_name, const char *id) @@ -3090,13 +3092,14 @@ static void do_web(vm_profile_t *profile, char *user, char *domain, char *host, } } - - +#define VM_INJECT_USAGE "[tag=] [] []" SWITCH_STANDARD_API(voicemail_inject_api_function) { - voicemail_inject(cmd); - - stream->write_function(stream, "%s", "+OK\n"); + if (voicemail_inject(cmd) == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "%s", "+OK\n"); + } else { + stream->write_function(stream, "Error: %s\n", VM_INJECT_USAGE); + } return SWITCH_STATUS_SUCCESS; } @@ -3226,7 +3229,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voicemail_load) } SWITCH_ADD_API(commands_api_interface, "voicemail", "voicemail", voicemail_api_function, VOICEMAIL_SYNTAX); - SWITCH_ADD_API(commands_api_interface, "voicemail_inject", "voicemail", voicemail_inject_api_function, ""); + SWITCH_ADD_API(commands_api_interface, "voicemail_inject", "voicemail_inject", voicemail_inject_api_function, VM_INJECT_USAGE); SWITCH_ADD_API(commands_api_interface, "vm_boxcount", "vm_boxcount", boxcount_api_function, BOXCOUNT_SYNTAX); /* indicate that the module should continue to be loaded */