1/*
2 * "$Id: module.h,v 1.1 2004/09/17 18:38:01 rleigh Exp $"
3 *
4 *   libgimpprint module loader - load modules with libltdl/libdl.
5 *
6 *   Copyright 1997-2000 Michael Sweet (mike@easysw.com),
7 *	Robert Krawitz (rlk@alum.mit.edu) and Michael Natterer (mitch@gimp.org)
8 *   Copyright 2002 Roger Leigh (rleigh@debian.org)
9 *
10 *   This program is free software; you can redistribute it and/or modify it
11 *   under the terms of the GNU General Public License as published by the Free
12 *   Software Foundation; either version 2 of the License, or (at your option)
13 *   any later version.
14 *
15 *   This program is distributed in the hope that it will be useful, but
16 *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 *   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
18 *   for more details.
19 *
20 *   You should have received a copy of the GNU General Public License
21 *   along with this program; if not, write to the Free Software
22 *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 */
24
25/**
26 * @file gutenprint/module.h
27 * @brief Module functions.
28 */
29
30/*
31 * This file must include only standard C header files.  The core code must
32 * compile on generic platforms that don't support glib, gimp, gtk, etc.
33 */
34
35#ifndef GUTENPRINT_MODULE_H
36#define GUTENPRINT_MODULE_H
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42#include <gutenprint/list.h>
43
44#ifdef USE_LTDL
45#include <ltdl.h>
46#elif defined(USE_DLOPEN)
47#include <dlfcn.h>
48#endif
49
50
51#ifdef USE_LTDL
52#define DLOPEN(Filename)       lt_dlopen(Filename)
53#define DLSYM(Handle, Symbol)  lt_dlsym(Handle, Symbol)
54#define DLCLOSE(Handle)        lt_dlclose(Handle)
55#define DLERROR()              lt_dlerror()
56#elif defined(USE_DLOPEN)
57#define DLOPEN(Filename)       dlopen(Filename, RTLD_LAZY)
58#define DLSYM(Handle, Symbol)  stp_dlsym(Handle, Symbol, modulename)
59#define DLCLOSE(Handle)        dlclose(Handle)
60#define DLERROR()              dlerror()
61#endif
62
63typedef struct stp_module_version
64{
65  int major;
66  int minor;
67} stp_module_version_t;
68
69
70typedef enum
71{
72  STP_MODULE_CLASS_INVALID,
73  STP_MODULE_CLASS_MISC,
74  STP_MODULE_CLASS_FAMILY,
75  STP_MODULE_CLASS_COLOR,
76  STP_MODULE_CLASS_DITHER
77} stp_module_class_t;
78
79
80typedef struct stp_module
81{
82  const char *name;         /* module name */
83  const char *version;      /* module version number */
84  const char *comment;      /* description of module function */
85  stp_module_class_t class; /* type of module */
86#ifdef USE_LTDL
87  lt_dlhandle handle;       /* ltdl module pointer (set by libgimpprint) */
88#else
89  void *handle;             /* dlopen or static module pointer */
90#endif
91  int (*init)(void);        /* initialisation function */
92  int (*fini)(void);        /* finalise (cleanup and removal) function */
93  void *syms;               /* pointer to e.g. a struct containing
94                               internal module symbols (class-specific
95                               functions and data) */
96} stp_module_t;
97
98
99extern int stp_module_load(void);
100extern int stp_module_exit(void);
101extern int stp_module_open(const char *modulename);
102extern int stp_module_init(void);
103extern int stp_module_close(stp_list_item_t *module);
104extern stp_list_t *stp_module_get_class(stp_module_class_t class);
105
106
107#ifdef __cplusplus
108  }
109#endif
110
111#endif /* GUTENPRINT_MODULE_H */
112