[asterisk-commits] mmichelson: branch group/manager2 r114079 - in /team/group/manager2: include/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 11 17:19:31 CDT 2008


Author: mmichelson
Date: Fri Apr 11 17:19:31 2008
New Revision: 114079

URL: http://svn.digium.com/view/asterisk?view=rev&rev=114079
Log:
Add a function to get an event's name. Use this in the
event_spitter to tell the name of the event which occurred.


Modified:
    team/group/manager2/include/asterisk/event.h
    team/group/manager2/main/event.c
    team/group/manager2/res/res_manager2.c

Modified: team/group/manager2/include/asterisk/event.h
URL: http://svn.digium.com/view/asterisk/team/group/manager2/include/asterisk/event.h?view=diff&rev=114079&r1=114078&r2=114079
==============================================================================
--- team/group/manager2/include/asterisk/event.h (original)
+++ team/group/manager2/include/asterisk/event.h Fri Apr 11 17:19:31 2008
@@ -74,6 +74,15 @@
 enum ast_event_type ast_event_get_type_by_name(const char *event_name);
 
 /*!
+ * \brief accessor function to get an event's name, given an event
+ *
+ * \param event an ast_event pointer which is the event whose name is desired
+ *
+ * \return The name of the event
+ */
+const char *ast_event_get_name(const struct ast_event *event);
+
+/*!
  * \brief accessor function to get an ast_event_ie_type's payload type
  *
  * \param ie the ast_event_ie_type to be looked up

Modified: team/group/manager2/main/event.c
URL: http://svn.digium.com/view/asterisk/team/group/manager2/main/event.c?view=diff&rev=114079&r1=114078&r2=114079
==============================================================================
--- team/group/manager2/main/event.c (original)
+++ team/group/manager2/main/event.c Fri Apr 11 17:19:31 2008
@@ -203,6 +203,18 @@
 		return -1;
 }
 
+const char *ast_event_get_name(const struct ast_event *event)
+{
+	enum ast_event_type event_type = ntohs(event->type);
+	ast_log(LOG_NOTICE, "The value is %d\n", event_type);
+	if (event_type >= 0 && event_type < AST_EVENT_TOTAL &&
+			event_name_map[event_type].event == event_type) {
+		return event_name_map[event_type].name;
+	}
+
+	return NULL;
+}
+
 enum ast_event_ie_pltype  ast_event_ie_get_pltype(enum ast_event_ie_type ie) 
 {
 	if (ie > 0 && ie < AST_EVENT_IE_LAST && 

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=114079&r1=114078&r2=114079
==============================================================================
--- team/group/manager2/res/res_manager2.c (original)
+++ team/group/manager2/res/res_manager2.c Fri Apr 11 17:19:31 2008
@@ -174,6 +174,8 @@
 			/* OH CRAP */
 		}
 
+		ast_str_append(&buf, 0, "Event: %s\r\n", S_OR(ast_event_get_name(event->event), "<unknown>"));
+
 		for (ast_event_iterator_init(&iter, event->event); !res; res = ast_event_iterator_next(&iter)) {
 			enum ast_event_ie_type ie_type = ast_event_iterator_get_ie_type(&iter);
 			if (ie_type == AST_EVENT_IE_END)




More information about the asterisk-commits mailing list