[master] 16658213c vte: Finish collecting and measuring lines
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Aug 21 20:52:07 UTC 2023
commit 16658213c39c56f5428b58499ec1251f97c730d9
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Thu Aug 17 12:13:51 2023 +0200
vte: Finish collecting and measuring lines
diff --git a/include/vte.h b/include/vte.h
index 2573c030e..7a97cadee 100644
--- a/include/vte.h
+++ b/include/vte.h
@@ -33,4 +33,5 @@ struct vte *VTE_new(int maxfields, int width);
int VTE_putc(struct vte *, char);
int VTE_cat(struct vte *, const char *);
int VTE_printf(struct vte *, const char *, ...) v_printflike_(2, 3);
+int VTE_finish(struct vte *);
void VTE_destroy(struct vte **);
diff --git a/lib/libvarnish/vte.c b/lib/libvarnish/vte.c
index b7ec41cab..2a21d1e06 100644
--- a/lib/libvarnish/vte.c
+++ b/lib/libvarnish/vte.c
@@ -32,6 +32,7 @@
#include "config.h"
#include <errno.h>
+#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
@@ -205,6 +206,29 @@ VTE_printf(struct vte *vte, const char *fmt, ...)
return (vte_update(vte));
}
+int
+VTE_finish(struct vte *vte)
+{
+
+ CHECK_OBJ_NOTNULL(vte, VTE_MAGIC);
+
+ if (vte->o_sep != 0)
+ return (-1);
+
+ if (VSB_finish(vte->vsb) < 0) {
+ vte->o_sep = -1;
+ return (-1);
+ }
+
+ if (vte->f_cnt == 0) {
+ vte->o_sep = INT_MAX;
+ return (0);
+ }
+
+ vte->o_sep = (vte->o_sz - vte->l_maxsz) / vte->f_cnt;
+ return (0);
+}
+
void
VCLI_VTE(struct cli *cli, struct vsb **src, int width)
{
More information about the varnish-commit
mailing list