mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
- 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
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Asterisk -- An open source telephony toolkit.
|
* Asterisk -- An open source telephony toolkit.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2005, Digium, Inc.
|
* Copyright (C) 2005 - 2006, Digium, Inc.
|
||||||
*
|
*
|
||||||
* Russell Bryant <russell@digium.com>
|
* Russell Bryant <russell@digium.com>
|
||||||
*
|
*
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \file
|
* \file
|
||||||
|
* \author Russell Bryant <russell@digium.com>
|
||||||
*
|
*
|
||||||
* \brief Originate calls via the CLI
|
* \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 };
|
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 *chantech;
|
||||||
char *chandata;
|
char *chandata;
|
||||||
@@ -75,14 +76,12 @@ static int orig_app(const char *chan, const char *app, const char *appdata)
|
|||||||
if (ast_strlen_zero(app))
|
if (ast_strlen_zero(app))
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
|
|
||||||
chandata = ast_strdupa(chan);
|
if (!(chandata = ast_strdupa(chan)))
|
||||||
if (!chandata) {
|
|
||||||
ast_log(LOG_ERROR, "Out of Memory!\n");
|
|
||||||
return RESULT_FAILURE;
|
return RESULT_FAILURE;
|
||||||
}
|
|
||||||
chantech = strsep(&chandata, "/");
|
chantech = strsep(&chandata, "/");
|
||||||
if (!chandata) {
|
if (!chandata) {
|
||||||
ast_log(LOG_ERROR, "No dial string.\n");
|
ast_cli(fd, "*** No data provided after channel type! ***\n");
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +90,7 @@ static int orig_app(const char *chan, const char *app, const char *appdata)
|
|||||||
return RESULT_SUCCESS;
|
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 *chantech;
|
||||||
char *chandata;
|
char *chandata;
|
||||||
@@ -99,19 +98,18 @@ static int orig_exten(const char *chan, const char *data)
|
|||||||
char *context = NULL;
|
char *context = NULL;
|
||||||
int reason = 0;
|
int reason = 0;
|
||||||
|
|
||||||
chandata = ast_strdupa(chan);
|
if (!(chandata = ast_strdupa(chan)))
|
||||||
if (!chandata) {
|
|
||||||
ast_log(LOG_ERROR, "Out of Memory!\n");
|
|
||||||
return RESULT_FAILURE;
|
return RESULT_FAILURE;
|
||||||
}
|
|
||||||
chantech = strsep(&chandata, "/");
|
chantech = strsep(&chandata, "/");
|
||||||
|
if (!chandata) {
|
||||||
|
ast_cli(fd, "*** No data provided after channel type! ***\n");
|
||||||
|
return RESULT_SHOWUSAGE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!ast_strlen_zero(data)) {
|
if (!ast_strlen_zero(data)) {
|
||||||
context = ast_strdupa(data);
|
if (!(context = ast_strdupa(data)))
|
||||||
if (!context) {
|
|
||||||
ast_log(LOG_ERROR, "Out of Memory!\n");
|
|
||||||
return RESULT_FAILURE;
|
return RESULT_FAILURE;
|
||||||
}
|
|
||||||
exten = strsep(&context, "@");
|
exten = strsep(&context, "@");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,9 +133,9 @@ static int handle_orig(int fd, int argc, char *argv[])
|
|||||||
ast_atomic_fetchadd_int(&me->usecnt, +1);
|
ast_atomic_fetchadd_int(&me->usecnt, +1);
|
||||||
|
|
||||||
if (!strcasecmp("application", argv[2])) {
|
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])) {
|
} else if (!strcasecmp("extension", argv[2])) {
|
||||||
res = orig_exten(argv[1], argv[3]);
|
res = orig_exten(fd, argv[1], argv[3]);
|
||||||
} else
|
} else
|
||||||
res = RESULT_SHOWUSAGE;
|
res = RESULT_SHOWUSAGE;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user