Slight contraction of gnc-module API.

Privatize structures that aren't used externally.  Remove unused functions. 



git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12368 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldfeatures/register-rewrite
Chris Shoemaker 21 years ago
parent 85c5bcd51c
commit 2bf2277660

@ -23,6 +23,15 @@
static GHashTable * loaded_modules = NULL;
static GList * module_info = NULL;
typedef struct {
char * module_path;
char * module_description;
char * module_filepath;
int module_interface;
int module_age;
int module_revision;
} GNCModuleInfo;
typedef struct
{
lt_dlhandle handle;
@ -32,6 +41,7 @@ typedef struct
int (* init_func)(int refcount);
} GNCLoadedModule;
static GNCModuleInfo * gnc_module_get_info(const char * lib_path);
/*************************************************************
* gnc_module_system_search_dirs
@ -192,15 +202,15 @@ gnc_module_system_refresh(void)
/* look in each search directory */
for(current = search_dirs; current; current = current->next)
{
DIR * d = opendir(current->data);
struct dirent * dent = NULL;
char * fullpath = NULL;
int namelen;
GNCModuleInfo * info;
if(d)
{
while((dent = readdir(d)) != NULL)
DIR *d = opendir(current->data);
struct dirent * dent = NULL;
char * fullpath = NULL;
int namelen;
GNCModuleInfo * info;
if (!d) continue;
while ((dent = readdir(d)) != NULL)
{
namelen = strlen(dent->d_name);
@ -221,7 +231,7 @@ gnc_module_system_refresh(void)
}
}
closedir(d);
}
}
/* free the search dir strings */
for(current = search_dirs; current; current=current->next)
@ -255,7 +265,7 @@ gnc_module_system_modinfo(void)
* if it's a gnc_module, return a struct describing it.
*************************************************************/
GNCModuleInfo *
static GNCModuleInfo *
gnc_module_get_info(const char * fullpath)
{
lt_dlhandle handle;
@ -568,38 +578,3 @@ gnc_module_unload(GNCModule module)
}
}
/*************************************************************
* gnc_module_lookup
* find a symbol in a module
*************************************************************/
void *
gnc_module_lookup(GNCModule module, gchar * symbol)
{
GNCLoadedModule * info;
lt_ptr ltptr;
if(!loaded_modules)
{
gnc_module_system_init();
}
if(module && symbol)
{
info = g_hash_table_lookup(loaded_modules, module);
if(info)
{
ltptr = lt_dlsym(info->handle, symbol);
return (void *)ltptr;
}
else
{
return NULL;
}
}
else
{
return NULL;
}
}

@ -16,15 +16,6 @@
typedef void * GNCModule;
typedef struct {
char * module_path;
char * module_description;
char * module_filepath;
int module_interface;
int module_age;
int module_revision;
} GNCModuleInfo;
#define DEFAULT_MODULE_PATH "/usr/local/gnucash/lib/modules"
/* the basics: initialize the module system, refresh its module
@ -43,11 +34,5 @@ GList * gnc_module_system_modinfo(void);
GNCModule gnc_module_load(gchar * module_name, gint interface);
GNCModule gnc_module_load_optional(gchar * module_name, gint interface);
int gnc_module_unload(GNCModule mod);
GNCModuleInfo * gnc_module_get_info(const char * lib_path);
int gnc_module_use_scm_module(gchar * module_path);
/* gnc_module_lookup locates the given 'symbol' in module
* 'mod'. 'mod' must be previously loaded. */
void * gnc_module_lookup(GNCModule mod, gchar * symbol);
#endif

@ -22,7 +22,6 @@
(re-export gnc:module-load)
(re-export gnc:module-load-optional)
(re-export gnc:module-unload)
(re-export gnc:module-lookup)
(define (gnc:module-system-init)
(let ((lib (if (or (string=? (version) "1.3")

@ -44,10 +44,5 @@
'((<gnc:module> module))
"Unreference a gnc-module. Module will unload when refcount goes to 0")
(gw:wrap-function
ws 'gnc:module-lookup
'<gw:void*> "gnc_module_lookup"
'((<gnc:module> module)
((<gw:mchars> caller-owned) symbol))
"Look up a symbol in the module. module must be loaded already."))
)

@ -8,8 +8,6 @@
static void
guile_main(void *closure, int argc, char ** argv)
{
int (*foo_hello)(void);
int helloval;
GNCModule foo;
printf(" test-load-c.c: testing module load/unload from C ... ");
@ -22,13 +20,6 @@ guile_main(void *closure, int argc, char ** argv)
printf(" Failed to load foo\n");
exit(-1);
}
foo_hello = gnc_module_lookup(foo, "foo_hello");
helloval = foo_hello();
if(helloval != 10) {
printf(" Call of module function failed.\n");
exit(-1);
}
if(!gnc_module_unload(foo)) {
printf(" Failed to unload foo\n");

Loading…
Cancel
Save