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

Annotation of /botnetop.mod/botnetop.c

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


Revision 1.8 - (hide annotations) (download) (as text)
Tue Feb 13 18:23:24 2001 UTC (19 years, 3 months ago) by sup
Branch: MAIN
Changes since 1.7: +3 -3 lines
File MIME type: text/x-chdr
Updated to 1.0.1

1 sup 1.3 /*
2     * botnetop.c -- part of botnetop.mod
3     *
4 sup 1.8 * $Id: botnetop.c,v 1.7 2000/11/11 16:13:02 sup Exp $
5 sup 1.3 */
6     /*
7 sup 1.8 * Copyright (C) 2000, 2001 Teemu Hjelt <temex@iki.fi>
8 guppy 1.1 *
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 sup 1.8 #define MODULE_VERSION "1.0.1"
27 guppy 1.1 #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 sup 1.7 static int strict_host = 0;
36 sup 1.4 static int bop_delay = 20;
37     static int bop_maxreq = 3;
38 guppy 1.1 static int bop_modeop = 0;
39     static int bop_linkop = 1;
40 sup 1.5 static int bop_icheck = 0;
41 guppy 1.1 static int bop_osync = 0;
42     static int bop_addhost = 0;
43     static int bop_log = 2;
44 sup 1.4 static struct delay_t *start_delay = NULL;
45 sup 1.5 static struct who_t *start_who = NULL;
46     static struct needs_t *start_needs = NULL;
47 guppy 1.1
48 sup 1.5 #include "botnetop.h"
49 guppy 1.1 #include "misc.c"
50     #include "botcmds.c"
51     #include "ircbinds.c"
52     #include "botbinds.c"
53 sup 1.3 #include "needbinds.c"
54 guppy 1.1 #include "tclcmds.c"
55 sup 1.4 #include "delay.c"
56 sup 1.5 #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 sup 1.6 struct delay_t *d = NULL, *dnext = NULL;
70     struct needs_t *n = NULL, *nnext = NULL;
71 sup 1.5
72 sup 1.6 for (d = start_delay; d; d = dnext) {
73     dnext = d->next;
74 sup 1.5 if (!(chan = findchan_by_dname(d->chan)))
75     del_delay(d);
76     }
77 sup 1.6 for (n = start_needs; n; n = nnext) {
78     nnext = n->next;
79 sup 1.5 if (!(chan = findchan_by_dname(n->chan)))
80     del_needs(n);
81     }
82     }
83 guppy 1.1
84     static int botnetop_expmem()
85     {
86 sup 1.5 return delay_expmem() + who_expmem() + needs_expmem();
87 guppy 1.1 }
88    
89     static void botnetop_report(int idx, int details)
90     {
91 sup 1.4 int dtot = 0;
92 sup 1.5 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 sup 1.4
98 sup 1.5 for (d = start_delay; d; d = d->next)
99 sup 1.4 dtot++;
100 sup 1.5 for (w = start_who; w; w = w->next)
101     wtot++;
102     for (n = start_needs; n; n = n->next)
103     ntot++;
104 sup 1.4 if (details) {
105 sup 1.5 dprintf(idx, " Version: %s\n", MODULE_VERSION);
106 guppy 1.1 dprintf(idx, " Tcl commands: bop_reqop, bop_letmein\n");
107 sup 1.5 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 sup 1.4 }
112 guppy 1.1 }
113    
114     static tcl_ints botnetop_tcl_ints[] =
115     {
116     {"strict-host", &strict_host, 0},
117 sup 1.4 {"bop_delay", &bop_delay, 0},
118     {"bop_maxreq", &bop_maxreq, 0},
119 guppy 1.1 {"bop_modeop", &bop_modeop, 0},
120     {"bop_linkop", &bop_linkop, 0},
121 sup 1.5 {"bop_icheck", &bop_icheck, 0},
122 guppy 1.1 {"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 sup 1.5 del_hook(HOOK_SECONDLY, (Function) botnetop_hook_secondly);
131     del_hook(HOOK_HOURLY, (Function) botnetop_hook_hourly);
132 guppy 1.1 rem_builtins(H_join, botnetop_join);
133     rem_builtins(H_mode, botnetop_mode);
134 sup 1.5 rem_builtins(H_raw, botnetop_raw);
135 guppy 1.1 rem_builtins(H_link, botnetop_link);
136     rem_builtins(H_bot, botnetop_bot);
137 sup 1.3 rem_builtins(H_need, botnetop_need);
138 guppy 1.1 rem_tcl_ints(botnetop_tcl_ints);
139 sup 1.4 rem_tcl_commands(botnetop_tcl_cmds);
140     delay_free_mem();
141 sup 1.5 who_free_mem();
142     needs_free_mem();
143 guppy 1.1 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 sup 1.5 module_register(MODULE_NAME, botnetop_table, 1, 0);
161 sup 1.7 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 guppy 1.1 return "You need the irc module to use the botnetop module.";
170 sup 1.7 }
171     if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0))) {
172     module_undepend(MODULE_NAME);
173 guppy 1.1 return "You need the server module to use the botnetop module.";
174 sup 1.7 }
175     if (!(channels_funcs = module_depend(MODULE_NAME, "channels", 1, 0))) {
176     module_undepend(MODULE_NAME);
177 guppy 1.1 return "You need the channels module to use the botnetop module.";
178 sup 1.7 }
179 sup 1.5 add_hook(HOOK_SECONDLY, (Function) botnetop_hook_secondly);
180     add_hook(HOOK_HOURLY, (Function) botnetop_hook_hourly);
181 guppy 1.1 add_builtins(H_join, botnetop_join);
182     add_builtins(H_mode, botnetop_mode);
183 sup 1.5 add_builtins(H_raw, botnetop_raw);
184 guppy 1.1 add_builtins(H_link, botnetop_link);
185     add_builtins(H_bot, botnetop_bot);
186 sup 1.3 add_builtins(H_need, botnetop_need);
187 guppy 1.1 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