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

Contents of /botnetop.mod/delay.c

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


Revision 1.1 - (show annotations) (download) (as text)
Mon Aug 28 18:23:31 2000 UTC (18 years, 8 months ago) by sup
Branch: MAIN
File MIME type: text/x-chdr
Updated to 0.5.0

1 /*
2 * delay.c -- part of botnetop.mod
3 *
4 * $Id$
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 static struct delay_t *find_delay(char *chname)
25 {
26 struct delay_t *delay = start_delay;
27
28 while (delay) {
29 if (!rfc_casecmp(delay->chan, chname))
30 return delay;
31 delay = delay->next;
32 }
33 return NULL;
34 }
35
36 static struct delay_t *add_delay(char *chname, char *bot)
37 {
38 struct delay_t *newdelay;
39
40 newdelay = (struct delay_t *) nmalloc(sizeof(struct delay_t));
41 newdelay->next = start_delay;
42 strncpy(newdelay->chan, chname, sizeof(newdelay->chan) - 1);
43 strncpy(newdelay->bot, bot, sizeof(newdelay->bot) - 1);
44 newdelay->reqtime = 0;
45 newdelay->resptime = 0;
46 newdelay->reqs = 0;
47 start_delay = newdelay;
48 putlog(LOG_DEBUG, "*", "botnetop.mod: New delay record created for %s", chname);
49 return newdelay;
50 }
51
52 static void delay_free_mem()
53 {
54 struct delay_t *d = start_delay, *dnext;
55
56 while (d) {
57 dnext = d->next;
58 nfree(d);
59 d = dnext;
60 }
61 start_delay = NULL;
62 }
63
64 static void check_delays()
65 {
66 struct delay_t *d = start_delay;
67
68 while (d) {
69 if ((d->reqtime) && (d->reqtime <= now)) {
70 d->reqtime = 0;
71 bnop_askbot(d->bot, d->chan);
72 }
73 if ((d->resptime) && (d->resptime <= now)) {
74 d->resptime = 0;
75 d->reqs = 0;
76 }
77 d = d->next;
78 }
79 }
80

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23