]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc.c
Correct numeric returned by whois
[ngircd-alex.git] / src / ngircd / irc.c
index ddef7d021ac3d8b03891062933408df4b0f2cae0..968bcea6e58998a7d4d56096f727fa887bc7b37a 100644 (file)
@@ -135,7 +135,7 @@ IRC_KILL(CLIENT *Client, REQUEST *Req)
        assert (Req != NULL);
 
        if (Client_Type(Client) != CLIENT_SERVER && !Client_OperByMe(Client))
-               return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
+               return IRC_WriteErrClient(Client, ERR_NOPRIVILEGES_MSG,
                                          Client_ID(Client));
 
        _IRC_ARGC_EQ_OR_RETURN_(Client, Req, 2)
@@ -192,7 +192,7 @@ IRC_KILL(CLIENT *Client, REQUEST *Req)
                                        msg = ERR_CANTKILLSERVER_MSG;
                                else
                                        msg = ERR_NOPRIVILEGES_MSG;
-                               return IRC_WriteStrClient(Client, msg,
+                               return IRC_WriteErrClient(Client, msg,
                                                          Client_ID(Client));
                        }
 
@@ -282,7 +282,7 @@ IRC_TRACE(CLIENT *Client, REQUEST *Req)
 
        /* Bad number of arguments? */
        if (Req->argc > 1)
-               return IRC_WriteStrClient(Client, ERR_NORECIPIENT_MSG,
+               return IRC_WriteErrClient(Client, ERR_NORECIPIENT_MSG,
                                          Client_ID(Client), Req->command);
 
        _IRC_GET_SENDER_OR_RETURN_(from, Req, Client)
@@ -329,7 +329,7 @@ IRC_TRACE(CLIENT *Client, REQUEST *Req)
                                        return DISCONNECTED;
                        }
                        if (Client_Type(c) == CLIENT_USER
-                           && strchr(Client_Modes(c), 'o')) {
+                           && Client_HasMode(c, 'o')) {
                                /* IRC Operator */
                                if (!IRC_WriteStrClient(from,
                                                RPL_TRACEOPERATOR_MSG,
@@ -450,6 +450,12 @@ Help(CLIENT *Client, const char *Topic)
        return CONNECTED;
 }
 
+/**
+ * Get pointer to a static string representing the connection "options".
+ *
+ * @param Idx Connection index.
+ * @return Pointer to static (global) string buffer.
+ */
 static char *
 #ifdef ZLIB
 Option_String(CONN_ID Idx)
@@ -460,16 +466,22 @@ Option_String(UNUSED CONN_ID Idx)
        static char option_txt[8];
 #ifdef ZLIB
        UINT16 options;
-
-       options = Conn_Options(Idx);
 #endif
 
+       assert(Idx != NONE);
+
+       options = Conn_Options(Idx);
        strcpy(option_txt, "F");        /* No idea what this means, but the
                                         * original ircd sends it ... */
+#ifdef SSL_SUPPORT
+       if(options & CONN_SSL)          /* SSL encrypted link */
+               strlcat(option_txt, "s", sizeof(option_txt));
+#endif
 #ifdef ZLIB
-       if(options & CONN_ZIP)          /* zlib compression supported. */
-               strcat(option_txt, "z");
+       if(options & CONN_ZIP)          /* zlib compression enabled */
+               strlcat(option_txt, "z", sizeof(option_txt));
 #endif
+       LogDebug(" *** %d: %d = %s", Idx, options, option_txt);
 
        return option_txt;
 } /* Option_String */
@@ -490,19 +502,19 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
        if (Req->argc == 0) {
                if (!SendErrors)
                        return CONNECTED;
-               return IRC_WriteStrClient(Client, ERR_NORECIPIENT_MSG,
+               return IRC_WriteErrClient(Client, ERR_NORECIPIENT_MSG,
                                          Client_ID(Client), Req->command);
        }
        if (Req->argc == 1) {
                if (!SendErrors)
                        return CONNECTED;
-               return IRC_WriteStrClient(Client, ERR_NOTEXTTOSEND_MSG,
+               return IRC_WriteErrClient(Client, ERR_NOTEXTTOSEND_MSG,
                                          Client_ID(Client));
        }
        if (Req->argc > 2) {
                if (!SendErrors)
                        return CONNECTED;
-               return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
+               return IRC_WriteErrClient(Client, ERR_NEEDMOREPARAMS_MSG,
                                          Client_ID(Client), Req->command);
        }
 
@@ -511,7 +523,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
        else
                from = Client;
        if (!from)
-               return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
+               return IRC_WriteErrClient(Client, ERR_NOSUCHNICK_MSG,
                                          Client_ID(Client), Req->prefix);
 
 #ifdef ICONV
@@ -606,7 +618,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
 #else
                        if (Client_Type(cl) != ForceType) {
 #endif
-                               if (SendErrors && !IRC_WriteStrClient(
+                               if (SendErrors && !IRC_WriteErrClient(
                                    from, ERR_NOSUCHNICK_MSG,Client_ID(from),
                                    currentTarget))
                                        return DISCONNECTED;
@@ -627,7 +639,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
                            !Client_HasMode(from, 'o') &&
                            !(Client_Type(from) == CLIENT_SERVER) &&
                            !(Client_Type(from) == CLIENT_SERVICE)) {
-                               if (SendErrors && !IRC_WriteStrClient(from,
+                               if (SendErrors && !IRC_WriteErrClient(from,
                                                ERR_NONONREG_MSG,
                                                Client_ID(from), Client_ID(cl)))
                                        return DISCONNECTED;
@@ -643,7 +655,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
                                        cl2chan = Channel_NextChannelOf(cl, cl2chan);
                                }
                                if (!cl2chan) {
-                                       if (SendErrors && !IRC_WriteStrClient(
+                                       if (SendErrors && !IRC_WriteErrClient(
                                            from, ERR_NOTONSAMECHANNEL_MSG,
                                            Client_ID(from), Client_ID(cl)))
                                                return DISCONNECTED;
@@ -652,7 +664,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
                        }
 
                        if (SendErrors && (Client_Type(Client) != CLIENT_SERVER)
-                           && strchr(Client_Modes(cl), 'a')) {
+                           && Client_HasMode(cl, 'a')) {
                                /* Target is away */
                                if (!IRC_WriteStrClient(from, RPL_AWAY_MSG,
                                                        Client_ID(from),
@@ -683,7 +695,7 @@ Send_Message(CLIENT * Client, REQUEST * Req, int ForceType, bool SendErrors)
                } else {
                        if (!SendErrors)
                                return CONNECTED;
-                       if (!IRC_WriteStrClient(from, ERR_NOSUCHNICK_MSG,
+                       if (!IRC_WriteErrClient(from, ERR_NOSUCHNICK_MSG,
                                                Client_ID(from), currentTarget))
                                return DISCONNECTED;
                }
@@ -708,10 +720,10 @@ Send_Message_Mask(CLIENT * from, char * command, char * targetMask,
 
        cl = NULL;
 
-       if (strchr(Client_Modes(from), 'o') == NULL) {
+       if (!Client_HasMode(from, 'o')) {
                if (!SendErrors)
                        return true;
-               return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG,
+               return IRC_WriteErrClient(from, ERR_NOPRIVILEGES_MSG,
                                          Client_ID(from));
        }
 
@@ -726,7 +738,7 @@ Send_Message_Mask(CLIENT * from, char * command, char * targetMask,
        {
                if (!SendErrors)
                        return true;
-               return IRC_WriteStrClient(from, ERR_WILDTOPLEVEL, targetMask);
+               return IRC_WriteErrClient(from, ERR_WILDTOPLEVEL, targetMask);
        }
 
        /* #: hostmask, see RFC 2812, sec. 3.3.1 */