commit c2ee5437da3483aacf2ab254370b9594776de7ad from: Alexander Barton date: Fri Jan 11 23:50:55 2002 UTC - LINKS implementiert, LUSERS begonnen. commit - 4fe7e9d6f1d7a3c2a02fe45372d09e2e9bd9b10b commit + c2ee5437da3483aacf2ab254370b9594776de7ad blob - 1f47226b7129ffddf964b4f27a98fa0066dd12d6 blob + 7ce6ee2740cd6c2cfc158a110375344dbb085450 --- src/ngircd/irc.c +++ src/ngircd/irc.c @@ -9,11 +9,14 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: irc.c,v 1.35 2002/01/09 21:30:45 alex Exp $ + * $Id: irc.c,v 1.36 2002/01/11 23:50:55 alex Exp $ * * irc.c: IRC-Befehle * * $Log: irc.c,v $ + * Revision 1.36 2002/01/11 23:50:55 alex + * - LINKS implementiert, LUSERS begonnen. + * * Revision 1.35 2002/01/09 21:30:45 alex * - WHOIS wurde faelschlicherweise an User geforwarded statt vom Server beantwortet. * @@ -773,7 +776,8 @@ GLOBAL BOOLEAN IRC_PRIVMSG( CLIENT *Client, REQUEST *R if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_GetFromID( Req->prefix ); else from = Client; - + if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); + to = Client_Search( Req->argv[0] ); if( to ) { @@ -799,6 +803,7 @@ GLOBAL BOOLEAN IRC_NOTICE( CLIENT *Client, REQUEST *Re if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_GetFromID( Req->prefix ); else from = Client; + if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); to = Client_Search( Req->argv[0] ); if( to ) @@ -1209,8 +1214,71 @@ GLOBAL BOOLEAN IRC_ERROR( CLIENT *Client, REQUEST *Req return CONNECTED; } /* IRC_ERROR */ + + +GLOBAL BOOLEAN IRC_LUSERS( CLIENT *Client, REQUEST *Req ) +{ + assert( Client != NULL ); + assert( Req != NULL ); + + if( Client_Type( Client ) != CLIENT_USER ) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client )); + + /* Falsche Anzahl Parameter? */ + if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); + + return CONNECTED; +} /* IRC_LUSERS */ + + +GLOBAL BOOLEAN IRC_LINKS( CLIENT *Client, REQUEST *Req ) +{ + CLIENT *target, *from, *c; + CHAR *mask; + + assert( Client != NULL ); + assert( Req != NULL ); + + if(( Client_Type( Client ) != CLIENT_USER ) && ( Client_Type( Client ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client )); + + /* Falsche Anzahl Parameter? */ + if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); + /* Server-Mask ermitteln */ + if( Req->argc > 0 ) mask = Req->argv[Req->argc - 1]; + else mask = "*"; + /* Absender ermitteln */ + if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_GetFromID( Req->prefix ); + else from = Client; + if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); + + /* An anderen Server forwarden? */ + if( Req->argc == 2 ) + { + target = Client_GetFromID( Req->argv[0] ); + if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] ); + else if( target != Client_ThisServer( )) return IRC_WriteStrClientPrefix( target, from, "LINKS %s %s", Req->argv[0], Req->argv[1] ); + } + + /* Wer ist der Absender? */ + if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_GetFromID( Req->prefix ); + else target = Client; + if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); + + c = Client_First( ); + while( c ) + { + if( Client_Type( c ) == CLIENT_SERVER ) + { + if( ! IRC_WriteStrClient( target, RPL_LINKS_MSG, Client_ID( target ), Client_ID( c ), Client_ID( Client_Introducer( c )), Client_Hops( c ), Client_Info( c ))) return DISCONNECTED; + } + c = Client_Next( c ); + } + + return IRC_WriteStrClient( target, RPL_ENDOFLINKS_MSG, Client_ID( target ), mask ); +} /* IRC_LINKS */ + + LOCAL BOOLEAN Hello_User( CLIENT *Client ) { assert( Client != NULL ); blob - 48b703d0cc89623c1fb20becd6466ac4bba73832 blob + b707cdb1120f3764a86c9c069b4366e73f66c232 --- src/ngircd/irc.h +++ src/ngircd/irc.h @@ -9,11 +9,14 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: irc.h,v 1.16 2002/01/05 19:15:03 alex Exp $ + * $Id: irc.h,v 1.17 2002/01/11 23:50:55 alex Exp $ * * irc.h: IRC-Befehle (Header) * * $Log: irc.h,v $ + * Revision 1.17 2002/01/11 23:50:55 alex + * - LINKS implementiert, LUSERS begonnen. + * * Revision 1.16 2002/01/05 19:15:03 alex * - Fehlerpruefung bei select() in der "Hauptschleife" korrigiert. * @@ -94,6 +97,8 @@ GLOBAL BOOLEAN IRC_QUIT( CLIENT *Client, REQUEST *Req GLOBAL BOOLEAN IRC_SQUIT( CLIENT *Client, REQUEST *Req ); GLOBAL BOOLEAN IRC_MOTD( CLIENT *Client, REQUEST *Req ); +GLOBAL BOOLEAN IRC_LUSERS( CLIENT *Client, REQUEST *Req ); +GLOBAL BOOLEAN IRC_LINKS( CLIENT *Client, REQUEST *Req ); GLOBAL BOOLEAN IRC_PRIVMSG( CLIENT *Client, REQUEST *Req ); GLOBAL BOOLEAN IRC_NOTICE( CLIENT *Client, REQUEST *Req ); blob - 8a47207c17e02ef950ff8f344e4e50ac155b5a2a blob + 0001426032d130542dc3881e10e293da96d19fd7 --- src/ngircd/messages.h +++ src/ngircd/messages.h @@ -9,11 +9,14 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: messages.h,v 1.17 2002/01/05 23:23:44 alex Exp $ + * $Id: messages.h,v 1.18 2002/01/11 23:50:55 alex Exp $ * * irc.h: IRC-Befehle (Header) * * $Log: messages.h,v $ + * Revision 1.18 2002/01/11 23:50:55 alex + * - LINKS implementiert, LUSERS begonnen. + * * Revision 1.17 2002/01/05 23:23:44 alex * - neue Nachricht ERR_NOSUCHSERVER_MSG definiert. * @@ -89,6 +92,21 @@ #define RPL_MYINFO "004" #define RPL_MYINFO_MSG RPL_MYINFO" %s %s ngircd-"VERSION" ior +" +#define RPL_LUSERCLIENT "251" +#define RPL_LUSERCLIENT_MSG RPL_LUSERCLIENT" %s :There are %d users and %d services on %d servers" + +#define RPL_LUSEROP "252" +#define RPL_LUSEROP_MSG RPL_LUSEROP" %s %d :operator(s) online" + +#define RPL_LUSERUNKNOWN "253" +#define RPL_LUSERUNKNOWN_MSG RPL_LUSERUNKNOWN" %s %d :unknown connection(s)" + +#define RPL_LUSERCHANNELS "254" +#define RPL_LUSERCHANNELS_MSG RPL_LUSERCHANNELS_MSG" %s %d :channels formed" + +#define RPL_LUSERME "255" +#define RPL_LUSERME_MSG RPL_LUSERME" %s :I have %d clients and %d servers" + #define RPL_MOTDSTART "375" #define RPL_MOTDSTART_MSG RPL_MOTDSTART" %s :- %s message of the day" @@ -128,6 +146,12 @@ #define RPL_NAMREPLY "353" #define RPL_NAMREPLY_MSG RPL_NAMREPLY" %s %s %s :%s" +#define RPL_LINKS "364" +#define RPL_LINKS_MSG RPL_LINKS" %s %s %s :%d %s" + +#define RPL_ENDOFLINKS "365" +#define RPL_ENDOFLINKS_MSG RPL_ENDOFLINKS" %s %s :End of LINKS list" + #define RPL_ENDOFNAMES "366" #define RPL_ENDOFNAMES_MSG RPL_ENDOFNAMES" %s %s :End of NAMES list" blob - bab9c6c5ec96d18fff4374c455f2b6b67bb06eea blob + 8ed765a087a23a9574da21bef794ea03d465393c --- src/ngircd/parse.c +++ src/ngircd/parse.c @@ -9,11 +9,14 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: parse.c,v 1.19 2002/01/09 01:08:42 alex Exp $ + * $Id: parse.c,v 1.20 2002/01/11 23:50:55 alex Exp $ * * parse.c: Parsen der Client-Anfragen * * $Log: parse.c,v $ + * Revision 1.20 2002/01/11 23:50:55 alex + * - LINKS implementiert, LUSERS begonnen. + * * Revision 1.19 2002/01/09 01:08:42 alex * - Parses handhabt Leerzeichen zw. Parametern nun etwas "lockerer". * @@ -353,6 +356,8 @@ LOCAL BOOLEAN Handle_Request( CONN_ID Idx, REQUEST *Re else if( strcasecmp( Req->command, "DIE" ) == 0 ) return IRC_DIE( client, Req ); else if( strcasecmp( Req->command, "RESTART" ) == 0 ) return IRC_RESTART( client, Req ); else if( strcasecmp( Req->command, "ERROR" ) == 0 ) return IRC_ERROR( client, Req ); + else if( strcasecmp( Req->command, "LUSERS" ) == 0 ) return IRC_LUSERS( client, Req ); + else if( strcasecmp( Req->command, "LINKS" ) == 0 ) return IRC_LINKS( client, Req ); /* Unbekannter Befehl */ if( Client_Type( client ) != CLIENT_SERVER ) IRC_WriteStrClient( client, ERR_UNKNOWNCOMMAND_MSG, Client_ID( client ), Req->command );