Renamed package to ion1, and made it conflict with package 'ion'.
[ion1.git] / src / modules.h
blob33ae7c85d068e31b6c2dce1b14e853d031842ddd
1 /*
2 * ion/modules.h
4 * Copyright (c) Tuomo Valkonen 1999-2001.
5 * See the included file LICENSE for details.
6 */
8 #ifndef INCLUDED_MODULES_H
9 #define INCLUDED_MODULES_H
11 #include "common.h"
12 #include "thing.h"
13 #include "window.h"
15 extern bool load_module(const char *name);
16 extern void call_hooks(const char *hook);
17 extern void call_hooks_p(const char *hook, void *p);
18 extern void unload_modules();
20 extern void *miter_begin(const char *sym);
21 extern void *miter_next(const char *sym);
22 extern void miter_end();
24 typedef void Hook();
25 typedef bool AltHookB();
26 typedef void *AltHookP();
29 #define FOR_ALL_SYMBOLS(VAR, TYPE, SYM) \
30 for(VAR=(TYPE)miter_begin(SYM); \
31 VAR!=NULL; \
32 VAR=(TYPE)miter_next(SYM))
35 #define CALL_HOOKS(HOOK) call_hooks(#HOOK)
36 #define CALL_HOOKS_P(HOOK, P) call_hooks_p(#HOOK, P)
39 #define CALL_HOOKS_ARG(NAME, ARGS) \
40 { \
41 Hook *hook_tmp_do_not_use; \
42 FOR_ALL_SYMBOLS(hook_tmp_do_not_use, Hook*, #NAME){ \
43 althook_tmp_do_not_use ARGS; \
44 } \
45 miter_end(); \
49 #define CALL_ALT_B_ARG(VAR, NAME, ARGS) \
50 { \
51 AltHookB *althook_tmp_do_not_use; \
52 VAR=FALSE; \
53 FOR_ALL_SYMBOLS(althook_tmp_do_not_use, AltHookB*, #NAME "_alt"){ \
54 VAR=althook_tmp_do_not_use ARGS; \
55 if(VAR) \
56 break; \
57 } \
58 miter_end(); \
59 if(!VAR) \
60 VAR=NAME ARGS; \
64 #define CALL_ALT_P_ARG(VAR, NAME, ARGS) \
65 { \
66 AltHookP *althook_tmp_do_not_use; \
67 VAR=NULL; \
68 FOR_ALL_SYMBOLS(althook_tmp_do_not_use, AltHookP*, #NAME "_alt"){ \
69 VAR=althook_tmp_do_not_use ARGS; \
70 if(VAR!=NULL) \
71 break; \
72 } \
73 miter_end(); \
74 if(VAR==NULL) \
75 VAR=NAME ARGS; \
78 #endif /* INCLUDED_MODULES_H */