This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgNeels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/12773 Change subject: vty api: add vty_out_va() ...................................................................... vty api: add vty_out_va() Provide a va_list type vty_out() variant, to be able to pass on variable arguments from other function signatures to vty_out(). This will be used by Ibd6b1ed7f1bd6e1f2e0fde53352055a4468f23e5 for osmo_tdef. Change-Id: Ie6e6f11a6b794f3cb686350c1ed678e4d5bbbb75 --- M include/osmocom/vty/vty.h M src/vty/vty.c 2 files changed, 20 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/73/12773/1 diff --git a/include/osmocom/vty/vty.h b/include/osmocom/vty/vty.h index c4cf707..8d2e1b3 100644 --- a/include/osmocom/vty/vty.h +++ b/include/osmocom/vty/vty.h @@ -193,6 +193,7 @@ struct vty *vty_new (void); struct vty *vty_create (int vty_sock, void *priv); int vty_out (struct vty *, const char *, ...) VTY_PRINTF_ATTRIBUTE(2, 3); +int vty_out_va(struct vty *vty, const char *format, va_list ap); int vty_out_newline(struct vty *); int vty_read(struct vty *vty); //void vty_time_print (struct vty *, int); diff --git a/src/vty/vty.c b/src/vty/vty.c index 8c89197..98b332d 100644 --- a/src/vty/vty.c +++ b/src/vty/vty.c @@ -249,26 +249,19 @@ 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 @@ 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 @@ 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) { -- To view, visit https://gerrit.osmocom.org/12773 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: newchange Gerrit-Change-Id: Ie6e6f11a6b794f3cb686350c1ed678e4d5bbbb75 Gerrit-Change-Number: 12773 Gerrit-PatchSet: 1 Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190201/73aa7e74/attachment.htm>