[asterisk-commits] mvanbaak: branch group/res_clialiases r145022 - in /team/group/res_clialiases...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Sep 28 10:24:35 CDT 2008
Author: mvanbaak
Date: Sun Sep 28 10:24:34 2008
New Revision: 145022
URL: http://svn.digium.com/view/asterisk?view=rev&rev=145022
Log:
Dont add the alias if the real command is not registered as CLI command.
JunkY: "If you get it working I owe you two beers"
Now it's time to collect ;)
Modified:
team/group/res_clialiases/include/asterisk/cli.h
team/group/res_clialiases/main/cli.c
team/group/res_clialiases/res/res_clialiases.c
Modified: team/group/res_clialiases/include/asterisk/cli.h
URL: http://svn.digium.com/view/asterisk/team/group/res_clialiases/include/asterisk/cli.h?view=diff&rev=145022&r1=145021&r2=145022
==============================================================================
--- team/group/res_clialiases/include/asterisk/cli.h (original)
+++ team/group/res_clialiases/include/asterisk/cli.h Sun Sep 28 10:24:34 2008
@@ -278,6 +278,8 @@
*/
char *ast_complete_channels(const char *line, const char *word, int pos, int state, int rpos);
+int ast_cli_is_registered(char *const cmd);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
Modified: team/group/res_clialiases/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/group/res_clialiases/main/cli.c?view=diff&rev=145022&r1=145021&r2=145022
==============================================================================
--- team/group/res_clialiases/main/cli.c (original)
+++ team/group/res_clialiases/main/cli.c Sun Sep 28 10:24:34 2008
@@ -1926,3 +1926,21 @@
}
return count;
}
+
+int ast_cli_is_registered(char *const cmd) {
+ int res;
+ char *args[AST_MAX_ARGS + 1];
+ int x;
+ char *duplicate = parse_args(cmd, &x, args + 1, AST_MAX_ARGS, NULL);
+ if (duplicate == NULL) {
+ res = 1;
+ }
+ AST_RWLIST_RDLOCK(&helpers);
+ if (find_cli(args + 1, 0)) {
+ res = 0;
+ } else {
+ res = 1;
+ }
+ AST_RWLIST_UNLOCK(&helpers);
+ return res;
+}
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=145022&r1=145021&r2=145022
==============================================================================
--- team/group/res_clialiases/res/res_clialiases.c (original)
+++ team/group/res_clialiases/res/res_clialiases.c Sun Sep 28 10:24:34 2008
@@ -206,15 +206,13 @@
ao2_callback(cli_aliases, OBJ_NODATA, alias_mark, NULL);
}
- for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
- if ( !strcmp(v->name,"template") ) {
+ for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
+ if ( !strcmp(v->name, "template") ) {
template_name = ast_strdup(v->value);
} 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) {
@@ -227,6 +225,12 @@
alias->cli_entry.command = alias->alias;
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)) {
ao2_link(cli_aliases, alias);
ast_verbose(VERBOSE_PREFIX_2 "Aliased CLI command '%s' to '%s'\n", v->name, v->value);
More information about the asterisk-commits
mailing list