]> jfr.im git - solanum.git/blame - modules/static_modules.c.SH
modules: Add AV2 description to m_xline
[solanum.git] / modules / static_modules.c.SH
CommitLineData
212380e3
AC
1#!/bin/sh
2# static_modules.c.SH: Generates our static module list
212380e3
AC
3#
4SYMS=`for x in $*; do basename $x .o|sed -es/^m_//; done`
5cat > static_modules.c <<EOF
6/*
7 * This file is automatically generated: do not modify
8 * ircd-ratbox: A slightly useful ircd
9 *
10 * Copyright (C) 2003 Aaron Sethman <androsyn@ratbox.org>
11 * Copyright (C) 2003-2005 ircd-ratbox development team
12 *
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.
17 *
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.
22 *
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
26 * USA
27 *
28 */
29#include "stdinc.h"
30#include "modules.h"
31#include "hash.h"
32#include "s_log.h"
33
34EOF
35
36for x in $SYMS; do
37 echo extern struct mapi_header_av1 "$x"_mheader\;
38done >> static_modules.c
39
40
41echo static const struct mapi_header_av1 *mapi_headers[] = { >> static_modules.c
42for x in $SYMS; do
43 echo \&"$x"_mheader,
44done >> static_modules.c
45
46echo NULL }\; >> static_modules.c
47
48cat >> static_modules.c <<EOF
49void load_static_modules(void)
50{
51 int x;
52 int *mapi_version;
53 for(x = 0; mapi_headers[x] != NULL; x++)
54 {
55 mapi_version = (int *)mapi_headers[x];
56 if(MAPI_MAGIC(*mapi_version) != MAPI_MAGIC_HDR)
57 {
58 ilog(L_MAIN, "Error: linked in module without a MAPI header..giving up");
59 exit(70);
60 }
61 switch(MAPI_VERSION(*mapi_version))
62 {
63 case 1:
64 {
65 struct mapi_mheader_av1 *mheader = (struct mapi_mheader_av1*)mapi_version;
66 if (mheader->mapi_register && (mheader->mapi_register() == -1))
67 {
68 ilog(L_MAIN, "Error: linked in module failed loading..giving up");
69 exit(70);
70 }
71
72 if(mheader->mapi_command_list)
73 {
74 struct Message **m;
75 for(m = mheader->mapi_command_list; *m; ++m)
76 mod_add_cmd(*m);
77 }
78
79 if(mheader->mapi_hook_list)
80 {
81 mapi_hlist_av1 *m;
82 for(m = mheader->mapi_hook_list; m->hapi_name; ++m)
83 *m->hapi_id = register_hook(m->hapi_name);
84 }
85
86 if(mheader->mapi_hfn_list)
87 {
88 mapi_hfn_list_av1 *m;
89 for(m = mheader->mapi_hfn_list; m->hapi_name; ++m)
90 add_hook(m->hapi_name, m->fn);
91
92 }
93
94 break;
95
96 }
97 default:
98 {
99 ilog(L_MAIN, "Error: Unknown MAPI version in linked in module..giving up");
100 exit(70);
101 }
102 }
103 }
104}
105EOF