Commit f13d2dd4 f13d2dd4180fb8c553808fb06bebbd1b8091695d by Sergey Poznyakoff

(sieve_value_get, sieve_log_action, sieve_mark_deleted): New functions.

1 parent 8b018cd9
...@@ -144,12 +144,21 @@ sieve_value_create (sieve_data_type type, void *data) ...@@ -144,12 +144,21 @@ sieve_value_create (sieve_data_type type, void *data)
144 break; 144 break;
145 145
146 default: 146 default:
147 sieve_compile_error (sieve_filename, sieve_line_num, "Invalid data type"); 147 sieve_compile_error (sieve_filename, sieve_line_num,
148 "Invalid data type");
148 abort (); 149 abort ();
149 } 150 }
150 return val; 151 return val;
151 } 152 }
152 153
154 sieve_value_t *
155 sieve_value_get (list_t vlist, size_t index)
156 {
157 sieve_value_t *val = NULL;
158 list_get (vlist, index, (void **)&val);
159 return val;
160 }
161
153 void 162 void
154 sieve_compile_error (const char *filename, int linenum, const char *fmt, ...) 163 sieve_compile_error (const char *filename, int linenum, const char *fmt, ...)
155 { 164 {
...@@ -163,7 +172,7 @@ sieve_compile_error (const char *filename, int linenum, const char *fmt, ...) ...@@ -163,7 +172,7 @@ sieve_compile_error (const char *filename, int linenum, const char *fmt, ...)
163 } 172 }
164 173
165 void 174 void
166 sieve_error (sieve_machine_t *mach, const char *fmt, ...) 175 sieve_error (sieve_machine_t mach, const char *fmt, ...)
167 { 176 {
168 va_list ap; 177 va_list ap;
169 178
...@@ -183,7 +192,7 @@ sieve_debug_internal (sieve_printf_t printer, void *data, const char *fmt, ...) ...@@ -183,7 +192,7 @@ sieve_debug_internal (sieve_printf_t printer, void *data, const char *fmt, ...)
183 } 192 }
184 193
185 void 194 void
186 sieve_debug (sieve_machine_t *mach, const char *fmt, ...) 195 sieve_debug (sieve_machine_t mach, const char *fmt, ...)
187 { 196 {
188 va_list ap; 197 va_list ap;
189 198
...@@ -192,6 +201,21 @@ sieve_debug (sieve_machine_t *mach, const char *fmt, ...) ...@@ -192,6 +201,21 @@ sieve_debug (sieve_machine_t *mach, const char *fmt, ...)
192 va_end (ap); 201 va_end (ap);
193 } 202 }
194 203
204 void
205 sieve_log_action (sieve_machine_t mach, const char *action,
206 const char *fmt, ...)
207 {
208 va_list ap;
209
210 if (!mach->logger)
211 return;
212 va_start (ap, fmt);
213 mach->logger (mach->data, mach->filename, mach->msgno, mach->msg,
214 action, fmt, ap);
215 va_end (ap);
216 }
217
218
195 int 219 int
196 _sieve_default_error_printer (void *unused, const char *fmt, va_list ap) 220 _sieve_default_error_printer (void *unused, const char *fmt, va_list ap)
197 { 221 {
...@@ -202,8 +226,10 @@ int ...@@ -202,8 +226,10 @@ int
202 _sieve_default_parse_error (void *unused, const char *filename, int lineno, 226 _sieve_default_parse_error (void *unused, const char *filename, int lineno,
203 const char *fmt, va_list ap) 227 const char *fmt, va_list ap)
204 { 228 {
229 if (filename)
205 fprintf (stderr, "%s:%d: ", filename, lineno); 230 fprintf (stderr, "%s:%d: ", filename, lineno);
206 vfprintf (stderr, fmt, ap); 231 vfprintf (stderr, fmt, ap);
232 fprintf (stderr, "\n");
207 return 0; 233 return 0;
208 } 234 }
209 235
...@@ -325,3 +351,23 @@ sieve_print_tag_list (list_t list, sieve_printf_t printer, void *data) ...@@ -325,3 +351,23 @@ sieve_print_tag_list (list_t list, sieve_printf_t printer, void *data)
325 } 351 }
326 352
327 353
354 int
355 sieve_mark_deleted (message_t msg, int deleted)
356 {
357 attribute_t attr = 0;
358 int rc;
359
360 rc = message_get_attribute (msg, &attr);
361
362 if (!rc)
363 {
364 if (deleted)
365 rc = attribute_set_deleted (attr);
366 else
367 rc = attribute_unset_deleted (attr);
368 }
369
370 return rc;
371 }
372
373
......