Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-re2
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-re2
Commits
04b3e9e0
Commit
04b3e9e0
authored
Apr 22, 2021
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the .check_call() method.
parent
7edfb217
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
385 additions
and
0 deletions
+385
-0
README.md
README.md
+9
-0
set.c
src/set.c
+75
-0
subroutine.vtc
src/tests/subroutine.vtc
+294
-0
vmod_re2.h
src/vmod_re2.h
+3
-0
vmod_re2.vcc
src/vmod_re2.vcc
+4
-0
No files found.
README.md
View file @
04b3e9e0
...
...
@@ -1533,6 +1533,15 @@ Example:
XXX ...
#### BOOL xset.check\_call(INT n, ENUM select)
BOOL xset.check_call(
INT n=0,
ENUM {FIRST, LAST, UNIQUE} select=UNIQUE
)
XXX ...
#### BOOL xset.saved(ENUM which, INT n, ENUM select)
BOOL xset.saved(
...
...
src/set.c
View file @
04b3e9e0
...
...
@@ -782,6 +782,81 @@ vmod_set_subroutine(VRT_CTX, struct VPFX(re2_set) *set, VCL_INT n,
return
set
->
sub
[
idx
];
}
VCL_BOOL
vmod_set_check_call
(
VRT_CTX
,
struct
VPFX
(
re2_set
)
*
set
,
VCL_INT
n
,
VCL_ENUM
selects
)
{
struct
task_set_match
*
task
;
int
idx
=
0
;
VCL_STRING
err
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
set
,
VMOD_RE2_SET_MAGIC
);
if
(
set
->
sub
==
NULL
)
{
VNOTICE
(
ctx
,
"%s.check_call(%jd): No subroutines were set for %s"
,
set
->
vcl_name
,
(
intmax_t
)
n
,
set
->
vcl_name
);
return
(
0
);
}
/*
* XXX: considerable DRY with get_match_idx().
* get_match_idx() invokes VRT_fail(), but we need to log
* SLT_Notice here, and the two alternatives are hard to
* disentangle within get_match_idx(). An alternative would be to
* pass in a flag to get_match_idx() that chooses between the two,
* and then we have to add the flag everywhere else. Consider
* that if we add anything else that needs SLT_Notice.
*/
if
(
n
>
set
->
npatterns
)
{
VNOTICE
(
ctx
,
"%s.check_call(%jd): set has %d patterns"
,
set
->
vcl_name
,
(
intmax_t
)
n
,
set
->
npatterns
);
return
(
0
);
}
if
(
n
<=
0
)
{
if
((
task
=
get_task_data
(
ctx
,
set
))
==
NULL
)
{
VNOTICE
(
ctx
,
"%s.check_call() called without prior match"
,
set
->
vcl_name
);
return
(
0
);
}
if
(
task
->
nmatches
==
0
)
{
VNOTICE
(
ctx
,
"%s.check_call(%jd): previous match was "
"unsuccessful"
,
set
->
vcl_name
,
(
intmax_t
)
n
);
return
(
0
);
}
if
(
task
->
nmatches
>
1
)
{
if
(
selects
==
VENUM
(
UNIQUE
))
{
VNOTICE
(
ctx
,
"%s.check_call(%jd): %ld "
"successful matches"
,
set
->
vcl_name
,
(
intmax_t
)
n
,
task
->
nmatches
);
return
(
0
);
}
if
(
selects
==
VENUM
(
LAST
))
idx
=
task
->
nmatches
-
1
;
else
assert
(
selects
==
VENUM
(
FIRST
));
}
WS_Assert_Allocated
(
ctx
->
ws
,
task
->
matches
,
task
->
nmatches
*
sizeof
(
int
));
idx
=
task
->
matches
[
idx
];
}
if
(
!
vbit_test
(
set
->
added
[
SUBROUTINE
],
idx
))
{
AN
(
selects
);
VNOTICE
(
ctx
,
"%s.check_call(%jd, %s): subroutine %d was not added"
,
set
->
vcl_name
,
n
,
selects
,
idx
+
1
);
return
(
0
);
}
if
((
err
=
VRT_check_call
(
ctx
,
set
->
sub
[
idx
]))
!=
NULL
)
{
VNOTICE
(
ctx
,
"%s.check_call(): %s"
,
set
->
vcl_name
,
err
);
return
(
0
);
}
return
(
1
);
}
VCL_BOOL
vmod_set_saved
(
VRT_CTX
,
struct
vmod_re2_set
*
set
,
VCL_ENUM
whichs
,
VCL_INT
n
,
VCL_ENUM
selects
)
...
...
src/tests/subroutine.vtc
View file @
04b3e9e0
This diff is collapsed.
Click to expand it.
src/vmod_re2.h
View file @
04b3e9e0
...
...
@@ -47,6 +47,9 @@
#define VERRNOMEM(ctx, fmt, ...) \
VFAIL((ctx), fmt ", out of space", __VA_ARGS__)
#define VNOTICE(ctx, fmt, ...) \
VSLb((ctx)->vsl, SLT_Notice, "vmod_re2: " fmt, __VA_ARGS__)
struct
vmod_re2_regex
{
unsigned
magic
;
#define VMOD_RE2_REGEX_MAGIC 0x5c3f6f24
...
...
src/vmod_re2.vcc
View file @
04b3e9e0
...
...
@@ -1401,6 +1401,10 @@ $Method SUB .subroutine(INT n=0, ENUM {FIRST, LAST, UNIQUE} select=UNIQUE)
XXX ...
$Method BOOL .check_call(INT n=0, ENUM {FIRST, LAST, UNIQUE} select=UNIQUE)
XXX ...
$Method BOOL .saved(ENUM {REGEX, STR, BE, INT, SUB} which=REGEX, INT n=0,
ENUM {FIRST, LAST, UNIQUE} select=UNIQUE)
...
...
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