[asterisk-commits] file: branch group/res_clialiases r145073 - /team/group/res_clialiases/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Sep 28 13:22:26 CDT 2008
Author: file
Date: Sun Sep 28 13:22:26 2008
New Revision: 145073
URL: http://svn.digium.com/view/asterisk?view=rev&rev=145073
Log:
Add in current 'round of fixes.
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=145073&r1=145072&r2=145073
==============================================================================
--- team/group/res_clialiases/res/res_clialiases.c (original)
+++ team/group/res_clialiases/res/res_clialiases.c Sun Sep 28 13:22:26 2008
@@ -47,6 +47,7 @@
char *alias; /*!< CLI Alias */
char *real_cmd; /*!< Actual CLI command it is aliased to */
unsigned int marked:1; /*!< Bit to indicate whether this CLI alias is marked for destruction or not */
+ unsigned int registered:1; /*!< Bit to indicate that the CLI command was registered */
};
static struct ao2_container *cli_aliases;
@@ -72,7 +73,13 @@
struct cli_alias *alias = obj;
/* Unregister the CLI entry from the core */
- ast_cli_unregister(&alias->cli_entry);
+ if (alias->registered) {
+ ast_cli_unregister(&alias->cli_entry);
+ }
+
+ if (alias->cli_entry._full_cmd) {
+ ast_free(alias->cli_entry._full_cmd);
+ }
ast_free(alias->alias);
ast_free(alias->real_cmd);
@@ -192,7 +199,7 @@
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct cli_alias *alias;
struct ast_variable *v;
- char *template_name = NULL;
+ const char *template_name = "default";
if (!(cfg = ast_config_load(config_file, config_flags))) {
ast_log(LOG_ERROR, "res_clialiases configuration file '%s' not found\n", config_file);
@@ -207,8 +214,8 @@
}
for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
- if ( !strcmp(v->name, "template") ) {
- template_name = ast_strdup(v->value);
+ if (!strcmp(v->name, "template")) {
+ template_name = v->value;
} else {
ast_log(LOG_WARNING, "%s is not a correct option in [%s]\n", v->name, "general");
}
@@ -226,16 +233,15 @@
alias->cli_entry._full_cmd = ast_strdup(alias->alias);
alias->cli_entry.usage = "Aliased CLI Command";
- //Make sure the alias real cmd really exists
- if ( ast_cli_is_registered(alias->real_cmd) ) {
- ast_log(LOG_ERROR, "%s is not registered yet, Skipping.\n", alias->real_cmd);
- continue;
- }
- if (!ast_cli_register(&alias->cli_entry)) {
+ /* 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);
- } else {
- ast_verbose(VERBOSE_PREFIX_2 "Failed to alias '%s' to '%s' as the CLI command already exists\n", v->name, v->value);
}
ao2_ref(alias, -1);
}
More information about the asterisk-commits
mailing list