[asterisk-commits] branch bweschke/bug_5374 - r8061 in /team/bweschke/bug_5374: ./ apps/ cdr/ ch...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Jan 13 11:50:38 CST 2006


Author: bweschke
Date: Fri Jan 13 11:50:10 2006
New Revision: 8061

URL: http://svn.digium.com/view/asterisk?rev=8061&view=rev
Log:
 SVNMerge: Bringing this up to date with /trunk and also bringing in DEA's Makefile change.


Added:
    team/bweschke/bug_5374/apps/app_morsecode.c
      - copied unchanged from r8060, trunk/apps/app_morsecode.c
    team/bweschke/bug_5374/contrib/init.d/rc.suse.asterisk
      - copied unchanged from r8060, trunk/contrib/init.d/rc.suse.asterisk
    team/bweschke/bug_5374/contrib/scripts/safe_asterisk_restart
      - copied unchanged from r8060, trunk/contrib/scripts/safe_asterisk_restart
    team/bweschke/bug_5374/formats/format_h264.c
      - copied unchanged from r8060, trunk/formats/format_h264.c
    team/bweschke/bug_5374/funcs/func_base64.c
      - copied unchanged from r8060, trunk/funcs/func_base64.c
    team/bweschke/bug_5374/funcs/func_rand.c
      - copied unchanged from r8060, trunk/funcs/func_rand.c
    team/bweschke/bug_5374/include/asterisk/stringfields.h
      - copied unchanged from r8060, trunk/include/asterisk/stringfields.h
    team/bweschke/bug_5374/include/asterisk/udptl.h
      - copied unchanged from r8060, trunk/include/asterisk/udptl.h
    team/bweschke/bug_5374/udptl.c
      - copied unchanged from r8060, trunk/udptl.c
Removed:
    team/bweschke/bug_5374/ast_expr.y
    team/bweschke/bug_5374/channels/chan_modem.c
    team/bweschke/bug_5374/channels/chan_modem_aopen.c
    team/bweschke/bug_5374/channels/chan_modem_bestdata.c
    team/bweschke/bug_5374/channels/chan_modem_i4l.c
    team/bweschke/bug_5374/include/asterisk/vmodem.h
Modified:
    team/bweschke/bug_5374/   (props changed)
    team/bweschke/bug_5374/Makefile
    team/bweschke/bug_5374/UPGRADE.txt
    team/bweschke/bug_5374/app.c
    team/bweschke/bug_5374/apps/   (props changed)
    team/bweschke/bug_5374/apps/Makefile
    team/bweschke/bug_5374/apps/app_adsiprog.c
    team/bweschke/bug_5374/apps/app_alarmreceiver.c
    team/bweschke/bug_5374/apps/app_authenticate.c
    team/bweschke/bug_5374/apps/app_chanspy.c
    team/bweschke/bug_5374/apps/app_curl.c
    team/bweschke/bug_5374/apps/app_dial.c
    team/bweschke/bug_5374/apps/app_dictate.c
    team/bweschke/bug_5374/apps/app_directed_pickup.c
    team/bweschke/bug_5374/apps/app_directory.c
    team/bweschke/bug_5374/apps/app_disa.c
    team/bweschke/bug_5374/apps/app_externalivr.c
    team/bweschke/bug_5374/apps/app_festival.c
    team/bweschke/bug_5374/apps/app_meetme.c
    team/bweschke/bug_5374/apps/app_milliwatt.c
    team/bweschke/bug_5374/apps/app_mixmonitor.c
    team/bweschke/bug_5374/apps/app_page.c
    team/bweschke/bug_5374/apps/app_parkandannounce.c
    team/bweschke/bug_5374/apps/app_playback.c
    team/bweschke/bug_5374/apps/app_privacy.c
    team/bweschke/bug_5374/apps/app_queue.c
    team/bweschke/bug_5374/apps/app_read.c
    team/bweschke/bug_5374/apps/app_rpt.c
    team/bweschke/bug_5374/apps/app_stack.c
    team/bweschke/bug_5374/apps/app_voicemail.c
    team/bweschke/bug_5374/ast_expr2.fl
    team/bweschke/bug_5374/ast_expr2f.c
    team/bweschke/bug_5374/asterisk.c
    team/bweschke/bug_5374/astmm.c
    team/bweschke/bug_5374/autoservice.c
    team/bweschke/bug_5374/callerid.c
    team/bweschke/bug_5374/cdr/   (props changed)
    team/bweschke/bug_5374/cdr.c
    team/bweschke/bug_5374/channel.c
    team/bweschke/bug_5374/channels/   (props changed)
    team/bweschke/bug_5374/channels/Makefile
    team/bweschke/bug_5374/channels/chan_agent.c
    team/bweschke/bug_5374/channels/chan_alsa.c
    team/bweschke/bug_5374/channels/chan_iax2.c
    team/bweschke/bug_5374/channels/chan_local.c
    team/bweschke/bug_5374/channels/chan_oss.c
    team/bweschke/bug_5374/channels/chan_phone.c
    team/bweschke/bug_5374/channels/chan_sip.c
    team/bweschke/bug_5374/channels/chan_zap.c
    team/bweschke/bug_5374/cli.c
    team/bweschke/bug_5374/codecs/   (props changed)
    team/bweschke/bug_5374/codecs/ilbc/   (props changed)
    team/bweschke/bug_5374/codecs/lpc10/   (props changed)
    team/bweschke/bug_5374/config.c
    team/bweschke/bug_5374/configs/agents.conf.sample
    team/bweschke/bug_5374/configs/extensions.conf.sample
    team/bweschke/bug_5374/configs/features.conf.sample
    team/bweschke/bug_5374/configs/manager.conf.sample
    team/bweschke/bug_5374/configs/queues.conf.sample
    team/bweschke/bug_5374/configs/sip.conf.sample
    team/bweschke/bug_5374/configs/voicemail.conf.sample
    team/bweschke/bug_5374/configs/zapata.conf.sample
    team/bweschke/bug_5374/contrib/scripts/managerproxy.pl
    team/bweschke/bug_5374/db.c
    team/bweschke/bug_5374/db1-ast/   (props changed)
    team/bweschke/bug_5374/dns.c
    team/bweschke/bug_5374/doc/CODING-GUIDELINES
    team/bweschke/bug_5374/doc/README.cdr
    team/bweschke/bug_5374/doc/README.variables
    team/bweschke/bug_5374/editline/   (props changed)
    team/bweschke/bug_5374/file.c
    team/bweschke/bug_5374/formats/   (props changed)
    team/bweschke/bug_5374/formats/Makefile
    team/bweschke/bug_5374/formats/format_pcm.c
    team/bweschke/bug_5374/formats/format_pcm_alaw.c
    team/bweschke/bug_5374/frame.c
    team/bweschke/bug_5374/funcs/   (props changed)
    team/bweschke/bug_5374/funcs/Makefile
    team/bweschke/bug_5374/funcs/func_cdr.c
    team/bweschke/bug_5374/funcs/func_cut.c
    team/bweschke/bug_5374/funcs/func_math.c
    team/bweschke/bug_5374/funcs/func_md5.c
    team/bweschke/bug_5374/funcs/func_moh.c
    team/bweschke/bug_5374/image.c
    team/bweschke/bug_5374/include/asterisk/app.h
    team/bweschke/bug_5374/include/asterisk/astmm.h
    team/bweschke/bug_5374/include/asterisk/astobj.h
    team/bweschke/bug_5374/include/asterisk/callerid.h
    team/bweschke/bug_5374/include/asterisk/channel.h
    team/bweschke/bug_5374/include/asterisk/chanspy.h
    team/bweschke/bug_5374/include/asterisk/dns.h
    team/bweschke/bug_5374/include/asterisk/doxyref.h
    team/bweschke/bug_5374/include/asterisk/frame.h
    team/bweschke/bug_5374/include/asterisk/image.h
    team/bweschke/bug_5374/include/asterisk/linkedlists.h
    team/bweschke/bug_5374/include/asterisk/manager.h
    team/bweschke/bug_5374/include/asterisk/pbx.h
    team/bweschke/bug_5374/include/asterisk/rtp.h
    team/bweschke/bug_5374/include/asterisk/strings.h
    team/bweschke/bug_5374/include/asterisk/translate.h
    team/bweschke/bug_5374/include/asterisk/utils.h
    team/bweschke/bug_5374/manager.c
    team/bweschke/bug_5374/pbx/   (props changed)
    team/bweschke/bug_5374/pbx.c
    team/bweschke/bug_5374/pbx/pbx_config.c
    team/bweschke/bug_5374/pbx/pbx_spool.c
    team/bweschke/bug_5374/res/   (props changed)
    team/bweschke/bug_5374/res/res_features.c
    team/bweschke/bug_5374/res/res_osp.c
    team/bweschke/bug_5374/rtp.c
    team/bweschke/bug_5374/say.c
    team/bweschke/bug_5374/stdtime/   (props changed)
    team/bweschke/bug_5374/translate.c
    team/bweschke/bug_5374/utils.c

Propchange: team/bweschke/bug_5374/
------------------------------------------------------------------------------
--- svnmerge-blocked (original)
+++ svnmerge-blocked Fri Jan 13 11:50:10 2006
@@ -1,1 +1,1 @@
-/branches/1.2:7497
+/branches/1.2:7497,7915,7960,7965,7970,7976

Propchange: team/bweschke/bug_5374/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jan 13 11:50:10 2006
@@ -1,2 +1,2 @@
 /branches/1.2:1-7351
-/trunk:1-7695
+/trunk:1-8060

Modified: team/bweschke/bug_5374/Makefile
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/Makefile?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/Makefile (original)
+++ team/bweschke/bug_5374/Makefile Fri Jan 13 11:50:10 2006
@@ -346,7 +346,7 @@
 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
 	translate.o file.o say.o pbx.o cli.o md5.o term.o \
 	ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
-	cdr.o tdd.o acl.o rtp.o manager.o asterisk.o \
+	cdr.o tdd.o acl.o rtp.o udptl.o manager.o asterisk.o \
 	dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
 	astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
 	utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
@@ -416,6 +416,8 @@
 LIBS+=-lssl
 
 INSTALL=install
+
+CFLAGS+=-DT38_SUPPORT
 
 _all: all
 	@echo " +--------- Asterisk Build Complete ---------+"  
@@ -767,6 +769,8 @@
 		echo ";astctlowner = root" ; \
 		echo ";astctlgroup = apache" ; \
 		echo ";astctl = asterisk.ctl" ; \
+		echo ";[options]" ; \
+		echo ";silence_suppression = yes" ; \
 		) > $(DESTDIR)$(ASTCONFPATH) ; \
 	else \
 		echo "Skipping asterisk.conf creation"; \

Modified: team/bweschke/bug_5374/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/UPGRADE.txt?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/UPGRADE.txt (original)
+++ team/bweschke/bug_5374/UPGRADE.txt Fri Jan 13 11:50:10 2006
@@ -18,6 +18,9 @@
 * The application SetVar has been renamed to Set.  The syntax SetVar was marked
   deprecated in version 1.2 and is no longer recognized in this version.
 
+* app_read has been updated to use the newer options codes, using "skip" or
+  "noanswer" will not work.  Use s or n.  Also there is a new feature i, for
+  using indication tones, so typing in skip would give you unexpected results.
 Variables:
 
 * The builtin variables ${CALLERID}, ${CALLERIDNAME}, ${CALLERIDNUM},
@@ -26,3 +29,6 @@
   functions.  You are encouraged to move towards the associated dialplan
   function, as these variables will be removed in a future release.
 
+The SIP channel:
+
+* The "incominglimit" setting is replaced by the "call-limit" setting in sip.conf.

Modified: team/bweschke/bug_5374/app.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/app.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/app.c (original)
+++ team/bweschke/bug_5374/app.c Fri Jan 13 11:50:10 2006
@@ -279,47 +279,57 @@
 	return 0;
 }
 
-int ast_dtmf_stream(struct ast_channel *chan,struct ast_channel *peer,char *digits,int between) 
-{
-	char *ptr;
+int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between) 
+{
+	const char *ptr;
 	int res = 0;
-	struct ast_frame f;
+	struct ast_frame f = {
+		.frametype = AST_FRAME_DTMF,
+		.src = "ast_dtmf_stream"
+	};
+
 	if (!between)
 		between = 100;
 
 	if (peer)
 		res = ast_autoservice_start(peer);
 
-	if (!res) {
-		res = ast_waitfor(chan,100);
-		if (res > -1) {
-			for (ptr=digits; *ptr; ptr++) {
-				if (*ptr == 'w') {
-					res = ast_safe_sleep(chan, 500);
-					if (res) 
-						break;
-					continue;
-				}
-				memset(&f, 0, sizeof(f));
-				f.frametype = AST_FRAME_DTMF;
+	if (!res)
+		res = ast_waitfor(chan, 100);
+
+	/* ast_waitfor will return the number of remaining ms on success */
+	if (res < 0)
+		return res;
+
+	for (ptr = digits; *ptr; ptr++) {
+		if (*ptr == 'w') {
+			/* 'w' -- wait half a second */
+			if ((res = ast_safe_sleep(chan, 500)))
+				break;
+		} else if (strchr("0123456789*#abcdfABCDF", *ptr)) {
+			/* Character represents valid DTMF */
+			if (*ptr == 'f' || *ptr == 'F') {
+				/* ignore return values if not supported by channel */
+				ast_indicate(chan, AST_CONTROL_FLASH);
+			} else {
 				f.subclass = *ptr;
-				f.src = "ast_dtmf_stream";
-				if (strchr("0123456789*#abcdABCD",*ptr)==NULL) {
-					ast_log(LOG_WARNING, "Illegal DTMF character '%c' in string. (0-9*#aAbBcCdD allowed)\n",*ptr);
-				} else {
-					res = ast_write(chan, &f);
-					if (res) 
-						break;
-					/* pause between digits */
-					res = ast_safe_sleep(chan,between);
-					if (res) 
-						break;
-				}
-			}
-		}
-		if (peer)
-			res = ast_autoservice_stop(peer);
-	}
+				if ((res = ast_write(chan, &f)))
+					break;
+			}
+			/* pause between digits */
+			if ((res = ast_safe_sleep(chan, between)))
+				break;
+		} else
+			ast_log(LOG_WARNING, "Illegal DTMF character '%c' in string. (0-9*#aAbBcCdD allowed)\n",*ptr);
+	}
+
+	if (peer) {
+		/* Stop autoservice on the peer channel, but don't overwrite any error condition 
+		   that has occurred previously while acting on the primary channel */
+		if (ast_autoservice_stop(peer) && !res)
+			res = -1;
+	}
+
 	return res;
 }
 

Propchange: team/bweschke/bug_5374/apps/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Jan 13 11:50:10 2006
@@ -1,1 +1,3 @@
 .depend
+*.a
+*.so

Modified: team/bweschke/bug_5374/apps/Makefile
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/Makefile?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/Makefile (original)
+++ team/bweschke/bug_5374/apps/Makefile Fri Jan 13 11:50:10 2006
@@ -24,7 +24,8 @@
      app_setcdruserfield.so app_settransfercapability.so app_softhangup.so     \
      app_stack.so app_system.so app_talkdetect.so app_test.so app_transfer.so  \
      app_userevent.so app_url.so app_verbose.so app_voicemail.so               \
-     app_waitforring.so app_waitforsilence.so app_while.so app_zapateller.so
+     app_waitforring.so app_waitforsilence.so app_while.so app_zapateller.so   \
+     app_morsecode.so
      
 #
 # Obsolete things...

Modified: team/bweschke/bug_5374/apps/app_adsiprog.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_adsiprog.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_adsiprog.c (original)
+++ team/bweschke/bug_5374/apps/app_adsiprog.c Fri Jan 13 11:50:10 2006
@@ -1359,13 +1359,10 @@
 		ast_log(LOG_WARNING, "Can't open file '%s'\n", fn);
 		return NULL;
 	}
-	scr = malloc(sizeof(struct adsi_script));
-	if (!scr) {
+	if (!(scr = ast_calloc(1, sizeof(*scr)))) {
 		fclose(f);
-		ast_log(LOG_WARNING, "Out of memory loading script '%s'\n", fn);
 		return NULL;
 	}
-	memset(scr, 0, sizeof(struct adsi_script));
 	/* Create "main" as first subroutine */
 	getsubbyname(scr, "main", NULL, 0);
 	while(!feof(f)) {

Modified: team/bweschke/bug_5374/apps/app_alarmreceiver.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_alarmreceiver.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_alarmreceiver.c (original)
+++ team/bweschke/bug_5374/apps/app_alarmreceiver.c Fri Jan 13 11:50:10 2006
@@ -56,6 +56,7 @@
 #include "asterisk/localtime.h"
 #include "asterisk/callerid.h"
 #include "asterisk/astdb.h"
+#include "asterisk/utils.h"
 
 #define ALMRCV_CONFIG "alarmreceiver.conf"
 #define ADEMCO_CONTACT_ID "ADEMCO_CONTACT_ID"
@@ -579,17 +580,11 @@
 
 		events_received++;
 		
-		/* Queue the Event */
-
-		if((enew = malloc(sizeof(event_node_t))) == NULL){
-			if(option_verbose >= 1)
-				ast_verbose(VERBOSE_PREFIX_1 "AlarmReceiver: Failed to allocate memory\n");
-			ast_log(LOG_WARNING, "AlarmReceiver Failed to allocate memory\n");
+		/* Queue the Event */		
+		if (!(enew = ast_calloc(1, sizeof(*enew)))) {
 			res = -1;
-                        break;
-		}
-
-		memset(enew, 0, sizeof(event_node_t));
+			break;
+		}
 		
 		enew->next = NULL;
 		ast_copy_string(enew->data, event, sizeof(enew->data));

Modified: team/bweschke/bug_5374/apps/app_authenticate.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_authenticate.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_authenticate.c (original)
+++ team/bweschke/bug_5374/apps/app_authenticate.c Fri Jan 13 11:50:10 2006
@@ -44,6 +44,23 @@
 #include "asterisk/app.h"
 #include "asterisk/astdb.h"
 #include "asterisk/utils.h"
+#include "asterisk/options.h"
+
+enum {
+	OPT_ACCOUNT = (1 << 0),
+	OPT_DATABASE = (1 << 1),
+	OPT_JUMP = (1 << 2),
+	OPT_MULTIPLE = (1 << 3),
+	OPT_REMOVE = (1 << 4),
+} auth_option_flags;
+
+AST_APP_OPTIONS(auth_app_options, {
+	AST_APP_OPTION('a', OPT_ACCOUNT),
+	AST_APP_OPTION('d', OPT_DATABASE),
+	AST_APP_OPTION('j', OPT_JUMP),
+	AST_APP_OPTION('m', OPT_MULTIPLE),
+	AST_APP_OPTION('r', OPT_REMOVE),
+});
 
 static char *tdesc = "Authentication Application";
 
@@ -52,9 +69,9 @@
 static char *synopsis = "Authenticate a user";
 
 static char *descrip =
-"  Authenticate(password[|options]): This application asks the caller to enter a\n"
-"given password in order to continue dialplan execution. If the password begins\n"
-"with the '/' character, it is interpreted as a file which contains a list of\n"
+"  Authenticate(password[|options[|maxdigits]]): This application asks the caller\n"
+"to enter a given password in order to continue dialplan execution. If the password\n"
+"begins with the '/' character, it is interpreted as a file which contains a list of\n"
 "valid passwords, listed 1 password per line in the file.\n"
 "  When using a database key, the value associated with the key can be anything.\n"
 "Users have three attempts to authenticate before the channel is hung up. If the\n"
@@ -69,6 +86,10 @@
 "         the file. When one of the passwords is matched, the channel will have\n"
 "         its account code set to the corresponding account code in the file.\n"
 "     r - Remove the database key upon successful entry (valid with 'd' only)\n"
+"     maxdigits  - maximum acceptable number of digits. Stops reading after\n"
+"         maxdigits have been entered (without requiring the user to\n"
+"         press the '#' key).\n"
+"         Defaults to 0 - no limit - wait for the user press the '#' key.\n"
 ;
 
 STANDARD_LOCAL_USER;
@@ -78,13 +99,19 @@
 static int auth_exec(struct ast_channel *chan, void *data)
 {
 	int res=0;
-	int jump = 0;
 	int retries;
 	struct localuser *u;
-	char password[256]="";
 	char passwd[256];
-	char *opts;
 	char *prompt;
+	int maxdigits;
+	char *argcopy =NULL;
+	struct ast_flags flags = {0};
+
+	AST_DECLARE_APP_ARGS(arglist,
+		AST_APP_ARG(password);
+		AST_APP_ARG(options);
+		AST_APP_ARG(maxdigits);
+	);
 	
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "Authenticate requires an argument(password)\n");
@@ -101,37 +128,49 @@
 		}
 	}
 	
-	strncpy(password, data, sizeof(password) - 1);
-	opts=strchr(password, '|');
-	if (opts) {
-		*opts = 0;
-		opts++;
-	} else
-		opts = "";
-	if (strchr(opts, 'j'))
-		jump = 1;
+	argcopy = ast_strdupa(data);
+	if (!argcopy) {
+		ast_log(LOG_ERROR, "Out of memory!\n");
+		LOCAL_USER_REMOVE(u);
+		return -1;
+	}
+
+	AST_STANDARD_APP_ARGS(arglist,argcopy);
+	
+	if (!ast_strlen_zero(arglist.options)) {
+		ast_app_parse_options(auth_app_options, &flags, NULL, arglist.options);
+	}
+
+	if (!ast_strlen_zero(arglist.maxdigits)) {
+		maxdigits = atoi(arglist.maxdigits);
+		if ((maxdigits<1) || (maxdigits>sizeof(passwd)-2))
+			maxdigits = sizeof(passwd) - 2;
+	} else {
+		maxdigits = sizeof(passwd) - 2;
+	}
+
 	/* Start asking for password */
 	prompt = "agent-pass";
 	for (retries = 0; retries < 3; retries++) {
-		res = ast_app_getdata(chan, prompt, passwd, sizeof(passwd) - 2, 0);
+		res = ast_app_getdata(chan, prompt, passwd, maxdigits, 0);
 		if (res < 0)
 			break;
 		res = 0;
-		if (password[0] == '/') {
-			if (strchr(opts, 'd')) {
+		if (arglist.password[0] == '/') {
+			if (ast_test_flag(&flags,OPT_DATABASE)) {
 				char tmp[256];
 				/* Compare against a database key */
-				if (!ast_db_get(password + 1, passwd, tmp, sizeof(tmp))) {
+				if (!ast_db_get(arglist.password + 1, passwd, tmp, sizeof(tmp))) {
 					/* It's a good password */
-					if (strchr(opts, 'r')) {
-						ast_db_del(password + 1, passwd);
+					if (ast_test_flag(&flags,OPT_REMOVE)) {
+						ast_db_del(arglist.password + 1, passwd);
 					}
 					break;
 				}
 			} else {
 				/* Compare against a file */
 				FILE *f;
-				f = fopen(password, "r");
+				f = fopen(arglist.password, "r");
 				if (f) {
 					char buf[256] = "";
 					char md5passwd[33] = "";
@@ -141,7 +180,7 @@
 						fgets(buf, sizeof(buf), f);
 						if (!feof(f) && !ast_strlen_zero(buf)) {
 							buf[strlen(buf) - 1] = '\0';
-							if (strchr(opts, 'm')) {
+							if (ast_test_flag(&flags,OPT_MULTIPLE)) {
 								md5secret = strchr(buf, ':');
 								if (md5secret == NULL)
 									continue;
@@ -149,13 +188,13 @@
 								md5secret++;
 								ast_md5_hash(md5passwd, passwd);
 								if (!strcmp(md5passwd, md5secret)) {
-									if (strchr(opts, 'a'))
+									if (ast_test_flag(&flags,OPT_ACCOUNT))
 										ast_cdr_setaccount(chan, buf);
 									break;
 								}
 							} else {
 								if (!strcmp(passwd, buf)) {
-									if (strchr(opts, 'a'))
+									if (ast_test_flag(&flags,OPT_ACCOUNT))
 										ast_cdr_setaccount(chan, buf);
 									break;
 								}
@@ -164,7 +203,7 @@
 					}
 					fclose(f);
 					if (!ast_strlen_zero(buf)) {
-						if (strchr(opts, 'm')) {
+						if (ast_test_flag(&flags,OPT_MULTIPLE)) {
 							if (md5secret && !strcmp(md5passwd, md5secret))
 								break;
 						} else {
@@ -173,23 +212,23 @@
 						}
 					}
 				} else 
-					ast_log(LOG_WARNING, "Unable to open file '%s' for authentication: %s\n", password, strerror(errno));
+					ast_log(LOG_WARNING, "Unable to open file '%s' for authentication: %s\n", arglist.password, strerror(errno));
 			}
 		} else {
 			/* Compare against a fixed password */
-			if (!strcmp(passwd, password)) 
+			if (!strcmp(passwd, arglist.password)) 
 				break;
 		}
 		prompt="auth-incorrect";
 	}
 	if ((retries < 3) && !res) {
-		if (strchr(opts, 'a') && !strchr(opts, 'm')) 
+		if (ast_test_flag(&flags,OPT_ACCOUNT) && !ast_test_flag(&flags,OPT_MULTIPLE)) 
 			ast_cdr_setaccount(chan, passwd);
 		res = ast_streamfile(chan, "auth-thankyou", chan->language);
 		if (!res)
 			res = ast_waitstream(chan, "");
 	} else {
-		if (jump && ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
+		if (ast_test_flag(&flags,OPT_JUMP) && ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
 			res = 0;
 		} else {
 			if (!ast_streamfile(chan, "vm-goodbye", chan->language))

Modified: team/bweschke/bug_5374/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_chanspy.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_chanspy.c (original)
+++ team/bweschke/bug_5374/apps/app_chanspy.c Fri Jan 13 11:50:10 2006
@@ -2,6 +2,7 @@
  * Asterisk -- An open source telephony toolkit.
  *
  * Copyright (C) 2005 Anthony Minessale II (anthmct at yahoo.com)
+ * Copyright (C) 2005 - 2006, Digium, Inc.
  *
  * Disclaimed to Digium
  *
@@ -211,9 +212,9 @@
 
 static void stop_spying(struct ast_channel *chan, struct ast_channel_spy *spy) 
 {
-	/* If our status has changed, then the channel we're spying on is gone....
+	/* If our status has changed to DONE, then the channel we're spying on is gone....
 	   DON'T TOUCH IT!!!  RUN AWAY!!! */
-	if (spy->status != CHANSPY_RUNNING)
+	if (spy->status == CHANSPY_DONE)
 		return;
 
 	if (!chan)

Modified: team/bweschke/bug_5374/apps/app_curl.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_curl.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_curl.c (original)
+++ team/bweschke/bug_5374/apps/app_curl.c Fri Jan 13 11:50:10 2006
@@ -46,6 +46,7 @@
 #include "asterisk/options.h"
 #include "asterisk/module.h"
 #include "asterisk/app.h"
+#include "asterisk/utils.h"
 
 static char *tdesc = "Load external URL";
 
@@ -63,9 +64,9 @@
 	/* There might be a realloc() out there that doesn't like reallocing
 	   NULL pointers, so we take care of it here */
 	if (ptr)
-		return realloc(ptr, size);
+		return ast_realloc(ptr, size);
 	else
-		return malloc(size);
+		return ast_malloc(size);
 }
 
 static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)

Modified: team/bweschke/bug_5374/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_dial.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_dial.c (original)
+++ team/bweschke/bug_5374/apps/app_dial.c Fri Jan 13 11:50:10 2006
@@ -164,7 +164,7 @@
 "    S(x) - Hang up the call after 'x' seconds *after* the called party has\n"
 "           answered the call.\n"  	
 "    t    - Allow the called party to transfer the calling party by sending the\n"
-"           DTMF sequence defiend in features.conf.\n"
+"           DTMF sequence defined in features.conf.\n"
 "    T    - Allow the calling party to transfer the called party by sending the\n"
 "           DTMF sequence defined in features.conf.\n"
 "    w    - Allow the called party to enable recording of the call by sending\n"
@@ -984,13 +984,10 @@
 			goto out;
 		}
 		*number = '\0';
-		number++;
-		tmp = malloc(sizeof(struct localuser));
-		if (!tmp) {
-			ast_log(LOG_WARNING, "Out of memory\n");
+		number++;		
+		if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
 			goto out;
 		}
-		memset(tmp, 0, sizeof(struct localuser));
 		if (opts.flags) {
 			ast_copy_flags(tmp, &opts,
 				       OPT_CALLEE_TRANSFER | OPT_CALLER_TRANSFER |

Modified: team/bweschke/bug_5374/apps/app_dictate.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_dictate.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_dictate.c (original)
+++ team/bweschke/bug_5374/apps/app_dictate.c Fri Jan 13 11:50:10 2006
@@ -82,7 +82,12 @@
 
 static int dictate_exec(struct ast_channel *chan, void *data)
 {
-	char *mydata, *argv[3], *path = NULL, filein[256], *filename = "";
+	char *path = NULL, filein[256], *filename = "";
+	char *parse;
+	AST_DECLARE_APP_ARGS(args,
+		AST_APP_ARG(base);
+		AST_APP_ARG(filename);
+	);
 	char dftbase[256];
 	char *base;
 	struct ast_flags flags = {0};
@@ -91,7 +96,6 @@
 	struct localuser *u;
 	int ffactor = 320 * 80,
 		res = 0,
-		argc = 0,
 		done = 0,
 		oldr = 0,
 		lastop = 0,
@@ -105,17 +109,23 @@
 	LOCAL_USER_ADD(u);
 	
 	snprintf(dftbase, sizeof(dftbase), "%s/dictate", ast_config_AST_SPOOL_DIR);
-	if (!ast_strlen_zero(data) && (mydata = ast_strdupa(data))) {
-		argc = ast_app_separate_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
-	}
+	if (!ast_strlen_zero(data)) {
+		parse = ast_strdupa(data);
+		if (!parse) {
+			ast_log(LOG_ERROR, "Out of memory!\n");
+			return -1;
+		}
+		AST_STANDARD_APP_ARGS(args, parse);
+	} else
+		args.argc = 0;
 	
-	if (argc) {
-		base = argv[0];
+	if (args.argc && !ast_strlen_zero(args.base)) {
+		base = args.base;
 	} else {
 		base = dftbase;
 	}
-	if (argc && argv[1]) {
-		filename = argv[1];
+	if (args.argc > 1 && args.filename) {
+		filename = args.filename;
 	} 
 	oldr = chan->readformat;
 	if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) {

Modified: team/bweschke/bug_5374/apps/app_directed_pickup.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_directed_pickup.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_directed_pickup.c (original)
+++ team/bweschke/bug_5374/apps/app_directed_pickup.c Fri Jan 13 11:50:10 2006
@@ -46,7 +46,7 @@
 static const char *app = "Pickup";
 static const char *synopsis = "Directed Call Pickup";
 static const char *descrip =
-"  Pickup(extension[@context]): This application can pickup any ringing channel\n"
+"  Pickup(extension[@context][&extension2 at context...]): This application can pickup any ringing channel\n"
 "that is calling the specified extension. If no context is specified, the current\n"
 "context will be used.\n";
 
@@ -59,7 +59,7 @@
 	int res = 0;
 	struct localuser *u = NULL;
 	struct ast_channel *origin = NULL, *target = NULL;
-	char *tmp = NULL, *exten = NULL, *context = NULL;
+	char *tmp = NULL, *exten = NULL, *context = NULL, *rest=data;
 	char workspace[256] = "";
 
 	if (ast_strlen_zero(data)) {
@@ -69,64 +69,65 @@
 
 	LOCAL_USER_ADD(u);
 	
-	/* Get the extension and context if present */
-	exten = data;
-	context = strchr(data, '@');
-	if (context) {
-		*context = '\0';
-		context++;
-	}
+	while (!target && (exten = rest) ) {
+		res = 0;
+		rest = strchr(exten, '&');
+		if (rest)
+			*rest++ = 0;
 
-	/* Find a channel to pickup */
-	origin = ast_get_channel_by_exten_locked(exten, context);
-	if (origin && origin->cdr) {
-		ast_cdr_getvar(origin->cdr, "dstchannel", &tmp, workspace,
-			       sizeof(workspace), 0);
-		if (tmp) {
-			/* We have a possible channel... now we need to find it! */
-			target = ast_get_channel_by_name_locked(tmp);
+		/* Get the extension and context if present */
+		context = strchr(exten, '@');
+		if (context)
+			*context++ = '\0';
+
+		/* Find a channel to pickup */
+		origin = ast_get_channel_by_exten_locked(exten, context);
+		if (origin) {
+			ast_cdr_getvar(origin->cdr, "dstchannel", &tmp, workspace,
+					sizeof(workspace), 0);
+			if (tmp) {
+				/* We have a possible channel... now we need to find it! */
+				target = ast_get_channel_by_name_locked(tmp);
+			} else {
+				ast_log(LOG_NOTICE, "No target channel found for %s.\n", exten);
+				res = -1;
+			}
+			ast_mutex_unlock(&origin->lock);
+
 		} else {
-			ast_log(LOG_DEBUG, "No target channel found.\n");
+			ast_log(LOG_DEBUG, "No originating channel found.\n");
+		}
+
+		if (res)
+			continue;
+
+		if (target && (!target->pbx) && ((target->_state == AST_STATE_RINGING) || (target->_state == AST_STATE_RING) ) ) {
+			ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n", target->name,
+					chan->name);
+			res = ast_answer(chan);
+			if (res) {
+				ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
+				res = -1;
+				break;
+			}
+			res = ast_queue_control(chan, AST_CONTROL_ANSWER);
+			if (res) {
+				ast_log(LOG_WARNING, "Unable to queue answer on '%s'\n",
+						chan->name);
+				res = -1;
+				break;
+			}
+			res = ast_channel_masquerade(target, chan);
+			if (res) {
+				ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, target->name);
+				res = -1;
+				break;
+			}
+		} else {
+			ast_log(LOG_NOTICE, "No call pickup possible for %s...\n", exten);
 			res = -1;
 		}
-		ast_mutex_unlock(&origin->lock);
-	} else {
-		if (origin)
-			ast_mutex_unlock(&origin->lock);
-		ast_log(LOG_DEBUG, "No originating channel found.\n");
 	}
-	
-	if (res)
-		goto out;
-
-	if (target && (!target->pbx) && ((target->_state == AST_STATE_RINGING) || (target->_state == AST_STATE_RING))) {
-		ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n", target->name,
-			chan->name);
-		res = ast_answer(chan);
-		if (res) {
-			ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
-			res = -1;
-			goto out;
-		}
-		res = ast_queue_control(chan, AST_CONTROL_ANSWER);
-		if (res) {
-			ast_log(LOG_WARNING, "Unable to queue answer on '%s'\n",
-				chan->name);
-			res = -1;
-			goto out;
-		}
-		res = ast_channel_masquerade(target, chan);
-		if (res) {
-			ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, target->name);
-			res = -1;
-			goto out;
-		}
-	} else {
-		ast_log(LOG_DEBUG, "No call pickup possible...\n");
-		res = -1;
-	}
-	/* Done */
- out:
 	if (target) 
 		ast_mutex_unlock(&target->lock);
 	

Modified: team/bweschke/bug_5374/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_directory.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_directory.c (original)
+++ team/bweschke/bug_5374/apps/app_directory.c Fri Jan 13 11:50:10 2006
@@ -84,7 +84,7 @@
 {
 	char *tmp;
 	int lcount = 0;
-	tmp = malloc(NUMDIGITS + 1);
+	tmp = ast_malloc(NUMDIGITS + 1);
 	if (tmp) {
 		while((*lastname > 32) && lcount < NUMDIGITS) {
 			switch(toupper(*lastname)) {

Modified: team/bweschke/bug_5374/apps/app_disa.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_disa.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_disa.c (original)
+++ team/bweschke/bug_5374/apps/app_disa.c Fri Jan 13 11:50:10 2006
@@ -146,12 +146,12 @@
 	}
 	
 	if (ast_set_write_format(chan,AST_FORMAT_ULAW)) {
-		ast_log(LOG_WARNING, "Unable to set write format to Mu-law on %s\n",chan->name);
+		ast_log(LOG_WARNING, "Unable to set write format to Mu-law on %s\n", chan->name);
 		LOCAL_USER_REMOVE(u);
 		return -1;
 	}
 	if (ast_set_read_format(chan,AST_FORMAT_ULAW)) {
-		ast_log(LOG_WARNING, "Unable to set read format to Mu-law on %s\n",chan->name);
+		ast_log(LOG_WARNING, "Unable to set read format to Mu-law on %s\n", chan->name);
 		LOCAL_USER_REMOVE(u);
 		return -1;
 	}
@@ -198,8 +198,7 @@
 	for (;;) {
 		  /* if outa time, give em reorder */
 		if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) > 
-		    ((k&2) ? digittimeout : firstdigittimeout))
-		{
+		    ((k&2) ? digittimeout : firstdigittimeout)) {
 			ast_log(LOG_DEBUG,"DISA %s entry timeout on chan %s\n",
 				((k&1) ? "extension" : "password"),chan->name);
 			break;
@@ -210,14 +209,12 @@
 		}
 			
 		f = ast_read(chan);
-		if (f == NULL) 
-		{
+		if (f == NULL) {
 			LOCAL_USER_REMOVE(u);
 			return -1;
 		}
 		if ((f->frametype == AST_FRAME_CONTROL) &&
-		    (f->subclass == AST_CONTROL_HANGUP))
-		{
+		    (f->subclass == AST_CONTROL_HANGUP)) {
 			ast_frfree(f);
 			LOCAL_USER_REMOVE(u);
 			return -1;
@@ -226,56 +223,54 @@
 			ast_frfree(f);
 			continue;
 		}
-		  /* if not DTMF, just do it again */
-		if (f->frametype != AST_FRAME_DTMF) 
-		{
+
+		/* if not DTMF, just do it again */
+		if (f->frametype != AST_FRAME_DTMF) {
 			ast_frfree(f);
 			continue;
 		}
 
 		j = f->subclass;  /* save digit */
 		ast_frfree(f);
-		if (i == 0) 
-		{
+		if (i == 0) {
 			k|=2; /* We have the first digit */ 
 			ast_playtones_stop(chan);
 		}
 		lastdigittime = ast_tvnow();
 		  /* got a DTMF tone */
-		if (i < AST_MAX_EXTENSION) /* if still valid number of digits */
-		{
-			if (!(k&1)) /* if in password state */
-			{
-				if (j == '#') /* end of password */
-				{
+		if (i < AST_MAX_EXTENSION) { /* if still valid number of digits */
+			if (!(k&1)) { /* if in password state */
+				if (j == '#') { /* end of password */
 					  /* see if this is an integer */
-					if (sscanf(args.passcode,"%d",&j) < 1)
-					   { /* nope, it must be a filename */
+					if (sscanf(args.passcode,"%d",&j) < 1) { /* nope, it must be a filename */
 						fp = fopen(args.passcode,"r");
-						if (!fp)
-						   {
+						if (!fp) {
 							ast_log(LOG_WARNING,"DISA password file %s not found on chan %s\n",args.passcode,chan->name);
 							LOCAL_USER_REMOVE(u);
 							return -1;
-						   }
+						}
 						pwline[0] = 0;
-						while(fgets(pwline,sizeof(pwline) - 1,fp))
-						   {
-							if (!pwline[0]) continue;
+						while(fgets(pwline,sizeof(pwline) - 1,fp)) {
+							if (!pwline[0])
+								continue;
 							if (pwline[strlen(pwline) - 1] == '\n') 
 								pwline[strlen(pwline) - 1] = 0;
-							if (!pwline[0]) continue;
-							  /* skip comments */
-							if (pwline[0] == '#') continue;
-							if (pwline[0] == ';') continue;
+							if (!pwline[0])
+								continue;
+							 /* skip comments */
+							if (pwline[0] == '#')
+								continue;
+							if (pwline[0] == ';')
+								continue;
 
 							AST_STANDARD_APP_ARGS(args, pwline);
 			
 							ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
 
-							  /* password must be in valid format (numeric) */
-							if (sscanf(args.passcode,"%d",&j) < 1) continue;
-							  /* if we got it */
+							/* password must be in valid format (numeric) */
+							if (sscanf(args.passcode,"%d", &j) < 1)
+								continue;
+							 /* if we got it */
 							if (!strcmp(exten,args.passcode)) {
 								if (ast_strlen_zero(args.context))
 									args.context = "disa";
@@ -283,12 +278,11 @@
 									args.mailbox = "";
 								break;
 							}
-						   }
+						}
 						fclose(fp);
-					   }
-					  /* compare the two */
-					if (strcmp(exten,args.passcode))
-					{
+					}
+					/* compare the two */
+					if (strcmp(exten,args.passcode)) {
 						ast_log(LOG_WARNING,"DISA on chan %s got bad password %s\n",chan->name,exten);
 						goto reorder;
 
@@ -302,15 +296,16 @@
 					exten[sizeof(acctcode)] = 0;
 					ast_copy_string(acctcode, exten, sizeof(acctcode));
 					exten[0] = 0;
-					ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n",chan->name);
+					ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n", chan->name);
 					continue;
 				}
 			}
 
 			exten[i++] = j;  /* save digit */
 			exten[i] = 0;
-			if (!(k&1)) continue; /* if getting password, continue doing it */
-			  /* if this exists */
+			if (!(k&1))
+				continue; /* if getting password, continue doing it */
+			/* if this exists */
 
 			if (ast_ignore_pattern(args.context, exten)) {
 				play_dialtone(chan, "");
@@ -321,7 +316,7 @@
 					did_ignore = 0;
 				}
 
-			  /* if can do some more, do it */
+			/* if can do some more, do it */
 			if (!ast_matchmore_extension(chan,args.context,exten,1, chan->cid.cid_num)) {
 				break;
 			}
@@ -341,8 +336,7 @@
 		if (!recheck || ast_exists_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
 			ast_playtones_stop(chan);
 			/* We're authenticated and have a target extension */
-			if (!ast_strlen_zero(args.cid))
-			{
+			if (!ast_strlen_zero(args.cid)) {
 				ast_callerid_split(args.cid, ourcidname, sizeof(ourcidname), ourcidnum, sizeof(ourcidnum));
 				ast_set_callerid(chan, ourcidnum, ourcidname, ourcidnum);
 			}
@@ -364,8 +358,7 @@
 	ast_indicate(chan,AST_CONTROL_CONGESTION);
 	/* something is invalid, give em reorder for several seconds */
 	time(&rstart);
-	while(time(NULL) < rstart + 10)
-	{
+	while(time(NULL) < rstart + 10) {
 		if (ast_waitfor(chan, -1) < 0)
 			break;
 		f = ast_read(chan);

Modified: team/bweschke/bug_5374/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_externalivr.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_externalivr.c (original)
+++ team/bweschke/bug_5374/apps/app_externalivr.c Fri Jan 13 11:50:10 2006
@@ -49,6 +49,7 @@
 #include "asterisk/module.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/app.h"
+#include "asterisk/utils.h"
 
 static const char *tdesc = "External IVR Interface Application";
 
@@ -112,10 +113,8 @@
 {
 	struct localuser *u = params;
 	struct gen_state *state;
-
-	state = calloc(1, sizeof(*state));
-
-	if (!state)
+	
+	if (!(state = ast_calloc(1, sizeof(*state))))
 		return NULL;
 
 	state->u = u;
@@ -234,10 +233,8 @@
 static struct playlist_entry *make_entry(const char *filename)
 {
 	struct playlist_entry *entry;
-
-	entry = calloc(1, sizeof(*entry) + strlen(filename) + 10);
-
-	if (!entry)
+	
+	if (!(entry = ast_calloc(1, sizeof(*entry) + strlen(filename) + 10)))
 		return NULL;
 
 	strcpy(entry->filename, filename);

Modified: team/bweschke/bug_5374/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/bug_5374/apps/app_festival.c?rev=8061&r1=8060&r2=8061&view=diff
==============================================================================
--- team/bweschke/bug_5374/apps/app_festival.c (original)

[... 11774 lines stripped ...]


More information about the asterisk-commits mailing list