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
1.4
Russell Bryant 20 years ago
parent efae38a82d
commit 5e6968ea86

51
pbx.c

@ -112,11 +112,11 @@ struct ast_context;
struct ast_exten { struct ast_exten {
char *exten; /*!< Extension name */ char *exten; /*!< Extension name */
int matchcid; /*!< Match caller id ? */ 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 */ int priority; /*!< Priority */
char *label; /*!< Label */ const char *label; /*!< Label */
struct ast_context *parent; /*!< The context this extension belongs to */ 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 *data; /*!< Data to use (arguments) */
void (*datad)(void *); /*!< Data destructor */ void (*datad)(void *); /*!< Data destructor */
struct ast_exten *peer; /*!< Next higher priority with our extension */ 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 */ /*! \brief ast_include: include= support in extensions.conf */
struct ast_include { struct ast_include {
char *name; const char *name;
char *rname; /*!< Context to include */ const char *rname; /*!< Context to include */
const char *registrar; /*!< Registrar */ const char *registrar; /*!< Registrar */
int hastime; /*!< If time construct exists */ int hastime; /*!< If time construct exists */
struct ast_timing timing; /*!< time construct */ struct ast_timing timing; /*!< time construct */
@ -151,7 +151,7 @@ struct ast_sw {
struct ast_ignorepat { struct ast_ignorepat {
const char *registrar; const char *registrar;
struct ast_ignorepat *next; struct ast_ignorepat *next;
char pattern[0]; const char pattern[0];
}; };
/*! \brief ast_context: An extension context */ /*! \brief ast_context: An extension context */
@ -3881,21 +3881,19 @@ int ast_context_add_include2(struct ast_context *con, const char *value,
return -1; 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; p = new_include->stuff;
new_include->name = p; new_include->name = p;
strcpy(new_include->name, value); strcpy(p, value);
p += strlen(value) + 1; p += strlen(value) + 1;
new_include->rname = p; new_include->rname = p;
strcpy(new_include->rname, value); strcpy(p, value);
c = new_include->rname; /* Strip off timing info, and process if it is there */
/* Strip off timing info */ if ( (c = strchr(p, '|')) ) {
while(*c && (*c != '|')) *c++ = '\0';
c++; new_include->hastime = ast_build_timing(&(new_include->timing), c);
/* Process if it's there */
if (*c) {
new_include->hastime = ast_build_timing(&(new_include->timing), c+1);
*c = '\0';
} }
new_include->next = NULL; new_include->next = NULL;
new_include->registrar = registrar; new_include->registrar = registrar;
@ -4137,7 +4135,10 @@ int ast_context_add_ignorepat2(struct ast_context *con, const char *value, const
errno = ENOMEM; errno = ENOMEM;
return -1; 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->next = NULL;
ignorepat->registrar = registrar; ignorepat->registrar = registrar;
ast_mutex_lock(&con->lock); ast_mutex_lock(&con->lock);
@ -4371,26 +4372,26 @@ int ast_add_extension2(struct ast_context *con,
datad = null_datad; datad = null_datad;
tmp = calloc(1, length); tmp = calloc(1, length);
if (tmp) { if (tmp) {
/* use p as dst in assignments, as the fields are const char * */
p = tmp->stuff; p = tmp->stuff;
if (label) { if (label) {
tmp->label = p; tmp->label = p;
strcpy(tmp->label, label); strcpy(p, label);
p += strlen(label) + 1; p += strlen(label) + 1;
} }
tmp->exten = p; 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->priority = priority;
tmp->cidmatch = p; tmp->cidmatch = p; /* but use p for assignments below */
if (callerid) { if (callerid) {
p += ext_strncpy(tmp->cidmatch, callerid, strlen(callerid) + 1) + 1; p += ext_strncpy(p, callerid, strlen(callerid) + 1) + 1;
tmp->matchcid = 1; tmp->matchcid = 1;
} else { } else {
tmp->cidmatch[0] = '\0'; *p++ = '\0';
tmp->matchcid = 0; tmp->matchcid = 0;
p++;
} }
tmp->app = p; tmp->app = p;
strcpy(tmp->app, application); strcpy(p, application);
tmp->parent = con; tmp->parent = con;
tmp->data = data; tmp->data = data;
tmp->datad = datad; tmp->datad = datad;

Loading…
Cancel
Save