1 /*
2 	plugin.h
3 
4 	QuakeForge plugin API structures and prototypes
5 
6 	Copyright (C) 2001 Jeff Teunissen <deek@dusknet.dhs.org>
7 
8 	This program is free software; you can redistribute it and/or
9 	modify it under the terms of the GNU General Public License
10 	as published by the Free Software Foundation; either version 2
11 	of the License, or (at your option) any later version.
12 
13 	This program is distributed in the hope that it will be useful,
14 	but WITHOUT ANY WARRANTY; without even the implied warranty of
15 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 	See the GNU General Public License for more details.
18 
19 	You should have received a copy of the GNU General Public License
20 	along with this program; if not, write to:
21 
22 		Free Software Foundation, Inc.
23 		59 Temple Place - Suite 330
24 		Boston, MA  02111-1307, USA
25 
26 */
27 
28 #ifndef __QF_plugin_h_
29 #define __QF_plugin_h_
30 
31 /** \defgroup plugin Plugins
32 	\ingroup utils
33 */
34 //@{
35 
36 #define QFPLUGIN_VERSION	"1.0"
37 
38 #include <QF/qtypes.h>
39 
40 #ifdef STATIC_PLUGINS
41 #define PLUGIN_INFO(type,name) plugin_t *type##_##name##_PluginInfo (void); plugin_t * type##_##name##_PluginInfo (void)
42 #else
43 #define PLUGIN_INFO(type,name) plugin_t *PluginInfo (void); __attribute__((visibility ("default"))) plugin_t *PluginInfo (void)
44 #endif
45 
46 typedef enum {
47 	qfp_null = 0,	// Not real
48 	qfp_input,		// Input (pointing devices, joysticks, etc)
49 	qfp_cd,			// CD Audio
50 	qfp_console,	// Console `driver'
51 	qfp_snd_output,	// Sound output (OSS, ALSA, Win32)
52 	qfp_snd_render,	// Sound mixing
53 	qfp_vid_render,	// Video renderer
54 } plugin_type_t;
55 
56 typedef struct plugin_funcs_s {
57 	struct general_funcs_s *general;
58 	struct input_funcs_s	*input;
59 	struct cd_funcs_s		*cd;
60 	struct console_funcs_s	*console;
61 	struct snd_output_funcs_s	*snd_output;
62 	struct snd_render_funcs_s	*snd_render;
63 	struct vid_render_funcs_s	*vid_render;
64 } plugin_funcs_t;
65 
66 typedef struct plugin_data_s {
67 	struct general_data_s	*general;
68 	struct input_data_s	*input;
69 	struct cd_data_s		*cd;
70 	struct console_data_s	*console;
71 	struct snd_output_data_s	*snd_output;
72 	struct snd_render_data_s	*snd_render;
73 	struct vid_render_data_s	*vid_render;
74 } plugin_data_t;
75 
76 typedef struct plugin_s {
77 	plugin_type_t	type;
78 	void			*handle;
79 	const char		*api_version;
80 	const char		*plugin_version;
81 	const char		*description;
82 	const char		*copyright;
83 	plugin_funcs_t	*functions;
84 	plugin_data_t	*data;
85 	const char		*full_name;
86 } plugin_t;
87 
88 /*
89 	General plugin info return function type
90 */
91 typedef plugin_t * (*P_PluginInfo) (void);
92 
93 typedef struct plugin_list_s {
94 	const char		*name;
95 	P_PluginInfo	info;
96 } plugin_list_t;
97 
98 /*
99 	Plugin system variables
100 */
101 extern struct cvar_s	*fs_pluginpath;
102 
103 /*
104 	Function prototypes
105 */
106 plugin_t *PI_LoadPlugin (const char *, const char *);
107 qboolean PI_UnloadPlugin (plugin_t *);
108 void PI_RegisterPlugins (plugin_list_t *);
109 void PI_Init (void);
110 void PI_Shutdown (void);
111 
112 // FIXME: we need a generic function to initialize unused fields
113 
114 //@}
115 
116 #endif	// __QF_plugin_h_
117