+} /* Client_Search */
+
+
+GLOBAL CLIENT *
+Client_GetFromToken( CLIENT *Client, int Token )
+{
+ /* Client-Struktur, die den entsprechenden Introducer (=Client)
+ * und das gegebene Token hat, liefern. Wird keine gefunden,
+ * so wird NULL geliefert. */
+
+ CLIENT *c;
+
+ assert( Client != NULL );
+ assert( Token > 0 );
+
+ c = My_Clients;
+ while( c )
+ {
+ if(( c->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c->token == Token )) return c;
+ c = (CLIENT *)c->next;
+ }
+ return NULL;
+} /* Client_GetFromToken */
+
+
+GLOBAL int
+Client_Type( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->type;
+} /* Client_Type */
+
+
+GLOBAL CONN_ID
+Client_Conn( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->conn_id;
+} /* Client_Conn */
+
+
+GLOBAL char *
+Client_ID( CLIENT *Client )
+{
+ assert( Client != NULL );
+
+#ifdef DEBUG
+ if(Client->type == CLIENT_USER)
+ assert(strlen(Client->id) < Conf_MaxNickLength);
+#endif
+
+ if( Client->id[0] ) return Client->id;
+ else return "*";
+} /* Client_ID */
+
+
+GLOBAL char *
+Client_Info( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->info;
+} /* Client_Info */
+
+
+GLOBAL char *
+Client_User( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->user[0] ? Client->user : "~";
+} /* Client_User */
+
+
+GLOBAL char *
+Client_Hostname( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->host;
+} /* Client_Hostname */
+
+
+GLOBAL char *
+Client_Password( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->pwd;
+} /* Client_Password */
+
+
+GLOBAL char *
+Client_Modes( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->modes;
+} /* Client_Modes */
+
+
+GLOBAL char *
+Client_Flags( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->flags;
+} /* Client_Flags */
+
+
+GLOBAL bool
+Client_OperByMe( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->oper_by_me;
+} /* Client_OperByMe */
+
+
+GLOBAL int
+Client_Hops( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->hops;
+} /* Client_Hops */
+
+
+GLOBAL int
+Client_Token( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->token;
+} /* Client_Token */
+
+
+GLOBAL int
+Client_MyToken( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->mytoken;
+} /* Client_MyToken */
+
+
+GLOBAL CLIENT *
+Client_NextHop( CLIENT *Client )
+{
+ CLIENT *c;
+
+ assert( Client != NULL );
+
+ c = Client;
+ while( c->introducer && ( c->introducer != c ) && ( c->introducer != This_Server ))
+ c = c->introducer;
+
+ return c;
+} /* Client_NextHop */
+
+
+GLOBAL char *
+Client_Mask( CLIENT *Client )
+{
+ /* Client-"ID" liefern, wie sie z.B. fuer
+ * Prefixe benoetigt wird. */
+
+ assert( Client != NULL );
+
+ if( Client->type == CLIENT_SERVER ) return Client->id;
+
+ snprintf( GetID_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user, Client->host );
+ return GetID_Buffer;
+} /* Client_Mask */
+
+
+GLOBAL CLIENT *
+Client_Introducer( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->introducer;
+} /* Client_Introducer */
+
+
+GLOBAL CLIENT *
+Client_TopServer( CLIENT *Client )
+{
+ assert( Client != NULL );
+ return Client->topserver;
+} /* Client_TopServer */
+
+
+GLOBAL bool
+Client_HasMode( CLIENT *Client, char Mode )
+{
+ assert( Client != NULL );
+ return strchr( Client->modes, Mode ) != NULL;
+} /* Client_HasMode */
+
+
+GLOBAL char *
+Client_Away( CLIENT *Client )
+{
+ /* AWAY-Text liefern */
+
+ assert( Client != NULL );
+ return Client->away;
+} /* Client_Away */
+
+
+GLOBAL bool
+Client_CheckNick( CLIENT *Client, char *Nick )
+{
+ assert( Client != NULL );
+ assert( Nick != NULL );
+
+ if( ! Client_IsValidNick( Nick ))
+ {
+ IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), Nick );
+ return false;
+ }
+
+ /* Nick bereits vergeben? */
+ if( Client_Search( Nick ))
+ {
+ /* den Nick gibt es bereits */
+ IRC_WriteStrClient( Client, ERR_NICKNAMEINUSE_MSG, Client_ID( Client ), Nick );
+ return false;
+ }
+
+ return true;
+} /* Client_CheckNick */
+
+
+GLOBAL bool
+Client_CheckID( CLIENT *Client, char *ID )
+{
+ /* Nick ueberpruefen */
+
+ char str[COMMAND_LEN];
+ CLIENT *c;
+
+ assert( Client != NULL );
+ assert( Client->conn_id > NONE );
+ assert( ID != NULL );
+
+ /* Nick zu lang? */
+ if( strlen( ID ) > CLIENT_ID_LEN )
+ {
+ IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), ID );
+ return false;
+ }
+
+ /* ID bereits vergeben? */
+ c = My_Clients;
+ while( c )
+ {
+ if( strcasecmp( c->id, ID ) == 0 )
+ {
+ /* die Server-ID gibt es bereits */
+ snprintf( str, sizeof( str ), "ID \"%s\" already registered", ID );
+ if( Client->conn_id != c->conn_id ) Log( LOG_ERR, "%s (on connection %d)!", str, c->conn_id );
+ else Log( LOG_ERR, "%s (via network)!", str );
+ Conn_Close( Client->conn_id, str, str, true);
+ return false;
+ }
+ c = (CLIENT *)c->next;
+ }
+
+ return true;
+} /* Client_CheckID */
+
+
+GLOBAL CLIENT *
+Client_First( void )
+{
+ /* Ersten Client liefern. */
+
+ return My_Clients;
+} /* Client_First */
+
+
+GLOBAL CLIENT *
+Client_Next( CLIENT *c )
+{
+ /* Naechsten Client liefern. Existiert keiner,
+ * so wird NULL geliefert. */
+
+ assert( c != NULL );
+ return (CLIENT *)c->next;
+} /* Client_Next */
+
+
+GLOBAL long
+Client_UserCount( void )
+{
+ return Count( CLIENT_USER );
+} /* Client_UserCount */
+
+
+GLOBAL long
+Client_ServiceCount( void )
+{
+ return Count( CLIENT_SERVICE );;
+} /* Client_ServiceCount */
+
+
+GLOBAL long
+Client_ServerCount( void )
+{
+ return Count( CLIENT_SERVER );
+} /* Client_ServerCount */
+
+
+GLOBAL long
+Client_MyUserCount( void )
+{
+ return MyCount( CLIENT_USER );
+} /* Client_MyUserCount */
+
+
+GLOBAL long
+Client_MyServiceCount( void )
+{
+ return MyCount( CLIENT_SERVICE );
+} /* Client_MyServiceCount */
+
+
+GLOBAL unsigned long
+Client_MyServerCount( void )
+{
+ CLIENT *c;
+ unsigned long cnt = 0;
+
+ c = My_Clients;
+ while( c )
+ {
+ if(( c->type == CLIENT_SERVER ) && ( c->hops == 1 )) cnt++;
+ c = (CLIENT *)c->next;
+ }
+ return cnt;
+} /* Client_MyServerCount */
+
+
+GLOBAL unsigned long
+Client_OperCount( void )
+{
+ CLIENT *c;
+ unsigned long cnt = 0;
+
+ c = My_Clients;
+ while( c )
+ {
+ if( c && ( c->type == CLIENT_USER ) && ( strchr( c->modes, 'o' ))) cnt++;
+ c = (CLIENT *)c->next;
+ }
+ return cnt;
+} /* Client_OperCount */
+
+
+GLOBAL unsigned long
+Client_UnknownCount( void )
+{
+ CLIENT *c;
+ unsigned long cnt = 0;
+
+ c = My_Clients;
+ while( c )
+ {
+ if( c && ( c->type != CLIENT_USER ) && ( c->type != CLIENT_SERVICE ) && ( c->type != CLIENT_SERVER )) cnt++;
+ c = (CLIENT *)c->next;
+ }
+
+ return cnt;
+} /* Client_UnknownCount */
+
+
+GLOBAL long
+Client_MaxUserCount( void )
+{
+ return Max_Users;
+} /* Client_MaxUserCount */
+
+
+GLOBAL long
+Client_MyMaxUserCount( void )
+{
+ return My_Max_Users;
+} /* Client_MyMaxUserCount */
+
+
+GLOBAL bool
+Client_IsValidNick( const char *Nick )
+{
+ const char *ptr;
+ static const char goodchars[] = ";0123456789-";
+
+ assert( Nick != NULL );
+
+ if( Nick[0] == '#' ) return false;
+ if( strchr( goodchars, Nick[0] )) return false;
+ if( strlen( Nick ) >= Conf_MaxNickLength) return false;
+
+ ptr = Nick;
+ while( *ptr )
+ {
+ if (( *ptr < 'A' ) && ( ! strchr( goodchars, *ptr ))) return false;
+ if ( *ptr > '}' ) return false;
+ ptr++;
+ }
+
+ return true;
+} /* Client_IsValidNick */
+
+
+/**
+ * Return pointer to "My_Whowas" structure.
+ */
+GLOBAL WHOWAS *
+Client_GetWhowas( void )
+{
+ return My_Whowas;
+} /* Client_GetWhowas */
+
+/**
+ * Return the index of the last used WHOWAS entry.
+ */
+GLOBAL int
+Client_GetLastWhowasIndex( void )
+{
+ return Last_Whowas;
+} /* Client_GetLastWhowasIndex */
+
+
+/**
+ * Get the start time of this client.
+ * The result is the start time in seconds since 1970-01-01, as reported
+ * by the C function time(NULL).
+ */
+GLOBAL time_t
+Client_StartTime(CLIENT *Client)
+{
+ assert( Client != NULL );
+ return Client->starttime;
+} /* Client_Uptime */
+