Files | |
file | event.h |
Core event system header file. | |
Data Structures | |
struct | _ev_englist_s |
Event context engine list structure. More... | |
struct | _ev_ctx_s |
Event context structure. More... | |
struct | _event_s |
Event structure. More... | |
struct | _ev_genhdr_s |
Event generator header structure. More... | |
Defines | |
#define | EV_CTX_MAGIC |
Event context magic number. | |
#define | EV_CTX_SECURE |
Secure operation flag. | |
#define | EV_CTX_RUNNING |
Library running flag. | |
#define | ec_verify(ctx) |
Event context verification macro. | |
#define | ec_flags(ctx) |
Event context flags. | |
#define | ec_prog(ctx) |
Event Context application name. | |
#define | ec_conf(ctx) |
Event Context configuration. | |
#define | EVENT_MAGIC |
Event magic number. | |
#define | ev_verify(event) |
Event verification macro. | |
#define | ev_context(event) |
Event context. | |
#define | ev_type(event) |
Event type. | |
#define | ev_generator(event) |
Event generator. | |
#define | ev_paramtype(event) |
Event parameter type. | |
#define | ev_intparam(event) |
Event parameter: integer. | |
#define | ev_ptrparam(event) |
Event parameter: pointer. | |
#define | EV_GEN_ACTIVE |
Generator in use. | |
#define | EV_GEN_DELETED |
Generator deleted. | |
#define | _eg_hdr(gen) |
Generator header. | |
#define | eg_verify(gen, magic) |
Generator verification macro. | |
#define | eg_type(gen) |
Generator type. | |
#define | eg_flags(gen) |
Generator flags. | |
#define | eg_flags_set(gen, fl) |
Set generator flags. | |
#define | eg_flags_clr(gen, fl) |
Clear generator flags. | |
#define | eg_next(gen) |
Next generator. | |
#define | eg_prev(gen) |
Previous generator. | |
#define | eg_context(gen) |
Generator context. | |
#define | eg_ref(gen) |
Retrieve reference count. | |
#define | eg_ref_inc(ctx, gen) |
Increment reference count. | |
#define | eg_ref_dec(ctx, gen) |
Decrement reference count. | |
#define | eg_callback(gen) |
Generator callback. | |
#define | eg_callback_set(gen, call) |
Set generator callback. | |
#define | eg_calldata(gen) |
Generator callback data. | |
#define | eg_calldata_set(gen, data) |
Set generator callback data. | |
#define | EV_INIT_SECURE |
Secure operation flag. | |
Typedefs | |
typedef _ev_ctx_s | ev_ctx_t |
Event context. | |
typedef _ev_englist_s | _ev_englist_t |
Event context engine list. | |
typedef _ev_attr_s * | ev_attr_t |
Event context attributes. | |
typedef _event_s | event_t |
Event structure. | |
typedef _ev_genhdr_s | ev_genhdr_t |
Generator header. | |
typedef unsigned int | ev_err_t |
Event errors. | |
typedef unsigned long | ev_magic_t |
Event magic number. | |
typedef unsigned long | ev_flags_t |
Event flags. | |
typedef void(* | ev_call_t )(ev_ctx_t *ctx, event_t *event, void *data) |
Event callbacks. | |
typedef void(* | ev_log_t )(const char *file, int line, const char *func, const char *msg) |
Library logging. | |
typedef void(* | ev_freegen_t )(ev_ctx_t *ctx, void *gen) |
Generator release callback. | |
Enumerations | |
enum | ev_type_t { ET_NONE, ET_READ, ET_WRITE, ET_ACCEPT, ET_CONNECT, ET_EOF, ET_ERROR, ET_SIGNAL, ET_EXPIRE, ET_RESERVED, ET_USER } |
Event types. More... | |
enum | ev_paramtype_t { EP_NONE, EP_INT, EP_PTR } |
Event parameter types. More... | |
enum | ev_gentype_t { EGT_NONE, EGT_SOCKET, EGT_SIGNAL, EGT_TIMER, EGT_RESERVED, EGT_USER } |
Generator types. More... | |
Functions | |
ev_err_t | event_init (ev_ctx_t *ctx, const ev_attr_t *attr, ev_flags_t flags, const char *prog, const char *envpath) |
Initialize events library. | |
ev_err_t | event_destroy (ev_ctx_t *ctx) |
Release memory used by events library context. | |
ev_err_t | event_attr_init (ev_attr_t *attr) |
Initialize a set of attributes for the events library. | |
ev_err_t | event_attr_confpath (ev_attr_t *attr, const char **path) |
Retrieve and/or set default configuration search path. | |
ev_err_t | event_attr_libpath (ev_attr_t *attr, const char **path) |
Retrieve and/or set default module search path. | |
ev_err_t | event_attr_modlist (ev_attr_t *attr, const char **list) |
Retrieve and/or set default module list. | |
ev_err_t | event_attr_confreg (ev_attr_t *attr, const char *name, const char *def, treeconf_nodown_t nodown, treeconf_change_t change, void *assoc) |
Register a treeconf variable for the application. | |
ev_err_t | event_attr_confvar (ev_attr_t *attr, const char *name, const char *value) |
Override a treeconf variable setting. | |
ev_err_t | event_attr_destroy (ev_attr_t *attr) |
Destroy an attribute set and release all allocated memory. | |
ev_err_t | event_gen_register (ev_ctx_t *ctx, unsigned int gentype, ev_magic_t genmagic, size_t gensize, ev_freegen_t genrel) |
Register a generator. | |
ev_err_t | event_gen_alloc (ev_ctx_t *ctx, unsigned int gentype, void *gen) |
Allocate a generator. | |
ev_err_t | event_gen_release (ev_ctx_t *ctx, ev_genhdr_t *gen) |
Release a generator. | |
ev_err_t | event_log_set (ev_log_t logger) |
Set a logging function. | |
ev_err_t | event_log_reset (void) |
Reset library logging. | |
ev_err_t | event_log_debug (int onoff) |
Turn library logging on or off. | |
ev_err_t | event_log_trace (int onoff) |
Turn library function tracing on or off. | |
ev_err_t | event_log_abort (int onoff) |
Turn library abort on or off. |
|
For internal use only. This macro retrieves a pointer to an ev_genhdr_t given a generator. (All generators MUST begin with an ev_genhdr_t!)
|
|
This macro retrieves a pointer to a treeconf_ctx_t containing the current configuration of the library. See the treeconf_ctx_t documentation for more information.
Definition at line 478 of file event.h. Referenced by event_destroy(), and event_init(). |
|
This macro retrieves the flags set for the ev_ctx_t.
Definition at line 453 of file event.h. Referenced by event_destroy(). |
|
This macro retrieves the application name set with the call to event_init().
|
|
This macro verifies that a given pointer actually does point to an ev_ctx_t.
Definition at line 443 of file event.h. Referenced by engine_activate(), engine_register(), event_destroy(), event_gen_alloc(), event_gen_register(), event_gen_release(), main(), signal_create(), signal_destroy(), timer_create(), timer_destroy(), and timer_resched(). |
|
This macro returns a pointer to the event callback function for the generator.
|
|
This macro may be used to set the generator callback function.
Definition at line 783 of file event.h. Referenced by signal_create(), and timer_create(). |
|
This macro returns a pointer to application-specific data to be passed to the event callback function. It may be used as an lvalue to set this data.
|
|
This macro may be used to set the generator callback function data.
Definition at line 808 of file event.h. Referenced by signal_create(), and timer_create(). |
|
This macro returns a pointer to the context associated with the generator.
Definition at line 725 of file event.h. Referenced by signal_destroy(), timer_destroy(), and timer_resched(). |
|
This macro returns the flags set for the generator.
Definition at line 672 of file event.h. Referenced by signal_destroy(), timer_destroy(), and timer_resched(). |
|
This macro clears a specific (or a set of specific) flags on the given generator.
Definition at line 692 of file event.h. Referenced by timer_resched(). |
|
This macro sets a specific (or a set of specific) flags on the given generator.
Definition at line 682 of file event.h. Referenced by signal_destroy(), timer_destroy(), and timer_resched(). |
|
This macro returns a pointer to the next generator in the generator linked list.
|
|
This macro returns a pointer to the previous generator in the generator linked list.
|
|
This macro returns the reference count for the generator.
|
|
This macro decrements the reference count for a generator. If the reference count hits zero and the EV_GEN_DELETED flag is set, the generator will be released by a call to event_gen_release().
Definition at line 757 of file event.h. Referenced by signal_destroy(), timer_destroy(), and timer_resched(). |
|
This macro simply increments the reference count for the generator.
Definition at line 746 of file event.h. Referenced by signal_create(), and timer_create(). |
|
This macro returns the type of generator described by the argument
|
|
This macro verifies a generator to ensure that the pointer actually belongs to the specified type of generator.
Definition at line 648 of file event.h. Referenced by event_gen_release(). |
|
This macro retrieves the context from the given
|
|
This is the magic number used for the event context structure. Definition at line 415 of file event.h. Referenced by event_init(). |
|
This flag, if set, indicates that the library is running. Definition at line 429 of file event.h. Referenced by event_destroy(). |
|
This flag, if set, indicates that the library has been configured for secure operation. This may be done by passing the EV_INIT_SECURE flag to event_init(). Definition at line 423 of file event.h. Referenced by event_init(). |
|
This flag is used to indicate that a given generator is in use by the library. Definition at line 612 of file event.h. Referenced by event_gen_release(). |
|
This flag is used by generator handlers to indicate that a given generator is in the process of being deleted. Definition at line 619 of file event.h. Referenced by signal_destroy(), timer_destroy(), and timer_resched(). |
|
This macro retrieves the responsible generator from the given
|
|
This flag is used to advise the library that the program is being run setuid. Certain insecure elements of the file list will be skipped, and the EV_CTX_SECURE flag of the context structure will be set for the benefit of other library code. Definition at line 880 of file event.h. Referenced by event_init(). |
|
This macro retrieves an integer parameter from the given
|
|
This macro retrieves the type of parameter associated with the given
|
|
This macro retrieves a pointer parameter from the given
|
|
This macro retrieves the event type from the given
|
|
This macro verifies that a given pointer actually does point to an event_t.
|
|
This is the magic number used for the event structure. |
|
For internal use only. This type is a helper type for the event context structure. It is used to represent a list of active event engines. |
|
Event context attributes is a catch-all for configuration of the event library at initialization time. If a |
|
Generators may optionally have a callback associated with them. (Callbacks are required if the library is operated in event loop mode.) All callbacks are pointers to functions taking a pointer to the event context and a pointer to the event for which the callback is being called, along with a generic pointer for user-defined data.
|
|
The event context structure is the core of the event system. Virtually every function in the library requires a pointer to an initialized context. It is initialized with the event_init() function and destroyed with event_destroy(). |
|
Almost all functions in the library have an error code as a return value. This error code may be passed to com_err() and related functions, if the library has been compiled with com_err() support, to generate error messages. A 0 return value always means "Success." |
|
Several functions and some structures use flags to modify behavior or store boolean (on or off) information. This type is large enough to store up to 32 different flags. |
|
The library keeps a list of active generators. When event_destroy() is called, a generator-specific release function may be called. This type is a pointer to a generator-specific release function for active generators.
|
|
All events are associated with a generator. Generators are abstract objects, such as sockets, that generate events, such as readability. All generators must begin with an instance of the ev_genhdr_t structure containing a unique magic number. |
|
The library includes support for self-debugging. By default, logs will be written to
|
|
This type is used for structure magic numbers. |
|
This is the workhorse of the library. All events are represented by an instance of this structure. It is returned by event_poll() and is passed to callback functions. |
|
All generators have an generator type describing the kind of generator. Generator typess in the range from EGT_RESERVED to EGT_USER (10-100) are reserved for application libraries, such as resolvers. Generator types above EGT_USER (100) are specifically reserved for applications. All generators must be registered using event_gen_register() in order to allocate space for the generator linked list. |
|
Events may optionally have a parameter. This enumeration specifies the generic type of this parameter. |
|
All events have an event type describing the kind of event that was generated. Event types in the range from ET_RESERVED to ET_USER (100-1000) are reserved for application libraries, such as resolvers. Event types above ET_USER (1000) are specifically reserved for applications.
|
|
The event_init() function loads several configuration files, based on a specified search path and a compiled-in default. This compiled-in default may be examined or overridden using this function.
Definition at line 32 of file event_attr_confpath.c. References ea_confpath, ea_verify, ev_init, and ev_return. Referenced by main(). |
|
The event_init() function registers a couple of library-specific treeconf configuration variables. This function enables the application to specify a list of variables to be registered for its use. Note that any errors will only be discovered by event_init().
Definition at line 35 of file event_attr_confreg.c. References ea_varlist, ea_verify, ev_init, ev_return, _ev_varlist_s::vl_assoc, _ev_varlist_s::vl_change, _ev_varlist_s::vl_default, _ev_varlist_s::vl_name, _ev_varlist_s::vl_next, _ev_varlist_s::vl_nodown, and _ev_varlist_s::vl_prev_p. Referenced by main(). |
|
Applications may desire to use some other form of configuration, rather than treeconf configuration files. This function allows the application to explicitly override the value of any variable in the configuration file(s) loaded by event_init(). Note that any errors will only be discovered by event_init().
Definition at line 35 of file event_attr_confvar.c. References ea_ovars, ea_verify, ev_init, ev_return, _ev_overvars_s::ov_name, _ev_overvars_s::ov_next, _ev_overvars_s::ov_prev_p, and _ev_overvars_s::ov_value. Referenced by main(). |
|
The memory allocated by event_attr_init() must be released to the system with a call to this function.
Definition at line 35 of file event_attr_destroy.c. References ea_ovars, ea_varlist, ea_verify, ev_init, ev_return, _ev_overvars_s::ov_next, and _ev_varlist_s::vl_next. Referenced by main(). |
|
The event_init() function takes an optional set of attributes that may be used to configure various aspects of the library. This routine is used to create an attribute set which may be manipulated and then passed to event_init(). Note that this function allocates memory that must be returned to the system by calling event_attr_destroy() once event_init() returns.
Definition at line 34 of file event_attr_init.c. References _ev_defattr, ev_init, and ev_return. Referenced by main(). |
|
The event_init() function loads several modules, based on a module search path and a list of modules to load. The compiled-in default for the module search path may be examined or overridden using this function.
Definition at line 32 of file event_attr_libpath.c. References ea_libpath, ea_verify, ev_init, and ev_return. Referenced by main(). |
|
The event_init() function loads several modules, based on a module search path and a list of modules to load. The compiled-in default for the module list may be examined or overridden using this function.
Definition at line 32 of file event_attr_modlist.c. References ea_modlist, ea_verify, ev_init, and ev_return. Referenced by main(). |
|
|
This function will allocate a generator of the given type, initializing all the common header components as necessary. In cooperation with event_gen_release(), it maintains a free list to help reduce memory fragmentation.
Definition at line 34 of file event_gen_alloc.c. References _ev_gen_lookup(), ec_verify, _ev_genhdr_s::eg_next, _ev_genhdr_s::eg_prev, ev_assert, ev_gen_init, ev_init, ev_return, _ev_gendesc_s::gd_active, _ev_gendesc_s::gd_free, _ev_gendesc_s::gd_size, _ev_genlist_s::gl_count, and _ev_genlist_s::gl_list. Referenced by main(), signal_create(), and timer_create(). Here is the call graph for this function: ![]() |
|
Generators must be registered with the library before they may be used. This function is used to register a generator. Part of the reason for this is free list management.
Definition at line 270 of file event_gen_register.c. References _ev_ctx_s::ec_gens, ec_verify, EGT_NONE, ev_assert, ev_init, ev_return, generator::genmagic, generator::genrel, gens_construct(), gens_extend(), gens_merge(), generator::gensize, generator::gentype, _ev_gens_s::gs_count, _ev_gens_s::gs_first, and _ev_gens_s::gs_next. Referenced by event_init(), and main(). Here is the call graph for this function: ![]() |
|
This function will release a generator allocated by event_gen_alloc(). It maintains a free list in cooperation with event_gen_alloc() in order to reduce memory fragmentation.
Definition at line 34 of file event_gen_release.c. References _ev_gen_lookup(), ec_verify, _ev_genhdr_s::eg_flags, _ev_genhdr_s::eg_next, _ev_genhdr_s::eg_prev, _ev_genhdr_s::eg_type, eg_verify, EV_GEN_ACTIVE, ev_init, ev_return, _ev_gendesc_s::gd_active, _ev_gendesc_s::gd_free, _ev_gendesc_s::gd_magic, _ev_genlist_s::gl_count, and _ev_genlist_s::gl_list. Referenced by main(), signal_create(), and timer_create(). Here is the call graph for this function: ![]() |
|
This function is used to initialize the library context. It will load configuration data from all the files listed in the
Definition at line 333 of file event_init.c. References ea_confpath, ea_engines, ea_libpath, ea_modlist, ea_ovars, ea_varlist, ea_verify, ec_conf, _ev_ctx_s::ec_engine, _ev_ctx_s::ec_evcnt, _ev_ctx_s::ec_evs, _ev_ctx_s::ec_flags, _ev_ctx_s::ec_gens, _ev_ctx_s::ec_magic, _ev_ctx_s::ec_maxgen, _ev_ctx_s::ec_prog, _ev_ctx_s::ec_signal, _ev_ctx_s::ec_socket, _ev_ctx_s::ec_timer, _ev_ctx_s::ec_timtree, EGT_SIGNAL, EGT_SOCKET, EGT_TIMER, _ev_englist_s::el_first, _ev_englist_s::el_last, _ev_englink_s::el_next, _ev_engine_s::eng_list, engine_load(), engine_register(), englink_clr, EV_CTX_LTDLINIT, EV_CTX_MAGIC, EV_CTX_SECURE, EV_ENGINE_COMPMASK, ev_init, EV_INIT_SECURE, ev_return, EV_SIG_MAGIC, EV_SOCK_MAGIC, EV_TIM_MAGIC, event_destroy(), event_gen_register(), new_modvar(), _ev_overvars_s::ov_name, _ev_overvars_s::ov_next, _ev_overvars_s::ov_value, substs, tc_break(), tc_get(), tc_init, tc_load(), tc_path(), TC_PATH_ALL, TC_PATH_SECURE, tc_register(), tc_set(), TC_SUBST_IGNORE, TC_SUBST_INIT, TC_SUBST_INSECURE, tu_flags, tu_value, VAR_LIBPATH, VAR_MODLIST, VAR_MODULES, _ev_varlist_s::vl_assoc, _ev_varlist_s::vl_change, _ev_varlist_s::vl_default, _ev_varlist_s::vl_name, _ev_varlist_s::vl_next, and _ev_varlist_s::vl_nodown. Referenced by main(). Here is the call graph for this function: ![]() |
|
The library contains its own implementation of the C assert() macro. In particular, this macro results in a return (with the
Definition at line 120 of file event_log.c. References _ev_asflags, ev_init, ev_return, and EVAS_ABORT. Referenced by main(). |
|
By default, library logging is turned off. This function allows the caller to turn library logging on or off, depending on the value of the
Definition at line 92 of file event_log.c. References _ev_asflags, ev_init, ev_return, and EVAS_LOG. Referenced by main(). |
|
This function resets the library logging to its default values--using a logging function that writes to
Definition at line 80 of file event_log.c. References _ev_asflags, _ev_debuglog, deflog(), ev_init, ev_return, EVAS_LOG, and EVAS_TRACE. Referenced by main(). Here is the call graph for this function: ![]() |
|
This function is used to set the library logging callback. It will also implicitly turn on debug logging, as if event_log_debug() was called with a
Definition at line 68 of file event_log.c. References _ev_asflags, _ev_debuglog, ev_init, ev_return, and EVAS_LOG. Referenced by main(). |
|
The library is capable of logging each function entry. By default, this functionality is turned off. This function allows the caller to turn library function tracing on or off, depending on the value of the
Definition at line 106 of file event_log.c. References _ev_asflags, ev_init, ev_return, and EVAS_TRACE. Referenced by main(). |