summaryrefslogtreecommitdiffstats
path: root/src/vty
diff options
context:
space:
mode:
Diffstat (limited to 'src/vty')
-rw-r--r--src/vty/vty.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/vty/vty.c b/src/vty/vty.c
index 8c89197e..98b332d6 100644
--- a/src/vty/vty.c
+++ b/src/vty/vty.c
@@ -249,26 +249,19 @@ int vty_shell(struct vty *vty)
return vty->type == VTY_SHELL ? 1 : 0;
}
-
-/*! VTY standard output function
- * \param[in] vty VTY to which we should print
- * \param[in] format variable-length format string
- */
-int vty_out(struct vty *vty, const char *format, ...)
+int vty_out_va(struct vty *vty, const char *format, va_list ap)
{
- va_list args;
int len = 0;
int size = 1024;
char buf[1024];
char *p = NULL;
if (vty_shell(vty)) {
- va_start(args, format);
- vprintf(format, args);
- va_end(args);
+ vprintf(format, ap);
} else {
+ va_list args;
/* Try to write to initial buffer. */
- va_start(args, format);
+ va_copy(args, ap);
len = vsnprintf(buf, sizeof buf, format, args);
va_end(args);
@@ -284,7 +277,7 @@ int vty_out(struct vty *vty, const char *format, ...)
if (!p)
return -1;
- va_start(args, format);
+ va_copy(args, ap);
len = vsnprintf(p, size, format, args);
va_end(args);
@@ -310,6 +303,20 @@ int vty_out(struct vty *vty, const char *format, ...)
return len;
}
+/*! VTY standard output function
+ * \param[in] vty VTY to which we should print
+ * \param[in] format variable-length format string
+ */
+int vty_out(struct vty *vty, const char *format, ...)
+{
+ va_list args;
+ int rc;
+ va_start(args, format);
+ rc = vty_out_va(vty, format, args);
+ va_end(args);
+ return rc;
+}
+
/*! print a newline on the given VTY */
int vty_out_newline(struct vty *vty)
{