Next: Manipulating the Sieve Machine, Up: libsieve
This is an opaque data type representing a pointer to an instance of sieve machine. The
sieve_machine_tkeeps all information necessary for compiling and executing the script.It is created by
sieve_machine_create()and destroyed bysieve_machine_destroy(). The functions for manipulating this data type are described in Manipulating the Sieve Machine.
This enumeration keeps the possible types of sieve data. These are:
SVT_VOID- No datatype.
SVT_NUMBER- Numeric type.
SVT_STRING- Character string.
SVT_STRING_LIST- A
mu_list_t. Each item in this list represents a character string.SVT_TAG- A sieve tag. See
mu_sieve_runtime_tag_tbelow.SVT_IDENT- A character string representing an identifier.
SVT_VALUE_LIST- A
mu_list_t. Each item in this list is ofmu_sieve_value_ttype.SVT_POINTER- An opaque pointer.
The
mu_sieve_value_tkeeps an instance of sieve data. It is defined as follows:typedef struct { mu_sieve_data_type type; /* Type of the data */ union { char *string; /* String value or identifier */ size_t number; /* Numeric value */ mu_list_t list; /* List value */ mu_sieve_runtime_tag_t *tag; /* Tag value */ void *ptr; /* Pointer value */ } v; } mu_sieve_value_t;Depending on the value of
typemember, following members of the unionvkeep the actual value:
SVT_VOID- Never appears.
SVT_NUMBER- The numeric value is kept in
numbermember.SVT_STRING- The string is kept in
stringmember.SVT_STRING_LISTSVT_VALUE_LIST- The list itself is pointed to by
listmemberSVT_TAG- The tag value is pointed to by
tagmember.SVT_IDENT- The
stringmember points to the identifier name.SVT_POINTER- The data are pointed to by
ptrmember.
This structure represents a definition of a tagged (optional) argument to a sieve action or test. It is defined as follows:
typedef struct { char *name; /* Tag name */ mu_sieve_data_type argtype; /* Type of tag argument. */ } mu_sieve_tag_def_t;The
namemember points to the tag's name without leading colon. Theargtypeis set toSVT_VOIDif the tag does not take argument, or to the type of the argument otherwise.
This structure represents the tagged (optional) argument at a runtime. It is defined as:
struct mu_sieve_runtime_tag { char *tag; /* Tag name */ mu_sieve_value_t *arg; /* Tag argument (if any) */ };The
argmember isNULLif the tag does not take an argument.
Objects of this type represent a location in the Sieve source file:
typedef struct { const char *source_file; size_t source_line; } mu_sieve_locus_t;
This is a pointer to function handler for a sieve action or test. It is defined as follows:
typedef int (*mu_sieve_handler_t) (mu_sieve_machine_t mach, mu_list_t args, mu_list_t tags);The arguments to the handler have the following meaning:
- mach
- Sieve machine being processed.
- args
- A list of required arguments to the handler
- tags
- A list of optional arguments (tags).
A pointer to a diagnostic output function. It is defined as follows:
typedef int (*mu_sieve_printf_t) (void *data, const char *fmt, va_list ap);
- data
- A pointer to application specific data. These data are passed as second argument to
mu_sieve_machine_init().- fmt
- Printf-like format string.
- ap
- Other arguments.
This data type is declared as follows:
typedef int (*mu_sieve_parse_error_t) (void *data, const char *filename, int lineno, const char *fmt, va_list ap);It is used to declare error handlers for parsing errors. The application-specific data are passed in the data argument. Arguments filename and line indicate the location of the error in the source text, while fmt and ap give verbose description of the error.
A pointer to the application-specific logging function:
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);
- data
- Application-specific data.
- locus
- Location in the Sieve source file.
- script
- Name of the sieve script being executed.
- msgno
- Ordinal number of the message in mailbox, if appropriate. When execution is started using
sieve_message(), this argument is zero.- msg
- The message this action is executed upon.
- action
- The name of the action.
- fmt
- var
- These two arguments give the detailed description of the action.
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 *);A pointer to the comparator handler function. The function compares its two operands and returns 1 if they are equal, and 0 otherwise. Notice, that the sense of the return value is inverted in comparison with most standard libc functions like
stcmp(), etc.
typedef int (*mu_sieve_retrieve_t) (void *item, void *data, int idx, char **pval);A pointer to generic retriever function. See description of
mu_sieve_vlist_compare()for details of its usage.
typedef void (*mu_sieve_destructor_t) (void *data);A pointer to destructor function. The function frees any resources associated with
data. See the description ofmu_sieve_machine_add_destructor()for more information.
typedef int (*mu_sieve_tag_checker_t) (const char *name, mu_list_t tags, mu_list_t args)A pointer to tag checker function. The purpose of the function is to perform compilation-time consistency test on tags. Its arguments are:
- name
- Name of the test or action whose tags are being checked.
- tags
- A list of
mu_sieve_runtime_tag_trepresenting tags.- args
- A list of
mu_sieve_value_trepresenting required arguments to name.The function is allowed to make any changes in tags and args. It should return 0 if the syntax is correct and non-zero otherwise. It is responsible for issuing the diagnostics in the latter case. [FIXME: describe how to do that]