summaryrefslogtreecommitdiffstats
path: root/lib/vty.c
diff options
context:
space:
mode:
authorChris Hall (GMCH) <chris.hall@highwayman.com>2009-11-24 21:15:12 +0000
committerChris Hall (GMCH) <chris.hall@highwayman.com>2009-11-24 21:15:12 +0000
commit52ad6d6aaa536656a5995c5e2f17a0bc291f13ad (patch)
tree419436c7d1adda12d8124ce7e347eaa8f31108e5 /lib/vty.c
parenta455deac4f59a815150cfac5690e3273292f0189 (diff)
downloadquagga-52ad6d6aaa536656a5995c5e2f17a0bc291f13ad.tar.bz2
quagga-52ad6d6aaa536656a5995c5e2f17a0bc291f13ad.tar.xz
Add functions to lib/vty.c & .h
Added: vty_puts -- output string vty_out_newline -- output newline of appropriate form vty_out_indent -- output given number of spaces Made (vty == NULL) a synonym for VTY_TERM, for vty_out and related functions.
Diffstat (limited to 'lib/vty.c')
-rw-r--r--lib/vty.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/vty.c b/lib/vty.c
index 31739f76..3bf7eb55 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -90,7 +90,7 @@ static u_char restricted_mode = 0;
char integrate_default[] = SYSCONFDIR INTEGRATE_DEFAULT_CONFIG;
-/* VTY standard output function. */
+/* VTY standard output function. vty == NULL or VTY_SHELL => stdout */
int
vty_out (struct vty *vty, const char *format, ...)
{
@@ -151,6 +151,27 @@ vty_out (struct vty *vty, const char *format, ...)
return len;
}
+int
+vty_puts(struct vty *vty, const char* str)
+{
+ return vty_out(vty, "%s", str) ;
+}
+
+int
+vty_out_newline(struct vty *vty)
+{
+ return vty_out(vty, "%s", VTY_NEWLINE) ;
+}
+
+/* 123456789012345678901234 */
+const char* vty_spaces_string = " " ;
+
+int
+vty_out_indent(struct vty *vty, int indent)
+{
+ return vty_puts(vty, VTY_SPACES(indent)) ;
+}
+
static int
vty_log_out (struct vty *vty, const char *level, const char *proto_str,
const char *format, struct timestamp_control *ctl, va_list va)
@@ -2927,7 +2948,7 @@ vty_get_cwd ()
int
vty_shell (struct vty *vty)
{
- return vty->type == VTY_SHELL ? 1 : 0;
+ return ((vty == NULL) || (vty->type == VTY_SHELL)) ? 1 : 0;
}
int