[asterisk-commits] kmoore: branch kmoore/cel_backend_refactor r395933 - in /team/kmoore/cel_back...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 31 22:32:54 CDT 2013


Author: kmoore
Date: Wed Jul 31 22:32:52 2013
New Revision: 395933

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395933
Log:
First stage cleanup

Modified:
    team/kmoore/cel_backend_refactor/include/asterisk/_private.h
    team/kmoore/cel_backend_refactor/include/asterisk/event.h
    team/kmoore/cel_backend_refactor/include/asterisk/event_defs.h
    team/kmoore/cel_backend_refactor/main/asterisk.c
    team/kmoore/cel_backend_refactor/main/event.c
    team/kmoore/cel_backend_refactor/tests/test_event.c

Modified: team/kmoore/cel_backend_refactor/include/asterisk/_private.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_backend_refactor/include/asterisk/_private.h?view=diff&rev=395933&r1=395932&r2=395933
==============================================================================
--- team/kmoore/cel_backend_refactor/include/asterisk/_private.h (original)
+++ team/kmoore/cel_backend_refactor/include/asterisk/_private.h Wed Jul 31 22:32:52 2013
@@ -29,7 +29,6 @@
 void dnsmgr_start_refresh(void);	/*!< Provided by dnsmgr.c */
 int dnsmgr_reload(void);		/*!< Provided by dnsmgr.c */
 void threadstorage_init(void);		/*!< Provided by threadstorage.c */
-int ast_event_init(void);		/*!< Provided by event.c */
 int ast_device_state_engine_init(void);	/*!< Provided by devicestate.c */
 int astobj2_init(void);			/*!< Provided by astobj2.c */
 int ast_file_init(void);		/*!< Provided by file.c */

Modified: team/kmoore/cel_backend_refactor/include/asterisk/event.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_backend_refactor/include/asterisk/event.h?view=diff&rev=395933&r1=395932&r2=395933
==============================================================================
--- team/kmoore/cel_backend_refactor/include/asterisk/event.h (original)
+++ team/kmoore/cel_backend_refactor/include/asterisk/event.h Wed Jul 31 22:32:52 2013
@@ -64,211 +64,6 @@
 #include "asterisk/event_defs.h"
 
 /*!
- * \brief Subscriber event callback type
- *
- * \param event the event being passed to the subscriber
- * \param userdata the data provider in the call to ast_event_subscribe()
- *
- * \return The event callbacks do not return anything.
- */
-typedef void (*ast_event_cb_t)(const struct ast_event *event, void *userdata);
-
-/*!
- * \brief Subscribe to events
- *
- * \param event_type The type of events to subscribe to
- * \param cb The function to be called with events
- * \param description Description of the subscription.
- * \param userdata data to be passed to the event callback
- *
- * The rest of the arguments to this function specify additional parameters for
- * the subscription to filter which events are passed to this subscriber.  The
- * arguments must be in sets of:
- * \code
- *    <enum ast_event_ie_type>, [enum ast_event_ie_pltype, [payload] ]
- * \endcode
- * and must end with AST_EVENT_IE_END.
- *
- * If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed
- * by a valid IE payload type.  A payload must also be specified.
- *
- * \return This returns a reference to the subscription for use with
- *         un-subscribing later.  If there is a failure in creating the
- *         subscription, NULL will be returned.
- *
- * Example usage:
- *
- * \code
- * peer->mwi_event_sub = ast_event_subscribe(AST_EVENT_MWI, mwi_event_cb, peer,
- *     AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, peer->mailbox,
- *     AST_EVENT_IE_END);
- * \endcode
- *
- * This creates a subscription to AST_EVENT_MWI events that contain an
- * information element, AST_EVENT_IE_MAILBOX, with the same string value
- * contained in peer->mailbox.  Also, the event callback will be passed a
- * pointer to the peer.
- *
- * \note A NULL description will cause this function to crash, so watch out!
- */
-struct ast_event_sub *ast_event_subscribe(enum ast_event_type event_type,
-       ast_event_cb_t cb, const char *description, void *userdata, ...);
-
-/*!
- * \brief Allocate a subscription, but do not activate it
- *
- * \param type the event type to subscribe to
- * \param cb the function to call when an event matches this subscription
- * \param userdata data to pass to the provided callback
- *
- * This function should be used when you want to dynamically build a
- * subscription.
- *
- * \return the allocated subscription, or NULL on failure
- * \since 1.6.1
- */
-struct ast_event_sub *ast_event_subscribe_new(enum ast_event_type type,
-	ast_event_cb_t cb, void *userdata);
-
-/*!
- * \brief Destroy an allocated subscription
- *
- * \param sub the subscription to destroy
- *
- * This function should be used when a subscription is allocated with
- * ast_event_subscribe_new(), but for some reason, you want to destroy it
- * instead of activating it.  This could be because of an error when
- * reading in the configuration for the dynamically built subscription.
- * \since 1.6.1
- */
-void ast_event_sub_destroy(struct ast_event_sub *sub);
-
-/*!
- * \brief Append a uint 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 uint the value that must be present in the event to match this subscription
- *
- * \retval 0 success
- * \retval non-zero failure
- * \since 1.6.1
- */
-int ast_event_sub_append_ie_uint(struct ast_event_sub *sub,
-	enum ast_event_ie_type ie_type, uint32_t uint);
-
-/*!
- * \brief Append a string 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 str the string that must be present in the event to match this subscription
- *
- * \retval 0 success
- * \retval non-zero failure
- * \since 1.6.1
- */
-int ast_event_sub_append_ie_str(struct ast_event_sub *sub,
-	enum ast_event_ie_type ie_type, const char *str);
-
-/*!
- * \brief Append a raw 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 data the data that must be present in the event to match this subscription
- * \param raw_datalen length of data
- *
- * \retval 0 success
- * \retval non-zero failure
- * \since 1.6.1
- */
-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);
-
-/*!
- * \brief Activate a dynamically built subscription
- *
- * \param sub the subscription to activate that was allocated using
- *      ast_event_subscribe_new()
- *
- * Once a dynamically built subscription has had all of the parameters added
- * to it, it should be activated using this function.
- *
- * \retval 0 success
- * \retval non-zero failure
- * \since 1.6.1
- */
-int ast_event_sub_activate(struct ast_event_sub *sub);
-
-/*!
- * \brief Un-subscribe from events
- *
- * \param event_sub This is the reference to the subscription returned by
- *        ast_event_subscribe.
- *
- * This function will remove a subscription and free the associated data
- * structures.
- *
- * \return NULL for convenience.
- * \version 1.6.1 return changed to NULL
- */
-struct ast_event_sub *ast_event_unsubscribe(struct ast_event_sub *event_sub);
-
-/*!
- * \brief Check if subscribers exist
- *
- * \param event_type This is the type of event that the caller would like to
- *        check for subscribers to.
- *
- * The rest of the arguments to this function specify additional parameters for
- * checking for subscriptions to subsets of an event type. The arguments must
- * in sets of:
- * \code
- *    <enum ast_event_ie_type>, [enum ast_event_ie_pltype, [payload] ]
- * \endcode
- * and must end with AST_EVENT_IE_END.
- *
- * If the ie_type specified is *not* AST_EVENT_IE_END, then it must be followed
- * by a valid IE payload type.  A payload must also be specified.
- *
- * \return This returns one of the values defined in the ast_event_subscriber_res
- *         enum which will indicate if subscribers exist that match the given
- *         criteria.
- *
- * Example usage:
- *
- * \code
- * if (ast_event_check_subscriber(AST_EVENT_MWI,
- *     AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
- *     AST_EVENT_IE_END) == AST_EVENT_SUB_NONE) {
- *       return;
- * }
- * \endcode
- *
- * This example will check if there are any subscribers to MWI events for the
- * mailbox defined in the "mailbox" variable.
- */
-enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type event_type, ...);
-
-/*!
- * \brief Report current subscriptions to a subscription subscriber
- *
- * \arg sub the subscription subscriber
- *
- * \return nothing
- *
- * This reports all of the current subscribers to a subscriber of
- * subscribers to a specific event type.  (Try saying that a few times fast).
- *
- * The idea here is that it is sometimes very useful for a module to know when
- * someone subscribes to events.  However, when they first subscribe, this
- * provides that module the ability to request the event core report to them
- * all of the subscriptions to that event type that already exist.
- */
-void ast_event_report_subs(const struct ast_event_sub *sub);
-
-/*!
  * \brief Create a new event
  *
  * \param event_type The type of event to create
@@ -321,22 +116,6 @@
 void ast_event_destroy(struct ast_event *event);
 
 /*!
- * \brief Queue an event
- *
- * \param event the event to be queued
- *
- * \retval zero success
- * \retval non-zero failure.  Note that the caller of this function is
- *         responsible for destroying the event in the case of a failure.
- *
- * This function queues an event to be dispatched to all of the appropriate
- * subscribers.  This function will not block while the event is being
- * dispatched because the event is queued up for a dispatching thread 
- * to handle.
- */
-int ast_event_queue(struct ast_event *event);
-
-/*!
  * \brief Append an information element that has a string payload
  *
  * \param event the event that the IE will be appended to

Modified: team/kmoore/cel_backend_refactor/include/asterisk/event_defs.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_backend_refactor/include/asterisk/event_defs.h?view=diff&rev=395933&r1=395932&r2=395933
==============================================================================
--- team/kmoore/cel_backend_refactor/include/asterisk/event_defs.h (original)
+++ team/kmoore/cel_backend_refactor/include/asterisk/event_defs.h Wed Jul 31 22:32:52 2013
@@ -271,7 +271,6 @@
 
 struct ast_event;
 struct ast_event_ie;
-struct ast_event_sub;
 struct ast_event_iterator;
 
 /*!

Modified: team/kmoore/cel_backend_refactor/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_backend_refactor/main/asterisk.c?view=diff&rev=395933&r1=395932&r2=395933
==============================================================================
--- team/kmoore/cel_backend_refactor/main/asterisk.c (original)
+++ team/kmoore/cel_backend_refactor/main/asterisk.c Wed Jul 31 22:32:52 2013
@@ -4143,11 +4143,6 @@
 		exit(1);
 	}
 
-	if (ast_event_init()) {
-		printf("%s", term_quit());
-		exit(1);
-	}
-
 #ifdef TEST_FRAMEWORK
 	if (ast_test_init()) {
 		printf("%s", term_quit());

Modified: team/kmoore/cel_backend_refactor/main/event.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_backend_refactor/main/event.c?view=diff&rev=395933&r1=395932&r2=395933
==============================================================================
--- team/kmoore/cel_backend_refactor/main/event.c (original)
+++ team/kmoore/cel_backend_refactor/main/event.c Wed Jul 31 22:32:52 2013
@@ -44,12 +44,9 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/cli.h"
 
-static struct ast_taskprocessor *event_dispatcher;
 static int event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type,
 	const void *data, size_t data_len);
 static const void *event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type);
-static uint16_t event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type);
-static uint32_t event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type);
 
 /*!
  * \brief An event information element
@@ -111,23 +108,6 @@
 	} payload;
 	size_t raw_datalen;
 };
-
-/*! \brief Event subscription */
-struct ast_event_sub {
-	enum ast_event_type type;
-	ast_event_cb_t cb;
-	char description[64];
-	void *userdata;
-	uint32_t uniqueid;
-	AST_LIST_HEAD_NOLOCK(, ast_event_ie_val) ie_vals;
-	AST_RWDLLIST_ENTRY(ast_event_sub) entry;
-};
-
-static uint32_t sub_uniqueid;
-
-/*! \brief Event subscriptions
- * The event subscribers are indexed by which event they are subscribed to */
-static AST_RWDLLIST_HEAD(ast_event_sub_list, ast_event_sub) ast_event_subs[AST_EVENT_TOTAL];
 
 struct ie_map {
 	enum ast_event_ie_pltype ie_pltype;
@@ -217,512 +197,10 @@
 	return res;
 }
 
-static void ast_event_ie_val_destroy(struct ast_event_ie_val *ie_val)
-{
-	switch (ie_val->ie_pltype) {
-	case AST_EVENT_IE_PLTYPE_STR:
-		ast_free((char *) ie_val->payload.str);
-		break;
-	case AST_EVENT_IE_PLTYPE_RAW:
-		ast_free(ie_val->payload.raw);
-		break;
-	case AST_EVENT_IE_PLTYPE_UINT:
-	case AST_EVENT_IE_PLTYPE_UNKNOWN:
-		break;
-	}
-
-	ast_free(ie_val);
-}
-
 /*! \brief Subscription event check list. */
 struct ast_ev_check_list {
 	AST_LIST_HEAD_NOLOCK(, ast_event_ie_val) ie_vals;
 };
-
-/*!
- * \internal
- * \brief Check if a subscription ie_val matches an event.
- *
- * \param sub_ie_val Subscripton IE value to check
- * \param check_ie_vals event list to check against
- *
- * \retval 0 not matched
- * \retval non-zero matched
- */
-static int match_sub_ie_val_to_event(const struct ast_event_ie_val *sub_ie_val, const struct ast_ev_check_list *check_ie_vals)
-{
-	const struct ast_event_ie_val *event_ie_val;
-	int res = 0;
-
-	AST_LIST_TRAVERSE(&check_ie_vals->ie_vals, event_ie_val, entry) {
-		if (sub_ie_val->ie_type == event_ie_val->ie_type) {
-			break;
-		}
-	}
-	if (!event_ie_val) {
-		/* We did not find the event ie the subscriber cares about. */
-		return 0;
-	}
-
-	if (sub_ie_val->ie_pltype != event_ie_val->ie_pltype) {
-		/* Payload types do not match. */
-		return 0;
-	}
-
-	switch (sub_ie_val->ie_pltype) {
-	case AST_EVENT_IE_PLTYPE_UINT:
-		res = (sub_ie_val->payload.uint == event_ie_val->payload.uint);
-		break;
-	case AST_EVENT_IE_PLTYPE_STR:
-	{
-		const char *substr = sub_ie_val->payload.str;
-		const char *estr = event_ie_val->payload.str;
-		res = !strcmp(substr, estr);
-		break;
-	}
-	case AST_EVENT_IE_PLTYPE_RAW:
-		res = (sub_ie_val->raw_datalen == event_ie_val->raw_datalen
-			&& !memcmp(sub_ie_val->payload.raw, event_ie_val->payload.raw,
-				sub_ie_val->raw_datalen));
-		break;
-	case AST_EVENT_IE_PLTYPE_UNKNOWN:
-		/*
-		 * Should never be in a subscription event ie val list and
-		 * check_ie_vals cannot have this type either.
-		 */
-		break;
-	}
-
-	return res;
-}
-
-enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type type, ...)
-{
-	va_list ap;
-	enum ast_event_ie_type ie_type;
-	enum ast_event_subscriber_res res = AST_EVENT_SUB_NONE;
-	struct ast_event_ie_val *ie_val;
-	struct ast_event_sub *sub;
-	struct ast_ev_check_list check_ie_vals = {
-		.ie_vals = AST_LIST_HEAD_NOLOCK_INIT_VALUE
-	};
-	const enum ast_event_type event_types[] = { type, AST_EVENT_ALL };
-	int i;
-	int want_specific_event;/* TRUE if looking for subscribers wanting specific parameters. */
-
-	if (type >= AST_EVENT_TOTAL) {
-		ast_log(LOG_ERROR, "%u is an invalid type!\n", type);
-		return res;
-	}
-
-	want_specific_event = 0;
-	va_start(ap, type);
-	for (ie_type = va_arg(ap, enum ast_event_ie_type);
-		ie_type != AST_EVENT_IE_END;
-		ie_type = va_arg(ap, enum ast_event_ie_type))
-	{
-		struct ast_event_ie_val *ie_value = ast_alloca(sizeof(*ie_value));
-		int insert = 0;
-
-		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);
-		switch (ie_value->ie_pltype) {
-		case AST_EVENT_IE_PLTYPE_UINT:
-			ie_value->payload.uint = va_arg(ap, uint32_t);
-			insert = 1;
-			break;
-		case AST_EVENT_IE_PLTYPE_STR:
-			ie_value->payload.str = va_arg(ap, const char *);
-			insert = 1;
-			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 = ast_alloca(datalen);
-			memcpy(ie_value->payload.raw, data, datalen);
-			ie_value->raw_datalen = datalen;
-			insert = 1;
-			break;
-		}
-		case AST_EVENT_IE_PLTYPE_UNKNOWN:
-			/* Unsupported payload type. */
-			break;
-		}
-
-		if (insert) {
-			want_specific_event = 1;
-			AST_LIST_INSERT_TAIL(&check_ie_vals.ie_vals, ie_value, entry);
-		} else {
-			ast_log(LOG_WARNING, "Unsupported PLTYPE(%d)\n", ie_value->ie_pltype);
-		}
-	}
-	va_end(ap);
-
-	for (i = 0; i < ARRAY_LEN(event_types); i++) {
-		AST_RWDLLIST_RDLOCK(&ast_event_subs[event_types[i]]);
-		if (want_specific_event) {
-			AST_RWDLLIST_TRAVERSE(&ast_event_subs[event_types[i]], sub, entry) {
-				AST_LIST_TRAVERSE(&sub->ie_vals, ie_val, entry) {
-					if (!match_sub_ie_val_to_event(ie_val, &check_ie_vals)) {
-						/* The current subscription ie did not match an event ie. */
-						break;
-					}
-				}
-				if (!ie_val) {
-					/* Everything matched.  A subscriber is looking for this event. */
-					break;
-				}
-			}
-		} else {
-			/* Just looking to see if there are ANY subscribers to the event type. */
-			sub = AST_RWLIST_FIRST(&ast_event_subs[event_types[i]]);
-		}
-		AST_RWDLLIST_UNLOCK(&ast_event_subs[event_types[i]]);
-		if (sub) {
-			break;
-		}
-	}
-
-	return sub ? AST_EVENT_SUB_EXISTS : AST_EVENT_SUB_NONE;
-}
-
-/*!
- * \internal
- * \brief Check if an ie_val matches an event
- *
- * \param event event to check against
- * \param ie_val IE value to check
- * \param event2 optional event, if specified, the value to compare against will be pulled
- *        from this event instead of from the ie_val structure.  In this case, only the IE
- *        type and payload type will be pulled from ie_val.
- *
- * \retval 0 not matched
- * \retval non-zero matched
- */
-static int match_ie_val(const struct ast_event *event,
-		const struct ast_event_ie_val *ie_val, const struct ast_event *event2)
-{
-	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;
-
-		return (val == ast_event_get_ie_uint(event, ie_val->ie_type)) ? 1 : 0;
-	}
-
-	case AST_EVENT_IE_PLTYPE_STR:
-	{
-		const char *str;
-		uint32_t hash;
-
-		hash = event2 ? event_get_ie_str_hash(event2, ie_val->ie_type) : ie_val->payload.hash;
-		if (hash != event_get_ie_str_hash(event, ie_val->ie_type)) {
-			return 0;
-		}
-
-		str = event2 ? ast_event_get_ie_str(event2, ie_val->ie_type) : ie_val->payload.str;
-		if (str) {
-			const char *e1str, *e2str;
-			e1str = ast_event_get_ie_str(event, ie_val->ie_type);
-			e2str = str;
-
-			if (!strcmp(e1str, e2str)) {
-				return 1;
-			}
-		}
-
-		return 0;
-	}
-
-	case AST_EVENT_IE_PLTYPE_RAW:
-	{
-		const void *buf = event2 ? event_get_ie_raw(event2, ie_val->ie_type) : ie_val->payload.raw;
-		uint16_t ie_payload_len = event2 ? event_get_ie_raw_payload_len(event2, ie_val->ie_type) : ie_val->raw_datalen;
-
-		return (buf
-			&& ie_payload_len == event_get_ie_raw_payload_len(event, ie_val->ie_type)
-			&& !memcmp(buf, event_get_ie_raw(event, ie_val->ie_type), ie_payload_len)) ? 1 : 0;
-	}
-
-	case AST_EVENT_IE_PLTYPE_UNKNOWN:
-		return 0;
-	}
-
-	return 0;
-}
-
-static struct ast_event *gen_sub_event(struct ast_event_sub *sub)
-{
-	struct ast_event_ie_val *ie_val;
-	struct ast_event *event;
-
-	event = ast_event_new(AST_EVENT_SUB,
-		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_DESCRIPTION, AST_EVENT_IE_PLTYPE_STR, sub->description,
-		AST_EVENT_IE_END);
-	if (!event)
-		return NULL;
-
-	AST_LIST_TRAVERSE(&sub->ie_vals, ie_val, entry) {
-		switch (ie_val->ie_pltype) {
-		case AST_EVENT_IE_PLTYPE_UNKNOWN:
-			break;
-		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_STR:
-			ast_event_append_ie_str(&event, ie_val->ie_type, ie_val->payload.str);
-			break;
-		case AST_EVENT_IE_PLTYPE_RAW:
-			event_append_ie_raw(&event, ie_val->ie_type, ie_val->payload.raw, ie_val->raw_datalen);
-			break;
-		}
-		if (!event)
-			break;
-	}
-
-	return event;
-}
-
-/*! \brief Send AST_EVENT_SUB events to this subscriber of ... subscriber events */
-void ast_event_report_subs(const struct ast_event_sub *event_sub)
-{
-	struct ast_event *event;
-	struct ast_event_sub *sub;
-	enum ast_event_type event_type = -1;
-	struct ast_event_ie_val *ie_val;
-
-	if (event_sub->type != AST_EVENT_SUB)
-		return;
-
-	AST_LIST_TRAVERSE(&event_sub->ie_vals, ie_val, entry) {
-		if (ie_val->ie_type == AST_EVENT_IE_EVENTTYPE) {
-			event_type = ie_val->payload.uint;
-			break;
-		}
-	}
-
-	if (event_type == -1)
-		return;
-
-	AST_RWDLLIST_RDLOCK(&ast_event_subs[event_type]);
-	AST_RWDLLIST_TRAVERSE(&ast_event_subs[event_type], sub, entry) {
-		if (event_sub == sub) {
-			continue;
-		}
-
-		event = gen_sub_event(sub);
-		if (!event) {
-			continue;
-		}
-
-		event_sub->cb(event, event_sub->userdata);
-
-		ast_event_destroy(event);
-	}
-	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 *sub;
-
-	if (type < 0 || type >= AST_EVENT_TOTAL) {
-		ast_log(LOG_ERROR, "%u is an invalid type!\n", type);
-		return NULL;
-	}
-
-	if (!(sub = ast_calloc(1, sizeof(*sub)))) {
-		return NULL;
-	}
-
-	sub->type = type;
-	sub->cb = cb;
-	sub->userdata = userdata;
-	sub->uniqueid = ast_atomic_fetchadd_int((int *) &sub_uniqueid, 1);
-
-	return sub;
-}
-
-int ast_event_sub_append_ie_uint(struct ast_event_sub *sub,
-	enum ast_event_ie_type ie_type, uint32_t unsigned_int)
-{
-	struct ast_event_ie_val *ie_val;
-
-	if (ie_type <= 0 || ie_type >= AST_EVENT_IE_TOTAL) {
-		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;
-	ie_val->ie_pltype = AST_EVENT_IE_PLTYPE_UINT;
-
-	AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry);
-
-	return 0;
-}
-
-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_TOTAL) {
-		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;
-
-	if (!(ie_val->payload.str = ast_strdup(str))) {
-		ast_free(ie_val);
-		return -1;
-	}
-
-	ie_val->payload.hash = ast_str_hash(str);
-
-	AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry);
-
-	return 0;
-}
-
-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_TOTAL) {
-		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;
-	ie_val->raw_datalen = raw_datalen;
-
-	if (!(ie_val->payload.raw = ast_malloc(raw_datalen))) {
-		ast_free(ie_val);
-		return -1;
-	}
-
-	memcpy(ie_val->payload.raw, data, raw_datalen);
-
-	AST_LIST_INSERT_TAIL(&sub->ie_vals, ie_val, entry);
-
-	return 0;
-}
-
-int ast_event_sub_activate(struct ast_event_sub *sub)
-{
-	if (ast_event_check_subscriber(AST_EVENT_SUB,
-		AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, sub->type,
-		AST_EVENT_IE_END) != AST_EVENT_SUB_NONE) {
-		struct ast_event *event;
-
-		event = gen_sub_event(sub);
-		if (event && ast_event_queue(event)) {
-			ast_event_destroy(event);
-		}
-	}
-
-	AST_RWDLLIST_WRLOCK(&ast_event_subs[sub->type]);
-	AST_RWDLLIST_INSERT_TAIL(&ast_event_subs[sub->type], sub, entry);
-	AST_RWDLLIST_UNLOCK(&ast_event_subs[sub->type]);
-
-	return 0;
-}
-
-struct ast_event_sub *ast_event_subscribe(enum ast_event_type type, ast_event_cb_t cb,
-	const 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))) {
-		return NULL;
-	}
-
-	ast_copy_string(sub->description, description, sizeof(sub->description));
-
-	va_start(ap, userdata);
-	for (ie_type = va_arg(ap, enum ast_event_ie_type);
-		ie_type != AST_EVENT_IE_END;
-		ie_type = va_arg(ap, enum ast_event_ie_type))
-	{
-		enum ast_event_ie_pltype ie_pltype;
-
-		ie_pltype = va_arg(ap, enum ast_event_ie_pltype);
-
-		switch (ie_pltype) {
-		case AST_EVENT_IE_PLTYPE_UNKNOWN:
-			break;
-		case AST_EVENT_IE_PLTYPE_UINT:
-		{
-			uint32_t unsigned_int = va_arg(ap, uint32_t);
-			ast_event_sub_append_ie_uint(sub, ie_type, unsigned_int);
-			break;
-		}
-		case AST_EVENT_IE_PLTYPE_STR:
-		{
-			const char *str = va_arg(ap, const char *);
-			ast_event_sub_append_ie_str(sub, ie_type, str);
-			break;
-		}
-		case AST_EVENT_IE_PLTYPE_RAW:
-		{
-			void *data = va_arg(ap, void *);
-			size_t data_len = va_arg(ap, size_t);
-			ast_event_sub_append_ie_raw(sub, ie_type, data, data_len);
-			break;
-		}
-		}
-	}
-	va_end(ap);
-
-	ast_event_sub_activate(sub);
-
-	return sub;
-}
-
-void ast_event_sub_destroy(struct ast_event_sub *sub)
-{
-	struct ast_event_ie_val *ie_val;
-
-	while ((ie_val = AST_LIST_REMOVE_HEAD(&sub->ie_vals, entry))) {
-		ast_event_ie_val_destroy(ie_val);
-	}
-
-	ast_free(sub);
-}
-
-struct ast_event_sub *ast_event_unsubscribe(struct ast_event_sub *sub)
-{
-
-	AST_RWDLLIST_WRLOCK(&ast_event_subs[sub->type]);
-	AST_DLLIST_REMOVE(&ast_event_subs[sub->type], sub, entry);
-	AST_RWDLLIST_UNLOCK(&ast_event_subs[sub->type]);
-
-	ast_event_sub_destroy(sub);
-
-	return NULL;
-}
 
 int ast_event_iterator_init(struct ast_event_iterator *iterator, const struct ast_event *event)
 {
@@ -770,11 +248,6 @@
 	return iterator->ie->ie_payload;
 }
 
-static uint16_t event_iterator_get_ie_raw_payload_len(struct ast_event_iterator *iterator)
-{
-	return ntohs(iterator->ie->ie_payload_len);
-}
-
 enum ast_event_type ast_event_get_type(const struct ast_event *event)
 {
 	return ntohs(event->type);
@@ -787,15 +260,6 @@
 	ie_val = event_get_ie_raw(event, ie_type);
 
 	return ie_val ? ntohl(get_unaligned_uint32(ie_val)) : 0;
-}
-
-static uint32_t event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type)
-{
-	const struct ast_event_ie_str_payload *str_payload;
-
-	str_payload = event_get_ie_raw(event, ie_type);
-
-	return str_payload ? str_payload->hash : 0;
 }
 
 const char *ast_event_get_ie_str(const struct ast_event *event, enum ast_event_ie_type ie_type)
@@ -819,20 +283,6 @@
 	}
 
 	return NULL;
-}
-
-static uint16_t event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type)
-{
-	struct ast_event_iterator iterator;
-	int res;
-
-	for (res = ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
-		if (ast_event_iterator_get_ie_type(&iterator) == ie_type) {
-			return event_iterator_get_ie_raw_payload_len(&iterator);
-		}
-	}
-
-	return 0;
 }
 
 int ast_event_append_ie_str(struct ast_event **event, enum ast_event_ie_type ie_type,
@@ -974,111 +424,3 @@
 {
 	ast_free(event);
 }
-
-static int handle_event(void *data)
-{
-	struct ast_event *event = data;
-	struct ast_event_sub *sub;
-	const enum ast_event_type event_types[] = {
-		ntohs(event->type),
-		AST_EVENT_ALL
-	};
-	int i;
-
-	for (i = 0; i < ARRAY_LEN(event_types); i++) {
-		AST_RWDLLIST_RDLOCK(&ast_event_subs[event_types[i]]);
-		AST_RWDLLIST_TRAVERSE(&ast_event_subs[event_types[i]], sub, entry) {
-			struct ast_event_ie_val *ie_val;
-
-			AST_LIST_TRAVERSE(&sub->ie_vals, ie_val, entry) {
-				if (!match_ie_val(event, ie_val, NULL)) {
-					/* The current subscription ie did not match an event ie. */
-					break;
-				}
-			}
-			if (ie_val) {
-				/* The event did not match this subscription. */
-				continue;
-			}
-			sub->cb(event, sub->userdata);
-		}
-		AST_RWDLLIST_UNLOCK(&ast_event_subs[event_types[i]]);
-	}
-
-	ast_event_destroy(event);
-
-	return 0;
-}
-
-int ast_event_queue(struct ast_event *event)
-{
-	uint16_t host_event_type;
-	int res;
-
-	host_event_type = ntohs(event->type);
-
-	/* Invalid type */
-	if (host_event_type >= AST_EVENT_TOTAL) {
-		ast_log(LOG_WARNING, "Someone tried to queue an event of invalid "
-			"type '%d'!\n", host_event_type);
-		return -1;
-	}
-
-	/* If nobody has subscribed to this event type, throw it away now */
-	if (ast_event_check_subscriber(host_event_type, AST_EVENT_IE_END)
-			== AST_EVENT_SUB_NONE) {
-		ast_event_destroy(event);
-		return 0;
-	}
-
-	res = ast_taskprocessor_push(event_dispatcher, handle_event, event);
-	if (res) {
-		ast_event_destroy(event);
-	}
-	return res;
-}
-
-/*! \internal \brief Clean up resources on Asterisk shutdown */
-static void event_shutdown(void)
-{
-	struct ast_event_sub *sub;
-	int i;
-
-	if (event_dispatcher) {
-		event_dispatcher = ast_taskprocessor_unreference(event_dispatcher);
-	}
-
-	/* Remove any remaining subscriptions.  Note that we can't just call
-	 * unsubscribe, as it will attempt to lock the subscription list
-	 * as well */
-	for (i = 0; i < AST_EVENT_TOTAL; i++) {
-		AST_RWDLLIST_WRLOCK(&ast_event_subs[i]);
-		while ((sub = AST_RWDLLIST_REMOVE_HEAD(&ast_event_subs[i], entry))) {
-			ast_event_sub_destroy(sub);
-		}
-		AST_RWDLLIST_UNLOCK(&ast_event_subs[i]);
-		AST_RWDLLIST_HEAD_DESTROY(&ast_event_subs[i]);
-	}
-}
-
-int ast_event_init(void)
-{
-	int i;
-
-	for (i = 0; i < AST_EVENT_TOTAL; i++) {
-		AST_RWDLLIST_HEAD_INIT(&ast_event_subs[i]);
-	}
-
-	if (!(event_dispatcher = ast_taskprocessor_get("core_event_dispatcher", 0))) {
-		goto event_init_cleanup;
-	}
-
-	ast_register_atexit(event_shutdown);
-
-	return 0;
-
-event_init_cleanup:
-	event_shutdown();
-	return -1;
-}
-

Modified: team/kmoore/cel_backend_refactor/tests/test_event.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/cel_backend_refactor/tests/test_event.c?view=diff&rev=395933&r1=395932&r2=395933
==============================================================================
--- team/kmoore/cel_backend_refactor/tests/test_event.c (original)
+++ team/kmoore/cel_backend_refactor/tests/test_event.c Wed Jul 31 22:32:52 2013
@@ -25,7 +25,6 @@
  * \ingroup tests
  *
  * \todo API Calls not yet touched by a test: XXX TODO
- *   - ast_event_report_subs()
  *   - ast_event_get_ie_type_name()
  *   - ast_event_get_ie_pltype()
  *   - ast_event_iterator_init()
@@ -194,555 +193,9 @@
 	unsigned int count;
 };
 
-static void event_sub_cb(const struct ast_event *event, void *d)
-{
-	struct event_sub_data *data = d;
-
-	data->count++;
-}
-
-enum test_subs_class_type {
-	TEST_SUBS_ALL_STR,
-	TEST_SUBS_CUSTOM_STR,
-	TEST_SUBS_CUSTOM_RAW,
-	TEST_SUBS_CUSTOM_UINT,
-	TEST_SUBS_CUSTOM_EXISTS,
-	TEST_SUBS_CUSTOM_DYNAMIC,
-	TEST_SUBS_CUSTOM_ANY,
-
-	/* Must be last. */
-	TEST_SUBS_TOTAL,
-};
-
-/*!
- * \internal
- * \brief Convert enum test_subs_class_type to string.
- *
- * \param val Enum value to convert to string.
- *
- * \return String equivalent of enum value.
- */
-static const char *test_subs_class_type_str(enum test_subs_class_type val)
-{
-	switch (val) {
-	case TEST_SUBS_ALL_STR:
-		return "TEST_SUBS_ALL_STR";
-	case TEST_SUBS_CUSTOM_STR:
-		return "TEST_SUBS_CUSTOM_STR";
-	case TEST_SUBS_CUSTOM_RAW:
-		return "TEST_SUBS_CUSTOM_RAW";
-	case TEST_SUBS_CUSTOM_UINT:
-		return "TEST_SUBS_CUSTOM_UINT";
-	case TEST_SUBS_CUSTOM_EXISTS:
-		return "TEST_SUBS_CUSTOM_EXISTS";
-	case TEST_SUBS_CUSTOM_DYNAMIC:
-		return "TEST_SUBS_CUSTOM_DYNAMIC";
-	case TEST_SUBS_CUSTOM_ANY:
-		return "TEST_SUBS_CUSTOM_ANY";
-	case TEST_SUBS_TOTAL:
-		break;
-	}
-	return "Unknown";
-}
-
-/*!
- * \internal
- * \brief Test event subscriptions
- *
- * - Query for existing Subscriptions:
- *   - ast_event_check_subscriber()
- */
-AST_TEST_DEFINE(event_sub_test)
-{
-	enum ast_test_result_state res = AST_TEST_PASS;
-	struct ast_event *event;
-	int i;
-	enum ast_event_subscriber_res sub_res;
-	struct {
-		struct ast_event_sub *sub;
-		struct event_sub_data data;
-		const unsigned int expected_count;
-	} test_subs[TEST_SUBS_TOTAL] = {
-		[TEST_SUBS_ALL_STR] = {
-			.expected_count = 2,
-		},
-		[TEST_SUBS_CUSTOM_STR] = {
-			.expected_count = 2,
-		},
-		[TEST_SUBS_CUSTOM_RAW] = {
-			.expected_count = 2,
-		},
-		[TEST_SUBS_CUSTOM_UINT] = {
-			.expected_count = 1,
-		},
-		[TEST_SUBS_CUSTOM_EXISTS] = {
-			.expected_count = 2,
-		},
-		[TEST_SUBS_CUSTOM_DYNAMIC] = {
-			.expected_count = 1,
-		},
-		[TEST_SUBS_CUSTOM_ANY] = {
-			.expected_count = 5,
-		},
-	};
-
-	switch (cmd) {
-	case TEST_INIT:
-		info->name = "ast_event_subscribe_test";
-		info->category = "/main/event/";
-		info->summary = "Test event subscriptions";
-		info->description =
-			"This test exercises the API calls that allow subscriptions "
-			"to events.";
-		return AST_TEST_NOT_RUN;
-	case TEST_EXECUTE:
-		break;
-	}
-
-	ast_test_status_update(test, "Check that NO CUSTOM subscribers exist\n");
-	sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM,
-		AST_EVENT_IE_END);
-	if (sub_res != AST_EVENT_SUB_NONE) {
-		ast_test_status_update(test, "CUSTOM subscriptions should not exist! (%d)\n",
-			sub_res);
-		res = AST_TEST_FAIL;
-	}
-
-	/*
-	 * Subscription TEST_SUBS_CUSTOM_STR:
-	 *  - allocate normally
-	 *  - subscribe to CUSTOM events with a CEL_CIDNAME STR IE check
-	 */
-	ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_STR subscription\n");
-	test_subs[TEST_SUBS_CUSTOM_STR].sub = ast_event_subscribe(AST_EVENT_CUSTOM, event_sub_cb,
-		test_subs_class_type_str(TEST_SUBS_CUSTOM_STR), &test_subs[TEST_SUBS_CUSTOM_STR].data,
-		AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, "FOO/bar",
-		AST_EVENT_IE_END);
-	if (!test_subs[TEST_SUBS_CUSTOM_STR].sub) {
-		ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_STR subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-
-	ast_test_status_update(test, "Check that a CUSTOM subscriber exists\n");
-	sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM,
-		AST_EVENT_IE_END);
-	if (sub_res != AST_EVENT_SUB_EXISTS) {
-		ast_test_status_update(test, "A CUSTOM subscription should exist! (%d)\n",
-			sub_res);
-		res = AST_TEST_FAIL;
-	}
-
-	/*
-	 * Subscription TEST_SUBS_ALL_STR:
-	 *  - allocate normally
-	 *  - subscribe to ALL events with a CEL_CIDNAME STR IE check
-	 */
-	ast_test_status_update(test, "Adding TEST_SUBS_ALL_STR subscription\n");
-	test_subs[TEST_SUBS_ALL_STR].sub = ast_event_subscribe(AST_EVENT_ALL, event_sub_cb,
-		test_subs_class_type_str(TEST_SUBS_ALL_STR), &test_subs[TEST_SUBS_ALL_STR].data,
-		AST_EVENT_IE_CEL_CIDNAME, AST_EVENT_IE_PLTYPE_STR, "FOO/bar",
-		AST_EVENT_IE_END);
-	if (!test_subs[TEST_SUBS_ALL_STR].sub) {
-		ast_test_status_update(test, "Failed to create TEST_SUBS_ALL_STR subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-
-	/*
-	 * Subscription TEST_SUBS_CUSTOM_RAW:
-	 *  - allocate normally
-	 *  - subscribe to CUSTOM events with a CEL_USEREVENT_NAME RAW IE check
-	 */
-	ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_RAW subscription\n");
-	test_subs[TEST_SUBS_CUSTOM_RAW].sub = ast_event_subscribe(AST_EVENT_CUSTOM, event_sub_cb,
-		test_subs_class_type_str(TEST_SUBS_CUSTOM_RAW), &test_subs[TEST_SUBS_CUSTOM_RAW].data,
-		AST_EVENT_IE_CEL_USEREVENT_NAME, AST_EVENT_IE_PLTYPE_RAW, "FOO/bar", sizeof("FOO/bar"),
-		AST_EVENT_IE_END);
-	if (!test_subs[TEST_SUBS_CUSTOM_RAW].sub) {
-		ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_RAW subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-
-	/*
-	 * Subscription TEST_SUBS_CUSTOM_UINT:
-	 *  - allocate normally
-	 *  - subscribe to CUSTOM events with a CEL_AMAFLAGS UINT IE check
-	 */
-	ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_UINT subscription\n");
-	test_subs[TEST_SUBS_CUSTOM_UINT].sub = ast_event_subscribe(AST_EVENT_CUSTOM, event_sub_cb,
-		test_subs_class_type_str(TEST_SUBS_CUSTOM_UINT), &test_subs[TEST_SUBS_CUSTOM_UINT].data,
-		AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, 5,
-		AST_EVENT_IE_END);
-	if (!test_subs[TEST_SUBS_CUSTOM_UINT].sub) {
-		ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_UINT subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-
-	/*
-	 * Subscription TEST_SUBS_CUSTOM_EXISTS:
-	 *  - allocate normally
-	 *  - subscribe to CUSTOM events with a CEL_AMAFLAGS UINT and UNIQUEID EXISTS IE check
-	 */
-	ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_EXISTS subscription\n");
-	test_subs[TEST_SUBS_CUSTOM_EXISTS].sub = ast_event_subscribe(AST_EVENT_CUSTOM, event_sub_cb,
-		test_subs_class_type_str(TEST_SUBS_CUSTOM_EXISTS), &test_subs[TEST_SUBS_CUSTOM_EXISTS].data,
-		AST_EVENT_IE_CEL_AMAFLAGS, AST_EVENT_IE_PLTYPE_UINT, 4,
-		AST_EVENT_IE_END);
-	if (!test_subs[TEST_SUBS_CUSTOM_EXISTS].sub) {
-		ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_EXISTS subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-
-	/* For the sake of exercising destruction before activation */
-	test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = ast_event_subscribe_new(AST_EVENT_CUSTOM,
-		event_sub_cb, &test_subs[TEST_SUBS_CUSTOM_DYNAMIC].data);
-	if (!test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub) {
-		ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_DYNAMIC subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-	ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub);
-
-	/*
-	 * Subscription TEST_SUBS_CUSTOM_DYNAMIC:
-	 *  - allocate dynamically
-	 *  - subscribe to all CUSTOM events
-	 *  - add IE checks for all types
-	 */
-	ast_test_status_update(test, "Adding TEST_SUBS_CUSTOM_DYNAMIC subscription\n");
-	test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = ast_event_subscribe_new(AST_EVENT_CUSTOM,
-		event_sub_cb, &test_subs[TEST_SUBS_CUSTOM_DYNAMIC].data);
-	if (!test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub) {
-		ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_DYNAMIC subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-
-	if (ast_event_sub_append_ie_uint(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_CEL_AMAFLAGS, 4)) {
-		ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub);
-		test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL;
-		ast_test_status_update(test, "Failed to append UINT IE to TEST_SUBS_CUSTOM_DYNAMIC subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-
-	if (ast_event_sub_append_ie_str(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_CEL_CIDNAME, "FOO/bar")) {
-		ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub);
-		test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL;
-		ast_test_status_update(test, "Failed to append STR IE to TEST_SUBS_CUSTOM_DYNAMIC subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-
-	if (ast_event_sub_append_ie_raw(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_CEL_USEREVENT_NAME, "800 km",
-			strlen("800 km"))) {
-		ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub);
-		test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL;
-		ast_test_status_update(test, "Failed to append RAW IE to TEST_SUBS_CUSTOM_DYNAMIC subscription\n");
-		res = AST_TEST_FAIL;
-		goto return_cleanup;
-	}
-
-	if (ast_event_sub_activate(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub)) {
-		ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub);
-		test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL;

[... 305 lines stripped ...]



More information about the asterisk-commits mailing list