Sieve 2 API: Functions
extern int sieve2_alloc(sieve2_context_t **c); extern int sieve2_free(sieve2_context_t **c);
Allocates and frees the basic context which carries through all of the
functions and callbacks in libSieve. At this time, the core parsers are not
thread-safe; only one instance may be allocated per-process.
extern int sieve2_callbacks(sieve2_context_t *c, sieve2_callback_t *callbacks); extern char * sieve2_listextensions(sieve2_context_t *c);
Registers a table of callbacks. See the structures page for details.
After a table of callbacks is registered, the extensions for which callbacks
have been registered will be listed by sieve2_listextensions.
extern int sieve2_validate(sieve2_action_t *c, void *user_data); extern int sieve2_execute(sieve2_action_t *c, void *user_data);
Validate a script and execute a script over a message. Validation will
only call the getscript callback, while execution will call getscript and
either getallheaders or getheader, then call the appropriate action callbacks.
The user_data you provide here will be passed into each of the callbacks.
The way to use this is to set up your own structure which contains
information the script and message you are currently working with. As the
callbacks are called, your functions, which know about your structure, can
figure out what they should be doing.
extern int sieve2_getvalue_int(sieve2_context_t *c, const char * const name); extern char * sieve2_getvalue_string(sieve2_context_t *c, const char * const name); extern char * * sieve2_getvalue_stringlist(sieve2_context_t *c, const char * const name);
The getvalue family of functions allow you to retrieve information
about the callback being called. All of the memory returned by these
functions are managed by libSieve and will be freed by calling sieve2_free.
See the structures page for a listing of value names available to each
callback.
extern int sieve2_setvalue_int(sieve2_context_t *c, const char * const name, int value); extern int sieve2_setvalue_string(sieve2_context_t *c, const char * const name, const char * const value); extern int sieve2_setvalue_stringlist(sieve2_context_t *c, const char * const name, const char * const * const value);
The setvalue family of functions allows you to return values into
libSieve from your callbacks. This is your memory, and must be freed after
calling sieve2_free.
See the structures page for a listing of value names available to each
callback.
extern char * sieve2_errstr(const int code);
Convert an error code to a generic description of the error.
Detailed error reports are found in the sieve2_error array. Do not free the
returned string, it is static.
extern char * sieve2_credits(void); extern char * sieve2_license(void);
Get a list of Credits about who writes libSieve
and a brief rundown on the License under which
libSieve is distributed. Do not free the returned string, it is static.
|