[Gnucash-changes] r12368 - gnucash/trunk/src/gnc-module - Slight
contraction of gnc-module API.
Chris Shoemaker
chris at cvs.gnucash.org
Mon Jan 16 11:30:13 EST 2006
Author: chris
Date: 2006-01-16 11:30:12 -0500 (Mon, 16 Jan 2006)
New Revision: 12368
Trac: http://svn.gnucash.org/trac/changeset/12368
Modified:
gnucash/trunk/src/gnc-module/gnc-module.c
gnucash/trunk/src/gnc-module/gnc-module.h
gnucash/trunk/src/gnc-module/gnc-module.scm
gnucash/trunk/src/gnc-module/gw-gnc-module-spec.scm
gnucash/trunk/src/gnc-module/test/test-load-c.c
Log:
Slight contraction of gnc-module API.
Privatize structures that aren't used externally. Remove unused functions.
Modified: gnucash/trunk/src/gnc-module/gnc-module.c
===================================================================
--- gnucash/trunk/src/gnc-module/gnc-module.c 2006-01-16 14:42:43 UTC (rev 12367)
+++ gnucash/trunk/src/gnc-module/gnc-module.c 2006-01-16 16:30:12 UTC (rev 12368)
@@ -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 @@
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 @@
/* 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 @@
}
}
closedir(d);
- }
+
}
/* free the search dir strings */
for(current = search_dirs; current; current=current->next)
@@ -255,7 +265,7 @@
* 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_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;
- }
-}
Modified: gnucash/trunk/src/gnc-module/gnc-module.h
===================================================================
--- gnucash/trunk/src/gnc-module/gnc-module.h 2006-01-16 14:42:43 UTC (rev 12367)
+++ gnucash/trunk/src/gnc-module/gnc-module.h 2006-01-16 16:30:12 UTC (rev 12368)
@@ -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 @@
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
Modified: gnucash/trunk/src/gnc-module/gnc-module.scm
===================================================================
--- gnucash/trunk/src/gnc-module/gnc-module.scm 2006-01-16 14:42:43 UTC (rev 12367)
+++ gnucash/trunk/src/gnc-module/gnc-module.scm 2006-01-16 16:30:12 UTC (rev 12368)
@@ -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")
Modified: gnucash/trunk/src/gnc-module/gw-gnc-module-spec.scm
===================================================================
--- gnucash/trunk/src/gnc-module/gw-gnc-module-spec.scm 2006-01-16 14:42:43 UTC (rev 12367)
+++ gnucash/trunk/src/gnc-module/gw-gnc-module-spec.scm 2006-01-16 16:30:12 UTC (rev 12368)
@@ -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."))
+)
Modified: gnucash/trunk/src/gnc-module/test/test-load-c.c
===================================================================
--- gnucash/trunk/src/gnc-module/test/test-load-c.c 2006-01-16 14:42:43 UTC (rev 12367)
+++ gnucash/trunk/src/gnc-module/test/test-load-c.c 2006-01-16 16:30:12 UTC (rev 12368)
@@ -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 @@
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");
More information about the gnucash-changes
mailing list