/src/pigeonhole/src/lib-sieve/mcht-is.c
Line | Count | Source |
1 | | /* Copyright (c) Pigeonhole authors, see top-level COPYING file */ |
2 | | |
3 | | /* Match-type ':is': |
4 | | */ |
5 | | |
6 | | #include "lib.h" |
7 | | |
8 | | #include "sieve-match-types.h" |
9 | | #include "sieve-comparators.h" |
10 | | #include "sieve-match.h" |
11 | | |
12 | | #include <string.h> |
13 | | #include <stdio.h> |
14 | | |
15 | | /* |
16 | | * Forward declarations |
17 | | */ |
18 | | |
19 | | static int |
20 | | mcht_is_match_key(struct sieve_match_context *mctx, |
21 | | const char *val, size_t val_size, |
22 | | const char *key, size_t key_size); |
23 | | |
24 | | /* |
25 | | * Match-type object |
26 | | */ |
27 | | |
28 | | const struct sieve_match_type_def is_match_type = { |
29 | | SIEVE_OBJECT("is", &match_type_operand, SIEVE_MATCH_TYPE_IS), |
30 | | .match_key = mcht_is_match_key |
31 | | }; |
32 | | |
33 | | /* |
34 | | * Match-type implementation |
35 | | */ |
36 | | |
37 | | static int |
38 | | mcht_is_match_key(struct sieve_match_context *mctx ATTR_UNUSED, |
39 | | const char *val, size_t val_size, |
40 | | const char *key, size_t key_size) |
41 | 0 | { |
42 | 0 | if (val_size == 0) |
43 | 0 | return (key_size == 0 ? 1 : 0); |
44 | | |
45 | 0 | if (mctx->comparator->def != NULL && |
46 | 0 | mctx->comparator->def->compare != NULL) { |
47 | 0 | return (mctx->comparator->def->compare(mctx->comparator, |
48 | 0 | val, val_size, |
49 | 0 | key, key_size) == 0 ? |
50 | 0 | 1 : 0 ); |
51 | 0 | } |
52 | | |
53 | 0 | return 0; |
54 | 0 | } |
55 | | |