xref: /plan9/sys/src/cmd/gs/src/iplugin.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2001 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: iplugin.h,v 1.5 2004/08/04 19:36:13 stefan Exp $ */
18 /* Plugin manager */
19 
20 #ifndef iplugin_INCLUDED
21 #define iplugin_INCLUDED
22 
23 #ifndef i_ctx_t_DEFINED
24 #define i_ctx_t_DEFINED
25 typedef struct gs_context_state_s i_ctx_t;
26 #endif
27 
28 #ifndef gs_memory_DEFINED
29 #define gs_memory_DEFINED
30 typedef struct gs_memory_s gs_memory_t;
31 #endif
32 
33 typedef struct i_plugin_holder_s i_plugin_holder;
34 typedef struct i_plugin_instance_s i_plugin_instance;
35 typedef struct i_plugin_descriptor_s i_plugin_descriptor;
36 typedef struct i_plugin_client_memory_s i_plugin_client_memory;
37 
38 struct i_plugin_descriptor_s { /* RTTI for plugins */
39     const char *type;          /* Plugin type, such as "FAPI" */
40     const char *subtype;       /* Plugin type, such as "UFST" */
41     void (*finit)(i_plugin_instance *instance, i_plugin_client_memory *mem); /* Destructor & deallocator for the instance. */
42 };
43 
44 struct i_plugin_instance_s {   /* Base class for various plugins */
45     const i_plugin_descriptor *d;
46 };
47 
48 struct i_plugin_holder_s { /* Forms list of plugins for plugin manager */
49     i_plugin_holder *next;
50     i_plugin_instance *I;
51 };
52 
53 struct i_plugin_client_memory_s { /* must be copying */
54     void *client_data;
55     void *(*alloc)(i_plugin_client_memory *mem, unsigned int size, const char *id);
56     void (*free)(i_plugin_client_memory *mem, void *data, const char *cname);
57 };
58 
59 #define plugin_instantiation_proc(proc)\
60   int proc(i_ctx_t *, i_plugin_client_memory *client_mem, i_plugin_instance **instance)
61 
62 #define extern_i_plugin_table()\
63   typedef plugin_instantiation_proc((*i_plugin_instantiation_proc));\
64   extern const i_plugin_instantiation_proc i_plugin_table[]
65 
66 void i_plugin_make_memory(i_plugin_client_memory *mem, gs_memory_t *mem_raw);
67 int i_plugin_init(i_ctx_t *);
68 void i_plugin_finit(gs_memory_t *mem, i_plugin_holder *list);
69 i_plugin_instance *i_plugin_find(i_ctx_t *i_ctx_p, const char *type, const char *subtype);
70 i_plugin_holder * i_plugin_get_list(i_ctx_t *i_ctx_p);
71 
72 #endif /* iplugin_INCLUDED */
73