Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
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
varnish-cache
Commits
2feafdcf
Commit
2feafdcf
authored
Jun 20, 2022
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the VMOD C-prototypes into the JSON data.
parent
2a7ea235
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
18 deletions
+46
-18
cache_vrt_vmod.c
bin/varnishd/cache/cache_vrt_vmod.c
+1
-1
vrt.h
include/vrt.h
+1
-0
vcc_vmod.c
lib/libvcc/vcc_vmod.c
+34
-2
vmodtool.py
lib/libvcc/vmodtool.py
+8
-13
vmod_debug.c
vmod/vmod_debug.c
+2
-2
No files found.
bin/varnishd/cache/cache_vrt_vmod.c
View file @
2feafdcf
...
...
@@ -132,7 +132,7 @@ VPI_Vmod_Init(VRT_CTX, struct vmod **hdl, unsigned nbr, void *ptr, int len,
strcmp
(
d
->
name
,
nm
)
||
d
->
func
==
NULL
||
d
->
func_len
<=
0
||
d
->
proto
=
=
NULL
||
d
->
proto
!
=
NULL
||
d
->
json
==
NULL
)
{
VSB_printf
(
ctx
->
msg
,
"Loading vmod %s from %s (%s):
\n
"
,
nm
,
backup
,
path
);
...
...
include/vrt.h
View file @
2feafdcf
...
...
@@ -58,6 +58,7 @@
* binary/load-time compatible, increment MAJOR version
*
* NEXT (2022-09-15)
* C-prototypes moved into JSON
* VRT_AddVDP() deprecated
* VRT_AddVFP() deprecated
* VRT_RemoveVDP() deprecated
...
...
lib/libvcc/vcc_vmod.c
View file @
2feafdcf
...
...
@@ -164,6 +164,7 @@ vcc_json_always(struct vcc *tl, const struct vjsn *vj, const char *vmod_name)
struct
inifin
*
ifp
;
const
struct
vjsn_val
*
vv
,
*
vv2
;
double
vmod_syntax
=
0
.
0
;
int
cproto_seen
=
0
;
AN
(
vj
);
AN
(
vmod_name
);
...
...
@@ -197,6 +198,8 @@ vcc_json_always(struct vcc *tl, const struct vjsn *vj, const char *vmod_name)
}
else
if
(
!
strcmp
(
vv2
->
value
,
"$ALIAS"
))
{
}
else
if
(
!
strcmp
(
vv2
->
value
,
"$FUNC"
))
{
}
else
if
(
!
strcmp
(
vv2
->
value
,
"$OBJ"
))
{
}
else
if
(
!
strcmp
(
vv2
->
value
,
"$CPROTO"
))
{
cproto_seen
=
1
;
}
else
{
VTAILQ_FOREACH
(
vv2
,
&
vv
->
children
,
list
)
fprintf
(
stderr
,
"
\t
t %s n %s v %s
\n
"
,
...
...
@@ -204,6 +207,8 @@ vcc_json_always(struct vcc *tl, const struct vjsn *vj, const char *vmod_name)
WRONG
(
"Vmod JSON syntax error"
);
}
}
if
(
!
cproto_seen
)
WRONG
(
"Vmod JSON has no CPROTO"
);
}
static
const
struct
vmod_data
*
...
...
@@ -244,7 +249,8 @@ vcc_VmodSanity(struct vcc *tl, void *hdl, const struct token *mod, char *fnp)
if
(
vmd
->
name
==
NULL
||
vmd
->
func
==
NULL
||
vmd
->
func_len
<=
0
||
vmd
->
proto
==
NULL
||
vmd
->
json
==
NULL
||
vmd
->
proto
!=
NULL
||
vmd
->
abi
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"Mangled VMOD %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fnp
);
...
...
@@ -335,6 +341,32 @@ vcc_VmodSymbols(struct vcc *tl, const struct symbol *sym)
}
}
static
void
vcc_emit_c_prototypes
(
const
struct
vcc
*
tl
,
const
struct
vjsn
*
vj
)
{
const
struct
vjsn_val
*
vv
,
*
vv2
,
*
vv3
;
Fh
(
tl
,
0
,
"
\n
"
);
vv
=
vj
->
value
;
assert
(
vjsn_is_array
(
vv
));
vv3
=
NULL
;
VTAILQ_FOREACH
(
vv2
,
&
vv
->
children
,
list
)
{
assert
(
vjsn_is_array
(
vv2
));
vv3
=
VTAILQ_FIRST
(
&
vv2
->
children
);
assert
(
vjsn_is_string
(
vv3
));
if
(
!
strcmp
(
vv3
->
value
,
"$CPROTO"
))
break
;
}
assert
(
vv3
!=
NULL
);
while
(
1
)
{
vv3
=
VTAILQ_NEXT
(
vv3
,
list
);
if
(
vv3
==
NULL
)
break
;
assert
(
vjsn_is_string
(
vv3
));
Fh
(
tl
,
0
,
"%s
\n
"
,
vv3
->
value
);
}
}
void
vcc_ParseImport
(
struct
vcc
*
tl
)
{
...
...
@@ -493,7 +525,7 @@ vcc_ParseImport(struct vcc *tl)
Fh
(
tl
,
0
,
"
\n
/* --- BEGIN VMOD %.*s --- */
\n\n
"
,
PF
(
mod
));
Fh
(
tl
,
0
,
"static struct vmod *VGC_vmod_%.*s;
\n
"
,
PF
(
mod
));
Fh
(
tl
,
0
,
"static struct vmod_priv vmod_priv_%.*s;
\n
"
,
PF
(
mod
));
Fh
(
tl
,
0
,
"
\n
%s
\n
"
,
vmd
->
proto
);
vcc_emit_c_prototypes
(
tl
,
vj
);
Fh
(
tl
,
0
,
"
\n
/* --- END VMOD %.*s --- */
\n\n
"
,
PF
(
mod
));
free
(
fnpx
);
}
...
...
lib/libvcc/vmodtool.py
View file @
2feafdcf
...
...
@@ -1084,24 +1084,22 @@ class vcc(object):
fmt_cstruct
(
fo
,
'.enum_
%
s ='
%
j
,
'&VENUM(
%
s),'
%
j
)
fo
.
write
(
"};
\n
"
)
def
vmod_proto
(
self
,
fo
,
fnx
):
fo
.
write
(
"
\n
static const char Vmod_Proto[] =
\n
"
)
for
i
in
open
(
fnx
):
fo
.
write
(
'
\t
"
%
s
\\
n"
\n
'
%
i
.
rstrip
())
fo
.
write
(
'
\t
"static struct
%
s
%
s;";
\n
'
%
(
self
.
csn
,
self
.
csn
))
def
iter_json
(
self
):
def
iter_json
(
self
,
fnx
):
jl
=
[[
"$VMOD"
,
"1.0"
]]
jl
.
append
([
"$CPROTO"
])
for
i
in
open
(
fnx
):
jl
[
-
1
]
.
append
(
i
.
rstrip
())
jl
[
-
1
]
.
append
(
"static struct
%
s
%
s;"
%
(
self
.
csn
,
self
.
csn
))
for
j
in
self
.
contents
:
j
.
json
(
jl
)
for
i
in
json
.
dumps
(
jl
,
indent
=
2
,
separators
=
(
","
,
": "
))
.
splitlines
():
yield
i
+
" "
def
json
(
self
,
fo
):
def
json
(
self
,
fo
,
fnx
):
fo
.
write
(
"
\n
static const char Vmod_Json[] = {
\n
"
)
for
i
in
self
.
iter_json
():
for
i
in
self
.
iter_json
(
fnx
):
fo
.
write
(
'
\t
"'
)
for
j
in
i
:
if
j
in
'"
\\
'
:
...
...
@@ -1127,7 +1125,6 @@ class vcc(object):
fo
.
write
(
'
\t
.func =
\t\t
&
%
s,
\n
'
%
self
.
csn
)
fo
.
write
(
'
\t
.func_len =
\t
sizeof(
%
s),
\n
'
%
self
.
csn
)
fo
.
write
(
'
\t
.func_name =
\t
"
%
s",
\n
'
%
self
.
csn
)
fo
.
write
(
'
\t
.proto =
\t
Vmod_Proto,
\n
'
)
fo
.
write
(
'
\t
.json =
\t\t
Vmod_Json,
\n
'
)
fo
.
write
(
'
\t
.abi =
\t\t
VMOD_ABI_Version,
\n
'
)
fo
.
write
(
"
\t
.file_id =
\t\"
%
s
\"
,
\n
"
%
self
.
file_id
)
...
...
@@ -1176,9 +1173,7 @@ class vcc(object):
fx
.
close
()
self
.
vmod_proto
(
fo
,
fnx
)
self
.
json
(
fo
)
self
.
json
(
fo
,
fnx
)
self
.
vmod_data
(
fo
)
...
...
vmod/vmod_debug.c
View file @
2feafdcf
...
...
@@ -1087,7 +1087,7 @@ const struct vmod_data Vmod_wrong2_Data = {
.
func
=
foo_struct
,
.
func_len
=
sizeof
foo_struct
,
.
func_name
=
"foo_struct"
,
.
proto
=
"blablabla"
,
.
json
=
"blablabla"
,
};
extern
const
struct
vmod_data
Vmod_wrong3_Data
;
...
...
@@ -1098,7 +1098,7 @@ const struct vmod_data Vmod_wrong3_Data = {
.
func
=
foo_struct
,
.
func_len
=
sizeof
foo_struct
,
.
func_name
=
"foo_struct"
,
.
proto
=
"blablabla"
,
.
json
=
"blablabla"
,
.
abi
=
"abiblabla"
,
};
...
...
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