Main Page | Class List | Directories | File List | Class Members | File Members

gmodule-dld.c File Reference

#include <dl.h>

Go to the source code of this file.

Defines

#define DYNAMIC_PATH   0
#define BIND_RESTRICTED   0
#define OPT_BIND_FLAGS   (BIND_NONFATAL | BIND_VERBOSE)

Functions

static gpointer _g_module_open (const gchar *file_name, gboolean bind_lazy)
static gpointer _g_module_self (void)
static void _g_module_close (gpointer handle, gboolean is_unref)
static gpointer _g_module_symbol (gpointer handle, const gchar *symbol_name)
static gchar_g_module_build_path (const gchar *directory, const gchar *module_name)


Define Documentation

#define BIND_RESTRICTED   0
 

Definition at line 63 of file gmodule-dld.c.

#define DYNAMIC_PATH   0
 

Definition at line 60 of file gmodule-dld.c.

#define OPT_BIND_FLAGS   (BIND_NONFATAL | BIND_VERBOSE)
 

Definition at line 66 of file gmodule-dld.c.

Referenced by _g_module_open().


Function Documentation

static gchar* _g_module_build_path const gchar directory,
const gchar module_name
[static]
 

Definition at line 138 of file gmodule-dld.c.

References g_strconcat(), g_strdup(), and NULL.

00140 {
00141   if (directory && *directory)
00142     if (strncmp (module_name, "lib", 3) == 0)
00143       return g_strconcat (directory, "/", module_name, NULL);
00144     else
00145       return g_strconcat (directory, "/lib", module_name, ".sl", NULL);
00146   else if (strncmp (module_name, "lib", 3) == 0)
00147     return g_strdup (module_name);
00148   else
00149     return g_strconcat ("lib", module_name, ".sl", NULL);
00150 }

static void _g_module_close gpointer  handle,
gboolean  is_unref
[static]
 

Definition at line 100 of file gmodule-dld.c.

References g_module_set_error(), and g_strerror().

00102 {
00103   if (!is_unref)
00104     {
00105       if (shl_unload ((shl_t) handle) != 0)
00106         g_module_set_error (g_strerror (errno));
00107     }
00108 }

static gpointer _g_module_open const gchar file_name,
gboolean  bind_lazy
[static]
 

Definition at line 71 of file gmodule-dld.c.

References g_module_set_error(), g_strerror(), and OPT_BIND_FLAGS.

00073 {
00074   shl_t shl_handle;
00075   
00076   shl_handle = shl_load (file_name,
00077                          (bind_lazy ? BIND_DEFERRED : BIND_IMMEDIATE) | OPT_BIND_FLAGS, 0);
00078   if (!shl_handle)
00079     {
00080       /* the hp-docs say we should better abort() if errno==ENOSYM ;( */
00081       g_module_set_error (g_strerror (errno));
00082     }
00083   
00084   return (gpointer) shl_handle;
00085 }

static gpointer _g_module_self void   )  [static]
 

Definition at line 88 of file gmodule-dld.c.

References g_module_set_error(), and g_strerror().

00089 {
00090   shl_t shl_handle;
00091   
00092   shl_handle = PROG_HANDLE;
00093   if (!shl_handle)
00094     g_module_set_error (g_strerror (errno));
00095   
00096   return shl_handle;
00097 }

static gpointer _g_module_symbol gpointer  handle,
const gchar symbol_name
[static]
 

Definition at line 111 of file gmodule-dld.c.

References g_module_set_error(), g_strerror(), and NULL.

00113 {
00114   gpointer p = NULL;
00115   
00116   /* should we restrict lookups to TYPE_PROCEDURE?
00117    */
00118   if (handle == PROG_HANDLE)
00119     {
00120       /* PROG_HANDLE will only lookup symbols in the program itself, not honouring
00121        * libraries. passing NULL as a handle will also try to lookup the symbol
00122        * in currently loaded libraries. fix pointed out and supplied by:
00123        * David Gero <dgero@nortelnetworks.com>
00124        */
00125       handle = NULL;
00126     }
00127   if (shl_findsym ((shl_t*) &handle, symbol_name, TYPE_UNDEFINED, &p) != 0 ||
00128       handle == NULL || p == NULL)
00129     {
00130       /* the hp-docs say we should better abort() if errno==ENOSYM ;( */
00131       g_module_set_error (g_strerror (errno));
00132     }
00133   
00134   return p;
00135 }


© sourcejam.com 2005-2008