/src/pigeonhole/src/lib-sieve/sieve-address-parts.h
Line | Count | Source |
1 | | #ifndef SIEVE_ADDRESS_PARTS_H |
2 | | #define SIEVE_ADDRESS_PARTS_H |
3 | | |
4 | | #include "message-address.h" |
5 | | |
6 | | #include "sieve-common.h" |
7 | | #include "sieve-match.h" |
8 | | #include "sieve-extensions.h" |
9 | | #include "sieve-objects.h" |
10 | | |
11 | | /* |
12 | | * Address part definition |
13 | | */ |
14 | | |
15 | | struct sieve_address_part_def { |
16 | | struct sieve_object_def obj_def; |
17 | | |
18 | | const char * |
19 | | (*extract_from)(const struct sieve_address_part *addrp, |
20 | | const struct smtp_address *address); |
21 | | }; |
22 | | |
23 | | /* |
24 | | * Address part instance |
25 | | */ |
26 | | |
27 | | struct sieve_address_part { |
28 | | struct sieve_object object; |
29 | | |
30 | | const struct sieve_address_part_def *def; |
31 | | }; |
32 | | |
33 | | #define SIEVE_ADDRESS_PART_DEFAULT(definition) \ |
34 | 0 | { SIEVE_OBJECT_DEFAULT(definition), &(definition) }; |
35 | | |
36 | | #define sieve_address_part_name(addrp) \ |
37 | 0 | ( (addrp)->object.def->identifier ) |
38 | | #define sieve_address_part_is(addrp, definition) \ |
39 | 0 | ( (addrp)->def == &(definition) ) |
40 | | |
41 | | /* |
42 | | * Core address parts |
43 | | */ |
44 | | |
45 | | enum sieve_address_part_code { |
46 | | SIEVE_ADDRESS_PART_ALL, |
47 | | SIEVE_ADDRESS_PART_LOCAL, |
48 | | SIEVE_ADDRESS_PART_DOMAIN, |
49 | | SIEVE_ADDRESS_PART_CUSTOM |
50 | | }; |
51 | | |
52 | | extern const struct sieve_address_part_def all_address_part; |
53 | | extern const struct sieve_address_part_def local_address_part; |
54 | | extern const struct sieve_address_part_def domain_address_part; |
55 | | |
56 | | /* |
57 | | * Address part tagged argument |
58 | | */ |
59 | | |
60 | | extern const struct sieve_argument_def address_part_tag; |
61 | | |
62 | | void sieve_address_parts_link_tags(struct sieve_validator *valdtr, |
63 | | struct sieve_command_registration *cmd_reg, |
64 | | int id_code); |
65 | | |
66 | | /* |
67 | | * Address part registry |
68 | | */ |
69 | | |
70 | | void sieve_address_part_register(struct sieve_validator *valdtr, |
71 | | const struct sieve_extension *ext, |
72 | | const struct sieve_address_part_def *addrp); |
73 | | |
74 | | /* |
75 | | * Address part operand |
76 | | */ |
77 | | |
78 | | extern const struct sieve_operand_def address_part_operand; |
79 | | extern const struct sieve_operand_class sieve_address_part_operand_class; |
80 | | |
81 | | #define SIEVE_EXT_DEFINE_ADDRESS_PART(OP) SIEVE_EXT_DEFINE_OBJECT(OP) |
82 | | #define SIEVE_EXT_DEFINE_ADDRESS_PARTS(OPS) SIEVE_EXT_DEFINE_OBJECTS(OPS) |
83 | | |
84 | | static inline void |
85 | | sieve_opr_address_part_emit(struct sieve_binary_block *sblock, |
86 | | const struct sieve_address_part *addrp) |
87 | 0 | { |
88 | 0 | sieve_opr_object_emit(sblock, addrp->object.ext, addrp->object.def); |
89 | 0 | } Unexecuted instantiation: sieve-message.c:sieve_opr_address_part_emit Unexecuted instantiation: sieve-validator.c:sieve_opr_address_part_emit Unexecuted instantiation: sieve-address-parts.c:sieve_opr_address_part_emit Unexecuted instantiation: tst-address.c:sieve_opr_address_part_emit Unexecuted instantiation: ext-envelope.c:sieve_opr_address_part_emit Unexecuted instantiation: ext-subaddress.c:sieve_opr_address_part_emit Unexecuted instantiation: ext-body.c:sieve_opr_address_part_emit Unexecuted instantiation: tst-body.c:sieve_opr_address_part_emit Unexecuted instantiation: ext-date.c:sieve_opr_address_part_emit Unexecuted instantiation: tst-date.c:sieve_opr_address_part_emit Unexecuted instantiation: tst-spamvirustest.c:sieve_opr_address_part_emit Unexecuted instantiation: ext-editheader.c:sieve_opr_address_part_emit Unexecuted instantiation: ext-debug.c:sieve_opr_address_part_emit Unexecuted instantiation: ext-vnd-environment.c:sieve_opr_address_part_emit Unexecuted instantiation: ext-vnd-environment-items.c:sieve_opr_address_part_emit |
90 | | |
91 | | static inline bool |
92 | | sieve_opr_address_part_dump(const struct sieve_dumptime_env *denv, |
93 | | sieve_size_t *address) |
94 | 0 | { |
95 | 0 | return sieve_opr_object_dump(denv, &sieve_address_part_operand_class, |
96 | 0 | address, NULL); |
97 | 0 | } Unexecuted instantiation: sieve-message.c:sieve_opr_address_part_dump Unexecuted instantiation: sieve-validator.c:sieve_opr_address_part_dump Unexecuted instantiation: sieve-address-parts.c:sieve_opr_address_part_dump Unexecuted instantiation: tst-address.c:sieve_opr_address_part_dump Unexecuted instantiation: ext-envelope.c:sieve_opr_address_part_dump Unexecuted instantiation: ext-subaddress.c:sieve_opr_address_part_dump Unexecuted instantiation: ext-body.c:sieve_opr_address_part_dump Unexecuted instantiation: tst-body.c:sieve_opr_address_part_dump Unexecuted instantiation: ext-date.c:sieve_opr_address_part_dump Unexecuted instantiation: tst-date.c:sieve_opr_address_part_dump Unexecuted instantiation: tst-spamvirustest.c:sieve_opr_address_part_dump Unexecuted instantiation: ext-editheader.c:sieve_opr_address_part_dump Unexecuted instantiation: ext-debug.c:sieve_opr_address_part_dump Unexecuted instantiation: ext-vnd-environment.c:sieve_opr_address_part_dump Unexecuted instantiation: ext-vnd-environment-items.c:sieve_opr_address_part_dump |
98 | | |
99 | | static inline int |
100 | | sieve_opr_address_part_read(const struct sieve_runtime_env *renv, |
101 | | sieve_size_t *address, |
102 | | struct sieve_address_part *addrp) |
103 | 0 | { |
104 | 0 | if (!sieve_opr_object_read(renv, &sieve_address_part_operand_class, |
105 | 0 | address, &addrp->object)) |
106 | 0 | return SIEVE_EXEC_BIN_CORRUPT; |
107 | | |
108 | 0 | addrp->def = (const struct sieve_address_part_def *)addrp->object.def; |
109 | 0 | return SIEVE_EXEC_OK; |
110 | 0 | } Unexecuted instantiation: sieve-message.c:sieve_opr_address_part_read Unexecuted instantiation: sieve-validator.c:sieve_opr_address_part_read Unexecuted instantiation: sieve-address-parts.c:sieve_opr_address_part_read Unexecuted instantiation: tst-address.c:sieve_opr_address_part_read Unexecuted instantiation: ext-envelope.c:sieve_opr_address_part_read Unexecuted instantiation: ext-subaddress.c:sieve_opr_address_part_read Unexecuted instantiation: ext-body.c:sieve_opr_address_part_read Unexecuted instantiation: tst-body.c:sieve_opr_address_part_read Unexecuted instantiation: ext-date.c:sieve_opr_address_part_read Unexecuted instantiation: tst-date.c:sieve_opr_address_part_read Unexecuted instantiation: tst-spamvirustest.c:sieve_opr_address_part_read Unexecuted instantiation: ext-editheader.c:sieve_opr_address_part_read Unexecuted instantiation: ext-debug.c:sieve_opr_address_part_read Unexecuted instantiation: ext-vnd-environment.c:sieve_opr_address_part_read Unexecuted instantiation: ext-vnd-environment-items.c:sieve_opr_address_part_read |
111 | | |
112 | | /* |
113 | | * Address-part string list |
114 | | */ |
115 | | |
116 | | struct sieve_stringlist * |
117 | | sieve_address_part_stringlist_create(const struct sieve_runtime_env *renv, |
118 | | const struct sieve_address_part *addrp, |
119 | | struct sieve_address_list *addresses); |
120 | | |
121 | | /* |
122 | | * Match utility |
123 | | */ |
124 | | |
125 | | enum sieve_addrmatch_opt_operand { |
126 | | SIEVE_AM_OPT_ADDRESS_PART = SIEVE_MATCH_OPT_LAST, |
127 | | SIEVE_AM_OPT_LAST |
128 | | }; |
129 | | |
130 | | int sieve_addrmatch_opr_optional_dump(const struct sieve_dumptime_env *denv, |
131 | | sieve_size_t *address, |
132 | | signed int *opt_code); |
133 | | |
134 | | int sieve_addrmatch_opr_optional_read(const struct sieve_runtime_env *renv, |
135 | | sieve_size_t *address, |
136 | | signed int *opt_code, int *exec_status, |
137 | | struct sieve_address_part *addrp, |
138 | | struct sieve_match_type *mtch, |
139 | | struct sieve_comparator *cmp); |
140 | | |
141 | | #endif |