Next: Logging and Diagnostic Functions, Previous: Sieve Data Types, Up: libsieve
This subsection describes functions used to create an instance of the sieve machine, read or alter its internal fields and destroy it.
The
mu_sieve_machine_init()
function creates an instance of a sieve machine. A pointer to the instance itself is returned in the argument mach. The user-specific data to be associated with the new machine are passed in data argument. The function returns 0 on success, non-zero error code otherwise,
This function destroys the instance of sieve machine pointed to by mach parameter. After execution of
mu_sieve_machine_destroy()
pmach containsNULL
. The destructors registered withmu_sieve_machine_add_destructor()
are executed in lifo order.
This function registers a destructor function dest. The purpose of the destructor is to free any resources associated with the item ptr. The destructor function takes a single argument — a pointer to the data being destroyed. All registered destructors are called in reverse order upon execution of
mu_sieve_machine_destroy()
. Here's a short example of the use of this function:static void free_regex (void *data) { regfree ((regex_t*)data); } int match_part_checker (const char *name, list_t tags, list_t args) { regex_t *regex; /* Initialise the regex: */ regex = mu_sieve_malloc (mach, sizeof (*regex)); /* Make sure it will be freed when necessary */ mu_sieve_machine_add_destructor (sieve_machine, free_regex, regex); . . . }
This function returns the application-specific data associated with the instance of sieve machine. See
mu_sieve_machine_init()
.
This function returns the current message.
This function returns the current message number in the mailbox. If there are no mailbox, i.e. the execution of the sieve code is started with
mu_sieve_message
, this function returns 1.
Returns the debug level set for this instance of sieve machine.
Returns the authentication ticket for this machine.
Returns the locus in the Sieve source file corresponding to the code pointer where the Sieve machine currently is.
This function returns the daemon email associated with this instance of sieve machine. The daemon email is an email address used in envelope from addresses of automatic reply messages. By default its local part is ‘<MAILER-DAEMON>’ and the domain part is the machine name.
This function sets the error printer function for the machine. If it is not set, the default error printer will be used. It is defined as follows:
int _sieve_default_error_printer (void *unused, const char *fmt, va_list ap) { return mu_verror (fmt, ap); }
This function sets the parse error printer function for the machine. If it is not set, the default parse error printer will be used. It is defined as follows:
int _sieve_default_parse_error (void *unused, const char *filename, int lineno, const char *fmt, va_list ap) { if (filename) fprintf (stderr, "%s:%d: ", filename, lineno); vfprintf (stderr, fmt, ap); fprintf (stderr, "\n"); return 0; }
This function sets the debug printer function for the machine. If it is not set, the default debug printer is
NULL
which means no debugging information will be displayed.
This function sets the debug level for the given instance of sieve machine. The dbg argument is the
mu_debug_t
object to be used with mailutils library, the level argument specifies the debugging level for the sieve library itself. It is a bitwise or of the following values:
MU_SIEVE_DEBUG_TRACE
- Trace the execution of the sieve script.
MU_SIEVE_DEBUG_INSTR
- Print the sieve machine instructions as they are executed.
MU_SIEVE_DEBUG_DISAS
- Dump the disassembled code of the sieve machine. Do not run it.
MU_SIEVE_DRY_RUN
- Do not executed the actions, only show what would have been done.
This function sets the logger function. By default the logger function is
NULL
, which means that the executed actions are not logged.
This function sets the authentication ticket to be used with this machine.
This function sets the mailer. The default mailer is
"sendmail:"
.
This functions sets the daemon email for
reject
andredirect
actions.
The
mu_sieve_is_dry_run()
returns 1 if the machine is in dry run state, i.e. it will only log the actions that would have been executed without actually executing them. The dry run state is set by callingmu_sieve_set_debug_level()
if its last argument has theMU_SIEVE_DRY_RUN
bit set.