[asterisk-commits] trunk - r7304 in /trunk: ./ apps/ channels/ funcs/ include/asterisk/ res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Dec 3 13:25:37 CST 2005


Author: tilghman
Date: Sat Dec  3 13:25:33 2005
New Revision: 7304

URL: http://svn.digium.com/view/asterisk?rev=7304&view=rev
Log:
Bug 5858 - Make the chanvars.c functions return a 'const char *'
This should prevent us from unintentionally changing variable
values when they're returned from pbx_builtin_getvar_helper.

Modified:
    trunk/app.c
    trunk/apps/app_chanspy.c
    trunk/apps/app_groupcount.c
    trunk/apps/app_macro.c
    trunk/apps/app_meetme.c
    trunk/apps/app_queue.c
    trunk/apps/app_stack.c
    trunk/apps/app_while.c
    trunk/apps/app_zapscan.c
    trunk/channel.c
    trunk/channels/chan_agent.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_mgcp.c
    trunk/channels/chan_sip.c
    trunk/channels/chan_zap.c
    trunk/chanvars.c
    trunk/frame.c
    trunk/funcs/func_groupcount.c
    trunk/include/asterisk/app.h
    trunk/include/asterisk/channel.h
    trunk/include/asterisk/chanvars.h
    trunk/include/asterisk/frame.h
    trunk/include/asterisk/pbx.h
    trunk/manager.c
    trunk/pbx.c
    trunk/res/res_features.c
    trunk/res/res_monitor.c

Modified: trunk/app.c
URL: http://svn.digium.com/view/asterisk/trunk/app.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/app.c (original)
+++ trunk/app.c Sat Dec  3 13:25:33 2005
@@ -1006,7 +1006,7 @@
 
 /* Channel group core functions */
 
-int ast_app_group_split_group(char *data, char *group, int group_max, char *category, int category_max)
+int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max)
 {
 	int res=0;
 	char tmp[256];
@@ -1035,7 +1035,7 @@
 	return res;
 }
 
-int ast_app_group_set_channel(struct ast_channel *chan, char *data)
+int ast_app_group_set_channel(struct ast_channel *chan, const char *data)
 {
 	int res=0;
 	char group[80] = "";
@@ -1049,13 +1049,13 @@
 	return res;
 }
 
-int ast_app_group_get_count(char *group, char *category)
+int ast_app_group_get_count(const char *group, const char *category)
 {
 	struct ast_channel *chan;
 	int count = 0;
-	char *test;
+	const char *test;
 	char cat[80];
-	char *s;
+	const char *s;
 
 	if (ast_strlen_zero(group))
 		return 0;
@@ -1074,14 +1074,14 @@
 	return count;
 }
 
-int ast_app_group_match_get_count(char *groupmatch, char *category)
+int ast_app_group_match_get_count(const char *groupmatch, const char *category)
 {
 	regex_t regexbuf;
 	struct ast_channel *chan;
 	int count = 0;
-	char *test;
+	const char *test;
 	char cat[80];
-	char *s;
+	const char *s;
 
 	if (ast_strlen_zero(groupmatch))
 		return 0;

Modified: trunk/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_chanspy.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/apps/app_chanspy.c (original)
+++ trunk/apps/app_chanspy.c Sat Dec  3 13:25:33 2005
@@ -468,7 +468,7 @@
 		prev=NULL;
 		while(peer) {
 			if (peer != chan) {
-				char *group = NULL;
+				const char *group = NULL;
 				int igrp = 1;
 
 				if (peer == prev && !chosen) {

Modified: trunk/apps/app_groupcount.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_groupcount.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/apps/app_groupcount.c (original)
+++ trunk/apps/app_groupcount.c Sat Dec  3 13:25:33 2005
@@ -56,7 +56,6 @@
 	char group[80] = "";
 	char category[80] = "";
 	char ret[80] = "";
-	char *grp;
 	static int deprecation_warning = 0;
 
 	LOCAL_USER_ADD(u);
@@ -69,7 +68,7 @@
 	ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category));
 
 	if (ast_strlen_zero(group)) {
-		grp = pbx_builtin_getvar_helper(chan, category);
+		const char *grp = pbx_builtin_getvar_helper(chan, category);
 		strncpy(group, grp, sizeof(group) - 1);
 	}
 

Modified: trunk/apps/app_macro.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_macro.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/apps/app_macro.c (original)
+++ trunk/apps/app_macro.c Sat Dec  3 13:25:33 2005
@@ -89,6 +89,8 @@
 
 static int macro_exec(struct ast_channel *chan, void *data)
 {
+	const char *s;
+
 	char *tmp;
 	char *cur, *rest;
 	char *macro;
@@ -101,8 +103,7 @@
 	int oldpriority;
 	char pc[80], depthc[12];
 	char oldcontext[AST_MAX_CONTEXT] = "";
-	char *offsets;
-	int offset, depth;
+	int offset, depth = 0;
 	int setmacrocontext=0;
 	int autoloopflag;
   
@@ -120,13 +121,9 @@
 	LOCAL_USER_ADD(u);
 
 	/* Count how many levels deep the rabbit hole goes */
-	tmp = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH");
-	if (tmp) {
-		sscanf(tmp, "%d", &depth);
-	} else {
-		depth = 0;
-	}
-
+	s = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH");
+	if (s)
+		sscanf(s, "%d", &depth);
 	if (depth >= 7) {
 		ast_log(LOG_ERROR, "Macro():  possible infinite loop detected.  Returning early.\n");
 		LOCAL_USER_REMOVE(u);
@@ -193,12 +190,13 @@
 	chan->priority = 1;
 
 	while((cur = strsep(&rest, "|")) && (argc < MAX_ARGS)) {
+		const char *s;
   		/* Save copy of old arguments if we're overwriting some, otherwise
 	   	let them pass through to the other macro */
   		snprintf(varname, sizeof(varname), "ARG%d", argc);
-		oldargs[argc] = pbx_builtin_getvar_helper(chan, varname);
-		if (oldargs[argc])
-			oldargs[argc] = strdup(oldargs[argc]);
+		s = pbx_builtin_getvar_helper(chan, varname);
+		if (s)
+			oldargs[argc] = strdup(s);
 		pbx_builtin_setvar_helper(chan, varname, cur);
 		argc++;
 	}
@@ -286,6 +284,7 @@
 		ast_copy_string(chan->context, oldcontext, sizeof(chan->context));
 		if (!(chan->_softhangup & AST_SOFTHANGUP_ASYNCGOTO)) {
 			/* Copy the extension, so long as we're not in softhangup, where we could be given an asyncgoto */
+			const char *offsets;
 			ast_copy_string(chan->exten, oldexten, sizeof(chan->exten));
 			if ((offsets = pbx_builtin_getvar_helper(chan, "MACRO_OFFSET"))) {
 				/* Handle macro offset if it's set by checking the availability of step n + offset + 1, otherwise continue

Modified: trunk/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_meetme.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Sat Dec  3 13:25:33 2005
@@ -143,8 +143,8 @@
 	int locked;				/* Is the conference locked? */
 	pthread_t recordthread;			/* thread for recording */
 	pthread_attr_t attr;			/* thread attribute */
-	char *recordingfilename;		/* Filename to record the Conference into */
-	char *recordingformat;			/* Format to record the Conference in */
+	const char *recordingfilename;		/* Filename to record the Conference into */
+	const char *recordingformat;			/* Format to record the Conference in */
 	char pin[AST_MAX_EXTENSION];		/* If protected by a PIN */
 	char pinadmin[AST_MAX_EXTENSION];	/* If protected by a admin PIN */
 	struct ast_conference *next;
@@ -813,8 +813,8 @@
 	int duration=20;
 	struct ast_dsp *dsp=NULL;
 	struct ast_app *app;
-	char *agifile;
-	char *agifiledefault = "conf-background.agi";
+	const char *agifile;
+	const char *agifiledefault = "conf-background.agi";
 	char meetmesecs[30] = "";
 	char exitcontext[AST_MAX_CONTEXT] = "";
 	char recordingtmp[AST_MAX_EXTENSION] = "";
@@ -1086,7 +1086,8 @@
 		/* Find a pointer to the agi app and execute the script */
 		app = pbx_findapp("agi");
 		if (app) {
-			ret = pbx_exec(chan, app, agifile, 1);
+			char *s = ast_strdupa(agifile);
+			ret = pbx_exec(chan, app, s, 1);
 		} else {
 			ast_log(LOG_WARNING, "Could not find application (agi)\n");
 			ret = -2;

Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Sat Dec  3 13:25:33 2005
@@ -1992,7 +1992,6 @@
 	char oldcontext[AST_MAX_CONTEXT]="";
 	char queuename[256]="";
 	char *newnum;
-	char *monitorfilename;
 	struct ast_channel *peer;
 	struct ast_channel *which;
 	struct localuser *lpeer;
@@ -2209,7 +2208,7 @@
 		}
 		/* Begin Monitoring */
 		if (qe->parent->monfmt && *qe->parent->monfmt) {
-			monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME");
+			const char *monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME");
 			if (pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC") || pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC_ARGS"))
 				which = qe->chan;
 			else
@@ -2845,7 +2844,7 @@
 	char *options = NULL;
 	char *url = NULL;
 	char *announceoverride = NULL;
-	char *user_priority;
+	const char *user_priority;
 	int prio;
 	char *queuetimeoutstr = NULL;
 	enum queue_result reason = QUEUE_UNKNOWN;

Modified: trunk/apps/app_stack.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_stack.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/apps/app_stack.c (original)
+++ trunk/apps/app_stack.c Sat Dec  3 13:25:33 2005
@@ -82,7 +82,7 @@
 
 static int return_exec(struct ast_channel *chan, void *data)
 {
-	char *label = pbx_builtin_getvar_helper(chan, STACKVAR);
+	const char *label = pbx_builtin_getvar_helper(chan, STACKVAR);
 
 	if (ast_strlen_zero(label)) {
 		ast_log(LOG_ERROR, "Return without Gosub: stack is empty\n");

Modified: trunk/apps/app_while.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_while.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/apps/app_while.c (original)
+++ trunk/apps/app_while.c Sat Dec  3 13:25:33 2005
@@ -122,7 +122,7 @@
 #define VAR_SIZE 64
 
 
-static char *get_index(struct ast_channel *chan, const char *prefix, int index) {
+static const char *get_index(struct ast_channel *chan, const char *prefix, int index) {
 	char varname[VAR_SIZE];
 
 	snprintf(varname, VAR_SIZE, "%s_%d", prefix, index);
@@ -209,15 +209,15 @@
 {
 	int res=0;
 	struct localuser *u;
-	char *while_pri = NULL;
-	char *goto_str = NULL, *my_name = NULL;
-	char *condition = NULL, *label = NULL;
+	const char *while_pri = NULL;
+	char *my_name = NULL;
+	const char *condition = NULL, *label = NULL;
 	char varname[VAR_SIZE], end_varname[VAR_SIZE];
 	const char *prefix = "WHILE";
 	size_t size=0;
 	int used_index_i = -1, x=0;
 	char used_index[VAR_SIZE] = "0", new_index[VAR_SIZE] = "0";
-	
+
 	if (!chan) {
 		/* huh ? */
 		return -1;
@@ -271,6 +271,7 @@
 
 	if (!end && !ast_true(condition)) {
 		/* Condition Met (clean up helper vars) */
+		const char *goto_str;
 		pbx_builtin_setvar_helper(chan, varname, NULL);
 		pbx_builtin_setvar_helper(chan, my_name, NULL);
         snprintf(end_varname,VAR_SIZE,"END_%s",varname);
@@ -291,6 +292,7 @@
 	}
 
 	if (!end && !while_pri) {
+		char *goto_str;
 		size = strlen(chan->context) + strlen(chan->exten) + 32;
 		goto_str = alloca(size);
 		memset(goto_str, 0, size);
@@ -302,6 +304,7 @@
 		/* END of loop */
 		snprintf(end_varname, VAR_SIZE, "END_%s", varname);
 		if (! pbx_builtin_getvar_helper(chan, end_varname)) {
+			char *goto_str;
 			size = strlen(chan->context) + strlen(chan->exten) + 32;
 			goto_str = alloca(size);
 			memset(goto_str, 0, size);

Modified: trunk/apps/app_zapscan.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_zapscan.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/apps/app_zapscan.c (original)
+++ trunk/apps/app_zapscan.c Sat Dec  3 13:25:33 2005
@@ -296,7 +296,6 @@
 	char confstr[80] = "", *tmp = NULL;
 	struct ast_channel *tempchan = NULL, *lastchan = NULL,*ichan = NULL;
 	struct ast_frame *f;
-	char *mygroup;
 	char *desired_group;
 	int input=0,search_group=0;
 	
@@ -335,6 +334,7 @@
 			break;
 		
 		if (tempchan && search_group) {
+			const char *mygroup;
 			if((mygroup = pbx_builtin_getvar_helper(tempchan, "GROUP")) && (!strcmp(mygroup, desired_group))) {
 				ast_verbose(VERBOSE_PREFIX_3 "Found Matching Channel %s in group %s\n", tempchan->name, desired_group);
 			} else {

Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Sat Dec  3 13:25:33 2005
@@ -2770,7 +2770,7 @@
 void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
 {
 	struct ast_var_t *current, *newvar;
-	char *varname;
+	const char *varname;
 
 	AST_LIST_TRAVERSE(&parent->varshead, current, entries) {
 		int vartype = 0;
@@ -3159,7 +3159,7 @@
 	return bridged;
 }
 
-static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, char *sound, int remain) 
+static void bridge_playfile(struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain) 
 {
 	int res=0, min=0, sec=0,check=0;
 

Modified: trunk/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_agent.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Sat Dec  3 13:25:33 2005
@@ -1686,7 +1686,7 @@
 			     AST_APP_ARG(options);
 			     AST_APP_ARG(extension);
 		);
-	char *tmpoptions = NULL;
+	const char *tmpoptions = NULL;
 	char *context = NULL;
 	int play_announcement = 1;
 	char agent_goodbye[AST_MAX_FILENAME_LEN];
@@ -2231,7 +2231,7 @@
 	int nowarnings = 0;
 	int changeoutgoing = 0;
 	int res = 0;
-	char agent[AST_MAX_AGENT], *tmp;
+	char agent[AST_MAX_AGENT];
 
 	if (data) {
 		if (strchr(data, 'd'))
@@ -2242,6 +2242,7 @@
 			changeoutgoing = 1;
 	}
 	if (chan->cid.cid_num) {
+		const char *tmp;
 		char agentvar[AST_MAX_BUF];
 		snprintf(agentvar, sizeof(agentvar), "%s_%s", GETAGENTBYCALLERID, chan->cid.cid_num);
 		if ((tmp = pbx_builtin_getvar_helper(NULL, agentvar))) {

Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Sat Dec  3 13:25:33 2005
@@ -9137,7 +9137,6 @@
 	char odata[256];
 	char req[256];
 	char *ncontext;
-	char *dialstatus;
 	struct iax2_dpcache *dp;
 	struct ast_app *dial;
 #if 0
@@ -9145,7 +9144,7 @@
 #endif
 	if (priority == 2) {
 		/* Indicate status, can be overridden in dialplan */
-		dialstatus = pbx_builtin_getvar_helper(chan, "DIALSTATUS");
+		const char *dialstatus = pbx_builtin_getvar_helper(chan, "DIALSTATUS");
 		if (dialstatus) {
 			dial = pbx_findapp(dialstatus);
 			if (dial) 

Modified: trunk/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_mgcp.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/channels/chan_mgcp.c (original)
+++ trunk/channels/chan_mgcp.c Sat Dec  3 13:25:33 2005
@@ -889,7 +889,7 @@
 	struct mgcp_endpoint *p;
 	struct mgcp_subchannel *sub;
 	char tone[50] = "";
-	char *distinctive_ring = NULL;
+	const char *distinctive_ring = NULL;
 	struct varshead *headp;
 	struct ast_var_t *current;
 

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sat Dec  3 13:25:33 2005
@@ -462,11 +462,11 @@
 
 /*! \brief Parameters to the transmit_invite function */
 struct sip_invite_param {
-	char *distinctive_ring;	/*!< Distinctive ring header */
+	const char *distinctive_ring;	/*!< Distinctive ring header */
 	char *osptoken;		/*!< OSP token for this call */
 	int addsipheaders;	/*!< Add extra SIP headers */
-	char *uri_options;	/*!< URI options to add to the URI */
-	char *vxml_url;		/*!< VXML url for Cisco phones */
+	const char *uri_options;	/*!< URI options to add to the URI */
+	const char *vxml_url;		/*!< VXML url for Cisco phones */
 	char *auth;		/*!< Authentication */
 	char *authheader;	/*!< Auth header */
 	enum sip_auth_type auth_type;	/*!< Authentication type */
@@ -2478,7 +2478,7 @@
 static int sip_answer(struct ast_channel *ast)
 {
 	int res = 0,fmt;
-	char *codec;
+	const char *codec;
 	struct sip_pvt *p = ast->tech_pvt;
 
 	ast_mutex_lock(&p->lock);

Modified: trunk/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_zap.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/channels/chan_zap.c (original)
+++ trunk/channels/chan_zap.c Sat Dec  3 13:25:33 2005
@@ -1932,7 +1932,7 @@
 			break;
 		case SIG_FEATDMF_TA:
 		{
-			char *cic = NULL, *ozz = NULL;
+			const char *cic, *ozz;
 
 			/* If you have to go through a Tandem Access point you need to use this */
 			ozz = pbx_builtin_getvar_helper(p->owner, "FEATDMF_OZZ");

Modified: trunk/chanvars.c
URL: http://svn.digium.com/view/asterisk/trunk/chanvars.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/chanvars.c (original)
+++ trunk/chanvars.c Sat Dec  3 13:25:33 2005
@@ -59,31 +59,27 @@
 		free(var);
 }
 
-char *ast_var_name(struct ast_var_t *var)
+const char *ast_var_name(const struct ast_var_t *var)
 {
-	char *name;
+	const char *name;
 
-	if (var == NULL)
-		return NULL;
-	if (var->name == NULL)
+	if (var == NULL || (name = var->name) == NULL)
 		return NULL;
 	/* Return the name without the initial underscores */
-	if (var->name[0] == '_') {
-		if (var->name[1] == '_')
-			name = (char*)&(var->name[2]);
-		else
-			name = (char*)&(var->name[1]);
-	} else
-		name = var->name;
+	if (name[0] == '_') {
+		name++;
+		if (name[0] == '_')
+			name++;
+	}
 	return name;
 }
 
-char *ast_var_full_name(struct ast_var_t *var)
+const char *ast_var_full_name(const struct ast_var_t *var)
 {
 	return (var ? var->name : NULL);
 }
 
-char *ast_var_value(struct ast_var_t *var)
+const char *ast_var_value(const struct ast_var_t *var)
 {
 	return (var ? var->value : NULL);
 }

Modified: trunk/frame.c
URL: http://svn.digium.com/view/asterisk/trunk/frame.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/frame.c (original)
+++ trunk/frame.c Sat Dec  3 13:25:33 2005
@@ -539,7 +539,7 @@
 	{"g723.1","g723"},
 };
 
-static char *ast_expand_codec_alias(char *in) {
+static const char *ast_expand_codec_alias(const char *in) {
 	int x = 0;
 
 	for (x = 0; x < sizeof(ast_codec_alias_table) / sizeof(struct ast_codec_alias_table) ; x++) {
@@ -549,7 +549,7 @@
 	return in;
 }
 
-int ast_getformatbyname(char *name)
+int ast_getformatbyname(const char *name)
 {
 	int x = 0, all = 0, format = 0;
 

Modified: trunk/funcs/func_groupcount.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_groupcount.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/funcs/func_groupcount.c (original)
+++ trunk/funcs/func_groupcount.c Sat Dec  3 13:25:33 2005
@@ -40,7 +40,7 @@
 	int count;
 	char group[80] = "";
 	char category[80] = "";
-	char *grp;
+	const char *grp;
 
 	ast_app_group_split_group(data, group, sizeof(group), category, sizeof(category));
 
@@ -101,7 +101,7 @@
 static char *group_function_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
 {
 	char varname[256];
-	char *group;
+	const char *group;
 
 	if (!ast_strlen_zero(data)) {
 		snprintf(varname, sizeof(varname), "%s_%s", GROUP_CATEGORY_PREFIX, data);

Modified: trunk/include/asterisk/app.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/app.h?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/include/asterisk/app.h (original)
+++ trunk/include/asterisk/app.h Sat Dec  3 13:25:33 2005
@@ -167,16 +167,16 @@
 #define GROUP_CATEGORY_PREFIX "GROUP"
 
 /*! Split a group string into group and category, returning a default category if none is provided. */
-int ast_app_group_split_group(char *data, char *group, int group_max, char *category, int category_max);
+int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max);
 
 /*! Set the group for a channel, splitting the provided data into group and category, if specified. */
-int ast_app_group_set_channel(struct ast_channel *chan, char *data);
+int ast_app_group_set_channel(struct ast_channel *chan, const char *data);
 
 /*! Get the current channel count of the specified group and category. */
-int ast_app_group_get_count(char *group, char *category);
+int ast_app_group_get_count(const char *group, const char *category);
 
 /*! Get the current channel count of all groups that match the specified pattern and category. */
-int ast_app_group_match_get_count(char *groupmatch, char *category);
+int ast_app_group_match_get_count(const char *groupmatch, const char *category);
 
 /*!
   \brief Define an application argument

Modified: trunk/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/channel.h?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Sat Dec  3 13:25:33 2005
@@ -454,9 +454,9 @@
 	long timelimit;
 	long play_warning;
 	long warning_freq;
-	char *warning_sound;
-	char *end_sound;
-	char *start_sound;
+	const char *warning_sound;
+	const char *end_sound;
+	const char *start_sound;
 	int firstpass;
 	unsigned int flags;
 };

Modified: trunk/include/asterisk/chanvars.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/chanvars.h?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/include/asterisk/chanvars.h (original)
+++ trunk/include/asterisk/chanvars.h Sat Dec  3 13:25:33 2005
@@ -35,8 +35,8 @@
 
 struct ast_var_t *ast_var_assign(const char *name, const char *value);
 void ast_var_delete(struct ast_var_t *var);
-char *ast_var_name(struct ast_var_t *var);
-char *ast_var_full_name(struct ast_var_t *var);
-char *ast_var_value(struct ast_var_t *var);
+const char *ast_var_name(const struct ast_var_t *var);
+const char *ast_var_full_name(const struct ast_var_t *var);
+const char *ast_var_value(const struct ast_var_t *var);
 
 #endif /* _ASTERISK_CHANVARS_H */

Modified: trunk/include/asterisk/frame.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/frame.h?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/include/asterisk/frame.h (original)
+++ trunk/include/asterisk/frame.h Sat Dec  3 13:25:33 2005
@@ -389,7 +389,7 @@
  * \param name string of format
  * \return This returns the form of the format in binary on success, 0 on error.
  */
-extern int ast_getformatbyname(char *name);
+extern int ast_getformatbyname(const char *name);
 
 /*! \brief Get a name from a format 
  * Gets a name from a format

Modified: trunk/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/pbx.h?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/include/asterisk/pbx.h (original)
+++ trunk/include/asterisk/pbx.h Sat Dec  3 13:25:33 2005
@@ -605,7 +605,7 @@
 struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw);
 
 int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t size);
-extern char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name);
+extern const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name);
 extern void pbx_builtin_pushvar_helper(struct ast_channel *chan, const char *name, const char *value);
 extern void pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value);
 extern void pbx_retrieve_variable(struct ast_channel *c, const char *var, char **ret, char *workspace, int workspacelen, struct varshead *headp);
@@ -620,11 +620,11 @@
   set to 1, sets to auto fall through.  If newval set to 0, sets to no auto
   fall through (reads extension instead).  Returns previous value. */
 extern int pbx_set_autofallthrough(int newval);
-int ast_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority);
+int ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority);
 /* I can find neither parsable nor parseable at dictionary.com, but google gives me 169000 hits for parseable and only 49,800 for parsable */
 int ast_parseable_goto(struct ast_channel *chan, const char *goto_string);
 int ast_explicit_goto(struct ast_channel *chan, const char *context, const char *exten, int priority);
-int ast_async_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority);
+int ast_async_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority);
 
 struct ast_custom_function* ast_custom_function_find(char *name);
 int ast_custom_function_unregister(struct ast_custom_function *acf);

Modified: trunk/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/manager.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/manager.c (original)
+++ trunk/manager.c Sat Dec  3 13:25:33 2005
@@ -726,7 +726,7 @@
         char *name = astman_get_header(m, "Channel");
         char *varname = astman_get_header(m, "Variable");
 	char *id = astman_get_header(m,"ActionID");
-	char *varval;
+	const char *varval;
 	char *varval2=NULL;
 
 	if (!strlen(varname)) {

Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Sat Dec  3 13:25:33 2005
@@ -1129,9 +1129,9 @@
 				ast_log(LOG_WARNING,"Comparing variable '%s' with '%s'\n",var,ast_var_name(variables));
 #endif
 				if (strcasecmp(ast_var_name(variables),var)==0) {
-					*ret=ast_var_value(variables);
-					if (*ret) {
-						ast_copy_string(workspace, *ret, workspacelen);
+					const char *s = ast_var_value(variables);
+					if (s) {
+						ast_copy_string(workspace, s, workspacelen);
 						*ret = workspace;
 					}
 					break;
@@ -1145,9 +1145,9 @@
 				ast_log(LOG_WARNING,"Comparing variable '%s' with '%s'\n",var,ast_var_name(variables));
 #endif
 				if (strcasecmp(ast_var_name(variables),var)==0) {
-					*ret = ast_var_value(variables);
-					if (*ret) {
-						ast_copy_string(workspace, *ret, workspacelen);
+					const char *s = ast_var_value(variables);
+					if (s) {
+						ast_copy_string(workspace, s, workspacelen);
 						*ret = workspace;
 					}
 				}
@@ -2413,7 +2413,7 @@
 					ast_cdr_update(c);
 			    }
 			} else {
-				char *status;
+				const char *status;
 
 				status = pbx_builtin_getvar_helper(c, "DIALSTATUS");
 				if (!status)
@@ -5846,7 +5846,7 @@
 int pbx_builtin_serialize_variables(struct ast_channel *chan, char *buf, size_t size) 
 {
 	struct ast_var_t *variables;
-	char *var, *val;
+	const char *var, *val;
 	int total = 0;
 
 	if (!chan)
@@ -5870,7 +5870,7 @@
 	return total;
 }
 
-char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name) 
+const char *pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name) 
 {
 	struct ast_var_t *variables;
 	struct varshead *headp;
@@ -6383,7 +6383,7 @@
 }
 
 
-static int __ast_goto_if_exists(struct ast_channel *chan, char *context, char *exten, int priority, int async) 
+static int __ast_goto_if_exists(struct ast_channel *chan, const char *context, const char *exten, int priority, int async) 
 {
 	int (*goto_func)(struct ast_channel *chan, const char *context, const char *exten, int priority);
 
@@ -6400,11 +6400,11 @@
 		return -3;
 }
 
-int ast_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority) {
+int ast_goto_if_exists(struct ast_channel *chan, const char* context, const char *exten, int priority) {
 	return __ast_goto_if_exists(chan, context, exten, priority, 0);
 }
 
-int ast_async_goto_if_exists(struct ast_channel *chan, char* context, char *exten, int priority) {
+int ast_async_goto_if_exists(struct ast_channel *chan, const char * context, const char *exten, int priority) {
 	return __ast_goto_if_exists(chan, context, exten, priority, 1);
 }
 

Modified: trunk/res/res_features.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_features.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/res/res_features.c (original)
+++ trunk/res/res_features.c Sat Dec  3 13:25:33 2005
@@ -180,18 +180,14 @@
 static void check_goto_on_transfer(struct ast_channel *chan) 
 {
 	struct ast_channel *xferchan;
-	char *goto_on_transfer;
-
-	goto_on_transfer = pbx_builtin_getvar_helper(chan, "GOTO_ON_BLINDXFR");
-
-	if (!ast_strlen_zero(goto_on_transfer) && (xferchan = ast_channel_alloc(0))) {
-		char *x;
-		struct ast_frame *f;
-		
+	const char *val = pbx_builtin_getvar_helper(chan, "GOTO_ON_BLINDXFR");
+	char *x, *goto_on_transfer;
+	struct ast_frame *f;
+
+	if (!ast_strlen_zero(val) && (goto_on_transfer = ast_strdupa(val)) && (xferchan = ast_channel_alloc(0))) {
 		for (x = goto_on_transfer; x && *x; x++)
 			if (*x == '^')
 				*x = '|';
-
 		strcpy(xferchan->name, chan->name);
 		/* Make formats okay */
 		xferchan->readformat = chan->readformat;
@@ -446,7 +442,7 @@
 
 static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense)
 {
-	char *touch_monitor = NULL, *caller_chan_id = NULL, *callee_chan_id = NULL, *args = NULL, *touch_format = NULL;
+	char *caller_chan_id = NULL, *callee_chan_id = NULL, *args = NULL;
 	int x = 0;
 	size_t len;
 	struct ast_channel *caller_chan = NULL, *callee_chan = NULL;
@@ -494,11 +490,12 @@
 	}
 
 	if (caller_chan && callee_chan) {
-		touch_format = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_FORMAT");
+		const char *touch_format = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR_FORMAT");
+		const char *touch_monitor = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR");
+
 		if (!touch_format)
 			touch_format = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR_FORMAT");
 
-		touch_monitor = pbx_builtin_getvar_helper(caller_chan, "TOUCH_MONITOR");
 		if (!touch_monitor)
 			touch_monitor = pbx_builtin_getvar_helper(callee_chan, "TOUCH_MONITOR");
 		
@@ -541,7 +538,7 @@
 {
 	struct ast_channel *transferer;
 	struct ast_channel *transferee;
-	char *transferer_real_context;
+	const char *transferer_real_context;
 	char newext[256];
 	int res;
 
@@ -670,7 +667,7 @@
 	struct ast_channel *newchan, *xferchan=NULL;
 	int outstate=0;
 	struct ast_bridge_config bconfig;
-	char *transferer_real_context;
+	const char *transferer_real_context;
 	char xferto[256],dialstr[265];
 	char *cid_num;
 	char *cid_name;
@@ -981,7 +978,7 @@
 	struct ast_flags features;
 	int res = FEATURE_RETURN_PASSDIGITS;
 	struct ast_call_feature *feature;
-	char *dynamic_features=pbx_builtin_getvar_helper(chan,"DYNAMIC_FEATURES");
+	const char *dynamic_features=pbx_builtin_getvar_helper(chan,"DYNAMIC_FEATURES");
 
 	if (sense == FEATURE_SENSE_CHAN)
 		ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL);	
@@ -1047,9 +1044,7 @@
 	}
 	
 	if (chan && peer && !(ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_0) && ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_1))) {
-		char *dynamic_features;
-
-		dynamic_features = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES");
+		const char *dynamic_features = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES");
 
 		if (dynamic_features) {
 			char *tmp = ast_strdupa(dynamic_features);
@@ -1261,7 +1256,6 @@
 	struct ast_option_header *aoh;
 	struct timeval start = { 0 , 0 };
 	struct ast_bridge_config backup_config;
-	char *monitor_exec;
 
 	memset(&backup_config, 0, sizeof(backup_config));
 
@@ -1274,14 +1268,24 @@
 		pbx_builtin_setvar_helper(chan, "BLINDTRANSFER", NULL);
 
 	if (monitor_ok) {
+		const char *monitor_exec;
+		struct ast_channel *src = NULL;
 		if (!monitor_app) { 
 			if (!(monitor_app = pbx_findapp("Monitor")))
 				monitor_ok=0;
 		}
 		if ((monitor_exec = pbx_builtin_getvar_helper(chan, "AUTO_MONITOR"))) 
-			pbx_exec(chan, monitor_app, monitor_exec, 1);
+			src = chan;
 		else if ((monitor_exec = pbx_builtin_getvar_helper(peer, "AUTO_MONITOR")))
-			pbx_exec(peer, monitor_app, monitor_exec, 1);
+			src = peer;
+		if (src) {
+			char *tmp = ast_strdupa(monitor_exec);
+			if (tmp) {
+				pbx_exec(src, monitor_app, tmp, 1);
+			} else {
+				ast_log(LOG_ERROR, "Monitor failed: out of memory\n");
+			}
+		}
 	}
 	
 	set_config_flags(chan, peer, config);

Modified: trunk/res/res_monitor.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_monitor.c?rev=7304&r1=7303&r2=7304&view=diff
==============================================================================
--- trunk/res/res_monitor.c (original)
+++ trunk/res/res_monitor.c Sat Dec  3 13:25:33 2005
@@ -212,7 +212,6 @@
 /* Stop monitoring a channel */
 int ast_monitor_stop(struct ast_channel *chan, int need_lock)
 {
-	char *execute, *execute_args;
 	int delfiles = 0;
 
 	if (need_lock) {
@@ -261,6 +260,7 @@
 			char *name = chan->monitor->filename_base;
 			int directory = strchr(name, '/') ? 1 : 0;
 			char *dir = directory ? "" : ast_config_AST_MONITOR_DIR;
+			const char *execute, *execute_args;
 
 			/* Set the execute application */
 			execute = pbx_builtin_getvar_helper(chan, "MONITOR_EXEC");



More information about the asterisk-commits mailing list