diff options
-rw-r--r-- | lib/ChangeLog | 5 | ||||
-rw-r--r-- | lib/command.c | 7 | ||||
-rw-r--r-- | vtysh/ChangeLog | 4 | ||||
-rw-r--r-- | vtysh/vtysh.c | 59 |
4 files changed, 71 insertions, 4 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index 7c372df3..ea965eae 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2004-08-27 Hasso Tepper <hasso at quagga.net> + + * command.c: Install "terminal length" commands only if vty is used. + Vtysh will handle it itself. + 2004-08-26 Greg Troxel <gdt@fnord.ir.bbn.com> * sockopt.h: Define method-independent macro for callers of diff --git a/lib/command.c b/lib/command.c index 8b6ae3d0..088ad38c 100644 --- a/lib/command.c +++ b/lib/command.c @@ -3300,8 +3300,11 @@ cmd_init (int terminal) } install_element (ENABLE_NODE, &show_startup_config_cmd); install_element (ENABLE_NODE, &show_version_cmd); - install_element (ENABLE_NODE, &config_terminal_length_cmd); - install_element (ENABLE_NODE, &config_terminal_no_length_cmd); + if (terminal) + { + install_element (ENABLE_NODE, &config_terminal_length_cmd); + install_element (ENABLE_NODE, &config_terminal_no_length_cmd); + } if (terminal) install_default (CONFIG_NODE); diff --git a/vtysh/ChangeLog b/vtysh/ChangeLog index 1903c7c2..aab737b3 100644 --- a/vtysh/ChangeLog +++ b/vtysh/ChangeLog @@ -1,5 +1,9 @@ 2004-08-27 Hasso Tepper <hasso at quagga.net> + * vtysh.c: Make "terminal length <0-512>" command work in vtysh. + +2004-08-27 Hasso Tepper <hasso at quagga.net> + * vtysh.c: Enable using ssh from ENABLE_NODE. * vtysh_config.c: Make enable password uniq lines appear only once in configuration. diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 503edb30..28ad39b1 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -212,9 +212,9 @@ vtysh_exit_ripd_only () void vtysh_pager_init () { - vtysh_pager_name = getenv ("VTYSH_PAGER"); + vtysh_pager_name = strdup (getenv ("VTYSH_PAGER")); if (! vtysh_pager_name) - vtysh_pager_name = "more"; + vtysh_pager_name = strdup ("more"); } /* Command execution over the vty interface. */ @@ -1503,6 +1503,56 @@ ALIAS (vtysh_write_terminal, SHOW_STR "Current operating configuration\n") +DEFUN (vtysh_terminal_length, + vtysh_terminal_length_cmd, + "terminal length <0-512>", + "Set terminal line parameters\n" + "Set number of lines on a screen\n" + "Number of lines on screen (0 for no pausing)\n") +{ + int lines; + char *endptr = NULL; + char default_pager[10]; + + lines = strtol (argv[0], &endptr, 10); + if (lines < 0 || lines > 512 || *endptr != '\0') + { + vty_out (vty, "length is malformed%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (vtysh_pager_name) + { + free (vtysh_pager_name); + vtysh_pager_name = NULL; + } + + if (lines != 0) + { + snprintf(default_pager, 10, "more -%i", lines); + vtysh_pager_name = strdup (default_pager); + } + + return CMD_SUCCESS; +} + +DEFUN (vtysh_terminal_no_length, + vtysh_terminal_no_length_cmd, + "terminal no length", + "Set terminal line parameters\n" + NO_STR + "Set number of lines on a screen\n") +{ + if (vtysh_pager_name) + { + free (vtysh_pager_name); + vtysh_pager_name = NULL; + } + + vtysh_pager_init(); + return CMD_SUCCESS; +} + /* Execute command in child process. */ int execute_command (char *command, int argc, char *arg1, char *arg2) @@ -1978,6 +2028,11 @@ vtysh_init_vty () install_element (KEYCHAIN_NODE, &vtysh_write_memory_cmd); install_element (KEYCHAIN_KEY_NODE, &vtysh_write_memory_cmd); + install_element (VIEW_NODE, &vtysh_terminal_length_cmd); + install_element (ENABLE_NODE, &vtysh_terminal_length_cmd); + install_element (VIEW_NODE, &vtysh_terminal_no_length_cmd); + install_element (ENABLE_NODE, &vtysh_terminal_no_length_cmd); + install_element (VIEW_NODE, &vtysh_ping_cmd); install_element (VIEW_NODE, &vtysh_ping_ip_cmd); install_element (VIEW_NODE, &vtysh_traceroute_cmd); |