[asterisk-commits] oej: branch oej/codename-pineapple r52331 - in /team/oej/codename-pineapple: ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Jan 26 09:54:55 MST 2007


Author: oej
Date: Fri Jan 26 10:54:54 2007
New Revision: 52331

URL: http://svn.digium.com/view/asterisk?view=rev&rev=52331
Log:
Resolve conflict caused by disabling /utils compilation...

Added:
    team/oej/codename-pineapple/include/asterisk/dial.h
      - copied unchanged from r52308, trunk/include/asterisk/dial.h
    team/oej/codename-pineapple/main/dial.c
      - copied unchanged from r52308, trunk/main/dial.c
Modified:
    team/oej/codename-pineapple/   (props changed)
    team/oej/codename-pineapple/CHANGES
    team/oej/codename-pineapple/UPGRADE.txt
    team/oej/codename-pineapple/apps/app_chanisavail.c
    team/oej/codename-pineapple/apps/app_mixmonitor.c
    team/oej/codename-pineapple/apps/app_page.c
    team/oej/codename-pineapple/apps/app_voicemail.c
    team/oej/codename-pineapple/channels/chan_sip.c
    team/oej/codename-pineapple/configs/users.conf.sample
    team/oej/codename-pineapple/main/Makefile
    team/oej/codename-pineapple/main/db.c
    team/oej/codename-pineapple/main/jitterbuf.c
    team/oej/codename-pineapple/utils/Makefile
    team/oej/codename-pineapple/utils/check_expr.c

Propchange: team/oej/codename-pineapple/
------------------------------------------------------------------------------
    automerge = http://edvina.net/training/

Propchange: team/oej/codename-pineapple/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/oej/codename-pineapple/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/oej/codename-pineapple/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jan 26 10:54:54 2007
@@ -1,1 +1,1 @@
-/trunk:1-52026
+/trunk:1-52330

Modified: team/oej/codename-pineapple/CHANGES
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/CHANGES?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/CHANGES (original)
+++ team/oej/codename-pineapple/CHANGES Fri Jan 26 10:54:54 2007
@@ -66,6 +66,7 @@
   * Added 's' option to Page application.
   * Added the srvlookup option to iax.conf
   * Added 'E' and 'V' commands to ExternalIVR.
+  * Added 'DBDel' and 'DBDelTree' manager commands.
 
 SIP changes
 -----------

Modified: team/oej/codename-pineapple/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/UPGRADE.txt?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/UPGRADE.txt (original)
+++ team/oej/codename-pineapple/UPGRADE.txt Fri Jan 26 10:54:54 2007
@@ -31,3 +31,6 @@
   to make them more distinguishable from 'maxmsgs', which sets folder
   size.  The old variables will continue to work in this version, albeit
   with a deprecation warning.
+* ChanIsAvail() now has a 't' option, which allows the specified device
+  to be queried for state without consulting the channel drivers. This
+  performs mostly a 'ChanExists' sort of function.

Modified: team/oej/codename-pineapple/apps/app_chanisavail.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/apps/app_chanisavail.c?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/apps/app_chanisavail.c (original)
+++ team/oej/codename-pineapple/apps/app_chanisavail.c Fri Jan 26 10:54:54 2007
@@ -61,12 +61,14 @@
 "  ${AVAILSTATUS}   - the status code for the available channel\n"
 "  Options:\n"
 "    s - Consider the channel unavailable if the channel is in use at all\n"
+"    t - Simply checks if specified channels exist in the channel list\n"
+"        (implies option s) \n"
 "    j - Support jumping to priority n+101 if no channel is available\n";
 
 
 static int chanavail_exec(struct ast_channel *chan, void *data)
 {
-	int res=-1, inuse=-1, option_state=0, priority_jump=0;
+	int res=-1, inuse=-1, option_state=0, priority_jump=0, string_compare=0;
 	int status;
 	struct ast_module_user *u;
 	char *info, tmp[512], trychan[512], *peers, *tech, *number, *rest, *cur;
@@ -90,6 +92,8 @@
 	if (args.options) {
 		if (strchr(args.options, 's'))
 			option_state = 1;
+		if (strchr(args.options, 't'))
+			string_compare = 1;
 		if (strchr(args.options, 'j'))
 			priority_jump = 1;
 	}
@@ -113,7 +117,13 @@
 			*number = '\0';
 			number++;
 			
-			if (option_state) {
+			if (string_compare) {
+				/* ast_parse_device_state checks for "SIP/1234" as a channel name. 
+				   ast_device_state will ask the SIP driver for the channel state. */
+
+				snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
+				status = inuse = ast_parse_device_state(trychan);
+			} else if (option_state) {
 				/* If the pbx says in use then don't bother trying further.
 				   This is to permit testing if someone's on a call, even if the 
 	 			   channel can permit more calls (ie callwaiting, sip calls, etc).  */

Modified: team/oej/codename-pineapple/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/apps/app_mixmonitor.c?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/apps/app_mixmonitor.c (original)
+++ team/oej/codename-pineapple/apps/app_mixmonitor.c Fri Jan 26 10:54:54 2007
@@ -68,7 +68,8 @@
 "Valid options:\n"
 " a      - Append to the file instead of overwriting it.\n"
 " b      - Only save audio to the file while the channel is bridged.\n"
-"          Note: does not include conferences.\n"
+"          Note: Does not include conferences or sounds played to each bridged\n"
+"                party.\n"
 " v(<x>) - Adjust the heard volume by a factor of <x> (range -4 to 4)\n"	
 " V(<x>) - Adjust the spoken volume by a factor of <x> (range -4 to 4)\n"	
 " W(<x>) - Adjust the both heard and spoken volumes by a factor of <x>\n"

Modified: team/oej/codename-pineapple/apps/app_page.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/apps/app_page.c?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/apps/app_page.c (original)
+++ team/oej/codename-pineapple/apps/app_page.c Fri Jan 26 10:54:54 2007
@@ -49,6 +49,7 @@
 #include "asterisk/chanvars.h"
 #include "asterisk/utils.h"
 #include "asterisk/devicestate.h"
+#include "asterisk/dial.h"
 
 static const char *app_page= "Page";
 
@@ -79,89 +80,18 @@
 	AST_APP_OPTION('s', PAGE_SKIP),
 });
 
-struct calloutdata {
-	char cidnum[64];
-	char cidname[64];
-	char tech[64];
-	char resource[256];
-	char meetmeopts[64];
-	struct ast_variable *variables;
-};
-
-static void *page_thread(void *data)
-{
-	struct calloutdata *cd = data;
-
-	ast_pbx_outgoing_app(cd->tech, AST_FORMAT_SLINEAR, cd->resource, 30000,
-		"MeetMe", cd->meetmeopts, NULL, 0, cd->cidnum, cd->cidname, cd->variables, NULL, NULL);
-
-	free(cd);
-
-	return NULL;
-}
-
-static void launch_page(struct ast_channel *chan, const char *meetmeopts, const char *tech, const char *resource)
-{
-	struct calloutdata *cd;
-	const char *varname;
-	struct ast_variable *lastvar = NULL;
-	struct ast_var_t *varptr;
-	pthread_t t;
-	pthread_attr_t attr;
-
-	if (!(cd = ast_calloc(1, sizeof(*cd))))
-		return;
-
-	/* Copy data from our page over */
-	ast_copy_string(cd->cidnum, chan->cid.cid_num ? chan->cid.cid_num : "", sizeof(cd->cidnum));
-	ast_copy_string(cd->cidname, chan->cid.cid_name ? chan->cid.cid_name : "", sizeof(cd->cidname));
-	ast_copy_string(cd->tech, tech, sizeof(cd->tech));
-	ast_copy_string(cd->resource, resource, sizeof(cd->resource));
-	ast_copy_string(cd->meetmeopts, meetmeopts, sizeof(cd->meetmeopts));
-	
-	AST_LIST_TRAVERSE(&chan->varshead, varptr, entries) {
-		struct ast_variable *newvar = NULL;
-
-		if (!(varname = ast_var_full_name(varptr)) || (varname[0] != '_'))
-			continue;
-			
-		if (varname[1] == '_')
-			newvar = ast_variable_new(varname, ast_var_value(varptr));
-		else
-			newvar = ast_variable_new(&varname[1], ast_var_value(varptr));
-		
-		if (newvar) {
-			if (lastvar)
-				lastvar->next = newvar;
-			else
-				cd->variables = newvar;
-			lastvar = newvar;
-		}
-	}
-
-	/* Spawn thread to handle this page */
-	pthread_attr_init(&attr);
-	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-	if (ast_pthread_create(&t, &attr, page_thread, cd)) {
-		ast_log(LOG_WARNING, "Unable to create paging thread: %s\n", strerror(errno));
-		free(cd);
-	}
-
-	return;
-}
+#define MAX_DIALS 128
 
 static int page_exec(struct ast_channel *chan, void *data)
 {
 	struct ast_module_user *u;
-	char *options;
-	char *tech, *resource;
-	char meetmeopts[80];
+	char *options, *tech, *resource, *tmp;
+	char meetmeopts[88], originator[AST_CHANNEL_NAME];
 	struct ast_flags flags = { 0 };
 	unsigned int confid = ast_random();
 	struct ast_app *app;
-	char *tmp;
-	int res=0;
-	char originator[AST_CHANNEL_NAME];
+	int res = 0, pos = 0, i = 0;
+	struct ast_dial *dials[MAX_DIALS];
 
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "This application requires at least one argument (destination(s) to page)\n");
@@ -186,16 +116,19 @@
 	if (options)
 		ast_app_parse_options(page_opts, &flags, NULL, options);
 
-	snprintf(meetmeopts, sizeof(meetmeopts), "%ud|%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"),
+	snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe|%ud|%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"),
 		(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );
 
+	/* Go through parsing/calling each device */
 	while ((tech = strsep(&tmp, "&"))) {
 		int state = 0;
+		struct ast_dial *dial = NULL;
 
 		/* don't call the originating device */
 		if (!strcasecmp(tech, originator))
 			continue;
 
+		/* If no resource is available, continue on */
 		if (!(resource = strchr(tech, '/'))) {
 			ast_log(LOG_WARNING, "Incomplete destination '%s' supplied.\n", tech);
 			continue;
@@ -206,9 +139,26 @@
 			ast_log(LOG_WARNING, "Destination '%s' has device state '%s'.\n", tech, devstate2str(state));
 			continue;
 		}
-		
+
 		*resource++ = '\0';
-		launch_page(chan, meetmeopts, tech, resource);
+
+		/* Create a dialing structure */
+		if (!(dial = ast_dial_create())) {
+			ast_log(LOG_WARNING, "Failed to create dialing structure.\n");
+			continue;
+		}
+
+		/* Append technology and resource */
+		ast_dial_append(dial, tech, resource);
+
+		/* Set ANSWER_EXEC as global option */
+		ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, meetmeopts);
+
+		/* Run this dial in async mode */
+		ast_dial_run(dial, chan, 1);
+
+		/* Put in our dialing array */
+		dials[pos++] = dial;
 	}
 
 	if (!ast_test_flag(&flags, PAGE_QUIET)) {
@@ -223,6 +173,21 @@
 		pbx_exec(chan, app, meetmeopts);
 	}
 
+	/* Go through each dial attempt cancelling, joining, and destroying */
+	for (i = 0; i < pos; i++) {
+		struct ast_dial *dial = dials[i];
+
+		/* If the dial is already answered, then they will/should get kicked out by Meetme */
+		if (ast_dial_status(dial) != AST_DIAL_RESULT_ANSWERED)
+			ast_dial_join(dial);
+
+		/* Hangup all channels */
+		ast_dial_hangup(dial);
+
+		/* Destroy dialing structure */
+		ast_dial_destroy(dial);
+	}
+
 	ast_module_user_remove(u);
 
 	return -1;

Modified: team/oej/codename-pineapple/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/apps/app_voicemail.c?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/apps/app_voicemail.c (original)
+++ team/oej/codename-pineapple/apps/app_voicemail.c Fri Jan 26 10:54:54 2007
@@ -678,9 +678,9 @@
 	struct ast_variable *tmp;
 	tmp = var;
 	while (tmp) {
-		if (!strcasecmp(tmp->name, "vmpassword")) {
+		if (!strcasecmp(tmp->name, "vmsecret")) {
 			ast_copy_string(retval->password, tmp->value, sizeof(retval->password));
-		} else if (!strcasecmp(tmp->name, "secret") || !strcasecmp(tmp->name, "password")) { /* don't overwrite vmpassword if it exists */
+		} else if (!strcasecmp(tmp->name, "secret") || !strcasecmp(tmp->name, "password")) { /* don't overwrite vmsecret if it exists */
 			if (ast_strlen_zero(retval->password))
 				ast_copy_string(retval->password, tmp->value, sizeof(retval->password));
 		} else if (!strcasecmp(tmp->name, "uniqueid")) {
@@ -823,7 +823,7 @@
 	category = NULL;
 	var = NULL;
 	/* check users.conf and update the password stored for the mailbox*/
-	/* if no vmpassword entry exists create one. */
+	/* if no vmsecret entry exists create one. */
 	if ((cfg = ast_config_load_with_comments("users.conf"))) {
 		if (option_debug > 3)
 			ast_log(LOG_DEBUG, "we are looking for %s\n", vmu->mailbox);
@@ -831,10 +831,10 @@
 			if (option_debug > 3)
 				ast_log(LOG_DEBUG, "users.conf: %s\n", category);
 			if (!strcasecmp(category, vmu->mailbox)) {
-				if (!(tmp = ast_variable_retrieve(cfg, category, "vmpassword"))) {
+				if (!(tmp = ast_variable_retrieve(cfg, category, "vmsecret"))) {
 					if (option_debug > 3)
-						ast_log(LOG_DEBUG, "looks like we need to make vmpassword!\n");
-					var = ast_variable_new("vmpassword", newpassword);
+						ast_log(LOG_DEBUG, "looks like we need to make vmsecret!\n");
+					var = ast_variable_new("vmsecret", newpassword);
 				} 
 				new = alloca(strlen(newpassword)+1);
 				sprintf(new, "%s", newpassword);
@@ -844,7 +844,7 @@
 					break;
 				}
 				if (!var)		
-					ast_variable_update(cat, "vmpassword", new, NULL);
+					ast_variable_update(cat, "vmsecret", new, NULL);
 				else
 					ast_variable_append(cat, var);
 			}

Modified: team/oej/codename-pineapple/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/chan_sip.c?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/channels/chan_sip.c (original)
+++ team/oej/codename-pineapple/channels/chan_sip.c Fri Jan 26 10:54:54 2007
@@ -3126,6 +3126,7 @@
 
 	if (option_debug > 2)
 		ast_log(LOG_DEBUG, "Updating call counter for %s call\n", outgoing ? "outgoing" : "incoming");
+
 	/* Test if we need to check call limits, in order to avoid 
 	   realtime lookups if we do not need it */
 	if (!ast_test_flag(&fup->flags[0], SIP_CALL_LIMIT))
@@ -3153,28 +3154,26 @@
 	switch(event) {
 	/* incoming and outgoing affects the inUse counter */
 	case DEC_CALL_LIMIT:
-		if ( *inuse > 0 ) {
-			if (ast_test_flag(&fup->flags[0], SIP_INC_COUNT))
-				(*inuse)--;
-		} else {
+		/* Decrement inuse count if applicable */
+		if (inuse && ast_test_flag(&fup->flags[0], SIP_INC_COUNT))
+			ast_atomic_fetchadd_int(inuse, -1);
+		else
 			*inuse = 0;
-		}
-		if (inringing) {
-			if (ast_test_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING)) {
-				if (*inringing > 0)
-					(*inringing)--;
-				else
-					ast_log(LOG_WARNING, "Inringing for peer '%s' < 0?\n", fup->peername);
-				ast_clear_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING);
-			}
-		}
-		if (option_debug > 1 || sipdebug) {
+		/* Decrement ringing count if applicable */
+		if (inringing && ast_test_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING)) {
+			ast_atomic_fetchadd_int(inringing, -1);
+			ast_clear_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING);
+		}
+		/* Decrement onhold count if applicable */
+		if (ast_test_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD) && global_notifyhold)
+			sip_peer_hold(fup, FALSE);
+		if (option_debug > 1 || sipdebug)
 			ast_log(LOG_DEBUG, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *call_limit);
-		}
 		break;
 
 	case INC_CALL_RINGING:
 	case INC_CALL_LIMIT:
+		/* If call limit is active and we have reached the limit, reject the call */
 		if (*call_limit > 0 ) {
 			if (*inuse >= *call_limit) {
 				ast_log(LOG_ERROR, "Call %s %s '%s' rejected due to usage limit of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *call_limit);
@@ -3187,12 +3186,12 @@
 		}
 		if (inringing && (event == INC_CALL_RINGING)) {
 			if (!ast_test_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING)) {
-				(*inringing)++;
+				ast_atomic_fetchadd_int(inringing, +1);
 				ast_set_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING);
 			}
 		}
 		/* Continue */
-		(*inuse)++;
+		ast_atomic_fetchadd_int(inuse, +1);
 		ast_set_flag(&fup->flags[0], SIP_INC_COUNT);
 		if (option_debug > 1 || sipdebug) {
 			ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit);
@@ -3200,14 +3199,9 @@
 		break;
 
 	case DEC_CALL_RINGING:
-		if (inringing) {
-			if (ast_test_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING)) {
-				if (*inringing > 0)
-					(*inringing)--;
-				else
-					ast_log(LOG_WARNING, "Inringing for peer '%s' < 0?\n", p->name);
-				ast_clear_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING);
-			}
+		if (inringing && ast_test_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING)) {
+			ast_atomic_fetchadd_int(inringing, -1);
+			ast_clear_flag(&fup->flags[1], SIP_PAGE2_INC_RINGING);
 		}
 		break;
 
@@ -8225,9 +8219,9 @@
 
 	/* If they put someone on hold, increment the value... otherwise decrement it */
 	if (hold)
-		peer->onHold++;
+		ast_atomic_fetchadd_int(&peer->onHold, +1);
 	else
-		peer->onHold--;
+		ast_atomic_fetchadd_int(&peer->onHold, -1);
 
 	/* Request device state update */
 	ast_device_state_changed("SIP/%s", peer->name);

Modified: team/oej/codename-pineapple/configs/users.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/configs/users.conf.sample?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/configs/users.conf.sample (original)
+++ team/oej/codename-pineapple/configs/users.conf.sample Fri Jan 26 10:54:54 2007
@@ -28,7 +28,7 @@
 ;
 ; Set voicemail mailbox 6000 password to 1234
 ;
-vmpassword = 1234
+vmsecret = 1234
 ;
 ; Create SIP Peer
 ;

Modified: team/oej/codename-pineapple/main/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/main/Makefile?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/main/Makefile (original)
+++ team/oej/codename-pineapple/main/Makefile Fri Jan 26 10:54:54 2007
@@ -26,7 +26,7 @@
 	utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
 	netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
 	cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
-	strcompat.o threadstorage.o
+	strcompat.o threadstorage.o dial.o
 
 # we need to link in the objects statically, not as a library, because
 # otherwise modules will not have them available if none of the static

Modified: team/oej/codename-pineapple/main/db.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/main/db.c?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/main/db.c (original)
+++ team/oej/codename-pineapple/main/db.c Fri Jan 26 10:54:54 2007
@@ -588,11 +588,62 @@
 	return 0;
 }
 
+static int manager_dbdel(struct mansession *s, const struct message *m)
+{
+	const char *family = astman_get_header(m, "Family");
+	const char *key = astman_get_header(m, "Key");
+	int res;
+
+	if (ast_strlen_zero(family)) {
+		astman_send_error(s, m, "No family specified.");
+		return 0;
+	}
+
+	if (ast_strlen_zero(key)) {
+		astman_send_error(s, m, "No key specified.");
+		return 0;
+	}
+
+	res = ast_db_del(family, key);
+	if (res)
+		astman_send_error(s, m, "Database entry not found");
+	else
+		astman_send_ack(s, m, "Key deleted successfully");
+
+	return 0;
+}
+
+static int manager_dbdeltree(struct mansession *s, const struct message *m)
+{
+	const char *family = astman_get_header(m, "Family");
+	const char *key = astman_get_header(m, "Key");
+	int res;
+
+	if (ast_strlen_zero(family)) {
+		astman_send_error(s, m, "No family specified.");
+		return 0;
+	}
+
+	if (!ast_strlen_zero(key))
+		res = ast_db_deltree(family, key);
+	else
+		res = ast_db_deltree(family, NULL);
+
+	if (res)
+		astman_send_error(s, m, "Database entry not found");
+	else
+		astman_send_ack(s, m, "Key tree deleted successfully");
+	
+	return 0;
+}
+
 int astdb_init(void)
 {
 	dbinit();
 	ast_cli_register_multiple(cli_database, sizeof(cli_database) / sizeof(struct ast_cli_entry));
 	ast_manager_register("DBGet", EVENT_FLAG_SYSTEM, manager_dbget, "Get DB Entry");
 	ast_manager_register("DBPut", EVENT_FLAG_SYSTEM, manager_dbput, "Put DB Entry");
-	return 0;
-}
+	ast_manager_register("DBDel", EVENT_FLAG_SYSTEM, manager_dbdel, "Delete DB Entry");
+	ast_manager_register("DBDelTree", EVENT_FLAG_SYSTEM, manager_dbdeltree, "Delete DB Tree");
+	return 0;
+}

Modified: team/oej/codename-pineapple/main/jitterbuf.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/main/jitterbuf.c?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/main/jitterbuf.c (original)
+++ team/oej/codename-pineapple/main/jitterbuf.c Fri Jan 26 10:54:54 2007
@@ -756,8 +756,8 @@
 long jb_next(jitterbuf *jb) 
 {
 	if (jb->info.silence_begin_ts) {
-		long next = queue_next(jb);
-		if (next > 0) { 
+		if (jb->frames) {
+			long next = queue_next(jb);
 			history_get(jb);
 			/* shrink during silence */
 			if (jb->info.target - jb->info.current < -jb->info.conf.target_extra)

Modified: team/oej/codename-pineapple/utils/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/utils/Makefile?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/utils/Makefile (original)
+++ team/oej/codename-pineapple/utils/Makefile Fri Jan 26 10:54:54 2007
@@ -13,7 +13,8 @@
 
 .PHONY: clean all uninstall
 
-ALL_UTILS:=astman smsq stereorize streamplayer aelparse #muted
+# to get check_expr, add it to the ALL_UTILS list
+ALL_UTILS:=#astman smsq stereorize streamplayer aelparse muted check_expr
 UTILS:=$(ALL_UTILS)
 
 include $(ASTTOPDIR)/Makefile.rules
@@ -85,7 +86,7 @@
 
 ast_expr2f.o: ASTCFLAGS+=-DSTANDALONE_AEL -I../main
 
-check_expr: check_expr.c ast_expr2.o ast_expr2f.o
+check_expr: check_expr.o ast_expr2.o ast_expr2f.o
 
 aelbison.c: ../pbx/ael/ael.tab.c
 	@cp $< $@

Modified: team/oej/codename-pineapple/utils/check_expr.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/utils/check_expr.c?view=diff&rev=52331&r1=52330&r2=52331
==============================================================================
--- team/oej/codename-pineapple/utils/check_expr.c (original)
+++ team/oej/codename-pineapple/utils/check_expr.c Fri Jan 26 10:54:54 2007
@@ -23,12 +23,12 @@
 #include <stdlib.h>
 #include <../include/asterisk/ast_expr.h>
 
-int global_lineno = 1;
-int global_expr_count = 0;
-int global_expr_max_size = 0;
-int global_expr_tot_size = 0;
-int global_warn_count = 0;
-int global_OK_count = 0;
+static int global_lineno = 1;
+static int global_expr_count=0;
+static int global_expr_max_size=0;
+static int global_expr_tot_size=0;
+static int global_warn_count=0;
+static int global_OK_count=0;
 
 struct varz
 {
@@ -54,6 +54,22 @@
 	fflush(stdout);
 	va_end(vars);
 }
+void ast_register_file_version(const char *file, const char *version);
+void ast_unregister_file_version(const char *file);
+
+char *find_var(const char *varname);
+void set_var(const char *varname, const char *varval);
+unsigned int check_expr(char* buffer, char* error_report);
+int check_eval(char *buffer, char *error_report);
+void parse_file(const char *fname);
+
+void ast_register_file_version(const char *file, const char *version)
+{
+}
+
+void ast_unregister_file_version(const char *file)
+{
+}
 
 char *find_var(const char *varname) /* the list should be pretty short, if there's any list at all */
 {
@@ -68,7 +84,7 @@
 
 void set_var(const char *varname, const char *varval)
 {
-	struct varz *t = calloc(1,sizeof(struct varz));
+	struct varz *t = (struct varz*)calloc(1,sizeof(struct varz));
 	if (!t)
 		return;
 	strcpy(t->varname, varname);
@@ -77,75 +93,79 @@
 	global_varlist = t;
 }
 
-int check_expr(char *buffer, char *error_report)
-{
-	char *cp;
-	int oplen = 0;
-	int warn_found = 0;
+unsigned int check_expr(char* buffer, char* error_report)
+{
+	char* cp;
+	unsigned int warn_found = 0;
 
 	error_report[0] = 0;
 	
-	for (cp=buffer;*cp;cp++) {
-		
-		if (*cp == '|' 
-			|| *cp == '&'
-			|| *cp == '='
-			|| *cp == '>'
-			|| *cp == '<'
-			|| *cp == '+'
-			|| *cp == '-'
-			|| *cp == '*'
-			|| *cp == '/'
-			|| *cp == '%'
-			|| *cp == '?'
-			|| *cp == ':'
-			/*	|| *cp == '('
-				|| *cp == ')' These are pretty hard to track, as they are in funcalls, etc. */
-			|| *cp == '"') {
-			if (*cp == '"') {
+	for (cp = buffer; *cp; ++cp)
+	{
+		switch (*cp)
+		{
+			case '"':
 				/* skip to the other end */
-				cp++;
-				while (*cp && *cp != '"')
-					cp++;
-				if (*cp == 0) {
-					fprintf(stderr,"Trouble? Unterminated double quote found at line %d\n",
-							global_lineno);
-				}
-			}
-			else {
-				if ((*cp == '>'||*cp == '<' ||*cp=='!') && (*(cp+1) == '=')) {
-					oplen = 2;
-				}
-				else {
-					oplen = 1;
-				}
-				
-				if ((cp > buffer && *(cp-1) != ' ') || *(cp+oplen) != ' ') {
-					char tbuf[1000];
-					if (oplen == 1)
-						sprintf(tbuf,"WARNING: line %d,  '%c' operator not separated by spaces. This may lead to confusion. You may wish to use double quotes to quote the grouping it is in. Please check!\n",
-								global_lineno, *cp);
-					else
-						sprintf(tbuf,"WARNING: line %d,  '%c%c' operator not separated by spaces. This may lead to confusion. You may wish to use double quotes to quote the grouping it is in. Please check!\n",
-								global_lineno, *cp, *(cp+1));
-					strcat(error_report,tbuf);
-
-					global_warn_count++;
-					warn_found++;
-				}
-			}
-		}
-	}
+				while (*(++cp) && *cp != '"') ;
+
+				if (*cp == 0)
+				{
+					fprintf(stderr,
+						"Trouble? Unterminated double quote found at line %d\n",
+						global_lineno);
+				}
+				break;
+				
+			case '>':
+			case '<':
+			case '!':
+				if (   (*(cp + 1) == '=')
+					&& ( ( (cp > buffer) && (*(cp - 1) != ' ') ) || (*(cp + 2) != ' ') ) )
+				{
+					char msg[200];
+					snprintf(msg,
+						sizeof(msg),
+						"WARNING: line %d: '%c%c' operator not separated by spaces. This may lead to confusion. You may wish to use double quotes to quote the grouping it is in. Please check!\n",
+						global_lineno, *cp, *(cp + 1));
+					strcat(error_report, msg);
+					++global_warn_count;
+					++warn_found;
+				}
+				break;
+				
+			case '|':
+			case '&':
+			case '=':
+			case '+':
+			case '-':
+			case '*':
+			case '/':
+			case '%':
+			case '?':
+			case ':':
+				if ( ( (cp > buffer) && (*(cp - 1) != ' ') ) || (*(cp + 1) != ' ') )
+				{
+					char msg[200];
+					snprintf(msg,
+						sizeof(msg),
+						"WARNING: line %d: '%c' operator not separated by spaces. This may lead to confusion. You may wish to use double quotes to quote the grouping it is in. Please check!\n",
+						global_lineno, *cp );
+					strcat(error_report, msg);
+					++global_warn_count;
+					++warn_found;
+				}
+				break;
+		}
+	}
+
 	return warn_found;
 }
 
 int check_eval(char *buffer, char *error_report)
 {
-	char *cp, *ep, *xp;
+	char *cp, *ep;
 	char s[4096];
 	char evalbuf[80000];
-	int oplen = 0;
-	int warn_found = 0;
 	int result;
 
 	error_report[0] = 0;
@@ -221,7 +241,7 @@
 	char buffer[30000]; /* I sure hope no expr gets this big! */
 	
 	if (!f) {
-		fprintf(stderr,"Couldn't open %s for reading... need an extensions.conf file to parse!\n");
+		fprintf(stderr,"Couldn't open %s for reading... need an extensions.conf file to parse!\n",fname);
 		exit(20);
 	}
 	if (!l) {
@@ -303,13 +323,23 @@
 }
 
 
-main(int argc,char **argv)
+int main(int argc,char **argv)
 {
 	int argc1;
 	char *eq;
 	
 	if (argc < 2) {
+		printf("check_expr -- a program to look thru extensions.conf files for $[...] expressions,\n");
+		printf("              and run them thru the parser, looking for problems\n");
 		printf("Hey-- give me a path to an extensions.conf file!\n");
+		printf(" You can also follow the file path with a series of variable decls,\n");
+		printf("     of the form, varname=value, each separated from the next by spaces.\n");
+		printf("     (this might allow you to avoid division by zero messages, check that math\n");
+		printf("      is being done correctly, etc.)\n");
+		printf(" Note that messages about operators not being surrounded by spaces is merely to alert\n");
+		printf("  you to possible problems where you might be expecting those operators as part of a string.\n");
+        printf("  (to include operators in a string, wrap with double quotes!)\n");
+		
 		exit(19);
 	}
 	global_varlist = 0;
@@ -323,4 +353,5 @@
 	/* parse command args for x=y and set varz */
 	
 	parse_file(argv[1]);
-}
+	return 0;
+}



More information about the asterisk-commits mailing list