/[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.5 - (show annotations) (download) (as text)
Fri Oct 13 20:22:48 2000 UTC (18 years, 6 months ago) by sup
Branch: MAIN
Changes since 1.4: +58 -35 lines
File MIME type: text/x-chdr
Updated to 1.0.0pre5

1 /*
2 * botnetop.c -- part of botnetop.mod
3 *
4 * $Id: botnetop.c,v 1.3 2000/08/25 20:19:17 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.0pre5"
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 = 1;
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_setneed = 0;
44 static int bop_log = 2;
45 static struct delay_t *start_delay = NULL;
46 static struct who_t *start_who = NULL;
47 static struct needs_t *start_needs = NULL;
48
49 #include "botnetop.h"
50 #include "misc.c"
51 #include "botcmds.c"
52 #include "ircbinds.c"
53 #include "botbinds.c"
54 #include "needbinds.c"
55 #include "tclcmds.c"
56 #include "delay.c"
57 #include "who.c"
58 #include "needs.c"
59
60 static void botnetop_hook_secondly()
61 {
62 check_delay();
63 check_who();
64 check_needs();
65 }
66
67 static void botnetop_hook_hourly()
68 {
69 struct chanset_t *chan = NULL;
70 struct delay_t *d = NULL;
71 struct needs_t *n = NULL;
72
73 for (d = start_delay; d; d = d->next) {
74 if (!(chan = findchan_by_dname(d->chan)))
75 del_delay(d);
76 }
77 for (n = start_needs; n; n = n->next) {
78 if (!(chan = findchan_by_dname(n->chan)))
79 del_needs(n);
80 }
81 }
82
83 static int botnetop_expmem()
84 {
85 return delay_expmem() + who_expmem() + needs_expmem();
86 }
87
88 static void botnetop_report(int idx, int details)
89 {
90 int dtot = 0;
91 int wtot = 0;
92 int ntot = 0;
93 struct delay_t *d = NULL;
94 struct who_t *w = NULL;
95 struct needs_t *n = NULL;
96
97 for (d = start_delay; d; d = d->next)
98 dtot++;
99 for (w = start_who; w; w = w->next)
100 wtot++;
101 for (n = start_needs; n; n = n->next)
102 ntot++;
103 if (details) {
104 dprintf(idx, " Version: %s\n", MODULE_VERSION);
105 dprintf(idx, " Tcl commands: bop_reqop, bop_letmein\n");
106 dprintf(idx, " %d delay record%s using %d bytes\n", dtot, dtot == 1 ? "" : "s", delay_expmem());
107 dprintf(idx, " %d who record%s using %d bytes\n", wtot, wtot == 1 ? "" : "s", who_expmem());
108 dprintf(idx, " %d needs record%s using %d bytes\n", ntot, ntot == 1 ? "" : "s", needs_expmem());
109 dprintf(idx, " botnetop.mod is using %d bytes\n", botnetop_expmem());
110 }
111 }
112
113 static tcl_ints botnetop_tcl_ints[] =
114 {
115 {"strict-host", &strict_host, 0},
116 {"bop_delay", &bop_delay, 0},
117 {"bop_maxreq", &bop_maxreq, 0},
118 {"bop_modeop", &bop_modeop, 0},
119 {"bop_linkop", &bop_linkop, 0},
120 {"bop_icheck", &bop_icheck, 0},
121 {"bop_osync", &bop_osync, 0},
122 {"bop_addhost", &bop_addhost, 0},
123 {"bop_setneed", &bop_setneed, 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 (!(irc_funcs = module_depend(MODULE_NAME, "irc", 1, 0)))
162 return "You need the irc module to use the botnetop module.";
163 if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0)))
164 return "You need the server module to use the botnetop module.";
165 if (!(channels_funcs = module_depend(MODULE_NAME, "channels", 1, 0)))
166 return "You need the channels module to use the botnetop module.";
167 if (!module_depend(MODULE_NAME, "eggdrop", 105, 4))
168 return "This module requires eggdrop1.5.4 or later";
169 add_hook(HOOK_SECONDLY, (Function) botnetop_hook_secondly);
170 add_hook(HOOK_HOURLY, (Function) botnetop_hook_hourly);
171 add_builtins(H_join, botnetop_join);
172 add_builtins(H_mode, botnetop_mode);
173 add_builtins(H_raw, botnetop_raw);
174 add_builtins(H_link, botnetop_link);
175 add_builtins(H_bot, botnetop_bot);
176 add_builtins(H_need, botnetop_need);
177 add_tcl_ints(botnetop_tcl_ints);
178 add_tcl_commands(botnetop_tcl_cmds);
179 putlog(LOG_MISC, "*", "botnetop.mod v%s by Sup loaded.", MODULE_VERSION);
180 return NULL;
181 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23