src/module.h
changeset 70 a9a4c5e6aa30
parent 66 ef8c9d7daf62
child 83 c8e2dac08207
equal deleted inserted replaced
69:6f298b6e0d5f 70:a9a4c5e6aa30
    53      * @param name the name of the configuration setting
    53      * @param name the name of the configuration setting
    54      * @param value the value of the configuration setting
    54      * @param value the value of the configuration setting
    55      * @param err returned error info
    55      * @param err returned error info
    56      */
    56      */
    57     err_t (*conf) (void *ctx, const char *name, char *value, struct error_info *err);
    57     err_t (*conf) (void *ctx, const char *name, char *value, struct error_info *err);
       
    58 
       
    59     /**
       
    60      * 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
       
    62      * cleanly. But the unloading should complete reasonably quickly, after which all event handlers added by the
       
    63      * module to the nexus' ev_base should have been removed, and resources released.
       
    64      *
       
    65      * @param ctx the module's context pointer as returned by init
       
    66      */
       
    67     err_t (*unload) (void *ctx);
    58 };
    68 };
    59 
    69 
    60 /**
    70 /**
    61  * A loaded module.
    71  * A loaded module.
    62  */
    72  */
    70     /** The resolved function table */
    80     /** The resolved function table */
    71     struct module_funcs *funcs;
    81     struct module_funcs *funcs;
    72 
    82 
    73     /** The module context object */
    83     /** The module context object */
    74     void *ctx;
    84     void *ctx;
       
    85 
       
    86     /** Reference back to modules struct used to load this module */
       
    87     struct modules *modules;
    75 
    88 
    76     /** Our entry in the list of modules */
    89     /** Our entry in the list of modules */
    77     TAILQ_ENTRY(module) modules_list;
    90     TAILQ_ENTRY(module) modules_list;
    78 };
    91 };
    79 
    92 
   145  * Set a module configuration option
   158  * Set a module configuration option
   146  */
   159  */
   147 err_t module_conf (struct module *module, const char *name, char *value, struct error_info *err);
   160 err_t module_conf (struct module *module, const char *name, char *value, struct error_info *err);
   148 
   161 
   149 /**
   162 /**
   150  * Unload a module
   163  * Unload a module. This means calling its 'unload' func, which will then go about shutting down the module. This might
       
   164  * not happen right away, though, so the module is not destroyed yet.
   151  *
   165  *
   152  * XXX: not implemented
   166  * XXX: currently the module is never destroyed, there needs to be a "module unload done" callback...
   153  */
   167  */
   154 err_t module_unload (struct module *module);
   168 err_t module_unload (struct module *module);
   155 
   169 
       
   170 /**
       
   171  * Destroy a module, releasing as many resources as possible
       
   172  */
       
   173 void module_destroy (struct module *module);
       
   174 
       
   175 /**
       
   176  * Unload all modules, this just calls module_unload for each module, logging errors as warnings.
       
   177  *
       
   178  * XXX: currently, this does not destroy any modules, or the modules state itself.
       
   179  */
       
   180 err_t modules_unload (struct modules *modules);
       
   181 
   156 #endif
   182 #endif