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