Details
mon_module
typedef struct {
/* These should be the first field */
mon_api_category api_category : 16;
int api_version : 16;
const char *name;
int ver_major;
int ver_minor;
unsigned int flags;
int (*module_init)(mon_module *module,
mon_cfg_node *cfg);
void (*module_done)(mon_module *module);
const mon_cfg_desc *parameters;
int refcnt;
} mon_module;
Information about aloadable module.
| mon_api_category api_category : 16; | the mon_api_category the module uses.
|
| int api_version : 16; | the API version the module implements.
|
| const char *name; | the name of the module.
|
| int ver_major; | the module's major version number.
|
| int ver_minor; | the module's minor version number.
|
| unsigned int flags; | module flags.
|
| module_init () | the module's initialization function.
|
| module_done () | the module's finalization function.
|
| const mon_cfg_desc *parameters; | list of module parameter descriptors.
|
| int refcnt; | reference count.
|
enum mon_api_category
typedef enum {
MON_API_REGISTRY,
MON_API_AUTH_CLIENT,
MON_API_AUTH_SERVER,
MON_API_PROTO_CONSUMER,
MON_API_PROTO_PRODUCER,
MON_API_SENSOR,
MON_API_ACTUATOR,
MON_API_REGISTRY_PRODUCER
} mon_api_category;
API categories used in the monitoring system.
| MON_API_REGISTRY | the registry API.
|
| MON_API_AUTH_CLIENT | the client-side authentication API.
|
| MON_API_AUTH_SERVER | the server-side authentication API.
|
| MON_API_PROTO_CONSUMER | the consumer-side protocol API.
|
| MON_API_PROTO_PRODUCER | the producer-side protocol API.
|
| MON_API_SENSOR | the sensor API.
|
| MON_API_ACTUATOR | the actuator API.
|
| MON_API_REGISTRY_PRODUCER | the async registry API.
|
MON_MODSYM()
#define MON_MODSYM(a)
This macro helps static linking. If a module is linked statically, the name of
the module is appended to the symbol to make it unique.
| a : | a symbol name that is exported by a module.
|
mon_symbol_info
typedef struct {
const char *description;
const char *symbol;
int init_order;
int (*mod_register)(mon_module *module);
void (*mod_unregister)(mon_module *module);
} mon_symbol_info;
Describes a symbol that is exported by a module.
| const char *description; | description of this symbol.
|
| const char *symbol; | the name of the symbol.
|
| int init_order; | number defining the initialization order.
|
| mod_register () | function to call when this symbol is found in a module.
|
| mod_unregister () | function to call when the module is about to be unloaded.
|
mon_module_load ()
int mon_module_load (const char *filename,
const mon_symbol_info symbols[],
mon_cfg_node *config,
GList **modules);
Loads a module.
| filename : | name of the DSO to load.
|
| symbols : | description of the symbols to look for.
|
| config : | configuration information for this DSO.
|
| modules : | list to append all modules that has been found.
|
| Returns : | 0 if successful or an error code.
|
mon_module_scan ()
int mon_module_scan (mon_cfg_node *cfgroot,
const mon_symbol_info symbols[],
int def_autoload,
GList **modules);
Scans a directory for modules to load.
This function examines every shared object in the mod_path directory and looks
for the symbols named sym_names. If all the requested symbols were found in
the module, their values along are passed to the cb function along with the file
name and the supplied cb_arg pointer. If the callback function returns 0, the
module is registered as loaded; otherwise, the module is unloaded.
| cfgroot : | root of the configuration tree that contains the configuration of modules.
|
| symbols : | desrcription of the symbols to look for.
|
| def_autoload : | default value for autoload.
|
| modules : | pointer to store the list of loaded mon_module descriptors if successful.
|
| Returns : | 0 if successful or an error code.
|
mon_module_init ()
int mon_module_init (mon_module *module);
Initializes a loaded module.
| module : | a mon_module.
|
| Returns : | 0 if successful or an error code.
|
mon_module_ref ()
void mon_module_ref (mon_module *module);
Increments the reference count of a mon_module.
mon_module_done ()
void mon_module_done (mon_module *module);
Decrements the reference count of a mon_module. If the reference count reaches
zero, the module is unloaded.
mon_module_list ()
char** mon_module_list (void);
Returns the list of currently loaded modules.
| Returns : | a NULL-terminated list of modules.
|
mon_modlog()
#define mon_modlog(level, fmt, ...)
Convinience function for modules. It calls mon_log() with the given arguments
but precedes every message with the module name.
| level : | the severity of the message.
|
| fmt : | the format string.
|
| ... : | variadic parameters matching the format string.
|
mon_static_file
typedef struct {
const char *const name;
const mon_static_symtab *const symtab;
} mon_static_file;
Describes a statically linked module.
| const char *const name; | the virtual filename of the module.
|
| const mon_static_symtab *const symtab; | the list of symbols this module exports.
|
mon_static_symtab
typedef struct {
const char *const name;
const void *value;
} mon_static_symtab;
Describes a symbol for a statically linked module.
| const char *const name; | the name of the symbol.
|
| const void *value; | the value of the symbol.
|
mon_module_register_static ()
void mon_module_register_static (const mon_static_file *filetab);
Registers a statically linked module.
| filetab : | list of mon_static_file entries to register. The list must be terminated by
an entry that has its name field set to NULL.
|