File: ext-relational-common.h

package info (click to toggle)
dovecot 1:2.2.13-12~deb8u4
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 38,792 kB
  • sloc: ansic: 341,472; sh: 16,920; makefile: 5,393; cpp: 1,474; perl: 265; xml: 44; python: 34; pascal: 27
file content (93 lines) | stat: -rw-r--r-- 2,185 bytes parent folder | download | duplicates (3)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* Copyright (c) 2002-2013 Pigeonhole authors, see the included COPYING file
 */

#ifndef __EXT_RELATIONAL_COMMON_H
#define __EXT_RELATIONAL_COMMON_H

#include "lib.h"
#include "str.h"

#include "sieve-common.h"

/*
 * Types
 */

enum ext_relational_match_type {
	RELATIONAL_VALUE,
	RELATIONAL_COUNT
};

enum relational_match {
	REL_MATCH_GREATER,
	REL_MATCH_GREATER_EQUAL,
	REL_MATCH_LESS,
	REL_MATCH_LESS_EQUAL,
	REL_MATCH_EQUAL,
	REL_MATCH_NOT_EQUAL,
	REL_MATCH_INVALID
};

#define REL_MATCH_INDEX(type, match) \
	(type * REL_MATCH_INVALID + match)
#define REL_MATCH_TYPE(index) \
	(index / REL_MATCH_INVALID)
#define REL_MATCH(index) \
	(index % REL_MATCH_INVALID)

/*
 * Extension definitions
 */

extern const struct sieve_extension_def relational_extension;

/*
 * Match types
 */

/* Registered for validation */

extern const struct sieve_match_type_def value_match_type;
extern const struct sieve_match_type_def count_match_type;

/* Used in byte code */

extern const struct sieve_match_type_def rel_match_count_gt;
extern const struct sieve_match_type_def rel_match_count_ge;
extern const struct sieve_match_type_def rel_match_count_lt;
extern const struct sieve_match_type_def rel_match_count_le;
extern const struct sieve_match_type_def rel_match_count_eq;
extern const struct sieve_match_type_def rel_match_count_ne;

extern const struct sieve_match_type_def rel_match_value_gt;
extern const struct sieve_match_type_def rel_match_value_ge;
extern const struct sieve_match_type_def rel_match_value_lt;
extern const struct sieve_match_type_def rel_match_value_le;
extern const struct sieve_match_type_def rel_match_value_eq;
extern const struct sieve_match_type_def rel_match_value_ne;

/*
 * Operand
 */

extern const struct sieve_operand_def rel_match_type_operand;


/*
 * Match type validation
 */

bool mcht_relational_validate
	(struct sieve_validator *validator, struct sieve_ast_argument **arg,
		struct sieve_match_type_context *ctx);

/*
 * Value match function (also used by :count)
 */

int mcht_value_match_key
	(struct sieve_match_context *mctx, const char *val, size_t val_size,
		const char *key, size_t key_size);


#endif /* __EXT_RELATIONAL_COMMON_H */