src/module.h
changeset 100 cfb7776bd6f0
parent 87 f0db6ebf18b9
child 103 454aea1e4f11
--- a/src/module.h	Tue Mar 31 23:35:24 2009 +0300
+++ b/src/module.h	Tue Mar 31 23:36:05 2009 +0300
@@ -28,12 +28,10 @@
 };
 
 /**
- * A table of (function) pointers defining a module's behaviour. This is dynamically resolved from the module DSO
- * using the "<mod_name>_funcs" symbol.
- *
- * XXX: this also includes non-functions now...
+ * A table of (function/other) pointers defining a module's behaviour. This is dynamically resolved from the module DSO
+ * using the "<mod_name>_module" symbol.
  */
-struct module_funcs {
+struct module_desc {
     /**
      * Initialize the module, returning an opaque context pointer that is stored in the module state, and supplied for
      * subsequent calls. The supplied nexus arg can be used to access the global state.
@@ -45,23 +43,10 @@
     err_t (*init) (struct nexus *nexus, void **ctx_ptr, struct error_info *err);
 
     /**
-     * Set a configuration option with the given name and value, given by the user. Configuration settings are not
-     * regarded as unique-per-name, but rather, several invocations of 'conf' with the same name and different values
-     * could set up a multitude of things.
-     *
-     * The given value is either a NUL-terminated string value (which may be mutated, using e.g. strsep), or NULL if
-     * no value was given (flag option).
+     * A module may define a set of available configuration parameters for use by module_conf, by setting this to an
+     * array of config_option's.
      *
-     * @param ctx the module's context pointer as returned by init
-     * @param name the name of the configuration setting
-     * @param value the value of the configuration setting
-     * @param err returned error info
-     */
-    err_t (*conf) (void *ctx, const char *name, char *value, struct error_info *err);
-
-    /**
-     * Optionally, a module may also provide some kind of list of available configuration parameters, by setting this
-     * to a pointer to an array of those.
+     * The handler functions will recieve the module's context pointer as their ctx argument.
      */
     const struct config_option *config_options;
 
@@ -86,8 +71,8 @@
     /** The dlopen handle */
     void *handle;
 
-    /** The resolved function table */
-    struct module_funcs *funcs;
+    /** The module entry point */
+    struct module_desc *desc;
 
     /** The module context object */
     void *ctx;
@@ -95,6 +80,11 @@
     /** Reference back to modules struct used to load this module */
     struct modules *modules;
 
+    /**
+     * Is the module currently being unloaded?
+     */
+    bool unloading;
+
     /** Our entry in the list of modules */
     TAILQ_ENTRY(module) modules_list;
 };
@@ -164,9 +154,19 @@
 struct module* module_get (struct modules *modules, const char *name);
 
 /**
- * Set a module configuration option
+ * Look up a module configuration option by name
  */
-err_t module_conf (struct module *module, const char *name, char *value, struct error_info *err);
+const struct config_option* module_conf_lookup (struct module *module, const char *name, struct error_info *err);
+
+/**
+ * Apply a module configuration option using a structured value
+ */
+err_t module_conf (struct module *module, const struct config_option *opt, const struct config_value *value, struct error_info *err);
+
+/**
+ * Set a module configuration option using a raw value
+ */
+err_t module_conf_raw (struct module *module, const char *name, char *value, struct error_info *err);
 
 /**
  * Unload a module. This means calling its 'unload' func, which will then go about shutting down the module. This might