1/* GMODULE - GLIB wrapper code for dynamic module loading
2 * Copyright (C) 1998 Tim Janik
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GLib Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GLib at ftp://ftp.gtk.org/pub/gtk/.
23 */
24
25#ifndef __GMODULE_H__
26#define __GMODULE_H__
27
28#include <glib.h>
29
30G_BEGIN_DECLS
31
32/* exporting and importing functions, this is special cased
33 * to feature Windows dll stubs.
34 */
35#define G_MODULE_IMPORT extern
36#ifdef G_PLATFORM_WIN32
37# define G_MODULE_EXPORT __declspec(dllexport)
38#elif __GNUC__ >= 4
39# define G_MODULE_EXPORT __attribute__((visibility("default")))
40#else /* !G_PLATFORM_WIN32 && __GNUC__ < 4 */
41# define G_MODULE_EXPORT
42#endif /* !G_PLATFORM_WIN32 */
43
44/**
45 * GModuleFlags:
46 * @G_MODULE_BIND_LAZY: specifies that symbols are only resolved when
47 * needed. The default action is to bind all symbols when the module
48 * is loaded.
49 * @G_MODULE_BIND_LOCAL: specifies that symbols in the module should
50 * not be added to the global name space. The default action on most
51 * platforms is to place symbols in the module in the global name space,
52 * which may cause conflicts with existing symbols.
53 * @G_MODULE_BIND_MASK: mask for all flags.
54 *
55 * Flags passed to g_module_open().
56 * Note that these flags are not supported on all platforms.
57 */
58typedef enum
59{
60 G_MODULE_BIND_LAZY = 1 << 0,
61 G_MODULE_BIND_LOCAL = 1 << 1,
62 G_MODULE_BIND_MASK = 0x03
63} GModuleFlags;
64
65typedef struct _GModule GModule;
66typedef const gchar* (*GModuleCheckInit) (GModule *module);
67typedef void (*GModuleUnload) (GModule *module);
68
69#define G_MODULE_ERROR g_module_error_quark () GLIB_AVAILABLE_MACRO_IN_2_70
70GLIB_AVAILABLE_IN_2_70
71GQuark g_module_error_quark (void);
72
73/**
74 * GModuleError:
75 * @G_MODULE_ERROR_FAILED: there was an error loading or opening a module file
76 * @G_MODULE_ERROR_CHECK_FAILED: a module returned an error from its `g_module_check_init()` function
77 *
78 * Errors returned by g_module_open_full().
79 *
80 * Since: 2.70
81 */
82typedef enum
83{
84 G_MODULE_ERROR_FAILED,
85 G_MODULE_ERROR_CHECK_FAILED,
86} GModuleError
87GLIB_AVAILABLE_ENUMERATOR_IN_2_70;
88
89/* return TRUE if dynamic module loading is supported */
90GLIB_AVAILABLE_IN_ALL
91gboolean g_module_supported (void) G_GNUC_CONST;
92
93/* open a module 'file_name' and return handle, which is NULL on error */
94GLIB_AVAILABLE_IN_ALL
95GModule* g_module_open (const gchar *file_name,
96 GModuleFlags flags);
97
98GLIB_AVAILABLE_IN_2_70
99GModule *g_module_open_full (const gchar *file_name,
100 GModuleFlags flags,
101 GError **error);
102
103/* close a previously opened module, returns TRUE on success */
104GLIB_AVAILABLE_IN_ALL
105gboolean g_module_close (GModule *module);
106
107/* make a module resident so g_module_close on it will be ignored */
108GLIB_AVAILABLE_IN_ALL
109void g_module_make_resident (GModule *module);
110
111/* query the last module error as a string */
112GLIB_AVAILABLE_IN_ALL
113const gchar * g_module_error (void);
114
115/* retrieve a symbol pointer from 'module', returns TRUE on success */
116GLIB_AVAILABLE_IN_ALL
117gboolean g_module_symbol (GModule *module,
118 const gchar *symbol_name,
119 gpointer *symbol);
120
121/* retrieve the file name from an existing module */
122GLIB_AVAILABLE_IN_ALL
123const gchar * g_module_name (GModule *module);
124
125/* Build the actual file name containing a module. 'directory' is the
126 * directory where the module file is supposed to be, or NULL or empty
127 * in which case it should either be in the current directory or, on
128 * some operating systems, in some standard place, for instance on the
129 * PATH. Hence, to be absolutely sure to get the correct module,
130 * always pass in a directory. The file name consists of the directory,
131 * if supplied, and 'module_name' suitably decorated according to
132 * the operating system's conventions (for instance lib*.so or *.dll).
133 *
134 * No checks are made that the file exists, or is of correct type.
135 */
136GLIB_AVAILABLE_IN_ALL
137gchar* g_module_build_path (const gchar *directory,
138 const gchar *module_name);
139
140G_END_DECLS
141
142#endif /* __GMODULE_H__ */
143

source code of include/glib-2.0/gmodule.h