]> jfr.im git - irc/rqf/shadowircd.git/blob - modules/static_modules.c.SH
Filter bogus CTCP ACTION messages.
[irc/rqf/shadowircd.git] / modules / static_modules.c.SH
1 #!/bin/sh
2 # static_modules.c.SH: Generates our static module list
3 # $Id: static_modules.c.SH 6 2005-09-10 01:02:21Z nenolod $
4 #
5 SYMS=`for x in $*; do basename $x .o|sed -es/^m_//; done`
6 cat > static_modules.c <<EOF
7 /*
8 * This file is automatically generated: do not modify
9 * ircd-ratbox: A slightly useful ircd
10 *
11 * Copyright (C) 2003 Aaron Sethman <androsyn@ratbox.org>
12 * Copyright (C) 2003-2005 ircd-ratbox development team
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 * USA
28 *
29 */
30 #include "stdinc.h"
31 #include "modules.h"
32 #include "hash.h"
33 #include "s_log.h"
34
35 EOF
36
37 for x in $SYMS; do
38 echo extern struct mapi_header_av1 "$x"_mheader\;
39 done >> static_modules.c
40
41
42 echo static const struct mapi_header_av1 *mapi_headers[] = { >> static_modules.c
43 for x in $SYMS; do
44 echo \&"$x"_mheader,
45 done >> static_modules.c
46
47 echo NULL }\; >> static_modules.c
48
49 cat >> static_modules.c <<EOF
50 void load_static_modules(void)
51 {
52 int x;
53 int *mapi_version;
54 for(x = 0; mapi_headers[x] != NULL; x++)
55 {
56 mapi_version = (int *)mapi_headers[x];
57 if(MAPI_MAGIC(*mapi_version) != MAPI_MAGIC_HDR)
58 {
59 ilog(L_MAIN, "Error: linked in module without a MAPI header..giving up");
60 exit(70);
61 }
62 switch(MAPI_VERSION(*mapi_version))
63 {
64 case 1:
65 {
66 struct mapi_mheader_av1 *mheader = (struct mapi_mheader_av1*)mapi_version;
67 if (mheader->mapi_register && (mheader->mapi_register() == -1))
68 {
69 ilog(L_MAIN, "Error: linked in module failed loading..giving up");
70 exit(70);
71 }
72
73 if(mheader->mapi_command_list)
74 {
75 struct Message **m;
76 for(m = mheader->mapi_command_list; *m; ++m)
77 mod_add_cmd(*m);
78 }
79
80 if(mheader->mapi_hook_list)
81 {
82 mapi_hlist_av1 *m;
83 for(m = mheader->mapi_hook_list; m->hapi_name; ++m)
84 *m->hapi_id = register_hook(m->hapi_name);
85 }
86
87 if(mheader->mapi_hfn_list)
88 {
89 mapi_hfn_list_av1 *m;
90 for(m = mheader->mapi_hfn_list; m->hapi_name; ++m)
91 add_hook(m->hapi_name, m->fn);
92
93 }
94
95 break;
96
97 }
98 default:
99 {
100 ilog(L_MAIN, "Error: Unknown MAPI version in linked in module..giving up");
101 exit(70);
102 }
103 }
104 }
105 }
106 EOF