Commit 6515f17e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add an optional argument to the debug.argtest function

parent f279df55
...@@ -24,6 +24,7 @@ varnish v1 -vcl+backend { ...@@ -24,6 +24,7 @@ varnish v1 -vcl+backend {
set resp.http.foo4 = debug.argtest("1", 2.4, three="3d", four=-1); set resp.http.foo4 = debug.argtest("1", 2.4, three="3d", four=-1);
set resp.http.foo5 = debug.argtest("1", 2.5); set resp.http.foo5 = debug.argtest("1", 2.5);
set resp.http.foo6 = debug.argtest("1", four=6); set resp.http.foo6 = debug.argtest("1", four=6);
set resp.http.foo7 = debug.argtest("1", opt="7");
set resp.http.obj0 = obj0.string() + ", " + obj0.number(); set resp.http.obj0 = obj0.string() + ", " + obj0.number();
set resp.http.obj1 = obj1.string() + ", " + obj1.number(); set resp.http.obj1 = obj1.string() + ", " + obj1.number();
...@@ -38,12 +39,13 @@ client c1 { ...@@ -38,12 +39,13 @@ client c1 {
txreq txreq
rxresp rxresp
expect resp.bodylen == "6" expect resp.bodylen == "6"
expect resp.http.foo1 == "1 2.1 3a , 4" expect resp.http.foo1 == "1 2.1 3a , 4 0 <undef>"
expect resp.http.foo2 == "1 -2.2 3b , 4" expect resp.http.foo2 == "1 -2.2 3b , 4 0 <undef>"
expect resp.http.foo3 == "1 2.3 3c , 4" expect resp.http.foo3 == "1 2.3 3c , 4 0 <undef>"
expect resp.http.foo4 == "1 2.4 3d , -1" expect resp.http.foo4 == "1 2.4 3d , -1 0 <undef>"
expect resp.http.foo5 == "1 2.5 3 , 4" expect resp.http.foo5 == "1 2.5 3 , 4 0 <undef>"
expect resp.http.foo6 == "1 2 3 , 6" expect resp.http.foo6 == "1 2 3 , 6 0 <undef>"
expect resp.http.foo7 == "1 2 3 , 4 1 7"
expect resp.http.obj0 == "default, one" expect resp.http.obj0 == "default, one"
expect resp.http.obj1 == "only_argument, one" expect resp.http.obj1 == "only_argument, one"
......
...@@ -117,7 +117,9 @@ Encrypt the HTTP header with quad-ROT13 encryption, ...@@ -117,7 +117,9 @@ Encrypt the HTTP header with quad-ROT13 encryption,
$Function STRING argtest( $Function STRING argtest(
STRING one, REAL two =2, STRING three= "3", STRING one, REAL two =2, STRING three= "3",
STRING comma="," , INT four = 4 ) STRING comma=",", INT four = 4,
[ STRING opt]
)
$Function INT vre_limit() $Function INT vre_limit()
......
...@@ -151,12 +151,14 @@ xyzzy_rot52(VRT_CTX, VCL_HTTP hp) ...@@ -151,12 +151,14 @@ xyzzy_rot52(VRT_CTX, VCL_HTTP hp)
} }
VCL_STRING v_matchproto_(td_debug_argtest) VCL_STRING v_matchproto_(td_debug_argtest)
xyzzy_argtest(VRT_CTX, VCL_STRING one, VCL_REAL two, VCL_STRING three, xyzzy_argtest(VRT_CTX, struct xyzzy_argtest_arg *arg)
VCL_STRING comma, VCL_INT four)
{ {
char buf[100]; char buf[100];
bprintf(buf, "%s %g %s %s %ld", one, two, three, comma, four); AN(arg);
bprintf(buf, "%s %g %s %s %ld %d %s",
arg->one, arg->two, arg->three, arg->comma, arg->four,
arg->valid_opt, arg->valid_opt ? arg->opt : "<undef>");
return (WS_Copy(ctx->ws, buf, -1)); return (WS_Copy(ctx->ws, buf, -1));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment