File: mcht-is.c

package info (click to toggle)
dovecot 1%3A1.2.15-7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 30,252 kB
  • ctags: 19,837
  • sloc: ansic: 191,438; sh: 21,091; makefile: 3,330; cpp: 526; perl: 108; xml: 44
file content (53 lines) | stat: -rw-r--r-- 1,112 bytes parent folder | download | duplicates (2)
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
53
/* Copyright (c) 2002-2010 Dovecot Sieve 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
	(struct sieve_match_context *mctx, const char *val, size_t val_size,
		const char *key, size_t key_size, int key_index);

/*
 * Match-type object
 */

const struct sieve_match_type_def is_match_type = {
	SIEVE_OBJECT("is", &match_type_operand, SIEVE_MATCH_TYPE_IS),
	TRUE, TRUE,
	NULL, NULL, NULL,
	mcht_is_match,
	NULL
};

/*
 * Match-type implementation
 */

static int mcht_is_match
(struct sieve_match_context *mctx ATTR_UNUSED,
	const char *val, size_t val_size,
	const char *key, size_t key_size, int key_index ATTR_UNUSED)
{
	if ( (val == NULL || val_size == 0) )
		return ( key_size == 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);

	return FALSE;
}