X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fparse.c;h=e5eaa6ee3ff9ad6771f13668664fe1c3b5b6ead8;hb=0ff33777febca1ac06417c976a4a3e76b68c93d8;hp=5ff9fcc2ce84136bb3fec671f2c822293da0cda7;hpb=35ed57e6c160dc13c2bbca2ca042406285d4ced3;p=ngircd-alex.git diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c index 5ff9fcc2..e5eaa6ee 100644 --- a/src/ngircd/parse.c +++ b/src/ngircd/parse.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2010 Alexander Barton (alex@barton.de) + * Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -127,7 +127,7 @@ static COMMAND My_Commands[] = { "GET", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, 0, 0 }, { "POST", IRC_QUIT_HTTP, CLIENT_UNKNOWN, 0, 0, 0 }, #endif - { NULL, NULL, 0x0, 0, 0, 0 } /* Ende-Marke */ + { NULL, NULL, 0x0, 0, 0, 0 } /* End-Mark */ }; static void Init_Request PARAMS(( REQUEST *Req )); @@ -157,7 +157,7 @@ Parse_GetCommandStruct( void ) * Parse a command ("request") received from a client. * * This function is called after the connection layer received a valid CR+LF - * terminated line of text: we asume that this is a valid IRC command and + * terminated line of text: we assume that this is a valid IRC command and * try to do something useful with it :-) * * All errors are reported to the client from which the command has been @@ -169,7 +169,7 @@ Parse_GetCommandStruct( void ) * @param Idx Index of the connection from which the command has been received. * @param Request NULL terminated line of text (the "command"). * @return true on success (valid command or "regular" error), false if a - * fatal error occured and the connection has been shut down. + * fatal error occurred and the connection has been shut down. */ GLOBAL bool Parse_Request( CONN_ID Idx, char *Request ) @@ -271,8 +271,6 @@ Parse_Request( CONN_ID Idx, char *Request ) static void Init_Request( REQUEST *Req ) { - /* Neue Request-Struktur initialisieren */ - int i; assert( Req != NULL ); @@ -367,7 +365,7 @@ Validate_Command( UNUSED CONN_ID Idx, UNUSED REQUEST *Req, bool *Closed ) *Closed = false; return true; -} /* Validate_Comman */ +} /* Validate_Command */ static bool @@ -514,10 +512,20 @@ Handle_Request( CONN_ID Idx, REQUEST *Req ) continue; } - if (!(client_type & cmd->type)) - return IRC_WriteStrClient(client, ERR_NOTREGISTERED_MSG, Client_ID(client)); + if (!(client_type & cmd->type)) { + if (client_type == CLIENT_USER + && cmd->type & CLIENT_SERVER) + return IRC_WriteErrClient(client, + ERR_NOTREGISTEREDSERVER_MSG, + Client_ID(client)); + else + return IRC_WriteErrClient(client, + ERR_NOTREGISTERED_MSG, + Client_ID(client)); + } - /* Command is allowed for this client: call it and count produced bytes */ + /* Command is allowed for this client: call it and count + * generated bytes in output */ Conn_ResetWCounter(); result = (cmd->function)(client, Req); cmd->bytes += Conn_WCounter(); @@ -541,11 +549,10 @@ Handle_Request( CONN_ID Idx, REQUEST *Req ) Req->argc == 1 ? "parameter" : "parameters", Req->prefix ? "" : " no" ); - if (Client_Type(client) != CLIENT_SERVER) { - result = IRC_WriteStrClient(client, ERR_UNKNOWNCOMMAND_MSG, + if (Client_Type(client) != CLIENT_SERVER) + result = IRC_WriteErrClient(client, ERR_UNKNOWNCOMMAND_MSG, Client_ID(client), Req->command); - Conn_SetPenalty(Idx, 1); - } + return result; } /* Handle_Request */