[asterisk-commits] mvanbaak: branch group/res_clialiases r145131 - /team/group/res_clialiases/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Sep 28 19:25:37 CDT 2008


Author: mvanbaak
Date: Sun Sep 28 19:25:36 2008
New Revision: 145131

URL: http://svn.digium.com/view/asterisk?view=rev&rev=145131
Log:
allow multiple templates to be used

Modified:
    team/group/res_clialiases/res/res_clialiases.c

Modified: team/group/res_clialiases/res/res_clialiases.c
URL: http://svn.digium.com/view/asterisk/team/group/res_clialiases/res/res_clialiases.c?view=diff&rev=145131&r1=145130&r2=145131
==============================================================================
--- team/group/res_clialiases/res/res_clialiases.c (original)
+++ team/group/res_clialiases/res/res_clialiases.c Sun Sep 28 19:25:36 2008
@@ -194,8 +194,7 @@
 	struct ast_config *cfg = NULL;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 	struct cli_alias *alias;
-	struct ast_variable *v;
-	const char *template_name = "default";
+	struct ast_variable *v, *v1;
 
 	if (!(cfg = ast_config_load(config_file, config_flags))) {
 		ast_log(LOG_ERROR, "res_clialiases configuration file '%s' not found\n", config_file);
@@ -211,34 +210,32 @@
 
 	for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
 		if (!strcmp(v->name, "template")) {
-			template_name = v->value;
+			/* Read in those there CLI aliases */
+			for (v1 = ast_variable_browse(cfg, v->value); v1; v1 = v1->next) {
+				if (!(alias = ao2_alloc(sizeof(*alias), alias_destroy))) {
+					continue;
+				}
+				alias->alias = ast_strdup(v1->name);
+				alias->real_cmd = ast_strdup(v1->value);
+				alias->cli_entry.handler = cli_alias_passthrough;
+				alias->cli_entry.command = alias->alias;
+				alias->cli_entry.usage = "Aliased CLI Command";
+
+				/* Make sure the real command this alias points to really exists */
+				if (ast_cli_is_registered(alias->real_cmd)) {
+					ast_log(LOG_ERROR, "%s is not registered yet, skipping.\n", alias->real_cmd);
+				} else if (ast_cli_register(&alias->cli_entry)) {
+					ast_log(LOG_ERROR, "%s is already registered, skipping.\n", alias->real_cmd);
+				} else {
+					alias->registered = 1;
+					ao2_link(cli_aliases, alias);
+					ast_verbose(VERBOSE_PREFIX_2 "Aliased CLI command '%s' to '%s'\n", v1->name, v1->value);
+				}
+				ao2_ref(alias, -1);
+			}
 		} else {
 			ast_log(LOG_WARNING, "%s is not a correct option in [%s]\n", v->name, "general");
 		}
-	}
-
-	/* Read in those there CLI aliases */
-	for (v = ast_variable_browse(cfg, template_name); v; v = v->next) {
-		if (!(alias = ao2_alloc(sizeof(*alias), alias_destroy))) {
-			continue;
-		}
-		alias->alias = ast_strdup(v->name);
-		alias->real_cmd = ast_strdup(v->value);
-		alias->cli_entry.handler = cli_alias_passthrough;
-		alias->cli_entry.command = alias->alias;
-		alias->cli_entry.usage = "Aliased CLI Command";
-
-		/* Make sure the real command this alias points to really exists */
-		if (ast_cli_is_registered(alias->real_cmd)) {
-			ast_log(LOG_ERROR, "%s is not registered yet, skipping.\n", alias->real_cmd);
-		} else if (ast_cli_register(&alias->cli_entry)) {
-			ast_log(LOG_ERROR, "%s is already registered, skipping.\n", alias->real_cmd);
-		} else {
-			alias->registered = 1;
-			ao2_link(cli_aliases, alias);
-			ast_verbose(VERBOSE_PREFIX_2 "Aliased CLI command '%s' to '%s'\n", v->name, v->value);
-		}
-		ao2_ref(alias, -1);
 	}
 
 	/* Drop any CLI aliases that should no longer exist */




More information about the asterisk-commits mailing list