repo: ngircd action: commit revision: path_from: revision_from: e03d8eb7284147f7d44ff192cec18ad9716fedff: path_to: revision_to:
commit e03d8eb7284147f7d44ff192cec18ad9716fedff Author: Federico G. SchwindtDate: Sun Aug 4 03:20:13 2013 +0100 Add Client_HasFlag() to check if a client has certain flag diff --git a/src/ngircd/client.c b/src/ngircd/client.c
--- a/src/ngircd/client.c
+++ b/src/ngircd/client.c
@@ -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 )
{
diff --git a/src/ngircd/client.h b/src/ngircd/client.h
--- a/src/ngircd/client.h +++ b/src/ngircd/client.h @@ -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 )); diff --git a/src/ngircd/irc-metadata.c b/src/ngircd/irc-metadata.c
--- a/src/ngircd/irc-metadata.c
+++ b/src/ngircd/irc-metadata.c
@@ -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);
diff --git a/src/ngircd/irc-server.c b/src/ngircd/irc-server.c
--- a/src/ngircd/irc-server.c
+++ b/src/ngircd/irc-server.c
@@ -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;
diff --git a/src/ngircd/irc-write.c b/src/ngircd/irc-write.c
--- a/src/ngircd/irc-write.c
+++ b/src/ngircd/irc-write.c
@@ -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);
diff --git a/src/ngircd/numeric.c b/src/ngircd/numeric.c
--- a/src/ngircd/numeric.c
+++ b/src/ngircd/numeric.c
@@ -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;
-----END OF PAGE-----