gmodule.h

Go to the documentation of this file.
00001 /* GMODULE - GLIB wrapper code for dynamic module loading
00002  * Copyright (C) 1998 Tim Janik
00003  * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the
00017  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018  * Boston, MA 02111-1307, USA.
00019  */
00020 
00021 /*
00022  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
00023  * file for a list of people on the GLib Team.  See the ChangeLog
00024  * files for a list of changes.  These files are distributed with
00025  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
00026  */
00027 
00028 #ifndef __GMODULE_H__
00029 #define __GMODULE_H__
00030 
00031 #include <_ansi.h>
00032 #include <glib.h>
00033 
00034 G_BEGIN_DECLS
00035 
00036 /* exporting and importing functions, this is special cased
00037  * to feature Windows dll stubs.
00038  */
00039 #define G_MODULE_IMPORT         extern
00040 #ifdef G_PLATFORM_WIN32
00041 #  define       G_MODULE_EXPORT         __declspec(dllexport)
00042 #else /* !G_PLATFORM_WIN32 */
00043 #  define       G_MODULE_EXPORT
00044 #endif /* !G_PLATFORM_WIN32 */
00045 
00046 typedef enum
00047 {
00048   G_MODULE_BIND_LAZY    = 1 << 0,
00049   G_MODULE_BIND_LOCAL   = 1 << 1,
00050   G_MODULE_BIND_MASK    = 0x03
00051 } GModuleFlags;
00052 
00053 typedef struct _GModule                  GModule;
00054 typedef const gchar* (*GModuleCheckInit) (GModule       *module);
00055 typedef void         (*GModuleUnload)    (GModule       *module);
00056 
00057 #ifdef G_OS_WIN32
00058 #define g_module_open g_module_open_utf8
00059 #define g_module_name g_module_name_utf8
00060 #endif
00061 
00062 /* return TRUE if dynamic module loading is supported */
00063 IMPORT_C gboolean       g_module_supported         (void) G_GNUC_CONST;
00064 
00065 /* open a module `file_name' and return handle, which is NULL on error */
00066 IMPORT_C GModule*              g_module_open          (const gchar  *file_name,
00067                                               GModuleFlags  flags);
00068 
00069 /* close a previously opened module, returns TRUE on success */
00070 IMPORT_C gboolean              g_module_close         (GModule      *module);
00071 
00072 /* make a module resident so g_module_close on it will be ignored */
00073 IMPORT_C void                  g_module_make_resident (GModule      *module);
00074 
00075 /* query the last module error as a string */
00076 IMPORT_C G_CONST_RETURN gchar* g_module_error         (void);
00077 
00078 /* retrieve a symbol pointer from `module', returns TRUE on success */
00079 IMPORT_C gboolean              g_module_symbol        (GModule      *module,
00080                                               const gchar  *symbol_name,
00081                                               gpointer     *symbol);
00082 
00083 /* retrieve the file name from an existing module */
00084 IMPORT_C G_CONST_RETURN gchar* g_module_name          (GModule      *module);
00085 
00086 /* Build the actual file name containing a module. `directory' is the
00087  * directory where the module file is supposed to be, or NULL or empty
00088  * in which case it should either be in the current directory or, on
00089  * some operating systems, in some standard place, for instance on the
00090  * PATH. Hence, to be absoultely sure to get the correct module,
00091  * always pass in a directory. The file name consists of the directory,
00092  * if supplied, and `module_name' suitably decorated accoring to
00093  * the operating system's conventions (for instance lib*.so or *.dll).
00094  *
00095  * No checks are made that the file exists, or is of correct type.
00096  */
00097 IMPORT_C gchar*                g_module_build_path    (const gchar  *directory,
00098                                               const gchar  *module_name);
00099 
00100 
00101 G_END_DECLS
00102 
00103 #endif /* __GMODULE_H__ */

Copyright © Nokia Corporation 2001-2008
Back to top