[svn-commits] mmichelson: branch group/CCSS r213111 - /team/group/CCSS/main/ccss.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Aug 19 16:20:53 CDT 2009


Author: mmichelson
Date: Wed Aug 19 16:20:49 2009
New Revision: 213111

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=213111
Log:
Improve representation of output of CC policies.

It really makes a Noop of one of the policies look
a lot nicer. Again, yay for testing!


Modified:
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=213111&r1=213110&r2=213111
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Wed Aug 19 16:20:49 2009
@@ -109,11 +109,51 @@
 	}
 }
 
+static const char *agent_policy_to_str(enum ast_cc_agent_policies policy)
+{
+	switch (policy) {
+	case AST_CC_AGENT_NEVER:
+		return "never";
+	case AST_CC_AGENT_NATIVE:
+		return "native";
+	case AST_CC_AGENT_GENERIC:
+		return "generic";
+	default:
+		/* This should never happen... */
+		return "";
+	}
+}
+
+static const char *monitor_policy_to_str(enum ast_cc_monitor_policies policy)
+{
+	switch (policy) {
+	case AST_CC_MONITOR_NEVER:
+		return "never";
+	case AST_CC_MONITOR_NATIVE:
+		return "native";
+	case AST_CC_MONITOR_GENERIC:
+		return "generic";
+	case AST_CC_MONITOR_ALWAYS:
+		return "always";
+	default:
+		/* This should never happen... */
+		return "";
+	}
+}
 int ast_cc_get_param(struct ast_cc_config_params *params, const char * const name, 
 		char *buf, size_t buf_len)
 {
+	const char *value = NULL;
 	if (!strcasecmp(name, "cc_callback_macro")) {
-		ast_copy_string(buf, ast_get_cc_callback_macro(params), buf_len);
+		value = ast_get_cc_callback_macro(params);
+	} else if (!strcasecmp(name, "cc_agent_policy")) {
+		value = agent_policy_to_str(ast_get_cc_agent_policy(params));
+	} else if (!strcasecmp(name, "cc_monitor_policy")) {
+		value = monitor_policy_to_str(ast_get_cc_monitor_policy(params));
+	}
+	
+	if (!ast_strlen_zero(value)) {
+		ast_copy_string(buf, value, buf_len);
 		return 0;
 	}
 
@@ -121,11 +161,7 @@
 	 * snprintf-itude
 	 */
 	
-	if (!strcasecmp(name, "cc_agent_policy")) {
-		snprintf(buf, buf_len, "%d", ast_get_cc_agent_policy(params));
-	} else if (!strcasecmp(name, "cc_monitor_policy")) {
-		snprintf(buf, buf_len, "%d", ast_get_cc_monitor_policy(params));
-	} else if (!strcasecmp(name, "cc_offer_timer")) {
+	if (!strcasecmp(name, "cc_offer_timer")) {
 		snprintf(buf, buf_len, "%u", ast_get_cc_offer_timer(params));
 	} else if (!strcasecmp(name, "ccnr_available_timer")) {
 		snprintf(buf, buf_len, "%u", ast_get_ccnr_available_timer(params));




More information about the svn-commits mailing list