Blame


1 38b9cb88 2001-12-14 alex /*
2 38b9cb88 2001-12-14 alex * ngIRCd -- The Next Generation IRC Daemon
3 1547f76c 2002-01-02 alex * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4 38b9cb88 2001-12-14 alex *
5 490f28ff 2002-12-12 alex * This program is free software; you can redistribute it and/or modify
6 490f28ff 2002-12-12 alex * it under the terms of the GNU General Public License as published by
7 490f28ff 2002-12-12 alex * the Free Software Foundation; either version 2 of the License, or
8 490f28ff 2002-12-12 alex * (at your option) any later version.
9 490f28ff 2002-12-12 alex * Please read the file COPYING, README and AUTHORS for more information.
10 38b9cb88 2001-12-14 alex *
11 490f28ff 2002-12-12 alex * Client management.
12 38b9cb88 2001-12-14 alex */
13 38b9cb88 2001-12-14 alex
14 38b9cb88 2001-12-14 alex
15 f7551900 2002-01-04 alex #define __client_c__
16 f7551900 2002-01-04 alex
17 f7551900 2002-01-04 alex
18 ca33cbda 2002-03-12 alex #include "portab.h"
19 38b9cb88 2001-12-14 alex
20 cb76d96e 2004-03-11 alex static char UNUSED id[] = "$Id: client.c,v 1.76 2004/03/11 22:16:31 alex Exp $";
21 490f28ff 2002-12-12 alex
22 ca33cbda 2002-03-12 alex #include "imp.h"
23 38b9cb88 2001-12-14 alex #include <assert.h>
24 d0ac1e9c 2001-12-23 alex #include <unistd.h>
25 118adda8 2001-12-27 alex #include <stdio.h>
26 b20fa7c6 2002-01-01 alex #include <stdlib.h>
27 d0ac1e9c 2001-12-23 alex #include <string.h>
28 57c7e236 2004-01-17 alex #include <strings.h>
29 c57a4645 2001-12-27 alex #include <netdb.h>
30 38b9cb88 2001-12-14 alex
31 c2f60abe 2002-05-27 alex #include "conn.h"
32 c2f60abe 2002-05-27 alex
33 ca33cbda 2002-03-12 alex #include "exp.h"
34 08cf5607 2001-12-26 alex #include "client.h"
35 08cf5607 2001-12-26 alex
36 08cf5607 2001-12-26 alex #include <imp.h>
37 79809118 2002-01-06 alex #include "ngircd.h"
38 38b9cb88 2001-12-14 alex #include "channel.h"
39 c2f60abe 2002-05-27 alex #include "resolve.h"
40 9856253d 2001-12-30 alex #include "conf.h"
41 b5c16c22 2002-03-25 alex #include "hash.h"
42 ff54198f 2002-02-27 alex #include "irc-write.h"
43 38b9cb88 2001-12-14 alex #include "log.h"
44 08cf5607 2001-12-26 alex #include "messages.h"
45 38b9cb88 2001-12-14 alex
46 38b9cb88 2001-12-14 alex #include <exp.h>
47 38b9cb88 2001-12-14 alex
48 38b9cb88 2001-12-14 alex
49 467e76aa 2002-10-04 alex #define GETID_LEN (CLIENT_NICK_LEN-1) + 1 + (CLIENT_USER_LEN-1) + 1 + (CLIENT_HOST_LEN-1) + 1
50 467e76aa 2002-10-04 alex
51 467e76aa 2002-10-04 alex
52 f7551900 2002-01-04 alex LOCAL CLIENT *This_Server, *My_Clients;
53 467e76aa 2002-10-04 alex LOCAL CHAR GetID_Buffer[GETID_LEN];
54 08cf5607 2001-12-26 alex
55 08cf5607 2001-12-26 alex
56 c7b55aa6 2002-10-09 alex LOCAL LONG Count PARAMS(( CLIENT_TYPE Type ));
57 c7b55aa6 2002-10-09 alex LOCAL LONG MyCount PARAMS(( CLIENT_TYPE Type ));
58 b9d701db 2002-01-16 alex
59 c2f60abe 2002-05-27 alex LOCAL CLIENT *New_Client_Struct PARAMS(( VOID ));
60 c2f60abe 2002-05-27 alex LOCAL VOID Generate_MyToken PARAMS(( CLIENT *Client ));
61 d0304b19 2002-12-22 alex LOCAL VOID Adjust_Counters PARAMS(( CLIENT *Client ));
62 939767d5 2003-01-15 alex
63 939767d5 2003-01-15 alex #ifndef Client_DestroyNow
64 939767d5 2003-01-15 alex GLOBAL VOID Client_DestroyNow PARAMS((CLIENT *Client ));
65 939767d5 2003-01-15 alex #endif
66 38b9cb88 2001-12-14 alex
67 38b9cb88 2001-12-14 alex
68 d0304b19 2002-12-22 alex LONG Max_Users = 0, My_Max_Users = 0;
69 d0304b19 2002-12-22 alex
70 d0304b19 2002-12-22 alex
71 c2f60abe 2002-05-27 alex GLOBAL VOID
72 c2f60abe 2002-05-27 alex Client_Init( VOID )
73 38b9cb88 2001-12-14 alex {
74 c57a4645 2001-12-27 alex struct hostent *h;
75 c57a4645 2001-12-27 alex
76 38b9cb88 2001-12-14 alex This_Server = New_Client_Struct( );
77 38b9cb88 2001-12-14 alex if( ! This_Server )
78 38b9cb88 2001-12-14 alex {
79 38b9cb88 2001-12-14 alex Log( LOG_EMERG, "Can't allocate client structure for server! Going down." );
80 62796722 2003-03-31 alex Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
81 38b9cb88 2001-12-14 alex exit( 1 );
82 38b9cb88 2001-12-14 alex }
83 38b9cb88 2001-12-14 alex
84 38b9cb88 2001-12-14 alex /* Client-Struktur dieses Servers */
85 38b9cb88 2001-12-14 alex This_Server->next = NULL;
86 38b9cb88 2001-12-14 alex This_Server->type = CLIENT_SERVER;
87 38b9cb88 2001-12-14 alex This_Server->conn_id = NONE;
88 38b9cb88 2001-12-14 alex This_Server->introducer = This_Server;
89 8f7e7d66 2002-01-09 alex This_Server->mytoken = 1;
90 4fe7e9d6 2002-01-11 alex This_Server->hops = 0;
91 c57a4645 2001-12-27 alex
92 d0ac1e9c 2001-12-23 alex gethostname( This_Server->host, CLIENT_HOST_LEN );
93 c57a4645 2001-12-27 alex h = gethostbyname( This_Server->host );
94 695631b2 2002-12-26 alex if( h ) strlcpy( This_Server->host, h->h_name, sizeof( This_Server->host ));
95 c57a4645 2001-12-27 alex
96 b5c16c22 2002-03-25 alex Client_SetID( This_Server, Conf_ServerName );
97 b5c16c22 2002-03-25 alex Client_SetInfo( This_Server, Conf_ServerInfo );
98 d0ac1e9c 2001-12-23 alex
99 38b9cb88 2001-12-14 alex My_Clients = This_Server;
100 38b9cb88 2001-12-14 alex } /* Client_Init */
101 38b9cb88 2001-12-14 alex
102 38b9cb88 2001-12-14 alex
103 c2f60abe 2002-05-27 alex GLOBAL VOID
104 c2f60abe 2002-05-27 alex Client_Exit( VOID )
105 38b9cb88 2001-12-14 alex {
106 d0ac1e9c 2001-12-23 alex CLIENT *c, *next;
107 d0ac1e9c 2001-12-23 alex INT cnt;
108 d0ac1e9c 2001-12-23 alex
109 77c4c015 2002-12-19 alex if( NGIRCd_SignalRestart ) Client_Destroy( This_Server, "Server going down (restarting).", NULL, FALSE );
110 9cb74e81 2002-06-02 alex else Client_Destroy( This_Server, "Server going down.", NULL, FALSE );
111 d0ac1e9c 2001-12-23 alex
112 d0ac1e9c 2001-12-23 alex cnt = 0;
113 d0ac1e9c 2001-12-23 alex c = My_Clients;
114 d0ac1e9c 2001-12-23 alex while( c )
115 d0ac1e9c 2001-12-23 alex {
116 d0ac1e9c 2001-12-23 alex cnt++;
117 95a4b1b1 2002-03-25 alex next = (CLIENT *)c->next;
118 d0ac1e9c 2001-12-23 alex free( c );
119 d0ac1e9c 2001-12-23 alex c = next;
120 d0ac1e9c 2001-12-23 alex }
121 d4a60bd4 2001-12-25 alex if( cnt ) Log( LOG_INFO, "Freed %d client structure%s.", cnt, cnt == 1 ? "" : "s" );
122 79809118 2002-01-06 alex } /* Client_Exit */
123 38b9cb88 2001-12-14 alex
124 38b9cb88 2001-12-14 alex
125 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
126 c2f60abe 2002-05-27 alex Client_ThisServer( VOID )
127 d0ac1e9c 2001-12-23 alex {
128 f7551900 2002-01-04 alex return This_Server;
129 f7551900 2002-01-04 alex } /* Client_ThisServer */
130 f7551900 2002-01-04 alex
131 f7551900 2002-01-04 alex
132 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
133 c2f60abe 2002-05-27 alex Client_NewLocal( CONN_ID Idx, CHAR *Hostname, INT Type, BOOLEAN Idented )
134 f7551900 2002-01-04 alex {
135 f7551900 2002-01-04 alex /* Neuen lokalen Client erzeugen: Wrapper-Funktion fuer Client_New(). */
136 1ab92bb9 2002-01-29 alex return Client_New( Idx, This_Server, NULL, Type, NULL, NULL, Hostname, NULL, 0, 0, NULL, Idented );
137 f7551900 2002-01-04 alex } /* Client_NewLocal */
138 f7551900 2002-01-04 alex
139 f7551900 2002-01-04 alex
140 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
141 c2f60abe 2002-05-27 alex Client_NewRemoteServer( CLIENT *Introducer, CHAR *Hostname, CLIENT *TopServer, INT Hops, INT Token, CHAR *Info, BOOLEAN Idented )
142 f7551900 2002-01-04 alex {
143 f7551900 2002-01-04 alex /* Neuen Remote-Client erzeugen: Wrapper-Funktion fuer Client_New (). */
144 1ab92bb9 2002-01-29 alex return Client_New( NONE, Introducer, TopServer, CLIENT_SERVER, Hostname, NULL, Hostname, Info, Hops, Token, NULL, Idented );
145 f7551900 2002-01-04 alex } /* Client_NewRemoteServer */
146 f7551900 2002-01-04 alex
147 f7551900 2002-01-04 alex
148 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
149 c2f60abe 2002-05-27 alex Client_NewRemoteUser( CLIENT *Introducer, CHAR *Nick, INT Hops, CHAR *User, CHAR *Hostname, INT Token, CHAR *Modes, CHAR *Info, BOOLEAN Idented )
150 f7551900 2002-01-04 alex {
151 f7551900 2002-01-04 alex /* Neuen Remote-Client erzeugen: Wrapper-Funktion fuer Client_New (). */
152 1ab92bb9 2002-01-29 alex return Client_New( NONE, Introducer, NULL, CLIENT_USER, Nick, User, Hostname, Info, Hops, Token, Modes, Idented );
153 f7551900 2002-01-04 alex } /* Client_NewRemoteUser */
154 f7551900 2002-01-04 alex
155 f7551900 2002-01-04 alex
156 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
157 c2f60abe 2002-05-27 alex Client_New( CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer, INT Type, CHAR *ID, CHAR *User, CHAR *Hostname, CHAR *Info, INT Hops, INT Token, CHAR *Modes, BOOLEAN Idented )
158 f7551900 2002-01-04 alex {
159 d0ac1e9c 2001-12-23 alex CLIENT *client;
160 d0ac1e9c 2001-12-23 alex
161 f7551900 2002-01-04 alex assert( Idx >= NONE );
162 f7551900 2002-01-04 alex assert( Introducer != NULL );
163 b7a18e9f 2001-12-24 alex assert( Hostname != NULL );
164 f7551900 2002-01-04 alex
165 d0ac1e9c 2001-12-23 alex client = New_Client_Struct( );
166 d0ac1e9c 2001-12-23 alex if( ! client ) return NULL;
167 d0ac1e9c 2001-12-23 alex
168 2c5da58d 2001-12-29 alex /* Initialisieren */
169 d0ac1e9c 2001-12-23 alex client->conn_id = Idx;
170 f7551900 2002-01-04 alex client->introducer = Introducer;
171 1ab92bb9 2002-01-29 alex client->topserver = TopServer;
172 f7551900 2002-01-04 alex client->type = Type;
173 f7551900 2002-01-04 alex if( ID ) Client_SetID( client, ID );
174 904d5e5b 2002-01-05 alex if( User ) Client_SetUser( client, User, Idented );
175 f7551900 2002-01-04 alex if( Hostname ) Client_SetHostname( client, Hostname );
176 f7551900 2002-01-04 alex if( Info ) Client_SetInfo( client, Info );
177 f7551900 2002-01-04 alex client->hops = Hops;
178 f7551900 2002-01-04 alex client->token = Token;
179 f7551900 2002-01-04 alex if( Modes ) Client_SetModes( client, Modes );
180 a53857b4 2002-01-07 alex if( Type == CLIENT_SERVER ) Generate_MyToken( client );
181 d0ac1e9c 2001-12-23 alex
182 a1a3e67d 2002-03-04 alex /* ist der User away? */
183 695631b2 2002-12-26 alex if( strchr( client->modes, 'a' )) strlcpy( client->away, DEFAULT_AWAY_MSG, sizeof( client->away ));
184 a1a3e67d 2002-03-04 alex
185 d0ac1e9c 2001-12-23 alex /* Verketten */
186 95a4b1b1 2002-03-25 alex client->next = (POINTER *)My_Clients;
187 d0ac1e9c 2001-12-23 alex My_Clients = client;
188 f7551900 2002-01-04 alex
189 d0304b19 2002-12-22 alex /* Adjust counters */
190 d0304b19 2002-12-22 alex Adjust_Counters( client );
191 d0304b19 2002-12-22 alex
192 d0ac1e9c 2001-12-23 alex return client;
193 f7551900 2002-01-04 alex } /* Client_New */
194 d0ac1e9c 2001-12-23 alex
195 d0ac1e9c 2001-12-23 alex
196 c2f60abe 2002-05-27 alex GLOBAL VOID
197 c2f60abe 2002-05-27 alex Client_Destroy( CLIENT *Client, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN SendQuit )
198 d0ac1e9c 2001-12-23 alex {
199 d0ac1e9c 2001-12-23 alex /* Client entfernen. */
200 d0ac1e9c 2001-12-23 alex
201 d0ac1e9c 2001-12-23 alex CLIENT *last, *c;
202 dce77559 2002-03-10 alex CHAR msg[LINE_LEN], *txt;
203 d0ac1e9c 2001-12-23 alex
204 b7a18e9f 2001-12-24 alex assert( Client != NULL );
205 c4854470 2002-01-04 alex
206 79809118 2002-01-06 alex if( LogMsg ) txt = LogMsg;
207 79809118 2002-01-06 alex else txt = FwdMsg;
208 79809118 2002-01-06 alex if( ! txt ) txt = "Reason unknown.";
209 dce77559 2002-03-10 alex
210 03c3f3c9 2002-03-12 alex /* Netz-Split-Nachricht vorbereiten (noch nicht optimal) */
211 b316c380 2002-12-26 alex if( Client->type == CLIENT_SERVER ) snprintf( msg, sizeof( msg ), "%s: lost server %s", This_Server->id, Client->id );
212 79809118 2002-01-06 alex
213 d0ac1e9c 2001-12-23 alex last = NULL;
214 d0ac1e9c 2001-12-23 alex c = My_Clients;
215 d0ac1e9c 2001-12-23 alex while( c )
216 d0ac1e9c 2001-12-23 alex {
217 c4854470 2002-01-04 alex if(( Client->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c != Client ))
218 c4854470 2002-01-04 alex {
219 dce77559 2002-03-10 alex /* der Client, der geloescht wird ist ein Server. Der Client, den wir gerade
220 dce77559 2002-03-10 alex * pruefen, ist ein Child von diesem und muss daher auch entfernt werden */
221 50ec7a56 2002-03-11 alex Client_Destroy( c, NULL, msg, FALSE );
222 c4854470 2002-01-04 alex last = NULL;
223 c4854470 2002-01-04 alex c = My_Clients;
224 c4854470 2002-01-04 alex continue;
225 c4854470 2002-01-04 alex }
226 d0ac1e9c 2001-12-23 alex if( c == Client )
227 d0ac1e9c 2001-12-23 alex {
228 dce77559 2002-03-10 alex /* Wir haben den Client gefunden: entfernen */
229 d0ac1e9c 2001-12-23 alex if( last ) last->next = c->next;
230 95a4b1b1 2002-03-25 alex else My_Clients = (CLIENT *)c->next;
231 15764f98 2001-12-27 alex
232 c4854470 2002-01-04 alex if( c->type == CLIENT_USER )
233 c4854470 2002-01-04 alex {
234 db58d347 2002-01-05 alex if( c->conn_id != NONE )
235 db58d347 2002-01-05 alex {
236 50ec7a56 2002-03-11 alex /* Ein lokaler User */
237 b89c3108 2002-01-07 alex Log( LOG_NOTICE, "User \"%s\" unregistered (connection %d): %s", Client_Mask( c ), c->conn_id, txt );
238 79809118 2002-01-06 alex
239 50ec7a56 2002-03-11 alex if( SendQuit )
240 50ec7a56 2002-03-11 alex {
241 50ec7a56 2002-03-11 alex /* Alle andere Server informieren! */
242 50ec7a56 2002-03-11 alex if( FwdMsg ) IRC_WriteStrServersPrefix( NULL, c, "QUIT :%s", FwdMsg );
243 50ec7a56 2002-03-11 alex else IRC_WriteStrServersPrefix( NULL, c, "QUIT :" );
244 50ec7a56 2002-03-11 alex }
245 db58d347 2002-01-05 alex }
246 79809118 2002-01-06 alex else
247 79809118 2002-01-06 alex {
248 50ec7a56 2002-03-11 alex /* Remote User */
249 b89c3108 2002-01-07 alex Log( LOG_DEBUG, "User \"%s\" unregistered: %s", Client_Mask( c ), txt );
250 50ec7a56 2002-03-11 alex
251 50ec7a56 2002-03-11 alex if( SendQuit )
252 50ec7a56 2002-03-11 alex {
253 50ec7a56 2002-03-11 alex /* Andere Server informieren, ausser denen, die "in
254 50ec7a56 2002-03-11 alex * Richtung dem liegen", auf dem der User registriert
255 50ec7a56 2002-03-11 alex * ist. Von denen haben wir das QUIT ja wohl bekommen. */
256 50ec7a56 2002-03-11 alex if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "QUIT :%s", FwdMsg );
257 50ec7a56 2002-03-11 alex else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "QUIT :" );
258 50ec7a56 2002-03-11 alex }
259 79809118 2002-01-06 alex }
260 dadebb21 2002-06-01 alex Channel_Quit( c, FwdMsg ? FwdMsg : c->id );
261 c4854470 2002-01-04 alex }
262 79809118 2002-01-06 alex else if( c->type == CLIENT_SERVER )
263 79809118 2002-01-06 alex {
264 28d58986 2002-02-27 alex if( c != This_Server )
265 28d58986 2002-02-27 alex {
266 6b58ab84 2002-03-27 alex if( c->conn_id != NONE ) Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt );
267 6b58ab84 2002-03-27 alex else Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered: %s", c->id, txt );
268 28d58986 2002-02-27 alex }
269 8f7e7d66 2002-01-09 alex
270 8f7e7d66 2002-01-09 alex /* andere Server informieren */
271 77c4c015 2002-12-19 alex if( ! NGIRCd_SignalQuit )
272 8f7e7d66 2002-01-09 alex {
273 8f7e7d66 2002-01-09 alex if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :%s", c->id, FwdMsg );
274 8f7e7d66 2002-01-09 alex else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :", c->id );
275 8f7e7d66 2002-01-09 alex }
276 79809118 2002-01-06 alex }
277 28d58986 2002-02-27 alex else
278 28d58986 2002-02-27 alex {
279 28d58986 2002-02-27 alex if( c->conn_id != NONE )
280 28d58986 2002-02-27 alex {
281 28d58986 2002-02-27 alex if( c->id[0] ) Log( LOG_NOTICE, "Client \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt );
282 28d58986 2002-02-27 alex else Log( LOG_NOTICE, "Client unregistered (connection %d): %s", c->conn_id, txt );
283 28d58986 2002-02-27 alex }
284 28d58986 2002-02-27 alex else
285 28d58986 2002-02-27 alex {
286 28d58986 2002-02-27 alex if( c->id[0] ) Log( LOG_WARNING, "Unregistered unknown client \"%s\": %s", c->id, txt );
287 28d58986 2002-02-27 alex else Log( LOG_WARNING, "Unregistered unknown client: %s", c->id, txt );
288 28d58986 2002-02-27 alex }
289 28d58986 2002-02-27 alex }
290 15764f98 2001-12-27 alex
291 d0ac1e9c 2001-12-23 alex free( c );
292 d0ac1e9c 2001-12-23 alex break;
293 d0ac1e9c 2001-12-23 alex }
294 d0ac1e9c 2001-12-23 alex last = c;
295 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
296 d0ac1e9c 2001-12-23 alex }
297 d0ac1e9c 2001-12-23 alex } /* Client_Destroy */
298 d0ac1e9c 2001-12-23 alex
299 d0ac1e9c 2001-12-23 alex
300 c2f60abe 2002-05-27 alex GLOBAL VOID
301 939767d5 2003-01-15 alex Client_DestroyNow( CLIENT *Client )
302 939767d5 2003-01-15 alex {
303 939767d5 2003-01-15 alex /* Destroy client structure immediately. This function is only
304 939767d5 2003-01-15 alex * intended for the connection layer to remove client structures
305 939767d5 2003-01-15 alex * of connections that can't be established! */
306 939767d5 2003-01-15 alex
307 939767d5 2003-01-15 alex CLIENT *last, *c;
308 939767d5 2003-01-15 alex
309 939767d5 2003-01-15 alex assert( Client != NULL );
310 939767d5 2003-01-15 alex
311 939767d5 2003-01-15 alex last = NULL;
312 939767d5 2003-01-15 alex c = My_Clients;
313 939767d5 2003-01-15 alex while( c )
314 939767d5 2003-01-15 alex {
315 939767d5 2003-01-15 alex if( c == Client )
316 939767d5 2003-01-15 alex {
317 939767d5 2003-01-15 alex /* Wir haben den Client gefunden: entfernen */
318 939767d5 2003-01-15 alex if( last ) last->next = c->next;
319 939767d5 2003-01-15 alex else My_Clients = (CLIENT *)c->next;
320 939767d5 2003-01-15 alex free( c );
321 939767d5 2003-01-15 alex break;
322 939767d5 2003-01-15 alex }
323 939767d5 2003-01-15 alex last = c;
324 939767d5 2003-01-15 alex c = (CLIENT *)c->next;
325 939767d5 2003-01-15 alex }
326 939767d5 2003-01-15 alex } /* Client_DestroyNow */
327 939767d5 2003-01-15 alex
328 939767d5 2003-01-15 alex
329 939767d5 2003-01-15 alex GLOBAL VOID
330 c2f60abe 2002-05-27 alex Client_SetHostname( CLIENT *Client, CHAR *Hostname )
331 2c5da58d 2001-12-29 alex {
332 2c5da58d 2001-12-29 alex /* Hostname eines Clients setzen */
333 2c5da58d 2001-12-29 alex
334 2c5da58d 2001-12-29 alex assert( Client != NULL );
335 c68c092c 2002-03-06 alex assert( Hostname != NULL );
336 c68c092c 2002-03-06 alex
337 0ced4181 2002-12-26 alex strlcpy( Client->host, Hostname, sizeof( Client->host ));
338 2c5da58d 2001-12-29 alex } /* Client_SetHostname */
339 f7551900 2002-01-04 alex
340 f7551900 2002-01-04 alex
341 c2f60abe 2002-05-27 alex GLOBAL VOID
342 c2f60abe 2002-05-27 alex Client_SetID( CLIENT *Client, CHAR *ID )
343 f7551900 2002-01-04 alex {
344 b5c16c22 2002-03-25 alex /* Hostname eines Clients setzen, Hash-Wert berechnen */
345 f7551900 2002-01-04 alex
346 f7551900 2002-01-04 alex assert( Client != NULL );
347 c68c092c 2002-03-06 alex assert( ID != NULL );
348 c68c092c 2002-03-06 alex
349 0ced4181 2002-12-26 alex strlcpy( Client->id, ID, sizeof( Client->id ));
350 b5c16c22 2002-03-25 alex
351 b5c16c22 2002-03-25 alex /* Hash */
352 b5c16c22 2002-03-25 alex Client->hash = Hash( Client->id );
353 f7551900 2002-01-04 alex } /* Client_SetID */
354 f7551900 2002-01-04 alex
355 f7551900 2002-01-04 alex
356 c2f60abe 2002-05-27 alex GLOBAL VOID
357 c2f60abe 2002-05-27 alex Client_SetUser( CLIENT *Client, CHAR *User, BOOLEAN Idented )
358 f7551900 2002-01-04 alex {
359 f7551900 2002-01-04 alex /* Username eines Clients setzen */
360 f7551900 2002-01-04 alex
361 f7551900 2002-01-04 alex assert( Client != NULL );
362 c68c092c 2002-03-06 alex assert( User != NULL );
363 c68c092c 2002-03-06 alex
364 0ced4181 2002-12-26 alex if( Idented ) strlcpy( Client->user, User, sizeof( Client->user ));
365 904d5e5b 2002-01-05 alex else
366 904d5e5b 2002-01-05 alex {
367 904d5e5b 2002-01-05 alex Client->user[0] = '~';
368 0ced4181 2002-12-26 alex strlcpy( Client->user + 1, User, sizeof( Client->user ) - 1 );
369 904d5e5b 2002-01-05 alex }
370 f7551900 2002-01-04 alex } /* Client_SetUser */
371 f7551900 2002-01-04 alex
372 f7551900 2002-01-04 alex
373 c2f60abe 2002-05-27 alex GLOBAL VOID
374 c2f60abe 2002-05-27 alex Client_SetInfo( CLIENT *Client, CHAR *Info )
375 f7551900 2002-01-04 alex {
376 f7551900 2002-01-04 alex /* Hostname eines Clients setzen */
377 f7551900 2002-01-04 alex
378 f7551900 2002-01-04 alex assert( Client != NULL );
379 c68c092c 2002-03-06 alex assert( Info != NULL );
380 c68c092c 2002-03-06 alex
381 0ced4181 2002-12-26 alex strlcpy( Client->info, Info, sizeof( Client->info ));
382 f7551900 2002-01-04 alex } /* Client_SetInfo */
383 f7551900 2002-01-04 alex
384 f7551900 2002-01-04 alex
385 c2f60abe 2002-05-27 alex GLOBAL VOID
386 c2f60abe 2002-05-27 alex Client_SetModes( CLIENT *Client, CHAR *Modes )
387 f7551900 2002-01-04 alex {
388 e62ad979 2002-09-03 alex /* Modes eines Clients setzen */
389 f7551900 2002-01-04 alex
390 f7551900 2002-01-04 alex assert( Client != NULL );
391 c68c092c 2002-03-06 alex assert( Modes != NULL );
392 c68c092c 2002-03-06 alex
393 0ced4181 2002-12-26 alex strlcpy( Client->modes, Modes, sizeof( Client->modes ));
394 f7551900 2002-01-04 alex } /* Client_SetModes */
395 e62ad979 2002-09-03 alex
396 e62ad979 2002-09-03 alex
397 e62ad979 2002-09-03 alex GLOBAL VOID
398 e62ad979 2002-09-03 alex Client_SetFlags( CLIENT *Client, CHAR *Flags )
399 e62ad979 2002-09-03 alex {
400 e62ad979 2002-09-03 alex /* Flags eines Clients setzen */
401 e62ad979 2002-09-03 alex
402 e62ad979 2002-09-03 alex assert( Client != NULL );
403 e62ad979 2002-09-03 alex assert( Flags != NULL );
404 e62ad979 2002-09-03 alex
405 0ced4181 2002-12-26 alex strlcpy( Client->flags, Flags, sizeof( Client->flags ));
406 e62ad979 2002-09-03 alex } /* Client_SetFlags */
407 f7551900 2002-01-04 alex
408 f7551900 2002-01-04 alex
409 c2f60abe 2002-05-27 alex GLOBAL VOID
410 c2f60abe 2002-05-27 alex Client_SetPassword( CLIENT *Client, CHAR *Pwd )
411 f7551900 2002-01-04 alex {
412 f7551900 2002-01-04 alex /* Von einem Client geliefertes Passwort */
413 f7551900 2002-01-04 alex
414 f7551900 2002-01-04 alex assert( Client != NULL );
415 c68c092c 2002-03-06 alex assert( Pwd != NULL );
416 c68c092c 2002-03-06 alex
417 0ced4181 2002-12-26 alex strlcpy( Client->pwd, Pwd, sizeof( Client->pwd ));
418 f7551900 2002-01-04 alex } /* Client_SetPassword */
419 c4850124 2002-02-27 alex
420 c4850124 2002-02-27 alex
421 c2f60abe 2002-05-27 alex GLOBAL VOID
422 c2f60abe 2002-05-27 alex Client_SetAway( CLIENT *Client, CHAR *Txt )
423 c4850124 2002-02-27 alex {
424 51e1a2e0 2003-01-08 alex /* Set AWAY reason of client */
425 c4850124 2002-02-27 alex
426 c4850124 2002-02-27 alex assert( Client != NULL );
427 51e1a2e0 2003-01-08 alex assert( Txt != NULL );
428 c4850124 2002-02-27 alex
429 51e1a2e0 2003-01-08 alex strlcpy( Client->away, Txt, sizeof( Client->away ));
430 51e1a2e0 2003-01-08 alex Log( LOG_DEBUG, "User \"%s\" is away: %s", Client_Mask( Client ), Txt );
431 c4850124 2002-02-27 alex } /* Client_SetAway */
432 f7551900 2002-01-04 alex
433 f7551900 2002-01-04 alex
434 c2f60abe 2002-05-27 alex GLOBAL VOID
435 c2f60abe 2002-05-27 alex Client_SetType( CLIENT *Client, INT Type )
436 f7551900 2002-01-04 alex {
437 f7551900 2002-01-04 alex assert( Client != NULL );
438 f7551900 2002-01-04 alex Client->type = Type;
439 a53857b4 2002-01-07 alex if( Type == CLIENT_SERVER ) Generate_MyToken( Client );
440 d0304b19 2002-12-22 alex Adjust_Counters( Client );
441 f7551900 2002-01-04 alex } /* Client_SetType */
442 f7551900 2002-01-04 alex
443 f7551900 2002-01-04 alex
444 c2f60abe 2002-05-27 alex GLOBAL VOID
445 c2f60abe 2002-05-27 alex Client_SetHops( CLIENT *Client, INT Hops )
446 f7551900 2002-01-04 alex {
447 f7551900 2002-01-04 alex assert( Client != NULL );
448 f7551900 2002-01-04 alex Client->hops = Hops;
449 f7551900 2002-01-04 alex } /* Client_SetHops */
450 f7551900 2002-01-04 alex
451 f7551900 2002-01-04 alex
452 c2f60abe 2002-05-27 alex GLOBAL VOID
453 c2f60abe 2002-05-27 alex Client_SetToken( CLIENT *Client, INT Token )
454 f7551900 2002-01-04 alex {
455 f7551900 2002-01-04 alex assert( Client != NULL );
456 f7551900 2002-01-04 alex Client->token = Token;
457 f7551900 2002-01-04 alex } /* Client_SetToken */
458 f7551900 2002-01-04 alex
459 f7551900 2002-01-04 alex
460 c2f60abe 2002-05-27 alex GLOBAL VOID
461 c2f60abe 2002-05-27 alex Client_SetIntroducer( CLIENT *Client, CLIENT *Introducer )
462 f7551900 2002-01-04 alex {
463 f7551900 2002-01-04 alex assert( Client != NULL );
464 c68c092c 2002-03-06 alex assert( Introducer != NULL );
465 f7551900 2002-01-04 alex Client->introducer = Introducer;
466 f7551900 2002-01-04 alex } /* Client_SetIntroducer */
467 f7551900 2002-01-04 alex
468 f7551900 2002-01-04 alex
469 c2f60abe 2002-05-27 alex GLOBAL VOID
470 c2f60abe 2002-05-27 alex Client_SetOperByMe( CLIENT *Client, BOOLEAN OperByMe )
471 f7551900 2002-01-04 alex {
472 f7551900 2002-01-04 alex assert( Client != NULL );
473 f7551900 2002-01-04 alex Client->oper_by_me = OperByMe;
474 f7551900 2002-01-04 alex } /* Client_SetOperByMe */
475 f7551900 2002-01-04 alex
476 f7551900 2002-01-04 alex
477 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
478 c2f60abe 2002-05-27 alex Client_ModeAdd( CLIENT *Client, CHAR Mode )
479 f7551900 2002-01-04 alex {
480 f7551900 2002-01-04 alex /* Mode soll gesetzt werden. TRUE wird geliefert, wenn der
481 f7551900 2002-01-04 alex * Mode neu gesetzt wurde, FALSE, wenn der Client den Mode
482 f7551900 2002-01-04 alex * bereits hatte. */
483 f7551900 2002-01-04 alex
484 f7551900 2002-01-04 alex CHAR x[2];
485 f7551900 2002-01-04 alex
486 f7551900 2002-01-04 alex assert( Client != NULL );
487 f7551900 2002-01-04 alex
488 f7551900 2002-01-04 alex x[0] = Mode; x[1] = '\0';
489 f7551900 2002-01-04 alex if( ! strchr( Client->modes, x[0] ))
490 f7551900 2002-01-04 alex {
491 f7551900 2002-01-04 alex /* Client hat den Mode noch nicht -> setzen */
492 6626395c 2002-12-26 alex strlcat( Client->modes, x, sizeof( Client->modes ));
493 f7551900 2002-01-04 alex return TRUE;
494 f7551900 2002-01-04 alex }
495 f7551900 2002-01-04 alex else return FALSE;
496 f7551900 2002-01-04 alex } /* Client_ModeAdd */
497 f7551900 2002-01-04 alex
498 f7551900 2002-01-04 alex
499 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
500 c2f60abe 2002-05-27 alex Client_ModeDel( CLIENT *Client, CHAR Mode )
501 f7551900 2002-01-04 alex {
502 f7551900 2002-01-04 alex /* Mode soll geloescht werden. TRUE wird geliefert, wenn der
503 f7551900 2002-01-04 alex * Mode entfernt wurde, FALSE, wenn der Client den Mode
504 f7551900 2002-01-04 alex * ueberhaupt nicht hatte. */
505 f7551900 2002-01-04 alex
506 f7551900 2002-01-04 alex CHAR x[2], *p;
507 f7551900 2002-01-04 alex
508 f7551900 2002-01-04 alex assert( Client != NULL );
509 f7551900 2002-01-04 alex
510 f7551900 2002-01-04 alex x[0] = Mode; x[1] = '\0';
511 2c5da58d 2001-12-29 alex
512 f7551900 2002-01-04 alex p = strchr( Client->modes, x[0] );
513 f7551900 2002-01-04 alex if( ! p ) return FALSE;
514 2c5da58d 2001-12-29 alex
515 f7551900 2002-01-04 alex /* Client hat den Mode -> loeschen */
516 f7551900 2002-01-04 alex while( *p )
517 f7551900 2002-01-04 alex {
518 f7551900 2002-01-04 alex *p = *(p + 1);
519 f7551900 2002-01-04 alex p++;
520 f7551900 2002-01-04 alex }
521 f7551900 2002-01-04 alex return TRUE;
522 f7551900 2002-01-04 alex } /* Client_ModeDel */
523 f7551900 2002-01-04 alex
524 f7551900 2002-01-04 alex
525 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
526 c2f60abe 2002-05-27 alex Client_GetFromConn( CONN_ID Idx )
527 d0ac1e9c 2001-12-23 alex {
528 804b1ec4 2001-12-31 alex /* Client-Struktur, die zur lokalen Verbindung Idx gehoert,
529 d0ac1e9c 2001-12-23 alex * liefern. Wird keine gefunden, so wird NULL geliefert. */
530 d0ac1e9c 2001-12-23 alex
531 d0ac1e9c 2001-12-23 alex CLIENT *c;
532 d0ac1e9c 2001-12-23 alex
533 b7a18e9f 2001-12-24 alex assert( Idx >= 0 );
534 b7a18e9f 2001-12-24 alex
535 d0ac1e9c 2001-12-23 alex c = My_Clients;
536 d0ac1e9c 2001-12-23 alex while( c )
537 d0ac1e9c 2001-12-23 alex {
538 d0ac1e9c 2001-12-23 alex if( c->conn_id == Idx ) return c;
539 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
540 d0ac1e9c 2001-12-23 alex }
541 d0ac1e9c 2001-12-23 alex return NULL;
542 d0ac1e9c 2001-12-23 alex } /* Client_GetFromConn */
543 d0ac1e9c 2001-12-23 alex
544 d0ac1e9c 2001-12-23 alex
545 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
546 c2f60abe 2002-05-27 alex Client_Search( CHAR *Nick )
547 90676129 2001-12-26 alex {
548 10363b39 2002-03-03 alex /* Client-Struktur, die den entsprechenden Nick hat, liefern.
549 10363b39 2002-03-03 alex * Wird keine gefunden, so wird NULL geliefert. */
550 804b1ec4 2001-12-31 alex
551 b5c16c22 2002-03-25 alex CHAR search_id[CLIENT_ID_LEN], *ptr;
552 40c9fd26 2002-01-27 alex CLIENT *c = NULL;
553 b5c16c22 2002-03-25 alex UINT32 search_hash;
554 804b1ec4 2001-12-31 alex
555 804b1ec4 2001-12-31 alex assert( Nick != NULL );
556 d17748e9 2002-01-27 alex
557 40c9fd26 2002-01-27 alex /* Nick kopieren und ggf. Host-Mask abschneiden */
558 0ced4181 2002-12-26 alex strlcpy( search_id, Nick, sizeof( search_id ));
559 b5c16c22 2002-03-25 alex ptr = strchr( search_id, '!' );
560 d17748e9 2002-01-27 alex if( ptr ) *ptr = '\0';
561 804b1ec4 2001-12-31 alex
562 b5c16c22 2002-03-25 alex search_hash = Hash( search_id );
563 b5c16c22 2002-03-25 alex
564 804b1ec4 2001-12-31 alex c = My_Clients;
565 804b1ec4 2001-12-31 alex while( c )
566 804b1ec4 2001-12-31 alex {
567 b5c16c22 2002-03-25 alex if( c->hash == search_hash )
568 b5c16c22 2002-03-25 alex {
569 b5c16c22 2002-03-25 alex /* lt. Hash-Wert: Treffer! */
570 b5c16c22 2002-03-25 alex if( strcasecmp( c->id, search_id ) == 0 ) return c;
571 b5c16c22 2002-03-25 alex }
572 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
573 804b1ec4 2001-12-31 alex }
574 804b1ec4 2001-12-31 alex return NULL;
575 b5c16c22 2002-03-25 alex } /* Client_Search */
576 804b1ec4 2001-12-31 alex
577 804b1ec4 2001-12-31 alex
578 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
579 c2f60abe 2002-05-27 alex Client_GetFromToken( CLIENT *Client, INT Token )
580 804b1ec4 2001-12-31 alex {
581 f7551900 2002-01-04 alex /* Client-Struktur, die den entsprechenden Introducer (=Client)
582 f7551900 2002-01-04 alex * und das gegebene Token hat, liefern. Wird keine gefunden,
583 f7551900 2002-01-04 alex * so wird NULL geliefert. */
584 f7551900 2002-01-04 alex
585 f7551900 2002-01-04 alex CLIENT *c;
586 f7551900 2002-01-04 alex
587 90676129 2001-12-26 alex assert( Client != NULL );
588 f7551900 2002-01-04 alex assert( Token > 0 );
589 90676129 2001-12-26 alex
590 f7551900 2002-01-04 alex c = My_Clients;
591 f7551900 2002-01-04 alex while( c )
592 f7551900 2002-01-04 alex {
593 f7551900 2002-01-04 alex if(( c->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c->token == Token )) return c;
594 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
595 f7551900 2002-01-04 alex }
596 f7551900 2002-01-04 alex return NULL;
597 f7551900 2002-01-04 alex } /* Client_GetFromToken */
598 f7551900 2002-01-04 alex
599 f7551900 2002-01-04 alex
600 c2f60abe 2002-05-27 alex GLOBAL INT
601 c2f60abe 2002-05-27 alex Client_Type( CLIENT *Client )
602 f7551900 2002-01-04 alex {
603 f7551900 2002-01-04 alex assert( Client != NULL );
604 f7551900 2002-01-04 alex return Client->type;
605 f7551900 2002-01-04 alex } /* Client_Type */
606 f7551900 2002-01-04 alex
607 f7551900 2002-01-04 alex
608 c2f60abe 2002-05-27 alex GLOBAL CONN_ID
609 c2f60abe 2002-05-27 alex Client_Conn( CLIENT *Client )
610 f7551900 2002-01-04 alex {
611 f7551900 2002-01-04 alex assert( Client != NULL );
612 f7551900 2002-01-04 alex return Client->conn_id;
613 f7551900 2002-01-04 alex } /* Client_Conn */
614 f7551900 2002-01-04 alex
615 f7551900 2002-01-04 alex
616 c2f60abe 2002-05-27 alex GLOBAL CHAR *
617 c2f60abe 2002-05-27 alex Client_ID( CLIENT *Client )
618 f7551900 2002-01-04 alex {
619 f7551900 2002-01-04 alex assert( Client != NULL );
620 f7551900 2002-01-04 alex
621 c68c092c 2002-03-06 alex #ifdef DEBUG
622 c68c092c 2002-03-06 alex if( Client->type == CLIENT_USER ) assert( strlen( Client->id ) < CLIENT_NICK_LEN );
623 c68c092c 2002-03-06 alex #endif
624 c68c092c 2002-03-06 alex
625 f7551900 2002-01-04 alex if( Client->id[0] ) return Client->id;
626 90676129 2001-12-26 alex else return "*";
627 f7551900 2002-01-04 alex } /* Client_ID */
628 90676129 2001-12-26 alex
629 90676129 2001-12-26 alex
630 c2f60abe 2002-05-27 alex GLOBAL CHAR *
631 c2f60abe 2002-05-27 alex Client_Info( CLIENT *Client )
632 f7551900 2002-01-04 alex {
633 f7551900 2002-01-04 alex assert( Client != NULL );
634 f7551900 2002-01-04 alex return Client->info;
635 f7551900 2002-01-04 alex } /* Client_Info */
636 f7551900 2002-01-04 alex
637 f7551900 2002-01-04 alex
638 c2f60abe 2002-05-27 alex GLOBAL CHAR *
639 c2f60abe 2002-05-27 alex Client_User( CLIENT *Client )
640 f7551900 2002-01-04 alex {
641 f7551900 2002-01-04 alex assert( Client != NULL );
642 95a4b1b1 2002-03-25 alex if( Client->user[0] ) return Client->user;
643 f7551900 2002-01-04 alex else return "~";
644 f7551900 2002-01-04 alex } /* Client_User */
645 f7551900 2002-01-04 alex
646 f7551900 2002-01-04 alex
647 c2f60abe 2002-05-27 alex GLOBAL CHAR *
648 c2f60abe 2002-05-27 alex Client_Hostname( CLIENT *Client )
649 f7551900 2002-01-04 alex {
650 f7551900 2002-01-04 alex assert( Client != NULL );
651 f7551900 2002-01-04 alex return Client->host;
652 f7551900 2002-01-04 alex } /* Client_Hostname */
653 f7551900 2002-01-04 alex
654 f7551900 2002-01-04 alex
655 c2f60abe 2002-05-27 alex GLOBAL CHAR *
656 c2f60abe 2002-05-27 alex Client_Password( CLIENT *Client )
657 f7551900 2002-01-04 alex {
658 f7551900 2002-01-04 alex assert( Client != NULL );
659 f7551900 2002-01-04 alex return Client->pwd;
660 f7551900 2002-01-04 alex } /* Client_Password */
661 f7551900 2002-01-04 alex
662 f7551900 2002-01-04 alex
663 c2f60abe 2002-05-27 alex GLOBAL CHAR *
664 c2f60abe 2002-05-27 alex Client_Modes( CLIENT *Client )
665 f7551900 2002-01-04 alex {
666 f7551900 2002-01-04 alex assert( Client != NULL );
667 f7551900 2002-01-04 alex return Client->modes;
668 f7551900 2002-01-04 alex } /* Client_Modes */
669 e62ad979 2002-09-03 alex
670 e62ad979 2002-09-03 alex
671 e62ad979 2002-09-03 alex GLOBAL CHAR *
672 e62ad979 2002-09-03 alex Client_Flags( CLIENT *Client )
673 e62ad979 2002-09-03 alex {
674 e62ad979 2002-09-03 alex assert( Client != NULL );
675 e62ad979 2002-09-03 alex return Client->flags;
676 e62ad979 2002-09-03 alex } /* Client_Flags */
677 f7551900 2002-01-04 alex
678 f7551900 2002-01-04 alex
679 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
680 c2f60abe 2002-05-27 alex Client_OperByMe( CLIENT *Client )
681 f7551900 2002-01-04 alex {
682 f7551900 2002-01-04 alex assert( Client != NULL );
683 f7551900 2002-01-04 alex return Client->oper_by_me;
684 f7551900 2002-01-04 alex } /* Client_OperByMe */
685 f7551900 2002-01-04 alex
686 f7551900 2002-01-04 alex
687 c2f60abe 2002-05-27 alex GLOBAL INT
688 c2f60abe 2002-05-27 alex Client_Hops( CLIENT *Client )
689 f7551900 2002-01-04 alex {
690 f7551900 2002-01-04 alex assert( Client != NULL );
691 f7551900 2002-01-04 alex return Client->hops;
692 f7551900 2002-01-04 alex } /* Client_Hops */
693 f7551900 2002-01-04 alex
694 f7551900 2002-01-04 alex
695 c2f60abe 2002-05-27 alex GLOBAL INT
696 c2f60abe 2002-05-27 alex Client_Token( CLIENT *Client )
697 f7551900 2002-01-04 alex {
698 f7551900 2002-01-04 alex assert( Client != NULL );
699 f7551900 2002-01-04 alex return Client->token;
700 f7551900 2002-01-04 alex } /* Client_Token */
701 a53857b4 2002-01-07 alex
702 a53857b4 2002-01-07 alex
703 c2f60abe 2002-05-27 alex GLOBAL INT
704 c2f60abe 2002-05-27 alex Client_MyToken( CLIENT *Client )
705 a53857b4 2002-01-07 alex {
706 a53857b4 2002-01-07 alex assert( Client != NULL );
707 a53857b4 2002-01-07 alex return Client->mytoken;
708 a53857b4 2002-01-07 alex } /* Client_MyToken */
709 f7551900 2002-01-04 alex
710 f7551900 2002-01-04 alex
711 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
712 c2f60abe 2002-05-27 alex Client_NextHop( CLIENT *Client )
713 e7be3a01 2002-01-05 alex {
714 e7be3a01 2002-01-05 alex CLIENT *c;
715 e7be3a01 2002-01-05 alex
716 e7be3a01 2002-01-05 alex assert( Client != NULL );
717 e7be3a01 2002-01-05 alex
718 e7be3a01 2002-01-05 alex c = Client;
719 e7be3a01 2002-01-05 alex while( c->introducer && ( c->introducer != c ) && ( c->introducer != This_Server )) c = c->introducer;
720 e7be3a01 2002-01-05 alex return c;
721 e7be3a01 2002-01-05 alex } /* Client_NextHop */
722 e7be3a01 2002-01-05 alex
723 e7be3a01 2002-01-05 alex
724 c2f60abe 2002-05-27 alex GLOBAL CHAR *
725 c2f60abe 2002-05-27 alex Client_Mask( CLIENT *Client )
726 f7551900 2002-01-04 alex {
727 f7551900 2002-01-04 alex /* Client-"ID" liefern, wie sie z.B. fuer
728 f7551900 2002-01-04 alex * Prefixe benoetigt wird. */
729 f7551900 2002-01-04 alex
730 f7551900 2002-01-04 alex assert( Client != NULL );
731 f7551900 2002-01-04 alex
732 f7551900 2002-01-04 alex if( Client->type == CLIENT_SERVER ) return Client->id;
733 f7551900 2002-01-04 alex
734 467e76aa 2002-10-04 alex snprintf( GetID_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user, Client->host );
735 f7551900 2002-01-04 alex return GetID_Buffer;
736 f7551900 2002-01-04 alex } /* Client_Mask */
737 f7551900 2002-01-04 alex
738 f7551900 2002-01-04 alex
739 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
740 c2f60abe 2002-05-27 alex Client_Introducer( CLIENT *Client )
741 f7551900 2002-01-04 alex {
742 f7551900 2002-01-04 alex assert( Client != NULL );
743 f7551900 2002-01-04 alex return Client->introducer;
744 f7551900 2002-01-04 alex } /* Client_Introducer */
745 f7551900 2002-01-04 alex
746 f7551900 2002-01-04 alex
747 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
748 c2f60abe 2002-05-27 alex Client_TopServer( CLIENT *Client )
749 1ab92bb9 2002-01-29 alex {
750 1ab92bb9 2002-01-29 alex assert( Client != NULL );
751 1ab92bb9 2002-01-29 alex return Client->topserver;
752 1ab92bb9 2002-01-29 alex } /* Client_TopServer */
753 1ab92bb9 2002-01-29 alex
754 1ab92bb9 2002-01-29 alex
755 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
756 c2f60abe 2002-05-27 alex Client_HasMode( CLIENT *Client, CHAR Mode )
757 f7551900 2002-01-04 alex {
758 f7551900 2002-01-04 alex assert( Client != NULL );
759 f7551900 2002-01-04 alex return strchr( Client->modes, Mode ) != NULL;
760 f7551900 2002-01-04 alex } /* Client_HasMode */
761 c4850124 2002-02-27 alex
762 c4850124 2002-02-27 alex
763 c2f60abe 2002-05-27 alex GLOBAL CHAR *
764 c2f60abe 2002-05-27 alex Client_Away( CLIENT *Client )
765 c4850124 2002-02-27 alex {
766 c4850124 2002-02-27 alex /* AWAY-Text liefern */
767 c4850124 2002-02-27 alex
768 c4850124 2002-02-27 alex assert( Client != NULL );
769 c4850124 2002-02-27 alex return Client->away;
770 c4850124 2002-02-27 alex } /* Client_Away */
771 f7551900 2002-01-04 alex
772 f7551900 2002-01-04 alex
773 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
774 c2f60abe 2002-05-27 alex Client_CheckNick( CLIENT *Client, CHAR *Nick )
775 08cf5607 2001-12-26 alex {
776 08cf5607 2001-12-26 alex /* Nick ueberpruefen */
777 08cf5607 2001-12-26 alex
778 08cf5607 2001-12-26 alex assert( Client != NULL );
779 08cf5607 2001-12-26 alex assert( Nick != NULL );
780 08cf5607 2001-12-26 alex
781 33944e8c 2002-02-06 alex /* Nick ungueltig? */
782 9f3a9df2 2002-02-17 alex if( ! Client_IsValidNick( Nick ))
783 9f3a9df2 2002-02-17 alex {
784 9f3a9df2 2002-02-17 alex IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), Nick );
785 9f3a9df2 2002-02-17 alex return FALSE;
786 9f3a9df2 2002-02-17 alex }
787 08cf5607 2001-12-26 alex
788 08cf5607 2001-12-26 alex /* Nick bereits vergeben? */
789 b5c16c22 2002-03-25 alex if( Client_Search( Nick ))
790 08cf5607 2001-12-26 alex {
791 b5c16c22 2002-03-25 alex /* den Nick gibt es bereits */
792 b5c16c22 2002-03-25 alex IRC_WriteStrClient( Client, ERR_NICKNAMEINUSE_MSG, Client_ID( Client ), Nick );
793 b5c16c22 2002-03-25 alex return FALSE;
794 08cf5607 2001-12-26 alex }
795 08cf5607 2001-12-26 alex
796 08cf5607 2001-12-26 alex return TRUE;
797 08cf5607 2001-12-26 alex } /* Client_CheckNick */
798 07903baa 2002-01-03 alex
799 07903baa 2002-01-03 alex
800 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
801 c2f60abe 2002-05-27 alex Client_CheckID( CLIENT *Client, CHAR *ID )
802 07903baa 2002-01-03 alex {
803 07903baa 2002-01-03 alex /* Nick ueberpruefen */
804 07903baa 2002-01-03 alex
805 07903baa 2002-01-03 alex CHAR str[COMMAND_LEN];
806 07903baa 2002-01-03 alex CLIENT *c;
807 07903baa 2002-01-03 alex
808 07903baa 2002-01-03 alex assert( Client != NULL );
809 07903baa 2002-01-03 alex assert( Client->conn_id > NONE );
810 07903baa 2002-01-03 alex assert( ID != NULL );
811 07903baa 2002-01-03 alex
812 07903baa 2002-01-03 alex /* Nick zu lang? */
813 9f3a9df2 2002-02-17 alex if( strlen( ID ) > CLIENT_ID_LEN )
814 9f3a9df2 2002-02-17 alex {
815 9f3a9df2 2002-02-17 alex IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), ID );
816 9f3a9df2 2002-02-17 alex return FALSE;
817 9f3a9df2 2002-02-17 alex }
818 08cf5607 2001-12-26 alex
819 07903baa 2002-01-03 alex /* ID bereits vergeben? */
820 07903baa 2002-01-03 alex c = My_Clients;
821 07903baa 2002-01-03 alex while( c )
822 07903baa 2002-01-03 alex {
823 f7551900 2002-01-04 alex if( strcasecmp( c->id, ID ) == 0 )
824 07903baa 2002-01-03 alex {
825 07903baa 2002-01-03 alex /* die Server-ID gibt es bereits */
826 b316c380 2002-12-26 alex snprintf( str, sizeof( str ), "ID \"%s\" already registered", ID );
827 9f122037 2002-12-03 alex if( Client->conn_id != c->conn_id ) Log( LOG_ERR, "%s (on connection %d)!", str, c->conn_id );
828 9f122037 2002-12-03 alex else Log( LOG_ERR, "%s (via network)!", str );
829 79809118 2002-01-06 alex Conn_Close( Client->conn_id, str, str, TRUE );
830 07903baa 2002-01-03 alex return FALSE;
831 07903baa 2002-01-03 alex }
832 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
833 07903baa 2002-01-03 alex }
834 08cf5607 2001-12-26 alex
835 07903baa 2002-01-03 alex return TRUE;
836 07903baa 2002-01-03 alex } /* Client_CheckID */
837 07903baa 2002-01-03 alex
838 07903baa 2002-01-03 alex
839 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
840 c2f60abe 2002-05-27 alex Client_First( VOID )
841 fb9d6ce1 2001-12-31 alex {
842 fb9d6ce1 2001-12-31 alex /* Ersten Client liefern. */
843 fb9d6ce1 2001-12-31 alex
844 fb9d6ce1 2001-12-31 alex return My_Clients;
845 fb9d6ce1 2001-12-31 alex } /* Client_First */
846 15764f98 2001-12-27 alex
847 15764f98 2001-12-27 alex
848 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
849 c2f60abe 2002-05-27 alex Client_Next( CLIENT *c )
850 fb9d6ce1 2001-12-31 alex {
851 fb9d6ce1 2001-12-31 alex /* Naechsten Client liefern. Existiert keiner,
852 fb9d6ce1 2001-12-31 alex * so wird NULL geliefert. */
853 fb9d6ce1 2001-12-31 alex
854 fb9d6ce1 2001-12-31 alex assert( c != NULL );
855 95a4b1b1 2002-03-25 alex return (CLIENT *)c->next;
856 fb9d6ce1 2001-12-31 alex } /* Client_Next */
857 b9d701db 2002-01-16 alex
858 b9d701db 2002-01-16 alex
859 c7b55aa6 2002-10-09 alex GLOBAL LONG
860 c2f60abe 2002-05-27 alex Client_UserCount( VOID )
861 b9d701db 2002-01-16 alex {
862 b9d701db 2002-01-16 alex return Count( CLIENT_USER );
863 b9d701db 2002-01-16 alex } /* Client_UserCount */
864 b9d701db 2002-01-16 alex
865 b9d701db 2002-01-16 alex
866 c7b55aa6 2002-10-09 alex GLOBAL LONG
867 c2f60abe 2002-05-27 alex Client_ServiceCount( VOID )
868 b9d701db 2002-01-16 alex {
869 b9d701db 2002-01-16 alex return Count( CLIENT_SERVICE );;
870 b9d701db 2002-01-16 alex } /* Client_ServiceCount */
871 b9d701db 2002-01-16 alex
872 b9d701db 2002-01-16 alex
873 c7b55aa6 2002-10-09 alex GLOBAL LONG
874 c2f60abe 2002-05-27 alex Client_ServerCount( VOID )
875 b9d701db 2002-01-16 alex {
876 b9d701db 2002-01-16 alex return Count( CLIENT_SERVER );
877 b9d701db 2002-01-16 alex } /* Client_ServerCount */
878 b9d701db 2002-01-16 alex
879 b9d701db 2002-01-16 alex
880 c7b55aa6 2002-10-09 alex GLOBAL LONG
881 c2f60abe 2002-05-27 alex Client_MyUserCount( VOID )
882 b9d701db 2002-01-16 alex {
883 b9d701db 2002-01-16 alex return MyCount( CLIENT_USER );
884 b9d701db 2002-01-16 alex } /* Client_MyUserCount */
885 b9d701db 2002-01-16 alex
886 b9d701db 2002-01-16 alex
887 c7b55aa6 2002-10-09 alex GLOBAL LONG
888 c2f60abe 2002-05-27 alex Client_MyServiceCount( VOID )
889 b9d701db 2002-01-16 alex {
890 b9d701db 2002-01-16 alex return MyCount( CLIENT_SERVICE );
891 b9d701db 2002-01-16 alex } /* Client_MyServiceCount */
892 b9d701db 2002-01-16 alex
893 b9d701db 2002-01-16 alex
894 c7b55aa6 2002-10-09 alex GLOBAL LONG
895 c2f60abe 2002-05-27 alex Client_MyServerCount( VOID )
896 b9d701db 2002-01-16 alex {
897 3be7b9ef 2002-04-14 alex CLIENT *c;
898 c7b55aa6 2002-10-09 alex LONG cnt;
899 3be7b9ef 2002-04-14 alex
900 3be7b9ef 2002-04-14 alex cnt = 0;
901 3be7b9ef 2002-04-14 alex c = My_Clients;
902 3be7b9ef 2002-04-14 alex while( c )
903 3be7b9ef 2002-04-14 alex {
904 3be7b9ef 2002-04-14 alex if(( c->type == CLIENT_SERVER ) && ( c->hops == 1 )) cnt++;
905 3be7b9ef 2002-04-14 alex c = (CLIENT *)c->next;
906 3be7b9ef 2002-04-14 alex }
907 3be7b9ef 2002-04-14 alex return cnt;
908 b9d701db 2002-01-16 alex } /* Client_MyServerCount */
909 b9d701db 2002-01-16 alex
910 b9d701db 2002-01-16 alex
911 c7b55aa6 2002-10-09 alex GLOBAL LONG
912 c2f60abe 2002-05-27 alex Client_OperCount( VOID )
913 b9d701db 2002-01-16 alex {
914 b9d701db 2002-01-16 alex CLIENT *c;
915 c7b55aa6 2002-10-09 alex LONG cnt;
916 b9d701db 2002-01-16 alex
917 b9d701db 2002-01-16 alex cnt = 0;
918 b9d701db 2002-01-16 alex c = My_Clients;
919 b9d701db 2002-01-16 alex while( c )
920 b9d701db 2002-01-16 alex {
921 b9d701db 2002-01-16 alex if( c && ( c->type == CLIENT_USER ) && ( strchr( c->modes, 'o' ))) cnt++;
922 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
923 b9d701db 2002-01-16 alex }
924 b9d701db 2002-01-16 alex return cnt;
925 b9d701db 2002-01-16 alex } /* Client_OperCount */
926 fb9d6ce1 2001-12-31 alex
927 fb9d6ce1 2001-12-31 alex
928 c7b55aa6 2002-10-09 alex GLOBAL LONG
929 c2f60abe 2002-05-27 alex Client_UnknownCount( VOID )
930 b9d701db 2002-01-16 alex {
931 b9d701db 2002-01-16 alex CLIENT *c;
932 c7b55aa6 2002-10-09 alex LONG cnt;
933 b9d701db 2002-01-16 alex
934 b9d701db 2002-01-16 alex cnt = 0;
935 b9d701db 2002-01-16 alex c = My_Clients;
936 b9d701db 2002-01-16 alex while( c )
937 b9d701db 2002-01-16 alex {
938 b9d701db 2002-01-16 alex if( c && ( c->type != CLIENT_USER ) && ( c->type != CLIENT_SERVICE ) && ( c->type != CLIENT_SERVER )) cnt++;
939 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
940 b9d701db 2002-01-16 alex }
941 b9d701db 2002-01-16 alex return cnt;
942 b9d701db 2002-01-16 alex } /* Client_UnknownCount */
943 d0304b19 2002-12-22 alex
944 d0304b19 2002-12-22 alex
945 d0304b19 2002-12-22 alex GLOBAL LONG
946 d0304b19 2002-12-22 alex Client_MaxUserCount( VOID )
947 d0304b19 2002-12-22 alex {
948 d0304b19 2002-12-22 alex return Max_Users;
949 d0304b19 2002-12-22 alex } /* Client_MaxUserCount */
950 d0304b19 2002-12-22 alex
951 d0304b19 2002-12-22 alex
952 d0304b19 2002-12-22 alex GLOBAL LONG
953 d0304b19 2002-12-22 alex Client_MyMaxUserCount( VOID )
954 d0304b19 2002-12-22 alex {
955 d0304b19 2002-12-22 alex return My_Max_Users;
956 d0304b19 2002-12-22 alex } /* Client_MyMaxUserCount */
957 b9d701db 2002-01-16 alex
958 b9d701db 2002-01-16 alex
959 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
960 c2f60abe 2002-05-27 alex Client_IsValidNick( CHAR *Nick )
961 33944e8c 2002-02-06 alex {
962 33944e8c 2002-02-06 alex /* Ist der Nick gueltig? */
963 7157d936 2002-03-02 alex
964 f7327524 2002-05-30 alex CHAR *ptr, goodchars[20];
965 33944e8c 2002-02-06 alex
966 33944e8c 2002-02-06 alex assert( Nick != NULL );
967 33944e8c 2002-02-06 alex
968 f7327524 2002-05-30 alex strcpy( goodchars, ";0123456789-" );
969 f7327524 2002-05-30 alex
970 33944e8c 2002-02-06 alex if( Nick[0] == '#' ) return FALSE;
971 7157d936 2002-03-02 alex if( strchr( goodchars, Nick[0] )) return FALSE;
972 7157d936 2002-03-02 alex if( strlen( Nick ) >= CLIENT_NICK_LEN ) return FALSE;
973 7157d936 2002-03-02 alex
974 7157d936 2002-03-02 alex ptr = Nick;
975 7157d936 2002-03-02 alex while( *ptr )
976 7157d936 2002-03-02 alex {
977 7157d936 2002-03-02 alex if(( *ptr < 'A' ) && ( ! strchr( goodchars, *ptr ))) return FALSE;
978 7157d936 2002-03-02 alex if(( *ptr > '}' ) && ( ! strchr( goodchars, *ptr ))) return FALSE;
979 7157d936 2002-03-02 alex ptr++;
980 7157d936 2002-03-02 alex }
981 7157d936 2002-03-02 alex
982 33944e8c 2002-02-06 alex return TRUE;
983 33944e8c 2002-02-06 alex } /* Client_IsValidNick */
984 33944e8c 2002-02-06 alex
985 33944e8c 2002-02-06 alex
986 c7b55aa6 2002-10-09 alex LOCAL LONG
987 c2f60abe 2002-05-27 alex Count( CLIENT_TYPE Type )
988 b9d701db 2002-01-16 alex {
989 b9d701db 2002-01-16 alex CLIENT *c;
990 c7b55aa6 2002-10-09 alex LONG cnt;
991 b9d701db 2002-01-16 alex
992 b9d701db 2002-01-16 alex cnt = 0;
993 b9d701db 2002-01-16 alex c = My_Clients;
994 b9d701db 2002-01-16 alex while( c )
995 b9d701db 2002-01-16 alex {
996 3be7b9ef 2002-04-14 alex if( c->type == Type ) cnt++;
997 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
998 b9d701db 2002-01-16 alex }
999 b9d701db 2002-01-16 alex return cnt;
1000 b9d701db 2002-01-16 alex } /* Count */
1001 b9d701db 2002-01-16 alex
1002 b9d701db 2002-01-16 alex
1003 c7b55aa6 2002-10-09 alex LOCAL LONG
1004 c2f60abe 2002-05-27 alex MyCount( CLIENT_TYPE Type )
1005 b9d701db 2002-01-16 alex {
1006 b9d701db 2002-01-16 alex CLIENT *c;
1007 c7b55aa6 2002-10-09 alex LONG cnt;
1008 b9d701db 2002-01-16 alex
1009 b9d701db 2002-01-16 alex cnt = 0;
1010 b9d701db 2002-01-16 alex c = My_Clients;
1011 b9d701db 2002-01-16 alex while( c )
1012 b9d701db 2002-01-16 alex {
1013 3be7b9ef 2002-04-14 alex if(( c->introducer == This_Server ) && ( c->type == Type )) cnt++;
1014 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
1015 b9d701db 2002-01-16 alex }
1016 b9d701db 2002-01-16 alex return cnt;
1017 b9d701db 2002-01-16 alex } /* MyCount */
1018 b9d701db 2002-01-16 alex
1019 b9d701db 2002-01-16 alex
1020 c2f60abe 2002-05-27 alex LOCAL CLIENT *
1021 c2f60abe 2002-05-27 alex New_Client_Struct( VOID )
1022 38b9cb88 2001-12-14 alex {
1023 d0ac1e9c 2001-12-23 alex /* Neue CLIENT-Struktur pre-initialisieren */
1024 d0ac1e9c 2001-12-23 alex
1025 38b9cb88 2001-12-14 alex CLIENT *c;
1026 38b9cb88 2001-12-14 alex
1027 cb76d96e 2004-03-11 alex c = (CLIENT *)malloc( sizeof( CLIENT ));
1028 38b9cb88 2001-12-14 alex if( ! c )
1029 38b9cb88 2001-12-14 alex {
1030 e6d1bcdf 2002-06-10 alex Log( LOG_EMERG, "Can't allocate memory! [New_Client_Struct]" );
1031 38b9cb88 2001-12-14 alex return NULL;
1032 38b9cb88 2001-12-14 alex }
1033 38b9cb88 2001-12-14 alex
1034 38b9cb88 2001-12-14 alex c->next = NULL;
1035 b5c16c22 2002-03-25 alex c->hash = 0;
1036 38b9cb88 2001-12-14 alex c->type = CLIENT_UNKNOWN;
1037 38b9cb88 2001-12-14 alex c->conn_id = NONE;
1038 38b9cb88 2001-12-14 alex c->introducer = NULL;
1039 1ab92bb9 2002-01-29 alex c->topserver = NULL;
1040 f7551900 2002-01-04 alex strcpy( c->id, "" );
1041 f7551900 2002-01-04 alex strcpy( c->pwd, "" );
1042 d0ac1e9c 2001-12-23 alex strcpy( c->host, "" );
1043 d0ac1e9c 2001-12-23 alex strcpy( c->user, "" );
1044 804b1ec4 2001-12-31 alex strcpy( c->info, "" );
1045 f0dacce9 2001-12-29 alex strcpy( c->modes, "" );
1046 804b1ec4 2001-12-31 alex c->oper_by_me = FALSE;
1047 f7551900 2002-01-04 alex c->hops = -1;
1048 f7551900 2002-01-04 alex c->token = -1;
1049 a53857b4 2002-01-07 alex c->mytoken = -1;
1050 c4850124 2002-02-27 alex strcpy( c->away, "" );
1051 e62ad979 2002-09-03 alex strcpy( c->flags, "" );
1052 d0ac1e9c 2001-12-23 alex
1053 38b9cb88 2001-12-14 alex return c;
1054 38b9cb88 2001-12-14 alex } /* New_Client */
1055 38b9cb88 2001-12-14 alex
1056 38b9cb88 2001-12-14 alex
1057 c2f60abe 2002-05-27 alex LOCAL VOID
1058 c2f60abe 2002-05-27 alex Generate_MyToken( CLIENT *Client )
1059 a53857b4 2002-01-07 alex {
1060 a53857b4 2002-01-07 alex CLIENT *c;
1061 a53857b4 2002-01-07 alex INT token;
1062 a53857b4 2002-01-07 alex
1063 a53857b4 2002-01-07 alex c = My_Clients;
1064 a53857b4 2002-01-07 alex token = 2;
1065 a53857b4 2002-01-07 alex while( c )
1066 a53857b4 2002-01-07 alex {
1067 a53857b4 2002-01-07 alex if( c->mytoken == token )
1068 a53857b4 2002-01-07 alex {
1069 a53857b4 2002-01-07 alex /* Das Token wurde bereits vergeben */
1070 a53857b4 2002-01-07 alex token++;
1071 a53857b4 2002-01-07 alex c = My_Clients;
1072 a53857b4 2002-01-07 alex continue;
1073 a53857b4 2002-01-07 alex }
1074 95a4b1b1 2002-03-25 alex else c = (CLIENT *)c->next;
1075 a53857b4 2002-01-07 alex }
1076 a53857b4 2002-01-07 alex Client->mytoken = token;
1077 a53857b4 2002-01-07 alex Log( LOG_DEBUG, "Assigned token %d to server \"%s\".", token, Client->id );
1078 a53857b4 2002-01-07 alex } /* Generate_MyToken */
1079 a53857b4 2002-01-07 alex
1080 a53857b4 2002-01-07 alex
1081 d0304b19 2002-12-22 alex LOCAL VOID
1082 d0304b19 2002-12-22 alex Adjust_Counters( CLIENT *Client )
1083 d0304b19 2002-12-22 alex {
1084 d0304b19 2002-12-22 alex LONG count;
1085 d0304b19 2002-12-22 alex
1086 d0304b19 2002-12-22 alex assert( Client != NULL );
1087 d0304b19 2002-12-22 alex
1088 d0304b19 2002-12-22 alex if( Client->type != CLIENT_USER ) return;
1089 d0304b19 2002-12-22 alex
1090 d0304b19 2002-12-22 alex if( Client->conn_id != NONE )
1091 d0304b19 2002-12-22 alex {
1092 d0304b19 2002-12-22 alex /* Local connection */
1093 d0304b19 2002-12-22 alex count = Client_MyUserCount( );
1094 d0304b19 2002-12-22 alex if( count > My_Max_Users ) My_Max_Users = count;
1095 d0304b19 2002-12-22 alex }
1096 d0304b19 2002-12-22 alex count = Client_UserCount( );
1097 d0304b19 2002-12-22 alex if( count > Max_Users ) Max_Users = count;
1098 d0304b19 2002-12-22 alex } /* Adjust_Counters */
1099 d0304b19 2002-12-22 alex
1100 d0304b19 2002-12-22 alex
1101 38b9cb88 2001-12-14 alex /* -eof- */