Index: loader.c =================================================================== --- loader.c (revision 8193) +++ loader.c (working copy) @@ -164,7 +164,7 @@ return res; } -char *ast_module_helper(char *line, char *word, int pos, int state, int rpos, int needsreload) +char *ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, int needsreload) { struct module *m; int which=0; Index: pbx/pbx_config.c =================================================================== --- pbx/pbx_config.c (revision 8193) +++ pbx/pbx_config.c (working copy) @@ -143,7 +143,7 @@ return RESULT_FAILURE; } -static char *complete_context_dont_include(char *line, char *word, +static char *complete_context_dont_include(const char *line, const char *word, int pos, int state) { int which = 0; @@ -449,7 +449,7 @@ * It's ugly, I know, but I'm waiting for Mark suggestion if upper is * bug or feature ... */ -static int fix_complete_args(char *line, char **word, int *pos) +static int fix_complete_args(const char *line, char **word, int *pos) { char *_line, *_strsep_line, *_previous_word = NULL, *_word = NULL; int words = 0; @@ -481,13 +481,14 @@ } #endif /* BROKEN_READLINE */ -static char *complete_context_remove_extension(char *line, char *word, int pos, +static char *complete_context_remove_extension(const char *line, const char *word2, int pos, int state) { char *ret = NULL; int which = 0; #ifdef BROKEN_READLINE + char *word = (char *)word2; /* fool the compiler. XXX will go away later */ /* * Fix arguments, *word is a new allocated structure, REMEMBER to * free *word when you want to return from this function ... @@ -496,6 +497,8 @@ ast_log(LOG_ERROR, "Out of free memory\n"); return NULL; } +#else + const char *word = word2; #endif /* @@ -745,7 +748,7 @@ return RESULT_SUCCESS; } -static char *complete_context_add_include(char *line, char *word, int pos, +static char *complete_context_add_include(const char *line, const char *word, int pos, int state) { struct ast_context *c; @@ -1243,7 +1246,7 @@ } /*! add extension 6123,1,Dial,IAX/212.71.138.13/6123 into local */ -static char *complete_context_add_extension(char *line, char *word, +static char *complete_context_add_extension(const char *line, const char *word, int pos, int state) { int which = 0; @@ -1326,7 +1329,7 @@ return RESULT_SUCCESS; } -static char *complete_context_add_ignorepat(char *line, char *word, +static char *complete_context_add_ignorepat(const char *line, const char *word, int pos, int state) { if (pos == 3) return state == 0 ? strdup("into") : NULL; @@ -1427,7 +1430,7 @@ return RESULT_SUCCESS; } -static char *complete_context_remove_ignorepat(char *line, char *word, +static char *complete_context_remove_ignorepat(const char *line, const char *word, int pos, int state) { struct ast_context *c; Index: pbx/pbx_dundi.c =================================================================== --- pbx/pbx_dundi.c (revision 8193) +++ pbx/pbx_dundi.c (working copy) @@ -2226,7 +2226,7 @@ } } -static char *complete_peer_helper(char *line, char *word, int pos, int state, int rpos) +static char *complete_peer_helper(const char *line, const char *word, int pos, int state, int rpos) { int which=0; char *ret; @@ -2251,7 +2251,7 @@ return ret; } -static char *complete_peer_4(char *line, char *word, int pos, int state) +static char *complete_peer_4(const char *line, const char *word, int pos, int state) { return complete_peer_helper(line, word, pos, state, 3); } Index: manager.c =================================================================== --- manager.c (revision 8193) +++ manager.c (working copy) @@ -161,7 +161,7 @@ return res; } -static char *complete_show_mancmd(char *line, char *word, int pos, int state) +static char *complete_show_mancmd(const char *line, const char *word, int pos, int state) { struct manager_action *cur = first_action; int which = 0; Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 8193) +++ channels/chan_sip.c (working copy) @@ -8401,7 +8401,7 @@ } /*! \brief complete_sipch: Support routine for 'sip show channel' CLI ---*/ -static char *complete_sipch(char *line, char *word, int pos, int state) +static char *complete_sipch(const char *line, const char *word, int pos, int state) { int which=0; struct sip_pvt *cur; @@ -8422,7 +8422,7 @@ } /*! \brief complete_sip_peer: Do completion on peer name ---*/ -static char *complete_sip_peer(char *word, int state, int flags2) +static char *complete_sip_peer(const char *word, const int state, int flags2) { char *result = NULL; int wordlen = strlen(word); @@ -8442,7 +8442,7 @@ } /*! \brief complete_sip_show_peer: Support routine for 'sip show peer' CLI ---*/ -static char *complete_sip_show_peer(char *line, char *word, int pos, int state) +static char *complete_sip_show_peer(const char *line, const char *word, int pos, int state) { if (pos == 3) return complete_sip_peer(word, state, 0); @@ -8451,7 +8451,7 @@ } /*! \brief complete_sip_debug_peer: Support routine for 'sip debug peer' CLI ---*/ -static char *complete_sip_debug_peer(char *line, char *word, int pos, int state) +static char *complete_sip_debug_peer(const char *line, const char *word, int pos, int state) { if (pos == 3) return complete_sip_peer(word, state, 0); @@ -8460,7 +8460,7 @@ } /*! \brief complete_sip_user: Do completion on user name ---*/ -static char *complete_sip_user(char *word, int state, int flags2) +static char *complete_sip_user(const char *word, int state, int flags2) { char *result = NULL; int wordlen = strlen(word); @@ -8480,7 +8480,7 @@ } /*! \brief complete_sip_show_user: Support routine for 'sip show user' CLI ---*/ -static char *complete_sip_show_user(char *line, char *word, int pos, int state) +static char *complete_sip_show_user(const char *line, const char *word, int pos, int state) { if (pos == 3) return complete_sip_user(word, state, 0); @@ -8489,7 +8489,7 @@ } /*! \brief complete_sipnotify: Support routine for 'sip notify' CLI ---*/ -static char *complete_sipnotify(char *line, char *word, int pos, int state) +static char *complete_sipnotify(const char *line, const char *word, int pos, int state) { char *c = NULL; @@ -8521,7 +8521,7 @@ } /*! \brief complete_sip_prune_realtime_peer: Support routine for 'sip prune realtime peer' CLI ---*/ -static char *complete_sip_prune_realtime_peer(char *line, char *word, int pos, int state) +static char *complete_sip_prune_realtime_peer(const char *line, const char *word, int pos, int state) { if (pos == 4) return complete_sip_peer(word, state, SIP_PAGE2_RTCACHEFRIENDS); @@ -8529,7 +8529,7 @@ } /*! \brief complete_sip_prune_realtime_user: Support routine for 'sip prune realtime user' CLI ---*/ -static char *complete_sip_prune_realtime_user(char *line, char *word, int pos, int state) +static char *complete_sip_prune_realtime_user(const char *line, const char *word, int pos, int state) { if (pos == 4) return complete_sip_user(word, state, SIP_PAGE2_RTCACHEFRIENDS); Index: channels/chan_agent.c =================================================================== --- channels/chan_agent.c (revision 8193) +++ channels/chan_agent.c (working copy) @@ -1622,7 +1622,7 @@ return 0; } -static char *complete_agent_logoff_cmd(char *line, char *word, int pos, int state) +static char *complete_agent_logoff_cmd(const char *line, const char *word, int pos, int state) { struct agent_pvt *p; char name[AST_MAX_AGENT]; Index: channels/iax2-provision.c =================================================================== --- channels/iax2-provision.c (revision 8193) +++ channels/iax2-provision.c (working copy) @@ -154,7 +154,7 @@ return cur; } -char *iax_prov_complete_template(char *line, char *word, int pos, int state) +char *iax_prov_complete_template(const char *line, const char *word, int pos, int state) { struct iax_template *c; int which=0; Index: channels/chan_iax2.c =================================================================== --- channels/chan_iax2.c (revision 8193) +++ channels/chan_iax2.c (working copy) @@ -1970,7 +1970,7 @@ return RESULT_SUCCESS; } -static char *complete_iax2_show_peer(char *line, char *word, int pos, int state) +static char *complete_iax2_show_peer(const char *line, const char *word, int pos, int state) { int which = 0; struct iax2_peer *p; @@ -7631,7 +7631,7 @@ return 0; } -static char *iax2_prov_complete_template_3rd(char *line, char *word, int pos, int state) +static char *iax2_prov_complete_template_3rd(const char *line, const char *word, int pos, int state) { if (pos != 3) return NULL; Index: channels/chan_oss.c =================================================================== --- channels/chan_oss.c (revision 8193) +++ channels/chan_oss.c (working copy) @@ -975,7 +975,7 @@ return RESULT_SUCCESS; } -static char *autoanswer_complete(char *line, char *word, int pos, int state) +static char *autoanswer_complete(const char *line, const char *word, int pos, int state) { int l = strlen(word); Index: channels/iax2-provision.h =================================================================== --- channels/iax2-provision.h (revision 8193) +++ channels/iax2-provision.h (working copy) @@ -50,4 +50,4 @@ extern int iax_provision_unload(void); extern int iax_provision_build(struct iax_ie_data *provdata, unsigned int *signature, const char *template, int force); extern int iax_provision_version(unsigned int *signature, const char *template, int force); -extern char *iax_prov_complete_template(char *line, char *word, int pos, int state); +extern char *iax_prov_complete_template(const char *line, const char *word, int pos, int state); Index: apps/app_meetme.c =================================================================== --- apps/app_meetme.c (revision 8193) +++ apps/app_meetme.c (working copy) @@ -688,7 +688,7 @@ return 0; } -static char *complete_confcmd(char *line, char *word, int pos, int state) { +static char *complete_confcmd(const char *line, const char *word, int pos, int state) { #define CONF_COMMANDS 6 int which = 0, x = 0; struct ast_conference *cnf = NULL; Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 8193) +++ apps/app_voicemail.c (working copy) @@ -5803,7 +5803,7 @@ return RESULT_SUCCESS; } -static char *complete_show_voicemail_users(char *line, char *word, int pos, int state) +static char *complete_show_voicemail_users(const char *line, const char *word, int pos, int state) { int which = 0; int wordlen; Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 8193) +++ apps/app_queue.c (working copy) @@ -3503,7 +3503,7 @@ return __queues_show(0, fd, argc, argv, 1); } -static char *complete_queue(char *line, char *word, int pos, int state) +static char *complete_queue(const char *line, const char *word, int pos, int state) { struct ast_call_queue *q; char *ret = NULL; @@ -3777,7 +3777,7 @@ } } -static char *complete_add_queue_member(char *line, char *word, int pos, int state) +static char *complete_add_queue_member(const char *line, const char *word, int pos, int state) { /* 0 - add; 1 - queue; 2 - member; 3 - ; 4 - to; 5 - ; 6 - penalty; 7 - */ switch (pos) { @@ -3845,7 +3845,7 @@ } } -static char *complete_remove_queue_member(char *line, char *word, int pos, int state) +static char *complete_remove_queue_member(const char *line, const char *word, int pos, int state) { int which = 0; struct ast_call_queue *q; Index: include/asterisk/module.h =================================================================== --- include/asterisk/module.h (revision 8193) +++ include/asterisk/module.h (working copy) @@ -242,7 +242,7 @@ * \return A possible completion of the partial match, or NULL if no matches * were found. */ -char *ast_module_helper(char *line, char *word, int pos, int state, int rpos, int needsreload); +char *ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, int needsreload); /*! * \brief Register a function to be executed before Asterisk exits. Index: include/asterisk/cli.h =================================================================== --- include/asterisk/cli.h (revision 8193) +++ include/asterisk/cli.h (working copy) @@ -44,8 +44,7 @@ /*! \brief A command line entry */ struct ast_cli_entry { - /*! Null terminated list of the words of the command */ - char * cmda[AST_MAX_CMD_LEN]; + char * const cmda[AST_MAX_CMD_LEN]; /*! Handler for the command (fd for output, # of args, argument list). Returns RESULT_SHOWUSAGE for improper arguments. argv[] has argc 'useful' entries, and an additional NULL entry @@ -67,19 +66,19 @@ Typically, the function is called with increasing values for n until a NULL is returned. */ - char *(*generator)(char *line, char *word, int pos, int n); + char *(*generator)(const char *line, const char *word, int pos, int n); /*! For linking */ struct ast_cli_entry *next; /*! For keeping track of usage */ int inuse; }; /*! \brief Interprets a command * Interpret a command s, sending output to fd * Returns 0 on succes, -1 on failure */ -int ast_cli_command(int fd, char *s); +int ast_cli_command(int fd, const char *s); /*! \brief Registers a command or an array of commands * \param e which cli entry to register @@ -114,9 +132,9 @@ * Useful for readline, that's about it * Returns 0 on success, -1 on failure */ -char *ast_cli_generator(char *, char *, int); +char *ast_cli_generator(const char *, const char *, int); -int ast_cli_generatornummatches(char *, char *); +int ast_cli_generatornummatches(const char *, const char *); /*! * \brief Generates a NULL-terminated array of strings that @@ -129,7 +147,7 @@ * All strings and the array itself are malloc'ed and must be freed * by the caller. */ -char **ast_cli_completion_matches(char *, char *); +char **ast_cli_completion_matches(const char *, const char *); #if defined(__cplusplus) || defined(c_plusplus) Index: asterisk.c =================================================================== --- asterisk.c (revision 8193) +++ asterisk.c (working copy) @@ -324,7 +324,7 @@ #undef FORMAT } -static char *complete_show_version_files(char *line, char *word, int pos, int state) +static char *complete_show_version_files(const char *line, const char *word, int pos, int state) { struct file_version *find; int which = 0; Index: cli.c =================================================================== --- cli.c (revision 8193) +++ cli.c (working copy) @@ -508,7 +508,7 @@ return RESULT_SUCCESS; } -static char *__ast_cli_generator(char *text, char *word, int state, int lock); +static char *__ast_cli_generator(const char *text, const char *word, int state, int lock); static int handle_commandmatchesarray(int fd, int argc, char *argv[]) { @@ -762,7 +762,7 @@ return RESULT_SUCCESS; } -static char *complete_show_channels(char *line, char *word, int pos, int state) +static char *complete_show_channels(const char *line, const char *word, int pos, int state) { static char *choices[] = { "concise", "verbose" }; int match = 0; @@ -785,7 +785,7 @@ return NULL; } -static char *complete_ch_helper(char *line, char *word, int pos, int state, int rpos) +static char *complete_ch_helper(const char *line, const char *word, int pos, int state, int rpos) { struct ast_channel *c = NULL; int which = 0; @@ -811,27 +811,27 @@ return ret; } -static char *complete_ch_3(char *line, char *word, int pos, int state) +static char *complete_ch_3(const char *line, const char *word, int pos, int state) { return complete_ch_helper(line, word, pos, state, 2); } -static char *complete_ch_4(char *line, char *word, int pos, int state) +static char *complete_ch_4(const char *line, const char *word, int pos, int state) { return complete_ch_helper(line, word, pos, state, 3); } -static char *complete_mod_2(char *line, char *word, int pos, int state) +static char *complete_mod_2(const char *line, const char *word, int pos, int state) { return ast_module_helper(line, word, pos, state, 1, 1); } -static char *complete_mod_4(char *line, char *word, int pos, int state) +static char *complete_mod_4(const char *line, const char *word, int pos, int state) { return ast_module_helper(line, word, pos, state, 3, 0); } -static char *complete_fn(char *line, char *word, int pos, int state) +static char *complete_fn(const char *line, const char *word, int pos, int state) { char *c; char filename[256]; @@ -903,7 +903,7 @@ static int handle_help(int fd, int argc, char *argv[]); -static char * complete_help(char *text, char *word, int pos, int state) +static char * complete_help(const char *text, const char *word, int pos, int state) { /* skip first 4 or 5 chars, "help "*/ int l = strlen(text); @@ -941,7 +941,7 @@ { { NULL }, NULL, NULL, NULL } }; -static struct ast_cli_entry *find_cli(char *cmds[], int exact) +static struct ast_cli_entry *find_cli(char *const cmds[], int exact) { int x; int y; @@ -987,7 +987,7 @@ return NULL; } -static void join(char *dest, size_t destsize, char *w[], int tws) +static void join(char *dest, size_t destsize, char *const w[], int tws) { ast_join(dest, destsize, w); @@ -995,7 +995,7 @@ strncat(dest, " ", destsize - strlen(dest) - 1); } -static void join2(char *dest, size_t destsize, char *w[]) +static void join2(char *dest, size_t destsize, char *const w[]) { int x; /* Join words into a string */ @@ -1186,7 +1186,7 @@ return RESULT_SUCCESS; } -static char *parse_args(char *s, int *argc, char *argv[], int max, int *trailingwhitespace) +static char *parse_args(const char *s, int *argc, char *argv[], int max, int *trailingwhitespace) { char *dup, *cur; int x = 0; @@ -1247,7 +1247,7 @@ } /* This returns the number of unique matches for the generator */ -int ast_cli_generatornummatches(char *text, char *word) +int ast_cli_generatornummatches(const char *text, const char *word) { int matches = 0, i = 0; char *buf = NULL, *oldbuf = NULL; @@ -1264,7 +1264,7 @@ return matches; } -char **ast_cli_completion_matches(char *text, char *word) +char **ast_cli_completion_matches(const char *text, const char *word) { char **match_list = NULL, *retstr, *prevstr; size_t match_list_len, max_equal, which, i; @@ -1303,7 +1303,7 @@ return match_list; } -static char *__ast_cli_generator(char *text, char *word, int state, int lock) +static char *__ast_cli_generator(const char *text, const char *word, int state, int lock) { char *argv[AST_MAX_ARGS]; struct ast_cli_entry *e, *e1, *e2; @@ -1379,12 +1379,12 @@ return NULL; } -char *ast_cli_generator(char *text, char *word, int state) +char *ast_cli_generator(const char *text, const char *word, int state) { return __ast_cli_generator(text, word, state, 1); } -int ast_cli_command(int fd, char *s) +int ast_cli_command(int fd, const char *s) { char *argv[AST_MAX_ARGS]; struct ast_cli_entry *e; Index: pbx.c =================================================================== --- pbx.c (revision 8193) +++ pbx.c (working copy) @@ -1082,7 +1082,7 @@ return RESULT_SUCCESS; } -static char *complete_show_function(char *line, char *word, int pos, int state) +static char *complete_show_function(const char *line, const char *word, int pos, int state) { struct ast_custom_function *acf; char *ret = NULL; @@ -2834,7 +2834,7 @@ * application at one time. You can type 'show application Dial Echo' and * you will see informations about these two applications ... */ -static char *complete_show_application(char *line, char *word, int pos, int state) +static char *complete_show_application(const char *line, const char *word, int pos, int state) { struct ast_app *a; char *ret = NULL; @@ -3067,7 +3067,7 @@ return RESULT_SUCCESS; } -static char *complete_show_applications(char *line, char *word, int pos, int state) +static char *complete_show_applications(const char *line, const char *word, int pos, int state) { int wordlen = strlen(word); @@ -3101,7 +3101,7 @@ /* * 'show dialplan' CLI command implementation functions ... */ -static char *complete_show_dialplan_context(char *line, char *word, int pos, +static char *complete_show_dialplan_context(const char *line, const char *word, int pos, int state) { struct ast_context *c = NULL; Index: res/res_clioriginate.c =================================================================== --- res/res_clioriginate.c (revision 8193) +++ res/res_clioriginate.c (working copy) @@ -64,7 +64,7 @@ "used. If no extension is given, the 's' extension will be used.\n"; static int handle_orig(int fd, int argc, char *argv[]); -static char *complete_orig(char *line, char *word, int pos, int state); +static char *complete_orig(const char *line, const char *word, int pos, int state); struct ast_cli_entry cli_orig = { { "originate", NULL }, handle_orig, "Originate a call", orig_help, complete_orig }; @@ -144,7 +144,7 @@ return res; } -static char *complete_orig(char *line, char *word, int pos, int state) +static char *complete_orig(const char *line, const char *word, int pos, int state) { int wordlen; char *app = "application";