Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-tus
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-tus
Commits
12ada84b
Unverified
Commit
12ada84b
authored
Nov 09, 2022
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use varnishd to extract vmod declarations
parent
0bc8866b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
Makefile.am
src/Makefile.am
+2
-0
vmod_get_h.c
src/vmod_get_h.c
+23
-2
No files found.
src/Makefile.am
View file @
12ada84b
...
...
@@ -25,9 +25,11 @@ TESTS = \
if
CHKSUM
import_vmod_blob.h
:
vmod_get_h $(VMOD_BLOB)
PATH
=
"
$(VARNISH_TEST_PATH)
:
$(PATH)
"
\
$(builddir)
/vmod_get_h blob
$(VMOD_BLOB)
>
$@
.tmp
mv
-f
$@
.tmp
$@
import_vmod_blobdigest.h
:
vmod_get_h $(VMOD_BLOBDIGEST)
PATH
=
"
$(VARNISH_TEST_PATH)
:
$(PATH)
"
\
$(builddir)
/vmod_get_h blobdigest
$(VMOD_BLOBDIGEST)
>
$@
.tmp
mv
-f
$@
.tmp
$@
libvmod_tus_la_SOURCES
=
tus_blob.c
...
...
src/vmod_get_h.c
View file @
12ada84b
...
...
@@ -32,6 +32,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include "vdef.h"
#include "vrt.h"
...
...
@@ -45,10 +47,11 @@ const struct vrt_blob *vrt_null_blob = &(struct vrt_blob){
int
main
(
int
argc
,
char
**
argv
)
{
void
*
dlhdl
;
char
buf
[
256
];
char
buf
[
256
]
,
vcl
[
64
]
;
const
struct
vmod_data
*
d
;
const
char
*
name
;
const
char
*
file
;
int
i
,
fd
;
if
(
argc
<
3
)
{
fprintf
(
stderr
,
"need 2 arguments
\n
"
);
...
...
@@ -58,6 +61,25 @@ main(int argc, char **argv) {
name
=
argv
[
1
];
file
=
argv
[
2
];
bprintf
(
buf
,
"vcl 4.1;backend none none;import %s from
\"
%s
\"
;
\n
"
,
name
,
file
);
bprintf
(
vcl
,
"/tmp/vmod_get_h_%s_XXXXXX"
,
name
);
fd
=
mkstemp
(
vcl
);
assert
(
fd
>=
0
);
i
=
write
(
fd
,
buf
,
strlen
(
buf
));
assert
(
i
>
0
);
i
=
close
(
fd
);
assert
(
i
==
0
);
bprintf
(
buf
,
"varnishd -Cf %s 2>&1 | awk '"
"/BEGIN VMOD %s/ {p=1} "
"/END VMOD %s/ {exit} "
"/./ {if (p == 1) { print }; n;}"
"'"
,
vcl
,
name
,
name
);
printf
(
"/* %s */
\n
"
,
buf
);
i
=
system
(
buf
);
assert
(
i
==
0
);
dlhdl
=
dlopen
(
file
,
RTLD_LAZY
|
RTLD_LOCAL
);
if
(
dlhdl
==
NULL
)
{
...
...
@@ -71,7 +93,6 @@ main(int argc, char **argv) {
return
(
1
);
}
printf
(
"%s"
,
d
->
proto
);
printf
(
"
\n
static const struct vmod_data import_%s = {
\n
"
,
buf
);
printf
(
"
\t
.name =
\t\t\"
%s
\"
,
\n
"
,
d
->
name
);
printf
(
"
\t
.file_id =
\t\"
%s
\"
,
\n
"
,
d
->
file_id
);
...
...
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