/src/pigeonhole/src/lib-sieve/sieve-script.h
Line | Count | Source |
1 | | #ifndef SIEVE_SCRIPT_H |
2 | | #define SIEVE_SCRIPT_H |
3 | | |
4 | | #include "sieve-common.h" |
5 | | |
6 | | #include <sys/types.h> |
7 | | |
8 | | |
9 | | /* |
10 | | * Sieve script name |
11 | | */ |
12 | | |
13 | | bool sieve_script_name_is_valid(const char *scriptname); |
14 | | |
15 | | /* |
16 | | * Sieve script file |
17 | | */ |
18 | | |
19 | | bool sieve_script_file_has_extension(const char *filename); |
20 | | const char *sieve_script_file_get_scriptname(const char *filename); |
21 | | const char *sieve_script_file_from_name(const char *name); |
22 | | |
23 | | /* |
24 | | * Sieve script class |
25 | | */ |
26 | | |
27 | | void sieve_script_class_register(struct sieve_instance *svinst, |
28 | | const struct sieve_script *script_class); |
29 | | void sieve_script_class_unregister(struct sieve_instance *svinst, |
30 | | const struct sieve_script *script_class); |
31 | | |
32 | | /* |
33 | | * Sieve script instance |
34 | | */ |
35 | | |
36 | | struct sieve_script; |
37 | | |
38 | | ARRAY_DEFINE_TYPE(sieve_script, struct sieve_script *); |
39 | | |
40 | | int sieve_script_create(struct sieve_instance *svinst, |
41 | | const char *cause, const char *type, const char *name, |
42 | | struct sieve_script **script_r, |
43 | | enum sieve_error *error_code_r, const char **error_r); |
44 | | int sieve_script_create_in(struct sieve_instance *svinst, const char *cause, |
45 | | const char *storage_name, const char *name, |
46 | | struct sieve_script **script_r, |
47 | | enum sieve_error *error_code_r, |
48 | | const char **error_r); |
49 | | void sieve_script_ref(struct sieve_script *script); |
50 | | void sieve_script_unref(struct sieve_script **script); |
51 | | |
52 | | int sieve_script_open(struct sieve_script *script, |
53 | | enum sieve_error *error_code_r); |
54 | | int sieve_script_open_as(struct sieve_script *script, const char *name, |
55 | | enum sieve_error *error_code_r); |
56 | | |
57 | | int sieve_script_create_open(struct sieve_instance *svinst, |
58 | | const char *cause, const char *type, |
59 | | const char *name, struct sieve_script **script_r, |
60 | | enum sieve_error *error_code_r, |
61 | | const char **error_r); |
62 | | int sieve_script_create_open_in(struct sieve_instance *svinst, |
63 | | const char *cause, |
64 | | const char *storage_name, const char *name, |
65 | | struct sieve_script **script_r, |
66 | | enum sieve_error *error_code_r, |
67 | | const char **error_r); |
68 | | |
69 | | int sieve_script_check(struct sieve_instance *svinst, |
70 | | const char *cause, const char *type, const char *name, |
71 | | enum sieve_error *error_code_r, const char **error_r); |
72 | | |
73 | | /* |
74 | | * Data script |
75 | | */ |
76 | | |
77 | | struct sieve_script * |
78 | | sieve_data_script_create_from_input(struct sieve_instance *svinst, |
79 | | const char *cause, const char *name, |
80 | | struct istream *input); |
81 | | |
82 | | /* |
83 | | * Binary |
84 | | */ |
85 | | |
86 | | int sieve_script_binary_read_metadata(struct sieve_script *script, |
87 | | struct sieve_binary_block *sblock, |
88 | | sieve_size_t *offset); |
89 | | void sieve_script_binary_write_metadata(struct sieve_script *script, |
90 | | struct sieve_binary_block *sblock); |
91 | | bool sieve_script_binary_dump_metadata(struct sieve_script *script, |
92 | | struct sieve_dumptime_env *denv, |
93 | | struct sieve_binary_block *sblock, |
94 | | sieve_size_t *offset) ATTR_NULL(1); |
95 | | |
96 | | int sieve_script_binary_load(struct sieve_script *script, |
97 | | struct sieve_binary **sbin_r, |
98 | | enum sieve_error *error_code_r); |
99 | | int sieve_script_binary_save(struct sieve_script *script, |
100 | | struct sieve_binary *sbin, bool update, |
101 | | enum sieve_error *error_code_r); |
102 | | |
103 | | const char *sieve_script_binary_get_prefix(struct sieve_script *script); |
104 | | |
105 | | /* |
106 | | * Stream management |
107 | | */ |
108 | | |
109 | | int sieve_script_get_stream(struct sieve_script *script, |
110 | | struct istream **stream_r, |
111 | | enum sieve_error *error_code_r); |
112 | | |
113 | | /* |
114 | | * Management |
115 | | */ |
116 | | |
117 | | // FIXME: check read/write flag! |
118 | | |
119 | | int sieve_script_rename(struct sieve_script *script, const char *newname); |
120 | | int sieve_script_is_active(struct sieve_script *script); |
121 | | int sieve_script_activate(struct sieve_script *script, time_t mtime); |
122 | | int sieve_script_delete(struct sieve_script *script, bool ignore_active); |
123 | | |
124 | | /* |
125 | | * Properties |
126 | | */ |
127 | | |
128 | | const char *sieve_script_name(const struct sieve_script *script) ATTR_PURE; |
129 | | const char *sieve_script_label(const struct sieve_script *script) ATTR_PURE; |
130 | | const char * |
131 | | sieve_script_storage_type(const struct sieve_script *script) ATTR_PURE; |
132 | | const char *sieve_script_cause(const struct sieve_script *script) ATTR_PURE; |
133 | | struct sieve_instance * |
134 | | sieve_script_svinst(const struct sieve_script *script) ATTR_PURE; |
135 | | |
136 | | int sieve_script_get_size(struct sieve_script *script, uoff_t *size_r); |
137 | | bool sieve_script_is_open(const struct sieve_script *script) ATTR_PURE; |
138 | | bool sieve_script_is_default(const struct sieve_script *script) ATTR_PURE; |
139 | | |
140 | | const char * |
141 | | sieve_file_script_get_dir_path(const struct sieve_script *script) ATTR_PURE; |
142 | | const char * |
143 | | sieve_file_script_get_path(const struct sieve_script *script) ATTR_PURE; |
144 | | |
145 | | /* |
146 | | * Comparison |
147 | | */ |
148 | | |
149 | | int sieve_script_cmp(const struct sieve_script *script1, |
150 | | const struct sieve_script *script2); |
151 | | static inline bool |
152 | | sieve_script_equals(const struct sieve_script *script1, |
153 | | const struct sieve_script *script2) |
154 | 0 | { |
155 | 0 | return (sieve_script_cmp(script1, script2) == 0); |
156 | 0 | } Unexecuted instantiation: testsuite-script.c:sieve_script_equals Unexecuted instantiation: testsuite-binary.c:sieve_script_equals Unexecuted instantiation: cmd-test-result.c:sieve_script_equals Unexecuted instantiation: tst-test-script-compile.c:sieve_script_equals Unexecuted instantiation: tst-test-script-run.c:sieve_script_equals Unexecuted instantiation: tst-test-multiscript.c:sieve_script_equals Unexecuted instantiation: tst-test-error.c:sieve_script_equals Unexecuted instantiation: tst-test-result-action.c:sieve_script_equals Unexecuted instantiation: tst-test-result-execute.c:sieve_script_equals Unexecuted instantiation: fuzzsuite.c:sieve_script_equals |
157 | | |
158 | | unsigned int sieve_script_hash(const struct sieve_script *script); |
159 | | |
160 | | /* |
161 | | * Error handling |
162 | | */ |
163 | | |
164 | | const char *sieve_script_get_last_error(struct sieve_script *script, |
165 | | enum sieve_error *error_code_r); |
166 | | const char *sieve_script_get_last_error_lcase(struct sieve_script *script); |
167 | | |
168 | | /* |
169 | | * Script sequence |
170 | | */ |
171 | | |
172 | | struct sieve_script_sequence; |
173 | | |
174 | | int sieve_script_sequence_create(struct sieve_instance *svinst, |
175 | | struct event *event_parent, |
176 | | const char *cause, const char *type, |
177 | | struct sieve_script_sequence **sseq_r, |
178 | | enum sieve_error *error_code_r, |
179 | | const char **error_r); |
180 | | int sieve_script_sequence_next(struct sieve_script_sequence *sseq, |
181 | | struct sieve_script **script_r, |
182 | | enum sieve_error *error_code_r, |
183 | | const char **error_r); |
184 | | void sieve_script_sequence_free(struct sieve_script_sequence **_seq); |
185 | | |
186 | | #endif |