Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / core / modules.h
index 7a83819f61a6f5b1030f5ef7b362904ef2392c21..75a77c7752dc74d649c4a25d74155d3ad42c7872 100644 (file)
 #define MODULE_DATA_SET(rec, data) \
        g_hash_table_insert((rec)->module_data, MODULE_NAME, data)
 
+#define MODULE_DATA_UNSET(rec) \
+       g_hash_table_remove((rec)->module_data, MODULE_NAME)
+
 #define MODULE_DATA(rec) \
        g_hash_table_lookup((rec)->module_data, MODULE_NAME)
 
+
+#ifdef HAVE_GMODULE
+#  define MODULE_IS_STATIC(rec) \
+        ((rec)->gmodule == NULL)
+#else
+#  define MODULE_IS_STATIC(rec) TRUE
+#endif
+
 enum {
        MODULE_ERROR_ALREADY_LOADED,
        MODULE_ERROR_LOAD,
        MODULE_ERROR_INVALID
 };
 
+typedef struct _MODULE_REC MODULE_REC;
+
 typedef struct {
+       MODULE_REC *root;
        char *name;
+        char *defined_module_name;
+       void (*module_deinit) (void);
+
 #ifdef HAVE_GMODULE
-       GModule *gmodule;
+       GModule *gmodule; /* static, if NULL */
 #endif
-} MODULE_REC;
+       unsigned int initialized:1;
+} MODULE_FILE_REC;
+
+struct _MODULE_REC {
+       char *name;
+        GSList *files; /* list of modules that belong to this root module */
+};
 
 extern GSList *modules;
 
-MODULE_REC *module_find(const char *name);
+/* Register a new module. The `name' is the root module name, `submodule'
+   specifies the current module to be registered (eg. "perl", "fe").
+   The module is registered as statically loaded by default. */
+MODULE_FILE_REC *module_register_full(const char *name, const char *submodule,
+                                     const char *defined_module_name);
+#define module_register(name, submodule) \
+        module_register_full(name, submodule, MODULE_NAME)
 
-/* Load module - automatically tries to load also the related non-core
-   modules given in `prefixes' (like irc, fe, fe_text, ..) */
-int module_load(const char *path, char **prefixes);
-void module_unload(MODULE_REC *module);
+MODULE_REC *module_find(const char *name);
+MODULE_FILE_REC *module_file_find(MODULE_REC *module, const char *name);
 
 #define MODULE_CHECK_CAST(object, cast, type_field, id) \
        ((cast *) module_check_cast(object, offsetof(cast, type_field), id))