mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-02 20:08:17 +00:00
const-ify some fields in the ast_exten and ast_include structures (issue #6270)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@8411 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
51
pbx.c
51
pbx.c
@@ -112,11 +112,11 @@ struct ast_context;
|
||||
struct ast_exten {
|
||||
char *exten; /*!< Extension name */
|
||||
int matchcid; /*!< Match caller id ? */
|
||||
char *cidmatch; /*!< Caller id to match for this extension */
|
||||
const char *cidmatch; /*!< Caller id to match for this extension */
|
||||
int priority; /*!< Priority */
|
||||
char *label; /*!< Label */
|
||||
const char *label; /*!< Label */
|
||||
struct ast_context *parent; /*!< The context this extension belongs to */
|
||||
char *app; /*!< Application to execute */
|
||||
const char *app; /*!< Application to execute */
|
||||
void *data; /*!< Data to use (arguments) */
|
||||
void (*datad)(void *); /*!< Data destructor */
|
||||
struct ast_exten *peer; /*!< Next higher priority with our extension */
|
||||
@@ -127,8 +127,8 @@ struct ast_exten {
|
||||
|
||||
/*! \brief ast_include: include= support in extensions.conf */
|
||||
struct ast_include {
|
||||
char *name;
|
||||
char *rname; /*!< Context to include */
|
||||
const char *name;
|
||||
const char *rname; /*!< Context to include */
|
||||
const char *registrar; /*!< Registrar */
|
||||
int hastime; /*!< If time construct exists */
|
||||
struct ast_timing timing; /*!< time construct */
|
||||
@@ -151,7 +151,7 @@ struct ast_sw {
|
||||
struct ast_ignorepat {
|
||||
const char *registrar;
|
||||
struct ast_ignorepat *next;
|
||||
char pattern[0];
|
||||
const char pattern[0];
|
||||
};
|
||||
|
||||
/*! \brief ast_context: An extension context */
|
||||
@@ -3881,21 +3881,19 @@ int ast_context_add_include2(struct ast_context *con, const char *value,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* ... fill in this structure ... */
|
||||
/* Fill in this structure. Use 'p' for assignments, as the fields
|
||||
* in the structure are 'const char *'
|
||||
*/
|
||||
p = new_include->stuff;
|
||||
new_include->name = p;
|
||||
strcpy(new_include->name, value);
|
||||
strcpy(p, value);
|
||||
p += strlen(value) + 1;
|
||||
new_include->rname = p;
|
||||
strcpy(new_include->rname, value);
|
||||
c = new_include->rname;
|
||||
/* Strip off timing info */
|
||||
while(*c && (*c != '|'))
|
||||
c++;
|
||||
/* Process if it's there */
|
||||
if (*c) {
|
||||
new_include->hastime = ast_build_timing(&(new_include->timing), c+1);
|
||||
*c = '\0';
|
||||
strcpy(p, value);
|
||||
/* Strip off timing info, and process if it is there */
|
||||
if ( (c = strchr(p, '|')) ) {
|
||||
*c++ = '\0';
|
||||
new_include->hastime = ast_build_timing(&(new_include->timing), c);
|
||||
}
|
||||
new_include->next = NULL;
|
||||
new_include->registrar = registrar;
|
||||
@@ -4137,7 +4135,10 @@ int ast_context_add_ignorepat2(struct ast_context *con, const char *value, const
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
strcpy(ignorepat->pattern, value);
|
||||
/* The cast to char * is because we need to write the initial value.
|
||||
* The field is not supposed to be modified otherwise
|
||||
*/
|
||||
strcpy((char *)ignorepat->pattern, value);
|
||||
ignorepat->next = NULL;
|
||||
ignorepat->registrar = registrar;
|
||||
ast_mutex_lock(&con->lock);
|
||||
@@ -4371,26 +4372,26 @@ int ast_add_extension2(struct ast_context *con,
|
||||
datad = null_datad;
|
||||
tmp = calloc(1, length);
|
||||
if (tmp) {
|
||||
/* use p as dst in assignments, as the fields are const char * */
|
||||
p = tmp->stuff;
|
||||
if (label) {
|
||||
tmp->label = p;
|
||||
strcpy(tmp->label, label);
|
||||
strcpy(p, label);
|
||||
p += strlen(label) + 1;
|
||||
}
|
||||
tmp->exten = p;
|
||||
p += ext_strncpy(tmp->exten, extension, strlen(extension) + 1) + 1;
|
||||
p += ext_strncpy(p, extension, strlen(extension) + 1) + 1;
|
||||
tmp->priority = priority;
|
||||
tmp->cidmatch = p;
|
||||
tmp->cidmatch = p; /* but use p for assignments below */
|
||||
if (callerid) {
|
||||
p += ext_strncpy(tmp->cidmatch, callerid, strlen(callerid) + 1) + 1;
|
||||
p += ext_strncpy(p, callerid, strlen(callerid) + 1) + 1;
|
||||
tmp->matchcid = 1;
|
||||
} else {
|
||||
tmp->cidmatch[0] = '\0';
|
||||
*p++ = '\0';
|
||||
tmp->matchcid = 0;
|
||||
p++;
|
||||
}
|
||||
tmp->app = p;
|
||||
strcpy(tmp->app, application);
|
||||
strcpy(p, application);
|
||||
tmp->parent = con;
|
||||
tmp->data = data;
|
||||
tmp->datad = datad;
|
||||
|
||||
Reference in New Issue
Block a user