X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fclient.c;h=07fd6481bb3a55c3f5848bd12294ce0385095075;hb=d58e22a3eab0741d6a471229c3c451ec1ae395bf;hp=52dc7ebf5c8577f326d1b5333f80a9381d108ab5;hpb=33944e8cdb4e03d624bbc08b7a132d3b2440ec8c;p=ngircd-alex.git diff --git a/src/ngircd/client.c b/src/ngircd/client.c index 52dc7ebf..07fd6481 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -9,7 +9,7 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: client.c,v 1.36 2002/02/06 16:49:41 alex Exp $ + * $Id: client.c,v 1.39 2002/02/27 18:22:09 alex Exp $ * * client.c: Management aller Clients * @@ -21,6 +21,15 @@ * Server gewesen, so existiert eine entsprechende CONNECTION-Struktur. * * $Log: client.c,v $ + * Revision 1.39 2002/02/27 18:22:09 alex + * - neue Funktion Client_SetAway() und Client_Away() implementiert. + * + * Revision 1.38 2002/02/27 14:47:53 alex + * - Logging beim Abmelden von Clients (erneut) geaendert: nun ist's aber gut ;-) + * + * Revision 1.37 2002/02/17 19:02:49 alex + * - Client_CheckNick() und Client_CheckID() lieferten u.U. falsche Ergebnisse. + * * Revision 1.36 2002/02/06 16:49:41 alex * - neue Funktion Client_IsValidNick(), Nicknames werden besser validiert. * @@ -342,7 +351,11 @@ GLOBAL VOID Client_Destroy( CLIENT *Client, CHAR *LogMsg, CHAR *FwdMsg ) } else if( c->type == CLIENT_SERVER ) { - if( c != This_Server ) Log( LOG_NOTICE, "Server \"%s\" unregistered: %s", c->id, txt ); + if( c != This_Server ) + { + if( c->conn_id != NONE ) Log( LOG_NOTICE, "Server \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt ); + else Log( LOG_NOTICE, "Server \"%s\" unregistered: %s", c->id, txt ); + } /* andere Server informieren */ if( ! NGIRCd_Quit ) @@ -351,7 +364,19 @@ GLOBAL VOID Client_Destroy( CLIENT *Client, CHAR *LogMsg, CHAR *FwdMsg ) else IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :", c->id ); } } - else Log( LOG_NOTICE, "Unknown client \"%s\" unregistered: %s", c->id, txt ); + else + { + if( c->conn_id != NONE ) + { + if( c->id[0] ) Log( LOG_NOTICE, "Client \"%s\" unregistered (connection %d): %s", c->id, c->conn_id, txt ); + else Log( LOG_NOTICE, "Client unregistered (connection %d): %s", c->conn_id, txt ); + } + else + { + if( c->id[0] ) Log( LOG_WARNING, "Unregistered unknown client \"%s\": %s", c->id, txt ); + else Log( LOG_WARNING, "Unregistered unknown client: %s", c->id, txt ); + } + } free( c ); break; @@ -427,6 +452,29 @@ GLOBAL VOID Client_SetPassword( CLIENT *Client, CHAR *Pwd ) } /* Client_SetPassword */ +GLOBAL VOID Client_SetAway( CLIENT *Client, CHAR *Txt ) +{ + /* Von einem Client gelieferte AWAY-Nachricht */ + + assert( Client != NULL ); + + if( Txt ) + { + /* Client AWAY setzen */ + strncpy( Client->away, Txt, CLIENT_AWAY_LEN ); + Client->away[CLIENT_AWAY_LEN - 1] = '\0'; + Client_ModeAdd( Client, 'a' ); + Log( LOG_DEBUG, "User \"%s\" is away: %s", Client_Mask( Client ), Txt ); + } + else + { + /* AWAY loeschen */ + Client_ModeDel( Client, 'a' ); + Log( LOG_DEBUG, "User \"%s\" is no longer away.", Client_Mask( Client )); + } +} /* Client_SetAway */ + + GLOBAL VOID Client_SetType( CLIENT *Client, INT Type ) { assert( Client != NULL ); @@ -709,6 +757,15 @@ GLOBAL BOOLEAN Client_HasMode( CLIENT *Client, CHAR Mode ) } /* Client_HasMode */ +GLOBAL CHAR *Client_Away( CLIENT *Client ) +{ + /* AWAY-Text liefern */ + + assert( Client != NULL ); + return Client->away; +} /* Client_Away */ + + GLOBAL BOOLEAN Client_CheckNick( CLIENT *Client, CHAR *Nick ) { /* Nick ueberpruefen */ @@ -719,7 +776,11 @@ GLOBAL BOOLEAN Client_CheckNick( CLIENT *Client, CHAR *Nick ) assert( Nick != NULL ); /* Nick ungueltig? */ - if( ! Client_IsValidNick( Nick )) return IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), Nick ); + if( ! Client_IsValidNick( Nick )) + { + IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), Nick ); + return FALSE; + } /* Nick bereits vergeben? */ c = My_Clients; @@ -750,7 +811,11 @@ GLOBAL BOOLEAN Client_CheckID( CLIENT *Client, CHAR *ID ) assert( ID != NULL ); /* Nick zu lang? */ - if( strlen( ID ) > CLIENT_ID_LEN ) return IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), ID ); + if( strlen( ID ) > CLIENT_ID_LEN ) + { + IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), ID ); + return FALSE; + } /* ID bereits vergeben? */ c = My_Clients; @@ -948,6 +1013,7 @@ LOCAL CLIENT *New_Client_Struct( VOID ) c->hops = -1; c->token = -1; c->mytoken = -1; + strcpy( c->away, "" ); return c; } /* New_Client */