2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public License
7 * version 2 as published by the Free Software Foundation.
9 * This program 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
12 * GNU Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
46 #define PLUGIN_PROTO(name,args...) void name(args)
49 #define PLUGIN_REGISTER(name,args...) \
51 plugin_register_##name(PLUGIN_PROTO((*func),args)) \
53 plugin_##name##_func=func; \
56 #define PLUGIN_CALL(name,args...) \
58 if (plugin_##name##_func) \
59 (*plugin_##name##_func)(args); \
62 #define PLUGIN_FUNC1(name,t1,p1) \
63 PLUGIN_PROTO((*plugin_##name##_func),t1 p1); \
64 void plugin_call_##name(t1 p1) PLUGIN_CALL(name,p1) \
65 PLUGIN_REGISTER(name,t1 p1)
67 #define PLUGIN_FUNC3(name,t1,p1,t2,p2,t3,p3) \
68 PLUGIN_PROTO((*plugin_##name##_func),t1 p1,t2 p2,t3 p3); \
69 void plugin_call_##name(t1 p1,t2 p2, t3 p3) PLUGIN_CALL(name,p1,p2,p3) \
70 PLUGIN_REGISTER(name,t1 p1,t2 p2,t3 p3)
72 #define PLUGIN_FUNC4(name,t1,p1,t2,p2,t3,p3,t4,p4) \
73 PLUGIN_PROTO((*plugin_##name##_func),t1 p1,t2 p2,t3 p3,t4 p4); \
74 void plugin_call_##name(t1 p1,t2 p2, t3 p3, t4 p4) PLUGIN_CALL(name,p1,p2,p3,p4) \
75 PLUGIN_REGISTER(name,t1 p1,t2 p2,t3 p3,t4 p4)
82 GList *plugin_types[plugin_type_last];
84 #define PLUGIN_TYPE(type,newargs) \
86 struct type##_methods; \
88 plugin_register_##type##_type(const char *name, struct type##_priv *(*new_) newargs) \
90 struct name_val *nv; \
91 nv=g_new(struct name_val, 1); \
92 nv->name=g_strdup(name); \
94 plugin_types[plugin_type_##type]=g_list_append(plugin_types[plugin_type_##type], nv); \
98 plugin_get_##type##_type(const char *name) \
100 return plugin_get_type(plugin_type_##type, #type, name); \
104 #define PLUGIN_FUNC1(name,t1,p1) \
105 void plugin_register_##name(void(*func)(t1 p1)); \
106 void plugin_call_##name(t1 p1);
108 #define PLUGIN_FUNC3(name,t1,p1,t2,p2,t3,p3) \
109 void plugin_register_##name(void(*func)(t1 p1,t2 p2,t3 p3)); \
110 void plugin_call_##name(t1 p1,t2 p2,t3 p3);
112 #define PLUGIN_FUNC4(name,t1,p1,t2,p2,t3,p3,t4,p4) \
113 void plugin_register_##name(void(*func)(t1 p1,t2 p2,t3 p3,t4 p4)); \
114 void plugin_call_##name(t1 p1,t2 p2,t3 p3,t4 p4);
116 #define PLUGIN_TYPE(type,newargs) \
117 struct type##_priv; \
118 struct type##_methods; \
119 void plugin_register_##type##_type(const char *name, struct type##_priv *(*new_) newargs); \
120 void *plugin_get_##type##_type(const char *name);
124 #include "plugin_def.h"
127 #define plugin_module_cat3(pre,mod,post) pre##mod##post
128 #define plugin_module_cat2(pre,mod,post) plugin_module_cat3(pre,mod,post)
129 #define plugin_module_cat(pre,post) plugin_module_cat2(pre,MODULE,post)
130 #define plugin_init plugin_module_cat(module_,_init)
136 void plugin_init(void);
137 struct plugin *plugin_new(char *plugin);
138 int plugin_load(struct plugin *pl);
139 char *plugin_get_name(struct plugin *pl);
140 int plugin_get_active(struct plugin *pl);
141 void plugin_set_active(struct plugin *pl, int active);
142 void plugin_set_lazy(struct plugin *pl, int lazy);
143 void plugin_call_init(struct plugin *pl);
144 void plugin_unload(struct plugin *pl);
145 void plugin_destroy(struct plugin *pl);
146 struct plugins *plugins_new(void);
147 void plugins_add_path(struct plugins *pls, struct attr ** attrs);
148 void plugins_init(struct plugins *pls);
149 void plugins_destroy(struct plugins *pls);
150 void *plugin_get_type(enum plugin_type type, const char *type_name, const char *name);
151 /* end of prototypes */