[svn-commits] file: branch file/t38fun r89131 - in /team/file/t38fun: ./ apps/ cdr/ channel...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Nov 9 10:36:30 CST 2007


Author: file
Date: Fri Nov  9 10:36:29 2007
New Revision: 89131

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89131
Log:
Merged revisions 89032,89036-89037,89042,89045-89046,89053,89079,89085,89088,89090,89093,89095,89097,89099,89101,89103,89105,89111,89115,89119,89125 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r89032 | file | 2007-11-06 13:08:05 -0400 (Tue, 06 Nov 2007) | 4 lines

Make it so that if a peer is determined to be unreachable using qualify their devicestate will report back unavailable.
(closes issue #11006)
Reported by: pj

........
r89036 | murf | 2007-11-06 13:52:50 -0400 (Tue, 06 Nov 2007) | 1 line

closes issue #8786 - where the [catname](!) and [catname](othercat1,othercat2,...) notation gets dropped across a ConfigUpdate (or any other thing that would cause a config file to be written). While I was at it, I also cleaned up some of the destroy routines to free up comments, which was not being done. Made sure the new struct I introduced is also cleaned up properly at destruction time. My code handles multiple template inclusions. Many thanks to ssokol for his patch, which, while not literally used in the final merge, served as a foundation for the fix.
........
r89037 | russell | 2007-11-06 14:20:07 -0400 (Tue, 06 Nov 2007) | 11 lines

If someone were to delete the files used by an existing MOH class, and then
issue a reload, further use of that class could result in a crash due to
dividing by zero.  This set of changes fixes up some places to prevent this
from happening.

(closes issue #10948)
Reported by: jcomellas
Patches:
      res_musiconhold_division_by_zero.patch uploaded by jcomellas (license 282)
	  Additional changes added by me.

........
r89042 | oej | 2007-11-06 14:53:37 -0400 (Tue, 06 Nov 2007) | 2 lines

Bug fixes to tdd support in zaptel. 

........
r89045 | tilghman | 2007-11-06 15:09:06 -0400 (Tue, 06 Nov 2007) | 2 lines

We went to the trouble of creating a method of tracking failed trylocks, then never turned it on (oops).

........
r89046 | qwell | 2007-11-06 15:09:30 -0400 (Tue, 06 Nov 2007) | 4 lines

Correctly set the total number of channels from a zaptel transcoder board.

SPD-49, patch by Matthew Nicholson.

........
r89053 | russell | 2007-11-06 16:18:49 -0400 (Tue, 06 Nov 2007) | 3 lines

Fix init_classes() so that classes that actually do have files loaded aren't
treated as empty, and immediately destroyed ...

........
r89079 | tilghman | 2007-11-07 00:07:49 -0400 (Wed, 07 Nov 2007) | 5 lines

Suppress AEL warnings on load.
Reported by: eliel
Patch by: eliel
Closes issue #11178

........
r89085 | mmichelson | 2007-11-07 11:56:49 -0400 (Wed, 07 Nov 2007) | 5 lines

Fixing a segfault in the manager "core show channels concise" command.

(closes issue #11183, reported by arnd and patched by ys)


........
r89088 | murf | 2007-11-07 17:40:28 -0400 (Wed, 07 Nov 2007) | 1 line

In response to 10578, I just ran 1.4 thru valgrind; some of the config leakage I've already fixed, but it doesn't hurt to double check. I found and fixed leaks in res_jabber, cdr_tds, pbx_ael. Nothing major, tho.
........
r89090 | mmichelson | 2007-11-07 18:40:35 -0400 (Wed, 07 Nov 2007) | 6 lines

This patch makes it possible for SIP phones to dial extensions defined with '#' characters
in extensions.conf AND maintain their escaped characters when forming URI's

(closes issue #10681, reported by cahen, patched by me, code review by file)


........
r89093 | tilghman | 2007-11-07 19:39:37 -0400 (Wed, 07 Nov 2007) | 7 lines

The member refcount must be incremented, to avoid using it after deallocation.
A huge thanks go to lvl- for patiently providing the necessary valgrind output
that was necessary to finding this problem of memory corruption.
Reported by: lvl-
Patch by: tilghman
Closes issue #11174

........
r89095 | file | 2007-11-07 19:53:25 -0400 (Wed, 07 Nov 2007) | 4 lines

If callerid is configured in sip.conf use that for checking the presence of an extension in the dialplan.
(closes issue #11185)
Reported by: spditner

........
r89097 | file | 2007-11-07 21:11:25 -0400 (Wed, 07 Nov 2007) | 8 lines

Add support for allowing one outgoing transaction. This means if a response comes back out of order chan_sip will still handle it. I dream of a chan_sip with real transaction support.
(closes issue #10946)
Reported by: flefoll
(closes issue #10915)
Reported by: ramonpeek
(closes issue #9567)
Reported by: atca_pres

........
r89099 | file | 2007-11-07 21:28:56 -0400 (Wed, 07 Nov 2007) | 6 lines

Improve the devicestate logic for multiple devices. If any are available then the extension is considered available.
(closes issue #10164)
Reported by: nic_bellamy
Patches:
      sip-hinting-svn-branch-1.4.patch uploaded by nic (license 299)

........
r89101 | file | 2007-11-07 22:26:48 -0400 (Wed, 07 Nov 2007) | 4 lines

Do not add a sip: to the beginning of the To URI unless needed.
(closes issue #10756)
Reported by: goestelecom

........
r89103 | tilghman | 2007-11-08 00:55:19 -0400 (Thu, 08 Nov 2007) | 2 lines

Typo

........
r89105 | kpfleming | 2007-11-08 01:26:47 -0400 (Thu, 08 Nov 2007) | 2 lines

fix a glaring bug in the new SRV record handling that would cause incorrect weight sorting

........
r89111 | mmichelson | 2007-11-08 12:47:23 -0400 (Thu, 08 Nov 2007) | 5 lines

I made this same adjustment in trunk to fix a bug, and it makes sense to do it in 1.4 as
well. If an imapfolder is specified in voicemail.conf, don't ever explicitly connect to 
INBOX since it may not exist.


........
r89115 | qwell | 2007-11-08 14:45:15 -0400 (Thu, 08 Nov 2007) | 4 lines

Avoid warnings on load when using sample configuration files.

Issue 11195, patch by eliel.

........
r89119 | mmichelson | 2007-11-08 17:00:08 -0400 (Thu, 08 Nov 2007) | 7 lines

Rework of the commit I made yesterday to use the already built-in
ast_uri_decode function as opposed to my home-rolled one. Also added
comments.

Thanks to oej for pointing me in the right direction


........
r89125 | qwell | 2007-11-08 19:52:35 -0400 (Thu, 08 Nov 2007) | 4 lines

Properly say the seconds here..

Issue 11203, fix described by vma.

........

Modified:
    team/file/t38fun/   (props changed)
    team/file/t38fun/apps/app_queue.c
    team/file/t38fun/apps/app_voicemail.c
    team/file/t38fun/cdr/cdr_tds.c
    team/file/t38fun/channels/chan_sip.c
    team/file/t38fun/codecs/codec_zap.c
    team/file/t38fun/configs/extensions.ael.sample
    team/file/t38fun/configs/res_odbc.conf.sample
    team/file/t38fun/doc/valgrind.txt
    team/file/t38fun/include/asterisk/lock.h
    team/file/t38fun/main/config.c
    team/file/t38fun/main/manager.c
    team/file/t38fun/main/say.c
    team/file/t38fun/main/srv.c
    team/file/t38fun/main/tdd.c
    team/file/t38fun/pbx/pbx_ael.c
    team/file/t38fun/res/res_jabber.c
    team/file/t38fun/res/res_musiconhold.c

Propchange: team/file/t38fun/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Nov  9 10:36:29 2007
@@ -1,1 +1,1 @@
-/branches/1.4:1-89003
+/branches/1.4:1-89129

Modified: team/file/t38fun/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/apps/app_queue.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/apps/app_queue.c (original)
+++ team/file/t38fun/apps/app_queue.c Fri Nov  9 10:36:29 2007
@@ -2622,6 +2622,8 @@
 		callcompletedinsl = ((now - qe->start) <= qe->parent->servicelevel);
 		ast_mutex_unlock(&qe->parent->lock);
 		member = lpeer->member;
+		/* Increment the refcount for this member, since we're going to be using it for awhile in here. */
+		ao2_ref(member, 1);
 		hangupcalls(outgoing, peer);
 		outgoing = NULL;
 		if (announce || qe->parent->reportholdtime || qe->parent->memberdelay) {
@@ -2668,6 +2670,7 @@
 							queuename, qe->chan->uniqueid, peer->name, member->interface, member->membername,
 							qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
 				ast_hangup(peer);
+				ao2_ref(member, -1);
 				goto out;
 			} else if (res2) {
 				/* Caller must have hung up just before being connected*/
@@ -2675,6 +2678,7 @@
 				ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "ABANDON", "%d|%d|%ld", qe->pos, qe->opos, (long)time(NULL) - qe->start);
 				record_abandoned(qe);
 				ast_hangup(peer);
+				ao2_ref(member, -1);
 				return -1;
 			}
 		}
@@ -2690,6 +2694,7 @@
 			ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", qe->chan->name, peer->name);
 			record_abandoned(qe);
 			ast_hangup(peer);
+			ao2_ref(member, -1);
 			return -1;
 		}
 
@@ -2874,6 +2879,7 @@
 			ast_hangup(peer);
 		update_queue(qe->parent, member, callcompletedinsl);
 		res = bridge ? bridge : 1;
+		ao2_ref(member, -1);
 	}
 out:
 	hangupcalls(outgoing, NULL);

Modified: team/file/t38fun/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/apps/app_voicemail.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/apps/app_voicemail.c (original)
+++ team/file/t38fun/apps/app_voicemail.c Fri Nov  9 10:36:29 2007
@@ -4677,7 +4677,7 @@
 		char *cp;
 #include "linkage.c"
 		/* Connect to INBOX first to get folders delimiter */
-		imap_mailbox_name(tmp, sizeof(tmp), vms, 0, 0);
+		imap_mailbox_name(tmp, sizeof(tmp), vms, 0, 1);
 		stream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
 		if (stream == NIL) {
 			ast_log (LOG_ERROR, "Can't connect to imap server %s\n", tmp);

Modified: team/file/t38fun/cdr/cdr_tds.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/cdr/cdr_tds.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/cdr/cdr_tds.c (original)
+++ team/file/t38fun/cdr/cdr_tds.c Fri Nov  9 10:36:29 2007
@@ -441,9 +441,11 @@
 	}
 
 	var = ast_variable_browse(cfg, "global");
-	if (!var) /* nothing configured */
+	if (!var) /* nothing configured */ {
+		ast_config_destroy(cfg);
 		return 0;
-
+	}
+	
 	ptr = ast_variable_retrieve(cfg, "global", "hostname");
 	if (ptr)
 		hostname = strdup(ptr);

Modified: team/file/t38fun/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/channels/chan_sip.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/channels/chan_sip.c (original)
+++ team/file/t38fun/channels/chan_sip.c Fri Nov  9 10:36:29 2007
@@ -942,6 +942,7 @@
 	ast_group_t callgroup;			/*!< Call group */
 	ast_group_t pickupgroup;		/*!< Pickup group */
 	int lastinvite;				/*!< Last Cseq of invite */
+	int lastnoninvite;                      /*!< Last Cseq of non-invite */
 	struct ast_flags flags[2];		/*!< SIP_ flags */
 	int timer_t1;				/*!< SIP timer T1, ms rtt */
 	unsigned int sipoptions;		/*!< Supported SIP options on the other end */
@@ -3889,7 +3890,6 @@
 }
 
 
-
 /*! \brief Initiate a call in the SIP channel
 	called from sip_request_call (calls from the pbx ) for outbound channels
 	and from handle_request_invite for inbound channels
@@ -3902,6 +3902,7 @@
 	int fmt;
 	int what;
 	int needvideo = 0, video = 0;
+	char *decoded_exten;
 	{
 		const char *my_name;    /* pick a good name */
 
@@ -4014,8 +4015,13 @@
 	i->owner = tmp;
 	ast_module_ref(ast_module_info->self);
 	ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
-	ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
-
+	/*Since it is valid to have extensions in the dialplan that have unescaped characters in them
+	 * we should decode the uri before storing it in the channel, but leave it encoded in the sip_pvt
+	 * structure so that there aren't issues when forming URI's
+	 */
+	decoded_exten = ast_strdupa(i->exten);
+	ast_uri_decode(decoded_exten);
+	ast_copy_string(tmp->exten, decoded_exten, sizeof(tmp->exten));
 
 	/* Don't use ast_set_callerid() here because it will
 	 * generate an unnecessary NewCallerID event  */
@@ -6881,7 +6887,7 @@
 
 	if (sipmethod == SIP_NOTIFY && !ast_strlen_zero(p->theirtag)) { 
 		/* If this is a NOTIFY, use the From: tag in the subscribe (RFC 3265) */
-		snprintf(to, sizeof(to), "<sip:%s>;tag=%s", p->uri, p->theirtag);
+		snprintf(to, sizeof(to), "<%s%s>;tag=%s", (strncasecmp(p->uri, "sip:", 4) ? "" : "sip:"), p->uri, p->theirtag);
 	} else if (p->options && p->options->vxml_url) {
 		/* If there is a VXML URL append it to the SIP URL */
 		snprintf(to, sizeof(to), "<%s>;%s", p->uri, p->options->vxml_url);
@@ -7077,13 +7083,22 @@
 	/* Check which device/devices we are watching  and if they are registered */
 	if (ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, p->context, p->exten)) {
 		char *hint2 = hint, *individual_hint = NULL;
+		int hint_count = 0, unavailable_count = 0;
+
 		while ((individual_hint = strsep(&hint2, "&"))) {
-			/* If they are not registered, we will override notification and show no availability */
-			if (ast_device_state(individual_hint) == AST_DEVICE_UNAVAILABLE) {
-				local_state = NOTIFY_CLOSED;
-				pidfstate = "away";
-				pidfnote = "Not online";
-			}
+			hint_count++;
+
+			if (ast_device_state(individual_hint) == AST_DEVICE_UNAVAILABLE)
+				unavailable_count++;
+		}
+
+		/* If none of the hinted devices are registered, we will
+		 * override notification and show no availability.
+		 */
+		if (hint_count > 0 && hint_count == unavailable_count) {
+			local_state = NOTIFY_CLOSED;
+			pidfstate = "away";
+			pidfnote = "Not online";
 		}
 	}
 
@@ -7255,6 +7270,8 @@
 
 	if (!p->initreq.headers)
 		initialize_initreq(p, &req);
+
+	p->lastnoninvite = p->ocseq;
 
 	return send_request(p, &req, XMIT_RELIABLE, p->ocseq);
 }
@@ -8708,18 +8725,22 @@
 	} else {
 		/* Check the dialplan for the username part of the request URI,
 		   the domain will be stored in the SIPDOMAIN variable
+		   Since extensions.conf can have unescaped characters, try matching a decoded
+		   uri in addition to the non-decoded uri
 		   Return 0 if we have a matching extension */
-		if (ast_exists_extension(NULL, p->context, uri, 1, from) ||
+		char *decoded_uri = ast_strdupa(uri);
+		ast_uri_decode(decoded_uri);
+		if (ast_exists_extension(NULL, p->context, uri, 1, S_OR(p->cid_num, from)) || ast_exists_extension(NULL, p->context, decoded_uri, 1, S_OR(p->cid_num, from)) ||
 		    !strcmp(uri, ast_pickup_ext())) {
 			if (!oreq)
 				ast_string_field_set(p, exten, uri);
 			return 0;
-		}
+		} 
 	}
 
 	/* Return 1 for pickup extension or overlap dialling support (if we support it) */
 	if((ast_test_flag(&global_flags[1], SIP_PAGE2_ALLOWOVERLAP) && 
- 	    ast_canmatch_extension(NULL, p->context, uri, 1, from)) ||
+ 	    ast_canmatch_extension(NULL, p->context, uri, 1, S_OR(p->cid_num, from))) ||
 	    !strncmp(uri, ast_pickup_ext(), strlen(uri))) {
 		return 1;
 	}
@@ -14961,11 +14982,11 @@
 				ast_log(LOG_DEBUG, "That's odd...  Got a response on a call we dont know about. Cseq %d Cmd %s\n", seqno, cmd);
 			ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
 			return 0;
-		} else if (p->ocseq && (p->ocseq < seqno)) {
+		} else if (p->ocseq && (p->ocseq < seqno) && (seqno != p->lastnoninvite)) {
 			if (option_debug)
 				ast_log(LOG_DEBUG, "Ignoring out of order response %d (expecting %d)\n", seqno, p->ocseq);
 			return -1;
-		} else if (p->ocseq && (p->ocseq != seqno)) {
+		} else if (p->ocseq && (p->ocseq != seqno) && (seqno != p->lastnoninvite)) {
 			/* ignore means "don't do anything with it" but still have to 
 			   respond appropriately  */
 			ignore = TRUE;
@@ -15652,7 +15673,7 @@
 			else if (p->call_limit && p->inUse)
 				/* Not busy, but we do have a call */
 				res = AST_DEVICE_INUSE;
-			else if (p->maxms && (p->lastms > p->maxms)) 
+			else if (p->maxms && ((p->lastms > p->maxms) || (p->lastms < 0))) 
 				/* We don't have a call. Are we reachable at all? Requires qualify= */
 				res = AST_DEVICE_UNAVAILABLE;
 			else	/* Default reply if we're registered and have no other data */

Modified: team/file/t38fun/codecs/codec_zap.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/codecs/codec_zap.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/codecs/codec_zap.c (original)
+++ team/file/t38fun/codecs/codec_zap.c Fri Nov  9 10:36:29 2007
@@ -224,7 +224,6 @@
 	if (ioctl(ztp->fd, ZT_TRANSCODE_OP, &x))
 		ast_log(LOG_WARNING, "Failed to release transcoder channel: %s\n", strerror(errno));
 
-	ast_atomic_fetchadd_int(&channels.total, -1);
 	switch (ztp->hdr->dstfmt) {
 	case AST_FORMAT_G729A:
 	case AST_FORMAT_G723_1:
@@ -286,7 +285,6 @@
 	ztp->fd = fd;
 	ztp->hdr = hdr;
 
-	ast_atomic_fetchadd_int(&channels.total, +1);
 	switch (hdr->dstfmt) {
 	case AST_FORMAT_G729A:
 	case AST_FORMAT_G723_1:
@@ -442,6 +440,7 @@
 		if (option_verbose > 1)
 			ast_verbose(VERBOSE_PREFIX_2 "Found transcoder '%s'.\n", info.name);
 		build_translators(&map, info.dstfmts, info.srcfmts);
+		ast_atomic_fetchadd_int(&channels.total, info.numchannels / 2);
 	}
 	close(fd);
 

Modified: team/file/t38fun/configs/extensions.ael.sample
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/configs/extensions.ael.sample?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/configs/extensions.ael.sample (original)
+++ team/file/t38fun/configs/extensions.ael.sample Fri Nov  9 10:36:29 2007
@@ -176,6 +176,7 @@
 // ARG1 is the extension to Dial
 //
 	goto ${exten}|1;
+	return;
 };
 
 //
@@ -275,7 +276,6 @@
 	ignorepat => 9;
 	includes {
 		ael-default;
-		ael-parkedcalls;
 		ael-trunklocal;
 		ael-iaxtel700;
 		ael-trunktollfree;
@@ -318,6 +318,7 @@
                 VoiceMailMain(${ext});
                 return;
         };
+	return;
 };
 
 context ael-demo {

Modified: team/file/t38fun/configs/res_odbc.conf.sample
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/configs/res_odbc.conf.sample?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/configs/res_odbc.conf.sample (original)
+++ team/file/t38fun/configs/res_odbc.conf.sample Fri Nov  9 10:36:29 2007
@@ -10,7 +10,7 @@
 ; All other sections are arbitrary names for database connections.
 
 [asterisk]
-enabled => yes
+enabled => no
 dsn => asterisk
 ;username => myuser
 ;password => mypass

Modified: team/file/t38fun/doc/valgrind.txt
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/doc/valgrind.txt?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/doc/valgrind.txt (original)
+++ team/file/t38fun/doc/valgrind.txt Fri Nov  9 10:36:29 2007
@@ -11,7 +11,7 @@
 2.  Rebuild and install Asterisk.
 
 3.  Run Asterisk as follows:
-	valgrind --log-file-exact=valgrind.txt asterisk -vvvvcg 2>malloc_debug.txt
+	valgrind --log-file-exactly=valgrind.txt asterisk -vvvvcg 2>malloc_debug.txt
 
 4.  Reproduce the issue.  Following the manifestation of the issue (or when
 	the process crashes), upload the two files, valgrind.txt and

Modified: team/file/t38fun/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/include/asterisk/lock.h?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/include/asterisk/lock.h (original)
+++ team/file/t38fun/include/asterisk/lock.h Fri Nov  9 10:36:29 2007
@@ -422,7 +422,7 @@
 		if (t->track)
 			ast_mark_lock_acquired();
 	} else if (t->track) {
-			ast_remove_lock_info(&t->mutex);
+		ast_mark_lock_failed();
 	}
 
 	return res;

Modified: team/file/t38fun/main/config.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/main/config.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/main/config.c (original)
+++ team/file/t38fun/main/config.c Fri Nov  9 10:36:29 2007
@@ -159,10 +159,17 @@
 
 #define MAX_INCLUDE_LEVEL 10
 
+struct ast_category_template_instance {
+	char name[80]; /* redundant? */
+	const struct ast_category *inst;
+	AST_LIST_ENTRY(ast_category_template_instance) next;
+};
+
 struct ast_category {
 	char name[80];
 	int ignored;			/*!< do not let user of the config see this category */
 	int include_level;	
+	AST_LIST_HEAD_NOLOCK(template_instance_list, ast_category_template_instance) template_instances;
 	struct ast_comment *precomments;
 	struct ast_comment *sameline;
 	struct ast_variable *root;
@@ -340,9 +347,36 @@
 	config->current = category;
 }
 
+static void ast_destroy_comments(struct ast_category *cat)
+{
+	struct ast_comment *n, *p;
+	for (p=cat->precomments; p; p=n) {
+		n = p->next;
+		free(p);
+	}
+	for (p=cat->sameline; p; p=n) {
+		n = p->next;
+		free(p);
+	}
+	cat->precomments = NULL;
+	cat->sameline = NULL;
+}
+
+static void ast_destroy_template_list(struct ast_category *cat)
+{
+	struct ast_category_template_instance *x;
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&cat->template_instances, x, next) {
+		AST_LIST_REMOVE_CURRENT(&cat->template_instances, next);
+		free(x);
+	}
+	AST_LIST_TRAVERSE_SAFE_END;
+}
+
 void ast_category_destroy(struct ast_category *cat)
 {
 	ast_variables_destroy(cat->root);
+	ast_destroy_comments(cat);
+	ast_destroy_template_list(cat);
 	free(cat);
 }
 
@@ -412,7 +446,10 @@
 static void inherit_category(struct ast_category *new, const struct ast_category *base)
 {
 	struct ast_variable *var;
-
+	struct ast_category_template_instance *x = ast_calloc(1,sizeof(struct ast_category_template_instance));
+	strcpy(x->name, base->name);
+	x->inst = base;
+	AST_LIST_INSERT_TAIL(&new->template_instances, x, next);
 	for (var = base->root; var; var = var->next)
 		ast_variable_append(new, variable_clone(var));
 }
@@ -519,7 +556,6 @@
 	cat = cfg->root;
 	while(cat) {
 		if (cat->name == category) {
-			ast_variables_destroy(cat->root);
 			if (prev) {
 				prev->next = cat->next;
 				if (cat == cfg->last)
@@ -529,7 +565,7 @@
 				if (cat == cfg->last)
 					cfg->last = NULL;
 			}
-			free(cat);
+			ast_category_destroy(cat);
 			return 0;
 		}
 		prev = cat;
@@ -540,7 +576,6 @@
 	cat = cfg->root;
 	while(cat) {
 		if (!strcasecmp(cat->name, category)) {
-			ast_variables_destroy(cat->root);
 			if (prev) {
 				prev->next = cat->next;
 				if (cat == cfg->last)
@@ -550,7 +585,7 @@
 				if (cat == cfg->last)
 					cfg->last = NULL;
 			}
-			free(cat);
+			ast_category_destroy(cat);
 			return 0;
 		}
 		prev = cat;
@@ -568,10 +603,9 @@
 
 	cat = cfg->root;
 	while(cat) {
-		ast_variables_destroy(cat->root);
 		catn = cat;
 		cat = cat->next;
-		free(catn);
+		ast_category_destroy(catn);
 	}
 	free(cfg);
 }
@@ -999,6 +1033,18 @@
 			if (!cat->precomments)
 				fprintf(f,"\n");
 			fprintf(f, "[%s]", cat->name);
+			if (cat->ignored)
+				fprintf(f, "(!)");
+			if (!AST_LIST_EMPTY(&cat->template_instances)) {
+				struct ast_category_template_instance *x;
+				fprintf(f, "(");
+				AST_LIST_TRAVERSE(&cat->template_instances, x, next) {
+					fprintf(f,"%s",x->name);
+					if (x != AST_LIST_LAST(&cat->template_instances))
+						fprintf(f,",");
+				}
+				fprintf(f, ")");
+			}
 			for(cmt = cat->sameline; cmt; cmt=cmt->next)
 			{
 				fprintf(f,"%s", cmt->cmt);
@@ -1007,6 +1053,19 @@
 				fprintf(f,"\n");
 			var = cat->root;
 			while(var) {
+				struct ast_category_template_instance *x;
+				int found = 0;
+				AST_LIST_TRAVERSE(&cat->template_instances, x, next) {
+					const char *pvalue = ast_variable_retrieve(cfg, x->name, var->name);
+					if (pvalue && !strcmp(pvalue, var->value)) {
+						found = 1;
+						break;
+					}
+				}
+				if (found) {
+					var = var->next;
+					continue;
+				}
 				for (cmt = var->precomments; cmt; cmt=cmt->next)
 				{
 					if (cmt->cmt[0] != ';' || cmt->cmt[1] != '!')

Modified: team/file/t38fun/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/main/manager.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/main/manager.c (original)
+++ team/file/t38fun/main/manager.c Fri Nov  9 10:36:29 2007
@@ -1648,7 +1648,7 @@
 			term_strip(final_buf, buf, l);
 			final_buf[l] = '\0';
 		}
-		astman_append(s, S_OR(final_buf, buf));
+		astman_append(s, "%s", S_OR(final_buf, buf));
 		ast_free(buf);
 	}
 	close(fd);

Modified: team/file/t38fun/main/say.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/main/say.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/main/say.c (original)
+++ team/file/t38fun/main/say.c Fri Nov  9 10:36:29 2007
@@ -4220,7 +4220,7 @@
 				break;
 			case 'S':
 				/* Seconds */
-				res = ast_say_number(chan, tm.tm_hour, ints, lang, (char * ) NULL);
+				res = ast_say_number(chan, tm.tm_sec, ints, lang, (char * ) NULL);
 				if (!res) {
 					res = wait_file(chan,ints, "digits/second",lang);
 				}

Modified: team/file/t38fun/main/srv.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/main/srv.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/main/srv.c (original)
+++ team/file/t38fun/main/srv.c Fri Nov  9 10:36:29 2007
@@ -190,6 +190,7 @@
 
 				AST_LIST_REMOVE_CURRENT(&temp_list, list);
 				AST_LIST_INSERT_TAIL(&newlist, current, list);
+				break;
 			}
 			AST_LIST_TRAVERSE_SAFE_END;
 		}

Modified: team/file/t38fun/main/tdd.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/main/tdd.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/main/tdd.c (original)
+++ team/file/t38fun/main/tdd.c Fri Nov  9 10:36:29 2007
@@ -53,6 +53,7 @@
 	int pos;
 	int modo;
 	int mode;
+	int charnum;
 };
 
 static float dr[4], di[4];
@@ -67,10 +68,10 @@
 	                         '\n','D','R','J','N','F','C','K',
 	                         'T','Z','L','W','H','Y','P','Q',
 	                         'O','B','G','^','M','X','V','^' };
-	static char figs[32] = { '<','3','\n','-',' ',',','8','7',
-	                         '\n','$','4','\'',',','·',':','(',
-	                         '5','+',')','2','·','6','0','1',
-	                         '9','7','·','^','.','/','=','^' };
+	static char figs[32] = { '<','3','\n','-',' ','\'','8','7',
+	                         '\n','$','4','\'',',','!',':','(',
+	                         '5','\"',')','2','=','6','0','1',
+	                         '9','?','+','^','.','/',';','^' };
 	int d = 0;  /* return 0 if not decodeable */
 	switch (data) {
 	case 0x1f:
@@ -101,9 +102,8 @@
 struct tdd_state *tdd_new(void)
 {
 	struct tdd_state *tdd;
-	tdd = malloc(sizeof(struct tdd_state));
+	tdd = calloc(1, sizeof(*tdd));
 	if (tdd) {
-		memset(tdd, 0, sizeof(struct tdd_state));
 		tdd->fskd.spb = 176;        /* 45.5 baud */
 		tdd->fskd.hdlc = 0;         /* Async */
 		tdd->fskd.nbit = 5;         /* 5 bits */
@@ -117,7 +117,8 @@
 		tdd->fskd.x0 = 0.0;
 		tdd->fskd.state = 0;
 		tdd->pos = 0;
-		tdd->mode = 2;
+		tdd->mode = 0;
+		tdd->charnum = 0;
 	} else
 		ast_log(LOG_WARNING, "Out of memory\n");
 	return tdd;
@@ -143,13 +144,12 @@
 	int b = 'X';
 	int res;
 	int c,x;
-	short *buf = malloc(2 * len + tdd->oldlen);
+	short *buf = calloc(1, 2 * len + tdd->oldlen);
 	short *obuf = buf;
 	if (!buf) {
 		ast_log(LOG_WARNING, "Out of memory\n");
 		return -1;
 	}
-	memset(buf, 0, 2 * len + tdd->oldlen);
 	memcpy(buf, tdd->oldstuff, tdd->oldlen);
 	mylen += tdd->oldlen/2;
 	for (x = 0; x < len; x++) 
@@ -159,13 +159,13 @@
 		olen = mylen;
 		res = fsk_serie(&tdd->fskd, buf, &mylen, &b);
 		if (mylen < 0) {
-			ast_log(LOG_ERROR, "fsk_serie made mylen < 0 (%d) (olen was %d)\n", mylen, olen);
+			ast_log(LOG_ERROR, "fsk_serial made mylen < 0 (%d) (olen was %d)\n", mylen, olen);
 			free(obuf);
 			return -1;
 		}
 		buf += (olen - mylen);
 		if (res < 0) {
-			ast_log(LOG_NOTICE, "fsk_serie failed\n");
+			ast_log(LOG_NOTICE, "fsk_serial failed\n");
 			free(obuf);
 			return -1;
 		}
@@ -174,7 +174,8 @@
 			if (b > 0x7f)
 				continue;
 			c = tdd_decode_baudot(tdd,b);
-			if ((c < 1) || (c > 126)) continue; /* if not valid */
+			if ((c < 1) || (c > 126))
+				continue; /* if not valid */
 			break;
 		}
 	}
@@ -185,7 +186,8 @@
 		tdd->oldlen = 0;
 	free(obuf);
 	if (res) {
-		tdd->mode = 2; /* put it in mode where it
+		tdd->mode = 2; 
+/* put it in mode where it
 			reliably puts teleprinter in correct shift mode */
 		return(c);
 	}
@@ -229,7 +231,7 @@
 } while(0)
 
 #define PUT_TDD_BAUD(bit) do { \
-	while(scont < tddsb) { \
+	while (scont < tddsb) { \
 		PUT_AUDIO_SAMPLE(tdd_getcarrier(&cr, &ci, bit)); \
 		scont += 1.0; \
 	} \
@@ -237,7 +239,7 @@
 } while(0)
 
 #define PUT_TDD_STOP do { \
-	while(scont < (tddsb * 1.5)) { \
+	while (scont < (tddsb * 1.5)) { \
 		PUT_AUDIO_SAMPLE(tdd_getcarrier(&cr, &ci, 1)); \
 		scont += 1.0; \
 	} \
@@ -261,14 +263,20 @@
 	int bytes=0;
 	int i,x;
 	char	c;
+	/*! Baudot letters */
 	static unsigned char lstr[31] = "\000E\nA SIU\rDRJNFCKTZLWHYPQOBG\000MXV";
-	static unsigned char fstr[31] = "\0003\n- \00787\r$4',!:(5\")2\0006019?&\000./;";
+	/*! Baudot figures */
+	static unsigned char fstr[31] = "\0003\n- \00787\r$4',!:(5\")2\0006019?+\000./;";
 	/* Initial carriers (real/imaginary) */
 	float cr = 1.0;
 	float ci = 0.0;
 	float scont = 0.0;
 
 	for(x = 0; str[x]; x++) {
+		/* Do synch for each 72th character */
+		if ( (tdd->charnum++) % 72 == 0) 
+			PUT_TDD(tdd->mode ? 27 /* FIGS */ : 31 /* LTRS */);
+
 		c = toupper(str[x]);
 #if	0
 		printf("%c",c); fflush(stdout);

Modified: team/file/t38fun/pbx/pbx_ael.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/pbx/pbx_ael.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/pbx/pbx_ael.c (original)
+++ team/file/t38fun/pbx/pbx_ael.c Fri Nov  9 10:36:29 2007
@@ -2993,7 +2993,7 @@
 				strncat(buf2,strp2+1, sizeof(buf2)-strlen(strp2+1)-2);
 				strcat(buf2,"]");
 				for_init->appargs = strdup(buf2);
-				for_init->app = strdup("Set");
+				/* for_init->app = strdup("Set"); just set! */
 			} else {
 				strp2 = p->u1.for_init;
 				while (*strp2 && isspace(*strp2))
@@ -3015,7 +3015,8 @@
 						*strp3 = 0; /* remove the closing paren */
 
 					for_init->appargs = strdup(buf2);
-
+					if (for_init->app)
+						free(for_init->app);
 					for_init->app = strdup("Macro");
 				} else {  /* must be a regular app call */
 					char *strp3;
@@ -3023,6 +3024,8 @@
 					strp3 = strchr(buf2,'(');
 					if (strp3) {
 						*strp3 = 0;
+						if (for_init->app)
+							free(for_init->app);
 						for_init->app = strdup(buf2);
 						for_init->appargs = strdup(strp3+1);
 						strp3 = strrchr(for_init->appargs, ')');

Modified: team/file/t38fun/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/res/res_jabber.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/res/res_jabber.c (original)
+++ team/file/t38fun/res/res_jabber.c Fri Nov  9 10:36:29 2007
@@ -2354,6 +2354,7 @@
 		}
 		cat = ast_category_browse(cfg, cat);
 	}
+	ast_config_destroy(cfg); /* or leak memory */
 	return 1;
 }
 

Modified: team/file/t38fun/res/res_musiconhold.c
URL: http://svn.digium.com/view/asterisk/team/file/t38fun/res/res_musiconhold.c?view=diff&rev=89131&r1=89130&r2=89131
==============================================================================
--- team/file/t38fun/res/res_musiconhold.c (original)
+++ team/file/t38fun/res/res_musiconhold.c Fri Nov  9 10:36:29 2007
@@ -231,6 +231,11 @@
 		chan->stream = NULL;
 	}
 
+	if (!state->class->total_files) {
+		ast_log(LOG_WARNING, "No files available for class '%s'\n", state->class->name);
+		return -1;
+	}
+
 	/* If a specific file has been saved, use it */
 	if (state->save_pos >= 0) {
 		state->pos = state->save_pos;
@@ -321,7 +326,7 @@
 			/* initialize */
 			memset(state, 0, sizeof(*state));
 			state->class = class;
-			if (ast_test_flag(state->class, MOH_RANDOMIZE))
+			if (ast_test_flag(state->class, MOH_RANDOMIZE) && class->total_files)
 				state->pos = ast_random() % class->total_files;
 		}
 
@@ -1259,8 +1264,15 @@
 			AST_LIST_REMOVE_CURRENT(&mohclasses, list);
 			if (!moh->inuse)
 				ast_moh_destroy_one(moh);
-		} else if (moh->total_files)
-			moh_scan_files(moh);
+		} else if (moh->total_files) {
+			if (moh_scan_files(moh) <= 0) {
+				ast_log(LOG_WARNING, "No files found for class '%s'\n", moh->name);
+				moh->delete = 1;
+				AST_LIST_REMOVE_CURRENT(&mohclasses, list);
+				if (!moh->inuse)
+					ast_moh_destroy_one(moh);
+			}
+		}
 	}
 	AST_LIST_TRAVERSE_SAFE_END
 	AST_LIST_UNLOCK(&mohclasses);




More information about the svn-commits mailing list