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)
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.
11 490f28ff 2002-12-12 alex * Client management.
15 f7551900 2002-01-04 alex #define __client_c__
18 ca33cbda 2002-03-12 alex #include "portab.h"
20 51e1a2e0 2003-01-08 alex static char UNUSED id[] = "$Id: client.c,v 1.72 2003/01/08 22:03:21 alex Exp $";
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 c57a4645 2001-12-27 alex #include <netdb.h>
30 c2f60abe 2002-05-27 alex #include "conn.h"
32 ca33cbda 2002-03-12 alex #include "exp.h"
33 08cf5607 2001-12-26 alex #include "client.h"
35 08cf5607 2001-12-26 alex #include <imp.h>
36 79809118 2002-01-06 alex #include "ngircd.h"
37 38b9cb88 2001-12-14 alex #include "channel.h"
38 c2f60abe 2002-05-27 alex #include "resolve.h"
39 9856253d 2001-12-30 alex #include "conf.h"
40 b5c16c22 2002-03-25 alex #include "hash.h"
41 ff54198f 2002-02-27 alex #include "irc-write.h"
42 38b9cb88 2001-12-14 alex #include "log.h"
43 08cf5607 2001-12-26 alex #include "messages.h"
45 38b9cb88 2001-12-14 alex #include <exp.h>
48 467e76aa 2002-10-04 alex #define GETID_LEN (CLIENT_NICK_LEN-1) + 1 + (CLIENT_USER_LEN-1) + 1 + (CLIENT_HOST_LEN-1) + 1
51 f7551900 2002-01-04 alex LOCAL CLIENT *This_Server, *My_Clients;
52 467e76aa 2002-10-04 alex LOCAL CHAR GetID_Buffer[GETID_LEN];
55 c7b55aa6 2002-10-09 alex LOCAL LONG Count PARAMS(( CLIENT_TYPE Type ));
56 c7b55aa6 2002-10-09 alex LOCAL LONG MyCount PARAMS(( CLIENT_TYPE Type ));
58 c2f60abe 2002-05-27 alex LOCAL CLIENT *New_Client_Struct PARAMS(( VOID ));
59 c2f60abe 2002-05-27 alex LOCAL VOID Generate_MyToken PARAMS(( CLIENT *Client ));
60 d0304b19 2002-12-22 alex LOCAL VOID Adjust_Counters PARAMS(( CLIENT *Client ));
63 d0304b19 2002-12-22 alex LONG Max_Users = 0, My_Max_Users = 0;
67 c2f60abe 2002-05-27 alex Client_Init( VOID )
69 c57a4645 2001-12-27 alex struct hostent *h;
71 38b9cb88 2001-12-14 alex This_Server = New_Client_Struct( );
72 38b9cb88 2001-12-14 alex if( ! This_Server )
74 38b9cb88 2001-12-14 alex Log( LOG_EMERG, "Can't allocate client structure for server! Going down." );
75 f7327524 2002-05-30 alex Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
79 38b9cb88 2001-12-14 alex /* Client-Struktur dieses Servers */
80 38b9cb88 2001-12-14 alex This_Server->next = NULL;
81 38b9cb88 2001-12-14 alex This_Server->type = CLIENT_SERVER;
82 38b9cb88 2001-12-14 alex This_Server->conn_id = NONE;
83 38b9cb88 2001-12-14 alex This_Server->introducer = This_Server;
84 8f7e7d66 2002-01-09 alex This_Server->mytoken = 1;
85 4fe7e9d6 2002-01-11 alex This_Server->hops = 0;
87 d0ac1e9c 2001-12-23 alex gethostname( This_Server->host, CLIENT_HOST_LEN );
88 c57a4645 2001-12-27 alex h = gethostbyname( This_Server->host );
89 695631b2 2002-12-26 alex if( h ) strlcpy( This_Server->host, h->h_name, sizeof( This_Server->host ));
91 b5c16c22 2002-03-25 alex Client_SetID( This_Server, Conf_ServerName );
92 b5c16c22 2002-03-25 alex Client_SetInfo( This_Server, Conf_ServerInfo );
94 38b9cb88 2001-12-14 alex My_Clients = This_Server;
95 38b9cb88 2001-12-14 alex } /* Client_Init */
99 c2f60abe 2002-05-27 alex Client_Exit( VOID )
101 d0ac1e9c 2001-12-23 alex CLIENT *c, *next;
104 77c4c015 2002-12-19 alex if( NGIRCd_SignalRestart ) Client_Destroy( This_Server, "Server going down (restarting).", NULL, FALSE );
105 9cb74e81 2002-06-02 alex else Client_Destroy( This_Server, "Server going down.", NULL, FALSE );
108 d0ac1e9c 2001-12-23 alex c = My_Clients;
112 95a4b1b1 2002-03-25 alex next = (CLIENT *)c->next;
116 d4a60bd4 2001-12-25 alex if( cnt ) Log( LOG_INFO, "Freed %d client structure%s.", cnt, cnt == 1 ? "" : "s" );
117 79809118 2002-01-06 alex } /* Client_Exit */
120 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
121 c2f60abe 2002-05-27 alex Client_ThisServer( VOID )
123 f7551900 2002-01-04 alex return This_Server;
124 f7551900 2002-01-04 alex } /* Client_ThisServer */
127 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
128 c2f60abe 2002-05-27 alex Client_NewLocal( CONN_ID Idx, CHAR *Hostname, INT Type, BOOLEAN Idented )
130 f7551900 2002-01-04 alex /* Neuen lokalen Client erzeugen: Wrapper-Funktion fuer Client_New(). */
131 1ab92bb9 2002-01-29 alex return Client_New( Idx, This_Server, NULL, Type, NULL, NULL, Hostname, NULL, 0, 0, NULL, Idented );
132 f7551900 2002-01-04 alex } /* Client_NewLocal */
135 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
136 c2f60abe 2002-05-27 alex Client_NewRemoteServer( CLIENT *Introducer, CHAR *Hostname, CLIENT *TopServer, INT Hops, INT Token, CHAR *Info, BOOLEAN Idented )
138 f7551900 2002-01-04 alex /* Neuen Remote-Client erzeugen: Wrapper-Funktion fuer Client_New (). */
139 1ab92bb9 2002-01-29 alex return Client_New( NONE, Introducer, TopServer, CLIENT_SERVER, Hostname, NULL, Hostname, Info, Hops, Token, NULL, Idented );
140 f7551900 2002-01-04 alex } /* Client_NewRemoteServer */
143 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
144 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 )
146 f7551900 2002-01-04 alex /* Neuen Remote-Client erzeugen: Wrapper-Funktion fuer Client_New (). */
147 1ab92bb9 2002-01-29 alex return Client_New( NONE, Introducer, NULL, CLIENT_USER, Nick, User, Hostname, Info, Hops, Token, Modes, Idented );
148 f7551900 2002-01-04 alex } /* Client_NewRemoteUser */
151 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
152 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 )
154 d0ac1e9c 2001-12-23 alex CLIENT *client;
156 f7551900 2002-01-04 alex assert( Idx >= NONE );
157 f7551900 2002-01-04 alex assert( Introducer != NULL );
158 b7a18e9f 2001-12-24 alex assert( Hostname != NULL );
160 d0ac1e9c 2001-12-23 alex client = New_Client_Struct( );
161 d0ac1e9c 2001-12-23 alex if( ! client ) return NULL;
163 2c5da58d 2001-12-29 alex /* Initialisieren */
164 d0ac1e9c 2001-12-23 alex client->conn_id = Idx;
165 f7551900 2002-01-04 alex client->introducer = Introducer;
166 1ab92bb9 2002-01-29 alex client->topserver = TopServer;
167 f7551900 2002-01-04 alex client->type = Type;
168 f7551900 2002-01-04 alex if( ID ) Client_SetID( client, ID );
169 904d5e5b 2002-01-05 alex if( User ) Client_SetUser( client, User, Idented );
170 f7551900 2002-01-04 alex if( Hostname ) Client_SetHostname( client, Hostname );
171 f7551900 2002-01-04 alex if( Info ) Client_SetInfo( client, Info );
172 f7551900 2002-01-04 alex client->hops = Hops;
173 f7551900 2002-01-04 alex client->token = Token;
174 f7551900 2002-01-04 alex if( Modes ) Client_SetModes( client, Modes );
175 a53857b4 2002-01-07 alex if( Type == CLIENT_SERVER ) Generate_MyToken( client );
177 a1a3e67d 2002-03-04 alex /* ist der User away? */
178 695631b2 2002-12-26 alex if( strchr( client->modes, 'a' )) strlcpy( client->away, DEFAULT_AWAY_MSG, sizeof( client->away ));
180 d0ac1e9c 2001-12-23 alex /* Verketten */
181 95a4b1b1 2002-03-25 alex client->next = (POINTER *)My_Clients;
182 d0ac1e9c 2001-12-23 alex My_Clients = client;
184 d0304b19 2002-12-22 alex /* Adjust counters */
185 d0304b19 2002-12-22 alex Adjust_Counters( client );
187 d0ac1e9c 2001-12-23 alex return client;
188 f7551900 2002-01-04 alex } /* Client_New */
191 c2f60abe 2002-05-27 alex GLOBAL VOID
192 c2f60abe 2002-05-27 alex Client_Destroy( CLIENT *Client, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN SendQuit )
194 d0ac1e9c 2001-12-23 alex /* Client entfernen. */
196 d0ac1e9c 2001-12-23 alex CLIENT *last, *c;
197 dce77559 2002-03-10 alex CHAR msg[LINE_LEN], *txt;
199 b7a18e9f 2001-12-24 alex assert( Client != NULL );
201 79809118 2002-01-06 alex if( LogMsg ) txt = LogMsg;
202 79809118 2002-01-06 alex else txt = FwdMsg;
203 79809118 2002-01-06 alex if( ! txt ) txt = "Reason unknown.";
205 03c3f3c9 2002-03-12 alex /* Netz-Split-Nachricht vorbereiten (noch nicht optimal) */
206 b316c380 2002-12-26 alex if( Client->type == CLIENT_SERVER ) snprintf( msg, sizeof( msg ), "%s: lost server %s", This_Server->id, Client->id );
208 d0ac1e9c 2001-12-23 alex last = NULL;
209 d0ac1e9c 2001-12-23 alex c = My_Clients;
212 c4854470 2002-01-04 alex if(( Client->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c != Client ))
214 dce77559 2002-03-10 alex /* der Client, der geloescht wird ist ein Server. Der Client, den wir gerade
215 dce77559 2002-03-10 alex * pruefen, ist ein Child von diesem und muss daher auch entfernt werden */
216 50ec7a56 2002-03-11 alex Client_Destroy( c, NULL, msg, FALSE );
217 c4854470 2002-01-04 alex last = NULL;
218 c4854470 2002-01-04 alex c = My_Clients;
221 d0ac1e9c 2001-12-23 alex if( c == Client )
223 dce77559 2002-03-10 alex /* Wir haben den Client gefunden: entfernen */
224 d0ac1e9c 2001-12-23 alex if( last ) last->next = c->next;
225 95a4b1b1 2002-03-25 alex else My_Clients = (CLIENT *)c->next;
227 c4854470 2002-01-04 alex if( c->type == CLIENT_USER )
229 db58d347 2002-01-05 alex if( c->conn_id != NONE )
231 50ec7a56 2002-03-11 alex /* Ein lokaler User */
232 b89c3108 2002-01-07 alex Log( LOG_NOTICE, "User \"%s\" unregistered (connection %d): %s", Client_Mask( c ), c->conn_id, txt );
234 50ec7a56 2002-03-11 alex if( SendQuit )
236 50ec7a56 2002-03-11 alex /* Alle andere Server informieren! */
237 50ec7a56 2002-03-11 alex if( FwdMsg ) IRC_WriteStrServersPrefix( NULL, c, "QUIT :%s", FwdMsg );
238 50ec7a56 2002-03-11 alex else IRC_WriteStrServersPrefix( NULL, c, "QUIT :" );
243 50ec7a56 2002-03-11 alex /* Remote User */
244 b89c3108 2002-01-07 alex Log( LOG_DEBUG, "User \"%s\" unregistered: %s", Client_Mask( c ), txt );
246 50ec7a56 2002-03-11 alex if( SendQuit )
248 50ec7a56 2002-03-11 alex /* Andere Server informieren, ausser denen, die "in
249 50ec7a56 2002-03-11 alex * Richtung dem liegen", auf dem der User registriert
250 50ec7a56 2002-03-11 alex * ist. Von denen haben wir das QUIT ja wohl bekommen. */
251 50ec7a56 2002-03-11 alex if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "QUIT :%s", FwdMsg );
252 50ec7a56 2002-03-11 alex else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "QUIT :" );
255 dadebb21 2002-06-01 alex Channel_Quit( c, FwdMsg ? FwdMsg : c->id );
257 79809118 2002-01-06 alex else if( c->type == CLIENT_SERVER )
259 28d58986 2002-02-27 alex if( c != This_Server )
261 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 );
262 6b58ab84 2002-03-27 alex else Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered: %s", c->id, txt );
265 8f7e7d66 2002-01-09 alex /* andere Server informieren */
266 77c4c015 2002-12-19 alex if( ! NGIRCd_SignalQuit )
268 8f7e7d66 2002-01-09 alex if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :%s", c->id, FwdMsg );
269 8f7e7d66 2002-01-09 alex else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :", c->id );
274 28d58986 2002-02-27 alex if( c->conn_id != NONE )
276 28d58986 2002-02-27 alex if( c->id[0] ) Log( LOG_NOTICE, "Client \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt );
277 28d58986 2002-02-27 alex else Log( LOG_NOTICE, "Client unregistered (connection %d): %s", c->conn_id, txt );
281 28d58986 2002-02-27 alex if( c->id[0] ) Log( LOG_WARNING, "Unregistered unknown client \"%s\": %s", c->id, txt );
282 28d58986 2002-02-27 alex else Log( LOG_WARNING, "Unregistered unknown client: %s", c->id, txt );
290 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
292 d0ac1e9c 2001-12-23 alex } /* Client_Destroy */
295 c2f60abe 2002-05-27 alex GLOBAL VOID
296 c2f60abe 2002-05-27 alex Client_SetHostname( CLIENT *Client, CHAR *Hostname )
298 2c5da58d 2001-12-29 alex /* Hostname eines Clients setzen */
300 2c5da58d 2001-12-29 alex assert( Client != NULL );
301 c68c092c 2002-03-06 alex assert( Hostname != NULL );
303 0ced4181 2002-12-26 alex strlcpy( Client->host, Hostname, sizeof( Client->host ));
304 2c5da58d 2001-12-29 alex } /* Client_SetHostname */
307 c2f60abe 2002-05-27 alex GLOBAL VOID
308 c2f60abe 2002-05-27 alex Client_SetID( CLIENT *Client, CHAR *ID )
310 b5c16c22 2002-03-25 alex /* Hostname eines Clients setzen, Hash-Wert berechnen */
312 f7551900 2002-01-04 alex assert( Client != NULL );
313 c68c092c 2002-03-06 alex assert( ID != NULL );
315 0ced4181 2002-12-26 alex strlcpy( Client->id, ID, sizeof( Client->id ));
318 b5c16c22 2002-03-25 alex Client->hash = Hash( Client->id );
319 f7551900 2002-01-04 alex } /* Client_SetID */
322 c2f60abe 2002-05-27 alex GLOBAL VOID
323 c2f60abe 2002-05-27 alex Client_SetUser( CLIENT *Client, CHAR *User, BOOLEAN Idented )
325 f7551900 2002-01-04 alex /* Username eines Clients setzen */
327 f7551900 2002-01-04 alex assert( Client != NULL );
328 c68c092c 2002-03-06 alex assert( User != NULL );
330 0ced4181 2002-12-26 alex if( Idented ) strlcpy( Client->user, User, sizeof( Client->user ));
333 904d5e5b 2002-01-05 alex Client->user[0] = '~';
334 0ced4181 2002-12-26 alex strlcpy( Client->user + 1, User, sizeof( Client->user ) - 1 );
336 f7551900 2002-01-04 alex } /* Client_SetUser */
339 c2f60abe 2002-05-27 alex GLOBAL VOID
340 c2f60abe 2002-05-27 alex Client_SetInfo( CLIENT *Client, CHAR *Info )
342 f7551900 2002-01-04 alex /* Hostname eines Clients setzen */
344 f7551900 2002-01-04 alex assert( Client != NULL );
345 c68c092c 2002-03-06 alex assert( Info != NULL );
347 0ced4181 2002-12-26 alex strlcpy( Client->info, Info, sizeof( Client->info ));
348 f7551900 2002-01-04 alex } /* Client_SetInfo */
351 c2f60abe 2002-05-27 alex GLOBAL VOID
352 c2f60abe 2002-05-27 alex Client_SetModes( CLIENT *Client, CHAR *Modes )
354 e62ad979 2002-09-03 alex /* Modes eines Clients setzen */
356 f7551900 2002-01-04 alex assert( Client != NULL );
357 c68c092c 2002-03-06 alex assert( Modes != NULL );
359 0ced4181 2002-12-26 alex strlcpy( Client->modes, Modes, sizeof( Client->modes ));
360 f7551900 2002-01-04 alex } /* Client_SetModes */
363 e62ad979 2002-09-03 alex GLOBAL VOID
364 e62ad979 2002-09-03 alex Client_SetFlags( CLIENT *Client, CHAR *Flags )
366 e62ad979 2002-09-03 alex /* Flags eines Clients setzen */
368 e62ad979 2002-09-03 alex assert( Client != NULL );
369 e62ad979 2002-09-03 alex assert( Flags != NULL );
371 0ced4181 2002-12-26 alex strlcpy( Client->flags, Flags, sizeof( Client->flags ));
372 e62ad979 2002-09-03 alex } /* Client_SetFlags */
375 c2f60abe 2002-05-27 alex GLOBAL VOID
376 c2f60abe 2002-05-27 alex Client_SetPassword( CLIENT *Client, CHAR *Pwd )
378 f7551900 2002-01-04 alex /* Von einem Client geliefertes Passwort */
380 f7551900 2002-01-04 alex assert( Client != NULL );
381 c68c092c 2002-03-06 alex assert( Pwd != NULL );
383 0ced4181 2002-12-26 alex strlcpy( Client->pwd, Pwd, sizeof( Client->pwd ));
384 f7551900 2002-01-04 alex } /* Client_SetPassword */
387 c2f60abe 2002-05-27 alex GLOBAL VOID
388 c2f60abe 2002-05-27 alex Client_SetAway( CLIENT *Client, CHAR *Txt )
390 51e1a2e0 2003-01-08 alex /* Set AWAY reason of client */
392 c4850124 2002-02-27 alex assert( Client != NULL );
393 51e1a2e0 2003-01-08 alex assert( Txt != NULL );
395 51e1a2e0 2003-01-08 alex strlcpy( Client->away, Txt, sizeof( Client->away ));
396 51e1a2e0 2003-01-08 alex Log( LOG_DEBUG, "User \"%s\" is away: %s", Client_Mask( Client ), Txt );
397 c4850124 2002-02-27 alex } /* Client_SetAway */
400 c2f60abe 2002-05-27 alex GLOBAL VOID
401 c2f60abe 2002-05-27 alex Client_SetType( CLIENT *Client, INT Type )
403 f7551900 2002-01-04 alex assert( Client != NULL );
404 f7551900 2002-01-04 alex Client->type = Type;
405 a53857b4 2002-01-07 alex if( Type == CLIENT_SERVER ) Generate_MyToken( Client );
406 d0304b19 2002-12-22 alex Adjust_Counters( Client );
407 f7551900 2002-01-04 alex } /* Client_SetType */
410 c2f60abe 2002-05-27 alex GLOBAL VOID
411 c2f60abe 2002-05-27 alex Client_SetHops( CLIENT *Client, INT Hops )
413 f7551900 2002-01-04 alex assert( Client != NULL );
414 f7551900 2002-01-04 alex Client->hops = Hops;
415 f7551900 2002-01-04 alex } /* Client_SetHops */
418 c2f60abe 2002-05-27 alex GLOBAL VOID
419 c2f60abe 2002-05-27 alex Client_SetToken( CLIENT *Client, INT Token )
421 f7551900 2002-01-04 alex assert( Client != NULL );
422 f7551900 2002-01-04 alex Client->token = Token;
423 f7551900 2002-01-04 alex } /* Client_SetToken */
426 c2f60abe 2002-05-27 alex GLOBAL VOID
427 c2f60abe 2002-05-27 alex Client_SetIntroducer( CLIENT *Client, CLIENT *Introducer )
429 f7551900 2002-01-04 alex assert( Client != NULL );
430 c68c092c 2002-03-06 alex assert( Introducer != NULL );
431 f7551900 2002-01-04 alex Client->introducer = Introducer;
432 f7551900 2002-01-04 alex } /* Client_SetIntroducer */
435 c2f60abe 2002-05-27 alex GLOBAL VOID
436 c2f60abe 2002-05-27 alex Client_SetOperByMe( CLIENT *Client, BOOLEAN OperByMe )
438 f7551900 2002-01-04 alex assert( Client != NULL );
439 f7551900 2002-01-04 alex Client->oper_by_me = OperByMe;
440 f7551900 2002-01-04 alex } /* Client_SetOperByMe */
443 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
444 c2f60abe 2002-05-27 alex Client_ModeAdd( CLIENT *Client, CHAR Mode )
446 f7551900 2002-01-04 alex /* Mode soll gesetzt werden. TRUE wird geliefert, wenn der
447 f7551900 2002-01-04 alex * Mode neu gesetzt wurde, FALSE, wenn der Client den Mode
448 f7551900 2002-01-04 alex * bereits hatte. */
452 f7551900 2002-01-04 alex assert( Client != NULL );
454 f7551900 2002-01-04 alex x[0] = Mode; x[1] = '\0';
455 f7551900 2002-01-04 alex if( ! strchr( Client->modes, x[0] ))
457 f7551900 2002-01-04 alex /* Client hat den Mode noch nicht -> setzen */
458 6626395c 2002-12-26 alex strlcat( Client->modes, x, sizeof( Client->modes ));
459 f7551900 2002-01-04 alex return TRUE;
461 f7551900 2002-01-04 alex else return FALSE;
462 f7551900 2002-01-04 alex } /* Client_ModeAdd */
465 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
466 c2f60abe 2002-05-27 alex Client_ModeDel( CLIENT *Client, CHAR Mode )
468 f7551900 2002-01-04 alex /* Mode soll geloescht werden. TRUE wird geliefert, wenn der
469 f7551900 2002-01-04 alex * Mode entfernt wurde, FALSE, wenn der Client den Mode
470 f7551900 2002-01-04 alex * ueberhaupt nicht hatte. */
472 f7551900 2002-01-04 alex CHAR x[2], *p;
474 f7551900 2002-01-04 alex assert( Client != NULL );
476 f7551900 2002-01-04 alex x[0] = Mode; x[1] = '\0';
478 f7551900 2002-01-04 alex p = strchr( Client->modes, x[0] );
479 f7551900 2002-01-04 alex if( ! p ) return FALSE;
481 f7551900 2002-01-04 alex /* Client hat den Mode -> loeschen */
482 f7551900 2002-01-04 alex while( *p )
484 f7551900 2002-01-04 alex *p = *(p + 1);
487 f7551900 2002-01-04 alex return TRUE;
488 f7551900 2002-01-04 alex } /* Client_ModeDel */
491 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
492 c2f60abe 2002-05-27 alex Client_GetFromConn( CONN_ID Idx )
494 804b1ec4 2001-12-31 alex /* Client-Struktur, die zur lokalen Verbindung Idx gehoert,
495 d0ac1e9c 2001-12-23 alex * liefern. Wird keine gefunden, so wird NULL geliefert. */
499 b7a18e9f 2001-12-24 alex assert( Idx >= 0 );
501 d0ac1e9c 2001-12-23 alex c = My_Clients;
504 d0ac1e9c 2001-12-23 alex if( c->conn_id == Idx ) return c;
505 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
507 d0ac1e9c 2001-12-23 alex return NULL;
508 d0ac1e9c 2001-12-23 alex } /* Client_GetFromConn */
511 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
512 c2f60abe 2002-05-27 alex Client_Search( CHAR *Nick )
514 10363b39 2002-03-03 alex /* Client-Struktur, die den entsprechenden Nick hat, liefern.
515 10363b39 2002-03-03 alex * Wird keine gefunden, so wird NULL geliefert. */
517 b5c16c22 2002-03-25 alex CHAR search_id[CLIENT_ID_LEN], *ptr;
518 40c9fd26 2002-01-27 alex CLIENT *c = NULL;
519 b5c16c22 2002-03-25 alex UINT32 search_hash;
521 804b1ec4 2001-12-31 alex assert( Nick != NULL );
523 40c9fd26 2002-01-27 alex /* Nick kopieren und ggf. Host-Mask abschneiden */
524 0ced4181 2002-12-26 alex strlcpy( search_id, Nick, sizeof( search_id ));
525 b5c16c22 2002-03-25 alex ptr = strchr( search_id, '!' );
526 d17748e9 2002-01-27 alex if( ptr ) *ptr = '\0';
528 b5c16c22 2002-03-25 alex search_hash = Hash( search_id );
530 804b1ec4 2001-12-31 alex c = My_Clients;
533 b5c16c22 2002-03-25 alex if( c->hash == search_hash )
535 b5c16c22 2002-03-25 alex /* lt. Hash-Wert: Treffer! */
536 b5c16c22 2002-03-25 alex if( strcasecmp( c->id, search_id ) == 0 ) return c;
538 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
540 804b1ec4 2001-12-31 alex return NULL;
541 b5c16c22 2002-03-25 alex } /* Client_Search */
544 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
545 c2f60abe 2002-05-27 alex Client_GetFromToken( CLIENT *Client, INT Token )
547 f7551900 2002-01-04 alex /* Client-Struktur, die den entsprechenden Introducer (=Client)
548 f7551900 2002-01-04 alex * und das gegebene Token hat, liefern. Wird keine gefunden,
549 f7551900 2002-01-04 alex * so wird NULL geliefert. */
553 90676129 2001-12-26 alex assert( Client != NULL );
554 f7551900 2002-01-04 alex assert( Token > 0 );
556 f7551900 2002-01-04 alex c = My_Clients;
559 f7551900 2002-01-04 alex if(( c->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c->token == Token )) return c;
560 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
562 f7551900 2002-01-04 alex return NULL;
563 f7551900 2002-01-04 alex } /* Client_GetFromToken */
567 c2f60abe 2002-05-27 alex Client_Type( CLIENT *Client )
569 f7551900 2002-01-04 alex assert( Client != NULL );
570 f7551900 2002-01-04 alex return Client->type;
571 f7551900 2002-01-04 alex } /* Client_Type */
574 c2f60abe 2002-05-27 alex GLOBAL CONN_ID
575 c2f60abe 2002-05-27 alex Client_Conn( CLIENT *Client )
577 f7551900 2002-01-04 alex assert( Client != NULL );
578 f7551900 2002-01-04 alex return Client->conn_id;
579 f7551900 2002-01-04 alex } /* Client_Conn */
582 c2f60abe 2002-05-27 alex GLOBAL CHAR *
583 c2f60abe 2002-05-27 alex Client_ID( CLIENT *Client )
585 f7551900 2002-01-04 alex assert( Client != NULL );
587 c68c092c 2002-03-06 alex #ifdef DEBUG
588 c68c092c 2002-03-06 alex if( Client->type == CLIENT_USER ) assert( strlen( Client->id ) < CLIENT_NICK_LEN );
591 f7551900 2002-01-04 alex if( Client->id[0] ) return Client->id;
592 90676129 2001-12-26 alex else return "*";
593 f7551900 2002-01-04 alex } /* Client_ID */
596 c2f60abe 2002-05-27 alex GLOBAL CHAR *
597 c2f60abe 2002-05-27 alex Client_Info( CLIENT *Client )
599 f7551900 2002-01-04 alex assert( Client != NULL );
600 f7551900 2002-01-04 alex return Client->info;
601 f7551900 2002-01-04 alex } /* Client_Info */
604 c2f60abe 2002-05-27 alex GLOBAL CHAR *
605 c2f60abe 2002-05-27 alex Client_User( CLIENT *Client )
607 f7551900 2002-01-04 alex assert( Client != NULL );
608 95a4b1b1 2002-03-25 alex if( Client->user[0] ) return Client->user;
609 f7551900 2002-01-04 alex else return "~";
610 f7551900 2002-01-04 alex } /* Client_User */
613 c2f60abe 2002-05-27 alex GLOBAL CHAR *
614 c2f60abe 2002-05-27 alex Client_Hostname( CLIENT *Client )
616 f7551900 2002-01-04 alex assert( Client != NULL );
617 f7551900 2002-01-04 alex return Client->host;
618 f7551900 2002-01-04 alex } /* Client_Hostname */
621 c2f60abe 2002-05-27 alex GLOBAL CHAR *
622 c2f60abe 2002-05-27 alex Client_Password( CLIENT *Client )
624 f7551900 2002-01-04 alex assert( Client != NULL );
625 f7551900 2002-01-04 alex return Client->pwd;
626 f7551900 2002-01-04 alex } /* Client_Password */
629 c2f60abe 2002-05-27 alex GLOBAL CHAR *
630 c2f60abe 2002-05-27 alex Client_Modes( CLIENT *Client )
632 f7551900 2002-01-04 alex assert( Client != NULL );
633 f7551900 2002-01-04 alex return Client->modes;
634 f7551900 2002-01-04 alex } /* Client_Modes */
637 e62ad979 2002-09-03 alex GLOBAL CHAR *
638 e62ad979 2002-09-03 alex Client_Flags( CLIENT *Client )
640 e62ad979 2002-09-03 alex assert( Client != NULL );
641 e62ad979 2002-09-03 alex return Client->flags;
642 e62ad979 2002-09-03 alex } /* Client_Flags */
645 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
646 c2f60abe 2002-05-27 alex Client_OperByMe( CLIENT *Client )
648 f7551900 2002-01-04 alex assert( Client != NULL );
649 f7551900 2002-01-04 alex return Client->oper_by_me;
650 f7551900 2002-01-04 alex } /* Client_OperByMe */
654 c2f60abe 2002-05-27 alex Client_Hops( CLIENT *Client )
656 f7551900 2002-01-04 alex assert( Client != NULL );
657 f7551900 2002-01-04 alex return Client->hops;
658 f7551900 2002-01-04 alex } /* Client_Hops */
662 c2f60abe 2002-05-27 alex Client_Token( CLIENT *Client )
664 f7551900 2002-01-04 alex assert( Client != NULL );
665 f7551900 2002-01-04 alex return Client->token;
666 f7551900 2002-01-04 alex } /* Client_Token */
670 c2f60abe 2002-05-27 alex Client_MyToken( CLIENT *Client )
672 a53857b4 2002-01-07 alex assert( Client != NULL );
673 a53857b4 2002-01-07 alex return Client->mytoken;
674 a53857b4 2002-01-07 alex } /* Client_MyToken */
677 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
678 c2f60abe 2002-05-27 alex Client_NextHop( CLIENT *Client )
682 e7be3a01 2002-01-05 alex assert( Client != NULL );
684 e7be3a01 2002-01-05 alex c = Client;
685 e7be3a01 2002-01-05 alex while( c->introducer && ( c->introducer != c ) && ( c->introducer != This_Server )) c = c->introducer;
687 e7be3a01 2002-01-05 alex } /* Client_NextHop */
690 c2f60abe 2002-05-27 alex GLOBAL CHAR *
691 c2f60abe 2002-05-27 alex Client_Mask( CLIENT *Client )
693 f7551900 2002-01-04 alex /* Client-"ID" liefern, wie sie z.B. fuer
694 f7551900 2002-01-04 alex * Prefixe benoetigt wird. */
696 f7551900 2002-01-04 alex assert( Client != NULL );
698 f7551900 2002-01-04 alex if( Client->type == CLIENT_SERVER ) return Client->id;
700 467e76aa 2002-10-04 alex snprintf( GetID_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user, Client->host );
701 f7551900 2002-01-04 alex return GetID_Buffer;
702 f7551900 2002-01-04 alex } /* Client_Mask */
705 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
706 c2f60abe 2002-05-27 alex Client_Introducer( CLIENT *Client )
708 f7551900 2002-01-04 alex assert( Client != NULL );
709 f7551900 2002-01-04 alex return Client->introducer;
710 f7551900 2002-01-04 alex } /* Client_Introducer */
713 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
714 c2f60abe 2002-05-27 alex Client_TopServer( CLIENT *Client )
716 1ab92bb9 2002-01-29 alex assert( Client != NULL );
717 1ab92bb9 2002-01-29 alex return Client->topserver;
718 1ab92bb9 2002-01-29 alex } /* Client_TopServer */
721 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
722 c2f60abe 2002-05-27 alex Client_HasMode( CLIENT *Client, CHAR Mode )
724 f7551900 2002-01-04 alex assert( Client != NULL );
725 f7551900 2002-01-04 alex return strchr( Client->modes, Mode ) != NULL;
726 f7551900 2002-01-04 alex } /* Client_HasMode */
729 c2f60abe 2002-05-27 alex GLOBAL CHAR *
730 c2f60abe 2002-05-27 alex Client_Away( CLIENT *Client )
732 c4850124 2002-02-27 alex /* AWAY-Text liefern */
734 c4850124 2002-02-27 alex assert( Client != NULL );
735 c4850124 2002-02-27 alex return Client->away;
736 c4850124 2002-02-27 alex } /* Client_Away */
739 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
740 c2f60abe 2002-05-27 alex Client_CheckNick( CLIENT *Client, CHAR *Nick )
742 08cf5607 2001-12-26 alex /* Nick ueberpruefen */
744 08cf5607 2001-12-26 alex assert( Client != NULL );
745 08cf5607 2001-12-26 alex assert( Nick != NULL );
747 33944e8c 2002-02-06 alex /* Nick ungueltig? */
748 9f3a9df2 2002-02-17 alex if( ! Client_IsValidNick( Nick ))
750 9f3a9df2 2002-02-17 alex IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), Nick );
751 9f3a9df2 2002-02-17 alex return FALSE;
754 08cf5607 2001-12-26 alex /* Nick bereits vergeben? */
755 b5c16c22 2002-03-25 alex if( Client_Search( Nick ))
757 b5c16c22 2002-03-25 alex /* den Nick gibt es bereits */
758 b5c16c22 2002-03-25 alex IRC_WriteStrClient( Client, ERR_NICKNAMEINUSE_MSG, Client_ID( Client ), Nick );
759 b5c16c22 2002-03-25 alex return FALSE;
762 08cf5607 2001-12-26 alex return TRUE;
763 08cf5607 2001-12-26 alex } /* Client_CheckNick */
766 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
767 c2f60abe 2002-05-27 alex Client_CheckID( CLIENT *Client, CHAR *ID )
769 07903baa 2002-01-03 alex /* Nick ueberpruefen */
771 07903baa 2002-01-03 alex CHAR str[COMMAND_LEN];
774 07903baa 2002-01-03 alex assert( Client != NULL );
775 07903baa 2002-01-03 alex assert( Client->conn_id > NONE );
776 07903baa 2002-01-03 alex assert( ID != NULL );
778 07903baa 2002-01-03 alex /* Nick zu lang? */
779 9f3a9df2 2002-02-17 alex if( strlen( ID ) > CLIENT_ID_LEN )
781 9f3a9df2 2002-02-17 alex IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), ID );
782 9f3a9df2 2002-02-17 alex return FALSE;
785 07903baa 2002-01-03 alex /* ID bereits vergeben? */
786 07903baa 2002-01-03 alex c = My_Clients;
789 f7551900 2002-01-04 alex if( strcasecmp( c->id, ID ) == 0 )
791 07903baa 2002-01-03 alex /* die Server-ID gibt es bereits */
792 b316c380 2002-12-26 alex snprintf( str, sizeof( str ), "ID \"%s\" already registered", ID );
793 9f122037 2002-12-03 alex if( Client->conn_id != c->conn_id ) Log( LOG_ERR, "%s (on connection %d)!", str, c->conn_id );
794 9f122037 2002-12-03 alex else Log( LOG_ERR, "%s (via network)!", str );
795 79809118 2002-01-06 alex Conn_Close( Client->conn_id, str, str, TRUE );
796 07903baa 2002-01-03 alex return FALSE;
798 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
801 07903baa 2002-01-03 alex return TRUE;
802 07903baa 2002-01-03 alex } /* Client_CheckID */
805 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
806 c2f60abe 2002-05-27 alex Client_First( VOID )
808 fb9d6ce1 2001-12-31 alex /* Ersten Client liefern. */
810 fb9d6ce1 2001-12-31 alex return My_Clients;
811 fb9d6ce1 2001-12-31 alex } /* Client_First */
814 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
815 c2f60abe 2002-05-27 alex Client_Next( CLIENT *c )
817 fb9d6ce1 2001-12-31 alex /* Naechsten Client liefern. Existiert keiner,
818 fb9d6ce1 2001-12-31 alex * so wird NULL geliefert. */
820 fb9d6ce1 2001-12-31 alex assert( c != NULL );
821 95a4b1b1 2002-03-25 alex return (CLIENT *)c->next;
822 fb9d6ce1 2001-12-31 alex } /* Client_Next */
825 c7b55aa6 2002-10-09 alex GLOBAL LONG
826 c2f60abe 2002-05-27 alex Client_UserCount( VOID )
828 b9d701db 2002-01-16 alex return Count( CLIENT_USER );
829 b9d701db 2002-01-16 alex } /* Client_UserCount */
832 c7b55aa6 2002-10-09 alex GLOBAL LONG
833 c2f60abe 2002-05-27 alex Client_ServiceCount( VOID )
835 b9d701db 2002-01-16 alex return Count( CLIENT_SERVICE );;
836 b9d701db 2002-01-16 alex } /* Client_ServiceCount */
839 c7b55aa6 2002-10-09 alex GLOBAL LONG
840 c2f60abe 2002-05-27 alex Client_ServerCount( VOID )
842 b9d701db 2002-01-16 alex return Count( CLIENT_SERVER );
843 b9d701db 2002-01-16 alex } /* Client_ServerCount */
846 c7b55aa6 2002-10-09 alex GLOBAL LONG
847 c2f60abe 2002-05-27 alex Client_MyUserCount( VOID )
849 b9d701db 2002-01-16 alex return MyCount( CLIENT_USER );
850 b9d701db 2002-01-16 alex } /* Client_MyUserCount */
853 c7b55aa6 2002-10-09 alex GLOBAL LONG
854 c2f60abe 2002-05-27 alex Client_MyServiceCount( VOID )
856 b9d701db 2002-01-16 alex return MyCount( CLIENT_SERVICE );
857 b9d701db 2002-01-16 alex } /* Client_MyServiceCount */
860 c7b55aa6 2002-10-09 alex GLOBAL LONG
861 c2f60abe 2002-05-27 alex Client_MyServerCount( VOID )
867 3be7b9ef 2002-04-14 alex c = My_Clients;
870 3be7b9ef 2002-04-14 alex if(( c->type == CLIENT_SERVER ) && ( c->hops == 1 )) cnt++;
871 3be7b9ef 2002-04-14 alex c = (CLIENT *)c->next;
873 3be7b9ef 2002-04-14 alex return cnt;
874 b9d701db 2002-01-16 alex } /* Client_MyServerCount */
877 c7b55aa6 2002-10-09 alex GLOBAL LONG
878 c2f60abe 2002-05-27 alex Client_OperCount( VOID )
884 b9d701db 2002-01-16 alex c = My_Clients;
887 b9d701db 2002-01-16 alex if( c && ( c->type == CLIENT_USER ) && ( strchr( c->modes, 'o' ))) cnt++;
888 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
890 b9d701db 2002-01-16 alex return cnt;
891 b9d701db 2002-01-16 alex } /* Client_OperCount */
894 c7b55aa6 2002-10-09 alex GLOBAL LONG
895 c2f60abe 2002-05-27 alex Client_UnknownCount( VOID )
901 b9d701db 2002-01-16 alex c = My_Clients;
904 b9d701db 2002-01-16 alex if( c && ( c->type != CLIENT_USER ) && ( c->type != CLIENT_SERVICE ) && ( c->type != CLIENT_SERVER )) cnt++;
905 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
907 b9d701db 2002-01-16 alex return cnt;
908 b9d701db 2002-01-16 alex } /* Client_UnknownCount */
911 d0304b19 2002-12-22 alex GLOBAL LONG
912 d0304b19 2002-12-22 alex Client_MaxUserCount( VOID )
914 d0304b19 2002-12-22 alex return Max_Users;
915 d0304b19 2002-12-22 alex } /* Client_MaxUserCount */
918 d0304b19 2002-12-22 alex GLOBAL LONG
919 d0304b19 2002-12-22 alex Client_MyMaxUserCount( VOID )
921 d0304b19 2002-12-22 alex return My_Max_Users;
922 d0304b19 2002-12-22 alex } /* Client_MyMaxUserCount */
925 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
926 c2f60abe 2002-05-27 alex Client_IsValidNick( CHAR *Nick )
928 33944e8c 2002-02-06 alex /* Ist der Nick gueltig? */
930 f7327524 2002-05-30 alex CHAR *ptr, goodchars[20];
932 33944e8c 2002-02-06 alex assert( Nick != NULL );
934 f7327524 2002-05-30 alex strcpy( goodchars, ";0123456789-" );
936 33944e8c 2002-02-06 alex if( Nick[0] == '#' ) return FALSE;
937 7157d936 2002-03-02 alex if( strchr( goodchars, Nick[0] )) return FALSE;
938 7157d936 2002-03-02 alex if( strlen( Nick ) >= CLIENT_NICK_LEN ) return FALSE;
940 7157d936 2002-03-02 alex ptr = Nick;
941 7157d936 2002-03-02 alex while( *ptr )
943 7157d936 2002-03-02 alex if(( *ptr < 'A' ) && ( ! strchr( goodchars, *ptr ))) return FALSE;
944 7157d936 2002-03-02 alex if(( *ptr > '}' ) && ( ! strchr( goodchars, *ptr ))) return FALSE;
948 33944e8c 2002-02-06 alex return TRUE;
949 33944e8c 2002-02-06 alex } /* Client_IsValidNick */
953 c2f60abe 2002-05-27 alex Count( CLIENT_TYPE Type )
959 b9d701db 2002-01-16 alex c = My_Clients;
962 3be7b9ef 2002-04-14 alex if( c->type == Type ) cnt++;
963 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
965 b9d701db 2002-01-16 alex return cnt;
966 b9d701db 2002-01-16 alex } /* Count */
970 c2f60abe 2002-05-27 alex MyCount( CLIENT_TYPE Type )
976 b9d701db 2002-01-16 alex c = My_Clients;
979 3be7b9ef 2002-04-14 alex if(( c->introducer == This_Server ) && ( c->type == Type )) cnt++;
980 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
982 b9d701db 2002-01-16 alex return cnt;
983 b9d701db 2002-01-16 alex } /* MyCount */
986 c2f60abe 2002-05-27 alex LOCAL CLIENT *
987 c2f60abe 2002-05-27 alex New_Client_Struct( VOID )
989 d0ac1e9c 2001-12-23 alex /* Neue CLIENT-Struktur pre-initialisieren */
993 38b9cb88 2001-12-14 alex c = malloc( sizeof( CLIENT ));
996 e6d1bcdf 2002-06-10 alex Log( LOG_EMERG, "Can't allocate memory! [New_Client_Struct]" );
997 38b9cb88 2001-12-14 alex return NULL;
1000 38b9cb88 2001-12-14 alex c->next = NULL;
1001 b5c16c22 2002-03-25 alex c->hash = 0;
1002 38b9cb88 2001-12-14 alex c->type = CLIENT_UNKNOWN;
1003 38b9cb88 2001-12-14 alex c->conn_id = NONE;
1004 38b9cb88 2001-12-14 alex c->introducer = NULL;
1005 1ab92bb9 2002-01-29 alex c->topserver = NULL;
1006 f7551900 2002-01-04 alex strcpy( c->id, "" );
1007 f7551900 2002-01-04 alex strcpy( c->pwd, "" );
1008 d0ac1e9c 2001-12-23 alex strcpy( c->host, "" );
1009 d0ac1e9c 2001-12-23 alex strcpy( c->user, "" );
1010 804b1ec4 2001-12-31 alex strcpy( c->info, "" );
1011 f0dacce9 2001-12-29 alex strcpy( c->modes, "" );
1012 804b1ec4 2001-12-31 alex c->oper_by_me = FALSE;
1013 f7551900 2002-01-04 alex c->hops = -1;
1014 f7551900 2002-01-04 alex c->token = -1;
1015 a53857b4 2002-01-07 alex c->mytoken = -1;
1016 c4850124 2002-02-27 alex strcpy( c->away, "" );
1017 e62ad979 2002-09-03 alex strcpy( c->flags, "" );
1020 38b9cb88 2001-12-14 alex } /* New_Client */
1023 c2f60abe 2002-05-27 alex LOCAL VOID
1024 c2f60abe 2002-05-27 alex Generate_MyToken( CLIENT *Client )
1026 a53857b4 2002-01-07 alex CLIENT *c;
1027 a53857b4 2002-01-07 alex INT token;
1029 a53857b4 2002-01-07 alex c = My_Clients;
1030 a53857b4 2002-01-07 alex token = 2;
1031 a53857b4 2002-01-07 alex while( c )
1033 a53857b4 2002-01-07 alex if( c->mytoken == token )
1035 a53857b4 2002-01-07 alex /* Das Token wurde bereits vergeben */
1037 a53857b4 2002-01-07 alex c = My_Clients;
1040 95a4b1b1 2002-03-25 alex else c = (CLIENT *)c->next;
1042 a53857b4 2002-01-07 alex Client->mytoken = token;
1043 a53857b4 2002-01-07 alex Log( LOG_DEBUG, "Assigned token %d to server \"%s\".", token, Client->id );
1044 a53857b4 2002-01-07 alex } /* Generate_MyToken */
1047 d0304b19 2002-12-22 alex LOCAL VOID
1048 d0304b19 2002-12-22 alex Adjust_Counters( CLIENT *Client )
1050 d0304b19 2002-12-22 alex LONG count;
1052 d0304b19 2002-12-22 alex assert( Client != NULL );
1054 d0304b19 2002-12-22 alex if( Client->type != CLIENT_USER ) return;
1056 d0304b19 2002-12-22 alex if( Client->conn_id != NONE )
1058 d0304b19 2002-12-22 alex /* Local connection */
1059 d0304b19 2002-12-22 alex count = Client_MyUserCount( );
1060 d0304b19 2002-12-22 alex if( count > My_Max_Users ) My_Max_Users = count;
1062 d0304b19 2002-12-22 alex count = Client_UserCount( );
1063 d0304b19 2002-12-22 alex if( count > Max_Users ) Max_Users = count;
1064 d0304b19 2002-12-22 alex } /* Adjust_Counters */
1067 38b9cb88 2001-12-14 alex /* -eof- */