dect
/
asterisk
Archived
13
0
Fork 0

constify arguments in more places where strings should not be modified (issue #6286)

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@8203 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
russell 2006-01-18 22:17:31 +00:00
parent 20dede9dcf
commit c6643537f1
19 changed files with 66 additions and 64 deletions

View File

@ -688,7 +688,7 @@ static int conf_cmd(int fd, int argc, char **argv) {
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;

View File

@ -3503,7 +3503,7 @@ static int queue_show(int fd, int argc, char **argv)
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 int handle_add_queue_member(int fd, int argc, char *argv[])
}
}
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 - <member>; 4 - to; 5 - <queue>; 6 - penalty; 7 - <penalty> */
switch (pos) {
@ -3845,7 +3845,7 @@ static int handle_remove_queue_member(int fd, int argc, char *argv[])
}
}
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;

View File

@ -5803,7 +5803,7 @@ static int handle_show_voicemail_zones(int fd, int argc, char *argv[])
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;

View File

@ -324,7 +324,7 @@ static int handle_show_version_files(int fd, int argc, char *argv[])
#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;

View File

@ -1622,7 +1622,7 @@ static int action_agent_logoff(struct mansession *s, struct message *m)
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];

View File

@ -1970,7 +1970,7 @@ static int iax2_show_peer(int fd, int argc, char *argv[])
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 @@ static int iax2_do_register(struct iax2_registry *reg)
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;

View File

@ -975,7 +975,7 @@ static int console_autoanswer(int fd, int argc, char *argv[])
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);

View File

@ -8401,7 +8401,7 @@ static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions
}
/*! \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 @@ static char *complete_sipch(char *line, char *word, int pos, int state)
}
/*! \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 @@ static char *complete_sip_peer(char *word, int state, int flags2)
}
/*! \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 @@ static char *complete_sip_show_peer(char *line, char *word, int pos, int state)
}
/*! \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 @@ static char *complete_sip_debug_peer(char *line, char *word, int pos, int state)
}
/*! \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 @@ static char *complete_sip_user(char *word, int state, int flags2)
}
/*! \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 @@ static char *complete_sip_show_user(char *line, char *word, int pos, int state)
}
/*! \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 @@ static char *complete_sipnotify(char *line, char *word, int pos, int state)
}
/*! \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 @@ static char *complete_sip_prune_realtime_peer(char *line, char *word, int pos, i
}
/*! \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);

View File

@ -154,7 +154,7 @@ static struct iax_template *iax_template_find(const char *s, int allowdead)
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;

View File

@ -50,4 +50,4 @@ extern int iax_provision_reload(void);
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);

36
cli.c
View File

@ -508,7 +508,7 @@ static int handle_softhangup(int fd, int argc, char *argv[])
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 @@ static int handle_showchan(int fd, int argc, char *argv[])
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 @@ static char *complete_show_channels(char *line, char *word, int pos, int state)
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 @@ static char *complete_ch_helper(char *line, char *word, int pos, int state, int
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 group_show_channels(int fd, int argc, char *argv[])
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 @@ static struct ast_cli_entry builtins[] = {
{ { 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 @@ static struct ast_cli_entry *find_cli(char *cmds[], int exact)
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 @@ static void join(char *dest, size_t destsize, char *w[], int tws)
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 @@ static int handle_help(int fd, int argc, char *argv[]) {
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 @@ static char *parse_args(char *s, int *argc, char *argv[], int max, int *trailing
}
/* 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 @@ int ast_cli_generatornummatches(char *text, char *word)
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 @@ char **ast_cli_completion_matches(char *text, char *word)
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 @@ static char *__ast_cli_generator(char *text, char *word, int state, int lock)
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;

View File

@ -44,8 +44,7 @@ void ast_cli(int fd, char *fmt, ...)
/*! \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,7 +66,7 @@ struct ast_cli_entry {
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 */
@ -79,7 +78,7 @@ struct ast_cli_entry {
* 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 +113,9 @@ void ast_cli_unregister_multiple(struct ast_cli_entry *e, int len);
* 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 +128,7 @@ int ast_cli_generatornummatches(char *, char *);
* 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)

View File

@ -242,7 +242,7 @@ int ast_module_reload(const char *name);
* \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.

View File

@ -164,7 +164,7 @@ int ast_unload_resource(const char *resource_name, int force)
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;

View File

@ -161,7 +161,7 @@ static char *authority_to_str(int authority, char *res, int reslen)
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;

8
pbx.c
View File

@ -1082,7 +1082,7 @@ static int handle_show_function(int fd, int argc, char *argv[])
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 @@ static char show_hints_help[] =
* 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 @@ static int handle_show_applications(int fd, int argc, char *argv[])
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 @@ static char *complete_show_applications(char *line, char *word, int pos, int sta
/*
* '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;

View File

@ -143,7 +143,7 @@ static int handle_context_dont_include(int fd, int argc, char *argv[])
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 @@ static int handle_context_remove_extension(int fd, int argc, char *argv[])
* 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 @@ static int fix_complete_args(char *line, char **word, int *pos)
}
#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 @@ static char *complete_context_remove_extension(char *line, char *word, int pos,
ast_log(LOG_ERROR, "Out of free memory\n");
return NULL;
}
#else
const char *word = word2;
#endif
/*
@ -745,7 +748,7 @@ static int handle_context_add_include(int fd, int argc, char *argv[])
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 @@ static int handle_context_add_extension(int fd, int argc, char *argv[])
}
/*! 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 @@ static int handle_context_add_ignorepat(int fd, int argc, char *argv[])
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 @@ static int handle_reload_extensions(int fd, int argc, char *argv[])
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;

View File

@ -2226,7 +2226,7 @@ static char *model2str(int model)
}
}
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 @@ static char *complete_peer_helper(char *line, char *word, int pos, int state, in
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);
}

View File

@ -64,7 +64,7 @@ static char orig_help[] =
"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 @@ static int handle_orig(int fd, int argc, char *argv[])
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";