]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-oper.c
remove fd from io_event structure
[ngircd-alex.git] / src / ngircd / irc-oper.c
index 8153e34db459d849e955bb83cf919e277f5d071d..c9241b345b2d726df041302680abbe60e29bcef7 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-oper.c,v 1.21 2005/06/12 17:18:27 fw Exp $";
+static char UNUSED id[] = "$Id: irc-oper.c,v 1.26 2006/05/10 21:24:01 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -38,18 +38,19 @@ static char UNUSED id[] = "$Id: irc-oper.c,v 1.21 2005/06/12 17:18:27 fw Exp $";
 
 
 static bool
-bad_operpass(CLIENT *Client, char *errtoken, char *errmsg)
+Bad_OperPass(CLIENT *Client, char *errtoken, char *errmsg)
 {
- Log( LOG_WARNING, "Got invalid OPER from \"%s\": \"%s\" -- %s", Client_Mask( Client ), errtoken, errmsg);
- IRC_SetPenalty(Client, 3);
- return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
+       Log( LOG_WARNING, "Got invalid OPER from \"%s\": \"%s\" -- %s", Client_Mask( Client ),
+                                                                               errtoken, errmsg);
+       IRC_SetPenalty(Client, 3);
+       return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
 }
 
 
 GLOBAL bool
 IRC_OPER( CLIENT *Client, REQUEST *Req )
 {
-       int i;
+       unsigned int i;
 
        assert( Client != NULL );
        assert( Req != NULL );
@@ -63,15 +64,15 @@ IRC_OPER( CLIENT *Client, REQUEST *Req )
                if( Conf_Oper[i].name[0] && Conf_Oper[i].pwd[0] && ( strcmp( Conf_Oper[i].name, Req->argv[0] ) == 0 )) break;
        }
        if( i >= Conf_Oper_Count )
-               return bad_operpass(Client, Req->argv[0], "not configured");
+               return Bad_OperPass(Client, Req->argv[0], "not configured");
 
        /* Stimmt das Passwort? */
        if( strcmp( Conf_Oper[i].pwd, Req->argv[1] ) != 0 )
-               return bad_operpass(Client, Conf_Oper[i].name, "Bad password");
+               return Bad_OperPass(Client, Conf_Oper[i].name, "Bad password");
 
        /* Authorized Mask? */
        if( Conf_Oper[i].mask && (! Match( Conf_Oper[i].mask, Client_Mask( Client ) )))
-               return bad_operpass(Client, Conf_Oper[i].mask, "hostmask check failed" );
+               return Bad_OperPass(Client, Conf_Oper[i].mask, "hostmask check failed" );
 
        if( ! Client_HasMode( Client, 'o' ))
        {
@@ -149,35 +150,52 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req )
 } /* IRC_RESTART */
 
 
+/**
+ * Connect configured or new server.
+ */
 GLOBAL bool
-IRC_CONNECT(CLIENT *Client, REQUEST *Req )
+IRC_CONNECT(CLIENT * Client, REQUEST * Req)
 {
-       /* Connect configured or new server */
 
-       assert( Client != NULL );
-       assert( Req != NULL );
+       assert(Client != NULL);
+       assert(Req != NULL);
 
        /* Not a local IRC operator? */
-       if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
+       if ((!Client_HasMode(Client, 'o')) || (!Client_OperByMe(Client)))
+               return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
+                                         Client_ID(Client));
 
        /* Bad number of parameters? */
-       if(( Req->argc != 2 ) && ( Req->argc != 5 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+       if ((Req->argc != 2) && (Req->argc != 5))
+               return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+                                         Client_ID(Client), Req->command);
 
        /* Invalid port number? */
-       if( atoi( Req->argv[1] ) < 1 )  return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
+       if (atoi(Req->argv[1]) < 1)
+               return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+                                         Client_ID(Client), Req->command);
 
-       Log( LOG_NOTICE|LOG_snotice, "Got CONNECT command from \"%s\" for \"%s\".", Client_Mask( Client ), Req->argv[0]);
+       Log(LOG_NOTICE | LOG_snotice,
+           "Got CONNECT command from \"%s\" for \"%s\".", Client_Mask(Client),
+           Req->argv[0]);
 
-       if( Req->argc == 2 )
-       {
+       if (Req->argc == 2) {
                /* Connect configured server */
-               if( ! Conf_EnableServer( Req->argv[0], atoi( Req->argv[1] ))) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
-       }
-       else
-       {
+               if (!Conf_EnableServer
+                   (Req->argv[0], (UINT16) atoi(Req->argv[1])))
+                       return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
+                                                 Client_ID(Client),
+                                                 Req->argv[0]);
+       } else {
                /* Add server */
-               if( ! Conf_AddServer( Req->argv[0], atoi( Req->argv[1] ), Req->argv[2], Req->argv[3], Req->argv[4] )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
+               if (!Conf_AddServer
+                   (Req->argv[0], (UINT16) atoi(Req->argv[1]), Req->argv[2],
+                    Req->argv[3], Req->argv[4]))
+                       return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
+                                                 Client_ID(Client),
+                                                 Req->argv[0]);
        }
+
        return CONNECTED;
 } /* IRC_CONNECT */
 
@@ -207,7 +225,7 @@ IRC_DISCONNECT(CLIENT *Client, REQUEST *Req )
        if( ! Conf_DisableServer( Req->argv[0] )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
 
        /* Are we still connected or were we killed, too? */
-       if( Client_GetFromConn( my_conn )) return CONNECTED;
+       if( Conn_GetClient( my_conn )) return CONNECTED;
        else return DISCONNECTED;
 } /* IRC_CONNECT */