4 #define MODULE_DATA_INIT(rec) \
5 (rec)->module_data = g_hash_table_new(g_str_hash, g_str_equal)
7 #define MODULE_DATA_DEINIT(rec) \
8 g_hash_table_destroy((rec)->module_data)
10 #define MODULE_DATA_SET(rec, data) \
11 g_hash_table_insert((rec)->module_data, MODULE_NAME, data)
13 #define MODULE_DATA_UNSET(rec) \
14 g_hash_table_remove((rec)->module_data, MODULE_NAME)
16 #define MODULE_DATA(rec) \
17 g_hash_table_lookup((rec)->module_data, MODULE_NAME)
21 # define MODULE_IS_STATIC(rec) \
22 ((rec)->gmodule == NULL)
24 # define MODULE_IS_STATIC(rec) TRUE
28 MODULE_ERROR_ALREADY_LOADED,
33 typedef struct _MODULE_REC MODULE_REC;
38 char *defined_module_name;
39 void (*module_deinit) (void);
42 GModule *gmodule; /* static, if NULL */
44 unsigned int initialized:1;
49 GSList *files; /* list of modules that belong to this root module */
52 extern GSList *modules;
54 /* Register a new module. The `name' is the root module name, `submodule'
55 specifies the current module to be registered (eg. "perl", "fe").
56 The module is registered as statically loaded by default. */
57 MODULE_FILE_REC *module_register_full(const char *name, const char *submodule,
58 const char *defined_module_name);
59 #define module_register(name, submodule) \
60 module_register_full(name, submodule, MODULE_NAME)
62 MODULE_REC *module_find(const char *name);
63 MODULE_FILE_REC *module_file_find(MODULE_REC *module, const char *name);
65 #define MODULE_CHECK_CAST(object, cast, type_field, id) \
66 ((cast *) module_check_cast(object, offsetof(cast, type_field), id))
67 #define MODULE_CHECK_CAST_MODULE(object, cast, type_field, module, id) \
68 ((cast *) module_check_cast_module(object, \
69 offsetof(cast, type_field), module, id))
70 void *module_check_cast(void *object, int type_pos, const char *id);
71 void *module_check_cast_module(void *object, int type_pos,
72 const char *module, const char *id);
74 /* return unique number across all modules for `id' */
75 int module_get_uniq_id(const char *module, int id);
76 /* return unique number across all modules for `id'. */
77 int module_get_uniq_id_str(const char *module, const char *id);
79 /* returns the original module specific id, -1 = not found */
80 int module_find_id(const char *module, int uniqid);
81 /* returns the original module specific id, NULL = not found */
82 const char *module_find_id_str(const char *module, int uniqid);
84 /* Destroy unique IDs from `module'. This function is automatically called
85 when module is destroyed with module's name as the parameter. */
86 void module_uniq_destroy(const char *module);
88 void modules_init(void);
89 void modules_deinit(void);