From 711f35fdc32e78d4dedc2b55d0b95fa88e6e506d Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Sat, 29 Apr 2006 05:02:17 +0000 Subject: - don't create duplicate log messages - note when the data part of the tech/data pair is missing not only when using the app version, but the exten version as well - instead of logging syntax errors, just output them to the CLI git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@23284 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_clioriginate.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'res') diff --git a/res/res_clioriginate.c b/res/res_clioriginate.c index a9ebb3647..1c02491d2 100644 --- a/res/res_clioriginate.c +++ b/res/res_clioriginate.c @@ -1,7 +1,7 @@ /* * Asterisk -- An open source telephony toolkit. * - * Copyright (C) 2005, Digium, Inc. + * Copyright (C) 2005 - 2006, Digium, Inc. * * Russell Bryant * @@ -18,6 +18,7 @@ /*! * \file + * \author Russell Bryant * * \brief Originate calls via the CLI * @@ -66,7 +67,7 @@ static char *complete_orig(const char *line, const char *word, int pos, int stat struct ast_cli_entry cli_orig = { { "originate", NULL }, handle_orig, "Originate a call", orig_help, complete_orig }; -static int orig_app(const char *chan, const char *app, const char *appdata) +static int orig_app(int fd, const char *chan, const char *app, const char *appdata) { char *chantech; char *chandata; @@ -75,14 +76,12 @@ static int orig_app(const char *chan, const char *app, const char *appdata) if (ast_strlen_zero(app)) return RESULT_SHOWUSAGE; - chandata = ast_strdupa(chan); - if (!chandata) { - ast_log(LOG_ERROR, "Out of Memory!\n"); + if (!(chandata = ast_strdupa(chan))) return RESULT_FAILURE; - } + chantech = strsep(&chandata, "/"); if (!chandata) { - ast_log(LOG_ERROR, "No dial string.\n"); + ast_cli(fd, "*** No data provided after channel type! ***\n"); return RESULT_SHOWUSAGE; } @@ -91,7 +90,7 @@ static int orig_app(const char *chan, const char *app, const char *appdata) return RESULT_SUCCESS; } -static int orig_exten(const char *chan, const char *data) +static int orig_exten(int fd, const char *chan, const char *data) { char *chantech; char *chandata; @@ -99,19 +98,18 @@ static int orig_exten(const char *chan, const char *data) char *context = NULL; int reason = 0; - chandata = ast_strdupa(chan); - if (!chandata) { - ast_log(LOG_ERROR, "Out of Memory!\n"); + if (!(chandata = ast_strdupa(chan))) return RESULT_FAILURE; - } + chantech = strsep(&chandata, "/"); + if (!chandata) { + ast_cli(fd, "*** No data provided after channel type! ***\n"); + return RESULT_SHOWUSAGE; + } if (!ast_strlen_zero(data)) { - context = ast_strdupa(data); - if (!context) { - ast_log(LOG_ERROR, "Out of Memory!\n"); + if (!(context = ast_strdupa(data))) return RESULT_FAILURE; - } exten = strsep(&context, "@"); } @@ -135,9 +133,9 @@ static int handle_orig(int fd, int argc, char *argv[]) ast_atomic_fetchadd_int(&me->usecnt, +1); if (!strcasecmp("application", argv[2])) { - res = orig_app(argv[1], argv[3], argv[4]); + res = orig_app(fd, argv[1], argv[3], argv[4]); } else if (!strcasecmp("extension", argv[2])) { - res = orig_exten(argv[1], argv[3]); + res = orig_exten(fd, argv[1], argv[3]); } else res = RESULT_SHOWUSAGE; -- cgit v1.2.3