gmodule.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 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. * Modified by the GLib Team and others 1997-2000. See the AUTHORS
  19. * file for a list of people on the GLib Team. See the ChangeLog
  20. * files for a list of changes. These files are distributed with
  21. * GLib at ftp://ftp.gtk.org/pub/gtk/.
  22. */
  23. #ifndef __GMODULE_H__
  24. #define __GMODULE_H__
  25. #include <glib.h>
  26. G_BEGIN_DECLS
  27. /* exporting and importing functions, this is special cased
  28. * to feature Windows dll stubs.
  29. */
  30. #define G_MODULE_IMPORT extern
  31. #ifdef G_PLATFORM_WIN32
  32. # define G_MODULE_EXPORT __declspec(dllexport)
  33. #else /* !G_PLATFORM_WIN32 */
  34. # define G_MODULE_EXPORT
  35. #endif /* !G_PLATFORM_WIN32 */
  36. typedef enum
  37. {
  38. G_MODULE_BIND_LAZY = 1 << 0,
  39. G_MODULE_BIND_LOCAL = 1 << 1,
  40. G_MODULE_BIND_MASK = 0x03
  41. } GModuleFlags;
  42. typedef struct _GModule GModule;
  43. typedef const gchar* (*GModuleCheckInit) (GModule *module);
  44. typedef void (*GModuleUnload) (GModule *module);
  45. /* return TRUE if dynamic module loading is supported */
  46. GLIB_AVAILABLE_IN_ALL
  47. gboolean g_module_supported (void) G_GNUC_CONST;
  48. /* open a module 'file_name' and return handle, which is NULL on error */
  49. GLIB_AVAILABLE_IN_ALL
  50. GModule* g_module_open (const gchar *file_name,
  51. GModuleFlags flags);
  52. /* close a previously opened module, returns TRUE on success */
  53. GLIB_AVAILABLE_IN_ALL
  54. gboolean g_module_close (GModule *module);
  55. /* make a module resident so g_module_close on it will be ignored */
  56. GLIB_AVAILABLE_IN_ALL
  57. void g_module_make_resident (GModule *module);
  58. /* query the last module error as a string */
  59. GLIB_AVAILABLE_IN_ALL
  60. const gchar * g_module_error (void);
  61. /* retrieve a symbol pointer from 'module', returns TRUE on success */
  62. GLIB_AVAILABLE_IN_ALL
  63. gboolean g_module_symbol (GModule *module,
  64. const gchar *symbol_name,
  65. gpointer *symbol);
  66. /* retrieve the file name from an existing module */
  67. GLIB_AVAILABLE_IN_ALL
  68. const gchar * g_module_name (GModule *module);
  69. /* Build the actual file name containing a module. 'directory' is the
  70. * directory where the module file is supposed to be, or NULL or empty
  71. * in which case it should either be in the current directory or, on
  72. * some operating systems, in some standard place, for instance on the
  73. * PATH. Hence, to be absoultely sure to get the correct module,
  74. * always pass in a directory. The file name consists of the directory,
  75. * if supplied, and 'module_name' suitably decorated according to
  76. * the operating system's conventions (for instance lib*.so or *.dll).
  77. *
  78. * No checks are made that the file exists, or is of correct type.
  79. */
  80. GLIB_AVAILABLE_IN_ALL
  81. gchar* g_module_build_path (const gchar *directory,
  82. const gchar *module_name);
  83. #ifndef __GTK_DOC_IGNORE__
  84. #ifdef G_OS_WIN32
  85. #define g_module_open g_module_open_utf8
  86. #define g_module_name g_module_name_utf8
  87. GLIB_AVAILABLE_IN_ALL
  88. GModule * g_module_open_utf8 (const gchar *file_name,
  89. GModuleFlags flags);
  90. GLIB_AVAILABLE_IN_ALL
  91. const gchar *g_module_name_utf8 (GModule *module);
  92. #endif
  93. #endif
  94. G_END_DECLS
  95. #endif /* __GMODULE_H__ */