summaryrefslogtreecommitdiff
path: root/res/res_agi.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2009-05-21 21:13:09 +0000
committerKevin P. Fleming <kpfleming@digium.com>2009-05-21 21:13:09 +0000
commite6b2e9a7501b5d2e351a5e626fa13dfc3c113f1e (patch)
treeb40d978190102dbe6f14458ab8a70f358db533e4 /res/res_agi.c
parent88bda581ec7c524050bca769c6705ee5c66357ad (diff)
Const-ify the world (or at least a good part of it)
This patch adds 'const' tags to a number of Asterisk APIs where they are appropriate (where the API already demanded that the function argument not be modified, but the compiler was not informed of that fact). The list includes: - CLI command handlers - CLI command handler arguments - AGI command handlers - AGI command handler arguments - Dialplan application handler arguments - Speech engine API function arguments In addition, various file-scope and function-scope constant arrays got 'const' and/or 'static' qualifiers where they were missing. Review: https://reviewboard.asterisk.org/r/251/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@196072 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_agi.c')
-rw-r--r--res/res_agi.c216
1 files changed, 110 insertions, 106 deletions
diff --git a/res/res_agi.c b/res/res_agi.c
index 93dc6c664..f7ff01c5e 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -425,7 +425,7 @@ enum agi_result {
AGI_RESULT_HANGUP,
};
-static agi_command *find_command(char *cmds[], int exact);
+static agi_command *find_command(const char * const cmds[], int exact);
AST_THREADSTORAGE(agi_buf);
#define AGI_BUF_INITSIZE 256
@@ -1093,7 +1093,7 @@ static void setup_env(struct ast_channel *chan, char *request, int fd, int enhan
ast_agi_send(fd, chan, "\n");
}
-static int handle_answer(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_answer(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res = 0;
@@ -1105,13 +1105,13 @@ static int handle_answer(struct ast_channel *chan, AGI *agi, int argc, char *arg
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_asyncagi_break(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_asyncagi_break(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_FAILURE;
}
-static int handle_waitfordigit(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_waitfordigit(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res, to;
@@ -1124,7 +1124,7 @@ static int handle_waitfordigit(struct ast_channel *chan, AGI *agi, int argc, cha
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_sendtext(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_sendtext(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res;
@@ -1143,7 +1143,7 @@ static int handle_sendtext(struct ast_channel *chan, AGI *agi, int argc, char *a
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_recvchar(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_recvchar(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res;
@@ -1163,7 +1163,7 @@ static int handle_recvchar(struct ast_channel *chan, AGI *agi, int argc, char *a
return RESULT_FAILURE;
}
-static int handle_recvtext(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_recvtext(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
char *buf;
@@ -1180,7 +1180,7 @@ static int handle_recvtext(struct ast_channel *chan, AGI *agi, int argc, char *a
return RESULT_SUCCESS;
}
-static int handle_tddmode(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_tddmode(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res, x;
@@ -1207,7 +1207,7 @@ static int handle_tddmode(struct ast_channel *chan, AGI *agi, int argc, char *ar
return RESULT_SUCCESS;
}
-static int handle_sendimage(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_sendimage(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res;
@@ -1223,10 +1223,10 @@ static int handle_sendimage(struct ast_channel *chan, AGI *agi, int argc, char *
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_controlstreamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_controlstreamfile(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res = 0, skipms = 3000;
- char *fwd = "#", *rev = "*", *suspend = NULL, *stop = NULL; /* Default values */
+ const char *fwd = "#", *rev = "*", *suspend = NULL, *stop = NULL; /* Default values */
if (argc < 5 || argc > 9) {
return RESULT_SHOWUSAGE;
@@ -1259,12 +1259,12 @@ static int handle_controlstreamfile(struct ast_channel *chan, AGI *agi, int argc
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res, vres;
struct ast_filestream *fs, *vfs;
long sample_offset = 0, max_length;
- char *edigits = "";
+ const char *edigits = "";
if (argc < 4 || argc > 5)
return RESULT_SHOWUSAGE;
@@ -1309,13 +1309,13 @@ static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char
}
/*! \brief get option - really similar to the handle_streamfile, but with a timeout */
-static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res, vres;
struct ast_filestream *fs, *vfs;
long sample_offset = 0, max_length;
int timeout = 0;
- char *edigits = "";
+ const char *edigits = "";
if ( argc < 4 || argc > 5 )
return RESULT_SHOWUSAGE;
@@ -1378,7 +1378,7 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, char *
/*! \brief Say number in various language syntaxes */
/* While waiting, we're sending a NULL. */
-static int handle_saynumber(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_saynumber(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res, num;
@@ -1393,7 +1393,7 @@ static int handle_saynumber(struct ast_channel *chan, AGI *agi, int argc, char *
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_saydigits(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_saydigits(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res, num;
@@ -1409,7 +1409,7 @@ static int handle_saydigits(struct ast_channel *chan, AGI *agi, int argc, char *
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_sayalpha(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_sayalpha(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res;
@@ -1423,7 +1423,7 @@ static int handle_sayalpha(struct ast_channel *chan, AGI *agi, int argc, char *a
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_saydate(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_saydate(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res, num;
@@ -1438,7 +1438,7 @@ static int handle_saydate(struct ast_channel *chan, AGI *agi, int argc, char *ar
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_saytime(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_saytime(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res, num;
@@ -1453,11 +1453,11 @@ static int handle_saytime(struct ast_channel *chan, AGI *agi, int argc, char *ar
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_saydatetime(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_saydatetime(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res = 0;
time_t unixtime;
- char *format, *zone = NULL;
+ const char *format, *zone = NULL;
if (argc < 4)
return RESULT_SHOWUSAGE;
@@ -1487,7 +1487,7 @@ static int handle_saydatetime(struct ast_channel *chan, AGI *agi, int argc, char
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_sayphonetic(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_sayphonetic(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res;
@@ -1501,7 +1501,7 @@ static int handle_sayphonetic(struct ast_channel *chan, AGI *agi, int argc, char
return (res >= 0) ? RESULT_SUCCESS : RESULT_FAILURE;
}
-static int handle_getdata(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_getdata(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res, max, timeout;
char data[1024];
@@ -1528,7 +1528,7 @@ static int handle_getdata(struct ast_channel *chan, AGI *agi, int argc, char *ar
return RESULT_SUCCESS;
}
-static int handle_setcontext(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_setcontext(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
if (argc != 3)
@@ -1538,7 +1538,7 @@ static int handle_setcontext(struct ast_channel *chan, AGI *agi, int argc, char
return RESULT_SUCCESS;
}
-static int handle_setextension(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_setextension(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
if (argc != 3)
return RESULT_SHOWUSAGE;
@@ -1547,7 +1547,7 @@ static int handle_setextension(struct ast_channel *chan, AGI *agi, int argc, cha
return RESULT_SUCCESS;
}
-static int handle_setpriority(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_setpriority(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int pri;
@@ -1564,7 +1564,7 @@ static int handle_setpriority(struct ast_channel *chan, AGI *agi, int argc, char
return RESULT_SUCCESS;
}
-static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
struct ast_filestream *fs;
struct ast_frame *f;
@@ -1741,7 +1741,7 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, char
return RESULT_SUCCESS;
}
-static int handle_autohangup(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_autohangup(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
double timeout;
struct timeval whentohangup = { 0, 0 };
@@ -1761,7 +1761,7 @@ static int handle_autohangup(struct ast_channel *chan, AGI *agi, int argc, char
return RESULT_SUCCESS;
}
-static int handle_hangup(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_hangup(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
struct ast_channel *c;
@@ -1787,7 +1787,7 @@ static int handle_hangup(struct ast_channel *chan, AGI *agi, int argc, char **ar
}
}
-static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res;
struct ast_app *app_to_exec;
@@ -1802,7 +1802,8 @@ static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, char **argv
ast_masq_park_call(chan, NULL, 0, NULL);
}
if (ast_compat_res_agi && !ast_strlen_zero(argv[2])) {
- char *compat = alloca(strlen(argv[2]) * 2 + 1), *cptr, *vptr;
+ char *compat = alloca(strlen(argv[2]) * 2 + 1), *cptr;
+ const char *vptr;
for (cptr = compat, vptr = argv[2]; *vptr; vptr++) {
if (*vptr == ',') {
*cptr++ = '\\';
@@ -1828,7 +1829,7 @@ static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, char **argv
return res;
}
-static int handle_setcallerid(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_setcallerid(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
char tmp[256]="";
char *l = NULL, *n = NULL;
@@ -1849,7 +1850,7 @@ static int handle_setcallerid(struct ast_channel *chan, AGI *agi, int argc, char
return RESULT_SUCCESS;
}
-static int handle_channelstatus(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_channelstatus(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
struct ast_channel *c;
if (argc == 2) {
@@ -1871,7 +1872,7 @@ static int handle_channelstatus(struct ast_channel *chan, AGI *agi, int argc, ch
}
}
-static int handle_setvariable(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_setvariable(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
if (argv[3])
pbx_builtin_setvar_helper(chan, argv[2], argv[3]);
@@ -1880,7 +1881,7 @@ static int handle_setvariable(struct ast_channel *chan, AGI *agi, int argc, char
return RESULT_SUCCESS;
}
-static int handle_getvariable(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_getvariable(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
char *ret;
char tempstr[1024];
@@ -1903,7 +1904,7 @@ static int handle_getvariable(struct ast_channel *chan, AGI *agi, int argc, char
return RESULT_SUCCESS;
}
-static int handle_getvariablefull(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_getvariablefull(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
struct ast_channel *chan2 = NULL;
@@ -1937,7 +1938,7 @@ static int handle_getvariablefull(struct ast_channel *chan, AGI *agi, int argc,
return RESULT_SUCCESS;
}
-static int handle_verbose(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_verbose(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int level = 0;
@@ -1954,7 +1955,7 @@ static int handle_verbose(struct ast_channel *chan, AGI *agi, int argc, char **a
return RESULT_SUCCESS;
}
-static int handle_dbget(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_dbget(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res;
struct ast_str *buf;
@@ -1987,7 +1988,7 @@ static int handle_dbget(struct ast_channel *chan, AGI *agi, int argc, char **arg
return RESULT_SUCCESS;
}
-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, const char * const argv[])
{
int res;
@@ -1998,7 +1999,7 @@ static int handle_dbput(struct ast_channel *chan, AGI *agi, int argc, char **arg
return RESULT_SUCCESS;
}
-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, const char * const argv[])
{
int res;
@@ -2009,7 +2010,7 @@ static int handle_dbdel(struct ast_channel *chan, AGI *agi, int argc, char **arg
return RESULT_SUCCESS;
}
-static int handle_dbdeltree(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_dbdeltree(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
int res;
@@ -2053,13 +2054,13 @@ static char *handle_cli_agi_debug(struct ast_cli_entry *e, int cmd, struct ast_c
return CLI_SUCCESS;
}
-static int handle_noop(struct ast_channel *chan, AGI *agi, int arg, char *argv[])
+static int handle_noop(struct ast_channel *chan, AGI *agi, int arg, const char * const argv[])
{
ast_agi_send(agi->fd, chan, "200 result=0\n");
return RESULT_SUCCESS;
}
-static int handle_setmusic(struct ast_channel *chan, AGI *agi, int argc, char *argv[])
+static int handle_setmusic(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
if (!strncasecmp(argv[2], "on", 2))
ast_moh_start(chan, argc > 3 ? argv[3] : NULL, NULL);
@@ -2069,7 +2070,7 @@ static int handle_setmusic(struct ast_channel *chan, AGI *agi, int argc, char *a
return RESULT_SUCCESS;
}
-static int handle_speechcreate(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_speechcreate(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
/* If a structure already exists, return an error */
if (agi->speech) {
@@ -2085,7 +2086,7 @@ static int handle_speechcreate(struct ast_channel *chan, AGI *agi, int argc, cha
return RESULT_SUCCESS;
}
-static int handle_speechset(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_speechset(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
/* Check for minimum arguments */
if (argc != 3)
@@ -2103,7 +2104,7 @@ static int handle_speechset(struct ast_channel *chan, AGI *agi, int argc, char *
return RESULT_SUCCESS;
}
-static int handle_speechdestroy(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_speechdestroy(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
if (agi->speech) {
ast_speech_destroy(agi->speech);
@@ -2116,7 +2117,7 @@ static int handle_speechdestroy(struct ast_channel *chan, AGI *agi, int argc, ch
return RESULT_SUCCESS;
}
-static int handle_speechloadgrammar(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_speechloadgrammar(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
if (argc != 5)
return RESULT_SHOWUSAGE;
@@ -2134,7 +2135,7 @@ static int handle_speechloadgrammar(struct ast_channel *chan, AGI *agi, int argc
return RESULT_SUCCESS;
}
-static int handle_speechunloadgrammar(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_speechunloadgrammar(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
if (argc != 4)
return RESULT_SHOWUSAGE;
@@ -2152,7 +2153,7 @@ static int handle_speechunloadgrammar(struct ast_channel *chan, AGI *agi, int ar
return RESULT_SUCCESS;
}
-static int handle_speechactivategrammar(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_speechactivategrammar(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
if (argc != 4)
return RESULT_SHOWUSAGE;
@@ -2170,7 +2171,7 @@ static int handle_speechactivategrammar(struct ast_channel *chan, AGI *agi, int
return RESULT_SUCCESS;
}
-static int handle_speechdeactivategrammar(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_speechdeactivategrammar(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
if (argc != 4)
return RESULT_SHOWUSAGE;
@@ -2207,10 +2208,11 @@ static int speech_streamfile(struct ast_channel *chan, const char *filename, con
return 0;
}
-static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc, char **argv)
+static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
{
struct ast_speech *speech = agi->speech;
- char *prompt, dtmf = 0, tmp[4096] = "", *buf = tmp;
+ const char *prompt;
+ char dtmf = 0, tmp[4096] = "", *buf = tmp;
int timeout = 0, offset = 0, old_read_format = 0, res = 0, i = 0;
long current_offset = 0;
const char *reason = NULL;
@@ -2354,27 +2356,27 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc,
return RESULT_SUCCESS;
}
-static char usage_verbose[] =
+static const char usage_verbose[] =
" Usage: VERBOSE <message> <level>\n"
" Sends <message> to the console via verbose message system.\n"
" <level> is the the verbose level (1-4)\n"
" Always returns 1.\n";
-static char usage_setvariable[] =
+static const char usage_setvariable[] =
" Usage: SET VARIABLE <variablename> <value>\n";
-static char usage_setcallerid[] =
+static const char usage_setcallerid[] =
" Usage: SET CALLERID <number>\n"
" Changes the callerid of the current channel.\n";
-static char usage_waitfordigit[] =
+static const char usage_waitfordigit[] =
" Usage: WAIT FOR DIGIT <timeout>\n"
" Waits up to 'timeout' milliseconds for channel to receive a DTMF digit.\n"
" Returns -1 on channel failure, 0 if no digit is received in the timeout, or\n"
" the numerical value of the ascii of the digit if one is received. Use -1\n"
" for the timeout value if you desire the call to block indefinitely.\n";
-static char usage_sendtext[] =
+static const char usage_sendtext[] =
" Usage: SEND TEXT \"<text to send>\"\n"
" Sends the given text on a channel. Most channels do not support the\n"
" transmission of text. Returns 0 if text is sent, or if the channel does not\n"
@@ -2382,19 +2384,19 @@ static char usage_sendtext[] =
" consisting of greater than one word should be placed in quotes since the\n"
" command only accepts a single argument.\n";
-static char usage_tddmode[] =
+static const char usage_tddmode[] =
" Usage: TDD MODE <on|off>\n"
" Enable/Disable TDD transmission/reception on a channel. Returns 1 if\n"
" successful, or 0 if channel is not TDD-capable.\n";
-static char usage_sendimage[] =
+static const char usage_sendimage[] =
" Usage: SEND IMAGE <image>\n"
" Sends the given image on a channel. Most channels do not support the\n"
" transmission of images. Returns 0 if image is sent, or if the channel does not\n"
" support image transmission. Returns -1 only on error/hangup. Image names\n"
" should not include extensions.\n";
-static char usage_streamfile[] =
+static const char usage_streamfile[] =
" Usage: STREAM FILE <filename> <escape digits> [sample offset]\n"
" Send the given file, allowing playback to be interrupted by the given\n"
" digits, if any. Use double quotes for the digits if you wish none to be\n"
@@ -2404,7 +2406,7 @@ static char usage_streamfile[] =
" or -1 on error or if the channel was disconnected. Remember, the file\n"
" extension must not be included in the filename.\n";
-static char usage_controlstreamfile[] =
+static const char usage_controlstreamfile[] =
" Usage: CONTROL STREAM FILE <filename> <escape digits> [skipms] [ffchar] [rewchr] [pausechr]\n"
" Send the given file, allowing playback to be controled by the given\n"
" digits, if any. Use double quotes for the digits if you wish none to be\n"
@@ -2414,28 +2416,28 @@ static char usage_controlstreamfile[] =
" extension must not be included in the filename.\n\n"
" Note: ffchar and rewchar default to * and # respectively.\n";
-static char usage_saynumber[] =
+static const char usage_saynumber[] =
" Usage: SAY NUMBER <number> <escape digits> [gender]\n"
" Say a given number, returning early if any of the given DTMF digits\n"
" are received on the channel. Returns 0 if playback completes without a digit\n"
" being pressed, or the ASCII numerical value of the digit if one was pressed or\n"
" -1 on error/hangup.\n";
-static char usage_saydigits[] =
+static const char usage_saydigits[] =
" Usage: SAY DIGITS <number> <escape digits>\n"
" Say a given digit string, returning early if any of the given DTMF digits\n"
" are received on the channel. Returns 0 if playback completes without a digit\n"
" being pressed, or the ASCII numerical value of the digit if one was pressed or\n"
" -1 on error/hangup.\n";
-static char usage_sayalpha[] =
+static const char usage_sayalpha[] =
" Usage: SAY ALPHA <number> <escape digits>\n"
" Say a given character string, returning early if any of the given DTMF digits\n"
" are received on the channel. Returns 0 if playback completes without a digit\n"
" being pressed, or the ASCII numerical value of the digit if one was pressed or\n"
" -1 on error/hangup.\n";
-static char usage_saydate[] =
+static const char usage_saydate[] =
" Usage: SAY DATE <date> <escape digits>\n"
" Say a given date, returning early if any of the given DTMF digits are\n"
" received on the channel. <date> is number of seconds elapsed since 00:00:00\n"
@@ -2443,7 +2445,7 @@ static char usage_saydate[] =
" completes without a digit being pressed, or the ASCII numerical value of the\n"
" digit if one was pressed or -1 on error/hangup.\n";
-static char usage_saytime[] =
+static const char usage_saytime[] =
" Usage: SAY TIME <time> <escape digits>\n"
" Say a given time, returning early if any of the given DTMF digits are\n"
" received on the channel. <time> is number of seconds elapsed since 00:00:00\n"
@@ -2451,7 +2453,7 @@ static char usage_saytime[] =
" completes without a digit being pressed, or the ASCII numerical value of the\n"
" digit if one was pressed or -1 on error/hangup.\n";
-static char usage_saydatetime[] =
+static const char usage_saydatetime[] =
" Usage: SAY DATETIME <time> <escape digits> [format] [timezone]\n"
" Say a given time, returning early if any of the given DTMF digits are\n"
" received on the channel. <time> is number of seconds elapsed since 00:00:00\n"
@@ -2462,61 +2464,61 @@ static char usage_saydatetime[] =
" completes without a digit being pressed, or the ASCII numerical value of the\n"
" digit if one was pressed or -1 on error/hangup.\n";
-static char usage_sayphonetic[] =
+static const char usage_sayphonetic[] =
" Usage: SAY PHONETIC <string> <escape digits>\n"
" Say a given character string with phonetics, returning early if any of the\n"
" given DTMF digits are received on the channel. Returns 0 if playback\n"
" completes without a digit pressed, the ASCII numerical value of the digit\n"
" if one was pressed, or -1 on error/hangup.\n";
-static char usage_setcontext[] =
+static const char usage_setcontext[] =
" Usage: SET CONTEXT <desired context>\n"
" Sets the context for continuation upon exiting the application.\n";
-static char usage_setextension[] =
+static const char usage_setextension[] =
" Usage: SET EXTENSION <new extension>\n"
" Changes the extension for continuation upon exiting the application.\n";
-static char usage_setpriority[] =
+static const char usage_setpriority[] =
" Usage: SET PRIORITY <priority>\n"
" Changes the priority for continuation upon exiting the application.\n"
" The priority must be a valid priority or label.\n";
-static char usage_autohangup[] =
+static const char usage_autohangup[] =
" Usage: SET AUTOHANGUP <time>\n"
" Cause the channel to automatically hangup at <time> seconds in the\n"
" future. Of course it can be hungup before then as well. Setting to 0 will\n"
" cause the autohangup feature to be disabled on this channel.\n";
-static char usage_speechcreate[] =
+static const char usage_speechcreate[] =
" Usage: SPEECH CREATE <engine>\n"
" Create a speech object to be used by the other Speech AGI commands.\n";
-static char usage_speechset[] =
+static const char usage_speechset[] =
" Usage: SPEECH SET <name> <value>\n"
" Set an engine-specific setting.\n";
-static char usage_speechdestroy[] =
+static const char usage_speechdestroy[] =
" Usage: SPEECH DESTROY\n"
" Destroy the speech object created by SPEECH CREATE.\n";
-static char usage_speechloadgrammar[] =
+static const char usage_speechloadgrammar[] =
" Usage: SPEECH LOAD GRAMMAR <grammar name> <path to grammar>\n"
" Loads the specified grammar as the specified name.\n";
-static char usage_speechunloadgrammar[] =
+static const char usage_speechunloadgrammar[] =
" Usage: SPEECH UNLOAD GRAMMAR <grammar name>\n"
" Unloads the specified grammar.\n";
-static char usage_speechactivategrammar[] =
+static const char usage_speechactivategrammar[] =
" Usage: SPEECH ACTIVATE GRAMMAR <grammar name>\n"
" Activates the specified grammar on the speech object.\n";
-static char usage_speechdeactivategrammar[] =
+static const char usage_speechdeactivategrammar[] =
" Usage: SPEECH DEACTIVATE GRAMMAR <grammar name>\n"
" Deactivates the specified grammar on the speech object.\n";
-static char usage_speechrecognize[] =
+static const char usage_speechrecognize[] =
" Usage: SPEECH RECOGNIZE <prompt> <timeout> [<offset>]\n"
" Plays back given prompt while listening for speech and dtmf.\n";
@@ -2574,7 +2576,7 @@ static struct agi_command commands[] = {
static AST_RWLIST_HEAD_STATIC(agi_commands, agi_command);
-static char *help_workhorse(int fd, char *match[])
+static char *help_workhorse(int fd, const char * const match[])
{
char fullcmd[MAX_CMD_LEN], matchstr[MAX_CMD_LEN];
struct agi_command *e;
@@ -2606,15 +2608,15 @@ int ast_agi_register(struct ast_module *mod, agi_command *cmd)
ast_join(fullcmd, sizeof(fullcmd), cmd->cmda);
- if (!find_command(cmd->cmda,1)) {
- cmd->docsrc = AST_STATIC_DOC;
+ if (!find_command(cmd->cmda, 1)) {
+ *((enum ast_doc_src *) &cmd->docsrc) = AST_STATIC_DOC;
#ifdef AST_XML_DOCS
if (ast_strlen_zero(cmd->summary) && ast_strlen_zero(cmd->usage)) {
- cmd->summary = ast_xmldoc_build_synopsis("agi", fullcmd);
- cmd->usage = ast_xmldoc_build_description("agi", fullcmd);
- cmd->syntax = ast_xmldoc_build_syntax("agi", fullcmd);
- cmd->seealso = ast_xmldoc_build_seealso("agi", fullcmd);
- cmd->docsrc = AST_XML_DOC;
+ *((char **) &cmd->summary) = ast_xmldoc_build_synopsis("agi", fullcmd);
+ *((char **) &cmd->usage) = ast_xmldoc_build_description("agi", fullcmd);
+ *((char **) &cmd->syntax) = ast_xmldoc_build_syntax("agi", fullcmd);
+ *((char **) &cmd->seealso) = ast_xmldoc_build_seealso("agi", fullcmd);
+ *((enum ast_doc_src *) &cmd->docsrc) = AST_XML_DOC;
}
#endif
cmd->mod = mod;
@@ -2647,12 +2649,14 @@ int ast_agi_unregister(struct ast_module *mod, agi_command *cmd)
ast_module_unref(ast_module_info->self);
#ifdef AST_XML_DOCS
if (e->docsrc == AST_XML_DOC) {
- ast_free(e->summary);
- ast_free(e->usage);
- ast_free(e->syntax);
- ast_free(e->seealso);
- e->summary = NULL, e->usage = NULL;
- e->syntax = NULL, e->seealso = NULL;
+ ast_free((char *) e->summary);
+ ast_free((char *) e->usage);
+ ast_free((char *) e->syntax);
+ ast_free((char *) e->seealso);
+ *((char **) &e->summary) = NULL;
+ *((char **) &e->usage) = NULL;
+ *((char **) &e->syntax) = NULL;
+ *((char **) &e->seealso) = NULL;
}
#endif
unregistered=1;
@@ -2714,7 +2718,7 @@ int ast_agi_unregister_multiple(struct ast_module *mod, struct agi_command *cmd,
return res;
}
-static agi_command *find_command(char *cmds[], int exact)
+static agi_command *find_command(const char * const cmds[], int exact)
{
int y, match;
struct agi_command *e;
@@ -2752,7 +2756,7 @@ static agi_command *find_command(char *cmds[], int exact)
return NULL;
}
-static int parse_args(char *s, int *max, char *argv[])
+static int parse_args(char *s, int *max, const char *argv[])
{
int x = 0, quoted = 0, escaped = 0, whitespace = 1;
char *cur;
@@ -2817,7 +2821,7 @@ normal:
static int agi_handle_command(struct ast_channel *chan, AGI *agi, char *buf, int dead)
{
- char *argv[MAX_ARGS];
+ const char *argv[MAX_ARGS];
int argc = MAX_ARGS, res;
agi_command *c;
const char *ami_res = "Unknown Result";
@@ -3164,7 +3168,7 @@ static void write_html_escaped(FILE *htmlfile, char *str)
return;
}
-static int write_htmldump(char *filename)
+static int write_htmldump(const char *filename)
{
struct agi_command *command;
char fullcmd[MAX_CMD_LEN];
@@ -3246,10 +3250,10 @@ static char *handle_cli_agi_dump_html(struct ast_cli_entry *e, int cmd, struct a
return CLI_SUCCESS;
}
-static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int dead)
+static int agi_exec_full(struct ast_channel *chan, const char *data, int enhanced, int dead)
{
enum agi_result res;
- char buf[AGI_BUF_LEN] = "", *tmp = buf;
+ char *buf;
int fds[2], efd = -1, pid;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(arg)[MAX_ARGS];
@@ -3262,9 +3266,9 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
}
if (dead)
ast_debug(3, "Hungup channel detected, running agi in dead mode.\n");
- ast_copy_string(buf, data, sizeof(buf));
memset(&agi, 0, sizeof(agi));
- AST_STANDARD_APP_ARGS(args, tmp);
+ buf = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, buf);
args.argv[args.argc] = NULL;
#if 0
/* Answer if need be */
@@ -3313,7 +3317,7 @@ static int agi_exec_full(struct ast_channel *chan, void *data, int enhanced, int
return 0;
}
-static int agi_exec(struct ast_channel *chan, void *data)
+static int agi_exec(struct ast_channel *chan, const char *data)
{
if (!ast_check_hangup(chan))
return agi_exec_full(chan, data, 0, 0);
@@ -3321,7 +3325,7 @@ static int agi_exec(struct ast_channel *chan, void *data)
return agi_exec_full(chan, data, 0, 1);
}
-static int eagi_exec(struct ast_channel *chan, void *data)
+static int eagi_exec(struct ast_channel *chan, const char *data)
{
int readformat, res;
@@ -3343,7 +3347,7 @@ static int eagi_exec(struct ast_channel *chan, void *data)
return res;
}
-static int deadagi_exec(struct ast_channel *chan, void *data)
+static int deadagi_exec(struct ast_channel *chan, const char *data)
{
ast_log(LOG_WARNING, "DeadAGI has been deprecated, please use AGI in all cases!\n");
return agi_exec(chan, data);