2 # static_modules.c.SH: Generates our static module list
4 SYMS
=`for x in $*; do basename $x .o|sed -es/^m_//; done`
5 cat > static_modules.c
<<EOF
7 * This file is automatically generated: do not modify
8 * ircd-ratbox: A slightly useful ircd
10 * Copyright (C) 2003 Aaron Sethman <androsyn@ratbox.org>
11 * Copyright (C) 2003-2005 ircd-ratbox development team
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
37 echo extern struct mapi_header_av1
"$x"_mheader\
;
38 done >> static_modules.c
41 echo static const struct mapi_header_av1
*mapi_headers
[] = { >> static_modules.c
44 done >> static_modules.c
46 echo NULL
}\
; >> static_modules.c
48 cat >> static_modules.c
<<EOF
49 void load_static_modules(void)
53 for(x = 0; mapi_headers[x] != NULL; x++)
55 mapi_version = (int *)mapi_headers[x];
56 if(MAPI_MAGIC(*mapi_version) != MAPI_MAGIC_HDR)
58 ilog(L_MAIN, "Error: linked in module without a MAPI header..giving up");
61 switch(MAPI_VERSION(*mapi_version))
65 struct mapi_mheader_av1 *mheader = (struct mapi_mheader_av1*)mapi_version;
66 if (mheader->mapi_register && (mheader->mapi_register() == -1))
68 ilog(L_MAIN, "Error: linked in module failed loading..giving up");
72 if(mheader->mapi_command_list)
75 for(m = mheader->mapi_command_list; *m; ++m)
79 if(mheader->mapi_hook_list)
82 for(m = mheader->mapi_hook_list; m->hapi_name; ++m)
83 *m->hapi_id = register_hook(m->hapi_name);
86 if(mheader->mapi_hfn_list)
89 for(m = mheader->mapi_hfn_list; m->hapi_name; ++m)
90 add_hook(m->hapi_name, m->fn);
99 ilog(L_MAIN, "Error: Unknown MAPI version in linked in module..giving up");