* '1' for selected entry from directory
* '*' for skipped entry from directory
*/
-static int play_mailbox_owner(struct ast_channel *chan, char *context,
- char *dialcontext, char *ext, char *name, int readext,
+static int play_mailbox_owner(struct ast_channel *chan, const char *context,
+ const char *dialcontext, const char *ext, const char *name, int readext,
int fromappvm)
{
int res = 0;
#define DEFAULT_CHARSET "ISO-8859-1"
/* Forward declarations */
-static char *message_template_parse_filebody(char *filename);
+static char *message_template_parse_filebody(const char *filename);
static char *message_template_parse_emailbody(const char *body);
static int create_vmaccount(char *name, struct ast_variable *var, int realtime);
static struct minivm_account *find_user_realtime(const char *domain, const char *username);
}
/*! \brief Add time zone to memory list */
-static int timezone_add(char *zonename, char *config)
+static int timezone_add(const char *zonename, const char *config)
{
struct minivm_zone *newzone;
}
/*! \brief Read message template from file */
-static char *message_template_parse_filebody(char *filename) {
+static char *message_template_parse_filebody(const char *filename) {
char buf[BUFSIZ * 6];
char readbuf[BUFSIZ];
char filenamebuf[BUFSIZ];
/*
* remap the 'say' functions to use those in this file
*/
-static int say_init_mode(char *mode) {
+static int say_init_mode(const char *mode) {
if (!strcmp(mode, say_new)) {
if (say_cfg == NULL) {
ast_log(LOG_ERROR, "There is no say.conf file to use new mode\n");
struct member *m;
struct ao2_iterator mem_iter;
char *interface = NULL;
- char *tmp, *tmp_name;
+ const char *tmp_name;
+ char *tmp;
char tmpbuf[64]; /* Must be longer than the longest queue param name. */
/* Static queues override realtime. */
if ((tmp = strchr(v->name, '_'))) {
ast_copy_string(tmpbuf, v->name, sizeof(tmpbuf));
tmp_name = tmpbuf;
- tmp = tmp_name;
+ tmp = tmpbuf;
while ((tmp = strchr(tmp, '_')))
*tmp++ = '-';
} else
const struct ast_channel *peer, const struct member *member, time_t callstart,
char *vars, size_t vars_len, enum agent_complete_reason rsn)
{
- const char *reason;
+ const char *reason = NULL; /* silence dumb compilers */
if (!qe->parent->eventwhencalled)
return;
{
char frompath2[PATH_MAX], topath2[PATH_MAX];
struct ast_variable *tmp,*var = NULL;
- char *origmailbox = NULL, *context = NULL, *macrocontext = NULL, *exten = NULL, *priority = NULL, *callerchan = NULL, *callerid = NULL, *origdate = NULL, *origtime = NULL, *category = NULL, *duration = NULL;
+ const char *origmailbox = NULL, *context = NULL, *macrocontext = NULL, *exten = NULL, *priority = NULL, *callerchan = NULL, *callerid = NULL, *origdate = NULL, *origtime = NULL, *category = NULL, *duration = NULL;
ast_filecopy(frompath, topath, NULL);
snprintf(frompath2, sizeof(frompath2), "%s.txt", frompath);
snprintf(topath2, sizeof(topath2), "%s.txt", topath);
return res;
}
-static struct ast_vm_user *find_or_create(char *context, char *mbox)
+static struct ast_vm_user *find_or_create(const char *context, const char *mbox)
{
struct ast_vm_user *vmu;
return vmu;
}
-static int append_mailbox(char *context, char *mbox, char *data)
+static int append_mailbox(const char *context, const char *mbox, const char *data)
{
/* Assumes lock is already held */
char *tmp;
* @return The just created agent.
* \sa agent_pvt, agents.
*/
-static struct agent_pvt *add_agent(char *agent, int pending)
+static struct agent_pvt *add_agent(const char *agent, int pending)
{
char *parse;
AST_DECLARE_APP_ARGS(args,
return 0;
}
-static int iax2_register(char *value, int lineno)
+static int iax2_register(const char *value, int lineno)
{
char copy[256];
char *username, *hostname, *secret;
return 0;
}
-static struct iax2_context *build_context(char *context)
+static struct iax2_context *build_context(const char *context)
{
struct iax2_context *con;
return con;
}
-static int get_auth_methods(char *value)
+static int get_auth_methods(const char *value)
{
int methods = 0;
if (strstr(value, "rsa"))
* Likely we will come up with a better way of doing config file parsing.
*/
#define M_START(var, val) \
- char *__s = var; char *__val = val;
+ const char *__s = var; const char *__val = val;
#define M_END(x) x;
#define M_F(tag, f) if (!strcasecmp((__s), tag)) { f; } else
#define M_BOOL(tag, dst) M_F(tag, (dst) = ast_true(__val) )
/*!
* \brief store the boost factor
*/
-static void store_boost(struct chan_oss_pvt *o, char *s)
+static void store_boost(struct chan_oss_pvt *o, const char *s)
{
double boost = 0;
if (sscanf(s, "%lf", &boost) != 1) {
* invalid or dangerous values (the string is used as argument for
* system("mixer %s")
*/
-static void store_mixer(struct chan_oss_pvt *o, char *s)
+static void store_mixer(struct chan_oss_pvt *o, const char *s)
{
int i;
/*!
* store the callerid components
*/
-static void store_callerid(struct chan_oss_pvt *o, char *s)
+static void store_callerid(struct chan_oss_pvt *o, const char *s)
{
ast_callerid_split(s, o->cid_name, sizeof(o->cid_name), o->cid_num, sizeof(o->cid_num));
}
static void clear_sip_domains(void);
/*--- SIP realm authentication */
-static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char *configuration, int lineno);
+static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, const char *configuration, int lineno);
static int clear_realm_authentication(struct sip_auth *authlist); /* Clear realm authentication list (at reload) */
static struct sip_auth *find_realm_authentication(struct sip_auth *authlist, const char *realm);
/*--- Internal UA client handling (outbound registrations) */
static void ast_sip_ouraddrfor(struct in_addr *them, struct sockaddr_in *us);
static void sip_registry_destroy(struct sip_registry *reg);
-static int sip_register(char *value, int lineno);
+static int sip_register(const char *value, int lineno);
static const char *regstate2str(enum sipregistrystate regstate) attribute_const;
static int sip_reregister(const void *data);
static int __sip_do_register(struct sip_registry *r);
}
/*! \brief Parse register=> line in sip.conf and add to registry */
-static int sip_register(char *value, int lineno)
+static int sip_register(const char *value, int lineno)
{
struct sip_registry *reg;
int portnum = 0;
initreqprep(&req, p, SIP_NOTIFY);
- for (var = varlist; var; var = var->next)
- add_header(&req, var->name, ast_unescape_semicolon(var->value));
+ for (var = varlist; var; var = var->next) {
+ char buf[512];
+ ast_copy_string(buf, var->value, sizeof(buf));
+ add_header(&req, var->name, ast_unescape_semicolon(buf));
+ }
/* Recalculate our side, and recalculate Call ID */
ast_sip_ouraddrfor(&p->sa.sin_addr, &p->ourip);
/*! \brief Add realm authentication in list */
-static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char *configuration, int lineno)
+static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, const char *configuration, int lineno)
{
char authcopy[256];
char *username=NULL, *realm=NULL, *secret=NULL, *md5secret=NULL;
if (!(sd = ast_calloc(1, sizeof(*sd)))) {
return NULL;
} else {
- char *stringp, *exten, *context, *label;
- stringp = v->value;
+ char buf[256];
+ char *stringp = buf, *exten, *context, *label;
+
+ ast_copy_string(buf, v->value, sizeof(buf));
exten = strsep(&stringp, ",");
if ((context = strchr(exten, '@'))) {
*context++ = '\0';
*
* \return zero if the property was set to the configuration, -1 if not.
*/
-int ast_jb_read_conf(struct ast_jb_conf *conf, char *varname, char *value);
+int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value);
/*!
void ast_free_ha(struct ast_ha *ha);
/*! \brief Append ACL entry to host access list. */
-struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path, int *error);
+struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error);
/*! \brief Check IP address with host access list */
int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin);
/*! \brief Structure for variables, used for configurations and for channel variables
*/
struct ast_variable {
- char *name;
- char *value;
+ const char *name;
+ const char *value;
+ struct ast_variable *next;
+
char *file;
+
int lineno;
int object; /*!< 0 for variable, 1 for object */
int blanklines; /*!< Number of blanklines following entry */
struct ast_comment *precomments;
struct ast_comment *sameline;
struct ast_comment *trailing; /*!< the last object in the list will get assigned any trailing comments when EOF is hit */
- struct ast_variable *next;
char stuff[0];
};
}
-int ast_jb_read_conf(struct ast_jb_conf *conf, char *varname, char *value)
+int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
{
int prefixlen = sizeof(AST_JB_CONF_PREFIX) - 1;
- char *name;
+ const char *name;
int tmp;
if (strncasecmp(AST_JB_CONF_PREFIX, varname, prefixlen))
return ret; /* Return start of list */
}
-struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path, int *error)
+struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
{
struct ast_ha *ha;
char *nm;
{
struct ast_variable *variable;
int name_len = strlen(name) + 1;
-
- if ((variable = ast_calloc(1, name_len + strlen(value) + 1 + strlen(filename) + 1 + sizeof(*variable)))) {
- variable->name = variable->stuff;
- variable->value = variable->stuff + name_len;
- variable->file = variable->stuff + name_len + strlen(value) + 1;
- strcpy(variable->name,name);
- strcpy(variable->value,value);
- strcpy(variable->file,filename);
+ int val_len = strlen(value) + 1;
+ int fn_len = strlen(filename) + 1;
+
+ if ((variable = ast_calloc(1, name_len + val_len + fn_len + sizeof(*variable)))) {
+ char *dst = variable->stuff; /* writable space starts here */
+ variable->name = strcpy(dst, name);
+ dst += name_len;
+ variable->value = strcpy(dst, value);
+ dst += fn_len;
+ variable->file = strcpy(dst, value);
}
return variable;
}
ast_mutex_unlock(&config_lock);
}
-static int append_mapping(char *name, char *driver, char *database, char *table)
+static int append_mapping(const char *name, const char *driver, const char *database, const char *table)
{
struct ast_config_map *map;
int length;
}
for (v = ast_variable_browse(config, "settings"); v; v = v->next) {
- stringp = v->value;
+ char buf[512];
+ ast_copy_string(buf, v->value, sizeof(buf));
+ stringp = buf;
driver = strsep(&stringp, ",");
if ((tmp = strchr(stringp, '\"')))
}
/*! \brief Add enum tree to linked list */
-static struct enum_search *enum_newtoplev(char *s)
+static struct enum_search *enum_newtoplev(const char *s)
{
struct enum_search *tmp;
AST_THREADSTORAGE(log_buf);
#define LOG_BUF_INIT_SIZE 256
-static int make_components(char *s, int lineno)
+static int make_components(const char *s, int lineno)
{
char *w;
int res = 0;
- char *stringp = s;
+ char *stringp = ast_strdupa(s);
while ((w = strsep(&stringp, ","))) {
w = ast_skip_blanks(w);
return res;
}
-static struct logchannel *make_logchannel(char *channel, char *components, int lineno)
+static struct logchannel *make_logchannel(const char *channel, const char *components, int lineno)
{
struct logchannel *chan;
char *facility;
static void xml_translate(struct ast_str **out, char *in, struct ast_variable *vars, enum output_format format)
{
struct ast_variable *v;
- char *dest = NULL;
+ const char *dest = NULL;
char *var, *val;
- char *objtype = NULL;
+ const char *objtype = NULL;
int in_data = 0; /* parsing data */
int inobj = 0;
int xml = (format == FORMAT_XML);
return os;
}
-int dundi_str_to_eid(dundi_eid *eid, char *s)
+int dundi_str_to_eid(dundi_eid *eid, const char *s)
{
unsigned int eid_int[6];
int x;
return 0;
}
-int dundi_str_short_to_eid(dundi_eid *eid, char *s)
+int dundi_str_short_to_eid(dundi_eid *eid, const char *s)
{
unsigned int eid_int[6];
int x;
extern int dundi_parse_ies(struct dundi_ies *ies, unsigned char *data, int datalen);
extern char *dundi_eid_to_str(char *s, int maxlen, dundi_eid *eid);
extern char *dundi_eid_to_str_short(char *s, int maxlen, dundi_eid *eid);
-extern int dundi_str_to_eid(dundi_eid *eid, char *s);
-extern int dundi_str_short_to_eid(dundi_eid *eid, char *s);
+extern int dundi_str_to_eid(dundi_eid *eid, const char *s);
+extern int dundi_str_short_to_eid(dundi_eid *eid, const char *s);
extern int dundi_eid_zero(dundi_eid *eid);
extern int dundi_eid_cmp(dundi_eid *eid1, dundi_eid *eid2);
extern char *dundi_flags2str(char *s, int maxlen, int flags);
AST_LIST_UNLOCK(&peers);
}
-static void append_permission(struct permissionlist *permlist, char *s, int allow)
+static void append_permission(struct permissionlist *permlist, const char *s, int allow)
{
struct permission *perm;
#define MAX_OPTS 128
-static void build_mapping(char *name, char *value)
+static void build_mapping(const char *name, const char *value)
{
char *t, *fields[MAX_OPTS];
struct dundi_mapping *map;
static char intro[ADSI_MAX_INTRO][20];
static int aligns[ADSI_MAX_INTRO];
-static char speeddial[ADSI_MAX_SPEED_DIAL][3][20];
+#define SPEEDDIAL_MAX_LEN 20
+static char speeddial[ADSI_MAX_SPEED_DIAL][3][SPEEDDIAL_MAX_LEN];
static int alignment = 0;
return 0;
}
-static int str2align(char *s)
+static int str2align(const char *s)
{
if (!strncasecmp(s, "l", 1))
return ADSI_JUST_LEFT;
x = 0;
for (v = ast_variable_browse(conf, "speeddial"); v; v = v->next) {
- char *stringp = v->value;
+ char buf[3 * SPEEDDIAL_MAX_LEN];
+ char *stringp = buf;
+ ast_copy_string(buf, v->value, sizeof(buf));
name = strsep(&stringp, ",");
sname = strsep(&stringp, ",");
if (!sname)