X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/55abcbb20aeabcf2e878a9c65c9697210dd10079..dd3355732b392f8be9f326feb1849b2f46c9a1fc:/include/match.h diff --git a/include/match.h b/include/match.h index 9b6fb882..7840c291 100644 --- a/include/match.h +++ b/include/match.h @@ -1,6 +1,6 @@ /* * ircd-ratbox: A slightly useful ircd. - * irc_string.h: A header for the ircd string functions. + * match.h: A header for the ircd string functions. * * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center * Copyright (C) 1996-2002 Hybrid Development Team @@ -20,8 +20,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA - * - * $Id: irc_string.h 3538 2007-07-26 14:21:57Z jilles $ */ #ifndef INCLUDED_match_h @@ -48,8 +46,8 @@ extern int match_ips(const char *mask, const char *name); /* * comp_with_mask - compares to IP address */ -int comp_with_mask(void *addr, void *dest, u_int mask); -int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, u_int mask); +int comp_with_mask(void *addr, void *dest, unsigned int mask); +int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, unsigned int mask); /* * collapse - collapse a string in place, converts multiple adjacent *'s @@ -61,6 +59,17 @@ int comp_with_mask_sock(struct sockaddr *addr, struct sockaddr *dest, u_int mask extern char *collapse(char *pattern); extern char *collapse_esc(char *pattern); +struct matchset { + char host[2][NAMELEN + USERLEN + HOSTLEN + 6]; + char ip[2][NAMELEN + USERLEN + HOSTIPLEN + 6]; +}; + +struct Client; + +void matchset_for_client(struct Client *who, struct matchset *m); +bool client_matches_mask(struct Client *who, const char *mask); +bool matches_mask(const struct matchset *m, const char *mask); + /* * irccmp - case insensitive comparison of s1 and s2 */ @@ -83,13 +92,13 @@ extern char *canonize(char *); /* * character macros */ -extern const unsigned char ToLowerTab[]; -#define ToLower(c) (ToLowerTab[(unsigned char)(c)]) +extern const unsigned char irctolower_tab[]; +#define irctolower(c) (irctolower_tab[(unsigned char)(c)]) -extern const unsigned char ToUpperTab[]; -#define ToUpper(c) (ToUpperTab[(unsigned char)(c)]) +extern const unsigned char irctoupper_tab[]; +#define irctoupper(c) (irctoupper_tab[(unsigned char)(c)]) -extern const unsigned int CharAttrs[]; +extern unsigned int CharAttrs[]; #define PRINT_C 0x001 #define CNTRL_C 0x002 @@ -139,4 +148,26 @@ extern const unsigned int CharAttrs[]; #define IsNonEOS(c) (CharAttrs[(unsigned char)(c)] & NONEOS_C) #define IsEol(c) (CharAttrs[(unsigned char)(c)] & EOL_C) + +/* Below are used for radix trees and the like */ +static inline void irccasecanon(char *str) +{ + while (*str) + { + *str = irctoupper(*str); + str++; + } + return; +} + +static inline void strcasecanon(char *str) +{ + while (*str) + { + *str = toupper((unsigned char)*str); + str++; + } + return; +} + #endif /* INCLUDED_match_h */