|
||||
File indexing completed on 2025-01-18 10:00:09
0001 /* GMODULE - GLIB wrapper code for dynamic module loading 0002 * Copyright (C) 1998 Tim Janik 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Lesser General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2.1 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Lesser General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Lesser General Public 0017 * License along with this library; if not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 /* 0021 * Modified by the GLib Team and others 1997-2000. See the AUTHORS 0022 * file for a list of people on the GLib Team. See the ChangeLog 0023 * files for a list of changes. These files are distributed with 0024 * GLib at ftp://ftp.gtk.org/pub/gtk/. 0025 */ 0026 0027 #ifndef __GMODULE_H__ 0028 #define __GMODULE_H__ 0029 0030 #include <glib.h> 0031 #include <gmodule/gmodule-visibility.h> 0032 0033 G_BEGIN_DECLS 0034 0035 /* exporting and importing functions, this is special cased 0036 * to feature Windows dll stubs. 0037 */ 0038 #if defined(_WIN32) || defined(__CYGWIN__) 0039 # define G_MODULE_EXPORT __declspec(dllexport) 0040 # define G_MODULE_IMPORT __declspec(dllimport) extern 0041 #elif __GNUC__ >= 4 0042 # define G_MODULE_EXPORT __attribute__((visibility("default"))) 0043 # define G_MODULE_IMPORT extern 0044 #else /* !defined(_WIN32) && !defined(__CYGWIN__) && __GNUC__ < 4 */ 0045 # define G_MODULE_EXPORT 0046 # define G_MODULE_IMPORT extern 0047 #endif 0048 0049 /** 0050 * GModuleFlags: 0051 * @G_MODULE_BIND_LAZY: specifies that symbols are only resolved when 0052 * needed. The default action is to bind all symbols when the module 0053 * is loaded. 0054 * @G_MODULE_BIND_LOCAL: specifies that symbols in the module should 0055 * not be added to the global name space. The default action on most 0056 * platforms is to place symbols in the module in the global name space, 0057 * which may cause conflicts with existing symbols. 0058 * @G_MODULE_BIND_MASK: mask for all flags. 0059 * 0060 * Flags passed to g_module_open(). 0061 * Note that these flags are not supported on all platforms. 0062 */ 0063 typedef enum 0064 { 0065 G_MODULE_BIND_LAZY = 1 << 0, 0066 G_MODULE_BIND_LOCAL = 1 << 1, 0067 G_MODULE_BIND_MASK = 0x03 0068 } GModuleFlags; 0069 0070 typedef struct _GModule GModule; 0071 typedef const gchar* (*GModuleCheckInit) (GModule *module); 0072 typedef void (*GModuleUnload) (GModule *module); 0073 0074 #define G_MODULE_ERROR g_module_error_quark () GMODULE_AVAILABLE_MACRO_IN_2_70 0075 GMODULE_AVAILABLE_IN_2_70 0076 GQuark g_module_error_quark (void); 0077 0078 /** 0079 * GModuleError: 0080 * @G_MODULE_ERROR_FAILED: there was an error loading or opening a module file 0081 * @G_MODULE_ERROR_CHECK_FAILED: a module returned an error from its `g_module_check_init()` function 0082 * 0083 * Errors returned by g_module_open_full(). 0084 * 0085 * Since: 2.70 0086 */ 0087 typedef enum 0088 { 0089 G_MODULE_ERROR_FAILED, 0090 G_MODULE_ERROR_CHECK_FAILED, 0091 } GModuleError 0092 GMODULE_AVAILABLE_ENUMERATOR_IN_2_70; 0093 0094 /* return TRUE if dynamic module loading is supported */ 0095 GMODULE_AVAILABLE_IN_ALL 0096 gboolean g_module_supported (void) G_GNUC_CONST; 0097 0098 /* open a module 'file_name' and return handle, which is NULL on error */ 0099 GMODULE_AVAILABLE_IN_ALL 0100 GModule* g_module_open (const gchar *file_name, 0101 GModuleFlags flags); 0102 0103 GMODULE_AVAILABLE_IN_2_70 0104 GModule *g_module_open_full (const gchar *file_name, 0105 GModuleFlags flags, 0106 GError **error); 0107 0108 /* close a previously opened module, returns TRUE on success */ 0109 GMODULE_AVAILABLE_IN_ALL 0110 gboolean g_module_close (GModule *module); 0111 0112 /* make a module resident so g_module_close on it will be ignored */ 0113 GMODULE_AVAILABLE_IN_ALL 0114 void g_module_make_resident (GModule *module); 0115 0116 /* query the last module error as a string */ 0117 GMODULE_AVAILABLE_IN_ALL 0118 const gchar * g_module_error (void); 0119 0120 /* retrieve a symbol pointer from 'module', returns TRUE on success */ 0121 GMODULE_AVAILABLE_IN_ALL 0122 gboolean g_module_symbol (GModule *module, 0123 const gchar *symbol_name, 0124 gpointer *symbol); 0125 0126 /* retrieve the file name from an existing module */ 0127 GMODULE_AVAILABLE_IN_ALL 0128 const gchar * g_module_name (GModule *module); 0129 0130 /* Build the actual file name containing a module. 'directory' is the 0131 * directory where the module file is supposed to be, or NULL or empty 0132 * in which case it should either be in the current directory or, on 0133 * some operating systems, in some standard place, for instance on the 0134 * PATH. Hence, to be absolutely sure to get the correct module, 0135 * always pass in a directory. The file name consists of the directory, 0136 * if supplied, and 'module_name' suitably decorated according to 0137 * the operating system's conventions (for instance lib*.so or *.dll). 0138 * 0139 * No checks are made that the file exists, or is of correct type. 0140 */ 0141 GMODULE_DEPRECATED_IN_2_76 0142 gchar* g_module_build_path (const gchar *directory, 0143 const gchar *module_name); 0144 0145 G_END_DECLS 0146 0147 #endif /* __GMODULE_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |