diff options
| author | David Lamparter <equinox@opensourcerouting.org> | 2016-12-05 20:04:08 +0100 |
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2016-12-05 20:04:08 +0100 |
| commit | 7ddcfca4fb5246c5e211f7e37d98a8c9a51b4e70 (patch) | |
| tree | ea8dead406e7963c4b8283477daea4d5224845ac /lib/command.c | |
| parent | 53dc2b05c76f4f5cd6a72373fb241afdcedb2ee1 (diff) | |
| parent | 54c5dce6a5e46717ad52c80f2dc99fc36a372e28 (diff) | |
Merge branch 'queue/osr/vtysh-generic'
WARNING: Merge contains nontrivial fixups in vrf_cmd handling.
Conflicts:
lib/if.c
zebra/interface.c
Diffstat (limited to 'lib/command.c')
| -rw-r--r-- | lib/command.c | 59 |
1 files changed, 23 insertions, 36 deletions
diff --git a/lib/command.c b/lib/command.c index f691cb599a..e51ff837aa 100644 --- a/lib/command.c +++ b/lib/command.c @@ -39,7 +39,6 @@ #include "workqueue.h" #include "vrf.h" #include "command_match.h" -#include "command_parse.h" #include "qobj.h" DEFINE_MTYPE( LIB, HOST, "Host config") @@ -1051,6 +1050,13 @@ DEFUN (config_exit, "exit", "Exit current mode and down to previous mode\n") { + cmd_exit (vty); + return CMD_SUCCESS; +} + +void +cmd_exit (struct vty *vty) +{ switch (vty->node) { case VIEW_NODE: @@ -1118,7 +1124,6 @@ DEFUN (config_exit, default: break; } - return CMD_SUCCESS; } /* ALIAS_FIXME */ @@ -1264,17 +1269,12 @@ permute (struct graph_node *start, struct vty *vty) list_delete_node (position, listtail(position)); } -/* Help display function for all node. */ -DEFUN (config_list, - config_list_cmd, - "list [permutations]", - "Print command list\n" - "Print all possible command permutations\n") +int +cmd_list_cmds (struct vty *vty, int do_permute) { struct cmd_node *node = vector_slot (cmdvec, vty->node); - if ((strmatch (argv[0]->text, "list") && argc == 2) || - (strmatch (argv[0]->text, "show") && argc == 3)) + if (do_permute) permute (vector_slot (node->cmdgraph->nodes, 0), vty); else { @@ -1289,13 +1289,23 @@ DEFUN (config_list, return CMD_SUCCESS; } +/* Help display function for all node. */ +DEFUN (config_list, + config_list_cmd, + "list [permutations]", + "Print command list\n" + "Print all possible command permutations\n") +{ + return cmd_list_cmds (vty, argc == 2); +} + DEFUN (show_commandtree, show_commandtree_cmd, "show commandtree [permutations]", SHOW_STR "Show command tree\n") { - return config_list (self, vty, argc, argv); + return cmd_list_cmds (vty, argc == 3); } /* Write current configuration into file. */ @@ -2352,10 +2362,8 @@ cmd_init (int terminal) install_element (ENABLE_NODE, &config_logmsg_cmd); install_default (CONFIG_NODE); - install_element (VIEW_NODE, &show_thread_cpu_cmd); - install_element (ENABLE_NODE, &clear_thread_cpu_cmd); - - install_element (VIEW_NODE, &show_work_queues_cmd); + thread_cmd_init (); + workqueue_cmd_init (); } install_element (CONFIG_NODE, &hostname_cmd); @@ -2438,27 +2446,6 @@ copy_cmd_token (struct cmd_token *token) } void -del_cmd_element(struct cmd_element *cmd) -{ - if (!cmd) return; - free ((char *) cmd->string); - free ((char *) cmd->doc); - free (cmd); -} - -struct cmd_element * -copy_cmd_element(const struct cmd_element *cmd) -{ - struct cmd_element *el = XMALLOC(MTYPE_CMD_TOKENS, sizeof (struct cmd_element)); - el->string = cmd->string ? XSTRDUP(MTYPE_CMD_TOKENS, cmd->string) : NULL; - el->func = cmd->func; - el->doc = cmd->doc ? XSTRDUP(MTYPE_CMD_TOKENS, cmd->doc) : NULL; - el->daemon = cmd->daemon; - el->attr = cmd->attr; - return el; -} - -void cmd_terminate () { struct cmd_node *cmd_node; |
