mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-20 03:59:01 +00:00
AGI formatting fixes (bug #3270)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4715 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -112,6 +112,8 @@ static void agi_debug_cli(int fd, char *fmt, ...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* launch_netscript: The fastagi handler.
|
||||||
|
FastAGI defaults to port 4573 */
|
||||||
static int launch_netscript(char *agiurl, char *argv[], int *fds, int *efd, int *opid)
|
static int launch_netscript(char *agiurl, char *argv[], int *fds, int *efd, int *opid)
|
||||||
{
|
{
|
||||||
int s;
|
int s;
|
||||||
@@ -123,8 +125,8 @@ static int launch_netscript(char *agiurl, char *argv[], int *fds, int *efd, int
|
|||||||
struct sockaddr_in sin;
|
struct sockaddr_in sin;
|
||||||
struct hostent *hp;
|
struct hostent *hp;
|
||||||
struct ast_hostent ahp;
|
struct ast_hostent ahp;
|
||||||
ast_log(LOG_DEBUG, "Blah\n");
|
|
||||||
host = ast_strdupa(agiurl + 6);
|
host = ast_strdupa(agiurl + 6); /* Remove agi:// */
|
||||||
if (!host)
|
if (!host)
|
||||||
return -1;
|
return -1;
|
||||||
/* Strip off any script name */
|
/* Strip off any script name */
|
||||||
@@ -184,6 +186,12 @@ static int launch_netscript(char *agiurl, char *argv[], int *fds, int *efd, int
|
|||||||
close(s);
|
close(s);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we have a script parameter, relay it to the fastagi server */
|
||||||
|
if (!ast_strlen_zero(script))
|
||||||
|
fdprintf(s, "agi_network_script: %s\n", script);
|
||||||
|
|
||||||
|
if (option_debug > 3)
|
||||||
ast_log(LOG_DEBUG, "Wow, connected!\n");
|
ast_log(LOG_DEBUG, "Wow, connected!\n");
|
||||||
fds[0] = s;
|
fds[0] = s;
|
||||||
fds[1] = s;
|
fds[1] = s;
|
||||||
@@ -390,9 +398,14 @@ static int handle_tddmode(struct ast_channel *chan, AGI *agi, int argc, char *ar
|
|||||||
int res,x;
|
int res,x;
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
if (!strncasecmp(argv[2],"on",2)) x = 1; else x = 0;
|
if (!strncasecmp(argv[2],"on",2))
|
||||||
if (!strncasecmp(argv[2],"mate",4)) x = 2;
|
x = 1;
|
||||||
if (!strncasecmp(argv[2],"tdd",3)) x = 1;
|
else
|
||||||
|
x = 0;
|
||||||
|
if (!strncasecmp(argv[2],"mate",4))
|
||||||
|
x = 2;
|
||||||
|
if (!strncasecmp(argv[2],"tdd",3))
|
||||||
|
x = 1;
|
||||||
res = ast_channel_setoption(chan, AST_OPTION_TDD, &x, sizeof(char), 0);
|
res = ast_channel_setoption(chan, AST_OPTION_TDD, &x, sizeof(char), 0);
|
||||||
fdprintf(agi->fd, "200 result=%d\n", res);
|
fdprintf(agi->fd, "200 result=%d\n", res);
|
||||||
if (res >= 0)
|
if (res >= 0)
|
||||||
@@ -637,8 +650,14 @@ static int handle_getdata(struct ast_channel *chan, AGI *agi, int argc, char *ar
|
|||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
if (argc >= 4) timeout = atoi(argv[3]); else timeout = 0;
|
if (argc >= 4)
|
||||||
if (argc >= 5) max = atoi(argv[4]); else max = 1024;
|
timeout = atoi(argv[3]);
|
||||||
|
else
|
||||||
|
timeout = 0;
|
||||||
|
if (argc >= 5)
|
||||||
|
max = atoi(argv[4]);
|
||||||
|
else
|
||||||
|
max = 1024;
|
||||||
res = ast_app_getdata_full(chan, argv[2], data, max, timeout, agi->audio, agi->ctrl);
|
res = ast_app_getdata_full(chan, argv[2], data, max, timeout, agi->audio, agi->ctrl);
|
||||||
if (res == 2) /* New command */
|
if (res == 2) /* New command */
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
@@ -928,6 +947,7 @@ static int handle_setcallerid(struct ast_channel *chan, AGI *agi, int argc, char
|
|||||||
{
|
{
|
||||||
char tmp[256]="";
|
char tmp[256]="";
|
||||||
char *l = NULL, *n = NULL;
|
char *l = NULL, *n = NULL;
|
||||||
|
|
||||||
if (argv[2]) {
|
if (argv[2]) {
|
||||||
strncpy(tmp, argv[2], sizeof(tmp) - 1);
|
strncpy(tmp, argv[2], sizeof(tmp) - 1);
|
||||||
ast_callerid_parse(tmp, &n, &l);
|
ast_callerid_parse(tmp, &n, &l);
|
||||||
@@ -984,6 +1004,7 @@ static int handle_getvariable(struct ast_channel *chan, AGI *agi, int argc, char
|
|||||||
{
|
{
|
||||||
char *ret;
|
char *ret;
|
||||||
char tempstr[1024];
|
char tempstr[1024];
|
||||||
|
|
||||||
if (argc != 3)
|
if (argc != 3)
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
pbx_retrieve_variable(chan, argv[2], &ret, tempstr, sizeof(tempstr), NULL);
|
pbx_retrieve_variable(chan, argv[2], &ret, tempstr, sizeof(tempstr), NULL);
|
||||||
@@ -999,6 +1020,7 @@ static int handle_getvariablefull(struct ast_channel *chan, AGI *agi, int argc,
|
|||||||
{
|
{
|
||||||
char tmp[4096];
|
char tmp[4096];
|
||||||
struct ast_channel *chan2=NULL;
|
struct ast_channel *chan2=NULL;
|
||||||
|
|
||||||
if ((argc != 4) && (argc != 5))
|
if ((argc != 4) && (argc != 5))
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
if (argc == 5) {
|
if (argc == 5) {
|
||||||
@@ -1060,6 +1082,7 @@ static int handle_dbget(struct ast_channel *chan, AGI *agi, int argc, char **arg
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
|
|
||||||
if (argc != 4)
|
if (argc != 4)
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
res = ast_db_get(argv[2], argv[3], tmp, sizeof(tmp));
|
res = ast_db_get(argv[2], argv[3], tmp, sizeof(tmp));
|
||||||
@@ -1074,6 +1097,7 @@ static int handle_dbget(struct ast_channel *chan, AGI *agi, int argc, char **arg
|
|||||||
static int handle_dbput(struct ast_channel *chan, AGI *agi, int argc, char **argv)
|
static int handle_dbput(struct ast_channel *chan, AGI *agi, int argc, char **argv)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (argc != 5)
|
if (argc != 5)
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
res = ast_db_put(argv[2], argv[3], argv[4]);
|
res = ast_db_put(argv[2], argv[3], argv[4]);
|
||||||
@@ -1088,6 +1112,7 @@ static int handle_dbput(struct ast_channel *chan, AGI *agi, int argc, char **arg
|
|||||||
static int handle_dbdel(struct ast_channel *chan, AGI *agi, int argc, char **argv)
|
static int handle_dbdel(struct ast_channel *chan, AGI *agi, int argc, char **argv)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (argc != 4)
|
if (argc != 4)
|
||||||
return RESULT_SHOWUSAGE;
|
return RESULT_SHOWUSAGE;
|
||||||
res = ast_db_del(argv[2], argv[3]);
|
res = ast_db_del(argv[2], argv[3]);
|
||||||
@@ -1419,6 +1444,7 @@ static agi_command commands[MAX_COMMANDS] = {
|
|||||||
static void join(char *s, size_t len, char *w[])
|
static void join(char *s, size_t len, char *w[])
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
/* Join words into a string */
|
/* Join words into a string */
|
||||||
if (!s) {
|
if (!s) {
|
||||||
return;
|
return;
|
||||||
@@ -1491,8 +1517,10 @@ static agi_command *find_command(char *cmds[], int exact)
|
|||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int match;
|
int match;
|
||||||
|
|
||||||
for (x=0; x < sizeof(commands) / sizeof(commands[0]); x++) {
|
for (x=0; x < sizeof(commands) / sizeof(commands[0]); x++) {
|
||||||
if (!commands[x].cmda[0]) break;
|
if (!commands[x].cmda[0])
|
||||||
|
break;
|
||||||
/* start optimistic */
|
/* start optimistic */
|
||||||
match = 1;
|
match = 1;
|
||||||
for (y=0; match && cmds[y]; y++) {
|
for (y=0; match && cmds[y]; y++) {
|
||||||
@@ -1502,7 +1530,8 @@ static agi_command *find_command(char *cmds[], int exact)
|
|||||||
if (!commands[x].cmda[y] && !exact)
|
if (!commands[x].cmda[y] && !exact)
|
||||||
break;
|
break;
|
||||||
/* don't segfault if the next part of a command doesn't exist */
|
/* don't segfault if the next part of a command doesn't exist */
|
||||||
if (!commands[x].cmda[y]) return NULL;
|
if (!commands[x].cmda[y])
|
||||||
|
return NULL;
|
||||||
if (strcasecmp(commands[x].cmda[y], cmds[y]))
|
if (strcasecmp(commands[x].cmda[y], cmds[y]))
|
||||||
match = 0;
|
match = 0;
|
||||||
}
|
}
|
||||||
@@ -1590,6 +1619,7 @@ static int agi_handle_command(struct ast_channel *chan, AGI *agi, char *buf)
|
|||||||
int res;
|
int res;
|
||||||
agi_command *c;
|
agi_command *c;
|
||||||
argc = MAX_ARGS;
|
argc = MAX_ARGS;
|
||||||
|
|
||||||
parse_args(buf, &argc, argv);
|
parse_args(buf, &argc, argv);
|
||||||
#if 0
|
#if 0
|
||||||
{ int x;
|
{ int x;
|
||||||
@@ -1790,6 +1820,7 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
|
|||||||
int pid;
|
int pid;
|
||||||
char *stringp;
|
char *stringp;
|
||||||
AGI agi;
|
AGI agi;
|
||||||
|
|
||||||
if (!data || ast_strlen_zero(data)) {
|
if (!data || ast_strlen_zero(data)) {
|
||||||
ast_log(LOG_WARNING, "AGI requires an argument (script)\n");
|
ast_log(LOG_WARNING, "AGI requires an argument (script)\n");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1837,6 +1868,7 @@ static int eagi_exec(struct ast_channel *chan, void *data)
|
|||||||
{
|
{
|
||||||
int readformat;
|
int readformat;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (chan->_softhangup)
|
if (chan->_softhangup)
|
||||||
ast_log(LOG_WARNING, "If you want to run AGI on hungup channels you should use DeadAGI!\n");
|
ast_log(LOG_WARNING, "If you want to run AGI on hungup channels you should use DeadAGI!\n");
|
||||||
readformat = chan->readformat;
|
readformat = chan->readformat;
|
||||||
|
Reference in New Issue
Block a user