summaryrefslogtreecommitdiff
path: root/pbx.c
diff options
context:
space:
mode:
authorMatt O'Gorman <mogorman@digium.com>2006-03-07 22:57:52 +0000
committerMatt O'Gorman <mogorman@digium.com>2006-03-07 22:57:52 +0000
commit09ea61fc7393e0d0de214ac511a30ef4b18f7fe0 (patch)
tree7d792fc6d3a6fcbd9c12a2e45460b2694e0ffd61 /pbx.c
parent9a475567bd88b7b2fe6b7b880a2f5260dbec6d2d (diff)
added show globals and set global from oej's patch
bug 6506 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@12430 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx.c')
-rw-r--r--pbx.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/pbx.c b/pbx.c
index b9f4a7a34..cef327d42 100644
--- a/pbx.c
+++ b/pbx.c
@@ -2810,6 +2810,14 @@ static char show_hints_help[] =
"Usage: show hints\n"
" Show registered hints\n";
+static char show_globals_help[] =
+"Usage: show globals\n"
+" Show current global dialplan variables and their values\n";
+
+static char set_global_help[] =
+"Usage: set global <name> <value>\n"
+" Set global dialplan variable <name> to <value>\n";
+
/*
* IMPLEMENTATION OF CLI FUNCTIONS IS IN THE SAME ORDER AS COMMANDS HELPS
@@ -3389,6 +3397,35 @@ static int handle_show_dialplan(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
+/*! \brief CLI support for listing global variables in a parseable way */
+static int handle_show_globals(int fd, int argc, char *argv[])
+{
+ int i = 0;
+ struct ast_var_t *newvariable;
+
+ AST_LIST_TRAVERSE (&globals, newvariable, entries) {
+ i++;
+ ast_cli(fd, " %s=%s\n", ast_var_name(newvariable), ast_var_value(newvariable));
+ }
+ /* ... we have applications ... */
+ ast_cli(fd, "\n -- %d variables\n", i);
+ return RESULT_SUCCESS;
+}
+
+/*! \brief CLI support for setting global variables */
+static int handle_set_global(int fd, int argc, char *argv[])
+{
+ if (argc != 4)
+ return RESULT_SHOWUSAGE;
+
+ pbx_builtin_setvar_helper(NULL, argv[2], argv[3]);
+ ast_cli(fd, "\n -- Global variables %s set to %s\n", argv[2], argv[3]);
+
+ return RESULT_SUCCESS;
+}
+
+
+
/*
* CLI entries for upper commands ...
*/
@@ -3407,6 +3444,10 @@ static struct ast_cli_entry pbx_cli[] = {
"Show alternative switches", show_switches_help },
{ { "show", "hints", NULL }, handle_show_hints,
"Show dialplan hints", show_hints_help },
+ { { "show", "globals", NULL }, handle_show_globals,
+ "Show global dialplan variables", show_globals_help },
+ { { "set", "global", NULL }, handle_set_global,
+ "Set global dialplan variable", set_global_help },
};
int ast_unregister_application(const char *app)