[asterisk-commits] branch kpfleming/chanfunc r9657 - in /team/kpfleming/chanfunc: ./ apps/ chann...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Feb 11 20:23:24 MST 2006


Author: kpfleming
Date: Sat Feb 11 21:23:22 2006
New Revision: 9657

URL: http://svn.digium.com/view/asterisk?rev=9657&view=rev
Log:
massive rework of dialplan functions
  useful return values from function implementations
  don't duplicate data multiple times


Modified:
    team/kpfleming/chanfunc/apps/app_curl.c
    team/kpfleming/chanfunc/apps/app_hasnewvoicemail.c
    team/kpfleming/chanfunc/apps/app_queue.c
    team/kpfleming/chanfunc/channels/chan_agent.c
    team/kpfleming/chanfunc/channels/chan_iax2.c
    team/kpfleming/chanfunc/channels/chan_sip.c
    team/kpfleming/chanfunc/funcs/func_base64.c
    team/kpfleming/chanfunc/funcs/func_callerid.c
    team/kpfleming/chanfunc/funcs/func_cdr.c
    team/kpfleming/chanfunc/funcs/func_channel.c
    team/kpfleming/chanfunc/funcs/func_cut.c
    team/kpfleming/chanfunc/funcs/func_db.c
    team/kpfleming/chanfunc/funcs/func_enum.c
    team/kpfleming/chanfunc/funcs/func_env.c
    team/kpfleming/chanfunc/funcs/func_groupcount.c
    team/kpfleming/chanfunc/funcs/func_language.c
    team/kpfleming/chanfunc/funcs/func_logic.c
    team/kpfleming/chanfunc/funcs/func_math.c
    team/kpfleming/chanfunc/funcs/func_md5.c
    team/kpfleming/chanfunc/funcs/func_moh.c
    team/kpfleming/chanfunc/funcs/func_odbc.c
    team/kpfleming/chanfunc/funcs/func_rand.c
    team/kpfleming/chanfunc/funcs/func_sha1.c
    team/kpfleming/chanfunc/funcs/func_strings.c
    team/kpfleming/chanfunc/funcs/func_timeout.c
    team/kpfleming/chanfunc/funcs/func_uri.c
    team/kpfleming/chanfunc/include/asterisk/channel.h
    team/kpfleming/chanfunc/include/asterisk/module.h
    team/kpfleming/chanfunc/include/asterisk/pbx.h
    team/kpfleming/chanfunc/manager.c
    team/kpfleming/chanfunc/pbx.c
    team/kpfleming/chanfunc/pbx/pbx_dundi.c
    team/kpfleming/chanfunc/res/res_agi.c

Modified: team/kpfleming/chanfunc/apps/app_curl.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/apps/app_curl.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/apps/app_curl.c (original)
+++ team/kpfleming/chanfunc/apps/app_curl.c Sat Feb 11 21:23:22 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C)  2004 - 2005, Tilghman Lesher
+ * Copyright (C)  2004 - 2006, Tilghman Lesher
  *
  * Tilghman Lesher <curl-20050919 at the-tilghman.com>
  * and Brian Wilkins <bwilkins at cfl.rr.com> (Added POST option)
@@ -109,10 +109,9 @@
 	return 0;
 }
 
-static char *acf_curl_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int acf_curl_exec(struct ast_channel *chan, char *cmd, char *info, char *buf, size_t len)
 {
 	struct localuser *u;
-	char *info;
 	struct MemoryStruct chunk = { NULL, 0 };
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(url);
@@ -121,21 +120,16 @@
 
 	*buf = '\0';
 	
-	if (ast_strlen_zero(data)) {
+	if (ast_strlen_zero(info)) {
 		ast_log(LOG_WARNING, "CURL requires an argument (URL)\n");
-		return buf;
+		return -1;
 	}
 
 	LOCAL_USER_ACF_ADD(u);
 
-	if (!(info = ast_strdupa(data))) {
-		LOCAL_USER_REMOVE(u);
-		return buf;
-	}
-
 	AST_STANDARD_APP_ARGS(args, info);	
 	
-	if (! curl_internal(&chunk, args.url, args.postdata)) {
+	if (!curl_internal(&chunk, args.url, args.postdata)) {
 		if (chunk.memory) {
 			chunk.memory[chunk.size] = '\0';
 			if (chunk.memory[chunk.size - 1] == 10)
@@ -149,7 +143,8 @@
 	}
 
 	LOCAL_USER_REMOVE(u);
-	return buf;
+
+	return 0;
 }
 
 struct ast_custom_function acf_curl = {

Modified: team/kpfleming/chanfunc/apps/app_hasnewvoicemail.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/apps/app_hasnewvoicemail.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/apps/app_hasnewvoicemail.c (original)
+++ team/kpfleming/chanfunc/apps/app_hasnewvoicemail.c Sat Feb 11 21:23:22 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Changes Copyright (c) 2004 - 2005 Todd Freeman <freeman at andrews.edu>
+ * Changes Copyright (c) 2004 - 2006 Todd Freeman <freeman at andrews.edu>
  * 
  * 95% based on HasNewVoicemail by:
  * 
@@ -178,10 +178,10 @@
 	return 0;
 }
 
-static char *acf_vmcount_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+int acf_vmcount_exec(struct ast_channel *chan, char *cmd, char *argsstr, char *buf, size_t len)
 {
 	struct localuser *u;
-	char *argsstr, *context;
+	char *context;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(vmbox);
 		AST_APP_ARG(folder);
@@ -190,11 +190,6 @@
 	LOCAL_USER_ACF_ADD(u);
 
 	buf[0] = '\0';
-
-	if (!(argsstr = ast_strdupa(data))) {
-		LOCAL_USER_REMOVE(u);
-		return buf;
-	}
 
 	AST_STANDARD_APP_ARGS(args, argsstr);
 
@@ -213,7 +208,7 @@
 
 	LOCAL_USER_REMOVE(u);
 	
-	return buf;
+	return 0;
 }
 
 struct ast_custom_function acf_vmcount = {

Modified: team/kpfleming/chanfunc/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/apps/app_queue.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/apps/app_queue.c (original)
+++ team/kpfleming/chanfunc/apps/app_queue.c Sat Feb 11 21:23:22 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
  *
  * Mark Spencer <markster at digium.com>
  *
@@ -3142,19 +3142,18 @@
 	return res;
 }
 
-static char *queue_function_qac(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int queue_function_qac(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
 {
 	int count = 0;
 	struct ast_call_queue *q;
 	struct localuser *u;
 	struct member *m;
 
-
-	ast_copy_string(buf, "0", len);
+	buf[0] = '\0';
 	
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd);
-		return buf;
+		return -1;
 	}
 
 	LOCAL_USER_ACF_ADD(u);
@@ -3183,10 +3182,10 @@
 
 	snprintf(buf, len, "%d", count);
 	LOCAL_USER_REMOVE(u);
-	return buf;
-}
-
-static char *queue_function_queuememberlist(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+	return 0;
+}
+
+static int queue_function_queuememberlist(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
 {
 	struct localuser *u;
 	struct ast_call_queue *q;
@@ -3197,7 +3196,7 @@
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_ERROR, "QUEUE_MEMBER_LIST requires an argument: queuename\n");
-		return buf;
+		return -1;
 	}
 	
 	LOCAL_USER_ACF_ADD(u);
@@ -3236,7 +3235,7 @@
 	/* We should already be terminated, but let's make sure. */
 	buf[len - 1] = '\0';
 	LOCAL_USER_REMOVE(u);
-	return buf;
+	return 0;
 }
 
 static struct ast_custom_function queueagentcount_function = {

Modified: team/kpfleming/chanfunc/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/channels/chan_agent.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/channels/chan_agent.c (original)
+++ team/kpfleming/chanfunc/channels/chan_agent.c Sat Feb 11 21:23:22 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
  *
  * Mark Spencer <markster at digium.com>
  *
@@ -2409,7 +2409,7 @@
 	return cur;	
 }
 
-static char *function_agent(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int function_agent(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
 {
 	char *parse;    
 	AST_DECLARE_APP_ARGS(args,
@@ -2423,11 +2423,11 @@
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "The AGENT function requires an argument - agentid!\n");
-		return buf;	
+		return -1;
 	}
 
 	if (!(parse = ast_strdupa(data)))
-		return buf;
+		return -1;
 
 	AST_NONSTANDARD_APP_ARGS(args, parse, ':');
 	if (!args.item)
@@ -2435,7 +2435,7 @@
 
 	if (!(agent = find_agent(args.agentid))) {
 		ast_log(LOG_WARNING, "Agent '%s' not found!\n", args.agentid);
-		return buf;
+		return -1;
 	}
 
 	if (!strcasecmp(args.item, "status")) {
@@ -2461,7 +2461,7 @@
 		ast_copy_string(buf, agent->loginchan, len);	
 	}
 
-	return buf;
+	return 0;
 }
 
 struct ast_custom_function agent_function = {

Modified: team/kpfleming/chanfunc/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/channels/chan_iax2.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/channels/chan_iax2.c (original)
+++ team/kpfleming/chanfunc/channels/chan_iax2.c Sat Feb 11 21:23:22 2006
@@ -9170,31 +9170,29 @@
 	return -1;
 }
 
-static char *function_iaxpeer(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
-{
-	char *ret = NULL;
+static int function_iaxpeer(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+{
 	struct iax2_peer *peer;
 	char *peername, *colname;
 	char iabuf[INET_ADDRSTRLEN];
 
 	if (!(peername = ast_strdupa(data)))
-		return ret;
+		return -1;
 
 	/* if our channel, return the IP address of the endpoint of current channel */
 	if (!strcmp(peername,"CURRENTCHANNEL")) {
 	        unsigned short callno = PTR_TO_CALLNO(chan->tech_pvt);
 		ast_copy_string(buf, iaxs[callno]->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), iaxs[callno]->addr.sin_addr) : "", len);
-		return buf;
-	}
-
-	if ((colname = strchr(peername, ':'))) {
-		*colname = '\0';
-		colname++;
-	} else {
+		return 0;
+	}
+
+	if ((colname = strchr(peername, ':')))
+		*colname++ = '\0';
+	else
 		colname = "ip";
-	}
+
 	if (!(peer = find_peer(peername, 1)))
-		return ret;
+		return -1;
 
 	if (!strcasecmp(colname, "ip")) {
 		ast_copy_string(buf, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "", len);
@@ -9229,16 +9227,15 @@
 			ast_copy_string(buf, ast_getformatname(codec), len);
 		}
 	}
-	ret = buf;
-
-	return ret;
+
+	return 0;
 }
 
 struct ast_custom_function iaxpeer_function = {
-    .name = "IAXPEER",
-    .synopsis = "Gets IAX peer information",
-    .syntax = "IAXPEER(<peername|CURRENTCHANNEL>[:item])",
-    .read = function_iaxpeer,
+	.name = "IAXPEER",
+	.synopsis = "Gets IAX peer information",
+	.syntax = "IAXPEER(<peername|CURRENTCHANNEL>[:item])",
+	.read = function_iaxpeer,
 	.desc = "If peername specified, valid items are:\n"
 	"- ip (default)          The IP address.\n"
 	"- status                The peer's status (if qualify=yes)\n"

Modified: team/kpfleming/chanfunc/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/channels/chan_sip.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/channels/chan_sip.c (original)
+++ team/kpfleming/chanfunc/channels/chan_sip.c Sat Feb 11 21:23:22 2006
@@ -9269,21 +9269,21 @@
 
 
 /*! \brief  func_header_read: Read SIP header (dialplan function) */
-static char *func_header_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
+int func_header_read(struct ast_channel *chan, char *function, char *data, char *buf, size_t len) 
 {
 	struct sip_pvt *p;
 	char *content;
 	
  	if (!data) {
 		ast_log(LOG_WARNING, "This function requires a header name.\n");
-		return NULL;
+		return -1;
 	}
 
 	ast_mutex_lock(&chan->lock);
 	if (chan->tech != &sip_tech) {
 		ast_log(LOG_WARNING, "This function can only be used on SIP channels.\n");
 		ast_mutex_unlock(&chan->lock);
-		return NULL;
+		return -1;
 	}
 
 	p = chan->tech_pvt;
@@ -9291,22 +9291,21 @@
 	/* If there is no private structure, this channel is no longer alive */
 	if (!p) {
 		ast_mutex_unlock(&chan->lock);
-		return NULL;
+		return -1;
 	}
 
 	content = get_header(&p->initreq, data);
 
 	if (ast_strlen_zero(content)) {
 		ast_mutex_unlock(&chan->lock);
-		return NULL;
+		return -1;
 	}
 
 	ast_copy_string(buf, content, len);
 	ast_mutex_unlock(&chan->lock);
 
-	return buf;
-}
-
+	return 0;
+}
 
 static struct ast_custom_function sip_header_function = {
 	.name = "SIP_HEADER",
@@ -9316,17 +9315,17 @@
 };
 
 /*! \brief  function_check_sipdomain: Dial plan function to check if domain is local */
-static char *func_check_sipdomain(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+int func_check_sipdomain(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
 {
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "CHECKSIPDOMAIN requires an argument - A domain name\n");
-		return buf;
+		return -1;
 	}
 	if (check_sip_domain(data, NULL, 0))
 		ast_copy_string(buf, data, len);
 	else
 		buf[0] = '\0';
-	return buf;
+	return 0;
 }
 
 static struct ast_custom_function checksipdomain_function = {
@@ -9340,26 +9339,20 @@
 		"Check the domain= configuration in sip.conf\n",
 };
 
-
 /*! \brief  function_sippeer: ${SIPPEER()} Dialplan function - reads peer data */
-static char *function_sippeer(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
-{
-	char *ret = NULL;
+int function_sippeer(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+{
 	struct sip_peer *peer;
 	char *peername, *colname;
 	char iabuf[INET_ADDRSTRLEN];
 
-	if (!(peername = ast_strdupa(data)))
-		return ret;
-
-	if ((colname = strchr(peername, ':'))) {
-		*colname = '\0';
-		colname++;
-	} else {
+	if ((colname = strchr(data, ':')))
+		*colname++ = '\0';
+	else
 		colname = "ip";
-	}
+
 	if (!(peer = find_peer(peername, NULL, 1)))
-		return ret;
+		return -1;
 
 	if (!strcasecmp(colname, "ip")) {
 		ast_copy_string(buf, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "", len);
@@ -9396,19 +9389,18 @@
 		codecnum = strchr(colname, '[');
 		*codecnum = '\0';
 		codecnum++;
-		if ((ptr = strchr(codecnum, ']'))) {
+		if ((ptr = strchr(codecnum, ']')))
 			*ptr = '\0';
-		}
+
 		index = atoi(codecnum);
 		if((codec = ast_codec_pref_index(&peer->prefs, index))) {
 			ast_copy_string(buf, ast_getformatname(codec), len);
 		}
 	}
-	ret = buf;
 
 	ASTOBJ_UNREF(peer, sip_destroy_peer);
 
-	return ret;
+	return 0;
 }
 
 /*! \brief Structure to declare a dialplan function: SIPPEER */
@@ -9438,7 +9430,7 @@
 };
 
 /*! \brief  function_sipchaninfo_read: ${SIPCHANINFO()} Dialplan function - reads sip channel data */
-static char *function_sipchaninfo_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
+int function_sipchaninfo_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
 {
 	struct sip_pvt *p;
 	char iabuf[INET_ADDRSTRLEN];
@@ -9447,14 +9439,14 @@
 	
  	if (!data) {
 		ast_log(LOG_WARNING, "This function requires a parameter name.\n");
-		return NULL;
+		return -1;
 	}
 
 	ast_mutex_lock(&chan->lock);
 	if (chan->tech != &sip_tech) {
 		ast_log(LOG_WARNING, "This function can only be used on SIP channels.\n");
 		ast_mutex_unlock(&chan->lock);
-		return NULL;
+		return -1;
 	}
 
 /* 	ast_verbose("function_sipchaninfo_read: %s\n", data); */
@@ -9463,7 +9455,7 @@
 	/* If there is no private structure, this channel is no longer alive */
 	if (!p) {
 		ast_mutex_unlock(&chan->lock);
-		return NULL;
+		return -1;
 	}
 
 	if (!strcasecmp(data, "peerip")) {
@@ -9480,11 +9472,11 @@
 		ast_copy_string(buf, p->peername, len);
 	} else {
 		ast_mutex_unlock(&chan->lock);
-		return NULL;
+		return -1;
 	}
 	ast_mutex_unlock(&chan->lock);
 
-	return buf;
+	return 0;
 }
 
 /*! \brief Structure to declare a dialplan function: SIPCHANINFO */
@@ -9501,8 +9493,6 @@
 	"- useragent             The useragent.\n"
 	"- peername              The name of the peer.\n"
 };
-
-
 
 /*! \brief  parse_moved_contact: Parse 302 Moved temporalily response */
 static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)

Modified: team/kpfleming/chanfunc/funcs/func_base64.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_base64.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_base64.c (original)
+++ team/kpfleming/chanfunc/funcs/func_base64.c Sat Feb 11 21:23:22 2006
@@ -36,31 +36,28 @@
 #include "asterisk/utils.h"
 #include "asterisk/app.h"
 
-static char *base64_encode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
+static int base64_encode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
 {
-	int res = 0;
-
 	if (ast_strlen_zero(data) ) {
 		ast_log(LOG_WARNING, "Syntax: BASE64_ENCODE(<data>) - missing argument!\n");
-		return NULL;
+		return -1;
 	}
 
-	ast_log(LOG_DEBUG, "data=%s\n",data);
-	res = ast_base64encode(buf, (unsigned char *)data, strlen(data), len);
-	ast_log(LOG_DEBUG, "res=%d\n", res);
-	return buf;
+	ast_base64encode(buf, (unsigned char *)data, strlen(data), len);
+
+	return 0;
 }
 
-static char *base64_decode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
+static int base64_decode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
 {
 	if (ast_strlen_zero(data) ) {
 		ast_log(LOG_WARNING, "Syntax: BASE64_DECODE(<base_64 string>) - missing argument!\n");
-		return NULL;
+		return -1;
 	}
 
-	ast_log(LOG_DEBUG, "data=%s\n", data);
-	ast_base64decode((unsigned char *)buf, data, len);
-	return buf;
+	ast_base64decode((unsigned char *) buf, data, len);
+
+	return 0;
 }
 
 static struct ast_custom_function base64_encode_function = {

Modified: team/kpfleming/chanfunc/funcs/func_callerid.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_callerid.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_callerid.c (original)
+++ team/kpfleming/chanfunc/funcs/func_callerid.c Sat Feb 11 21:23:22 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999-2006, Digium, Inc.
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -38,7 +38,7 @@
 #include "asterisk/options.h"
 #include "asterisk/callerid.h"
 
-static char *callerid_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
+static int callerid_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
 {
 	char *opt = data;
 
@@ -84,17 +84,19 @@
 			ast_log(LOG_ERROR, "Unknown callerid data type.\n");
 		}
 	}
-	return buf;
+
+	return 0;
 }
 
-static void callerid_write(struct ast_channel *chan, char *cmd, char *data, const char *value) 
+static int callerid_write(struct ast_channel *chan, char *cmd, char *data, const char *value) 
 {
 	if (!value)
-                return;
+                return -1;
 	
 	if (!strncasecmp("all", data, 3)) {
 		char name[256];
 		char num[256];
+
 		if (!ast_callerid_split(value, name, sizeof(name), num, sizeof(num)))
 			ast_set_callerid(chan, num, name, num);	
         } else if (!strncasecmp("name", data, 4)) {
@@ -116,6 +118,8 @@
         } else {
                 ast_log(LOG_ERROR, "Unknown callerid data type.\n");
         }
+
+        return 0;
 }
 
 static struct ast_custom_function callerid_function = {

Modified: team/kpfleming/chanfunc/funcs/func_cdr.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_cdr.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_cdr.c (original)
+++ team/kpfleming/chanfunc/funcs/func_cdr.c Sat Feb 11 21:23:22 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999-2006, Digium, Inc.
  *
  * Portions Copyright (C) 2005, Anthony Minessale II
  *
@@ -47,65 +47,55 @@
 	AST_APP_OPTION('r', OPT_RECURSIVE),
 });
 
-static char *cdr_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
+static int cdr_read(struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len) 
 {
-	char *ret;
-	char *parse;
+        char *ret;
 	struct ast_flags flags = {0};
-	
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(variable);
 		AST_APP_ARG(options);
 	);
 
-	if (ast_strlen_zero(data))
-		return NULL;
+	if (ast_strlen_zero(parse))
+		return -1;
 	
 	if (!chan->cdr)
-		return NULL;
-
-	if (!(parse = ast_strdupa(data)))
-		return NULL;
+		return -1;
 
 	AST_STANDARD_APP_ARGS(args, parse);
 	
-	if(!ast_strlen_zero(args.options) ) {
+	if (!ast_strlen_zero(args.options))
 		ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
-	}
-	ast_cdr_getvar(chan->cdr, args.variable, &ret, buf, len, (ast_test_flag(&flags,OPT_RECURSIVE) ) ? 1 : 0 );
 
-	return ret;
+	ast_cdr_getvar(chan->cdr, args.variable, &ret, buf, len, ast_test_flag(&flags, OPT_RECURSIVE));
+
+	return 0;
 }
 
-static void cdr_write(struct ast_channel *chan, char *cmd, char *data, const char *value) 
+static int cdr_write(struct ast_channel *chan, char *cmd, char *parse, const char *value) 
 {
-	char *parse;
 	struct ast_flags flags = {0};
-
 	AST_DECLARE_APP_ARGS(args, 
 		AST_APP_ARG(variable);
 		AST_APP_ARG(options);
 	);      
 
-	if (ast_strlen_zero(data) || !value)
-		return;
+	if (ast_strlen_zero(parse) || !value)
+		return -1;
 	
-	if (!(parse = ast_strdupa(data)))
-		return;
-
 	AST_STANDARD_APP_ARGS(args, parse);
 
-	/* check for a trailing flags argument */
-	if(!ast_strlen_zero(args.options) ) {
+	if (!ast_strlen_zero(args.options))
 		ast_app_parse_options(cdr_func_options, &flags, NULL, args.options);
-	}
 
 	if (!strcasecmp(args.variable, "accountcode"))
 		ast_cdr_setaccount(chan, value);
 	else if (!strcasecmp(args.variable, "userfield"))
 		ast_cdr_setuserfield(chan, value);
 	else if (chan->cdr)
-		ast_cdr_setvar(chan->cdr, args.variable, value, (ast_test_flag(&flags,OPT_RECURSIVE) ) ? 1 : 0 );
+		ast_cdr_setvar(chan->cdr, args.variable, value, ast_test_flag(&flags, OPT_RECURSIVE));
+
+        return 0;
 }
 
 static struct ast_custom_function cdr_function = {

Modified: team/kpfleming/chanfunc/funcs/func_channel.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_channel.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_channel.c (original)
+++ team/kpfleming/chanfunc/funcs/func_channel.c Sat Feb 11 21:23:22 2006
@@ -38,15 +38,17 @@
 #include "asterisk/app.h"
 #include "asterisk/indications.h"
 
-static char *func_channel(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
+static int func_channel_read(struct ast_channel *chan, char *function, char *data, char *buf, size_t len)
 {
+        int ret = 0;
+
         if (!strcasecmp(data, "audionativeformat"))
                 /* use the _multiple version when chan->nativeformats holds multiple formats */
-/*                ast_getformatname_multiple(buf, len, chan->nativeformats & AST_FORMAT_AUDIO_MASK); */
+		/* ast_getformatname_multiple(buf, len, chan->nativeformats & AST_FORMAT_AUDIO_MASK); */
                 ast_copy_string(buf, ast_getformatname(chan->nativeformats & AST_FORMAT_AUDIO_MASK), len);
         else if (!strcasecmp(data, "videonativeformat"))
                 /* use the _multiple version when chan->nativeformats holds multiple formats */
-/*                ast_getformatname_multiple(buf, len, chan->nativeformats & AST_FORMAT_VIDEO_MASK); */
+		/* ast_getformatname_multiple(buf, len, chan->nativeformats & AST_FORMAT_VIDEO_MASK); */
                 ast_copy_string(buf, ast_getformatname(chan->nativeformats & AST_FORMAT_VIDEO_MASK), len);
         else if (!strcasecmp(data, "audioreadformat"))
                 ast_copy_string(buf, ast_getformatname(chan->readformat), len);
@@ -54,28 +56,49 @@
                 ast_copy_string(buf, ast_getformatname(chan->writeformat), len);
         else if (!strcasecmp(data, "tonezone") && chan->zone)
                 ast_copy_string(buf, chan->zone->country, len);
+        else if (!strcasecmp(data, "language"))
+                ast_copy_string(buf, chan->language, len);
+        else if (!strcasecmp(data, "musicclass"))
+                ast_copy_string(buf, chan->musicclass, len);
+        else if (!chan->tech->func_channel_read)
+                ret = -1;
+        else if ((ret = chan->tech->func_channel_read(chan, function, data, buf, len))) {
+                ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n", data);
+                ret = -1;
+        }
 
-	return buf;
+        return ret;
+}
+
+static int func_channel_write(struct ast_channel *chan, char *cmd, char *data, const char *value)
+{
+	if (value)
+                ast_string_field_set(chan, language, value);
+
+        return 0;
 }
 
 static struct ast_custom_function channel_function = {
 	.name = "CHANNEL",
-	.synopsis = "Gets various pieces of information about the channel.",
+	.synopsis = "Gets/sets various pieces of information about the channel.",
 	.syntax = "CHANNEL(item)",
-	.desc = "Gets various pieces of information about the channel.\n"
+	.desc = "Gets/set various pieces of information about the channel.\n"
         "Standard items (provided by all channel technologies) are:\n"
-        "	audionativeformat -	format (codec) used natively for audio\n"
-        "	videonativeformat -	format (codec) used nativel for video\n"
-        "	audioreadformat -	format currently being read\n"
-        "	audiowriteformat -	format currently being written\n"
-        "	tonezone -		zone for indications played\n"
+        "R/O	audioreadformat		format currently being read\n"
+        "R/O	audionativeformat 	format used natively for audio\n"
+        "R/O	audiowriteformat 	format currently being written\n"
+        "R/W	language 		language for sounds played\n"
+        "R/W	musicclass 		class (from musiconhold.conf) for hold music\n"
+        "R/O	tonezone 		zone for indications played\n"
+        "R/O	videonativeformat 	format used natively for video\n"
         "\n"
         "Additional items may be available from the channel driver providing\n"
         "the channel; see its documentation for details.\n"
         "\n"
         "Any item requested that is not available on the current channel will\n"
         "return an empty string.\n",
-	.read = func_channel,
+	.read = func_channel_read,
+        .write = func_channel_write,
 };
 
 static char *tdesc = "Channel information dialplan function";

Modified: team/kpfleming/chanfunc/funcs/func_cut.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_cut.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_cut.c (original)
+++ team/kpfleming/chanfunc/funcs/func_cut.c Sat Feb 11 21:23:22 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (c) 2003 Tilghman Lesher.  All rights reserved.
+ * Copyright (c) 2003-2006 Tilghman Lesher.  All rights reserved.
  *
  * Tilghman Lesher <app_cut__v003 at the-tilghman.com>
  *
@@ -228,9 +228,10 @@
 	return 0;
 }
 
-static char *acf_sort_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int acf_sort_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
 {
 	struct localuser *u;
+	int ret = -1;
 
 	LOCAL_USER_ACF_ADD(u);
 
@@ -242,16 +243,19 @@
 		ast_log(LOG_ERROR, "Out of memory\n");
 		break;
 	case 0:
+		ret = 0;
 		break;
 	default:
 		ast_log(LOG_ERROR, "Unknown internal error\n");
 	}
 	LOCAL_USER_REMOVE(u);
-	return buf;
-}
-
-static char *acf_cut_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
-{
+
+	return ret;
+}
+
+static int acf_cut_exec(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+{
+	int ret = -1;
 	struct localuser *u;
 
 	LOCAL_USER_ACF_ADD(u);
@@ -267,12 +271,14 @@
 		ast_log(LOG_ERROR, "Usage: CUT(<varname>,<char-delim>,<range-spec>)\n");
 		break;
 	case 0:
+		ret = 0;
 		break;
 	default:
 		ast_log(LOG_ERROR, "Unknown internal error\n");
 	}
 	LOCAL_USER_REMOVE(u);
-	return buf;
+
+	return ret;
 }
 
 struct ast_custom_function acf_sort = {

Modified: team/kpfleming/chanfunc/funcs/func_db.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_db.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_db.c (original)
+++ team/kpfleming/chanfunc/funcs/func_db.c Sat Feb 11 21:23:22 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 2005, Russell Bryant <russelb at clemson.edu> 
+ * Copyright (C) 2005-2006, Russell Bryant <russelb at clemson.edu> 
  *
  * func_db.c adapted from the old app_db.c, copyright by the following people 
  * Copyright (C) 2005, Mark Spencer <markster at digium.com>
@@ -43,33 +43,25 @@
 #include "asterisk/app.h"
 #include "asterisk/astdb.h"
 
-static char *function_db_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int function_db_read(struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len)
 {
-	char *parse;    
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(family);
 		AST_APP_ARG(key);
 	);
 
-	if (ast_strlen_zero(data)) {
+	buf[0] = '\0';
+
+	if (ast_strlen_zero(parse)) {
 		ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)\n");
-		buf[0] = '\0';
-		return buf;
+		return -1;
 	}
 
-	parse = ast_strdupa(data);
-	if (!parse) {
-		ast_log(LOG_ERROR, "Out of memory!\n");
-		buf[0] = '\0';
-		return buf;
-	}
-	        
 	AST_NONSTANDARD_APP_ARGS(args, parse, '/');
 	
 	if (args.argc < 2) {
 		ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)\n");
-		buf[0] = '\0';
-		return buf;
+		return -1;
 	}
 
 	if (ast_db_get(args.family, args.key, buf, len-1)) {
@@ -77,39 +69,32 @@
 	} else
 		pbx_builtin_setvar_helper(chan, "DB_RESULT", buf);
 
-	
-	return buf;
+	return 0;
 }
 
-static void function_db_write(struct ast_channel *chan, char *cmd, char *data, const char *value) 
+static int function_db_write(struct ast_channel *chan, char *cmd, char *parse, const char *value) 
 {
-	char *parse;    
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(family);
 		AST_APP_ARG(key);
 	);
 
-	if (ast_strlen_zero(data)) {
+	if (ast_strlen_zero(parse)) {
 		ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)=<value>\n");
-		return;
-	}
-
-	parse = ast_strdupa(data);
-	if (!parse) { 
-		ast_log(LOG_ERROR, "Out of memory!\n"); 
-		return;
+		return -1;
 	}
 
 	AST_NONSTANDARD_APP_ARGS(args, parse, '/');
 
 	if (args.argc < 2) {
 		ast_log(LOG_WARNING, "DB requires an argument, DB(<family>/<key>)=value\n");
-		return;
+		return -1;
 	}
 
-	if (ast_db_put(args.family, args.key, (char*)value)) {
+	if (ast_db_put(args.family, args.key, (char*)value))
 		ast_log(LOG_WARNING, "DB: Error writing value to database.\n");
-	}
+
+	return 0;
 }
 
 static struct ast_custom_function db_function = {
@@ -126,43 +111,35 @@
 	.write = function_db_write,
 };
 
-static char *function_db_exists(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int function_db_exists(struct ast_channel *chan, char *cmd, char *parse, char *buf, size_t len)
 {
-	char *parse;    
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(family);
 		AST_APP_ARG(key);
 	);
 
-	if (ast_strlen_zero(data)) {
+	buf[0] = '\0';
+
+	if (ast_strlen_zero(parse)) {
 		ast_log(LOG_WARNING, "DB_EXISTS requires an argument, DB(<family>/<key>)\n");
-		buf[0] = '\0';
-		return buf;
+		return -1;
 	}
 
-	parse = ast_strdupa(data);
-	if (!parse) {
-		ast_log(LOG_ERROR, "Out of memory!\n");
-		buf[0] = '\0';
-		return buf;
-	}
-	        
 	AST_NONSTANDARD_APP_ARGS(args, parse, '/');
 	
 	if (args.argc < 2) {
 		ast_log(LOG_WARNING, "DB_EXISTS requires an argument, DB(<family>/<key>)\n");
-		buf[0] = '\0';
-		return buf;
+		return -1;
 	}
 
 	if (ast_db_get(args.family, args.key, buf, len-1))
-		ast_copy_string(buf, "0", len);	
+		strcpy(buf, "0");
 	else {
 		pbx_builtin_setvar_helper(chan, "DB_RESULT", buf);
-		ast_copy_string(buf, "1", len);
+		strcpy(buf, "1");
 	}
 	
-	return buf;
+	return 0;
 }
 
 static struct ast_custom_function db_exists_function = {

Modified: team/kpfleming/chanfunc/funcs/func_enum.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_enum.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_enum.c (original)
+++ team/kpfleming/chanfunc/funcs/func_enum.c Sat Feb 11 21:23:22 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005
+ * Copyright (C) 1999 - 2006
  *
  * Mark Spencer <markster at digium.com>
  * Oleksiy Krivoshey <oleksiyk at gmail.com>
@@ -40,116 +40,86 @@
 #include "asterisk/channel.h"
 #include "asterisk/pbx.h"
 #include "asterisk/utils.h"
-
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
 #include "asterisk/logger.h"
-
 #include "asterisk/pbx.h"
 #include "asterisk/options.h"
-
 #include "asterisk/enum.h"
-
-static char* synopsis = "Syntax: ENUMLOOKUP(number[,Method-type[,options|record#[,zone-suffix]]])\n";
+#include "asterisk/app.h"
+
+static char* synopsis = "Syntax: ENUMLOOKUP(number[|Method-type[|options[|record#[|zone-suffix]]]])\n";
 
 STANDARD_LOCAL_USER;
 
 LOCAL_USER_DECL;
 
-static char *function_enum(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
-{
-       int res=0;
-       char tech[80];
-       char dest[80] = "";
-       char *zone;
-       char *options;
-       struct localuser *u;
-       char *params[4];
-       char *p = data;
-       char *s;
-       int i = 0;
-
-
-       if (ast_strlen_zero(data)) {
-               ast_log(LOG_WARNING, synopsis);
-               return "";
-       }
-
-       do {
-               if(i>3){
-                       ast_log(LOG_WARNING, synopsis);
-                       return "";
-               }
-               params[i++] = p;
-               p = strchr(p, '|');
-               if(p){
-                       *p = '\0';
-                       p++;
-               }
-       } while(p);
-
-       if(i < 1){
-               ast_log(LOG_WARNING, synopsis);
-               return "";
-       }
-
-       if( (i > 1 && strlen(params[1]) == 0) || i < 2){
-               ast_copy_string(tech, "sip", sizeof(tech));
-       } else {
-               ast_copy_string(tech, params[1], sizeof(tech));
-       }
-
-       if( (i > 3 && strlen(params[3]) == 0) || i<4){
-               zone = "e164.arpa";
-       } else {
-               zone = params[3];
-       }
-
-       if( (i > 2 && strlen(params[2]) == 0) || i<3){
-               options = "1";
-       } else {
-               options = params[2];
-       }
-
-       /* strip any '-' signs from number */
-       p = params[0];
-       /*
-       while(*p == '+'){
-               p++;
-       }
-       */
-       s = p;
-       i = 0;
-       while(*p && *s){
-               if(*s == '-'){
-                       s++;
-               } else {
-                       p[i++] = *s++;
-               }
-       }
-       p[i] = 0;
-
-       LOCAL_USER_ACF_ADD(u);
-
-       res = ast_get_enum(chan, p, dest, sizeof(dest), tech, sizeof(tech), zone, options);
-
-       LOCAL_USER_REMOVE(u);
-
-       p = strchr(dest, ':');
-       if(p && strncasecmp(tech, "ALL", sizeof(tech))) {
-               ast_copy_string(buf, p+1, sizeof(dest));
-       } else {
-               ast_copy_string(buf, dest, sizeof(dest));
-       }
-
-       return buf;
+static int function_enum(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+{
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(number);
+		AST_APP_ARG(tech);
+		AST_APP_ARG(options);
+		AST_APP_ARG(record);
+		AST_APP_ARG(zone);
+	);
+	int res = 0;
+	char tech[80];
+	char dest[80] = "";
+	char *zone;
+	char *options;
+	struct localuser *u;
+	char *s, *p;
+
+	buf[0] = '\0';
+
+	if (ast_strlen_zero(data)) {
+		ast_log(LOG_WARNING, synopsis);
+		return -1;
+	}
+
+	AST_STANDARD_APP_ARGS(args, data);
+	
+	if (args.argc < 1) {
+		ast_log(LOG_WARNING, synopsis);
+		return -1;
+	}
+
+	ast_copy_string(tech, args.tech ? args.tech : "sip", sizeof(tech));
+
+	if (!args.zone)
+		args.zone = "e164.arpa";
+
+	if (!args.options)
+		args.options = "1";
+
+	/* strip any '-' signs from number */
+	for (p = args.number, s = p; *s; *s++) {
+		if (*s != '-')
+			*p++ = *s;
+	}
+	*p = '\0';
+
+	LOCAL_USER_ACF_ADD(u);
+
+	res = ast_get_enum(chan, p, dest, sizeof(dest), tech, sizeof(tech), zone, options);
+
+	LOCAL_USER_REMOVE(u);
+
+	p = strchr(dest, ':');
+	if (p && strcasecmp(tech, "ALL"))
+		ast_copy_string(buf, p+1, len);
+	else
+		ast_copy_string(buf, dest, len);
+
+	return 0;
 }
 
 static struct ast_custom_function enum_function = {
        .name = "ENUMLOOKUP",
        .synopsis = "ENUMLOOKUP allows for general or specific querying of NAPTR records"
        " or counts of NAPTR types for ENUM or ENUM-like DNS pointers",
-       .syntax = "ENUMLOOKUP(number[,Method-type[,options|record#[,zone-suffix]]])",
+       .syntax = "ENUMLOOKUP(number[|Method-type[|options[|record#[|zone-suffix]]]])",
        .desc = "Option 'c' returns an integer count of the number of NAPTRs of a certain RR type.\n"
        "Combination of 'c' and Method-type of 'ALL' will return a count of all NAPTRs for the record.\n"
        "Defaults are: Method-type=sip, no options, record=1, zone-suffix=e164.arpa\n\n"
@@ -157,7 +127,7 @@
        .read = function_enum,
 };
 
-static char *function_txtcidname(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int function_txtcidname(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
 {
 	int res;
 	char tech[80];
@@ -165,14 +135,14 @@
 	char dest[80];
 	struct localuser *u;
 
+	buf[0] = '\0';
+
 	LOCAL_USER_ACF_ADD(u);
-
-	buf[0] = '\0';
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "TXTCIDNAME requires an argument (number)\n");
 		LOCAL_USER_REMOVE(u);
-		return buf;	
+		return -1;
 	}
 
 	res = ast_get_txt(chan, data, dest, sizeof(dest), tech, sizeof(tech), txt, sizeof(txt));
@@ -182,7 +152,7 @@
 	
 	LOCAL_USER_REMOVE(u);
 
-	return buf;
+	return 0;
 }
 
 static struct ast_custom_function txtcidname_function = {

Modified: team/kpfleming/chanfunc/funcs/func_env.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/chanfunc/funcs/func_env.c?rev=9657&r1=9656&r2=9657&view=diff
==============================================================================
--- team/kpfleming/chanfunc/funcs/func_env.c (original)
+++ team/kpfleming/chanfunc/funcs/func_env.c Sat Feb 11 21:23:22 2006
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2006, Digium, Inc.
  *
  * See http://www.asterisk.org for more information about
  * the Asterisk project. Please do not directly contact
@@ -37,21 +37,22 @@
 #include "asterisk/utils.h"
 #include "asterisk/app.h"
 
-static char *env_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
+static int env_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
 {
-	char *ret = "";
+	char *ret = NULL;
 
-	if (data) {
+        *buf = '\0';
+
+        if (data)
 		ret = getenv(data);
-		if (!ret)
-			ret = "";
-	}
-	ast_copy_string(buf, ret, len);
 
-	return buf;
+        if (ret)

[... 1804 lines stripped ...]


More information about the asterisk-commits mailing list