/[cvs]/botnetop.mod/botnetop.c
ViewVC logotype

Contents of /botnetop.mod/botnetop.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Sat Nov 11 16:13:02 2000 UTC (18 years, 5 months ago) by sup
Branch: MAIN
Changes since 1.6: +18 -11 lines
File MIME type: text/x-chdr
Updated to v1.0.0

1 /*
2 * botnetop.c -- part of botnetop.mod
3 *
4 * $Id: botnetop.c,v 1.6 2000/10/20 19:35:56 sup Exp $
5 */
6 /*
7 * Copyright (C) 2000 Teemu Hjelt <temex@iki.fi>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24 #define MODULE_NAME "botnetop"
25 #define MAKING_BOTNETOP
26 #define MODULE_VERSION "1.0.0"
27 #include "../module.h"
28 #include "../irc.mod/irc.h"
29 #include "../server.mod/server.h"
30 #include "../channels.mod/channels.h"
31
32 #undef global
33 static Function *global = NULL, *irc_funcs = NULL, *server_funcs = NULL, *channels_funcs = NULL;
34
35 static int strict_host = 0;
36 static int bop_delay = 20;
37 static int bop_maxreq = 3;
38 static int bop_modeop = 0;
39 static int bop_linkop = 1;
40 static int bop_icheck = 0;
41 static int bop_osync = 0;
42 static int bop_addhost = 0;
43 static int bop_log = 2;
44 static struct delay_t *start_delay = NULL;
45 static struct who_t *start_who = NULL;
46 static struct needs_t *start_needs = NULL;
47
48 #include "botnetop.h"
49 #include "misc.c"
50 #include "botcmds.c"
51 #include "ircbinds.c"
52 #include "botbinds.c"
53 #include "needbinds.c"
54 #include "tclcmds.c"
55 #include "delay.c"
56 #include "who.c"
57 #include "needs.c"
58
59 static void botnetop_hook_secondly()
60 {
61 check_delay();
62 check_who();
63 check_needs();
64 }
65
66 static void botnetop_hook_hourly()
67 {
68 struct chanset_t *chan = NULL;
69 struct delay_t *d = NULL, *dnext = NULL;
70 struct needs_t *n = NULL, *nnext = NULL;
71
72 for (d = start_delay; d; d = dnext) {
73 dnext = d->next;
74 if (!(chan = findchan_by_dname(d->chan)))
75 del_delay(d);
76 }
77 for (n = start_needs; n; n = nnext) {
78 nnext = n->next;
79 if (!(chan = findchan_by_dname(n->chan)))
80 del_needs(n);
81 }
82 }
83
84 static int botnetop_expmem()
85 {
86 return delay_expmem() + who_expmem() + needs_expmem();
87 }
88
89 static void botnetop_report(int idx, int details)
90 {
91 int dtot = 0;
92 int wtot = 0;
93 int ntot = 0;
94 struct delay_t *d = NULL;
95 struct who_t *w = NULL;
96 struct needs_t *n = NULL;
97
98 for (d = start_delay; d; d = d->next)
99 dtot++;
100 for (w = start_who; w; w = w->next)
101 wtot++;
102 for (n = start_needs; n; n = n->next)
103 ntot++;
104 if (details) {
105 dprintf(idx, " Version: %s\n", MODULE_VERSION);
106 dprintf(idx, " Tcl commands: bop_reqop, bop_letmein\n");
107 dprintf(idx, " %d delay record%s using %d bytes\n", dtot, dtot == 1 ? "" : "s", delay_expmem());
108 dprintf(idx, " %d who record%s using %d bytes\n", wtot, wtot == 1 ? "" : "s", who_expmem());
109 dprintf(idx, " %d needs record%s using %d bytes\n", ntot, ntot == 1 ? "" : "s", needs_expmem());
110 dprintf(idx, " botnetop.mod is using %d bytes\n", botnetop_expmem());
111 }
112 }
113
114 static tcl_ints botnetop_tcl_ints[] =
115 {
116 {"strict-host", &strict_host, 0},
117 {"bop_delay", &bop_delay, 0},
118 {"bop_maxreq", &bop_maxreq, 0},
119 {"bop_modeop", &bop_modeop, 0},
120 {"bop_linkop", &bop_linkop, 0},
121 {"bop_icheck", &bop_icheck, 0},
122 {"bop_osync", &bop_osync, 0},
123 {"bop_addhost", &bop_addhost, 0},
124 {"bop_log", &bop_log, 0},
125 {0, 0, 0}
126 };
127
128 static char *botnetop_close()
129 {
130 del_hook(HOOK_SECONDLY, (Function) botnetop_hook_secondly);
131 del_hook(HOOK_HOURLY, (Function) botnetop_hook_hourly);
132 rem_builtins(H_join, botnetop_join);
133 rem_builtins(H_mode, botnetop_mode);
134 rem_builtins(H_raw, botnetop_raw);
135 rem_builtins(H_link, botnetop_link);
136 rem_builtins(H_bot, botnetop_bot);
137 rem_builtins(H_need, botnetop_need);
138 rem_tcl_ints(botnetop_tcl_ints);
139 rem_tcl_commands(botnetop_tcl_cmds);
140 delay_free_mem();
141 who_free_mem();
142 needs_free_mem();
143 module_undepend(MODULE_NAME);
144 return NULL;
145 }
146
147 char *botnetop_start();
148
149 static Function botnetop_table[] =
150 {
151 (Function) botnetop_start,
152 (Function) botnetop_close,
153 (Function) botnetop_expmem,
154 (Function) botnetop_report,
155 };
156
157 char *botnetop_start(Function * global_funcs)
158 {
159 global = global_funcs;
160 module_register(MODULE_NAME, botnetop_table, 1, 0);
161 if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
162 if (!module_depend(MODULE_NAME, "eggdrop", 105, 4)) {
163 module_undepend(MODULE_NAME);
164 return "This module requires eggdrop1.5.4 or later";
165 }
166 }
167 if (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 0))) {
168 module_undepend(MODULE_NAME);
169 return "You need the irc module to use the botnetop module.";
170 }
171 if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0))) {
172 module_undepend(MODULE_NAME);
173 return "You need the server module to use the botnetop module.";
174 }
175 if (!(channels_funcs = module_depend(MODULE_NAME, "channels", 1, 0))) {
176 module_undepend(MODULE_NAME);
177 return "You need the channels module to use the botnetop module.";
178 }
179 add_hook(HOOK_SECONDLY, (Function) botnetop_hook_secondly);
180 add_hook(HOOK_HOURLY, (Function) botnetop_hook_hourly);
181 add_builtins(H_join, botnetop_join);
182 add_builtins(H_mode, botnetop_mode);
183 add_builtins(H_raw, botnetop_raw);
184 add_builtins(H_link, botnetop_link);
185 add_builtins(H_bot, botnetop_bot);
186 add_builtins(H_need, botnetop_need);
187 add_tcl_ints(botnetop_tcl_ints);
188 add_tcl_commands(botnetop_tcl_cmds);
189 return NULL;
190 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23