[master] ae65ef430 vte: New VTE_dump() utility

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue May 7 13:31:05 UTC 2024


commit ae65ef43095226f6b0ed47fecbcade2e3054878b
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue May 7 12:07:31 2024 +0200

    vte: New VTE_dump() utility

diff --git a/include/vte.h b/include/vte.h
index fcd13fb2b..28e26871e 100644
--- a/include/vte.h
+++ b/include/vte.h
@@ -47,4 +47,5 @@ int VTE_cat(struct vte *, const char *);
 int VTE_printf(struct vte *, const char *, ...) v_printflike_(2, 3);
 int VTE_finish(struct vte *);
 int VTE_format(const struct vte *, VTE_format_f *func, void *priv);
+int VTE_dump(const struct vte *, VTE_format_f *func, void *priv);
 void VTE_destroy(struct vte **);
diff --git a/lib/libvarnish/vte.c b/lib/libvarnish/vte.c
index db15bd94d..cad557b67 100644
--- a/lib/libvarnish/vte.c
+++ b/lib/libvarnish/vte.c
@@ -239,6 +239,23 @@ VTE_finish(struct vte *vte)
 			return (-1);			\
 	} while (0)
 
+int
+VTE_dump(const struct vte *vte, VTE_format_f *func, void *priv)
+{
+	const char *p;
+
+	CHECK_OBJ_NOTNULL(vte, VTE_MAGIC);
+	AN(func);
+
+	if (vte->o_sep <= 0)
+		return (-1);
+
+	p = VSB_data(vte->vsb);
+	AN(p);
+	VTE_FORMAT(func, priv, "%s", p);
+	return (0);
+}
+
 int
 VTE_format(const struct vte *vte, VTE_format_f *func, void *priv)
 {


More information about the varnish-commit mailing list