+Thu Jun 10 21:29:55 2004 Matthias Clasen <maclas@gmx.de>
+
+ * glib/tmpl/modules.sgml: Add an example for GModule
+ usage. (#144127, Tommi Komulainen)
+
Sun Jun 6 23:20:42 2004 Matthias Clasen <maclas@gmx.de>
* gobject/tmpl/gtype.sgml: Fix the docs for G_DEFINE_TYPE()
it must ensure that it is never unloaded, by calling g_module_make_resident().
</para>
+<para>
+<example>
+<title>Calling a function defined in a <structname>GModule</structname></title>
+<programlisting>
+/* the function signature for 'say_hello' */
+typedef void (* SayHelloFunc) (const char *message);
+
+gboolean
+just_say_hello (const char *filename, GError **error)
+{
+ SayHelloFunc say_hello;
+ GModule *module;
+
+ module = g_module_open (filename, G_MODULE_BIND_LAZY);
+ if (!module)
+ {
+ g_set_error (error, FOO_ERROR, FOO_ERROR_BLAH,
+ "%s", g_module_error (<!-- -->));
+ return FALSE;
+ }
+
+ if (!g_module_symbol (module, "say_hello", (gpointer *)&say_hello))
+ {
+ g_set_error (error, SAY_ERROR, SAY_ERROR_OPEN,
+ "%s: %s", filename, g_module_error (<!-- -->));
+ if (!g_module_close (module))
+ g_warning ("%s: %s", filename, g_module_error (<!-- -->));
+ return FALSE;
+ }
+
+ /* call our function in the module */
+ say_hello ("Hello world!");
+
+ if (!g_module_close (module))
+ g_warning ("%s: %s", filename, g_module_error (<!-- -->));
+
+ return TRUE;
+}
+</programlisting>
+</example>
+</para>
+
<!-- ##### SECTION See_Also ##### -->
<para>