]> jfr.im git - irc/evilnet/x3.git/blob - src/eventhooks.h
Added new event hooks system and started migrating events to new system
[irc/evilnet/x3.git] / src / eventhooks.h
1 /* eventhooks.h - Event hooks
2 * Copyright 2000-2024 Evilnet Development
3 *
4 * This file is part of x3.
5 *
6 * x3 is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with srvx; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19 */
20
21 #ifndef INCLUDED_eventhooks_h
22 #define INCLUDED_eventhooks_h
23
24 #define EH_ADD_HEAD 1
25 #define EH_ADD_TAIL -1
26 #define EH_ADD_DEFAULT 0
27
28 #define DEFINE_EH_FUNC_LIST(l, d, cf) struct eh_func_list l = {NULL, NULL, d, 0, cf}
29 #define INIT_EH_FUNC_LIST(d) {NULL, NULL, d, 0}
30
31 #define EH_CONT 0
32 #define EH_STOP 1
33
34 struct eh_func;
35
36 typedef int (*eh_func_t) (void *extra, void *callextra);
37 typedef void (*eh_clean_func_t) (struct eh_func *ehf);
38
39 struct eh_func {
40 struct eh_func *next;
41 eh_func_t func;
42 void *extra;
43 };
44
45 struct eh_func_list {
46 struct eh_func *head;
47 struct eh_func *tail;
48 int add_default;
49 int count;
50 eh_clean_func_t clean;
51 };
52
53 struct eh_func_list *init_hook_func_list(struct eh_func_list *list, int defpos);
54 void reg_hook_func(struct eh_func_list *list, eh_func_t func, void *extra);
55 void reg_hook_func_pos(struct eh_func_list *list, eh_func_t func, void *extra, int pos);
56 void unreg_hook_func(struct eh_func_list *list, eh_func_t func, void *extra);
57 void free_hook_func_list(struct eh_func_list *list);
58 void call_hook_func_noargs(struct eh_func_list *list);
59 void call_hook_func_args(struct eh_func_list *list, void *callextra);
60
61 #endif /* INCLUDED_eventhooks_h */