r3760 - in trunk/varnish-cache: include lib/libvarnish

phk at projects.linpro.no phk at projects.linpro.no
Fri Feb 13 10:38:58 CET 2009


Author: phk
Date: 2009-02-13 10:38:57 +0100 (Fri, 13 Feb 2009)
New Revision: 3760

Modified:
   trunk/varnish-cache/include/vlu.h
   trunk/varnish-cache/lib/libvarnish/vlu.c
Log:
Add VLU_Data() function for injecting input



Modified: trunk/varnish-cache/include/vlu.h
===================================================================
--- trunk/varnish-cache/include/vlu.h	2009-02-13 09:25:33 UTC (rev 3759)
+++ trunk/varnish-cache/include/vlu.h	2009-02-13 09:38:57 UTC (rev 3760)
@@ -36,6 +36,7 @@
 struct vlu *VLU_New(void *priv, vlu_f *func, unsigned bufsize);
 int VLU_Fd(int fd, struct vlu *l);
 int VLU_File(FILE *f, struct vlu *l);
+int VLU_Data(const void *ptr, int len, struct vlu *l);
 void VLU_Destroy(struct vlu *l);
 
 #endif

Modified: trunk/varnish-cache/lib/libvarnish/vlu.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/vlu.c	2009-02-13 09:25:33 UTC (rev 3759)
+++ trunk/varnish-cache/lib/libvarnish/vlu.c	2009-02-13 09:38:57 UTC (rev 3760)
@@ -134,3 +134,28 @@
 	l->bufp = strlen(l->buf);
 	return (LineUpProcess(l));
 }
+
+int
+VLU_Data(const void *ptr, int len, struct vlu *l)
+{
+	const char *p;
+	int i;
+
+	p = ptr;
+	CHECK_OBJ_NOTNULL(l, LINEUP_MAGIC);
+	if (len < 0)
+		len = strlen(p);
+	while (len > 0) {
+		i = len;
+		if (i > l->bufl - l->bufp)
+			i = l->bufl - l->bufp;
+		memcpy(l->buf + l->bufp, p, i);
+		l->bufp += i;
+		p += i;
+		len -= i;
+		i = LineUpProcess(l);
+		if (i)
+			break;
+	}
+	return (i);
+}



More information about the varnish-commit mailing list