Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-selector
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-selector
Commits
d6d30486
Commit
d6d30486
authored
Feb 21, 2021
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the .subroutine() method.
parent
5cea4e6d
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
677 additions
and
6 deletions
+677
-6
README.rst
README.rst
+19
-3
associate.c
src/associate.c
+18
-0
subroutine.vtc
src/tests/subroutine.vtc
+625
-0
vmod_selector.c
src/vmod_selector.c
+5
-1
vmod_selector.h
src/vmod_selector.h
+3
-1
vmod_selector.vcc
src/vmod_selector.vcc
+7
-1
No files found.
README.rst
View file @
d6d30486
...
...
@@ -438,8 +438,8 @@ Examples::
.. _xset.add():
VOID xset.add(STRING, [STRING string], [STRING regex], [BACKEND backend], [INT integer], [BOOL bool])
-----------------------------------------------------------------------------------------------------
VOID xset.add(STRING, [STRING string], [STRING regex], [BACKEND backend], [INT integer], [BOOL bool]
, [SUB sub]
)
-----------------------------------------------------------------------------------------------------
-----------
::
...
...
@@ -449,7 +449,8 @@ VOID xset.add(STRING, [STRING string], [STRING regex], [BACKEND backend], [INT i
[STRING regex],
[BACKEND backend],
[INT integer],
[BOOL bool]
[BOOL bool],
[SUB sub]
)
Add the given string to the set. As indicated above, elements added to
...
...
@@ -1056,6 +1057,21 @@ Example::
# /foo/bar/1/2/* is rewritten as /foo/bar/2/1/*
# /foo/bar/baz/1/2/* is rewritten as /foo/bar/baz/2/1/*
.. _xset.subroutine():
SUB xset.subroutine(INT n, STRING element, ENUM select)
-------------------------------------------------------
::
SUB xset.subroutine(
INT n=0,
STRING element=0,
ENUM {UNIQUE, EXACT, FIRST, LAST, SHORTEST, LONGEST} select=UNIQUE
)
XXX ...
.. _selector.version():
STRING version()
...
...
src/associate.c
View file @
d6d30486
...
...
@@ -273,3 +273,21 @@ vmod_set_bool(VRT_CTX, struct VPFX(selector_set) *set, VCL_INT n,
return
(
set
->
table
[
idx
]
->
bool
);
}
VCL_SUB
vmod_set_subroutine
(
VRT_CTX
,
struct
VPFX
(
selector_set
)
*
set
,
VCL_INT
n
,
VCL_STRING
element
,
VCL_ENUM
selects
)
{
unsigned
idx
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
set
,
VMOD_SELECTOR_SET_MAGIC
);
idx
=
get_idx
(
ctx
,
n
,
set
,
"subroutine"
,
element
,
selects
);
if
(
idx
==
UINT_MAX
)
return
(
NULL
);
if
(
!
check_added
(
ctx
,
set
,
idx
,
SUB
,
"subroutine"
,
"subroutine"
))
return
(
NULL
);
return
(
set
->
table
[
idx
]
->
sub
);
}
src/tests/subroutine.vtc
0 → 100644
View file @
d6d30486
This diff is collapsed.
Click to expand it.
src/vmod_selector.c
View file @
d6d30486
...
...
@@ -506,7 +506,7 @@ vmod_set_add(VRT_CTX, struct vmod_selector_set *set,
}
if
(
!
args
->
valid_string
&&
re
==
NULL
&&
!
args
->
valid_backend
&&
!
args
->
valid_integer
&&
!
args
->
valid_bool
)
&&
!
args
->
valid_integer
&&
!
args
->
valid_bool
&&
!
args
->
valid_sub
)
return
;
set
->
table
=
realloc
(
set
->
table
,
n
*
sizeof
(
struct
entry
*
));
...
...
@@ -534,6 +534,10 @@ vmod_set_add(VRT_CTX, struct vmod_selector_set *set,
entry
->
bool
=
args
->
bool
;
set_added
(
set
,
n
-
1
,
BOOLEAN
);
}
if
(
args
->
valid_sub
)
{
entry
->
sub
=
args
->
sub
;
set_added
(
set
,
n
-
1
,
SUB
);
}
set
->
table
[
n
-
1
]
=
entry
;
}
...
...
src/vmod_selector.h
View file @
d6d30486
...
...
@@ -48,11 +48,12 @@
struct
entry
{
unsigned
magic
;
#define VMOD_SELECTOR_ENTRY_MAGIC 0x733dbe63
VCL_BOOL
bool
;
char
*
string
;
VCL_BACKEND
backend
;
VCL_SUB
sub
;
vre_t
*
re
;
VCL_INT
integer
;
VCL_BOOL
bool
;
};
enum
bitmap_e
{
...
...
@@ -61,6 +62,7 @@ enum bitmap_e {
REGEX
,
INTEGER
,
BOOLEAN
,
SUB
,
__MAX_BITMAP
,
};
...
...
src/vmod_selector.vcc
View file @
d6d30486
...
...
@@ -423,7 +423,7 @@ Examples::
}
$Method VOID .add(STRING, [STRING string], [STRING regex], [BACKEND backend],
[INT integer], [BOOL bool])
[INT integer], [BOOL bool]
, [SUB sub]
)
Add the given string to the set. As indicated above, elements added to
the set are implicitly numbered in the order in which they are added
...
...
@@ -931,6 +931,12 @@ Example::
# /foo/bar/1/2/* is rewritten as /foo/bar/2/1/*
# /foo/bar/baz/1/2/* is rewritten as /foo/bar/baz/2/1/*
$Method SUB .subroutine(INT n=0, STRING element=0,
ENUM {UNIQUE, EXACT, FIRST, LAST, SHORTEST, LONGEST}
select=UNIQUE)
XXX ...
$Function STRING version()
Return the version string for this VMOD.
...
...
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