]> git.puffer.fish Git - mirror/frr.git/commitdiff
Make "terminal length <0-512>" command work in vtysh.
authorhasso <hasso>
Fri, 27 Aug 2004 13:56:39 +0000 (13:56 +0000)
committerhasso <hasso>
Fri, 27 Aug 2004 13:56:39 +0000 (13:56 +0000)
lib/ChangeLog
lib/command.c
vtysh/ChangeLog
vtysh/vtysh.c

index 7c372df369572e18ce3bde7807f7053288c8eb0b..ea965eae31337f7de9efe0c10b5012d71f7c2413 100644 (file)
@@ -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
index 8b6ae3d0fd8157fb7ba631bbcd83326e8f53358c..088ad38cfa612f7b4d196198846a428f8331b56c 100644 (file)
@@ -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);
index 1903c7c2a7c55e86a93fe74839ed33c7d202754c..aab737b3b50d8a204fd265e73e7b94297ffc6d0e 100644 (file)
@@ -1,3 +1,7 @@
+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.
index 503edb30aea0d6a174b1c762ef8d6f952d3a2fcd..28ad39b1c2190f7cd0b4b994564a3fe786fa52e9 100644 (file)
@@ -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);