[asterisk-commits] russell: branch russell/events r84741 - /team/russell/events/pbx/pbx_dundi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 4 18:50:37 CDT 2007


Author: russell
Date: Thu Oct  4 18:50:37 2007
New Revision: 84741

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84741
Log:
Fix a bunch of silly code.

Modified:
    team/russell/events/pbx/pbx_dundi.c

Modified: team/russell/events/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/team/russell/events/pbx/pbx_dundi.c?view=diff&rev=84741&r1=84740&r2=84741
==============================================================================
--- team/russell/events/pbx/pbx_dundi.c (original)
+++ team/russell/events/pbx/pbx_dundi.c Thu Oct  4 18:50:37 2007
@@ -4745,7 +4745,7 @@
 		return s;
 
 	s = ast_skip_blanks(s);
-	for (len = strlen(s); s[len] < 33; s[len] = '\0', len = strlen(s)) 
+	for (len = strlen(s); len && s[len - 1] < 33; s[len - 1] = '\0', len = strlen(s))
 		;
 	
 	return s;
@@ -4767,34 +4767,35 @@
 	return -1;
 }
 
-static enum ast_event_ie_pltype get_ie_pltype_mwi(const char *val)
+static enum ast_event_ie_pltype get_ie_pltype(enum ast_event_ie_type ie_type)
+{
+	switch (ie_type) {
+	case AST_EVENT_IE_CONTEXT:
+		return AST_EVENT_IE_PLTYPE_STR;
+	default:
+		return -1;
+	}
+}
+
+static enum ast_event_ie_type get_ie_type_mwi(const char *val)
 {
 	if (!strcasecmp(val, "context"))
 		return AST_EVENT_IE_CONTEXT;
-	
+
 	return -1;
 }
 
-static enum ast_event_ie_pltype get_ie_pltype(enum ast_event_ie_type ie_type,
+static enum ast_event_ie_type get_supported_event_ie_type(enum ast_event_type event_type,
 	const char *val)
 {
-	switch (ie_type) {
+	switch (event_type) {
 	case AST_EVENT_MWI:
-		return get_ie_pltype_mwi(val);
+		return get_ie_type_mwi(val);
 	default:
 		return -1;
 	}
 }
 
-static enum ast_event_ie_type get_supported_event_ie_type(enum ast_event_type event_type,
-	const char *val)
-{
-	if (!strcasecmp(val, "mwi"))
-		return AST_EVENT_MWI;
-
-	return -1;
-}
-
 static int add_param_to_event_sub(struct pub_event_map *pub_event_map,
 	struct ast_variable *param)
 {
@@ -4803,17 +4804,13 @@
 
 	ie_type = get_supported_event_ie_type(pub_event_map->event_type, param->name);
 	if (ie_type == -1) {
-		ast_log(LOG_ERROR, "Invalid parameter type '%s' for event mapping "
-			" for DUNDi context '%s'\n", param->name, pub_event_map->context);
+		ast_log(LOG_ERROR, "Invalid event parameter type '%s' "
+			"for event type '%d' in DUNDi context '%s'\n", 
+			param->name, pub_event_map->event_type, pub_event_map->context);
 		return -1;
 	}
 
-	switch (get_ie_pltype(ie_type, param->value)) {
-	case -1:
-		ast_log(LOG_ERROR, "Invalie value '%s' for parameter in event "
-			"mapping for DUNDi context '%s\n", 
-			param->value, pub_event_map->context);
-		return -1;
+	switch (get_ie_pltype(ie_type)) {
 	case AST_EVENT_IE_PLTYPE_UINT:
 	{
 		uint32_t uint;
@@ -4833,6 +4830,11 @@
 	case AST_EVENT_IE_PLTYPE_EXISTS:
 		ast_event_sub_append_ie_exists(sub, ie_type);
 		break;
+	case -1:
+		ast_log(LOG_ERROR, "Invalid value '%s' for parameter in event "
+			"mapping for DUNDi context '%s\n", 
+			param->value, pub_event_map->context);
+		return -1;
 	}
 
 	return 0;
@@ -4848,7 +4850,7 @@
 	enum ast_event_type event_type;
 
 	params = ast_strdupa(val);
-
+	
 	context = strsep(&params, ",");
 	context = clean_string(context);
 




More information about the asterisk-commits mailing list