[Gnucash-changes] Minor code factoring patch from Chris Shoemaker.
David Hampton
hampton at cvs.gnucash.org
Thu Oct 13 23:53:23 EDT 2005
Log Message:
-----------
Minor code factoring patch from Chris Shoemaker.
Tags:
----
gnucash-gnome2-dev
Modified Files:
--------------
gnucash/src/gnc-module:
gnc-module.c
Revision Data
-------------
Index: gnc-module.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnc-module/gnc-module.c,v
retrieving revision 1.20.4.3
retrieving revision 1.20.4.4
diff -Lsrc/gnc-module/gnc-module.c -Lsrc/gnc-module/gnc-module.c -u -r1.20.4.3 -r1.20.4.4
--- src/gnc-module/gnc-module.c
+++ src/gnc-module/gnc-module.c
@@ -258,25 +258,35 @@
GNCModuleInfo *
gnc_module_get_info(const char * fullpath)
{
- lt_dlhandle handle;
+ lt_dlhandle handle;
+ lt_ptr modsysver;
//printf("(init) dlopening %s\n", fullpath);
handle = lt_dlopen(fullpath);
- if(handle)
- {
- lt_ptr modsysver = lt_dlsym(handle, "gnc_module_system_interface");
+ if (handle == NULL) {
+ g_warning ("Failed to dlopen() '%s': %s\n", fullpath, lt_dlerror());
+ return NULL;
+ }
+
+ modsysver = lt_dlsym(handle, "gnc_module_system_interface");
- /* the modsysver tells us what the expected symbols and their
- * types are */
- if (!modsysver)
- {
+ /* the modsysver tells us what the expected symbols and their
+ * types are */
+ if (!modsysver) {
//printf("(init) closing %s\n", fullpath);
//lt_dlclose(handle);
return NULL;
- }
+ }
- if(*(int *)modsysver == 0)
- {
+ if (*(int *)modsysver != 0) {
+ /* unsupported module system interface version */
+ /* printf("\n** WARNING ** : module '%s' requires newer module system\n",
+ fullpath); */
+ //lt_dlclose(handle);
+ return NULL;
+ }
+
+ {
lt_ptr initfunc = lt_dlsym(handle, "gnc_module_init");
lt_ptr pathfunc = lt_dlsym(handle, "gnc_module_path");
lt_ptr descripfunc = lt_dlsym(handle, "gnc_module_description");
@@ -284,43 +294,29 @@
lt_ptr revision = lt_dlsym(handle, "gnc_module_revision");
lt_ptr age = lt_dlsym(handle, "gnc_module_age");
- if(initfunc && pathfunc && descripfunc && interface &&
- revision && age)
- {
- /* we have found a gnc_module. */
- GNCModuleInfo * info = g_new0(GNCModuleInfo, 1);
- char * (* f_path)(void) = pathfunc;
- char * (* f_descrip)(void) = descripfunc;
- info->module_path = f_path();
- info->module_description = f_descrip();
- info->module_filepath = g_strdup(fullpath);
- info->module_interface = *(int *)interface;
- info->module_age = *(int *)age;
- info->module_revision = *(int *)revision;
- //printf("(init) closing %s\n", fullpath);
- //lt_dlclose(handle);
- return info;
+ if (!(initfunc && pathfunc && descripfunc && interface &&
+ revision && age)) {
+ g_warning ("module '%s' does not match module signature\n",
+ fullpath);
+ //lt_dlclose(handle);
+ return NULL;
}
- else
+
{
- g_warning ("module '%s' does not match module signature\n", fullpath);
- //lt_dlclose(handle);
- return NULL;
+ /* we have found a gnc_module. */
+ GNCModuleInfo * info = g_new0(GNCModuleInfo, 1);
+ char * (* f_path)(void) = pathfunc;
+ char * (* f_descrip)(void) = descripfunc;
+ info->module_path = f_path();
+ info->module_description = f_descrip();
+ info->module_filepath = g_strdup(fullpath);
+ info->module_interface = *(int *)interface;
+ info->module_age = *(int *)age;
+ info->module_revision = *(int *)revision;
+ //printf("(init) closing %s\n", fullpath);
+ //lt_dlclose(handle);
+ return info;
}
- }
- else
- {
- /* unsupported module system interface version */
- /* printf("\n** WARNING ** : module '%s' requires newer module system\n",
- fullpath); */
- //lt_dlclose(handle);
- return NULL;
- }
- }
- else
- {
- g_warning ("Failed to dlopen() '%s': %s\n", fullpath, lt_dlerror());
- return NULL;
}
}
More information about the gnucash-changes
mailing list