Skip to content
Snippets Groups Projects
Commit 711f35fd authored by Russell Bryant's avatar Russell Bryant
Browse files

- 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
parent 532e552c
Branches
Tags
No related merge requests found
/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 2005, Digium, Inc.
* Copyright (C) 2005 - 2006, Digium, Inc.
*
* Russell Bryant <russell@digium.com>
*
......@@ -18,6 +18,7 @@
/*!
* \file
* \author Russell Bryant <russell@digium.com>
*
* \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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment