glib (2.79.0)

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