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
eecbd7cb
Commit
eecbd7cb
authored
Sep 18, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ne-operator - merge with query lang
parent
7abf8292
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
8 deletions
+45
-8
l00001.vtc
bin/varnishtest/tests/l00001.vtc
+7
-0
vsl_query.c
lib/libvarnishapi/vsl_query.c
+38
-8
No files found.
bin/varnishtest/tests/l00001.vtc
View file @
eecbd7cb
...
...
@@ -16,7 +16,14 @@ client c1 {
expect resp.status == 200
} -run
# Test 'eq' operator
logexpect l1 -d 1 -g request -q "Begin eq 'req 1000'" {
expect * * Begin
expect * = ReqEnd
} -run
# Test 'ne' operator
logexpect l1 -d 1 -g request -q "Begin ne 'req 1001'" {
expect * * Begin
expect * = ReqEnd
} -run
lib/libvarnishapi/vsl_query.c
View file @
eecbd7cb
...
...
@@ -52,19 +52,49 @@ struct vslq_query {
struct
vex
*
vex
;
};
static
int
vslq_test_rec
(
const
struct
vex
*
vex
,
const
struct
VSLC_ptr
*
rec
)
{
int
reclen
;
const
char
*
recdata
;
AN
(
vex
);
AN
(
rec
);
reclen
=
VSL_LEN
(
rec
->
ptr
);
recdata
=
VSL_CDATA
(
rec
->
ptr
);
switch
(
vex
->
tok
)
{
case
T_SEQ
:
/* eq */
assert
(
vex
->
val
->
type
==
VEX_STRING
);
if
(
reclen
==
strlen
(
vex
->
val
->
val_string
)
&&
!
strncmp
(
vex
->
val
->
val_string
,
recdata
,
reclen
))
return
(
1
);
return
(
0
);
case
T_SNEQ
:
/* ne */
assert
(
vex
->
val
->
type
==
VEX_STRING
);
if
(
reclen
!=
strlen
(
vex
->
val
->
val_string
)
||
strncmp
(
vex
->
val
->
val_string
,
recdata
,
reclen
))
return
(
1
);
return
(
0
);
default:
INCOMPL
();
}
return
(
0
);
}
static
int
vslq_test
(
const
struct
vex
*
vex
,
struct
VSL_transaction
*
const
ptrans
[])
{
struct
VSL_transaction
*
t
;
int
i
,
reclen
,
vallen
;
const
char
*
recdata
;
int
i
;
CHECK_OBJ_NOTNULL
(
vex
,
VEX_MAGIC
);
CHECK_OBJ_NOTNULL
(
vex
->
tag
,
VEX_TAG_MAGIC
);
CHECK_OBJ_NOTNULL
(
vex
->
val
,
VEX_VAL_MAGIC
);
AN
(
vex
->
val
->
val_string
);
vallen
=
strlen
(
vex
->
val
->
val_string
);
for
(
t
=
ptrans
[
0
];
t
!=
NULL
;
t
=
*++
ptrans
)
{
AZ
(
VSL_ResetCursor
(
t
->
c
));
while
(
1
)
{
...
...
@@ -79,11 +109,11 @@ vslq_test(const struct vex *vex, struct VSL_transaction * const ptrans[])
if
(
vex
->
tag
->
tag
!=
VSL_TAG
(
t
->
c
->
rec
.
ptr
))
continue
;
reclen
=
VSL_LEN
(
t
->
c
->
rec
.
ptr
);
recdata
=
VSL_CDATA
(
t
->
c
->
rec
.
ptr
);
if
(
reclen
==
vallen
&&
!
strncmp
(
vex
->
val
->
val_string
,
recdata
,
reclen
))
return
(
1
);
i
=
vslq_test_rec
(
vex
,
&
t
->
c
->
rec
);
if
(
i
)
return
(
i
);
}
}
...
...
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