[asterisk-commits] trunk r9674 - in /trunk: ./ apps/ channels/ doc/ formats/ funcs/ include/aste...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Feb 11 21:29:01 MST 2006


Author: kpfleming
Date: Sat Feb 11 22:28:58 2006
New Revision: 9674

URL: http://svn.digium.com/view/asterisk?rev=9674&view=rev
Log:
major dialplan functions update
deprecate LANGUAGE() and MUSICCLASS(), in favor of CHANNEL()

Added:
    trunk/funcs/func_channel.c
      - copied unchanged from r9673, team/kpfleming/chanfunc/funcs/func_channel.c
Modified:
    trunk/apps/app_curl.c
    trunk/apps/app_hasnewvoicemail.c
    trunk/apps/app_queue.c
    trunk/channels/chan_agent.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_sip.c
    trunk/doc/CODING-GUIDELINES
    trunk/formats/format_ogg_vorbis.c
    trunk/funcs/func_base64.c
    trunk/funcs/func_callerid.c
    trunk/funcs/func_cdr.c
    trunk/funcs/func_cut.c
    trunk/funcs/func_db.c
    trunk/funcs/func_enum.c
    trunk/funcs/func_env.c
    trunk/funcs/func_groupcount.c
    trunk/funcs/func_language.c
    trunk/funcs/func_logic.c
    trunk/funcs/func_math.c
    trunk/funcs/func_md5.c
    trunk/funcs/func_moh.c
    trunk/funcs/func_odbc.c
    trunk/funcs/func_rand.c
    trunk/funcs/func_sha1.c
    trunk/funcs/func_strings.c
    trunk/funcs/func_timeout.c
    trunk/funcs/func_uri.c
    trunk/include/asterisk/channel.h
    trunk/include/asterisk/module.h
    trunk/include/asterisk/pbx.h
    trunk/manager.c
    trunk/pbx.c
    trunk/pbx/pbx_dundi.c
    trunk/res/res_agi.c

Modified: trunk/apps/app_curl.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_curl.c?rev=9674&r1=9673&r2=9674&view=diff
==============================================================================
--- trunk/apps/app_curl.c (original)
+++ trunk/apps/app_curl.c Sat Feb 11 22:28:58 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: trunk/apps/app_hasnewvoicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_hasnewvoicemail.c?rev=9674&r1=9673&r2=9674&view=diff
==============================================================================
--- trunk/apps/app_hasnewvoicemail.c (original)
+++ trunk/apps/app_hasnewvoicemail.c Sat Feb 11 22:28:58 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: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=9674&r1=9673&r2=9674&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Sat Feb 11 22:28:58 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: trunk/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_agent.c?rev=9674&r1=9673&r2=9674&view=diff
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Sat Feb 11 22:28:58 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: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?rev=9674&r1=9673&r2=9674&view=diff
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Sat Feb 11 22:28:58 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: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=9674&r1=9673&r2=9674&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sat Feb 11 22:28:58 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: trunk/doc/CODING-GUIDELINES
URL: http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES?rev=9674&r1=9673&r2=9674&view=diff
==============================================================================
--- trunk/doc/CODING-GUIDELINES (original)
+++ trunk/doc/CODING-GUIDELINES Sat Feb 11 22:28:58 2006
@@ -77,7 +77,7 @@
 Roughly, Asterisk code formatting guidelines are generally equivalent to the 
 following:
 
-# indent -i4 -ts4 -br -brs -cdw -cli0 -ce -nbfda -npcs -nprs -npsl -saf -sai -saw foo.c
+# indent -i4 -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -ln90 foo.c
 
 this means in verbose:
  -i4:    indent level 4
@@ -85,7 +85,7 @@
  -br:    braces on if line
  -brs:   braces on struct decl line
  -cdw:   cuddle do while
- -cli0:  case indentation 0
+ -lp:    line up continuation below parenthesis
  -ce:    cuddle else
  -nbfda: dont break function decl args
  -npcs:  no space after function call names
@@ -94,6 +94,8 @@
  -saf:   space after for
  -sai:   space after if
  -saw:   space after while
+ -cs:    space after cast
+ -ln90:  line length 90 columns
 
 Function calls and arguments should be spaced in a consistent way across
 the codebase.

Modified: trunk/formats/format_ogg_vorbis.c
URL: http://svn.digium.com/view/asterisk/trunk/formats/format_ogg_vorbis.c?rev=9674&r1=9673&r2=9674&view=diff
==============================================================================
--- trunk/formats/format_ogg_vorbis.c (original)
+++ trunk/formats/format_ogg_vorbis.c Sat Feb 11 22:28:58 2006
@@ -20,7 +20,7 @@
  * \arg File name extension: ogg
  * \ingroup formats
  */
- 
+
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -48,37 +48,35 @@
 #include "asterisk/file.h"
 #include "asterisk/logger.h"
 #include "asterisk/module.h"
-
 #define SAMPLES_MAX 160
 #define BLOCK_SIZE 4096
 
-
 struct ast_filestream {
 	void *reserved[AST_RESERVED_POINTERS];
-
+	
 	FILE *f;
-
+	
 	/* structures for handling the Ogg container */
-	ogg_sync_state	 oy;
+	ogg_sync_state oy;
 	ogg_stream_state os;
-	ogg_page	 og;
-	ogg_packet	 op;
+	ogg_page og;
+	ogg_packet op;
 	
 	/* structures for handling Vorbis audio data */
-	vorbis_info	 vi;
-	vorbis_comment	 vc;
+	vorbis_info vi;
+	vorbis_comment vc;
 	vorbis_dsp_state vd;
-	vorbis_block	 vb;
+	vorbis_block vb;
 	
 	/*! \brief Indicates whether this filestream is set up for reading or writing. */
 	int writing;
-
+	
 	/*! \brief Indicates whether an End of Stream condition has been detected. */
 	int eos;
-
+	
 	/*! \brief Buffer to hold audio data. */
 	short buffer[SAMPLES_MAX];
-
+	
 	/*! \brief Asterisk frame object. */
 	struct ast_frame fr;
 	char waste[AST_FRIENDLY_OFFSET];
@@ -86,6 +84,7 @@
 };
 
 AST_MUTEX_DEFINE_STATIC(ogg_vorbis_lock);
+
 static int glistcnt = 0;
 
 static char *name = "ogg_vorbis";
@@ -97,7 +96,7 @@
  * \param f File that points to on disk storage of the OGG/Vorbis data.
  * \return The new filestream.
  */
-static struct ast_filestream *ogg_vorbis_open(FILE *f)
+static struct ast_filestream *ogg_vorbis_open(FILE * f)
 {
 	int i;
 	int bytes;
@@ -107,7 +106,7 @@
 
 	struct ast_filestream *tmp;
 
-	if((tmp = malloc(sizeof(struct ast_filestream)))) {
+	if ((tmp = malloc(sizeof(struct ast_filestream)))) {
 		memset(tmp, 0, sizeof(struct ast_filestream));
 
 		tmp->writing = 0;
@@ -120,24 +119,26 @@
 		ogg_sync_wrote(&tmp->oy, bytes);
 
 		result = ogg_sync_pageout(&tmp->oy, &tmp->og);
-		if(result != 1) {
-			if(bytes < BLOCK_SIZE) {
+		if (result != 1) {
+			if (bytes < BLOCK_SIZE) {
 				ast_log(LOG_ERROR, "Run out of data...\n");
 			} else {
-				ast_log(LOG_ERROR, "Input does not appear to be an Ogg bitstream.\n");
+				ast_log(LOG_ERROR,
+						"Input does not appear to be an Ogg bitstream.\n");
 			}
 			fclose(f);
 			ogg_sync_clear(&tmp->oy);
 			free(tmp);
 			return NULL;
 		}
-		
+
 		ogg_stream_init(&tmp->os, ogg_page_serialno(&tmp->og));
 		vorbis_info_init(&tmp->vi);
 		vorbis_comment_init(&tmp->vc);
 
-		if(ogg_stream_pagein(&tmp->os, &tmp->og) < 0) { 
-			ast_log(LOG_ERROR, "Error reading first page of Ogg bitstream data.\n");
+		if (ogg_stream_pagein(&tmp->os, &tmp->og) < 0) {
+			ast_log(LOG_ERROR,
+					"Error reading first page of Ogg bitstream data.\n");
 			fclose(f);
 			ogg_stream_clear(&tmp->os);
 			vorbis_comment_clear(&tmp->vc);
@@ -146,8 +147,8 @@
 			free(tmp);
 			return NULL;
 		}
-		
-		if(ogg_stream_packetout(&tmp->os, &tmp->op) != 1) { 
+
+		if (ogg_stream_packetout(&tmp->os, &tmp->op) != 1) {
 			ast_log(LOG_ERROR, "Error reading initial header packet.\n");
 			fclose(f);
 			ogg_stream_clear(&tmp->os);
@@ -157,8 +158,8 @@
 			free(tmp);
 			return NULL;
 		}
-		
-		if(vorbis_synthesis_headerin(&tmp->vi, &tmp->vc, &tmp->op) < 0) { 
+
+		if (vorbis_synthesis_headerin(&tmp->vi, &tmp->vc, &tmp->op) < 0) {
 			ast_log(LOG_ERROR, "This Ogg bitstream does not contain Vorbis audio data.\n");
 			fclose(f);
 			ogg_stream_clear(&tmp->os);
@@ -168,20 +169,20 @@
 			free(tmp);
 			return NULL;
 		}
-		
+
 		i = 0;
-		while(i < 2) {
-			while(i < 2){
+		while (i < 2) {
+			while (i < 2) {
 				result = ogg_sync_pageout(&tmp->oy, &tmp->og);
-				if(result == 0)
+				if (result == 0)
 					break;
-				if(result == 1) {
+				if (result == 1) {
 					ogg_stream_pagein(&tmp->os, &tmp->og);
-					while(i < 2) {
-						result = ogg_stream_packetout(&tmp->os,&tmp->op);
-						if(result == 0)
+					while (i < 2) {
+						result = ogg_stream_packetout(&tmp->os, &tmp->op);
+						if (result == 0)
 							break;
-						if(result < 0) {
+						if (result < 0) {
 							ast_log(LOG_ERROR, "Corrupt secondary header.  Exiting.\n");
 							fclose(f);
 							ogg_stream_clear(&tmp->os);
@@ -199,7 +200,7 @@
 
 			buffer = ogg_sync_buffer(&tmp->oy, BLOCK_SIZE);
 			bytes = fread(buffer, 1, BLOCK_SIZE, f);
-			if(bytes == 0 && i < 2) {
+			if (bytes == 0 && i < 2) {
 				ast_log(LOG_ERROR, "End of file before finding all Vorbis headers!\n");
 				fclose(f);
 				ogg_stream_clear(&tmp->os);
@@ -211,16 +212,18 @@
 			}
 			ogg_sync_wrote(&tmp->oy, bytes);
 		}
-		
+
 		ptr = tmp->vc.user_comments;
-		while(*ptr){
+		while (*ptr) {
 			ast_log(LOG_DEBUG, "OGG/Vorbis comment: %s\n", *ptr);
 			++ptr;
 		}
-		ast_log(LOG_DEBUG, "OGG/Vorbis bitstream is %d channel, %ldHz\n", tmp->vi.channels, tmp->vi.rate);
-		ast_log(LOG_DEBUG, "OGG/Vorbis file encoded by: %s\n", tmp->vc.vendor);
-
-		if(tmp->vi.channels != 1) {
+		ast_log(LOG_DEBUG, "OGG/Vorbis bitstream is %d channel, %ldHz\n",
+			tmp->vi.channels, tmp->vi.rate);
+		ast_log(LOG_DEBUG, "OGG/Vorbis file encoded by: %s\n",
+			tmp->vc.vendor);
+
+		if (tmp->vi.channels != 1) {
 			ast_log(LOG_ERROR, "Only monophonic OGG/Vorbis files are currently supported!\n");
 			ogg_stream_clear(&tmp->os);
 			vorbis_comment_clear(&tmp->vc);
@@ -229,9 +232,8 @@
 			free(tmp);
 			return NULL;
 		}
-		
-
-		if(tmp->vi.rate != 8000) {
+
+		if (tmp->vi.rate != 8000) {
 			ast_log(LOG_ERROR, "Only 8000Hz OGG/Vorbis files are currently supported!\n");
 			fclose(f);
 			ogg_stream_clear(&tmp->os);
@@ -243,11 +245,11 @@
 			free(tmp);
 			return NULL;
 		}
-		
+
 		vorbis_synthesis_init(&tmp->vd, &tmp->vi);
 		vorbis_block_init(&tmp->vd, &tmp->vb);
 
-		if(ast_mutex_lock(&ogg_vorbis_lock)) {
+		if (ast_mutex_lock(&ogg_vorbis_lock)) {
 			ast_log(LOG_WARNING, "Unable to lock ogg_vorbis list\n");
 			fclose(f);
 			ogg_stream_clear(&tmp->os);
@@ -272,7 +274,8 @@
  * \param comment Comment that should be embedded in the OGG/Vorbis file.
  * \return A new filestream.
  */
-static struct ast_filestream *ogg_vorbis_rewrite(FILE *f, const char *comment)
+static struct ast_filestream *ogg_vorbis_rewrite(FILE * f,
+						 const char *comment)
 {
 	ogg_packet header;
 	ogg_packet header_comm;
@@ -280,7 +283,7 @@
 
 	struct ast_filestream *tmp;
 
-	if((tmp = malloc(sizeof(struct ast_filestream)))) {
+	if ((tmp = malloc(sizeof(struct ast_filestream)))) {
 		memset(tmp, 0, sizeof(struct ast_filestream));
 
 		tmp->writing = 1;
@@ -288,7 +291,7 @@
 
 		vorbis_info_init(&tmp->vi);
 
-		if(vorbis_encode_init_vbr(&tmp->vi, 1, 8000, 0.4)) {
+		if (vorbis_encode_init_vbr(&tmp->vi, 1, 8000, 0.4)) {
 			ast_log(LOG_ERROR, "Unable to initialize Vorbis encoder!\n");
 			free(tmp);
 			return NULL;
@@ -296,7 +299,7 @@
 
 		vorbis_comment_init(&tmp->vc);
 		vorbis_comment_add_tag(&tmp->vc, "ENCODER", "Asterisk PBX");
-		if(comment)
+		if (comment)
 			vorbis_comment_add_tag(&tmp->vc, "COMMENT", (char *) comment);
 
 		vorbis_analysis_init(&tmp->vd, &tmp->vi);
@@ -304,21 +307,22 @@
 
 		ogg_stream_init(&tmp->os, rand());
 
-		vorbis_analysis_headerout(&tmp->vd, &tmp->vc, &header, &header_comm, &header_code);
-		ogg_stream_packetin(&tmp->os, &header);							
+		vorbis_analysis_headerout(&tmp->vd, &tmp->vc, &header, &header_comm,
+					  &header_code);
+		ogg_stream_packetin(&tmp->os, &header);
 		ogg_stream_packetin(&tmp->os, &header_comm);
 		ogg_stream_packetin(&tmp->os, &header_code);
 
-		while(!tmp->eos) {
-			if(ogg_stream_flush(&tmp->os, &tmp->og) == 0)
+		while (!tmp->eos) {
+			if (ogg_stream_flush(&tmp->os, &tmp->og) == 0)
 				break;
 			fwrite(tmp->og.header, 1, tmp->og.header_len, tmp->f);
 			fwrite(tmp->og.body, 1, tmp->og.body_len, tmp->f);
-			if(ogg_page_eos(&tmp->og))
+			if (ogg_page_eos(&tmp->og))
 				tmp->eos = 1;
 		}
 
-		if(ast_mutex_lock(&ogg_vorbis_lock)) {
+		if (ast_mutex_lock(&ogg_vorbis_lock)) {
 			ast_log(LOG_WARNING, "Unable to lock ogg_vorbis list\n");
 			fclose(f);
 			ogg_stream_clear(&tmp->os);
@@ -345,16 +349,16 @@
 	while (vorbis_analysis_blockout(&s->vd, &s->vb) == 1) {
 		vorbis_analysis(&s->vb, NULL);
 		vorbis_bitrate_addblock(&s->vb);
-		
+
 		while (vorbis_bitrate_flushpacket(&s->vd, &s->op)) {
 			ogg_stream_packetin(&s->os, &s->op);
 			while (!s->eos) {
-				if(ogg_stream_pageout(&s->os, &s->og) == 0) {
+				if (ogg_stream_pageout(&s->os, &s->og) == 0) {
 					break;
 				}
 				fwrite(s->og.header, 1, s->og.header_len, s->f);
 				fwrite(s->og.body, 1, s->og.body_len, s->f);
-				if(ogg_page_eos(&s->og)) {
+				if (ogg_page_eos(&s->og)) {
 					s->eos = 1;
 				}
 			}
@@ -374,20 +378,21 @@
 	float **buffer;
 	short *data;
 
-	if(!s->writing) {
+	if (!s->writing) {
 		ast_log(LOG_ERROR, "This stream is not set up for writing!\n");
 		return -1;
 	}
 
-	if(f->frametype != AST_FRAME_VOICE) {
+	if (f->frametype != AST_FRAME_VOICE) {
 		ast_log(LOG_WARNING, "Asked to write non-voice frame!\n");
 		return -1;
 	}
-	if(f->subclass != AST_FORMAT_SLINEAR) {
-		ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%d)!\n", f->subclass);
+	if (f->subclass != AST_FORMAT_SLINEAR) {
+		ast_log(LOG_WARNING, "Asked to write non-SLINEAR frame (%d)!\n",
+				f->subclass);
 		return -1;
 	}
-	if(!f->datalen)
+	if (!f->datalen)
 		return -1;
 
 	data = (short *) f->data;
@@ -395,7 +400,7 @@
 	buffer = vorbis_analysis_buffer(&s->vd, f->samples);
 
 	for (i = 0; i < f->samples; i++) {
-		buffer[0][i] = data[i]/32768.f;
+		buffer[0][i] = data[i] / 32768.f;
 	}
 
 	vorbis_analysis_wrote(&s->vd, f->samples);
@@ -411,7 +416,7 @@
  */
 static void ogg_vorbis_close(struct ast_filestream *s)
 {
-	if(ast_mutex_lock(&ogg_vorbis_lock)) {
+	if (ast_mutex_lock(&ogg_vorbis_lock)) {
 		ast_log(LOG_WARNING, "Unable to lock ogg_vorbis list\n");
 		return;
 	}
@@ -419,7 +424,7 @@
 	ast_mutex_unlock(&ogg_vorbis_lock);
 	ast_update_use_count();
 
-	if(s->writing) {
+	if (s->writing) {
 		/* Tell the Vorbis encoder that the stream is finished
 		 * and write out the rest of the data */
 		vorbis_analysis_wrote(&s->vd, 0);
@@ -432,10 +437,10 @@
 	vorbis_comment_clear(&s->vc);
 	vorbis_info_clear(&s->vi);
 
-	if(s->writing) {
+	if (s->writing) {
 		ogg_sync_clear(&s->oy);
 	}
-	
+
 	fclose(s->f);
 	free(s);
 }
@@ -455,28 +460,29 @@
 
 	while (1) {
 		samples_in = vorbis_synthesis_pcmout(&s->vd, pcm);
-		if(samples_in > 0) {
+		if (samples_in > 0) {
 			return samples_in;
 		}
-		
+
 		/* The Vorbis decoder needs more data... */
 		/* See ifOGG has any packets in the current page for the Vorbis decoder. */
 		result = ogg_stream_packetout(&s->os, &s->op);
-		if(result > 0) {
+		if (result > 0) {
 			/* Yes OGG had some more packets for the Vorbis decoder. */
-			if(vorbis_synthesis(&s->vb, &s->op) == 0) {
+			if (vorbis_synthesis(&s->vb, &s->op) == 0) {
 				vorbis_synthesis_blockin(&s->vd, &s->vb);
 			}
-			
+
 			continue;
 		}
 
-		if(result < 0)
-			ast_log(LOG_WARNING, "Corrupt or missing data at this page position; continuing...\n");
-		
+		if (result < 0)
+			ast_log(LOG_WARNING,
+					"Corrupt or missing data at this page position; continuing...\n");
+
 		/* No more packets left in the current page... */
 
-		if(s->eos) {
+		if (s->eos) {
 			/* No more pages left in the stream */
 			return -1;
 		}
@@ -484,22 +490,24 @@
 		while (!s->eos) {
 			/* See ifOGG has any pages in it's internal buffers */
 			result = ogg_sync_pageout(&s->oy, &s->og);
-			if(result > 0) {
+			if (result > 0) {
 				/* Yes, OGG has more pages in it's internal buffers,
 				   add the page to the stream state */
 				result = ogg_stream_pagein(&s->os, &s->og);
-				if(result == 0) {
+				if (result == 0) {
 					/* Yes, got a new,valid page */
-					if(ogg_page_eos(&s->og)) {
+					if (ogg_page_eos(&s->og)) {
 						s->eos = 1;
 					}
 					break;
 				}
-				ast_log(LOG_WARNING, "Invalid page in the bitstream; continuing...\n");
-			}
-			
-			if(result < 0)
-				ast_log(LOG_WARNING, "Corrupt or missing data in bitstream; continuing...\n");
+				ast_log(LOG_WARNING,
+						"Invalid page in the bitstream; continuing...\n");
+			}
+
+			if (result < 0)
+				ast_log(LOG_WARNING,
+						"Corrupt or missing data in bitstream; continuing...\n");
 
 			/* No, we need to read more data from the file descrptor */
 			/* get a buffer from OGG to read the data into */
@@ -508,7 +516,7 @@
 			bytes = fread(buffer, 1, BLOCK_SIZE, s->f);
 			/* Tell OGG how many bytes we actually read into the buffer */
 			ogg_sync_wrote(&s->oy, bytes);
-			if(bytes == 0) {
+			if (bytes == 0) {
 				s->eos = 1;
 			}
 		}
@@ -521,7 +529,8 @@
  * \param whennext Number of sample times to schedule the next call.
  * \return A pointer to a frame containing audio data or NULL ifthere is no more audio data.
  */
-static struct ast_frame *ogg_vorbis_read(struct ast_filestream *s, int *whennext)
+static struct ast_frame *ogg_vorbis_read(struct ast_filestream *s,
+					 int *whennext)
 {
 	int clipflag = 0;
 	int i;
@@ -535,25 +544,25 @@
 
 	while (1) {
 		/* See ifwe have filled up an audio frame yet */
-		if(samples_out == SAMPLES_MAX)
+		if (samples_out == SAMPLES_MAX)
 			break;
 
 		/* See ifVorbis decoder has some audio data for us ... */
 		samples_in = read_samples(s, &pcm);
-		if(samples_in <= 0)
+		if (samples_in <= 0)
 			break;
 
 		/* Got some audio data from Vorbis... */
 		/* Convert the float audio data to 16-bit signed linear */
-		
+
 		clipflag = 0;
 
 		samples_in = samples_in < (SAMPLES_MAX - samples_out) ? samples_in : (SAMPLES_MAX - samples_out);
-  
-		for(j = 0; j < samples_in; j++)
+
+		for (j = 0; j < samples_in; j++)
 			accumulator[j] = 0.0;
 
-		for(i = 0; i < s->vi.channels; i++) {
+		for (i = 0; i < s->vi.channels; i++) {
 			mono = pcm[i];
 			for (j = 0; j < samples_in; j++) {
 				accumulator[j] += mono[j];
@@ -561,27 +570,26 @@
 		}
 
 		for (j = 0; j < samples_in; j++) {
-			val =  accumulator[j] * 32767.0 / s->vi.channels;
-			if(val > 32767) {
+			val = accumulator[j] * 32767.0 / s->vi.channels;
+			if (val > 32767) {
 				val = 32767;
 				clipflag = 1;
 			}
-			if(val < -32768) {
+			if (val < -32768) {
 				val = -32768;
 				clipflag = 1;
 			}
 			s->buffer[samples_out + j] = val;
 		}
-			
-		if(clipflag)
-			ast_log(LOG_WARNING, "Clipping in frame %ld\n", (long)(s->vd.sequence));
-		
+
+		if (clipflag)
+			ast_log(LOG_WARNING, "Clipping in frame %ld\n", (long) (s->vd.sequence));
 		/* Tell the Vorbis decoder how many samples we actually used. */
 		vorbis_synthesis_read(&s->vd, samples_in);
 		samples_out += samples_in;
 	}
 
-	if(samples_out > 0) {
+	if (samples_out > 0) {
 		s->fr.frametype = AST_FRAME_VOICE;
 		s->fr.subclass = AST_FORMAT_SLINEAR;
 		s->fr.offset = AST_FRIENDLY_OFFSET;
@@ -591,7 +599,7 @@
 		s->fr.mallocd = 0;
 		s->fr.samples = samples_out;
 		*whennext = samples_out;
-		
+
 		return &s->fr;
 	} else {
 		return NULL;
@@ -618,17 +626,21 @@
  * \return 0 on success, -1 on failure.
  */
 
-static int ogg_vorbis_seek(struct ast_filestream *s, long sample_offset, int whence) {
+static int ogg_vorbis_seek(struct ast_filestream *s, long sample_offset,
+			   int whence)
+{
 	ast_log(LOG_WARNING, "Seeking is not supported on OGG/Vorbis streams!\n");
 	return -1;
 }
 
-static long ogg_vorbis_tell(struct ast_filestream *s) {
+static long ogg_vorbis_tell(struct ast_filestream *s)
+{
 	ast_log(LOG_WARNING, "Telling is not supported on OGG/Vorbis streams!\n");
 	return -1;
 }
 
-static char *ogg_vorbis_getcomment(struct ast_filestream *s) {
+static char *ogg_vorbis_getcomment(struct ast_filestream *s)
+{
 	ast_log(LOG_WARNING, "Getting comments is not supported on OGG/Vorbis streams!\n");
 	return NULL;
 }
@@ -650,7 +662,7 @@
 int unload_module()
 {
 	return ast_format_unregister(name);
-}	
+}
 
 int usecount()
 {
@@ -667,11 +679,3 @@
 {
 	return ASTERISK_GPL_KEY;
 }
-
-/*
-Local Variables:
-mode: C
-c-file-style: "linux"
-indent-tabs-mode: t
-End:
-*/

Modified: trunk/funcs/func_base64.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_base64.c?rev=9674&r1=9673&r2=9674&view=diff
==============================================================================
--- trunk/funcs/func_base64.c (original)
+++ trunk/funcs/func_base64.c Sat Feb 11 22:28:58 2006
@@ -36,31 +36,30 @@
 #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) ) {
+	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) ) {
+	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 = {
@@ -83,13 +82,13 @@
 
 int unload_module(void)
 {
-        return ast_custom_function_unregister(&base64_encode_function) ||
+	return ast_custom_function_unregister(&base64_encode_function) |
 		ast_custom_function_unregister(&base64_decode_function);
 }
 
 int load_module(void)
 {
-        return ast_custom_function_register(&base64_encode_function) ||
+	return ast_custom_function_register(&base64_encode_function) |
 		ast_custom_function_register(&base64_decode_function);
 }
 
@@ -107,11 +106,3 @@
 {
 	return ASTERISK_GPL_KEY;
 }
-
-/*
-Local Variables:
-mode: C
-c-file-style: "linux"
-indent-tabs-mode: nil
-End:
-*/

Modified: trunk/funcs/func_callerid.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_callerid.c?rev=9674&r1=9673&r2=9674&view=diff
==============================================================================
--- trunk/funcs/func_callerid.c (original)
+++ trunk/funcs/func_callerid.c Sat Feb 11 22:28:58 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
@@ -28,7 +28,6 @@
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
 #include "asterisk/module.h"
 #include "asterisk/channel.h"
 #include "asterisk/pbx.h"
@@ -38,7 +37,8 @@
 #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;
 
@@ -49,22 +49,27 @@
 		ast_callerid_split(opt, name, sizeof(name), num, sizeof(num));
 
 		if (!strncasecmp("all", data, 3)) {
-			snprintf(buf, len, "\"%s\" <%s>", name, num);	
+			snprintf(buf, len, "\"%s\" <%s>", name, num);
 		} else if (!strncasecmp("name", data, 4)) {
 			ast_copy_string(buf, name, len);
-		} else if (!strncasecmp("num", data, 3) || !strncasecmp("number", data, 6)) {
+		} else if (!strncasecmp("num", data, 3) ||
+			   !strncasecmp("number", data, 6)) {
+
 			ast_copy_string(buf, num, len);
 		} else {
 			ast_log(LOG_ERROR, "Unknown callerid data type.\n");
 		}
 	} else {
 		if (!strncasecmp("all", data, 3)) {
-			snprintf(buf, len, "\"%s\" <%s>", chan->cid.cid_name ? chan->cid.cid_name : "", chan->cid.cid_num ? chan->cid.cid_num : "");	
+			snprintf(buf, len, "\"%s\" <%s>",
+				 chan->cid.cid_name ? chan->cid.cid_name : "",
+				 chan->cid.cid_num ? chan->cid.cid_num : "");
 		} else if (!strncasecmp("name", data, 4)) {
 			if (chan->cid.cid_name) {
 				ast_copy_string(buf, chan->cid.cid_name, len);
 			}
-		} else if (!strncasecmp("num", data, 3) || !strncasecmp("number", data, 6)) {
+		} else if (!strncasecmp("num", data, 3)
+				   || !strncasecmp("number", data, 6)) {
 			if (chan->cid.cid_num) {
 				ast_copy_string(buf, chan->cid.cid_num, len);
 			}
@@ -84,47 +89,54 @@
 			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)) {
-                ast_set_callerid(chan, NULL, value, NULL);
-        } else if (!strncasecmp("num", data, 3) || !strncasecmp("number", data, 6)) {
-                ast_set_callerid(chan, value, NULL, NULL);
-        } else if (!strncasecmp("ani", data, 3)) {
-                ast_set_callerid(chan, NULL, NULL, value);
-        } else if (!strncasecmp("dnid", data, 4)) {
-                /* do we need to lock chan here? */
-                if (chan->cid.cid_dnid)
-                        free(chan->cid.cid_dnid);
-                chan->cid.cid_dnid = ast_strlen_zero(value) ? NULL : strdup(value);
-        } else if (!strncasecmp("rdnis", data, 5)) {
-                /* do we need to lock chan here? */
-                if (chan->cid.cid_rdnis)
-                        free(chan->cid.cid_rdnis);
-                chan->cid.cid_rdnis = ast_strlen_zero(value) ? NULL : strdup(value);
-        } else {
-                ast_log(LOG_ERROR, "Unknown callerid data type.\n");
-        }
+			ast_set_callerid(chan, num, name, num);
+	} else if (!strncasecmp("name", data, 4)) {
+		ast_set_callerid(chan, NULL, value, NULL);
+	} else if (!strncasecmp("num", data, 3) ||
+		   !strncasecmp("number", data, 6)) {
+		ast_set_callerid(chan, value, NULL, NULL);
+	} else if (!strncasecmp("ani", data, 3)) {
+		ast_set_callerid(chan, NULL, NULL, value);
+	} else if (!strncasecmp("dnid", data, 4)) {
+		/* do we need to lock chan here? */
+		if (chan->cid.cid_dnid)
+			free(chan->cid.cid_dnid);
+		chan->cid.cid_dnid = ast_strlen_zero(value) ? NULL : strdup(value);
+	} else if (!strncasecmp("rdnis", data, 5)) {
+		/* do we need to lock chan here? */
+		if (chan->cid.cid_rdnis)
+			free(chan->cid.cid_rdnis);
+		chan->cid.cid_rdnis = ast_strlen_zero(value) ? NULL : strdup(value);
+	} else {
+		ast_log(LOG_ERROR, "Unknown callerid data type.\n");
+	}
+
+	return 0;
 }
 
 static struct ast_custom_function callerid_function = {
 	.name = "CALLERID",
 	.synopsis = "Gets or sets Caller*ID data on the channel.",
 	.syntax = "CALLERID(datatype[,<optional-CID>])",

[... 3405 lines stripped ...]


More information about the asterisk-commits mailing list