| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This subsection describes functions used to create an instance of the sieve machine, read or alter its internal fields and destroy it.
The 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 sieve_machine_destroy()
pmach contains NULL. The destructors registered with
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
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 = sieve_malloc (mach, sizeof (*regex));
/* Make sure it will be freed when necessary */
sieve_machine_add_destructor (sieve_machine, free_regex, regex);
.
.
.
}
|
sieve_machine_init().
sieve_message, this function returns 1.
int
_sieve_default_error_printer (void *unused, const char *fmt,
va_list ap)
{
return mu_verror (fmt, ap);
}
|
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;
}
|
NULL which means no
debugging information will be displayed.
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
MU_SIEVE_DEBUG_INSTR
MU_SIEVE_DEBUG_DISAS
MU_SIEVE_DRY_RUN
NULL, which means that the executed actions are not logged.
"sendmail:".
reject and
redirect actions.
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 calling sieve_set_debug_level() if its last argument has
the MU_SIEVE_DRY_RUN bit set.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |