]> git.xonotic.org Git - xonotic/darkplaces.git/blob - hook.h
Fix apropos crash when it reaches cvar alias
[xonotic/darkplaces.git] / hook.h
1 /*
2 Copyright (C) 2020 Cloudwalk
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
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.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 // hook.h
22
23 #ifndef HOOK_H
24 #define HOOK_H
25
26 typedef union hook_val_s
27 {
28         intptr_t val;
29         uintptr_t uval;
30         void *ptr;
31         char *str;
32         int ival;
33         unsigned int uival;
34         double fval;
35         qboolean bval;
36 } hook_val_t;
37
38 typedef struct hook_s
39 {
40         char *name;
41         hook_val_t *(*func)(hook_val_t *hook);
42         hook_val_t *arg;
43         hook_val_t ret;
44         unsigned int argc;
45 } hook_t;
46
47 hook_t *_Hook_Register(hook_t *hook, const char *name, void *func, unsigned int argc);
48 hook_val_t *_Hook_Call(hook_t *hook, ... );
49 void Hook_Init(void);
50 void Hook_Shutdown(void);
51
52 // For your convenience
53 #define Hook_Register(hook, func, argc) _Hook_Register(hook, #hook, func, argc)
54 #define Hook_Call(hook, ... ) _Hook_Call(hook, __VA_ARGS__, NULL)
55
56 #endif