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

Annotation of /botnetop.mod/request.c

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


Revision 1.2 - (hide annotations) (download) (as text)
Wed Oct 20 17:30:52 2010 UTC (9 years, 7 months ago) by pseudo
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -2 lines
File MIME type: text/x-chdr
Updated dependencies to make the module run on eggdrop 1.8.x

1 sup 1.1 /*
2     * request.c -- part of botnetop.mod
3     *
4 pseudo 1.2 * $Id: request.c,v 1.1 2002/07/14 09:29:53 sup Exp $
5 sup 1.1 */
6     /*
7     * Copyright (C) 2000, 2001, 2002 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 request_t *find_request(char *handle, char *chan)
25     {
26     struct request_t *r = NULL;
27    
28     for (r = request_start; r != NULL; r = r->next) {
29     if (!egg_strcasecmp(r->handle, handle) && !rfc_casecmp(r->chan, chan))
30     return r;
31     }
32    
33     return NULL;
34     }
35    
36     static struct request_t *add_request(char *handle, char *chan)
37     {
38     struct request_t *r = NULL;
39    
40     r = (struct request_t *) nmalloc(sizeof(struct request_t));
41     if (r == NULL)
42     return NULL;
43    
44     r->handle = (char *) nmalloc(strlen(handle) + 1);
45     if (r->handle == NULL) {
46     nfree(r);
47     return NULL;
48     }
49    
50     r->chan = (char *) nmalloc(strlen(chan) + 1);
51     if (r->chan == NULL) {
52     nfree(r->handle);
53     nfree(r);
54     return NULL;
55     }
56    
57     strncpyz(r->handle, handle, strlen(handle) + 1);
58     strncpyz(r->chan, chan, strlen(chan) + 1);
59    
60     r->next = request_start;
61     request_start = r;
62    
63     putlog(LOG_DEBUG, "*", "botnetop.mod: new request record created for %s on %s (address: %u)", r->handle, r->chan, r);
64    
65     return r;
66     }
67    
68     static void del_request(struct request_t *request)
69     {
70     struct request_t *r = NULL, *old = NULL;
71    
72     for (r = request_start; r != NULL; old = r, r = r->next) {
73     if (r == request) {
74     if (old != NULL)
75     old->next = r->next;
76     else
77     request_start = r->next;
78     putlog(LOG_DEBUG, "*", "botnetop.mod: request record removed from %s on %s (address: %u)", r->handle, r->chan, r);
79     if (r->handle != NULL)
80     nfree(r->handle);
81     if (r->chan != NULL)
82     nfree(r->chan);
83     nfree(r);
84     break;
85     }
86     }
87     }
88    
89     static int check_request_status(char *handle, char *chan)
90     {
91     if (!find_request(handle, chan)) {
92 pseudo 1.2 (void) add_request(handle, chan);
93 sup 1.1 return 0;
94     } else
95     return 1;
96     }
97    
98     static void request_free_mem()
99     {
100     struct request_t *r = NULL, *rnext = NULL;
101    
102     for (r = request_start; r != NULL; r = rnext) {
103     rnext = r->next;
104     if (r->handle != NULL)
105     nfree(r->handle);
106     if (r->chan != NULL)
107     nfree(r->chan);
108     nfree(r);
109     }
110     request_start = NULL;
111     }
112    
113     static int request_expmem()
114     {
115     int size = 0;
116     struct request_t *r = NULL;
117    
118     for (r = request_start; r != NULL; r = r->next) {
119     if (r->handle != NULL)
120     size += strlen(r->handle) + 1;
121     if (r->chan != NULL)
122     size += strlen(r->chan) + 1;
123     size += sizeof(struct request_t);
124     }
125    
126     return size;
127     }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23