]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Add Client_HasFlag() to check if a client has certain flag
authorFederico G. Schwindt <fgsch@lodoss.net>
Sun, 4 Aug 2013 02:20:13 +0000 (03:20 +0100)
committerFederico G. Schwindt <fgsch@lodoss.net>
Sun, 4 Aug 2013 03:00:34 +0000 (04:00 +0100)
src/ngircd/client.c
src/ngircd/client.h
src/ngircd/irc-metadata.c
src/ngircd/irc-server.c
src/ngircd/irc-write.c
src/ngircd/numeric.c

index 9358dbb5fb281db125dd448c8e50c4098b6e34b5..7821d3bd6b7ae29d679bedbeb97dfb96285c3978 100644 (file)
@@ -950,6 +950,14 @@ Client_HasMode( CLIENT *Client, char Mode )
 } /* Client_HasMode */
 
 
+GLOBAL bool
+Client_HasFlag( CLIENT *Client, char Flag )
+{
+       assert( Client != NULL );
+       return strchr( Client->flags, Flag ) != NULL;
+} /* Client_HasFlag */
+
+
 GLOBAL char *
 Client_Away( CLIENT *Client )
 {
index 68d411c04f0a1625b9cb714e7d5c6cba5b74dae7..94ca4dc5fdbf1018ebb3a95563524f60cf582334 100644 (file)
@@ -126,6 +126,7 @@ GLOBAL char *Client_Away PARAMS(( CLIENT *Client ));
 GLOBAL time_t Client_StartTime PARAMS(( CLIENT *Client ));
 
 GLOBAL bool Client_HasMode PARAMS(( CLIENT *Client, char Mode ));
+GLOBAL bool Client_HasFlag PARAMS(( CLIENT *Client, char Flag ));
 
 GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, const char *Hostname ));
 GLOBAL void Client_SetID PARAMS(( CLIENT *Client, const char *Nick ));
index d185488b500789af68a4a8253adc313a918d16f9..3c8a4a85623bc9c6ccaf53180e49a2170a38fa0f 100644 (file)
@@ -70,7 +70,7 @@ IRC_METADATA(CLIENT *Client, REQUEST *Req)
                 Req->argv[1], Req->argv[2]);
 
        /* Mark client: it has receiveda a METADATA command */
-       if (!strchr(Client_Flags(target), 'M')) {
+       if (!Client_HasFlag(target, 'M')) {
                snprintf(new_flags, sizeof new_flags, "%sM",
                         Client_Flags(target));
                Client_SetFlags(target, new_flags);
index 8fc575f3d86597b9576fb6f2cc503b292264680a..d8e4b29ace707d26583a00e8c828c77d002887ce 100644 (file)
@@ -152,7 +152,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
                Client_SetType(Client, CLIENT_UNKNOWNSERVER);
 
 #ifdef ZLIB
-               if (strchr(Client_Flags(Client), 'Z')
+               if (Client_HasFlag(Client, 'Z')
                    && !Zip_InitConn(Client_Conn(Client))) {
                        Conn_Close(Client_Conn(Client),
                                   "Can't initialize compression (zlib)!",
@@ -162,7 +162,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
 #endif
 
 #ifdef IRCPLUS
-               if (strchr(Client_Flags(Client), 'H')) {
+               if (Client_HasFlag(Client, 'H')) {
                        LogDebug("Peer supports IRC+ extended server handshake ...");
                        if (!IRC_Send_ISUPPORT(Client))
                                return DISCONNECTED;
index 16aac9a081859aa27904e116252d009ba02d3176..fd0f85a7151f749432e98aff2271e2417f992248 100644 (file)
@@ -311,7 +311,7 @@ IRC_WriteStrServersPrefixFlag_CB(CLIENT *ExceptOf, CLIENT *Prefix, char Flag,
                if (Client_Type(c) == CLIENT_SERVER && Client_Conn(c) > NONE &&
                    c != Client_ThisServer() && c != ExceptOf) {
                        /* Found a target server, do the flags match? */
-                       if (Flag == '\0' || strchr(Client_Flags(c), Flag))
+                       if (Flag == '\0' || Client_HasFlag(c, Flag))
                                callback(c, Prefix, cb_data);
                }
                c = Client_Next(c);
index 01091edef17272a9bfaf26f67064c709fdc95486..f2c61e8a8cb46ea0b7b7649ad73b76c7f9db438a 100644 (file)
@@ -52,7 +52,7 @@ Announce_Channel(CLIENT *Client, CHANNEL *Chan)
 
        /* Check features of remote server */
        njoin = Conn_Options(Client_Conn(Client)) & CONN_RFC1459 ? false : true;
-       xop = strchr(Client_Flags(Client), 'X') ? true : false;
+       xop = Client_HasFlag(Client, 'X') ? true : false;
 
        /* Get all the members of this channel */
        cl2chan = Channel_FirstMember(Chan);
@@ -321,7 +321,7 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
                }
 #ifdef IRCPLUS
                /* Send CHANINFO if the peer supports it */
-               if (strchr(Client_Flags(Client), 'C')) {
+               if (Client_HasFlag(Client, 'C')) {
                        if (!Send_CHANINFO(Client, chan))
                                return DISCONNECTED;
                }
@@ -335,7 +335,7 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req)
        }
 
 #ifdef IRCPLUS
-       if (strchr(Client_Flags(Client), 'L')) {
+       if (Client_HasFlag(Client, 'L')) {
                LogDebug("Synchronizing INVITE- and BAN-lists ...");
                if (!Synchronize_Lists(Client))
                        return DISCONNECTED;