[asterisk-commits] branch rizzo/base r11773 - in /team/rizzo/base: ./ apps/ build_tools/ cdr/ ch...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Mar 4 02:22:50 MST 2006


Author: rizzo
Date: Sat Mar  4 03:22:31 2006
New Revision: 11773

URL: http://svn.digium.com/view/asterisk?rev=11773&view=rev
Log:
merge recent changes to trunk.
Remove 'newstack' from pbx_exec() and associated places.
Assorted cleanups of pbx.c
Some simplifications to cdr.c


Modified:
    team/rizzo/base/CREDITS
    team/rizzo/base/Makefile
    team/rizzo/base/README
    team/rizzo/base/UPGRADE.txt
    team/rizzo/base/app.c
    team/rizzo/base/apps/app_dial.c
    team/rizzo/base/apps/app_dial2.c
    team/rizzo/base/apps/app_exec.c
    team/rizzo/base/apps/app_meetme.c
    team/rizzo/base/apps/app_page.c
    team/rizzo/base/apps/app_voicemail.c
    team/rizzo/base/apps/app_while.c
    team/rizzo/base/asterisk.c
    team/rizzo/base/asterisk.sgml
    team/rizzo/base/build_tools/make_build_h
    team/rizzo/base/build_tools/make_svn_branch_name
    team/rizzo/base/cdr.c
    team/rizzo/base/cdr/cdr_csv.c
    team/rizzo/base/cdr/cdr_manager.c
    team/rizzo/base/cdr/cdr_odbc.c
    team/rizzo/base/cdr/cdr_pgsql.c
    team/rizzo/base/cdr/cdr_tds.c
    team/rizzo/base/channel.c
    team/rizzo/base/channels/chan_iax2.c
    team/rizzo/base/channels/chan_sip.c
    team/rizzo/base/cli.c
    team/rizzo/base/configs/cdr.conf.sample
    team/rizzo/base/configs/sip.conf.sample
    team/rizzo/base/funcs/Makefile
    team/rizzo/base/include/asterisk/adsi.h
    team/rizzo/base/include/asterisk/cdr.h
    team/rizzo/base/include/asterisk/pbx.h
    team/rizzo/base/include/asterisk/strings.h
    team/rizzo/base/manager.c
    team/rizzo/base/pbx.c
    team/rizzo/base/pbx/pbx_dundi.c
    team/rizzo/base/pbx/pbx_loopback.c
    team/rizzo/base/pbx/pbx_realtime.c
    team/rizzo/base/res/res_adsi.c
    team/rizzo/base/res/res_agi.c
    team/rizzo/base/res/res_config_odbc.c
    team/rizzo/base/res/res_features.c
    team/rizzo/base/translate.c

Modified: team/rizzo/base/CREDITS
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/CREDITS?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/CREDITS (original)
+++ team/rizzo/base/CREDITS Sat Mar  4 03:22:31 2006
@@ -59,8 +59,8 @@
 Jayson Vantuyl - Manager protocol changes, various other bugs.
 	jvantuyl at computingedge.net
 Thorsten Lockert - OpenBSD, FreeBSD ports, making MacOS X port run on 10.3,
-	dialplan include verification, route lookup on OpenBSD, various other
-	bugs. tholo at sigmasoft.com
+	dialplan include verification, route lookup on OpenBSD, SNMP agent
+	support (res_snmp), various other bugs. tholo at sigmasoft.com
 Brian West - ODBC support and Bug Marshaling  
 Josh Roberson - chan_zap reload support, Advanced Voicemail Features, other misc. patches,
 	and Bug Marshalling. - josh at asteriasgi.com, http://www.asteriasgi.com

Modified: team/rizzo/base/Makefile
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/Makefile?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/Makefile (original)
+++ team/rizzo/base/Makefile Sat Mar  4 03:22:31 2006
@@ -241,10 +241,12 @@
 endif
 
 GREP=grep
+ID=id
 
 ifeq ($(OSARCH),SunOS)
   GREP=/usr/xpg4/bin/grep
   M4=/usr/local/bin/m4
+  ID=/usr/xpg4/bin/id
 endif
 
 INCLUDE+=-Iinclude -I../include
@@ -597,7 +599,7 @@
 	$(MAKE) -C stdtime clean
 
 datafiles: all
-	if [ x`whoami` = xroot ]; then sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
+	if [ x`$(ID) -un` = xroot ]; then sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
 	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
 	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/priv-callerintros
 	for x in sounds/digits/*.gsm; do \

Modified: team/rizzo/base/README
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/README?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/README (original)
+++ team/rizzo/base/README Sat Mar  4 03:22:31 2006
@@ -67,7 +67,7 @@
   In order to discover new features to use, please check the configuration
 examples in the /configs directory of the source code distribution. 
 To discover the major new features of Asterisk 1.2, please visit 
-http://www.astricon.net/asterisk1-2/
+http://edvina.net/asterisk1-2/
 
 * NEW INSTALLATIONS
 

Modified: team/rizzo/base/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/UPGRADE.txt?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/UPGRADE.txt (original)
+++ team/rizzo/base/UPGRADE.txt Sat Mar  4 03:22:31 2006
@@ -37,6 +37,9 @@
   functions.  You are encouraged to move towards the associated dialplan
   function, as these variables will be removed in a future release.
 
+* The CDR-CSV variables uniqueid, userfield, and basing time on GMT are now 
+  adjustable from cdr.conf, instead of recompiling.
+
 Functions:
 
 * The function ${CHECK_MD5()} has been deprecated in favor of using an

Modified: team/rizzo/base/app.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/app.c?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/app.c (original)
+++ team/rizzo/base/app.c Sat Mar  4 03:22:31 2006
@@ -79,7 +79,7 @@
 	else 
 		ast_log(LOG_NOTICE,"Huh....? no dial for indications?\n");
 	
-	for (x = strlen(collect); strlen(collect) < maxlen; ) {
+	for (x = strlen(collect); x < maxlen; ) {
 		res = ast_waitfordigit(chan, timeout);
 		if (!ast_ignore_pattern(context, collect))
 			ast_playtones_stop(chan);
@@ -94,12 +94,8 @@
 			break;
 		}
 	}
-	if (res >= 0) {
-		if (ast_exists_extension(chan, context, collect, 1, chan->cid.cid_num))
-			res = 1;
-		else
-			res = 0;
-	}
+	if (res >= 0)
+		res = ast_exists_extension(chan, context, collect, 1, chan->cid.cid_num) ? 1 : 0;
 	return res;
 }
 
@@ -542,7 +538,6 @@
 static int global_silence_threshold = 128;
 static int global_maxsilence = 0;
 
-/* XXX much of this is duplicated in ast_play_and_prepend() */
 int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int silencethreshold, int maxsilence, const char *path)
 {
 	int d;
@@ -1090,7 +1085,7 @@
 	if (regcomp(&regexbuf, groupmatch, REG_EXTENDED | REG_NOSUB))
 		return 0;
 
-	s = (!ast_strlen_zero(category)) ? category : GROUP_CATEGORY_PREFIX;
+	s = S_OR(category, GROUP_CATEGORY_PREFIX);
 	ast_copy_string(cat, s, sizeof(cat));
 
 	chan = NULL;

Modified: team/rizzo/base/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_dial.c?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/apps/app_dial.c (original)
+++ team/rizzo/base/apps/app_dial.c Sat Mar  4 03:22:31 2006
@@ -1448,7 +1448,7 @@
 					if (*ch == '^')
 						*ch = '|';
 				}
-				res = pbx_exec(peer, app, opt_args[OPT_ARG_CALLEE_MACRO], 1);
+				res = pbx_exec(peer, app, opt_args[OPT_ARG_CALLEE_MACRO]);
 				ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
 				res = 0;
 			} else {

Modified: team/rizzo/base/apps/app_dial2.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_dial2.c?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/apps/app_dial2.c (original)
+++ team/rizzo/base/apps/app_dial2.c Sat Mar  4 03:22:31 2006
@@ -37,7 +37,7 @@
 
 #include "asterisk.h"
 
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 8379 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision: 9060 $")
 
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
@@ -326,10 +326,6 @@
 	}
 }
 
-
-/* return first string if not empty, otherwise second */
-#define S_OR(a, b)	(!ast_strlen_zero(a) ? (a) : (b))
-
 /* free the buffer if allocated, and set the pointer to the second arg */
 #define S_REPLACE(s, new)	\
 	do {					\
@@ -980,7 +976,7 @@
 
 	if (app && !res) {
 		replace_macro_delimiter(arg);
-		res = pbx_exec(peer, app, arg, 1);
+		res = pbx_exec(peer, app, arg);
 		ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
 		res = 0;
 	} else {
@@ -1260,8 +1256,8 @@
 		tc = tmp->chan = ast_request(tech, chan->nativeformats, numsubst, &cause);
 		if (!tc) {
 			/* If we can't, just go on to the next call */
-			ast_log(LOG_NOTICE, "Unable to create channel of type '%s' (cause %d - %s)\n",
-				tech, cause, ast_cause2str(cause));
+			ast_log(LOG_NOTICE, "Unable to create channel of type '%s''%s' (cause %d - %s)\n",
+				tech, numsubst, cause, ast_cause2str(cause));
 			handle_cause(cause, &num);
 			if (!rest)	/* last one, so exit the loop ? */
 				chan->hangupcause = cause;

Modified: team/rizzo/base/apps/app_exec.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_exec.c?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/apps/app_exec.c (original)
+++ team/rizzo/base/apps/app_exec.c Sat Mar  4 03:22:31 2006
@@ -82,7 +82,7 @@
 			if (appname) {
 				app = pbx_findapp(appname);
 				if (app) {
-					res = pbx_exec(chan, app, args, 1);
+					res = pbx_exec(chan, app, args);
 				} else {
 					ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
 					res = -1;

Modified: team/rizzo/base/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_meetme.c?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/apps/app_meetme.c (original)
+++ team/rizzo/base/apps/app_meetme.c Sat Mar  4 03:22:31 2006
@@ -1119,7 +1119,7 @@
 		app = pbx_findapp("agi");
 		if (app) {
 			char *s = ast_strdupa(agifile);
-			ret = pbx_exec(chan, app, s, 1);
+			ret = pbx_exec(chan, app, s);
 		} else {
 			ast_log(LOG_WARNING, "Could not find application (agi)\n");
 			ret = -2;

Modified: team/rizzo/base/apps/app_page.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_page.c?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/apps/app_page.c (original)
+++ team/rizzo/base/apps/app_page.c Sat Mar  4 03:22:31 2006
@@ -186,7 +186,7 @@
 	}
 	if (!res) {
 		snprintf(meetmeopts, sizeof(meetmeopts), "%ud|A%sqxd", confid, ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "t");
-		pbx_exec(chan, app, meetmeopts, 1);
+		pbx_exec(chan, app, meetmeopts);
 	}
 
 	LOCAL_USER_REMOVE(u);

Modified: team/rizzo/base/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_voicemail.c?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/apps/app_voicemail.c (original)
+++ team/rizzo/base/apps/app_voicemail.c Sat Mar  4 03:22:31 2006
@@ -769,7 +769,7 @@
 		ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
 }
 
-static int make_dir(char *dest, int len, char *context, char *ext, char *folder)
+static int make_dir(char *dest, int len, const char *context, const char *ext, const char *folder)
 {
 	return snprintf(dest, len, "%s%s/%s/%s", VM_SPOOL_DIR, context, ext, folder);
 }
@@ -786,7 +786,7 @@
  * \param folder  String. Ignored if is null or empty string. 
  * \return 0 on failure, 1 on success.
  */
-static int create_dirpath(char *dest, int len, char *context, char *ext, char *folder)
+static int create_dirpath(char *dest, int len, const char *context, const char *ext, const char *folder)
 {
 	mode_t	mode = VOICEMAIL_DIR_MODE;
 
@@ -1930,10 +1930,7 @@
 		if (res)
 			return res;
 	}
-	if (busy)
-		res = ast_streamfile(chan, "vm-isonphone", chan->language);
-	else
-		res = ast_streamfile(chan, "vm-isunavail", chan->language);
+	res = ast_streamfile(chan, busy ? "vm-isonphone" : "vm-isunavail", chan->language);
 	if (res)
 		return -1;
 	res = ast_waitstream(chan, ecodes);
@@ -1951,32 +1948,21 @@
 	free(z);
 }
 
-static char *mbox(int id)
-{
-	switch(id) {
-	case 0:
-		return "INBOX";
-	case 1:
-		return "Old";
-	case 2:
-		return "Work";
-	case 3:
-		return "Family";
-	case 4:
-		return "Friends";
-	case 5:
-		return "Cust1";
-	case 6:
-		return "Cust2";
-	case 7:
-		return "Cust3";
-	case 8:
-		return "Cust4";
-	case 9:
-		return "Cust5";
-	default:
-		return "Unknown";
-	}
+static const char *mbox(int id)
+{
+	static const char *msgs[] = {
+		"INBOX",
+		"Old",
+		"Work",
+		"Family",
+		"Friends",
+		"Cust1",
+		"Cust2",
+		"Cust3",
+		"Cust4",
+		"Cust5",
+	};
+	return (id >= 0 && id < (sizeof(msgs)/sizeof(msgs[0]))) ? msgs[id] : "Unknown";
 }
 
 #ifdef USE_ODBC_STORAGE
@@ -2280,7 +2266,7 @@
 static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt)
 {
 	char fromdir[256], todir[256], frompath[256], topath[256];
-	char *frombox = mbox(imbox);
+	const char *frombox = mbox(imbox);
 	int recipmsgnum;
 
 	ast_log(LOG_NOTICE, "Copying message from %s@%s to %s@%s\n", vmu->mailbox, vmu->context, recip->mailbox, recip->context);
@@ -2687,7 +2673,7 @@
 	char sfn[256];
 	char dfn[256];
 	char ddir[256];
-	char *dbox = mbox(box);
+	const char *dbox = mbox(box);
 	int x;
  	make_file(sfn, sizeof(sfn), dir, msg);
 	create_dirpath(ddir, sizeof(ddir), context, username, dbox);
@@ -3417,7 +3403,7 @@
 				old_priority = chan->priority;
 				
 				/* call the the Directory, changes the channel */
-				res = pbx_exec(chan, app, context ? context : "default", 1);
+				res = pbx_exec(chan, app, context ? context : "default");
 				
 				ast_copy_string(username, chan->exten, sizeof(username));
 				
@@ -4496,6 +4482,79 @@
 	return res;
 }
 
+static int get_lastdigits(int num)
+{
+	num %= 100;
+	return (num < 20) ? num : num % 10;
+}
+
+static int vm_intro_ru(struct ast_channel *chan,struct vm_state *vms)
+{
+	int res;
+	int lastnum = 0;
+	int dcnum;
+
+	res = ast_play_and_wait(chan, "vm-youhave");
+	if (!res && vms->newmessages) {
+		lastnum = get_lastdigits(vms->newmessages);
+		dcnum = vms->newmessages - lastnum;
+		if (dcnum)
+			res = say_and_wait(chan, dcnum, chan->language);
+		if (!res && lastnum) {
+			if (lastnum == 1) 
+				res = ast_play_and_wait(chan, "digits/ru/odno");
+			else
+				res = say_and_wait(chan, lastnum, chan->language);
+		}
+
+		if (!res)
+			res = ast_play_and_wait(chan, (lastnum == 1) ? "vm-novoe" : "vm-novyh");
+
+		if (!res && vms->oldmessages)
+			res = ast_play_and_wait(chan, "vm-and");
+	}
+
+	if (!res && vms->oldmessages) {
+		lastnum = get_lastdigits(vms->oldmessages);
+		dcnum = vms->newmessages - lastnum;
+		if (dcnum)
+			res = say_and_wait(chan, dcnum, chan->language);
+		if (!res && lastnum) {
+			if (lastnum == 1) 
+				res = ast_play_and_wait(chan, "digits/ru/odno");
+			else
+				res = say_and_wait(chan, lastnum, chan->language);
+		}
+
+		if (!res)
+			res = ast_play_and_wait(chan, (lastnum == 1) ? "vm-staroe" : "vm-staryh");
+	}
+
+	if (!res && !vms->newmessages && !vms->oldmessages) {
+		lastnum = 0;
+		res = ast_play_and_wait(chan, "vm-no");
+	}
+
+	if (!res) {
+		switch(lastnum) {
+		case 1:
+			res = ast_play_and_wait(chan, "vm-soobshenie");
+			break;
+		case 2:
+		case 3:
+		case 4:
+			res = ast_play_and_wait(chan, "vm-soobsheniya");
+			break;
+		default:
+			res = ast_play_and_wait(chan, "vm-soobsheniy");
+			break;
+		}
+	}
+
+	return res;
+}
+
+
 static int vm_intro(struct ast_channel *chan,struct vm_state *vms)
 {
 	/* Play voicemail intro - syntax is different for different languages */
@@ -4519,6 +4578,8 @@
 		return vm_intro_se(chan, vms);
 	} else if (!strcasecmp(chan->language, "no")) {	/* NORWEGIAN syntax */
 		return vm_intro_no(chan, vms);
+	} else if (!strcasecmp(chan->language, "ru")) {   /* RUSSIAN syntax */
+		return vm_intro_ru(chan, vms);
 	} else {					/* Default to ENGLISH */
 		return vm_intro_en(chan, vms);
 	}
@@ -6440,125 +6501,128 @@
 	if (!strncasecmp("macro",context,5)) /* Macro names in contexts are useless for our needs */
 		context = ast_variable_retrieve(msg_cfg, "message","macrocontext");
 
-	if (option == 3) {
-
+	switch (option) {
+	case 3:
 		if (!res)
 			res = play_message_datetime(chan, vmu, origtime, filename);
 		if (!res)
 			res = play_message_callerid(chan, vms, cid, context, 0);
-	} else if (option == 2) { /* Call back */
-
-		if (!ast_strlen_zero(cid)) {
-			ast_callerid_parse(cid, &name, &num);
-			while ((res > -1) && (res != 't')) {
-				switch(res) {
-					case '1':
-						if (num) {
-							/* Dial the CID number */
-							res = dialout(chan, vmu, num, vmu->callback);
-							if (res)
-								return 9;
-						} else {
-							res = '2';
-						}
-						break;
-
-					case '2':
-						/* Want to enter a different number, can only do this if there's a dialout context for this user */
-						if (!ast_strlen_zero(vmu->dialout)) {
-							res = dialout(chan, vmu, NULL, vmu->dialout);
-							if (res)
-								return 9;
-						} else {
-							ast_verbose( VERBOSE_PREFIX_3 "Caller can not specify callback number - no dialout context available\n");
-							res = ast_play_and_wait(chan, "vm-sorry");
-						}
-						return res;
-					case '*':
-						res = 't';
-						break;
-					case '3':
-					case '4':
-					case '5':
-					case '6':
-					case '7':
-					case '8':
-					case '9':
-					case '0':
-
-						res = ast_play_and_wait(chan, "vm-sorry");
-						retries++;
-						break;
-					default:
-						if (num) {
-							ast_verbose( VERBOSE_PREFIX_3 "Confirm CID number '%s' is number to use for callback\n", num);
-							res = ast_play_and_wait(chan, "vm-num-i-have");
-							if (!res)
-								res = play_message_callerid(chan, vms, num, vmu->context, 1);
-							if (!res)
-								res = ast_play_and_wait(chan, "vm-tocallnum");
-							/* Only prompt for a caller-specified number if there is a dialout context specified */
-							if (!ast_strlen_zero(vmu->dialout)) {
-								if (!res)
-									res = ast_play_and_wait(chan, "vm-calldiffnum");
-							}
-						} else {
-							res = ast_play_and_wait(chan, "vm-nonumber");
-							if (!ast_strlen_zero(vmu->dialout)) {
-								if (!res)
-									res = ast_play_and_wait(chan, "vm-toenternumber");
-							}
-						}
+		break;
+	case 2:	/* Call back */
+		if (ast_strlen_zero(cid))
+			break;
+
+		ast_callerid_parse(cid, &name, &num);
+		while ((res > -1) && (res != 't')) {
+			switch(res) {
+			case '1':
+				if (num) {
+					/* Dial the CID number */
+					res = dialout(chan, vmu, num, vmu->callback);
+					if (res)
+						return 9;
+				} else {
+					res = '2';
+				}
+				break;
+
+			case '2':
+				/* Want to enter a different number, can only do this if there's a dialout context for this user */
+				if (!ast_strlen_zero(vmu->dialout)) {
+					res = dialout(chan, vmu, NULL, vmu->dialout);
+					if (res)
+						return 9;
+				} else {
+					ast_verbose( VERBOSE_PREFIX_3 "Caller can not specify callback number - no dialout context available\n");
+					res = ast_play_and_wait(chan, "vm-sorry");
+				}
+				return res;
+			case '*':
+				res = 't';
+				break;
+			case '3':
+			case '4':
+			case '5':
+			case '6':
+			case '7':
+			case '8':
+			case '9':
+			case '0':
+
+				res = ast_play_and_wait(chan, "vm-sorry");
+				retries++;
+				break;
+			default:
+				if (num) {
+					ast_verbose( VERBOSE_PREFIX_3 "Confirm CID number '%s' is number to use for callback\n", num);
+					res = ast_play_and_wait(chan, "vm-num-i-have");
+					if (!res)
+						res = play_message_callerid(chan, vms, num, vmu->context, 1);
+					if (!res)
+						res = ast_play_and_wait(chan, "vm-tocallnum");
+					/* Only prompt for a caller-specified number if there is a dialout context specified */
+					if (!ast_strlen_zero(vmu->dialout)) {
 						if (!res)
-							res = ast_play_and_wait(chan, "vm-star-cancel");
+							res = ast_play_and_wait(chan, "vm-calldiffnum");
+					}
+				} else {
+					res = ast_play_and_wait(chan, "vm-nonumber");
+					if (!ast_strlen_zero(vmu->dialout)) {
 						if (!res)
-							res = ast_waitfordigit(chan, 6000);
-						if (!res)
-							retries++;
-						if (retries > 3)
-							res = 't';
-							break; 
-
-						}
-					if (res == 't')
-						res = 0;
-					else if (res == '*')
-						res = -1;
+							res = ast_play_and_wait(chan, "vm-toenternumber");
+					}
 				}
-			}
-
-	}
-	else if (option == 1) { /* Reply */
+				if (!res)
+					res = ast_play_and_wait(chan, "vm-star-cancel");
+				if (!res)
+					res = ast_waitfordigit(chan, 6000);
+				if (!res)
+					retries++;
+				if (retries > 3)
+					res = 't';
+				break; 
+
+			}
+			if (res == 't')
+				res = 0;
+			else if (res == '*')
+				res = -1;
+		}
+		break;
+
+	case 1:	/* Reply */
 		/* Send reply directly to sender */
-		if (!ast_strlen_zero(cid)) {
-			ast_callerid_parse(cid, &name, &num);
-			if (!num) {
-				ast_verbose(VERBOSE_PREFIX_3 "No CID number available, no reply sent\n");
+		if (ast_strlen_zero(cid))
+			break;
+
+		ast_callerid_parse(cid, &name, &num);
+		if (!num) {
+			ast_verbose(VERBOSE_PREFIX_3 "No CID number available, no reply sent\n");
+			if (!res)
+				res = ast_play_and_wait(chan, "vm-nonumber");
+			return res;
+		} else {
+			if (find_user(NULL, vmu->context, num)) {
+				struct leave_vm_options leave_options;
+
+				ast_verbose(VERBOSE_PREFIX_3 "Leaving voicemail for '%s' in context '%s'\n", num, vmu->context);
+				
+				memset(&leave_options, 0, sizeof(leave_options));
+				leave_options.record_gain = record_gain;
+				res = leave_voicemail(chan, num, &leave_options);
 				if (!res)
-					res = ast_play_and_wait(chan, "vm-nonumber");
+					res = 't';
 				return res;
 			} else {
-				if (find_user(NULL, vmu->context, num)) {
-					struct leave_vm_options leave_options;
-
-					ast_verbose(VERBOSE_PREFIX_3 "Leaving voicemail for '%s' in context '%s'\n", num, vmu->context);
-					
-					memset(&leave_options, 0, sizeof(leave_options));
-					leave_options.record_gain = record_gain;
-					res = leave_voicemail(chan, num, &leave_options);
-					if (!res)
-						res = 't';
-					return res;
-				} else {
-					/* Sender has no mailbox, can't reply */
-					ast_verbose( VERBOSE_PREFIX_3 "No mailbox number '%s' in context '%s', no reply sent\n", num, vmu->context);
-					ast_play_and_wait(chan, "vm-nobox");
-					res = 't';
-					return res;
-				}
-			} 
-			res = 0;
-		}
+				/* Sender has no mailbox, can't reply */
+				ast_verbose( VERBOSE_PREFIX_3 "No mailbox number '%s' in context '%s', no reply sent\n", num, vmu->context);
+				ast_play_and_wait(chan, "vm-nobox");
+				res = 't';
+				return res;
+			}
+		} 
+		res = 0;
+		break;
 	}
 
 	ast_config_destroy(msg_cfg);

Modified: team/rizzo/base/apps/app_while.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_while.c?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/apps/app_while.c (original)
+++ team/rizzo/base/apps/app_while.c Sat Mar  4 03:22:31 2006
@@ -101,7 +101,7 @@
 
 		if (ast_true(expr)) { 
 			if ((app = pbx_findapp(myapp))) {
-				res = pbx_exec(chan, app, mydata, 1);
+				res = pbx_exec(chan, app, mydata);
 			} else {
 				ast_log(LOG_WARNING, "Count not find application! (%s)\n", myapp);
 				res = -1;

Modified: team/rizzo/base/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/asterisk.c?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/asterisk.c (original)
+++ team/rizzo/base/asterisk.c Sat Mar  4 03:22:31 2006
@@ -85,6 +85,9 @@
 
 #if  defined(__FreeBSD__) || defined( __NetBSD__ ) || defined(SOLARIS)
 #include <netdb.h>
+#if defined(SOLARIS)
+extern int daemon(int, int);  /* defined in libresolv of all places */
+#endif
 #endif
 
 #include "asterisk.h"
@@ -1962,7 +1965,8 @@
 			snprintf(ast_config_AST_MONITOR_DIR, sizeof(ast_config_AST_MONITOR_DIR) - 1, "%s/monitor", v->value);
 		} else if (!strcasecmp(v->name, "astvarlibdir")) {
 			ast_copy_string(ast_config_AST_VAR_DIR, v->value, sizeof(ast_config_AST_VAR_DIR));
-			snprintf(ast_config_AST_DB, sizeof(ast_config_AST_DB), "%s/%s", v->value, "astdb");    
+			snprintf(ast_config_AST_DB, sizeof(ast_config_AST_DB), "%s/astdb", v->value);
+			snprintf(ast_config_AST_KEY_DIR, sizeof(ast_config_AST_KEY_DIR), "%s/keys", v->value);
 		} else if (!strcasecmp(v->name, "astlogdir")) {
 			ast_copy_string(ast_config_AST_LOG_DIR, v->value, sizeof(ast_config_AST_LOG_DIR));
 		} else if (!strcasecmp(v->name, "astagidir")) {
@@ -2228,7 +2232,7 @@
 			exit(1);
 		}
 		if (setgid(gr->gr_gid)) {
-			ast_log(LOG_WARNING, "Unable to setgid to %d (%s)\n", gr->gr_gid, rungroup);
+			ast_log(LOG_WARNING, "Unable to setgid to %d (%s)\n", (int)gr->gr_gid, rungroup);
 			exit(1);
 		}
 		if (setgroups(0, NULL)) {
@@ -2248,7 +2252,7 @@
 		}
 		if (!rungroup) {
 			if (setgid(pw->pw_gid)) {
-				ast_log(LOG_WARNING, "Unable to setgid to %d!\n", pw->pw_gid);
+				ast_log(LOG_WARNING, "Unable to setgid to %d!\n", (int)pw->pw_gid);
 				exit(1);
 			}
 			if (initgroups(pw->pw_name, pw->pw_gid)) {
@@ -2257,7 +2261,7 @@
 			}
 		}
 		if (setuid(pw->pw_uid)) {
-			ast_log(LOG_WARNING, "Unable to setuid to %d (%s)\n", pw->pw_uid, runuser);
+			ast_log(LOG_WARNING, "Unable to setuid to %d (%s)\n", (int)pw->pw_uid, runuser);
 			exit(1);
 		}
 		setenv("ASTERISK_ALREADY_NONROOT","yes",1);
@@ -2322,7 +2326,7 @@
 	unlink(ast_config_AST_PID);
 	f = fopen(ast_config_AST_PID, "w");
 	if (f) {
-		fprintf(f, "%d\n", getpid());
+		fprintf(f, "%d\n", (int)getpid());
 		fclose(f);
 	} else
 		ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));
@@ -2333,7 +2337,7 @@
 		unlink(ast_config_AST_PID);
 		f = fopen(ast_config_AST_PID, "w");
 		if (f) {
-			fprintf(f, "%d\n", getpid());
+			fprintf(f, "%d\n", (int)getpid());
 			fclose(f);
 		} else
 			ast_log(LOG_WARNING, "Unable to open pid file '%s': %s\n", ast_config_AST_PID, strerror(errno));

Modified: team/rizzo/base/asterisk.sgml
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/asterisk.sgml?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/asterisk.sgml (original)
+++ team/rizzo/base/asterisk.sgml Sat Mar  4 03:22:31 2006
@@ -27,6 +27,7 @@
 <arg><option>-G </option><replaceable class="parameter">group</replaceable></arg>
 <arg><option>-x </option><replaceable class="parameter">command</replaceable></arg>
 <arg><option>-M </option><replaceable class="parameter">value</replaceable></arg>
+<arg><option>-L </option><replaceable class="parameter">loadaverage</replaceable></arg>
 	</cmdsynopsis>
 	<cmdsynopsis>
 

Modified: team/rizzo/base/build_tools/make_build_h
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/build_tools/make_build_h?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/build_tools/make_build_h (original)
+++ team/rizzo/base/build_tools/make_build_h Sat Mar  4 03:22:31 2006
@@ -3,7 +3,11 @@
 KERNEL=`uname -r`
 MACHINE=`uname -m`
 OS=`uname -s`
-USER=`whoami`
+if [ `uname -s` = "SunOS" ]; then
+  USER=`/usr/xpg4/bin/id -un`
+else
+  USER=`id -un`
+fi
 DATE=`date -u "+%Y-%m-%d %H:%M:%S"`
 cat << END
 /*

Modified: team/rizzo/base/build_tools/make_svn_branch_name
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/build_tools/make_svn_branch_name?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/build_tools/make_svn_branch_name (original)
+++ team/rizzo/base/build_tools/make_svn_branch_name Sat Mar  4 03:22:31 2006
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-PARTS=`LANG=C svn info | grep URL | awk '{print $2;}' | sed -e s:^.*/svn/asterisk/:: | sed -e 's:/: :g'`
+PARTS=`LANG=C svn info | grep URL | awk '{print $2;}' | sed -e 's:^.*/svn/asterisk/::' | sed -e 's:/: :g'`
 BRANCH=0
 TEAM=0
 

Modified: team/rizzo/base/cdr.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/cdr.c?rev=11773&r1=11772&r2=11773&view=diff
==============================================================================
--- team/rizzo/base/cdr.c (original)
+++ team/rizzo/base/cdr.c Sat Mar  4 03:22:31 2006
@@ -167,11 +167,10 @@
 */
 struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr) 
 {
-	struct ast_cdr *newcdr;
-
-	if (!(newcdr = ast_cdr_alloc())) {
+	struct ast_cdr *newcdr = ast_cdr_alloc();
+
+	if (!newcdr)
 		return NULL;
-	}
 
 	memcpy(newcdr, cdr, sizeof(*newcdr));
 	/* The varshead is unusable, volatile even, after the memcpy so we take care of that here */
@@ -184,31 +183,38 @@
 
 static const char *ast_cdr_getvar_internal(struct ast_cdr *cdr, const char *name, int recur) 
 {
-	struct ast_var_t *variables;
-	struct varshead *headp;
-
 	if (ast_strlen_zero(name))
 		return NULL;
 
-	while (cdr) {
-		headp = &cdr->varshead;
+	for (; cdr; cdr = recur ? cdr->next : NULL) {
+		struct ast_var_t *variables;
+		struct varshead *headp = &cdr->varshead;
 		AST_LIST_TRAVERSE(headp, variables, entries) {
 			if (!strcasecmp(name, ast_var_name(variables)))
 				return ast_var_value(variables);
 		}
-		if (!recur)
-			break;
-		cdr = cdr->next;
 	}
 
 	return NULL;
+}
+
+static void cdr_get_tv(struct timeval tv, const char *fmt, char *buf, int bufsize)
+{
+	if (fmt == NULL) {	/* raw mode */
+		snprintf(buf, bufsize, "%ld.%06ld", (long)tv.tv_sec, (long)tv.tv_usec);
+	} else {  
+		time_t t = tv.tv_sec;
+		if (t) {
+			struct tm tm;
+			localtime_r(&t, &tm);
+			strftime(buf, bufsize, fmt, &tm);
+		}
+	}
 }
 
 /*! CDR channel variable retrieval */
 void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur, int raw) 
 {
-	struct tm tm;
-	time_t t;
 	const char *fmt = "%Y-%m-%d %T";
 	const char *varbuf;
 
@@ -232,49 +238,25 @@
 		ast_copy_string(workspace, cdr->lastapp, workspacelen);
 	else if (!strcasecmp(name, "lastdata"))
 		ast_copy_string(workspace, cdr->lastdata, workspacelen);
-	else if (!strcasecmp(name, "start")) {
-		if (raw) {
-			snprintf(workspace, workspacelen, "%ld.%06ld", (long)cdr->start.tv_sec, (long)cdr->start.tv_usec);
-		} else {
-			t = cdr->start.tv_sec;
-			if (t) {
-				localtime_r(&t, &tm);
-				strftime(workspace, workspacelen, fmt, &tm);
-			}
-		}
-	} else if (!strcasecmp(name, "answer")) {
-		if (raw) {
-			snprintf(workspace, workspacelen, "%ld.%06ld", (long)cdr->answer.tv_sec, (long)cdr->answer.tv_usec);
-		} else {
-			t = cdr->answer.tv_sec;
-			if (t) {
-				localtime_r(&t, &tm);
-				strftime(workspace, workspacelen, fmt, &tm);
-			}
-		}
-	} else if (!strcasecmp(name, "end")) {
-		if (raw) {
-			snprintf(workspace, workspacelen, "%ld.%06ld", (long)cdr->end.tv_sec, (long)cdr->end.tv_usec);
-		} else {
-			t = cdr->end.tv_sec;
-			if (t) {
-				localtime_r(&t, &tm);
-				strftime(workspace, workspacelen, fmt, &tm);
-			}
-		}
-	} else if (!strcasecmp(name, "duration"))
-		snprintf(workspace, workspacelen, "%d", cdr->duration);
+	else if (!strcasecmp(name, "start"))
+		cdr_get_tv(cdr->start, raw ? NULL : fmt, workspace, workspacelen);
+	else if (!strcasecmp(name, "answer"))
+		cdr_get_tv(cdr->answer, raw ? NULL : fmt, workspace, workspacelen);
+	else if (!strcasecmp(name, "end"))
+		cdr_get_tv(cdr->end, raw ? NULL : fmt, workspace, workspacelen);
+	else if (!strcasecmp(name, "duration"))
+		snprintf(workspace, workspacelen, "%ld", cdr->duration);
 	else if (!strcasecmp(name, "billsec"))
-		snprintf(workspace, workspacelen, "%d", cdr->billsec);
+		snprintf(workspace, workspacelen, "%ld", cdr->billsec);
 	else if (!strcasecmp(name, "disposition")) {
 		if (raw) {
-			snprintf(workspace, workspacelen, "%d", cdr->disposition);
+			snprintf(workspace, workspacelen, "%ld", cdr->disposition);
 		} else {
 			ast_copy_string(workspace, ast_cdr_disp2str(cdr->disposition), workspacelen);
 		}
 	} else if (!strcasecmp(name, "amaflags")) {
 		if (raw) {
-			snprintf(workspace, workspacelen, "%d", cdr->amaflags);
+			snprintf(workspace, workspacelen, "%ld", cdr->amaflags);
 		} else {
 			ast_copy_string(workspace, ast_cdr_flags2str(cdr->amaflags), workspacelen);
 		}
@@ -317,7 +299,7 @@
 		return -1;
 	}
 
-	while (cdr) {
+	for (; cdr; cdr = recur ? cdr->next : NULL) {
 		headp = &cdr->varshead;
 		AST_LIST_TRAVERSE_SAFE_BEGIN(headp, newvariable, entries) {
 			if (!strcasecmp(ast_var_name(newvariable), name)) {
@@ -333,12 +315,6 @@
 			newvariable = ast_var_assign(name, value);
 			AST_LIST_INSERT_HEAD(headp, newvariable, entries);
 		}
-
-		if (!recur) {
-			break;
-		}
-
-		cdr = cdr->next;
 	}
 
 	return 0;
@@ -413,33 +389,36 @@
 
 void ast_cdr_free_vars(struct ast_cdr *cdr, int recur)
 {
-	struct varshead *headp;
-	struct ast_var_t *vardata;
 
 	/* clear variables */
+	for (; cdr; cdr = recur ? cdr->next : NULL) {
+		struct ast_var_t *vardata;
+		struct varshead *headp = &cdr->varshead;
+		while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries)))
+			ast_var_delete(vardata);
+	}
+}
+
+/*! \brief  print a warning if cdr already posted */
+static void check_post(struct ast_cdr *cdr)
+{
+	if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
+		ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", S_OR(cdr->channel, "<unknown>"));
+}
+
+/*! \brief  print a warning if cdr already started */
+static void check_start(struct ast_cdr *cdr)
+{
+	if (!ast_tvzero(cdr->start))
+		ast_log(LOG_WARNING, "CDR on channel '%s' already started\n", S_OR(cdr->channel, "<unknown>"));
+}
+
+void ast_cdr_free(struct ast_cdr *cdr)
+{
+
 	while (cdr) {
-		headp = &cdr->varshead;
-		while (!AST_LIST_EMPTY(headp)) {
-			vardata = AST_LIST_REMOVE_HEAD(headp, entries);
-			ast_var_delete(vardata);
-		}
-
-		if (!recur) {
-			break;
-		}
-
-		cdr = cdr->next;
-	}
-}
-
-void ast_cdr_free(struct ast_cdr *cdr)
-{
-	char *chan;
-	struct ast_cdr *next; 
-
-	while (cdr) {
-		next = cdr->next;
-		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
+		struct ast_cdr *next = cdr->next;
+		char *chan = S_OR(cdr->channel, "<unknown>");
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_POSTED) && !ast_test_flag(cdr, AST_CDR_FLAG_POST_DISABLED))
 			ast_log(LOG_WARNING, "CDR on channel '%s' not posted\n", chan);
 		if (ast_tvzero(cdr->end))
@@ -462,62 +441,46 @@
 {
 	char *chan; 
 
-	while (cdr) {
+	for (; cdr; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
-			chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-			if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-				ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
-			if (!ast_tvzero(cdr->start))
-				ast_log(LOG_WARNING, "CDR on channel '%s' already started\n", chan);
+			chan = S_OR(cdr->channel, "<unknown>");
+			check_post(cdr);
+			check_start(cdr);
 			cdr->start = ast_tvnow();
 		}
-		cdr = cdr->next;
 	}
 }
 
 void ast_cdr_answer(struct ast_cdr *cdr)
 {
-	char *chan; 
-
-	while (cdr) {
-		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+
+	for (; cdr; cdr = cdr->next) {
+		check_post(cdr);
 		if (cdr->disposition < AST_CDR_ANSWERED)
 			cdr->disposition = AST_CDR_ANSWERED;
 		if (ast_tvzero(cdr->answer))
 			cdr->answer = ast_tvnow();
-		cdr = cdr->next;
 	}
 }
 
 void ast_cdr_busy(struct ast_cdr *cdr)
 {
-	char *chan; 
-
-	while (cdr) {
+
+	for (; cdr; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
-			chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-			if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-				ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+			check_post(cdr);
 			if (cdr->disposition < AST_CDR_BUSY)
 				cdr->disposition = AST_CDR_BUSY;
 		}
-		cdr = cdr->next;
 	}
 }
 
 void ast_cdr_failed(struct ast_cdr *cdr)
 {
-	char *chan; 
-
-	while (cdr) {
-		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+	for (; cdr; cdr = cdr->next) {
+		check_post(cdr);
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
 			cdr->disposition = AST_CDR_FAILED;
-		cdr = cdr->next;
 	}
 }
 
@@ -525,7 +488,7 @@
 {
 	int res = 0;
 
-	while (cdr) {
+	for (; cdr; cdr = cdr->next) {
 		switch(cause) {
 		case AST_CAUSE_BUSY:
 			ast_cdr_busy(cdr);
@@ -542,34 +505,25 @@
 			res = -1;
 			ast_log(LOG_WARNING, "Cause not handled\n");
 		}
-		cdr = cdr->next;
 	}
 	return res;
 }
 
 void ast_cdr_setdestchan(struct ast_cdr *cdr, const char *chann)
 {
-	char *chan; 
-
-	while (cdr) {
-		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+	for (; cdr; cdr = cdr->next) {
+		check_post(cdr);
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED))
 			ast_copy_string(cdr->dstchannel, chann, sizeof(cdr->dstchannel));
-		cdr = cdr->next;
 	}
 }
 
 void ast_cdr_setapp(struct ast_cdr *cdr, char *app, char *data)
 {
-	char *chan; 
-
-	while (cdr) {
+
+	for (; cdr; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
-			chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-			if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-				ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+			check_post(cdr);
 			if (!app)
 				app = "";
 			ast_copy_string(cdr->lastapp, app, sizeof(cdr->lastapp));
@@ -577,19 +531,17 @@
 				data = "";
 			ast_copy_string(cdr->lastdata, data, sizeof(cdr->lastdata));
 		}
-		cdr = cdr->next;
 	}
 }
 
 int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *c)
 {
 	char tmp[AST_MAX_EXTENSION] = "";
-	char *num;
-
-	while (cdr) {
+
+	for (; cdr; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
 			/* Grab source from ANI or normal Caller*ID */
-			num = c->cid.cid_ani ? c->cid.cid_ani : c->cid.cid_num;
+			char *num = c->cid.cid_ani ? c->cid.cid_ani : c->cid.cid_num; /* XXX ast_strlen_zero ? */
 			
 			if (c->cid.cid_name && num)
 				snprintf(tmp, sizeof(tmp), "\"%s\" <%s>", c->cid.cid_name, num);
@@ -600,7 +552,6 @@
 			ast_copy_string(cdr->clid, tmp, sizeof(cdr->clid));
 			ast_copy_string(cdr->src, num ? num : "", sizeof(cdr->src));
 		}
-		cdr = cdr->next;
 	}
 
 	return 0;
@@ -613,9 +564,9 @@
 	char *num;
 	char tmp[AST_MAX_EXTENSION] = "";
 
-	while (cdr) {
+	for ( ; cdr ; cdr = cdr->next) {
 		if (!ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
-			chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
+			chan = S_OR(cdr->channel, "<unknown>");
 			if (!ast_strlen_zero(cdr->channel)) 
 				ast_log(LOG_WARNING, "CDR already initialized on '%s'\n", chan); 
 			ast_copy_string(cdr->channel, c->name, sizeof(cdr->channel));
@@ -640,24 +591,18 @@
 			/* Unique call identifier */
 			ast_copy_string(cdr->uniqueid, c->uniqueid, sizeof(cdr->uniqueid));
 		}
-		cdr = cdr->next;
 	}
 	return 0;
 }
 
 void ast_cdr_end(struct ast_cdr *cdr)
 {
-	char *chan;
-
-	while (cdr) {
-		chan = !ast_strlen_zero(cdr->channel) ? cdr->channel : "<unknown>";
-		if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
-			ast_log(LOG_WARNING, "CDR on channel '%s' already posted\n", chan);
+	for ( ; cdr ; cdr = cdr->next) {
+		check_post(cdr);
 		if (ast_tvzero(cdr->start))
-			ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", chan);
+			ast_log(LOG_WARNING, "CDR on channel '%s' has not started\n", S_OR(cdr->channel, "<unknown>"));
 		if (ast_tvzero(cdr->end))
 			cdr->end = ast_tvnow();
-		cdr = cdr->next;
 	}
 }
 
@@ -695,10 +640,9 @@
 	struct ast_cdr *cdr = chan->cdr;
 
 	ast_string_field_set(chan, accountcode, account);
-	while (cdr) {

[... 2390 lines stripped ...]


More information about the asterisk-commits mailing list