[asterisk-commits] mmichelson: branch group/manager2 r113594 - /team/group/manager2/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 8 19:23:27 CDT 2008


Author: mmichelson
Date: Tue Apr  8 19:23:27 2008
New Revision: 113594

URL: http://svn.digium.com/view/asterisk?view=rev&rev=113594
Log:
Update the copyright header block since this is not app_skel...

Also change the scheme by which filters mark which events to subscribe to.
This will allow for O(1) lookups should such lookups be needed.


Modified:
    team/group/manager2/res/res_manager2.c

Modified: team/group/manager2/res/res_manager2.c
URL: http://svn.digium.com/view/asterisk/team/group/manager2/res/res_manager2.c?view=diff&rev=113594&r1=113593&r2=113594
==============================================================================
--- team/group/manager2/res/res_manager2.c (original)
+++ team/group/manager2/res/res_manager2.c Tue Apr  8 19:23:27 2008
@@ -18,11 +18,15 @@
 
 /*! \file
  *
- * \brief Skeleton application
+ * \brief Event Subscriber Resource
+ * This is intended to allow an observer to see events that happen
+ * on the system (similar to manager events of the past). The difference
+ * is that since this uses the Asterisk event API, it provides for more
+ * powerful filtering options, meaning that manager sessions will not
+ * be bombarded with a slew of unwelcome events.
  *
  * \author\verbatim Mark Michelson <mmichelson at digium.com> \endverbatim
  * 
- * This is a skeleton for development of an Asterisk application 
  * \ingroup applications
  */
 
@@ -71,7 +75,7 @@
 };
 
 struct subscriber_filter {
-	enum ast_event_type events[800];     /* Totally arbitrary number for the time being */
+	enum ast_event_type events[AST_EVENT_TOTAL];     /* The events to which we subscribe. */
 	int num_events;                      /* Number of events we're subscribed to. Used for iteration purposes */
 };
 
@@ -285,7 +289,7 @@
 {
 	struct subscriber_filter *new_filter = NULL;
 	struct ast_variable *var = NULL;
-	int event_index = 0;
+	int num_events_subscribed = 0;
 
 	if (!(new_filter = ast_calloc(1, sizeof(*new_filter)))) {
 		/* OH CRAP */
@@ -296,7 +300,8 @@
 		if (!strcasecmp(var->name, "event")) {
 			enum ast_event_type new_type = ast_event_get_type_by_name(var->value);
 			if (new_type != -1) {
-				new_filter->events[event_index++] = new_type;
+				new_filter->events[new_type] = 1;
+				num_events_subscribed++;
 			} else {
 				ast_log(LOG_WARNING, "Error parsing event type '%s' on line %d; not added to filter!\n", var->value, var->lineno);
 			}
@@ -305,7 +310,7 @@
 		}
 	}
 
-	new_filter->num_events = event_index;
+	new_filter->num_events = num_events_subscribed;
 
 	return new_filter;
 }




More information about the asterisk-commits mailing list