Chapter 25. Amanda Event API Prev Part V. Technical Background Next ------------------------------------------------------------------------------- Chapter 25. Amanda Event API Mike Grupenhoff Original text AMANDA Core Team Stefan G. Weichinger XML-conversion;Updates AMANDA Core Team Table of Contents Introduction The_API event_register event_release event_loop event_wait event_wakeup Data_types event_handle_t event_id_t event_type_t event_fn_t Event_Types EV_READFD EV_WRITEFD EV_SIG EV_TIME EV_WAIT Introduction This is a document of the API for the event handler. The purpose of the event handler is to allow scheduling and serialization of multiple different types of events. The API event_register event_handle_t *event_register(event_id_t data, event_type_t type, event_fn_t callback, void *arg); Sets up an event of the given type to call the given function with the given argument. The 'data' argument is type specific. EV_READFD, EV_WRITEFD - the file descriptor to monitor EV_SIG - the signal number to monitor EV_TIME - the number of seconds between each pulse EV_WAIT - the wait identifier used with event_wakeup() EV_DEAD - internal use only event_release void event_release(event_handle_t *handle); Remove an event from the queue. This can happen at any time, even while the event is firing. event_loop void event_loop(int dontblock); Process all pending events. If the argument is zero, this will keep running until all events have been released. If the argument is nonzero, this will do one pass over all pending events, and fire the ones that are immediately ready, and then return. event_wait void event_wait(event_id_t id); Like event_loop(0), except that it will stop as soon as the event id is serviced. event_wakeup int event_wakeup(event_id_t id); Fire all EV_WAIT events registered with an argument value of 'id' immediately. Returns the number of events that were fired. Data types event_handle_t This is an opaque structure that describes a registered event. It is only useful to keep if you need to unregister the event later. event_id_t This is type-specific data. The contents and format depend on on the type of the event. This is an unsigned integral type. event_type_t This is an enumerated type describing the different events we handle. event_fn_t typedef void (*event_fn_t)(void *arg); This is a function signature for the type of function that needs to get passed to event_register. The argument to the function is a pointer of the caller's choosing. Event Types EV_READFD This type of event will fire when the file descriptor passed to event_register has data waiting to be read. EV_WRITEFD This type of event will fire when the file descriptor passed to event_register can have data written to it without blocking. EV_SIG This type of event will fire when the signal number passed to event_register has been caught. Note that if a signal is caught while processing is not in event_loop(), the event will be delayed until processing returns to event_loop (). EV_TIME This type of event will fire repeatedly with a delay of the number of seconds passed to event_register between each interval. EV_WAIT This type of event will fire when someone calls event_wakeup() with the numeric argument equal to the argument this event was registered with. Note Refer to http://www.amanda.org/docs/eventapi.html for the current version of this document. ------------------------------------------------------------------------------- Prev Up Next Chapter 24. Amanda Internals Home Chapter 26. Amanda Security API