lib   S i e v e
   h o m e   |   a p i d o c s   |   s c r i p t s   |   l i c e n s e   |   d o w n l o a d   |   g i t h u b   |   s o u r c e f o r g e
e x a m p l e .  

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.

n o t e s .  
The Sieve 2 API is an extensible API designed to ride through revisions in the underlying implementation and through updates to the Sieve RFC and various extensions, as they move from drafts towards full RFC's. The API has three main parts: the incomplete opaque internal types, the complete and user accessible external structures and the function calls.
API Functions

API Structures

Example App

l i n k s .  
Sieve Homepage

Cyrus Project

GNU Mailutils

Network World Chaos article

Network World Gearhead article
template © 2002 by artwiz of oswd -- contents © 2002, 2003 by aaron stone