1 #ifndef SIEVE_ERROR_PRIVATE_H
2 #define SIEVE_ERROR_PRIVATE_H
3
4 #include "sieve-error.h"
5
6 /*
7 * Initialization
8 */
9
10 void sieve_errors_init(struct sieve_instance *svinst);
11 void sieve_errors_deinit(struct sieve_instance *svinst);
12
13 /*
14 * Error handler object
15 */
16
17 struct sieve_error_handler {
18 pool_t pool;
19 int refcount;
20
21 struct sieve_instance *svinst;
22
23 unsigned int max_errors;
24
25 unsigned int errors;
26 unsigned int warnings;
27
28 void (*log)(struct sieve_error_handler *ehandler,
29 const struct sieve_error_params *params,
30 enum sieve_error_flags flags,
31 const char *message);
32
33 void (*free)(struct sieve_error_handler *ehandler);
34
35 bool master_log:1; /* this logs through master log facility */
36 bool log_info:1; /* handle or discard info log */
37 bool log_debug:1; /* handle or discard debug log */
38 };
39
40 void sieve_error_handler_init(struct sieve_error_handler *ehandler,
41 struct sieve_instance *svinst, pool_t pool,
42 unsigned int max_errors);
43
44 /*
45 * Direct handler calls
46 */
47
48 void sieve_direct_logv(struct sieve_instance *svinst,
49 struct sieve_error_handler *ehandler,
50 const struct sieve_error_params *params,
51 enum sieve_error_flags flags,
52 const char *fmt, va_list args) ATTR_FORMAT(5, 0);
53
54 static inline void ATTR_FORMAT(5, 6)
sieve_direct_log(struct sieve_instance * svinst,struct sieve_error_handler * ehandler,const struct sieve_error_params * params,enum sieve_error_flags flags,const char * fmt,...)55 sieve_direct_log(struct sieve_instance *svinst,
56 struct sieve_error_handler *ehandler,
57 const struct sieve_error_params *params,
58 enum sieve_error_flags flags, const char *fmt, ...)
59 {
60 va_list args;
61
62 va_start(args, fmt);
63 sieve_direct_logv(svinst, ehandler, params, flags, fmt, args);
64 va_end(args);
65 }
66
67 #endif
68