[asterisk-commits] russell: branch russell/events r85400 - in /team/russell/events: include/aste...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 11 10:55:33 CDT 2007


Author: russell
Date: Thu Oct 11 10:55:33 2007
New Revision: 85400

URL: http://svn.digium.com/view/asterisk?view=rev&rev=85400
Log:
Remove custom implementation of the ast_strip() API call

Modified:
    team/russell/events/include/asterisk/strings.h
    team/russell/events/pbx/pbx_dundi.c

Modified: team/russell/events/include/asterisk/strings.h
URL: http://svn.digium.com/view/asterisk/team/russell/events/include/asterisk/strings.h?view=diff&rev=85400&r1=85399&r2=85400
==============================================================================
--- team/russell/events/include/asterisk/strings.h (original)
+++ team/russell/events/include/asterisk/strings.h Thu Oct 11 10:55:33 2007
@@ -54,6 +54,8 @@
 AST_INLINE_API(
 char *ast_skip_blanks(const char *str),
 {
+	if (!str)
+		return NULL;
 	while (*str && *str < 33)
 		str++;
 	return (char *)str;

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=85400&r1=85399&r2=85400
==============================================================================
--- team/russell/events/pbx/pbx_dundi.c (original)
+++ team/russell/events/pbx/pbx_dundi.c Thu Oct 11 10:55:33 2007
@@ -4728,35 +4728,14 @@
 	return NULL;
 }
 
-/*!
- * \brief Clean up a string
- *
- * Remove leading and trailing whitespace.  This will modify the string passed.
- *
- * \return The modified string.  If there was leading whitespace, the return
- *         value will point to the first non-whitespace character.  Any
- *         trailing whitespace will have been removed.
- */
-static char *clean_string(char *s)
-{
-	size_t len;
-
-	if (ast_strlen_zero(s))
-		return s;
-
-	s = ast_skip_blanks(s);
-	for (len = strlen(s); len && s[len - 1] < 33; s[len - 1] = '\0', len = strlen(s))
-		;
-	
-	return s;
-}
-
 static void ast_event_cb(const struct ast_event *event, void *data)
 {
 	struct pub_event_map *pub_event_map = data;
 
 	ast_debug(1, "Got an event to publish to DUNDi context '%s'\n",
 		pub_event_map->context);
+
+	/*! \todo XXX Send the event out to the network */
 }
 
 static enum ast_event_type get_event_type(const char *val)
@@ -4852,10 +4831,10 @@
 	params = ast_strdupa(val);
 	
 	context = strsep(&params, ",");
-	context = clean_string(context);
+	context = ast_strip(context);
 
 	event_type_s = strsep(&params, ",");
-	event_type_s = clean_string(event_type_s);
+	event_type_s = ast_strip(event_type_s);
 	if (ast_strlen_zero(event_type_s)) {
 		ast_log(LOG_ERROR, "publish_event mapping missing event type: '%s'\n", val);
 		return;
@@ -4884,21 +4863,21 @@
 	if (!pub_event_map->event_sub)
 		goto return_unref;
 
-	params = clean_string(params);
+	params = ast_strip(params);
 	for (cur_param = strsep(&params, ","); !ast_strlen_zero(cur_param); 
 			cur_param = strsep(&params, ",")) {
 		struct ast_variable *v;
 		char *param_name, *param_value;
 
-		param_value = clean_string(cur_param);
+		param_value = ast_strip(cur_param);
 		param_name = strsep(&param_value, "=");
 		if (ast_strlen_zero(param_name) || ast_strlen_zero(param_value)) {
 			ast_log(LOG_ERROR, "invalid event mapping in dundi.conf\n");
 			goto return_unref;
 		}
 
-		param_name = clean_string(param_name);
-		param_value = clean_string(param_value);
+		param_name = ast_strip(param_name);
+		param_value = ast_strip(param_value);
 
 		if (!(v = ast_variable_new(param_name, param_value, "")))
 			goto return_unref;




More information about the asterisk-commits mailing list