]> err.no Git - varnish/commitdiff
Add -vcl option varnish command, to load inline VCL code.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 17 Jun 2008 07:30:16 +0000 (07:30 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 17 Jun 2008 07:30:16 +0000 (07:30 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2714 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishtest/vtc_varnish.c

index ffa438faf50143835882e5e078a871de1ee25c5f..3977f15ac5df4647b221695a33439e0383731100 100644 (file)
@@ -250,11 +250,21 @@ varnish_vcl(struct varnish *v, char *vcl)
 
        v->vcl_nbr++;
        vsb_printf(vsb, "vcl.inline vcl%d \"", v->vcl_nbr);
-       for (; *vcl != '\0'; vcl++) {
-               if (isgraph(*vcl) || *vcl == '\\' || *vcl == '"')
-                       vsb_putc(vsb, *vcl);
-               else
-                       vsb_printf(vsb, "\\x%02x", *vcl);
+       for (vcl++; vcl[1] != '\0'; vcl++) {
+               switch (*vcl) {
+               case '\\':
+               case '"':
+                       vsb_printf(vsb, "\\%c", *vcl); break;
+               case '\n':
+                       vsb_printf(vsb, "\\n"); break;
+               case '\t':
+                       vsb_printf(vsb, "\\t"); break;
+               default:
+                       if (isgraph(*vcl) || *vcl == ' ')
+                               vsb_putc(vsb, *vcl);
+                       else
+                               vsb_printf(vsb, "\\x%02x", *vcl);
+               }
        }
        vsb_printf(vsb, "\"", *vcl);
        vsb_finish(vsb);
@@ -263,7 +273,7 @@ varnish_vcl(struct varnish *v, char *vcl)
        u = varnish_ask_cli(v, vsb_data(vsb), NULL);
        assert(u == CLIS_OK);
        vsb_clear(vsb);
-       vsb_printf(vsb, "vcl.use vcl%d \"", v->vcl_nbr);
+       vsb_printf(vsb, "vcl.use vcl%d", v->vcl_nbr);
        vsb_finish(vsb);
        AZ(vsb_overflowed(vsb));
        u = varnish_ask_cli(v, vsb_data(vsb), NULL);