Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
83abd0da
...
83abd0daf114b5e365bf819e1de046d1dfaad198
authored
2003-01-05 16:56:41 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
(sieve_test_address,sieve_test_header): Added support for relational tests.
1 parent
c9e92991
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
7 deletions
libsieve/tests.c
libsieve/tests.c
View file @
83abd0d
...
...
@@ -89,11 +89,13 @@ retrieve_address (void *item, void *data, int idx, char **pval)
int
sieve_test_address
(
sieve_machine_t
mach
,
list_t
args
,
list_t
tags
)
{
sieve_value_t
*
h
,
*
v
;
sieve_value_t
*
h
,
*
v
,
*
arg
;
header_t
header
=
NULL
;
sieve_comparator_t
comp
=
sieve_get_comparator
(
mach
,
tags
);
sieve_relcmp_t
test
=
sieve_get_relcmp
(
mach
,
tags
);
struct
address_closure
clos
;
int
rc
;
size_t
count
;
if
(
mach
->
debug_level
&
MU_SIEVE_DEBUG_TRACE
)
sieve_debug
(
mach
,
"ADDRESS
\n
"
);
...
...
@@ -115,8 +117,24 @@ sieve_test_address (sieve_machine_t mach, list_t args, list_t tags)
clos
.
data
=
header
;
clos
.
aget
=
sieve_get_address_part
(
tags
);
clos
.
addr
=
NULL
;
rc
=
sieve_vlist_compare
(
h
,
v
,
comp
,
retrieve_address
,
&
clos
);
rc
=
sieve_vlist_compare
(
h
,
v
,
comp
,
test
,
retrieve_address
,
&
clos
,
&
count
);
address_destroy
(
&
clos
.
addr
);
if
(
sieve_tag_lookup
(
tags
,
"count"
,
&
arg
))
{
size_t
limit
;
char
*
str
;
sieve_value_t
*
val
;
sieve_relcmpn_t
stest
;
val
=
sieve_value_get
(
args
,
1
);
list_get
(
val
->
v
.
list
,
0
,
(
void
**
)
&
str
);
limit
=
strtoul
(
str
,
&
str
,
10
);
sieve_str_to_relcmp
(
arg
->
v
.
string
,
NULL
,
&
stest
);
return
stest
(
count
,
limit
);
}
return
rc
;
}
...
...
@@ -131,9 +149,11 @@ retrieve_header (void *item, void *data, int idx, char **pval)
int
sieve_test_header
(
sieve_machine_t
mach
,
list_t
args
,
list_t
tags
)
{
sieve_value_t
*
h
,
*
v
;
sieve_value_t
*
h
,
*
v
,
*
arg
;
header_t
header
=
NULL
;
sieve_comparator_t
comp
=
sieve_get_comparator
(
mach
,
tags
);
sieve_relcmp_t
test
=
sieve_get_relcmp
(
mach
,
tags
);
size_t
count
,
mcount
=
0
;
if
(
mach
->
debug_level
&
MU_SIEVE_DEBUG_TRACE
)
sieve_debug
(
mach
,
"HEADER
\n
"
);
...
...
@@ -168,15 +188,33 @@ sieve_test_header (sieve_machine_t mach, list_t args, list_t tags)
if
(
message_get_part
(
mach
->
msg
,
i
,
&
message
)
==
0
)
{
message_get_header
(
message
,
&
header
);
if
(
sieve_vlist_compare
(
h
,
v
,
comp
,
retrieve_header
,
header
))
if
(
sieve_vlist_compare
(
h
,
v
,
comp
,
test
,
retrieve_header
,
header
,
&
mcount
))
return
1
;
}
}
}
}
message_get_header
(
mach
->
msg
,
&
header
);
return
sieve_vlist_compare
(
h
,
v
,
comp
,
retrieve_header
,
header
);
if
(
sieve_vlist_compare
(
h
,
v
,
comp
,
test
,
retrieve_header
,
header
,
&
count
))
return
1
;
if
(
sieve_tag_lookup
(
tags
,
"count"
,
&
arg
))
{
size_t
limit
;
char
*
str
;
sieve_value_t
*
val
;
sieve_relcmpn_t
stest
;
val
=
sieve_value_get
(
args
,
1
);
list_get
(
val
->
v
.
list
,
0
,
(
void
**
)
&
str
);
limit
=
strtoul
(
str
,
&
str
,
10
);
sieve_str_to_relcmp
(
arg
->
v
.
string
,
NULL
,
&
stest
);
return
stest
(
count
+
mcount
,
limit
);
}
return
0
;
}
int
...
...
@@ -212,6 +250,7 @@ sieve_test_envelope (sieve_machine_t mach, list_t args, list_t tags)
{
sieve_value_t
*
h
,
*
v
;
sieve_comparator_t
comp
=
sieve_get_comparator
(
mach
,
tags
);
sieve_relcmp_t
test
=
sieve_get_relcmp
(
mach
,
tags
);
struct
address_closure
clos
;
int
rc
;
...
...
@@ -234,7 +273,7 @@ sieve_test_envelope (sieve_machine_t mach, list_t args, list_t tags)
message_get_envelope
(
sieve_get_message
(
mach
),
(
envelope_t
*
)
&
clos
.
data
);
clos
.
aget
=
sieve_get_address_part
(
tags
);
clos
.
addr
=
NULL
;
rc
=
sieve_vlist_compare
(
h
,
v
,
comp
,
retrieve_envelope
,
&
clos
);
rc
=
sieve_vlist_compare
(
h
,
v
,
comp
,
test
,
retrieve_envelope
,
&
clos
,
NULL
);
address_destroy
(
&
clos
.
addr
);
return
rc
;
}
...
...
@@ -322,6 +361,8 @@ static sieve_tag_def_t match_part_tags[] = {
{
"contains"
,
SVT_VOID
},
{
"matches"
,
SVT_VOID
},
{
"regex"
,
SVT_VOID
},
{
"count"
,
SVT_STRING
},
{
"value"
,
SVT_STRING
},
{
"comparator"
,
SVT_STRING
},
{
NULL
}
};
...
...
Please
register
or
sign in
to post a comment