[master] a1104edc9 vte: Add a VTE_putc() convenience

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Aug 21 20:52:06 UTC 2023


commit a1104edc95c76750a3b1ad7594ff0c7aadff156f
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu Aug 17 12:04:47 2023 +0200

    vte: Add a VTE_putc() convenience

diff --git a/include/vte.h b/include/vte.h
index 438321611..2573c030e 100644
--- a/include/vte.h
+++ b/include/vte.h
@@ -30,6 +30,7 @@
 struct vte;
 
 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);
 void VTE_destroy(struct vte **);
diff --git a/lib/libvarnish/vte.c b/lib/libvarnish/vte.c
index 8529c05fe..b7ec41cab 100644
--- a/lib/libvarnish/vte.c
+++ b/lib/libvarnish/vte.c
@@ -145,6 +145,24 @@ vte_update(struct vte *vte)
 	return (0);
 }
 
+int
+VTE_putc(struct vte *vte, char c)
+{
+
+	CHECK_OBJ_NOTNULL(vte, VTE_MAGIC);
+	AN(c);
+
+	if (vte->o_sep != 0)
+		return (-1);
+
+	if (VSB_putc(vte->vsb, c) < 0) {
+		vte->o_sep = -1;
+		return (-1);
+	}
+
+	return (vte_update(vte));
+}
+
 int
 VTE_cat(struct vte *vte, const char *s)
 {


More information about the varnish-commit mailing list