[asterisk-commits] mnicholson: branch group/newcdr r192211 - in /team/group/newcdr: ./ configs/ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 4 16:45:01 CDT 2009


Author: mnicholson
Date: Mon May  4 16:44:57 2009
New Revision: 192211

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=192211
Log:
Merged revisions 191848,191884,191919,191955,191997 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
  r191848 | russell | 2009-05-02 16:15:18 -0500 (Sat, 02 May 2009) | 7 lines
  
  Do a bit of code cleanup.
  
   - convert handling of IE PLTYPEs to switch statements
   - add braces to various small blocks
   - remove a bit of trailing whitespace
   - remove a couple of unnecessary ast_strdupa() uses
........
  r191884 | russell | 2009-05-03 09:05:10 -0500 (Sun, 03 May 2009) | 2 lines
  
  Remove unnecessary compiler flag
........
  r191919 | kpfleming | 2009-05-03 09:28:59 -0500 (Sun, 03 May 2009) | 11 lines
  
  Add 'bitflags'-style information elements to event framework
  
  This patch add a new payload type for information elements, a set
  of bit flags. The payload is transported as a 32-bit unsigned integer
  but when matching is performed between events and subscribers,
  the matching is done by using a bitwise AND instead of numeric value
  comparison.
  
  Review: http://reviewboard.asterisk.org/r/242/
........
  r191955 | kpfleming | 2009-05-04 04:57:36 -0500 (Mon, 04 May 2009) | 8 lines
  
  Ensure that by default only one console channel driver is loaded
  
  This configuration file was changed to ensure that only one console channel driver
  (chan_oss) is loaded by default, but the change would only work if chan_console
  was not built. Now it will work as expected; if chan_alsa or chan_console are built
  and installed, they will not be loaded unless explicity requested.
........
  r191997 | kpfleming | 2009-05-04 07:52:44 -0500 (Mon, 04 May 2009) | 5 lines
  
  Minor changes in test modules
  
  Correct command description in test_sched.c and include asterisk/cli.h in test_skel.c, since it's highly unlikely that a test module will *not* want to provide CLI commands to execute the tests
........

Modified:
    team/group/newcdr/   (props changed)
    team/group/newcdr/Makefile
    team/group/newcdr/configs/modules.conf.sample
    team/group/newcdr/include/asterisk/event.h
    team/group/newcdr/include/asterisk/event_defs.h
    team/group/newcdr/main/event.c
    team/group/newcdr/main/pbx.c
    team/group/newcdr/tests/test_sched.c
    team/group/newcdr/tests/test_skel.c
    team/group/newcdr/tests/test_substitution.c

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
    automerge = on

Propchange: team/group/newcdr/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon May  4 16:44:57 2009
@@ -1,1 +1,1 @@
-/trunk:1-191803
+/trunk:1-192031

Modified: team/group/newcdr/Makefile
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/Makefile?view=diff&rev=192211&r1=192210&r2=192211
==============================================================================
--- team/group/newcdr/Makefile (original)
+++ team/group/newcdr/Makefile Mon May  4 16:44:57 2009
@@ -306,7 +306,7 @@
 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
 
 ifneq ($(findstring darwin,$(OSARCH)),)
-  ASTCFLAGS+=-D__Darwin__ -fnested-functions
+  ASTCFLAGS+=-D__Darwin__
   SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
 else
 # These are used for all but Darwin

Modified: team/group/newcdr/configs/modules.conf.sample
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/configs/modules.conf.sample?view=diff&rev=192211&r1=192210&r2=192211
==============================================================================
--- team/group/newcdr/configs/modules.conf.sample (original)
+++ team/group/newcdr/configs/modules.conf.sample Mon May  4 16:44:57 2009
@@ -33,7 +33,7 @@
 ;
 noload => chan_alsa.so
 ;noload => chan_oss.so
-;noload => chan_console.so
+noload => chan_console.so
 ;
 ;
 ; Only load one timing interface.  If DAHDI is available, use that as it will

Modified: team/group/newcdr/include/asterisk/event.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/include/asterisk/event.h?view=diff&rev=192211&r1=192210&r2=192211
==============================================================================
--- team/group/newcdr/include/asterisk/event.h (original)
+++ team/group/newcdr/include/asterisk/event.h Mon May  4 16:44:57 2009
@@ -157,6 +157,20 @@
 	enum ast_event_ie_type ie_type, uint32_t uint);
 
 /*!
+ * \brief Append a bitflags parameter to a subscription
+ *
+ * \param sub the dynamic subscription allocated with ast_event_subscribe_new()
+ * \param ie_type the information element type for the parameter
+ * \param flags the flags that must be present in the event to match this subscription
+ *
+ * \retval 0 success
+ * \retval non-zero failure
+ * \since 1.6.3
+ */
+int ast_event_sub_append_ie_bitflags(struct ast_event_sub *sub,
+	enum ast_event_ie_type ie_type, uint32_t flags);
+
+/*!
  * \brief Append a string parameter to a subscription
  *
  * \param sub the dynamic subscription allocated with ast_event_subscribe_new()
@@ -470,6 +484,24 @@
 	uint32_t data);
 
 /*!
+ * \brief Append an information element that has a bitflags payload
+ *
+ * \param event the event that the IE will be appended to
+ * \param ie_type the type of IE to append
+ * \param flags the flags that are the payload of the IE
+ *
+ * \retval 0 success
+ * \retval -1 failure
+ * \since 1.6.3
+ *
+ * The pointer to the event will get updated with the new location for the event
+ * that now contains the appended information element.  If the re-allocation of
+ * the memory for this event fails, it will be set to NULL.
+ */
+int ast_event_append_ie_bitflags(struct ast_event **event, enum ast_event_ie_type ie_type,
+	uint32_t bitflags);
+
+/*!
  * \brief Append an information element that has a raw payload
  *
  * \param event the event that the IE will be appended to
@@ -500,6 +532,18 @@
 uint32_t ast_event_get_ie_uint(const struct ast_event *event, enum ast_event_ie_type ie_type);
 
 /*!
+ * \brief Get the value of an information element that has a bitflags payload
+ *
+ * \param event The event to get the IE from
+ * \param ie_type the type of information element to retrieve
+ *
+ * \return This returns the payload of the information element with the given type.
+ *         However, an IE with a payload of 0, and the case where no IE is found
+ *         yield the same return value.
+ */
+uint32_t ast_event_get_ie_bitflags(const struct ast_event *event, enum ast_event_ie_type ie_type);
+
+/*!
  * \brief Get the value of an information element that has a string payload
  *
  * \param event The event to get the IE from
@@ -638,13 +682,22 @@
 enum ast_event_ie_type ast_event_iterator_get_ie_type(struct ast_event_iterator *iterator);
 
 /*!
- * \brief Get the value of the current IE in the ierator as an integer payload
+ * \brief Get the value of the current IE in the iterator as an integer payload
  *
  * \param iterator The iterator instance
  *
  * \return This returns the payload of the information element as a uint.
  */
 uint32_t ast_event_iterator_get_ie_uint(struct ast_event_iterator *iterator);
+
+/*!
+ * \brief Get the value of the current IE in the iterator as a bitflags payload
+ *
+ * \param iterator The iterator instance
+ *
+ * \return This returns the payload of the information element as bitflags.
+ */
+uint32_t ast_event_iterator_get_ie_bitflags(struct ast_event_iterator *iterator);
 
 /*!
  * \brief Get the value of the current IE in the iterator as a string payload

Modified: team/group/newcdr/include/asterisk/event_defs.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/include/asterisk/event_defs.h?view=diff&rev=192211&r1=192210&r2=192211
==============================================================================
--- team/group/newcdr/include/asterisk/event_defs.h (original)
+++ team/group/newcdr/include/asterisk/event_defs.h Mon May  4 16:44:57 2009
@@ -271,6 +271,8 @@
 	AST_EVENT_IE_PLTYPE_STR,
 	/*! Raw data, compared with memcmp */
 	AST_EVENT_IE_PLTYPE_RAW,
+	/*! Bit flags (unsigned integer, compared using boolean logic) */
+	AST_EVENT_IE_PLTYPE_BITFLAGS,
 };
 
 /*!

Modified: team/group/newcdr/main/event.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/main/event.c?view=diff&rev=192211&r1=192210&r2=192211
==============================================================================
--- team/group/newcdr/main/event.c (original)
+++ team/group/newcdr/main/event.c Mon May  4 16:44:57 2009
@@ -335,6 +335,7 @@
 		ast_free(ie_val->payload.raw);
 		break;
 	case AST_EVENT_IE_PLTYPE_UINT:
+	case AST_EVENT_IE_PLTYPE_BITFLAGS:
 	case AST_EVENT_IE_PLTYPE_EXISTS:
 	case AST_EVENT_IE_PLTYPE_UNKNOWN:
 		break;
@@ -363,60 +364,104 @@
 		ie_type = va_arg(ap, enum ast_event_type))
 	{
 		struct ast_event_ie_val *ie_value = alloca(sizeof(*ie_value));
+		int insert = 1;
 		memset(ie_value, 0, sizeof(*ie_value));
 		ie_value->ie_type = ie_type;
 		ie_value->ie_pltype = va_arg(ap, enum ast_event_ie_pltype);
-		if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_UINT)
+		switch (ie_value->ie_pltype) {
+		case AST_EVENT_IE_PLTYPE_UINT:
 			ie_value->payload.uint = va_arg(ap, uint32_t);
-		else if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_STR)
-			ie_value->payload.str = ast_strdupa(va_arg(ap, const char *));
-		else if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_RAW) {
+			break;
+		case AST_EVENT_IE_PLTYPE_BITFLAGS:
+			ie_value->payload.uint = va_arg(ap, uint32_t);
+			break;
+		case AST_EVENT_IE_PLTYPE_STR:
+			ie_value->payload.str = va_arg(ap, const char *);
+			break;
+		case AST_EVENT_IE_PLTYPE_RAW:
+		{
 			void *data = va_arg(ap, void *);
 			size_t datalen = va_arg(ap, size_t);
 			ie_value->payload.raw = alloca(datalen);
 			memcpy(ie_value->payload.raw, data, datalen);
 			ie_value->raw_datalen = datalen;
-		}
-		AST_LIST_INSERT_TAIL(&ie_vals, ie_value, entry);
+			break;
+		}
+		case AST_EVENT_IE_PLTYPE_UNKNOWN:
+			insert = 0;
+		case AST_EVENT_IE_PLTYPE_EXISTS:
+			break;
+		}
+
+		if (insert) {
+			AST_LIST_INSERT_TAIL(&ie_vals, ie_value, entry);
+		}
 	}
 	va_end(ap);
 
 	AST_RWDLLIST_RDLOCK(&ast_event_subs[type]);
 	AST_RWDLLIST_TRAVERSE(&ast_event_subs[type], sub, entry) {
 		AST_LIST_TRAVERSE(&ie_vals, ie_val, entry) {
+			int break_out = 0;
+
 			AST_LIST_TRAVERSE(&sub->ie_vals, sub_ie_val, entry) {
-				if (sub_ie_val->ie_type == ie_val->ie_type)
+				if (sub_ie_val->ie_type == ie_val->ie_type) {
 					break;
+				}
 			}
+
 			if (!sub_ie_val) {
-				if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_EXISTS)
-					break;
+				/* This subscriber doesn't care about this IE, so consider
+				 * it matched. */
 				continue;
 			}
-			/* The subscriber doesn't actually care what the value is */
-			if (sub_ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_EXISTS)
-				continue;
-			if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_UINT &&
-				ie_val->payload.uint != sub_ie_val->payload.uint)
+
+			switch (ie_val->ie_pltype) {
+			case AST_EVENT_IE_PLTYPE_UINT:
+				break_out = (ie_val->payload.uint != sub_ie_val->payload.uint);
 				break;
-			if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR &&
-				strcmp(ie_val->payload.str, sub_ie_val->payload.str))
+			case AST_EVENT_IE_PLTYPE_BITFLAGS:
+				/* if the subscriber has requested *any* of the bitflags we are providing,
+				 * then it's a match
+				 */
+				break_out = (ie_val->payload.uint & sub_ie_val->payload.uint);
 				break;
-			if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_RAW &&
-				memcmp(ie_val->payload.raw, sub_ie_val->payload.raw, ie_val->raw_datalen))
+			case AST_EVENT_IE_PLTYPE_STR:
+				break_out = strcmp(ie_val->payload.str, sub_ie_val->payload.str);
 				break;
-		}
-		if (!ie_val)
-			break;
+			case AST_EVENT_IE_PLTYPE_RAW:
+				break_out = memcmp(ie_val->payload.raw,
+						sub_ie_val->payload.raw, ie_val->raw_datalen);
+				break;
+			case AST_EVENT_IE_PLTYPE_EXISTS:
+				/* The subscriber doesn't actually care what the value is */
+				break_out = 1;
+				break;
+			case AST_EVENT_IE_PLTYPE_UNKNOWN:
+				break;
+			}
+
+			if (break_out) {
+				break;
+			}
+		}
+
+		if (!ie_val) {
+			/* Everything matched */
+			break;
+		}
 	}
 	AST_RWDLLIST_UNLOCK(&ast_event_subs[type]);
 
-	if (sub) /* All parameters were matched */
+	if (sub) {
+		/* All parameters were matched */
 		return AST_EVENT_SUB_EXISTS;
+	}
 
 	AST_RWDLLIST_RDLOCK(&ast_event_subs[AST_EVENT_ALL]);
-	if (!AST_DLLIST_EMPTY(&ast_event_subs[AST_EVENT_ALL]))
+	if (!AST_DLLIST_EMPTY(&ast_event_subs[AST_EVENT_ALL])) {
 		res = AST_EVENT_SUB_EXISTS;
+	}
 	AST_RWDLLIST_UNLOCK(&ast_event_subs[AST_EVENT_ALL]);
 
 	return res;
@@ -425,14 +470,26 @@
 static int match_ie_val(const struct ast_event *event,
 		const struct ast_event_ie_val *ie_val, const struct ast_event *event2)
 {
-	if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_UINT) {
+	switch (ie_val->ie_pltype) {
+	case AST_EVENT_IE_PLTYPE_UINT:
+	{
 		uint32_t val = event2 ? ast_event_get_ie_uint(event2, ie_val->ie_type) : ie_val->payload.uint;
-		if (val == ast_event_get_ie_uint(event, ie_val->ie_type))
-			return 1;
-		return 0;
-	}
-
-	if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR) {
+
+		return (val == ast_event_get_ie_uint(event, ie_val->ie_type)) ? 1 : 0;
+	}
+
+	case AST_EVENT_IE_PLTYPE_BITFLAGS:
+	{
+		uint32_t flags = event2 ? ast_event_get_ie_uint(event2, ie_val->ie_type) : ie_val->payload.uint;
+
+		/* if the subscriber has requested *any* of the bitflags that this event provides,
+		 * then it's a match
+		 */
+		return (flags & ast_event_get_ie_bitflags(event, ie_val->ie_type)) ? 1 : 0;
+	}
+
+	case AST_EVENT_IE_PLTYPE_STR:
+	{
 		const char *str;
 		uint32_t hash;
 
@@ -449,16 +506,19 @@
 		return 0;
 	}
 
-	if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_RAW) {
+	case AST_EVENT_IE_PLTYPE_RAW:
+	{
 		const void *buf = event2 ? ast_event_get_ie_raw(event2, ie_val->ie_type) : ie_val->payload.raw;
-		if (buf && !memcmp(buf, ast_event_get_ie_raw(event, ie_val->ie_type), ie_val->raw_datalen))
-			return 1;
-		return 0;
-	}
-
-	if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_EXISTS) {
-		if (ast_event_get_ie_raw(event, ie_val->ie_type))
-			return 1;
+
+		return (buf && !memcmp(buf, ast_event_get_ie_raw(event, ie_val->ie_type), ie_val->raw_datalen)) ? 1 : 0;
+	}
+
+	case AST_EVENT_IE_PLTYPE_EXISTS:
+	{
+		return ast_event_get_ie_raw(event, ie_val->ie_type) ? 1 : 0;
+	}
+
+	case AST_EVENT_IE_PLTYPE_UNKNOWN:
 		return 0;
 	}
 
@@ -516,6 +576,9 @@
 		case AST_EVENT_IE_PLTYPE_UINT:
 			ast_event_append_ie_uint(&event, ie_val->ie_type, ie_val->payload.uint);
 			break;
+		case AST_EVENT_IE_PLTYPE_BITFLAGS:
+			ast_event_append_ie_bitflags(&event, ie_val->ie_type, ie_val->payload.uint);
+			break;
 		case AST_EVENT_IE_PLTYPE_STR:
 			ast_event_append_ie_str(&event, ie_val->ie_type, ie_val->payload.str);
 			break;
@@ -553,13 +616,15 @@
 
 	AST_RWDLLIST_RDLOCK(&ast_event_subs[event_type]);
 	AST_RWDLLIST_TRAVERSE(&ast_event_subs[event_type], sub, entry) {
-		if (event_sub == sub)
+		if (event_sub == sub) {
 			continue;
+		}
 
 		event = gen_sub_event(sub);
 
-		if (!event)
+		if (!event) {
 			continue;
+		}
 
 		event_sub->cb(event, event_sub->userdata);
 
@@ -568,7 +633,8 @@
 	AST_RWDLLIST_UNLOCK(&ast_event_subs[event_type]);
 }
 
-struct ast_event_sub *ast_event_subscribe_new(enum ast_event_type type, ast_event_cb_t cb, void *userdata)
+struct ast_event_sub *ast_event_subscribe_new(enum ast_event_type type,
+	ast_event_cb_t cb, void *userdata)
 {
 	struct ast_event_sub *sub;
 
@@ -577,8 +643,9 @@
 		return NULL;
 	}
 
-	if (!(sub = ast_calloc(1, sizeof(*sub))))
+	if (!(sub = ast_calloc(1, sizeof(*sub)))) {
 		return NULL;
+	}
 
 	sub->type = type;
 	sub->cb = cb;
@@ -593,11 +660,13 @@
 {
 	struct ast_event_ie_val *ie_val;
 
-	if (ie_type < 0 || ie_type > AST_EVENT_IE_MAX)
-		return -1;
-
-	if (!(ie_val = ast_calloc(1, sizeof(*ie_val))))
-		return -1;
+	if (ie_type < 0 || ie_type > AST_EVENT_IE_MAX) {
+		return -1;
+	}
+
+	if (!(ie_val = ast_calloc(1, sizeof(*ie_val)))) {
+		return -1;
+	}
 
 	ie_val->ie_type = ie_type;
 	ie_val->payload.uint = unsigned_int;
@@ -608,16 +677,38 @@
 	return 0;
 }
 
+int ast_event_sub_append_ie_bitflags(struct ast_event_sub *sub,
+	enum ast_event_ie_type ie_type, uint32_t flags)
+{
+	struct ast_event_ie_val *ie_val;
+
+	if (ie_type < 0 || ie_type > AST_EVENT_IE_MAX)
+		return -1;
+
+	if (!(ie_val = ast_calloc(1, sizeof(*ie_val))))
+		return -1;
+
+	ie_val->ie_type = ie_type;
+	ie_val->payload.uint = flags;
+	ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_BITFLAGS;
+
+	AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry);
+
+	return 0;
+}
+
 int ast_event_sub_append_ie_exists(struct ast_event_sub *sub,
 	enum ast_event_ie_type ie_type)
 {
 	struct ast_event_ie_val *ie_val;
 
-	if (ie_type < 0 || ie_type > AST_EVENT_IE_MAX)
-		return -1;
-
-	if (!(ie_val = ast_calloc(1, sizeof(*ie_val))))
-		return -1;
+	if (ie_type < 0 || ie_type > AST_EVENT_IE_MAX) {
+		return -1;
+	}
+
+	if (!(ie_val = ast_calloc(1, sizeof(*ie_val)))) {
+		return -1;
+	}
 
 	ie_val->ie_type = ie_type;
 	ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_EXISTS;
@@ -627,16 +718,18 @@
 	return 0;
 }
 
-int ast_event_sub_append_ie_str(struct ast_event_sub *sub, 	
+int ast_event_sub_append_ie_str(struct ast_event_sub *sub,
 	enum ast_event_ie_type ie_type, const char *str)
 {
 	struct ast_event_ie_val *ie_val;
 
-	if (ie_type < 0 || ie_type > AST_EVENT_IE_MAX)
-		return -1;
-
-	if (!(ie_val = ast_calloc(1, sizeof(*ie_val))))
-		return -1;
+	if (ie_type < 0 || ie_type > AST_EVENT_IE_MAX) {
+		return -1;
+	}
+
+	if (!(ie_val = ast_calloc(1, sizeof(*ie_val)))) {
+		return -1;
+	}
 
 	ie_val->ie_type = ie_type;
 	ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_STR;
@@ -653,16 +746,18 @@
 	return 0;
 }
 
-int ast_event_sub_append_ie_raw(struct ast_event_sub *sub, 	
+int ast_event_sub_append_ie_raw(struct ast_event_sub *sub,
 	enum ast_event_ie_type ie_type, void *data, size_t raw_datalen)
 {
 	struct ast_event_ie_val *ie_val;
 
-	if (ie_type < 0 || ie_type > AST_EVENT_IE_MAX)
-		return -1;
-
-	if (!(ie_val = ast_calloc(1, sizeof(*ie_val))))
-		return -1;
+	if (ie_type < 0 || ie_type > AST_EVENT_IE_MAX) {
+		return -1;
+	}
+
+	if (!(ie_val = ast_calloc(1, sizeof(*ie_val)))) {
+		return -1;
+	}
 
 	ie_val->ie_type = ie_type;
 	ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_RAW;
@@ -689,8 +784,9 @@
 
 		event = gen_sub_event(sub);
 
-		if (event)
+		if (event) {
 			ast_event_queue(event);
+		}
 	}
 
 	AST_RWDLLIST_WRLOCK(&ast_event_subs[sub->type]);
@@ -700,15 +796,16 @@
 	return 0;
 }
 
-struct ast_event_sub *ast_event_subscribe(enum ast_event_type type, ast_event_cb_t cb, 
+struct ast_event_sub *ast_event_subscribe(enum ast_event_type type, ast_event_cb_t cb,
 	char *description, void *userdata, ...)
 {
 	va_list ap;
 	enum ast_event_ie_type ie_type;
 	struct ast_event_sub *sub;
 
-	if (!(sub = ast_event_subscribe_new(type, cb, userdata)))
+	if (!(sub = ast_event_subscribe_new(type, cb, userdata))) {
 		return NULL;
+	}
 
 	ast_copy_string(sub->description, description, sizeof(sub->description));
 
@@ -730,6 +827,12 @@
 			ast_event_sub_append_ie_uint(sub, ie_type, unsigned_int);
 			break;
 		}
+		case AST_EVENT_IE_PLTYPE_BITFLAGS:
+		{
+			uint32_t unsigned_int = va_arg(ap, uint32_t);
+			ast_event_sub_append_ie_bitflags(sub, ie_type, unsigned_int);
+			break;
+		}
 		case AST_EVENT_IE_PLTYPE_STR:
 		{
 			const char *str = va_arg(ap, const char *);
@@ -759,8 +862,9 @@
 {
 	struct ast_event_ie_val *ie_val;
 
-	while ((ie_val = AST_LIST_REMOVE_HEAD(&sub->ie_vals, entry)))
+	while ((ie_val = AST_LIST_REMOVE_HEAD(&sub->ie_vals, entry))) {
 		ast_event_ie_val_destroy(ie_val);
+	}
 
 	ast_free(sub);
 }
@@ -803,14 +907,15 @@
 	if (ast_event_check_subscriber(AST_EVENT_UNSUB,
 		AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, sub->type,
 		AST_EVENT_IE_END) != AST_EVENT_SUB_NONE) {
-		
+
 		event = ast_event_new(AST_EVENT_UNSUB,
 			AST_EVENT_IE_UNIQUEID,  AST_EVENT_IE_PLTYPE_UINT, sub->uniqueid,
 			AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, sub->type,
 			AST_EVENT_IE_END);
 
-		if (event)
+		if (event) {
 			ast_event_queue(event);
+		}
 	}
 
 	ast_event_sub_destroy(sub);
@@ -823,7 +928,6 @@
 	iterator->event_len = ntohs(event->event_len);
 	iterator->event = event;
 	iterator->ie = (struct ast_event_ie *) ( ((char *) event) + sizeof(*event) );
-	return;
 }
 
 int ast_event_iterator_next(struct ast_event_iterator *iterator)
@@ -842,6 +946,11 @@
 	return ntohl(get_unaligned_uint32(iterator->ie->ie_payload));
 }
 
+uint32_t ast_event_iterator_get_ie_bitflags(struct ast_event_iterator *iterator)
+{
+	return ntohl(get_unaligned_uint32(iterator->ie->ie_payload));
+}
+
 const char *ast_event_iterator_get_ie_str(struct ast_event_iterator *iterator)
 {
 	const struct ast_event_ie_str_payload *str_payload;
@@ -862,6 +971,15 @@
 }
 
 uint32_t ast_event_get_ie_uint(const struct ast_event *event, enum ast_event_ie_type ie_type)
+{
+	const uint32_t *ie_val;
+
+	ie_val = ast_event_get_ie_raw(event, ie_type);
+
+	return ie_val ? ntohl(get_unaligned_uint32(ie_val)) : 0;
+}
+
+uint32_t ast_event_get_ie_bitflags(const struct ast_event *event, enum ast_event_ie_type ie_type)
 {
 	const uint32_t *ie_val;
 
@@ -894,8 +1012,9 @@
 	int res = 0;
 
 	for (ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
-		if (ast_event_iterator_get_ie_type(&iterator) == ie_type)
+		if (ast_event_iterator_get_ie_type(&iterator) == ie_type) {
 			return ast_event_iterator_get_ie_raw(&iterator);
+		}
 	}
 
 	return NULL;
@@ -921,6 +1040,13 @@
 {
 	data = htonl(data);
 	return ast_event_append_ie_raw(event, ie_type, &data, sizeof(data));
+}
+
+int ast_event_append_ie_bitflags(struct ast_event **event, enum ast_event_ie_type ie_type,
+	uint32_t flags)
+{
+	flags = htonl(flags);
+	return ast_event_append_ie_raw(event, ie_type, &flags, sizeof(flags));
 }
 
 int ast_event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type,
@@ -933,8 +1059,9 @@
 	event_len = ntohs((*event)->event_len);
 	extra_len = sizeof(*ie) + data_len;
 
-	if (!(*event = ast_realloc(*event, event_len + extra_len)))
-		return -1;
+	if (!(*event = ast_realloc(*event, event_len + extra_len))) {
+		return -1;
+	}
 
 	ie = (struct ast_event_ie *) ( ((char *) *event) + event_len );
 	ie->ie_type = htons(ie_type);
@@ -967,40 +1094,76 @@
 		ie_type = va_arg(ap, enum ast_event_type))
 	{
 		struct ast_event_ie_val *ie_value = alloca(sizeof(*ie_value));
+		int insert = 1;
 		memset(ie_value, 0, sizeof(*ie_value));
 		ie_value->ie_type = ie_type;
 		ie_value->ie_pltype = va_arg(ap, enum ast_event_ie_pltype);
-		if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_UINT)
+		switch (ie_value->ie_pltype) {
+		case AST_EVENT_IE_PLTYPE_UINT:
 			ie_value->payload.uint = va_arg(ap, uint32_t);
-		else if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_STR)
-			ie_value->payload.str = ast_strdupa(va_arg(ap, const char *));
-		else if (ie_value->ie_pltype == AST_EVENT_IE_PLTYPE_RAW) {
+			break;
+		case AST_EVENT_IE_PLTYPE_BITFLAGS:
+			ie_value->payload.uint = va_arg(ap, uint32_t);
+			break;
+		case AST_EVENT_IE_PLTYPE_STR:
+			ie_value->payload.str = va_arg(ap, const char *);
+			break;
+		case AST_EVENT_IE_PLTYPE_RAW:
+		{
 			void *data = va_arg(ap, void *);
 			size_t datalen = va_arg(ap, size_t);
 			ie_value->payload.raw = alloca(datalen);
 			memcpy(ie_value->payload.raw, data, datalen);
 			ie_value->raw_datalen = datalen;
-		}
-		AST_LIST_INSERT_TAIL(&ie_vals, ie_value, entry);
+			break;
+		}
+		case AST_EVENT_IE_PLTYPE_UNKNOWN:
+			insert = 0;
+			break;
+		case AST_EVENT_IE_PLTYPE_EXISTS:
+			break;
+		}
+
+		if (insert) {
+			AST_LIST_INSERT_TAIL(&ie_vals, ie_value, entry);
+		}
 	}
 	va_end(ap);
 
-	if (!(event = ast_calloc(1, sizeof(*event))))
+	if (!(event = ast_calloc(1, sizeof(*event)))) {
 		return NULL;
+	}
 
 	event->type = htons(type);
 	event->event_len = htons(sizeof(*event));
 
 	AST_LIST_TRAVERSE(&ie_vals, ie_val, entry) {
-		if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_STR)
+		switch (ie_val->ie_pltype) {
+		case AST_EVENT_IE_PLTYPE_STR:
 			ast_event_append_ie_str(&event, ie_val->ie_type, ie_val->payload.str);
-		else if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_UINT)
+			break;
+		case AST_EVENT_IE_PLTYPE_UINT:
 			ast_event_append_ie_uint(&event, ie_val->ie_type, ie_val->payload.uint);
-		else if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_RAW)
-			ast_event_append_ie_raw(&event, ie_val->ie_type, ie_val->payload.raw, ie_val->raw_datalen);
-
-		if (!event)
-			break;
+			break;
+		case AST_EVENT_IE_PLTYPE_BITFLAGS:
+			ast_event_append_ie_bitflags(&event, ie_val->ie_type, ie_val->payload.uint);
+			break;
+		case AST_EVENT_IE_PLTYPE_RAW:
+			ast_event_append_ie_raw(&event, ie_val->ie_type,
+					ie_val->payload.raw, ie_val->raw_datalen);
+			break;
+		case AST_EVENT_IE_PLTYPE_EXISTS:
+			ast_log(LOG_WARNING, "PLTYPE_EXISTS unsupported in event_new\n");
+			break;
+		case AST_EVENT_IE_PLTYPE_UNKNOWN:
+			ast_log(LOG_WARNING, "PLTYPE_UNKNOWN passed as an IE type "
+					"for a new event\n");
+			break;
+		}
+
+		if (!event) {
+			break;
+		}
 	}
 
 	if (!ast_event_get_ie_raw(event, AST_EVENT_IE_EID)) {
@@ -1079,6 +1242,9 @@
 		case AST_EVENT_IE_PLTYPE_UINT:
 			ast_event_append_ie_uint(&cache_arg_event, ie_type, va_arg(ap, uint32_t));
 			break;
+		case AST_EVENT_IE_PLTYPE_BITFLAGS:
+			ast_event_append_ie_bitflags(&cache_arg_event, ie_type, va_arg(ap, uint32_t));
+			break;
 		case AST_EVENT_IE_PLTYPE_STR:
 			ast_event_append_ie_str(&cache_arg_event, ie_type, va_arg(ap, const char *));
 			break;

Modified: team/group/newcdr/main/pbx.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/main/pbx.c?view=diff&rev=192211&r1=192210&r2=192211
==============================================================================
--- team/group/newcdr/main/pbx.c (original)
+++ team/group/newcdr/main/pbx.c Mon May  4 16:44:57 2009
@@ -3602,7 +3602,7 @@
 					cp4 = ast_func_read2(c, finalvars, &substr3, 0) ? NULL : ast_str_buffer(substr3);
 				} else {
 					struct varshead old;
-					struct ast_channel *bogus = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Bogus/%p", vars);
+					struct ast_channel *bogus = ast_channel_alloc(0, 0, "", "", "", "", "", NULL, 0, "Bogus/%p", vars);
 					if (bogus) {
 						memcpy(&old, &bogus->varshead, sizeof(old));
 						memcpy(&bogus->varshead, headp, sizeof(bogus->varshead));

Modified: team/group/newcdr/tests/test_sched.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/tests/test_sched.c?view=diff&rev=192211&r1=192210&r2=192211
==============================================================================
--- team/group/newcdr/tests/test_sched.c (original)
+++ team/group/newcdr/tests/test_sched.c Mon May  4 16:44:57 2009
@@ -168,7 +168,7 @@
 	case CLI_INIT:
 		e->command = "sched benchmark";
 		e->usage = ""
-			"Usage: sched test <num>\n"
+			"Usage: sched benchmark <num>\n"
 			"";
 		return NULL;
 	case CLI_GENERATE:

Modified: team/group/newcdr/tests/test_skel.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/tests/test_skel.c?view=diff&rev=192211&r1=192210&r2=192211
==============================================================================
--- team/group/newcdr/tests/test_skel.c (original)
+++ team/group/newcdr/tests/test_skel.c Mon May  4 16:44:57 2009
@@ -40,6 +40,7 @@
 #include "asterisk/module.h"
 #include "asterisk/lock.h"
 #include "asterisk/app.h"
+#include "asterisk/cli.h"
 
 static int unload_module(void)
 {

Modified: team/group/newcdr/tests/test_substitution.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/newcdr/tests/test_substitution.c?view=diff&rev=192211&r1=192210&r2=192211
==============================================================================
--- team/group/newcdr/tests/test_substitution.c (original)
+++ team/group/newcdr/tests/test_substitution.c Mon May  4 16:44:57 2009
@@ -165,7 +165,7 @@
 	}
 
 	ast_cli(a->fd, "Testing variable substitution ...\n");
-	c = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Test/substitution");
+	c = ast_channel_alloc(0, 0, "", "", "", "", "", NULL, 0, "Test/substitution");
 
 	test_chan_integer(a->fd, c, &c->cid.cid_pres, "${CALLINGPRES}");
 	test_chan_integer(a->fd, c, &c->cid.cid_ani2, "${CALLINGANI2}");




More information about the asterisk-commits mailing list