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 38b9cb88 2001-12-14 alex * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
6 38b9cb88 2001-12-14 alex * der GNU General Public License (GPL), wie von der Free Software Foundation
7 38b9cb88 2001-12-14 alex * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
8 38b9cb88 2001-12-14 alex * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
9 38b9cb88 2001-12-14 alex * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
10 804b1ec4 2001-12-31 alex * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
12 e62ad979 2002-09-03 alex * $Id: client.c,v 1.60 2002/09/03 18:54:31 alex Exp $
14 38b9cb88 2001-12-14 alex * client.c: Management aller Clients
16 38b9cb88 2001-12-14 alex * Der Begriff "Client" ist in diesem Fall evtl. etwas verwirrend: Clients sind
17 38b9cb88 2001-12-14 alex * alle Verbindungen, die im gesamten(!) IRC-Netzwerk bekannt sind. Das sind IRC-
18 38b9cb88 2001-12-14 alex * Clients (User), andere Server und IRC-Services.
19 38b9cb88 2001-12-14 alex * Ueber welchen IRC-Server die Verbindung nun tatsaechlich in das Netzwerk her-
20 38b9cb88 2001-12-14 alex * gestellt wurde, muss der jeweiligen Struktur entnommen werden. Ist es dieser
21 38b9cb88 2001-12-14 alex * Server gewesen, so existiert eine entsprechende CONNECTION-Struktur.
25 f7551900 2002-01-04 alex #define __client_c__
28 ca33cbda 2002-03-12 alex #include "portab.h"
30 ca33cbda 2002-03-12 alex #include "imp.h"
31 38b9cb88 2001-12-14 alex #include <assert.h>
32 d0ac1e9c 2001-12-23 alex #include <unistd.h>
33 118adda8 2001-12-27 alex #include <stdio.h>
34 b20fa7c6 2002-01-01 alex #include <stdlib.h>
35 d0ac1e9c 2001-12-23 alex #include <string.h>
36 c57a4645 2001-12-27 alex #include <netdb.h>
38 c2f60abe 2002-05-27 alex #include "conn.h"
40 ca33cbda 2002-03-12 alex #include "exp.h"
41 08cf5607 2001-12-26 alex #include "client.h"
43 08cf5607 2001-12-26 alex #include <imp.h>
44 79809118 2002-01-06 alex #include "ngircd.h"
45 38b9cb88 2001-12-14 alex #include "channel.h"
46 c2f60abe 2002-05-27 alex #include "resolve.h"
47 9856253d 2001-12-30 alex #include "conf.h"
48 b5c16c22 2002-03-25 alex #include "hash.h"
49 ff54198f 2002-02-27 alex #include "irc-write.h"
50 38b9cb88 2001-12-14 alex #include "log.h"
51 08cf5607 2001-12-26 alex #include "messages.h"
53 38b9cb88 2001-12-14 alex #include <exp.h>
56 f7551900 2002-01-04 alex LOCAL CLIENT *This_Server, *My_Clients;
57 118adda8 2001-12-27 alex LOCAL CHAR GetID_Buffer[CLIENT_ID_LEN];
60 c2f60abe 2002-05-27 alex LOCAL INT Count PARAMS(( CLIENT_TYPE Type ));
61 c2f60abe 2002-05-27 alex LOCAL INT MyCount PARAMS(( CLIENT_TYPE Type ));
63 c2f60abe 2002-05-27 alex LOCAL CLIENT *New_Client_Struct PARAMS(( VOID ));
64 c2f60abe 2002-05-27 alex LOCAL VOID Generate_MyToken PARAMS(( CLIENT *Client ));
68 c2f60abe 2002-05-27 alex Client_Init( VOID )
70 c57a4645 2001-12-27 alex struct hostent *h;
72 38b9cb88 2001-12-14 alex This_Server = New_Client_Struct( );
73 38b9cb88 2001-12-14 alex if( ! This_Server )
75 38b9cb88 2001-12-14 alex Log( LOG_EMERG, "Can't allocate client structure for server! Going down." );
76 f7327524 2002-05-30 alex Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
80 38b9cb88 2001-12-14 alex /* Client-Struktur dieses Servers */
81 38b9cb88 2001-12-14 alex This_Server->next = NULL;
82 38b9cb88 2001-12-14 alex This_Server->type = CLIENT_SERVER;
83 38b9cb88 2001-12-14 alex This_Server->conn_id = NONE;
84 38b9cb88 2001-12-14 alex This_Server->introducer = This_Server;
85 8f7e7d66 2002-01-09 alex This_Server->mytoken = 1;
86 4fe7e9d6 2002-01-11 alex This_Server->hops = 0;
88 d0ac1e9c 2001-12-23 alex gethostname( This_Server->host, CLIENT_HOST_LEN );
89 c57a4645 2001-12-27 alex h = gethostbyname( This_Server->host );
90 c57a4645 2001-12-27 alex if( h ) strcpy( This_Server->host, h->h_name );
92 b5c16c22 2002-03-25 alex Client_SetID( This_Server, Conf_ServerName );
93 b5c16c22 2002-03-25 alex Client_SetInfo( This_Server, Conf_ServerInfo );
95 38b9cb88 2001-12-14 alex My_Clients = This_Server;
96 38b9cb88 2001-12-14 alex } /* Client_Init */
100 c2f60abe 2002-05-27 alex Client_Exit( VOID )
102 d0ac1e9c 2001-12-23 alex CLIENT *c, *next;
105 9cb74e81 2002-06-02 alex if( NGIRCd_Restart ) Client_Destroy( This_Server, "Server going down (restarting).", NULL, FALSE );
106 9cb74e81 2002-06-02 alex else Client_Destroy( This_Server, "Server going down.", NULL, FALSE );
109 d0ac1e9c 2001-12-23 alex c = My_Clients;
113 95a4b1b1 2002-03-25 alex next = (CLIENT *)c->next;
117 d4a60bd4 2001-12-25 alex if( cnt ) Log( LOG_INFO, "Freed %d client structure%s.", cnt, cnt == 1 ? "" : "s" );
118 79809118 2002-01-06 alex } /* Client_Exit */
121 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
122 c2f60abe 2002-05-27 alex Client_ThisServer( VOID )
124 f7551900 2002-01-04 alex return This_Server;
125 f7551900 2002-01-04 alex } /* Client_ThisServer */
128 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
129 c2f60abe 2002-05-27 alex Client_NewLocal( CONN_ID Idx, CHAR *Hostname, INT Type, BOOLEAN Idented )
131 f7551900 2002-01-04 alex /* Neuen lokalen Client erzeugen: Wrapper-Funktion fuer Client_New(). */
132 1ab92bb9 2002-01-29 alex return Client_New( Idx, This_Server, NULL, Type, NULL, NULL, Hostname, NULL, 0, 0, NULL, Idented );
133 f7551900 2002-01-04 alex } /* Client_NewLocal */
136 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
137 c2f60abe 2002-05-27 alex Client_NewRemoteServer( CLIENT *Introducer, CHAR *Hostname, CLIENT *TopServer, INT Hops, INT Token, CHAR *Info, BOOLEAN Idented )
139 f7551900 2002-01-04 alex /* Neuen Remote-Client erzeugen: Wrapper-Funktion fuer Client_New (). */
140 1ab92bb9 2002-01-29 alex return Client_New( NONE, Introducer, TopServer, CLIENT_SERVER, Hostname, NULL, Hostname, Info, Hops, Token, NULL, Idented );
141 f7551900 2002-01-04 alex } /* Client_NewRemoteServer */
144 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
145 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 )
147 f7551900 2002-01-04 alex /* Neuen Remote-Client erzeugen: Wrapper-Funktion fuer Client_New (). */
148 1ab92bb9 2002-01-29 alex return Client_New( NONE, Introducer, NULL, CLIENT_USER, Nick, User, Hostname, Info, Hops, Token, Modes, Idented );
149 f7551900 2002-01-04 alex } /* Client_NewRemoteUser */
152 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
153 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 )
155 d0ac1e9c 2001-12-23 alex CLIENT *client;
157 f7551900 2002-01-04 alex assert( Idx >= NONE );
158 f7551900 2002-01-04 alex assert( Introducer != NULL );
159 b7a18e9f 2001-12-24 alex assert( Hostname != NULL );
161 d0ac1e9c 2001-12-23 alex client = New_Client_Struct( );
162 d0ac1e9c 2001-12-23 alex if( ! client ) return NULL;
164 2c5da58d 2001-12-29 alex /* Initialisieren */
165 d0ac1e9c 2001-12-23 alex client->conn_id = Idx;
166 f7551900 2002-01-04 alex client->introducer = Introducer;
167 1ab92bb9 2002-01-29 alex client->topserver = TopServer;
168 f7551900 2002-01-04 alex client->type = Type;
169 f7551900 2002-01-04 alex if( ID ) Client_SetID( client, ID );
170 904d5e5b 2002-01-05 alex if( User ) Client_SetUser( client, User, Idented );
171 f7551900 2002-01-04 alex if( Hostname ) Client_SetHostname( client, Hostname );
172 f7551900 2002-01-04 alex if( Info ) Client_SetInfo( client, Info );
173 f7551900 2002-01-04 alex client->hops = Hops;
174 f7551900 2002-01-04 alex client->token = Token;
175 f7551900 2002-01-04 alex if( Modes ) Client_SetModes( client, Modes );
176 a53857b4 2002-01-07 alex if( Type == CLIENT_SERVER ) Generate_MyToken( client );
178 a1a3e67d 2002-03-04 alex /* ist der User away? */
179 a1a3e67d 2002-03-04 alex if( strchr( client->modes, 'a' )) strcpy( client->away, DEFAULT_AWAY_MSG );
181 d0ac1e9c 2001-12-23 alex /* Verketten */
182 95a4b1b1 2002-03-25 alex client->next = (POINTER *)My_Clients;
183 d0ac1e9c 2001-12-23 alex My_Clients = client;
185 d0ac1e9c 2001-12-23 alex return client;
186 f7551900 2002-01-04 alex } /* Client_New */
189 c2f60abe 2002-05-27 alex GLOBAL VOID
190 c2f60abe 2002-05-27 alex Client_Destroy( CLIENT *Client, CHAR *LogMsg, CHAR *FwdMsg, BOOLEAN SendQuit )
192 d0ac1e9c 2001-12-23 alex /* Client entfernen. */
194 d0ac1e9c 2001-12-23 alex CLIENT *last, *c;
195 dce77559 2002-03-10 alex CHAR msg[LINE_LEN], *txt;
197 b7a18e9f 2001-12-24 alex assert( Client != NULL );
199 79809118 2002-01-06 alex if( LogMsg ) txt = LogMsg;
200 79809118 2002-01-06 alex else txt = FwdMsg;
201 79809118 2002-01-06 alex if( ! txt ) txt = "Reason unknown.";
203 03c3f3c9 2002-03-12 alex /* Netz-Split-Nachricht vorbereiten (noch nicht optimal) */
204 9146fa25 2002-03-12 alex if( Client->type == CLIENT_SERVER ) sprintf( msg, "%s: lost server %s", This_Server->id, Client->id );
206 d0ac1e9c 2001-12-23 alex last = NULL;
207 d0ac1e9c 2001-12-23 alex c = My_Clients;
210 c4854470 2002-01-04 alex if(( Client->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c != Client ))
212 dce77559 2002-03-10 alex /* der Client, der geloescht wird ist ein Server. Der Client, den wir gerade
213 dce77559 2002-03-10 alex * pruefen, ist ein Child von diesem und muss daher auch entfernt werden */
214 50ec7a56 2002-03-11 alex Client_Destroy( c, NULL, msg, FALSE );
215 c4854470 2002-01-04 alex last = NULL;
216 c4854470 2002-01-04 alex c = My_Clients;
219 d0ac1e9c 2001-12-23 alex if( c == Client )
221 dce77559 2002-03-10 alex /* Wir haben den Client gefunden: entfernen */
222 d0ac1e9c 2001-12-23 alex if( last ) last->next = c->next;
223 95a4b1b1 2002-03-25 alex else My_Clients = (CLIENT *)c->next;
225 c4854470 2002-01-04 alex if( c->type == CLIENT_USER )
227 db58d347 2002-01-05 alex if( c->conn_id != NONE )
229 50ec7a56 2002-03-11 alex /* Ein lokaler User */
230 b89c3108 2002-01-07 alex Log( LOG_NOTICE, "User \"%s\" unregistered (connection %d): %s", Client_Mask( c ), c->conn_id, txt );
232 50ec7a56 2002-03-11 alex if( SendQuit )
234 50ec7a56 2002-03-11 alex /* Alle andere Server informieren! */
235 50ec7a56 2002-03-11 alex if( FwdMsg ) IRC_WriteStrServersPrefix( NULL, c, "QUIT :%s", FwdMsg );
236 50ec7a56 2002-03-11 alex else IRC_WriteStrServersPrefix( NULL, c, "QUIT :" );
241 50ec7a56 2002-03-11 alex /* Remote User */
242 b89c3108 2002-01-07 alex Log( LOG_DEBUG, "User \"%s\" unregistered: %s", Client_Mask( c ), txt );
244 50ec7a56 2002-03-11 alex if( SendQuit )
246 50ec7a56 2002-03-11 alex /* Andere Server informieren, ausser denen, die "in
247 50ec7a56 2002-03-11 alex * Richtung dem liegen", auf dem der User registriert
248 50ec7a56 2002-03-11 alex * ist. Von denen haben wir das QUIT ja wohl bekommen. */
249 50ec7a56 2002-03-11 alex if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "QUIT :%s", FwdMsg );
250 50ec7a56 2002-03-11 alex else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "QUIT :" );
253 dadebb21 2002-06-01 alex Channel_Quit( c, FwdMsg ? FwdMsg : c->id );
255 79809118 2002-01-06 alex else if( c->type == CLIENT_SERVER )
257 28d58986 2002-02-27 alex if( c != This_Server )
259 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 );
260 6b58ab84 2002-03-27 alex else Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered: %s", c->id, txt );
263 8f7e7d66 2002-01-09 alex /* andere Server informieren */
264 8f7e7d66 2002-01-09 alex if( ! NGIRCd_Quit )
266 8f7e7d66 2002-01-09 alex if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :%s", c->id, FwdMsg );
267 8f7e7d66 2002-01-09 alex else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :", c->id );
272 28d58986 2002-02-27 alex if( c->conn_id != NONE )
274 28d58986 2002-02-27 alex if( c->id[0] ) Log( LOG_NOTICE, "Client \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt );
275 28d58986 2002-02-27 alex else Log( LOG_NOTICE, "Client unregistered (connection %d): %s", c->conn_id, txt );
279 28d58986 2002-02-27 alex if( c->id[0] ) Log( LOG_WARNING, "Unregistered unknown client \"%s\": %s", c->id, txt );
280 28d58986 2002-02-27 alex else Log( LOG_WARNING, "Unregistered unknown client: %s", c->id, txt );
288 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
290 d0ac1e9c 2001-12-23 alex } /* Client_Destroy */
293 c2f60abe 2002-05-27 alex GLOBAL VOID
294 c2f60abe 2002-05-27 alex Client_SetHostname( CLIENT *Client, CHAR *Hostname )
296 2c5da58d 2001-12-29 alex /* Hostname eines Clients setzen */
298 2c5da58d 2001-12-29 alex assert( Client != NULL );
299 c68c092c 2002-03-06 alex assert( Hostname != NULL );
301 10363b39 2002-03-03 alex strncpy( Client->host, Hostname, CLIENT_HOST_LEN - 1 );
302 804b1ec4 2001-12-31 alex Client->host[CLIENT_HOST_LEN - 1] = '\0';
303 2c5da58d 2001-12-29 alex } /* Client_SetHostname */
306 c2f60abe 2002-05-27 alex GLOBAL VOID
307 c2f60abe 2002-05-27 alex Client_SetID( CLIENT *Client, CHAR *ID )
309 b5c16c22 2002-03-25 alex /* Hostname eines Clients setzen, Hash-Wert berechnen */
311 f7551900 2002-01-04 alex assert( Client != NULL );
312 c68c092c 2002-03-06 alex assert( ID != NULL );
314 10363b39 2002-03-03 alex strncpy( Client->id, ID, CLIENT_ID_LEN - 1 );
315 f7551900 2002-01-04 alex Client->id[CLIENT_ID_LEN - 1] = '\0';
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 10363b39 2002-03-03 alex if( Idented ) strncpy( Client->user, User, CLIENT_USER_LEN - 1 );
333 904d5e5b 2002-01-05 alex Client->user[0] = '~';
334 10363b39 2002-03-03 alex strncpy( Client->user + 1, User, CLIENT_USER_LEN - 2 );
336 f7551900 2002-01-04 alex Client->user[CLIENT_USER_LEN - 1] = '\0';
337 f7551900 2002-01-04 alex } /* Client_SetUser */
340 c2f60abe 2002-05-27 alex GLOBAL VOID
341 c2f60abe 2002-05-27 alex Client_SetInfo( CLIENT *Client, CHAR *Info )
343 f7551900 2002-01-04 alex /* Hostname eines Clients setzen */
345 f7551900 2002-01-04 alex assert( Client != NULL );
346 c68c092c 2002-03-06 alex assert( Info != NULL );
348 10363b39 2002-03-03 alex strncpy( Client->info, Info, CLIENT_INFO_LEN - 1 );
349 f7551900 2002-01-04 alex Client->info[CLIENT_INFO_LEN - 1] = '\0';
350 f7551900 2002-01-04 alex } /* Client_SetInfo */
353 c2f60abe 2002-05-27 alex GLOBAL VOID
354 c2f60abe 2002-05-27 alex Client_SetModes( CLIENT *Client, CHAR *Modes )
356 e62ad979 2002-09-03 alex /* Modes eines Clients setzen */
358 f7551900 2002-01-04 alex assert( Client != NULL );
359 c68c092c 2002-03-06 alex assert( Modes != NULL );
361 10363b39 2002-03-03 alex strncpy( Client->modes, Modes, CLIENT_MODE_LEN - 1 );
362 49ed223c 2002-01-18 alex Client->modes[CLIENT_MODE_LEN - 1] = '\0';
363 f7551900 2002-01-04 alex } /* Client_SetModes */
366 e62ad979 2002-09-03 alex GLOBAL VOID
367 e62ad979 2002-09-03 alex Client_SetFlags( CLIENT *Client, CHAR *Flags )
369 e62ad979 2002-09-03 alex /* Flags eines Clients setzen */
371 e62ad979 2002-09-03 alex assert( Client != NULL );
372 e62ad979 2002-09-03 alex assert( Flags != NULL );
374 e62ad979 2002-09-03 alex strncpy( Client->flags, Flags, CLIENT_FLAGS_LEN - 1 );
375 e62ad979 2002-09-03 alex Client->modes[CLIENT_FLAGS_LEN - 1] = '\0';
376 e62ad979 2002-09-03 alex } /* Client_SetFlags */
379 c2f60abe 2002-05-27 alex GLOBAL VOID
380 c2f60abe 2002-05-27 alex Client_SetPassword( CLIENT *Client, CHAR *Pwd )
382 f7551900 2002-01-04 alex /* Von einem Client geliefertes Passwort */
384 f7551900 2002-01-04 alex assert( Client != NULL );
385 c68c092c 2002-03-06 alex assert( Pwd != NULL );
387 10363b39 2002-03-03 alex strncpy( Client->pwd, Pwd, CLIENT_PASS_LEN - 1 );
388 f7551900 2002-01-04 alex Client->pwd[CLIENT_PASS_LEN - 1] = '\0';
389 f7551900 2002-01-04 alex } /* Client_SetPassword */
392 c2f60abe 2002-05-27 alex GLOBAL VOID
393 c2f60abe 2002-05-27 alex Client_SetAway( CLIENT *Client, CHAR *Txt )
395 c4850124 2002-02-27 alex /* Von einem Client gelieferte AWAY-Nachricht */
397 c4850124 2002-02-27 alex assert( Client != NULL );
401 c4850124 2002-02-27 alex /* Client AWAY setzen */
402 10363b39 2002-03-03 alex strncpy( Client->away, Txt, CLIENT_AWAY_LEN - 1 );
403 c4850124 2002-02-27 alex Client->away[CLIENT_AWAY_LEN - 1] = '\0';
404 c4850124 2002-02-27 alex Client_ModeAdd( Client, 'a' );
405 c4850124 2002-02-27 alex Log( LOG_DEBUG, "User \"%s\" is away: %s", Client_Mask( Client ), Txt );
409 c4850124 2002-02-27 alex /* AWAY loeschen */
410 c4850124 2002-02-27 alex Client_ModeDel( Client, 'a' );
411 c4850124 2002-02-27 alex Log( LOG_DEBUG, "User \"%s\" is no longer away.", Client_Mask( Client ));
413 c4850124 2002-02-27 alex } /* Client_SetAway */
416 c2f60abe 2002-05-27 alex GLOBAL VOID
417 c2f60abe 2002-05-27 alex Client_SetType( CLIENT *Client, INT Type )
419 f7551900 2002-01-04 alex assert( Client != NULL );
420 f7551900 2002-01-04 alex Client->type = Type;
421 a53857b4 2002-01-07 alex if( Type == CLIENT_SERVER ) Generate_MyToken( Client );
422 f7551900 2002-01-04 alex } /* Client_SetType */
425 c2f60abe 2002-05-27 alex GLOBAL VOID
426 c2f60abe 2002-05-27 alex Client_SetHops( CLIENT *Client, INT Hops )
428 f7551900 2002-01-04 alex assert( Client != NULL );
429 f7551900 2002-01-04 alex Client->hops = Hops;
430 f7551900 2002-01-04 alex } /* Client_SetHops */
433 c2f60abe 2002-05-27 alex GLOBAL VOID
434 c2f60abe 2002-05-27 alex Client_SetToken( CLIENT *Client, INT Token )
436 f7551900 2002-01-04 alex assert( Client != NULL );
437 f7551900 2002-01-04 alex Client->token = Token;
438 f7551900 2002-01-04 alex } /* Client_SetToken */
441 c2f60abe 2002-05-27 alex GLOBAL VOID
442 c2f60abe 2002-05-27 alex Client_SetIntroducer( CLIENT *Client, CLIENT *Introducer )
444 f7551900 2002-01-04 alex assert( Client != NULL );
445 c68c092c 2002-03-06 alex assert( Introducer != NULL );
446 f7551900 2002-01-04 alex Client->introducer = Introducer;
447 f7551900 2002-01-04 alex } /* Client_SetIntroducer */
450 c2f60abe 2002-05-27 alex GLOBAL VOID
451 c2f60abe 2002-05-27 alex Client_SetOperByMe( CLIENT *Client, BOOLEAN OperByMe )
453 f7551900 2002-01-04 alex assert( Client != NULL );
454 f7551900 2002-01-04 alex Client->oper_by_me = OperByMe;
455 f7551900 2002-01-04 alex } /* Client_SetOperByMe */
458 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
459 c2f60abe 2002-05-27 alex Client_ModeAdd( CLIENT *Client, CHAR Mode )
461 f7551900 2002-01-04 alex /* Mode soll gesetzt werden. TRUE wird geliefert, wenn der
462 f7551900 2002-01-04 alex * Mode neu gesetzt wurde, FALSE, wenn der Client den Mode
463 f7551900 2002-01-04 alex * bereits hatte. */
467 f7551900 2002-01-04 alex assert( Client != NULL );
469 f7551900 2002-01-04 alex x[0] = Mode; x[1] = '\0';
470 f7551900 2002-01-04 alex if( ! strchr( Client->modes, x[0] ))
472 f7551900 2002-01-04 alex /* Client hat den Mode noch nicht -> setzen */
473 f7551900 2002-01-04 alex strcat( Client->modes, x );
474 f7551900 2002-01-04 alex return TRUE;
476 f7551900 2002-01-04 alex else return FALSE;
477 f7551900 2002-01-04 alex } /* Client_ModeAdd */
480 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
481 c2f60abe 2002-05-27 alex Client_ModeDel( CLIENT *Client, CHAR Mode )
483 f7551900 2002-01-04 alex /* Mode soll geloescht werden. TRUE wird geliefert, wenn der
484 f7551900 2002-01-04 alex * Mode entfernt wurde, FALSE, wenn der Client den Mode
485 f7551900 2002-01-04 alex * ueberhaupt nicht hatte. */
487 f7551900 2002-01-04 alex CHAR x[2], *p;
489 f7551900 2002-01-04 alex assert( Client != NULL );
491 f7551900 2002-01-04 alex x[0] = Mode; x[1] = '\0';
493 f7551900 2002-01-04 alex p = strchr( Client->modes, x[0] );
494 f7551900 2002-01-04 alex if( ! p ) return FALSE;
496 f7551900 2002-01-04 alex /* Client hat den Mode -> loeschen */
497 f7551900 2002-01-04 alex while( *p )
499 f7551900 2002-01-04 alex *p = *(p + 1);
502 f7551900 2002-01-04 alex return TRUE;
503 f7551900 2002-01-04 alex } /* Client_ModeDel */
506 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
507 c2f60abe 2002-05-27 alex Client_GetFromConn( CONN_ID Idx )
509 804b1ec4 2001-12-31 alex /* Client-Struktur, die zur lokalen Verbindung Idx gehoert,
510 d0ac1e9c 2001-12-23 alex * liefern. Wird keine gefunden, so wird NULL geliefert. */
514 b7a18e9f 2001-12-24 alex assert( Idx >= 0 );
516 d0ac1e9c 2001-12-23 alex c = My_Clients;
519 d0ac1e9c 2001-12-23 alex if( c->conn_id == Idx ) return c;
520 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
522 d0ac1e9c 2001-12-23 alex return NULL;
523 d0ac1e9c 2001-12-23 alex } /* Client_GetFromConn */
526 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
527 c2f60abe 2002-05-27 alex Client_Search( CHAR *Nick )
529 10363b39 2002-03-03 alex /* Client-Struktur, die den entsprechenden Nick hat, liefern.
530 10363b39 2002-03-03 alex * Wird keine gefunden, so wird NULL geliefert. */
532 b5c16c22 2002-03-25 alex CHAR search_id[CLIENT_ID_LEN], *ptr;
533 40c9fd26 2002-01-27 alex CLIENT *c = NULL;
534 b5c16c22 2002-03-25 alex UINT32 search_hash;
536 804b1ec4 2001-12-31 alex assert( Nick != NULL );
538 40c9fd26 2002-01-27 alex /* Nick kopieren und ggf. Host-Mask abschneiden */
539 b5c16c22 2002-03-25 alex strncpy( search_id, Nick, CLIENT_ID_LEN - 1 );
540 b5c16c22 2002-03-25 alex search_id[CLIENT_ID_LEN - 1] = '\0';
541 b5c16c22 2002-03-25 alex ptr = strchr( search_id, '!' );
542 d17748e9 2002-01-27 alex if( ptr ) *ptr = '\0';
544 b5c16c22 2002-03-25 alex search_hash = Hash( search_id );
546 804b1ec4 2001-12-31 alex c = My_Clients;
549 b5c16c22 2002-03-25 alex if( c->hash == search_hash )
551 b5c16c22 2002-03-25 alex /* lt. Hash-Wert: Treffer! */
552 b5c16c22 2002-03-25 alex if( strcasecmp( c->id, search_id ) == 0 ) return c;
554 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
556 804b1ec4 2001-12-31 alex return NULL;
557 b5c16c22 2002-03-25 alex } /* Client_Search */
560 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
561 c2f60abe 2002-05-27 alex Client_GetFromToken( CLIENT *Client, INT Token )
563 f7551900 2002-01-04 alex /* Client-Struktur, die den entsprechenden Introducer (=Client)
564 f7551900 2002-01-04 alex * und das gegebene Token hat, liefern. Wird keine gefunden,
565 f7551900 2002-01-04 alex * so wird NULL geliefert. */
569 90676129 2001-12-26 alex assert( Client != NULL );
570 f7551900 2002-01-04 alex assert( Token > 0 );
572 f7551900 2002-01-04 alex c = My_Clients;
575 f7551900 2002-01-04 alex if(( c->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c->token == Token )) return c;
576 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
578 f7551900 2002-01-04 alex return NULL;
579 f7551900 2002-01-04 alex } /* Client_GetFromToken */
583 c2f60abe 2002-05-27 alex Client_Type( CLIENT *Client )
585 f7551900 2002-01-04 alex assert( Client != NULL );
586 f7551900 2002-01-04 alex return Client->type;
587 f7551900 2002-01-04 alex } /* Client_Type */
590 c2f60abe 2002-05-27 alex GLOBAL CONN_ID
591 c2f60abe 2002-05-27 alex Client_Conn( CLIENT *Client )
593 f7551900 2002-01-04 alex assert( Client != NULL );
594 f7551900 2002-01-04 alex return Client->conn_id;
595 f7551900 2002-01-04 alex } /* Client_Conn */
598 c2f60abe 2002-05-27 alex GLOBAL CHAR *
599 c2f60abe 2002-05-27 alex Client_ID( CLIENT *Client )
601 f7551900 2002-01-04 alex assert( Client != NULL );
603 c68c092c 2002-03-06 alex #ifdef DEBUG
604 c68c092c 2002-03-06 alex if( Client->type == CLIENT_USER ) assert( strlen( Client->id ) < CLIENT_NICK_LEN );
607 f7551900 2002-01-04 alex if( Client->id[0] ) return Client->id;
608 90676129 2001-12-26 alex else return "*";
609 f7551900 2002-01-04 alex } /* Client_ID */
612 c2f60abe 2002-05-27 alex GLOBAL CHAR *
613 c2f60abe 2002-05-27 alex Client_Info( CLIENT *Client )
615 f7551900 2002-01-04 alex assert( Client != NULL );
616 f7551900 2002-01-04 alex return Client->info;
617 f7551900 2002-01-04 alex } /* Client_Info */
620 c2f60abe 2002-05-27 alex GLOBAL CHAR *
621 c2f60abe 2002-05-27 alex Client_User( CLIENT *Client )
623 f7551900 2002-01-04 alex assert( Client != NULL );
624 95a4b1b1 2002-03-25 alex if( Client->user[0] ) return Client->user;
625 f7551900 2002-01-04 alex else return "~";
626 f7551900 2002-01-04 alex } /* Client_User */
629 c2f60abe 2002-05-27 alex GLOBAL CHAR *
630 c2f60abe 2002-05-27 alex Client_Hostname( CLIENT *Client )
632 f7551900 2002-01-04 alex assert( Client != NULL );
633 f7551900 2002-01-04 alex return Client->host;
634 f7551900 2002-01-04 alex } /* Client_Hostname */
637 c2f60abe 2002-05-27 alex GLOBAL CHAR *
638 c2f60abe 2002-05-27 alex Client_Password( CLIENT *Client )
640 f7551900 2002-01-04 alex assert( Client != NULL );
641 f7551900 2002-01-04 alex return Client->pwd;
642 f7551900 2002-01-04 alex } /* Client_Password */
645 c2f60abe 2002-05-27 alex GLOBAL CHAR *
646 c2f60abe 2002-05-27 alex Client_Modes( CLIENT *Client )
648 f7551900 2002-01-04 alex assert( Client != NULL );
649 f7551900 2002-01-04 alex return Client->modes;
650 f7551900 2002-01-04 alex } /* Client_Modes */
653 e62ad979 2002-09-03 alex GLOBAL CHAR *
654 e62ad979 2002-09-03 alex Client_Flags( CLIENT *Client )
656 e62ad979 2002-09-03 alex assert( Client != NULL );
657 e62ad979 2002-09-03 alex return Client->flags;
658 e62ad979 2002-09-03 alex } /* Client_Flags */
661 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
662 c2f60abe 2002-05-27 alex Client_OperByMe( CLIENT *Client )
664 f7551900 2002-01-04 alex assert( Client != NULL );
665 f7551900 2002-01-04 alex return Client->oper_by_me;
666 f7551900 2002-01-04 alex } /* Client_OperByMe */
670 c2f60abe 2002-05-27 alex Client_Hops( CLIENT *Client )
672 f7551900 2002-01-04 alex assert( Client != NULL );
673 f7551900 2002-01-04 alex return Client->hops;
674 f7551900 2002-01-04 alex } /* Client_Hops */
678 c2f60abe 2002-05-27 alex Client_Token( CLIENT *Client )
680 f7551900 2002-01-04 alex assert( Client != NULL );
681 f7551900 2002-01-04 alex return Client->token;
682 f7551900 2002-01-04 alex } /* Client_Token */
686 c2f60abe 2002-05-27 alex Client_MyToken( CLIENT *Client )
688 a53857b4 2002-01-07 alex assert( Client != NULL );
689 a53857b4 2002-01-07 alex return Client->mytoken;
690 a53857b4 2002-01-07 alex } /* Client_MyToken */
693 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
694 c2f60abe 2002-05-27 alex Client_NextHop( CLIENT *Client )
698 e7be3a01 2002-01-05 alex assert( Client != NULL );
700 e7be3a01 2002-01-05 alex c = Client;
701 e7be3a01 2002-01-05 alex while( c->introducer && ( c->introducer != c ) && ( c->introducer != This_Server )) c = c->introducer;
703 e7be3a01 2002-01-05 alex } /* Client_NextHop */
706 c2f60abe 2002-05-27 alex GLOBAL CHAR *
707 c2f60abe 2002-05-27 alex Client_Mask( CLIENT *Client )
709 f7551900 2002-01-04 alex /* Client-"ID" liefern, wie sie z.B. fuer
710 f7551900 2002-01-04 alex * Prefixe benoetigt wird. */
712 f7551900 2002-01-04 alex assert( Client != NULL );
714 f7551900 2002-01-04 alex if( Client->type == CLIENT_SERVER ) return Client->id;
716 f7551900 2002-01-04 alex sprintf( GetID_Buffer, "%s!%s@%s", Client->id, Client->user, Client->host );
717 f7551900 2002-01-04 alex return GetID_Buffer;
718 f7551900 2002-01-04 alex } /* Client_Mask */
721 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
722 c2f60abe 2002-05-27 alex Client_Introducer( CLIENT *Client )
724 f7551900 2002-01-04 alex assert( Client != NULL );
725 f7551900 2002-01-04 alex return Client->introducer;
726 f7551900 2002-01-04 alex } /* Client_Introducer */
729 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
730 c2f60abe 2002-05-27 alex Client_TopServer( CLIENT *Client )
732 1ab92bb9 2002-01-29 alex assert( Client != NULL );
733 1ab92bb9 2002-01-29 alex return Client->topserver;
734 1ab92bb9 2002-01-29 alex } /* Client_TopServer */
737 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
738 c2f60abe 2002-05-27 alex Client_HasMode( CLIENT *Client, CHAR Mode )
740 f7551900 2002-01-04 alex assert( Client != NULL );
741 f7551900 2002-01-04 alex return strchr( Client->modes, Mode ) != NULL;
742 f7551900 2002-01-04 alex } /* Client_HasMode */
745 c2f60abe 2002-05-27 alex GLOBAL CHAR *
746 c2f60abe 2002-05-27 alex Client_Away( CLIENT *Client )
748 c4850124 2002-02-27 alex /* AWAY-Text liefern */
750 c4850124 2002-02-27 alex assert( Client != NULL );
751 c4850124 2002-02-27 alex return Client->away;
752 c4850124 2002-02-27 alex } /* Client_Away */
755 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
756 c2f60abe 2002-05-27 alex Client_CheckNick( CLIENT *Client, CHAR *Nick )
758 08cf5607 2001-12-26 alex /* Nick ueberpruefen */
760 08cf5607 2001-12-26 alex assert( Client != NULL );
761 08cf5607 2001-12-26 alex assert( Nick != NULL );
763 33944e8c 2002-02-06 alex /* Nick ungueltig? */
764 9f3a9df2 2002-02-17 alex if( ! Client_IsValidNick( Nick ))
766 9f3a9df2 2002-02-17 alex IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), Nick );
767 9f3a9df2 2002-02-17 alex return FALSE;
770 08cf5607 2001-12-26 alex /* Nick bereits vergeben? */
771 b5c16c22 2002-03-25 alex if( Client_Search( Nick ))
773 b5c16c22 2002-03-25 alex /* den Nick gibt es bereits */
774 b5c16c22 2002-03-25 alex IRC_WriteStrClient( Client, ERR_NICKNAMEINUSE_MSG, Client_ID( Client ), Nick );
775 b5c16c22 2002-03-25 alex return FALSE;
778 08cf5607 2001-12-26 alex return TRUE;
779 08cf5607 2001-12-26 alex } /* Client_CheckNick */
782 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
783 c2f60abe 2002-05-27 alex Client_CheckID( CLIENT *Client, CHAR *ID )
785 07903baa 2002-01-03 alex /* Nick ueberpruefen */
787 07903baa 2002-01-03 alex CHAR str[COMMAND_LEN];
790 07903baa 2002-01-03 alex assert( Client != NULL );
791 07903baa 2002-01-03 alex assert( Client->conn_id > NONE );
792 07903baa 2002-01-03 alex assert( ID != NULL );
794 07903baa 2002-01-03 alex /* Nick zu lang? */
795 9f3a9df2 2002-02-17 alex if( strlen( ID ) > CLIENT_ID_LEN )
797 9f3a9df2 2002-02-17 alex IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), ID );
798 9f3a9df2 2002-02-17 alex return FALSE;
801 07903baa 2002-01-03 alex /* ID bereits vergeben? */
802 07903baa 2002-01-03 alex c = My_Clients;
805 f7551900 2002-01-04 alex if( strcasecmp( c->id, ID ) == 0 )
807 07903baa 2002-01-03 alex /* die Server-ID gibt es bereits */
808 07903baa 2002-01-03 alex sprintf( str, "ID \"%s\" already registered!", ID );
809 79809118 2002-01-06 alex Log( LOG_ERR, "%s (on connection %d)", str, Client->conn_id );
810 79809118 2002-01-06 alex Conn_Close( Client->conn_id, str, str, TRUE );
811 07903baa 2002-01-03 alex return FALSE;
813 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
816 07903baa 2002-01-03 alex return TRUE;
817 07903baa 2002-01-03 alex } /* Client_CheckID */
820 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
821 c2f60abe 2002-05-27 alex Client_First( VOID )
823 fb9d6ce1 2001-12-31 alex /* Ersten Client liefern. */
825 fb9d6ce1 2001-12-31 alex return My_Clients;
826 fb9d6ce1 2001-12-31 alex } /* Client_First */
829 c2f60abe 2002-05-27 alex GLOBAL CLIENT *
830 c2f60abe 2002-05-27 alex Client_Next( CLIENT *c )
832 fb9d6ce1 2001-12-31 alex /* Naechsten Client liefern. Existiert keiner,
833 fb9d6ce1 2001-12-31 alex * so wird NULL geliefert. */
835 fb9d6ce1 2001-12-31 alex assert( c != NULL );
836 95a4b1b1 2002-03-25 alex return (CLIENT *)c->next;
837 fb9d6ce1 2001-12-31 alex } /* Client_Next */
841 c2f60abe 2002-05-27 alex Client_UserCount( VOID )
843 b9d701db 2002-01-16 alex return Count( CLIENT_USER );
844 b9d701db 2002-01-16 alex } /* Client_UserCount */
848 c2f60abe 2002-05-27 alex Client_ServiceCount( VOID )
850 b9d701db 2002-01-16 alex return Count( CLIENT_SERVICE );;
851 b9d701db 2002-01-16 alex } /* Client_ServiceCount */
855 c2f60abe 2002-05-27 alex Client_ServerCount( VOID )
857 b9d701db 2002-01-16 alex return Count( CLIENT_SERVER );
858 b9d701db 2002-01-16 alex } /* Client_ServerCount */
862 c2f60abe 2002-05-27 alex Client_MyUserCount( VOID )
864 b9d701db 2002-01-16 alex return MyCount( CLIENT_USER );
865 b9d701db 2002-01-16 alex } /* Client_MyUserCount */
869 c2f60abe 2002-05-27 alex Client_MyServiceCount( VOID )
871 b9d701db 2002-01-16 alex return MyCount( CLIENT_SERVICE );
872 b9d701db 2002-01-16 alex } /* Client_MyServiceCount */
876 c2f60abe 2002-05-27 alex Client_MyServerCount( VOID )
882 3be7b9ef 2002-04-14 alex c = My_Clients;
885 3be7b9ef 2002-04-14 alex if(( c->type == CLIENT_SERVER ) && ( c->hops == 1 )) cnt++;
886 3be7b9ef 2002-04-14 alex c = (CLIENT *)c->next;
888 3be7b9ef 2002-04-14 alex return cnt;
889 b9d701db 2002-01-16 alex } /* Client_MyServerCount */
893 c2f60abe 2002-05-27 alex Client_OperCount( VOID )
899 b9d701db 2002-01-16 alex c = My_Clients;
902 b9d701db 2002-01-16 alex if( c && ( c->type == CLIENT_USER ) && ( strchr( c->modes, 'o' ))) cnt++;
903 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
905 b9d701db 2002-01-16 alex return cnt;
906 b9d701db 2002-01-16 alex } /* Client_OperCount */
910 c2f60abe 2002-05-27 alex Client_UnknownCount( VOID )
916 b9d701db 2002-01-16 alex c = My_Clients;
919 b9d701db 2002-01-16 alex if( c && ( c->type != CLIENT_USER ) && ( c->type != CLIENT_SERVICE ) && ( c->type != CLIENT_SERVER )) cnt++;
920 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
922 b9d701db 2002-01-16 alex return cnt;
923 b9d701db 2002-01-16 alex } /* Client_UnknownCount */
926 c2f60abe 2002-05-27 alex GLOBAL BOOLEAN
927 c2f60abe 2002-05-27 alex Client_IsValidNick( CHAR *Nick )
929 33944e8c 2002-02-06 alex /* Ist der Nick gueltig? */
931 f7327524 2002-05-30 alex CHAR *ptr, goodchars[20];
933 33944e8c 2002-02-06 alex assert( Nick != NULL );
935 f7327524 2002-05-30 alex strcpy( goodchars, ";0123456789-" );
937 33944e8c 2002-02-06 alex if( Nick[0] == '#' ) return FALSE;
938 7157d936 2002-03-02 alex if( strchr( goodchars, Nick[0] )) return FALSE;
939 7157d936 2002-03-02 alex if( strlen( Nick ) >= CLIENT_NICK_LEN ) return FALSE;
941 7157d936 2002-03-02 alex ptr = Nick;
942 7157d936 2002-03-02 alex while( *ptr )
944 7157d936 2002-03-02 alex if(( *ptr < 'A' ) && ( ! strchr( goodchars, *ptr ))) return FALSE;
945 7157d936 2002-03-02 alex if(( *ptr > '}' ) && ( ! strchr( goodchars, *ptr ))) return FALSE;
949 33944e8c 2002-02-06 alex return TRUE;
950 33944e8c 2002-02-06 alex } /* Client_IsValidNick */
954 c2f60abe 2002-05-27 alex Count( CLIENT_TYPE Type )
960 b9d701db 2002-01-16 alex c = My_Clients;
963 3be7b9ef 2002-04-14 alex if( c->type == Type ) cnt++;
964 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
966 b9d701db 2002-01-16 alex return cnt;
967 b9d701db 2002-01-16 alex } /* Count */
971 c2f60abe 2002-05-27 alex MyCount( CLIENT_TYPE Type )
977 b9d701db 2002-01-16 alex c = My_Clients;
980 3be7b9ef 2002-04-14 alex if(( c->introducer == This_Server ) && ( c->type == Type )) cnt++;
981 95a4b1b1 2002-03-25 alex c = (CLIENT *)c->next;
983 b9d701db 2002-01-16 alex return cnt;
984 b9d701db 2002-01-16 alex } /* MyCount */
987 c2f60abe 2002-05-27 alex LOCAL CLIENT *
988 c2f60abe 2002-05-27 alex New_Client_Struct( VOID )
990 d0ac1e9c 2001-12-23 alex /* Neue CLIENT-Struktur pre-initialisieren */
994 38b9cb88 2001-12-14 alex c = malloc( sizeof( CLIENT ));
997 e6d1bcdf 2002-06-10 alex Log( LOG_EMERG, "Can't allocate memory! [New_Client_Struct]" );
998 38b9cb88 2001-12-14 alex return NULL;
1001 38b9cb88 2001-12-14 alex c->next = NULL;
1002 b5c16c22 2002-03-25 alex c->hash = 0;
1003 38b9cb88 2001-12-14 alex c->type = CLIENT_UNKNOWN;
1004 38b9cb88 2001-12-14 alex c->conn_id = NONE;
1005 38b9cb88 2001-12-14 alex c->introducer = NULL;
1006 1ab92bb9 2002-01-29 alex c->topserver = NULL;
1007 f7551900 2002-01-04 alex strcpy( c->id, "" );
1008 f7551900 2002-01-04 alex strcpy( c->pwd, "" );
1009 d0ac1e9c 2001-12-23 alex strcpy( c->host, "" );
1010 d0ac1e9c 2001-12-23 alex strcpy( c->user, "" );
1011 804b1ec4 2001-12-31 alex strcpy( c->info, "" );
1012 f0dacce9 2001-12-29 alex strcpy( c->modes, "" );
1013 804b1ec4 2001-12-31 alex c->oper_by_me = FALSE;
1014 f7551900 2002-01-04 alex c->hops = -1;
1015 f7551900 2002-01-04 alex c->token = -1;
1016 a53857b4 2002-01-07 alex c->mytoken = -1;
1017 c4850124 2002-02-27 alex strcpy( c->away, "" );
1018 e62ad979 2002-09-03 alex strcpy( c->flags, "" );
1021 38b9cb88 2001-12-14 alex } /* New_Client */
1024 c2f60abe 2002-05-27 alex LOCAL VOID
1025 c2f60abe 2002-05-27 alex Generate_MyToken( CLIENT *Client )
1027 a53857b4 2002-01-07 alex CLIENT *c;
1028 a53857b4 2002-01-07 alex INT token;
1030 a53857b4 2002-01-07 alex c = My_Clients;
1031 a53857b4 2002-01-07 alex token = 2;
1032 a53857b4 2002-01-07 alex while( c )
1034 a53857b4 2002-01-07 alex if( c->mytoken == token )
1036 a53857b4 2002-01-07 alex /* Das Token wurde bereits vergeben */
1038 a53857b4 2002-01-07 alex c = My_Clients;
1041 95a4b1b1 2002-03-25 alex else c = (CLIENT *)c->next;
1043 a53857b4 2002-01-07 alex Client->mytoken = token;
1044 a53857b4 2002-01-07 alex Log( LOG_DEBUG, "Assigned token %d to server \"%s\".", token, Client->id );
1045 a53857b4 2002-01-07 alex } /* Generate_MyToken */
1048 38b9cb88 2001-12-14 alex /* -eof- */