struct hostent *hp;
struct ast_hostent ahp;
+ /* agiusl is "agi://host.domain[:port][/script/name]" */
host = ast_strdupa(agiurl + 6); /* Remove agi:// */
if (!host)
return -1;
return -1;
}
}
-
+ /* XXX in theory should check for partial writes... */
while (write(s, "agi_network: yes\n", strlen("agi_network: yes\n")) < 0) {
if (errno != EINTR) {
ast_log(LOG_WARNING, "Connect to '%s' failed: %s\n", agiurl, strerror(errno));
res = ast_answer(chan);
}
fdprintf(agi->fd, "200 result=%d\n", res);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
static int handle_waitfordigit(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
return RESULT_SHOWUSAGE;
res = ast_waitfordigit_full(chan, to, agi->audio, agi->ctrl);
fdprintf(agi->fd, "200 result=%d\n", res);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
static int handle_sendtext(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
before sending it to ast_sendtext --DUDE */
res = ast_sendtext(chan, argv[2]);
fdprintf(agi->fd, "200 result=%d\n", res);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
static int handle_recvchar(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
if (!ast_check_hangup(chan))
res = 0;
fdprintf(agi->fd, "200 result=%d\n", res);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
static int handle_controlstreamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
fdprintf(agi->fd, "200 result=%d\n", res);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
long sample_offset = 0;
long max_length;
- if (argc < 4)
- return RESULT_SHOWUSAGE;
- if (argc > 5)
+ if (argc < 4 || argc > 5)
return RESULT_SHOWUSAGE;
if ((argc > 4) && (sscanf(argv[4], "%ld", &sample_offset) != 1))
return RESULT_SHOWUSAGE;
res = ast_playstream(fs);
if (res) {
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset);
- if (res >= 0)
- return RESULT_SHOWUSAGE;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SHOWUSAGE : RESULT_FAILURE;
}
res = ast_waitstream_full(chan, argv[3], agi->audio, agi->ctrl);
/* this is to check for if ast_waitstream closed the stream, we probably are at
return RESULT_SUCCESS;
}
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
/* get option - really similar to the handle_streamfile, but with a timeout */
}
fdprintf(agi->fd, "200 result=%d endpos=%ld\n", res, sample_offset);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
if (res == 1)
return RESULT_SUCCESS;
fdprintf(agi->fd, "200 result=%d\n", res);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
static int handle_saydigits(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
if (res == 1) /* New command */
return RESULT_SUCCESS;
fdprintf(agi->fd, "200 result=%d\n", res);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
static int handle_sayalpha(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
if (res == 1) /* New command */
return RESULT_SUCCESS;
fdprintf(agi->fd, "200 result=%d\n", res);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
static int handle_saydate(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
if (res == 1)
return RESULT_SUCCESS;
fdprintf(agi->fd, "200 result=%d\n", res);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
static int handle_saytime(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
if (argc > 4) {
format = argv[4];
} else {
+ /* XXX this doesn't belong here, but in the 'say' module */
if (!strcasecmp(chan->language, "de")) {
format = "A dBY HMS";
} else {
if (res == 1) /* New command */
return RESULT_SUCCESS;
fdprintf(agi->fd, "200 result=%d\n", res);
- if (res >= 0)
- return RESULT_SUCCESS;
- else
- return RESULT_FAILURE;
+ return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
static int handle_getdata(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
if (argc != 5)
return RESULT_SHOWUSAGE;
res = ast_db_put(argv[2], argv[3], argv[4]);
- if (res)
- fdprintf(agi->fd, "200 result=0\n");
- else
- fdprintf(agi->fd, "200 result=1\n");
-
+ fdprintf(agi->fd, "200 result=%c\n", res ? '0' : '1');
return RESULT_SUCCESS;
}
if (argc != 4)
return RESULT_SHOWUSAGE;
res = ast_db_del(argv[2], argv[3]);
- if (res)
- fdprintf(agi->fd, "200 result=0\n");
- else
- fdprintf(agi->fd, "200 result=1\n");
-
+ fdprintf(agi->fd, "200 result=%c\n", res ? '0' : '1');
return RESULT_SUCCESS;
}
else
res = ast_db_deltree(argv[2], NULL);
- if (res)
- fdprintf(agi->fd, "200 result=0\n");
- else
- fdprintf(agi->fd, "200 result=1\n");
+ fdprintf(agi->fd, "200 result=%c\n", res ? '0' : '1');
return RESULT_SUCCESS;
}
static int handle_setmusic(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
{
- if (!strncasecmp(argv[2],"on",2)) {
- if (argc > 3)
- ast_moh_start(chan, argv[3]);
- else
- ast_moh_start(chan, NULL);
- }
- if (!strncasecmp(argv[2],"off",3)) {
+ if (!strncasecmp(argv[2], "on", 2))
+ ast_moh_start(chan, argc > 3 ? argv[3] : NULL);
+ else if (!strncasecmp(argv[2], "off", 3))
ast_moh_stop(chan);
- }
fdprintf(agi->fd, "200 result=0\n");
return RESULT_SUCCESS;
}
return returnstatus;
}
-static int handle_showagi(int fd, int argc, char *argv[]) {
+static int handle_showagi(int fd, int argc, char *argv[])
+{
struct agi_command *e;
char fullcmd[80];
if ((argc < 2))
return RESULT_SUCCESS;
}
-static int handle_dumpagihtml(int fd, int argc, char *argv[]) {
+static int handle_dumpagihtml(int fd, int argc, char *argv[])
+{
struct agi_command *e;
char fullcmd[80];
int x;