diff options
author | David Lamparter <equinox@diac24.net> | 2010-02-05 09:48:45 +0100 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2010-02-05 09:51:24 +0100 |
commit | 55d24e7f3dbc69db37781dbff325bda0779778df (patch) | |
tree | a2b2525677332fd92ccc66a4c6082c620ba27802 /lib/vty.c | |
parent | 647e8e064d8e5316fc89587714a056b1240fa298 (diff) | |
download | quagga-55d24e7f3dbc69db37781dbff325bda0779778df.tar.bz2 quagga-55d24e7f3dbc69db37781dbff325bda0779778df.tar.xz |
lib: get rid of extraneous output with vty_prepend
the vty_*prepend* family can be used to reduce the amount of output
produced by "show running-config" and "write ...". it buffers output in
struct vty->prepend (1024 bytes) and outputs it when vty_out is called.
if vty_out isn't called, it can be removed with vty_unprepend later.
applied on zebra and ospfd to get rid of empty interface blocks.
Diffstat (limited to 'lib/vty.c')
-rw-r--r-- | lib/vty.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -90,6 +90,25 @@ static u_char restricted_mode = 0; char integrate_default[] = SYSCONFDIR INTEGRATE_DEFAULT_CONFIG; +void +vty_prepend (struct vty *vty, const char *format, ...) +{ + va_list args; + + va_start (args, format); + vsnprintf (vty->prepend + vty->prepend_pos, + sizeof(vty->prepend) - vty->prepend_pos, + format, args); + vty->prepend_pos = strlen (vty->prepend); + va_end (args); +} + +void +vty_unprepend (struct vty *vty) +{ + vty->prepend_pos = 0; +} + /* VTY standard output function. */ int vty_out (struct vty *vty, const char *format, ...) @@ -100,6 +119,12 @@ vty_out (struct vty *vty, const char *format, ...) char buf[1024]; char *p = NULL; + if (vty->prepend_pos) + { + vty->prepend_pos = 0; + vty_out (vty, "%s", vty->prepend); + } + if (vty_shell (vty)) { va_start (args, format); |