src/module.h
changeset 83 c8e2dac08207
parent 70 a9a4c5e6aa30
child 87 f0db6ebf18b9
equal deleted inserted replaced
82:bc767e01648d 83:c8e2dac08207
     4 /**
     4 /**
     5  * @file
     5  * @file
     6  *
     6  *
     7  * Dynamically loadable modules for use with nexus.
     7  * Dynamically loadable modules for use with nexus.
     8  *
     8  *
     9  * The modules are loaded using dlopen(), and hence should be standard dynamic libraries. Module initialization happens
     9  * The modules are loaded using dlopen(), and hence should be standard dynamic libraries. Modules are then "loaded" by
    10  * using a module_init_func_t named "<name>_init", which should return some kind of context pointer, which can later be
    10  * resolving a `struct module_funcs` symbol called '<modname>_funcs', and then using the init func to construct a
    11  * used to perform other operations on the module.
    11  * "context", which is then further manipulated by various other module functions.
    12  */
    12  */
    13 #include "nexus.h"
    13 #include "nexus.h"
       
    14 #include "config.h"
    14 #include "error.h"
    15 #include "error.h"
    15 
    16 
    16 #include <sys/queue.h>
    17 #include <sys/queue.h>
    17 
    18 
    18 /**
    19 /**
    27 };
    28 };
    28 
    29 
    29 /**
    30 /**
    30  * A module's behaviour is defined as a set of function pointers, which is dynamically resolved from the module DSO,
    31  * A module's behaviour is defined as a set of function pointers, which is dynamically resolved from the module DSO,
    31  * using the <mod_name>_funcs symbol.
    32  * using the <mod_name>_funcs symbol.
       
    33  *
       
    34  * XXX: this also includes non-functions now...
    32  */
    35  */
    33 struct module_funcs {
    36 struct module_funcs {
    34     /**
    37     /**
    35      * Initialize the module, returning an opaque context pointer that is stored in the module state, and supplied for
    38      * Initialize the module, returning an opaque context pointer that is stored in the module state, and supplied for
    36      * subsequent calls. The supplied nexus arg can be used to access the global state.
    39      * subsequent calls. The supplied nexus arg can be used to access the global state.
    53      * @param name the name of the configuration setting
    56      * @param name the name of the configuration setting
    54      * @param value the value of the configuration setting
    57      * @param value the value of the configuration setting
    55      * @param err returned error info
    58      * @param err returned error info
    56      */
    59      */
    57     err_t (*conf) (void *ctx, const char *name, char *value, struct error_info *err);
    60     err_t (*conf) (void *ctx, const char *name, char *value, struct error_info *err);
       
    61 
       
    62     /**
       
    63      * Optionally, a module may also provide some kind of list of available configuration parameters, by setting this
       
    64      * to a pointer to an array of those.
       
    65      */
       
    66     const struct config_option *config_options;
    58 
    67 
    59     /**
    68     /**
    60      * Unload the module, removing all handlers/callbacks added to the nexus' irc_client. This does not have to act
    69      * Unload the module, removing all handlers/callbacks added to the nexus' irc_client. This does not have to act
    61      * immediately, and will still have access to all irc_* resources it had earlier, and may perform I/O to unload
    70      * immediately, and will still have access to all irc_* resources it had earlier, and may perform I/O to unload
    62      * cleanly. But the unloading should complete reasonably quickly, after which all event handlers added by the
    71      * cleanly. But the unloading should complete reasonably quickly, after which all event handlers added by the