Commit d5110ad6 d5110ad69315b1e00c3b6b019b72204bdd8d4ac1 by Sergey Poznyakoff

(MU_SIEVE_CHARSET): New define

1 parent ec0cdfd3
......@@ -32,32 +32,36 @@ extern "C" {
typedef struct sieve_machine *mu_sieve_machine_t;
typedef struct {
typedef struct
{
const char *source_file;
size_t source_line;
} mu_sieve_locus_t;
}
mu_sieve_locus_t;
typedef int (*mu_sieve_handler_t) (mu_sieve_machine_t mach,
mu_list_t args, mu_list_t tags);
mu_list_t args, mu_list_t tags);
typedef int (*mu_sieve_printf_t) (void *data, const char *fmt, va_list ap);
typedef int (*mu_sieve_parse_error_t) (void *data,
const char *filename, int lineno,
const char *fmt, va_list ap);
const char *filename, int lineno,
const char *fmt, va_list ap);
typedef void (*mu_sieve_action_log_t) (void *data,
const mu_sieve_locus_t *locus,
size_t msgno, mu_message_t msg,
const char *action,
const char *fmt, va_list ap);
const mu_sieve_locus_t * locus,
size_t msgno, mu_message_t msg,
const char *action,
const char *fmt, va_list ap);
typedef int (*mu_sieve_relcmp_t) (int, int);
typedef int (*mu_sieve_relcmpn_t) (size_t, size_t);
typedef int (*mu_sieve_relcmp_t) (int, int);
typedef int (*mu_sieve_relcmpn_t) (size_t, size_t);
typedef int (*mu_sieve_comparator_t) (const char *, const char *);
typedef int (*mu_sieve_retrieve_t) (void *item, void *data, int idx, char **pval);
typedef int (*mu_sieve_retrieve_t) (void *item, void *data, int idx,
char **pval);
typedef void (*mu_sieve_destructor_t) (void *data);
typedef int (*mu_sieve_tag_checker_t) (const char *name,
mu_list_t tags, mu_list_t args);
mu_list_t tags, mu_list_t args);
typedef enum {
typedef enum
{
SVT_VOID,
SVT_NUMBER,
SVT_STRING,
......@@ -66,13 +70,16 @@ typedef enum {
SVT_IDENT,
SVT_VALUE_LIST,
SVT_POINTER
} mu_sieve_data_type;
}
mu_sieve_data_type;
typedef struct mu_sieve_runtime_tag mu_sieve_runtime_tag_t;
typedef struct {
typedef struct
{
mu_sieve_data_type type;
union {
union
{
char *string;
size_t number;
mu_list_t list;
......@@ -81,22 +88,26 @@ typedef struct {
} v;
} mu_sieve_value_t;
typedef struct {
typedef struct
{
char *name;
mu_sieve_data_type argtype;
} mu_sieve_tag_def_t;
typedef struct {
typedef struct
{
mu_sieve_tag_def_t *tags;
mu_sieve_tag_checker_t checker;
} mu_sieve_tag_group_t;
struct mu_sieve_runtime_tag {
struct mu_sieve_runtime_tag
{
char *tag;
mu_sieve_value_t *arg;
};
typedef struct {
typedef struct
{
const char *name;
int required;
mu_sieve_handler_t handler;
......@@ -104,6 +115,8 @@ typedef struct {
mu_sieve_tag_group_t *tags;
} mu_sieve_register_t;
#define MU_SIEVE_CHARSET "UTF-8"
#define MU_SIEVE_MATCH_IS 1
#define MU_SIEVE_MATCH_CONTAINS 2
#define MU_SIEVE_MATCH_MATCHES 3
......@@ -112,7 +125,7 @@ typedef struct {
#define MU_SIEVE_MATCH_LAST 6
/* Debugging levels */
#define MU_SIEVE_DEBUG_TRACE 0x0001
#define MU_SIEVE_DEBUG_TRACE 0x0001
#define MU_SIEVE_DEBUG_INSTR 0x0002
#define MU_SIEVE_DEBUG_DISAS 0x0004
#define MU_SIEVE_DRY_RUN 0x0008
......@@ -123,10 +136,10 @@ extern mu_list_t mu_sieve_library_path;
/* Memory allocation functions */
void *mu_sieve_alloc (size_t size);
void *mu_sieve_palloc (mu_list_t *pool, size_t size);
void *mu_sieve_prealloc (mu_list_t *pool, void *ptr, size_t size);
void mu_sieve_pfree (mu_list_t *pool, void *ptr);
char *mu_sieve_pstrdup (mu_list_t *pool, const char *str);
void *mu_sieve_palloc (mu_list_t * pool, size_t size);
void *mu_sieve_prealloc (mu_list_t * pool, void *ptr, size_t size);
void mu_sieve_pfree (mu_list_t * pool, void *ptr);
char *mu_sieve_pstrdup (mu_list_t * pool, const char *str);
void *mu_sieve_malloc (mu_sieve_machine_t mach, size_t size);
char *mu_sieve_mstrdup (mu_sieve_machine_t mach, const char *str);
......@@ -134,61 +147,64 @@ void *mu_sieve_mrealloc (mu_sieve_machine_t mach, void *ptr, size_t size);
void mu_sieve_mfree (mu_sieve_machine_t mach, void *ptr);
mu_sieve_value_t *mu_sieve_value_create (mu_sieve_data_type type, void *data);
void mu_sieve_slist_destroy (mu_list_t *plist);
void mu_sieve_slist_destroy (mu_list_t * plist);
/* Symbol space functions */
mu_sieve_register_t *mu_sieve_test_lookup (mu_sieve_machine_t mach,
const char *name);
const char *name);
mu_sieve_register_t *mu_sieve_action_lookup (mu_sieve_machine_t mach,
const char *name);
const char *name);
int mu_sieve_register_test (mu_sieve_machine_t mach,
const char *name, mu_sieve_handler_t handler,
mu_sieve_data_type *arg_types,
mu_sieve_tag_group_t *tags, int required);
const char *name, mu_sieve_handler_t handler,
mu_sieve_data_type * arg_types,
mu_sieve_tag_group_t * tags, int required);
int mu_sieve_register_action (mu_sieve_machine_t mach,
const char *name, mu_sieve_handler_t handler,
mu_sieve_data_type *arg_types,
mu_sieve_tag_group_t *tags, int required);
const char *name, mu_sieve_handler_t handler,
mu_sieve_data_type * arg_types,
mu_sieve_tag_group_t * tags, int required);
int mu_sieve_register_comparator (mu_sieve_machine_t mach, const char *name,
int required, mu_sieve_comparator_t is,
mu_sieve_comparator_t contains,
mu_sieve_comparator_t matches,
mu_sieve_comparator_t regex,
mu_sieve_comparator_t eq);
int required, mu_sieve_comparator_t is,
mu_sieve_comparator_t contains,
mu_sieve_comparator_t matches,
mu_sieve_comparator_t regex,
mu_sieve_comparator_t eq);
int mu_sieve_require_action (mu_sieve_machine_t mach, const char *name);
int mu_sieve_require_test (mu_sieve_machine_t mach, const char *name);
int mu_sieve_require_comparator (mu_sieve_machine_t mach, const char *name);
int mu_sieve_require_relational (mu_sieve_machine_t mach, const char *name);
mu_sieve_comparator_t mu_sieve_comparator_lookup (mu_sieve_machine_t mach,
const char *name,
int matchtype);
mu_sieve_comparator_t mu_sieve_get_comparator (mu_sieve_machine_t mach, mu_list_t tags);
int mu_sieve_str_to_relcmp (const char *str,
mu_sieve_relcmp_t *test, mu_sieve_relcmpn_t *stest);
mu_sieve_relcmp_t mu_sieve_get_relcmp (mu_sieve_machine_t mach, mu_list_t tags);
const char *name,
int matchtype);
mu_sieve_comparator_t mu_sieve_get_comparator (mu_sieve_machine_t mach,
mu_list_t tags);
int mu_sieve_str_to_relcmp (const char *str, mu_sieve_relcmp_t * test,
mu_sieve_relcmpn_t * stest);
mu_sieve_relcmp_t mu_sieve_get_relcmp (mu_sieve_machine_t mach,
mu_list_t tags);
void mu_sieve_require (mu_list_t slist);
int mu_sieve_tag_lookup (mu_list_t taglist, char *name, mu_sieve_value_t **arg);
int mu_sieve_tag_lookup (mu_list_t taglist, char *name,
mu_sieve_value_t ** arg);
int mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name);
int mu_sieve_match_part_checker (const char *name, mu_list_t tags, mu_list_t args);
int mu_sieve_match_part_checker (const char *name, mu_list_t tags,
mu_list_t args);
/* Operations in value lists */
mu_sieve_value_t *mu_sieve_value_get (mu_list_t vlist, size_t index);
int mu_sieve_vlist_do (mu_sieve_value_t *val, mu_list_action_t *ac, void *data);
int mu_sieve_vlist_compare (mu_sieve_value_t *a, mu_sieve_value_t *b,
mu_sieve_comparator_t comp, mu_sieve_relcmp_t test,
mu_sieve_retrieve_t ac,
void *data,
size_t *count);
int mu_sieve_vlist_do (mu_sieve_value_t * val, mu_list_action_t * ac,
void *data);
int mu_sieve_vlist_compare (mu_sieve_value_t * a, mu_sieve_value_t * b,
mu_sieve_comparator_t comp,
mu_sieve_relcmp_t test, mu_sieve_retrieve_t ac,
void *data, size_t * count);
/* Functions to create and destroy sieve machine */
int mu_sieve_machine_init (mu_sieve_machine_t *mach, void *data);
void mu_sieve_machine_destroy (mu_sieve_machine_t *pmach);
int mu_sieve_machine_init (mu_sieve_machine_t * mach, void *data);
void mu_sieve_machine_destroy (mu_sieve_machine_t * pmach);
int mu_sieve_machine_add_destructor (mu_sieve_machine_t mach,
mu_sieve_destructor_t destr,
void *ptr);
mu_sieve_destructor_t destr, void *ptr);
/* Functions for accessing sieve machine internals */
void *mu_sieve_get_data (mu_sieve_machine_t mach);
......@@ -200,12 +216,16 @@ mu_mailer_t mu_sieve_get_mailer (mu_sieve_machine_t mach);
int mu_sieve_get_locus (mu_sieve_machine_t mach, mu_sieve_locus_t *);
char *mu_sieve_get_daemon_email (mu_sieve_machine_t mach);
const char *mu_sieve_get_identifier (mu_sieve_machine_t mach);
void mu_sieve_set_error (mu_sieve_machine_t mach, mu_sieve_printf_t error_printer);
void mu_sieve_set_parse_error (mu_sieve_machine_t mach, mu_sieve_parse_error_t p);
void mu_sieve_set_error (mu_sieve_machine_t mach,
mu_sieve_printf_t error_printer);
void mu_sieve_set_parse_error (mu_sieve_machine_t mach,
mu_sieve_parse_error_t p);
void mu_sieve_set_debug (mu_sieve_machine_t mach, mu_sieve_printf_t debug);
void mu_sieve_set_debug_level (mu_sieve_machine_t mach, mu_debug_t dbg, int level);
void mu_sieve_set_logger (mu_sieve_machine_t mach, mu_sieve_action_log_t logger);
void mu_sieve_set_debug_level (mu_sieve_machine_t mach, mu_debug_t dbg,
int level);
void mu_sieve_set_logger (mu_sieve_machine_t mach,
mu_sieve_action_log_t logger);
void mu_sieve_set_ticket (mu_sieve_machine_t mach, mu_ticket_t ticket);
void mu_sieve_set_mailer (mu_sieve_machine_t mach, mu_mailer_t mailer);
void mu_sieve_set_daemon_email (mu_sieve_machine_t mach, const char *email);
......@@ -217,11 +237,11 @@ int mu_sieve_get_message_sender (mu_message_t msg, char **ptext);
void mu_sieve_error (mu_sieve_machine_t mach, const char *fmt, ...);
void mu_sieve_debug (mu_sieve_machine_t mach, const char *fmt, ...);
void mu_sieve_log_action (mu_sieve_machine_t mach, const char *action,
const char *fmt, ...);
const char *fmt, ...);
void mu_sieve_abort (mu_sieve_machine_t mach);
int mu_stream_printf (mu_stream_t stream, size_t *off, const char *fmt, ...);
int mu_stream_printf (mu_stream_t stream, size_t * off, const char *fmt, ...);
void mu_sieve_arg_error (mu_sieve_machine_t mach, int n);
int mu_sieve_is_dry_run (mu_sieve_machine_t mach);
const char *mu_sieve_type_str (mu_sieve_data_type type);
......@@ -232,10 +252,10 @@ int mu_sieve_mailbox (mu_sieve_machine_t mach, mu_mailbox_t mbox);
int mu_sieve_message (mu_sieve_machine_t mach, mu_message_t message);
int mu_sieve_disass (mu_sieve_machine_t mach);
/* Command line handling */
/* Command line handling */
extern void mu_sieve_argp_init (void);
#ifdef __cplusplus
}
#endif
......