mirror of
				https://github.com/osmarks/ngircd.git
				synced 2025-10-31 05:52:59 +00:00 
			
		
		
		
	Add Client_HasFlag() to check if a client has certain flag
This commit is contained in:
		| @@ -950,6 +950,14 @@ Client_HasMode( CLIENT *Client, char Mode ) | |||||||
| } /* Client_HasMode */ | } /* Client_HasMode */ | ||||||
|  |  | ||||||
|  |  | ||||||
|  | GLOBAL bool | ||||||
|  | Client_HasFlag( CLIENT *Client, char Flag ) | ||||||
|  | { | ||||||
|  | 	assert( Client != NULL ); | ||||||
|  | 	return strchr( Client->flags, Flag ) != NULL; | ||||||
|  | } /* Client_HasFlag */ | ||||||
|  |  | ||||||
|  |  | ||||||
| GLOBAL char * | GLOBAL char * | ||||||
| Client_Away( CLIENT *Client ) | Client_Away( CLIENT *Client ) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -126,6 +126,7 @@ GLOBAL char *Client_Away PARAMS(( CLIENT *Client )); | |||||||
| GLOBAL time_t Client_StartTime PARAMS(( CLIENT *Client )); | GLOBAL time_t Client_StartTime PARAMS(( CLIENT *Client )); | ||||||
|  |  | ||||||
| GLOBAL bool Client_HasMode PARAMS(( CLIENT *Client, char Mode )); | 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_SetHostname PARAMS(( CLIENT *Client, const char *Hostname )); | ||||||
| GLOBAL void Client_SetID PARAMS(( CLIENT *Client, const char *Nick )); | GLOBAL void Client_SetID PARAMS(( CLIENT *Client, const char *Nick )); | ||||||
|   | |||||||
| @@ -70,7 +70,7 @@ IRC_METADATA(CLIENT *Client, REQUEST *Req) | |||||||
| 		 Req->argv[1], Req->argv[2]); | 		 Req->argv[1], Req->argv[2]); | ||||||
|  |  | ||||||
| 	/* Mark client: it has receiveda a METADATA command */ | 	/* 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", | 		snprintf(new_flags, sizeof new_flags, "%sM", | ||||||
| 			 Client_Flags(target)); | 			 Client_Flags(target)); | ||||||
| 		Client_SetFlags(target, new_flags); | 		Client_SetFlags(target, new_flags); | ||||||
|   | |||||||
| @@ -152,7 +152,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) | |||||||
| 		Client_SetType(Client, CLIENT_UNKNOWNSERVER); | 		Client_SetType(Client, CLIENT_UNKNOWNSERVER); | ||||||
|  |  | ||||||
| #ifdef ZLIB | #ifdef ZLIB | ||||||
| 		if (strchr(Client_Flags(Client), 'Z') | 		if (Client_HasFlag(Client, 'Z') | ||||||
| 		    && !Zip_InitConn(Client_Conn(Client))) { | 		    && !Zip_InitConn(Client_Conn(Client))) { | ||||||
| 			Conn_Close(Client_Conn(Client), | 			Conn_Close(Client_Conn(Client), | ||||||
| 				   "Can't initialize compression (zlib)!", | 				   "Can't initialize compression (zlib)!", | ||||||
| @@ -162,7 +162,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req ) | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef IRCPLUS | #ifdef IRCPLUS | ||||||
| 		if (strchr(Client_Flags(Client), 'H')) { | 		if (Client_HasFlag(Client, 'H')) { | ||||||
| 			LogDebug("Peer supports IRC+ extended server handshake ..."); | 			LogDebug("Peer supports IRC+ extended server handshake ..."); | ||||||
| 			if (!IRC_Send_ISUPPORT(Client)) | 			if (!IRC_Send_ISUPPORT(Client)) | ||||||
| 				return DISCONNECTED; | 				return DISCONNECTED; | ||||||
|   | |||||||
| @@ -311,7 +311,7 @@ IRC_WriteStrServersPrefixFlag_CB(CLIENT *ExceptOf, CLIENT *Prefix, char Flag, | |||||||
| 		if (Client_Type(c) == CLIENT_SERVER && Client_Conn(c) > NONE && | 		if (Client_Type(c) == CLIENT_SERVER && Client_Conn(c) > NONE && | ||||||
| 		    c != Client_ThisServer() && c != ExceptOf) { | 		    c != Client_ThisServer() && c != ExceptOf) { | ||||||
| 			/* Found a target server, do the flags match? */ | 			/* 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); | 				callback(c, Prefix, cb_data); | ||||||
| 		} | 		} | ||||||
| 		c = Client_Next(c); | 		c = Client_Next(c); | ||||||
|   | |||||||
| @@ -52,7 +52,7 @@ Announce_Channel(CLIENT *Client, CHANNEL *Chan) | |||||||
|  |  | ||||||
| 	/* Check features of remote server */ | 	/* Check features of remote server */ | ||||||
| 	njoin = Conn_Options(Client_Conn(Client)) & CONN_RFC1459 ? false : true; | 	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 */ | 	/* Get all the members of this channel */ | ||||||
| 	cl2chan = Channel_FirstMember(Chan); | 	cl2chan = Channel_FirstMember(Chan); | ||||||
| @@ -321,7 +321,7 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req) | |||||||
| 		} | 		} | ||||||
| #ifdef IRCPLUS | #ifdef IRCPLUS | ||||||
| 		/* Send CHANINFO if the peer supports it */ | 		/* Send CHANINFO if the peer supports it */ | ||||||
| 		if (strchr(Client_Flags(Client), 'C')) { | 		if (Client_HasFlag(Client, 'C')) { | ||||||
| 			if (!Send_CHANINFO(Client, chan)) | 			if (!Send_CHANINFO(Client, chan)) | ||||||
| 				return DISCONNECTED; | 				return DISCONNECTED; | ||||||
| 		} | 		} | ||||||
| @@ -335,7 +335,7 @@ IRC_Num_ENDOFMOTD(CLIENT * Client, UNUSED REQUEST * Req) | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| #ifdef IRCPLUS | #ifdef IRCPLUS | ||||||
| 	if (strchr(Client_Flags(Client), 'L')) { | 	if (Client_HasFlag(Client, 'L')) { | ||||||
| 		LogDebug("Synchronizing INVITE- and BAN-lists ..."); | 		LogDebug("Synchronizing INVITE- and BAN-lists ..."); | ||||||
| 		if (!Synchronize_Lists(Client)) | 		if (!Synchronize_Lists(Client)) | ||||||
| 			return DISCONNECTED; | 			return DISCONNECTED; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Federico G. Schwindt
					Federico G. Schwindt