]> err.no Git - varnish/commitdiff
Add VLU_Data() function for injecting input
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 13 Feb 2009 09:38:57 +0000 (09:38 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 13 Feb 2009 09:38:57 +0000 (09:38 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3760 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/include/vlu.h
varnish-cache/lib/libvarnish/vlu.c

index e7da9973b1d76aa39f3f3189e7653ae654468021..3dd7eeab47e331bf5253a3b51c3d61d2c895037d 100644 (file)
@@ -36,6 +36,7 @@ typedef int (vlu_f)(void *, const char *);
 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
index f463546bae99d9e2520558e3ae885f1dbba0e4f8..c728749dce4435fc2cfc5501ddfe3e3edc3ae03e 100644 (file)
@@ -134,3 +134,28 @@ VLU_File(FILE *f, struct vlu *l)
        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);
+}