[svn-commits] russell: branch russell/chan_console r95377 - in /team/russell/chan_console: ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Dec 30 13:54:26 CST 2007


Author: russell
Date: Sun Dec 30 13:54:25 2007
New Revision: 95377

URL: http://svn.digium.com/view/asterisk?view=rev&rev=95377
Log:
Convert config parsing to use the CV_*() config parsing macros.  I also added
a CV_STRFIELD() macro that sets a stringfield to a config value.

Modified:
    team/russell/chan_console/channels/chan_console.c
    team/russell/chan_console/channels/chan_oss.c
    team/russell/chan_console/include/asterisk/config.h

Modified: team/russell/chan_console/channels/chan_console.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/channels/chan_console.c?view=diff&rev=95377&r1=95376&r2=95377
==============================================================================
--- team/russell/chan_console/channels/chan_console.c (original)
+++ team/russell/chan_console/channels/chan_console.c Sun Dec 30 13:54:25 2007
@@ -863,6 +863,38 @@
 	pvt->autoanswer = 0;
 }
 
+static void store_callerid(struct console_pvt *pvt, const char *value)
+{
+	char cid_name[256];
+	char cid_num[256];
+
+	ast_callerid_split(value, cid_name, sizeof(cid_name), 
+		cid_num, sizeof(cid_num));
+
+	ast_string_field_set(pvt, cid_name, cid_name);
+	ast_string_field_set(pvt, cid_num, cid_num);
+}
+
+static void store_config_core(struct console_pvt *pvt, const char *var, const char *value)
+{
+	if (!ast_jb_read_conf(&global_jbconf, var, value))
+		return;
+
+	CV_START(var, value);
+
+	CV_STRFIELD("context", pvt, context);
+	CV_STRFIELD("extension", pvt, exten);
+	CV_STRFIELD("mohinterpret", pvt, mohinterpret);
+	CV_STRFIELD("language", pvt, language);
+	CV_F("callerid", store_callerid(pvt, value));
+	CV_BOOL("overridecontext", pvt->overridecontext);
+	CV_BOOL("autoanswer", pvt->autoanswer);
+	
+	ast_log(LOG_WARNING, "Unknown option '%s'\n", var);
+
+	CV_END;
+}
+
 /*!
  * \brief Load the configuration
  * \param reload if this was called due to a reload
@@ -889,33 +921,9 @@
 		goto return_unlock;
 	}
 
-	v = ast_variable_browse(cfg, "general");
-	for (; v; v = v->next) {
-		if (!ast_jb_read_conf(&global_jbconf, v->name, v->value))
-			continue;
-		else if (!strcasecmp(v->name, "context"))
-			ast_string_field_set(pvt, context, v->value);
-		else if (!strcasecmp(v->name, "extension"))
-			ast_string_field_set(pvt, exten, v->value);
-		else if (!strcasecmp(v->name, "mohinterpret"))
-			ast_string_field_set(pvt, mohinterpret, v->value);
-		else if (!strcasecmp(v->name, "language"))
-			ast_string_field_set(pvt, language, v->value);
-		else if (!strcasecmp(v->name, "callerid")) {
-			char cid_name[256];
-			char cid_num[256];
-			ast_callerid_split(v->value, cid_name, sizeof(cid_name), 
-				cid_num, sizeof(cid_num));
-			ast_string_field_set(pvt, cid_name, cid_name);
-			ast_string_field_set(pvt, cid_num, cid_num);
-		} else if (!strcasecmp(v->name, "overridecontext"))
-			pvt->overridecontext = ast_true(v->value) ? 1 : 0;
-		else if (!strcasecmp(v->name, "autoanswer"))
-			pvt->autoanswer = ast_true(v->value) ? 1 : 0;
-		else
-			ast_log(LOG_WARNING, "Unknown option '%s' on line '%d' of '%s'!\n",
-				v->name, v->lineno, config_file);
-	}
+	for (v = ast_variable_browse(cfg, "general"); v; v = v->next)
+		store_config_core(pvt, v->name, v->value);
+
 	ast_config_destroy(cfg);
 
 	res = 0;

Modified: team/russell/chan_console/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/channels/chan_oss.c?view=diff&rev=95377&r1=95376&r2=95377
==============================================================================
--- team/russell/chan_console/channels/chan_oss.c (original)
+++ team/russell/chan_console/channels/chan_oss.c Sun Dec 30 13:54:25 2007
@@ -1545,7 +1545,7 @@
 	CV_STR("mohinterpret", o->mohinterpret);
 	CV_STR("extension", o->ext);
 	CV_F("mixer", store_mixer(o, value));
-	CV_F("callerid", store_callerid(o, value))  ;
+	CV_F("callerid", store_callerid(o, value));
 	CV_F("boost", store_boost(o, value));
 
 	CV_END;

Modified: team/russell/chan_console/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/team/russell/chan_console/include/asterisk/config.h?view=diff&rev=95377&r1=95376&r2=95377
==============================================================================
--- team/russell/chan_console/include/asterisk/config.h (original)
+++ team/russell/chan_console/include/asterisk/config.h Sun Dec 30 13:54:25 2007
@@ -397,6 +397,7 @@
 #define CV_UINT(__x, __dst)	CV_F(__x, (__dst) = strtoul(__val, NULL, 0) )
 #define CV_STR(__x, __dst)	CV_F(__x, ast_copy_string(__dst, __val, sizeof(__dst)))
 #define CV_DSTR(__x, __dst)	CV_F(__x, if (__dst) ast_free(__dst); __dst = ast_strdup(__val))
+#define CV_STRFIELD(__x, __obj, __field) CV_F(__x, ast_string_field_set(__obj, __field, __val))
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }




More information about the svn-commits mailing list