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

Annotation of /botnetop.mod/who.c

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


Revision 1.2 - (hide annotations) (download) (as text)
Fri Oct 20 19:35:56 2000 UTC (18 years, 6 months ago) by sup
Branch: MAIN
Changes since 1.1: +5 -4 lines
File MIME type: text/x-chdr
Updated to 1.0.0pre6

1 sup 1.1 /*
2     * who.c -- part of botnetop.mod
3     *
4 sup 1.2 * $Id: who.c,v 1.1 2000/10/13 20:22:48 sup Exp $
5 sup 1.1 */
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 who_t *find_who(char *nick)
25     {
26     struct who_t *w = NULL;
27    
28     for (w = start_who; w; w = w->next)
29     if (!rfc_casecmp(w->nick, nick))
30     return w;
31     return NULL;
32     }
33    
34     static struct who_t *add_who(char *nick, char *chan, char *bot, char *uhost)
35     {
36     struct who_t *w = NULL;
37    
38     w = (struct who_t *) nmalloc(sizeof(struct who_t));
39 sup 1.2 if (!w)
40 sup 1.1 return NULL;
41     w->next = start_who;
42     start_who = w;
43     strncpyz(w->nick, nick, sizeof w->nick);
44     strncpyz(w->chan, chan, sizeof w->chan);
45     strncpyz(w->bot, bot, sizeof w->bot);
46     strncpyz(w->uhost, uhost, sizeof w->uhost);
47     w->time = now;
48     putlog(LOG_DEBUG, "*", "botnetop.mod: new who record created for %s (address: %u)", nick, w);
49     return w;
50     }
51    
52     static void del_who(struct who_t *who)
53     {
54     struct who_t *w = NULL, *old = NULL;
55    
56     for (w = start_who; w; old = w, w = w->next) {
57     if (w == who) {
58     if (old)
59     old->next = w->next;
60     else
61     start_who = w->next;
62     putlog(LOG_DEBUG, "*", "botnetop.mod: who record removed from %s (address: %u)", w->nick, w);
63     nfree(w);
64     break;
65     }
66     }
67     }
68    
69     static void check_who()
70     {
71 sup 1.2 struct who_t *w = NULL, *wnext = NULL;
72 sup 1.1
73 sup 1.2 for (w = start_who; w; w = wnext) {
74     wnext = w->next;
75 sup 1.1 if ((w->time) && (w->time + 300 <= now))
76     del_who(w);
77     }
78     }
79    
80     static void who_free_mem()
81     {
82     struct who_t *w = NULL, *wnext = NULL;
83    
84     for (w = start_who; w; w = wnext) {
85     wnext = w->next;
86     nfree(w);
87     }
88     start_who = NULL;
89     }
90    
91     static int who_expmem()
92     {
93     int size = 0;
94     struct who_t *w = NULL;
95    
96     for (w = start_who; w; w = w->next)
97     size += sizeof(struct who_t);
98     return size;
99     }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23