From 51e156b303174567062db59268bc8afa43ef730f Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 23 Jun 2016 14:47:32 +0000 Subject: [PATCH] Add grammar sandbox framework --- lib/command.c | 6 +++++ lib/grammar_sandbox.c | 53 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 lib/grammar_sandbox.c diff --git a/lib/command.c b/lib/command.c index 34864e9d3f..b5a754fccf 100644 --- a/lib/command.c +++ b/lib/command.c @@ -34,6 +34,8 @@ Boston, MA 02111-1307, USA. */ #include "workqueue.h" #include "vrf.h" +#include "grammar_sandbox.c" + /* Command vector which includes some level of command lists. Normally each daemon maintains each own cmdvec. */ vector cmdvec = NULL; @@ -4079,6 +4081,10 @@ cmd_init (int terminal) install_element (ENABLE_NODE, &show_version_cmd); install_element (ENABLE_NODE, &show_commandtree_cmd); + /**/ + grammar_sandbox_init(); + /**/ + if (terminal) { install_element (ENABLE_NODE, &config_terminal_length_cmd); diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c new file mode 100644 index 0000000000..c19be7f934 --- /dev/null +++ b/lib/grammar_sandbox.c @@ -0,0 +1,53 @@ +#include "command.h" + +#define GRAMMAR_STR "CLI grammar sandbox\n" + +DEFUN (grammar_midkey_test, + grammar_midkey_test_cmd, + "grammar {one|two} test", + GRAMMAR_STR + "First option\n" + "Second option\n" + "Test parameter to end string\n") +{ + return CMD_SUCCESS; +} + +DEFUN (grammar_onemidkey_test, + grammar_onemidkey_test_cmd, + "grammar {onekey} test", + GRAMMAR_STR + "First option\n" + "Test parameter to end string\n") +{ + return CMD_SUCCESS; +} + +DEFUN (grammar_smashmouth_test, + grammar_smashmouth_test_cmd, + "grammar {smash MOUTH} test", + GRAMMAR_STR + "It ain't easy bein' cheesy\n" + "Test parameter to end string\n") +{ + return CMD_SUCCESS; +} + +DEFUN (grammar_midopt_test, + grammar_midopt_test_cmd, + "grammar [option] test", + GRAMMAR_STR + "optional argument\n" + "Test parameter to end string\n") +{ + return CMD_SUCCESS; +} + + +void grammar_sandbox_init(void); +void grammar_sandbox_init() { + install_element (ENABLE_NODE, &grammar_midkey_test_cmd); + install_element (ENABLE_NODE, &grammar_onemidkey_test_cmd); + install_element (ENABLE_NODE, &grammar_midopt_test_cmd); + install_element (ENABLE_NODE, &grammar_smashmouth_test_cmd); +} -- 2.39.5