]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
CLI: adding cli_vprintf()
authorMaria Matejka <mq@ucw.cz>
Thu, 14 Nov 2024 19:46:45 +0000 (20:46 +0100)
committerOndrej Zajicek <santiago@crfreenet.org>
Mon, 2 Dec 2024 03:27:30 +0000 (04:27 +0100)
nest/cli.c
nest/cli.h

index 9573f7700688efa293313cd7fd8c4723807a2b04..42f1d6cd759f1b8ebed634de023735178736e416 100644 (file)
@@ -117,9 +117,8 @@ cli_alloc_out(cli *c, int size)
  * macro instead.
  */
 void
-cli_printf(cli *c, int code, char *msg, ...)
+cli_vprintf(cli *c, int code, const char *msg, va_list args)
 {
-  va_list args;
   byte buf[CLI_LINE_SIZE];
   int cd = code;
   int errcode;
@@ -147,9 +146,7 @@ cli_printf(cli *c, int code, char *msg, ...)
     }
 
   c->last_reply = cd;
-  va_start(args, msg);
   cnt = bvsnprintf(buf+size, sizeof(buf)-size-1, msg, args);
-  va_end(args);
   if (cnt < 0)
     {
       cli_printf(c, errcode, "<line overflow>");
index e48216c2efeb9bb9e7a9430f3c0e5a84e81ba97e..423b2180315a132559720ebefd92b204b1b7bf63 100644 (file)
@@ -75,7 +75,15 @@ extern struct cli *this_cli;         /* Used during parsing */
 
 /* Functions to be called by command handlers */
 
-void cli_printf(cli *, int, char *, ...);
+void cli_vprintf(cli *, int, const char *, va_list);
+static inline void cli_printf(cli *cli, int code, const char *fmt, ...)
+{
+  va_list args;
+  va_start(args, fmt);
+  cli_vprintf(cli, code, fmt, args);
+  va_end(args);
+}
+
 #define cli_msg(x...) cli_printf(this_cli, x)
 void cli_set_log_echo(cli *, uint mask, uint size);
 void cli_set_timeformat(cli *c, const struct timeformat tf);