Commit ebc5307d ebc5307dba077c2fb4ef5d79f793d3ec6758f342 by Sergey Poznyakoff

(sieve_require_action, sieve_require_test): New functions.

1 parent d92cbeef
......@@ -26,6 +26,9 @@
extern "C" {
#endif
#define __s_cat3__(a,b,c) a ## b ## c
#define SIEVE_EXPORT(module,name) __s_cat3__(module,_LTX_,name)
typedef struct sieve_machine *sieve_machine_t;
typedef int (*sieve_handler_t) __PMT((sieve_machine_t mach,
......@@ -137,6 +140,8 @@ int sieve_register_comparator __P((sieve_machine_t mach,
sieve_comparator_t contains,
sieve_comparator_t matches,
sieve_comparator_t regex));
int sieve_require_action __P((sieve_machine_t mach, const char *name));
int sieve_require_test __P((sieve_machine_t mach, const char *name));
int sieve_require_comparator __P((sieve_machine_t mach, const char *name));
sieve_comparator_t sieve_comparator_lookup __P((sieve_machine_t mach,
......@@ -148,6 +153,7 @@ sieve_comparator_t sieve_get_comparator __P((sieve_machine_t mach,
void sieve_require __P((list_t slist));
int sieve_tag_lookup __P((list_t taglist, char *name, sieve_value_t **arg));
int sieve_load_ext __P((sieve_machine_t mach, const char *name));
/* Operations in value lists */
sieve_value_t *sieve_value_get __P((list_t vlist, size_t index));
......@@ -201,6 +207,7 @@ int sieve_mailbox __P((sieve_machine_t mach, mailbox_t mbox));
int sieve_message __P((sieve_machine_t mach, message_t message));
int sieve_disass __P((sieve_machine_t mach));
#ifdef __cplusplus
}
#endif
......
......@@ -26,7 +26,7 @@
#include <sieve.h>
static sieve_register_t *
sieve_lookup (list_t list, const char *name)
reg_lookup (list_t list, const char *name)
{
iterator_t itr;
sieve_register_t *reg;
......@@ -49,15 +49,42 @@ sieve_lookup (list_t list, const char *name)
sieve_register_t *
sieve_test_lookup (sieve_machine_t mach, const char *name)
{
return sieve_lookup (mach->test_list, name);
return reg_lookup (mach->test_list, name);
}
sieve_register_t *
sieve_action_lookup (sieve_machine_t mach, const char *name)
{
return sieve_lookup (mach->action_list, name);
return reg_lookup (mach->action_list, name);
}
static int
reg_require (sieve_machine_t mach, list_t list, const char *name)
{
sieve_register_t *reg = reg_lookup (list, name);
if (!reg)
{
if (!(sieve_load_ext (mach, name) == 0
&& (reg = reg_lookup (list, name)) != NULL))
return 1;
}
reg->required = 1;
return 0;
}
int
sieve_require_action (sieve_machine_t mach, const char *name)
{
return reg_require (mach, mach->action_list, name);
}
int
sieve_require_test (sieve_machine_t mach, const char *name)
{
return reg_require (mach, mach->test_list, name);
}
static int
sieve_register (list_t *pool,
list_t *list,
......