Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-example
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
libvmod-example
Commits
ce3f10b6
Commit
ce3f10b6
authored
May 25, 2011
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite the example to be a hello world vmod
parent
6506b603
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
6 deletions
+20
-6
test01.vtc
src/tests/test01.vtc
+2
-2
vmod_example.c
src/vmod_example.c
+17
-3
vmod_example.vcc
src/vmod_example.vcc
+1
-1
No files found.
src/tests/test01.vtc
View file @
ce3f10b6
...
...
@@ -9,14 +9,14 @@ varnish v1 -vcl+backend {
import example from "${vmod_topbuild}/src/.libs/libvmod_example.so";
sub vcl_deliver {
set resp.http.
val = example.abs(2-3
);
set resp.http.
hello = example.hello("World!"
);
}
} -start
client c1 {
txreq -url "/"
rxresp
expect resp.http.
val == "1
"
expect resp.http.
hello == "Hello, World!
"
}
client c1 -run
src/vmod_example.c
View file @
ce3f10b6
...
...
@@ -11,8 +11,22 @@ init_function(struct vmod_priv *priv, const struct VCL_conf *conf)
return
(
0
);
}
int
vmod_
abs
(
struct
sess
*
sp
,
int
val
)
const
char
*
vmod_
hello
(
struct
sess
*
sp
,
const
char
*
name
)
{
return
(
abs
(
val
));
char
*
p
;
unsigned
u
,
v
;
u
=
WS_Reserve
(
sp
->
wrk
->
ws
,
0
);
/* Reserve some work space */
p
=
sp
->
wrk
->
ws
->
f
;
/* Front of workspace area */
v
=
snprintf
(
p
,
u
,
"Hello, %s"
,
name
);
v
++
;
if
(
v
>
u
)
{
/* No space, reset and leave */
WS_Release
(
sp
->
wrk
->
ws
,
0
);
return
(
NULL
);
}
/* Update work space with what we've used */
WS_Release
(
sp
->
wrk
->
ws
,
v
);
return
(
p
);
}
src/vmod_example.vcc
View file @
ce3f10b6
Module example
Init init_function
Function
INT abs(INT
)
Function
STRING hello(STRING
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment