Re: g_module in GTK 1.2
- From: Harring Figueiredo <harringf yahoo com>
- To: hopeye cfl rr com, gtk-app-devel-list gnome org
- Subject: Re: g_module in GTK 1.2
- Date: Fri, 14 Jun 2002 06:49:28 -0700 (PDT)
Take a look at the code testgmodule.c , it is on the 1.2.10 distribution under
the gmodule directory.
I think that the example is a little too much since it checks for all the
platforms, thus it defeats the purpose of using the API; therefore, it is not
really a good example.
If you take a look at the API doc, you will realize that the code takes care
of platfom differences. Having said that, here is a little my own example.
NOTE: pg is my own struct with the fowllowing:
strcut _plugin
{
char* shlib_path; /* the path where the loadable lib is */
char* shlib; /* the plugin itself -- leave the prefix "lib" and the
suffix ".so" out for maximum portability - glib adds those for us depending on
the platform we are. */
GModule* module /* handle to the module */
(int)(entry_func)(void* data)... /* init function on the plugin.*/
...
};
/* here is the code to load the module */
if( g_module_supported() == FALSE)
{
fprintf(stderr, "Plataform does not support loading of shared
libraries. ");
return -1;
}
path = g_module_build_path(pg->shlib_path, pg->shlib);
g_return_val_if_fail(path != NULL, -1);
pg->module = (GModule *)g_module_open(path, G_MODULE_BIND_LAZY);
g_return_val_if_fail(pg->module != NULL, -1);
/* find the function symbol */
if (g_module_symbol(pg->module, pg->entry_func, &f_ptr) == FALSE)
{
fprintf(stderr, "File: %s, Line: %d - Could not find function name
[%s] on plugin %s." __FILE__, __LINE__, pg->entry_func, pg->name)
return -1;
}
Harring.
==================
Hope this help.
--- Jim Parker <hopeye cfl rr com> wrote:
G'Day !
I am looking for a small program that uses GLIB's g_module API. I need the
functionality in my program and would like a simple example of how use the
API.
Any suggestions ? Tried Abiword, but code base is too complicated to be
useful.
BTW is the 1.2 tutorial still available on-line ?
cheers,
Jim Parker
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]