The InspIRCd Project
Home | Developers | Wiki | Forums | Bug Tracker | SVN | Download | Blog | Stats
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

wildcard.h File Reference

#include "inspircd_config.h"

Include dependency graph for wildcard.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

CoreExport bool match (const char *str, const char *mask)
 Match a string against a mask.
CoreExport bool match (const char *str, const char *mask, bool use_cidr_match)
 Match a string against a mask, and define wether or not to use CIDR rules.
CoreExport bool match (bool case_sensitive, const char *str, const char *mask)
 Match a string against a mask, defining wether case sensitivity applies.
CoreExport bool match (bool case_sensitive, const char *str, const char *mask, bool use_cidr_match)
 Match a string against a mask, defining wether case sensitivity applies, and defining wether or not to use CIDR rules first.


Function Documentation

CoreExport bool match bool  case_sensitive,
const char *  str,
const char *  mask,
bool  use_cidr_match
 

Match a string against a mask, defining wether case sensitivity applies, and defining wether or not to use CIDR rules first.

Parameters:
case_sensitive True if the match is case sensitive
str The string to check
mask the mask to check against
use_cidr_match True if CIDR matching rules should be applied first
Returns:
true if the strings match

Definition at line 137 of file wildcard.cpp.

References csmatch(), match(), and irc::sockets::MatchCIDR().

00138 {
00139         if (use_cidr_match && MatchCIDR(str, mask, true))
00140                 return true;
00141 
00142         return case_sensitive ? csmatch(str, mask) : match(str, mask);
00143 }

CoreExport bool match bool  case_sensitive,
const char *  str,
const char *  mask
 

Match a string against a mask, defining wether case sensitivity applies.

Parameters:
str The string to check
mask the mask to check against
case_sensitive True if the match is case sensitive
Returns:
True if the strings match

Definition at line 145 of file wildcard.cpp.

References csmatch(), and match().

00146 {
00147         return case_sensitive ? csmatch(str, mask) : match(str, mask);
00148 }

CoreExport bool match const char *  str,
const char *  mask,
bool  use_cidr_match
 

Match a string against a mask, and define wether or not to use CIDR rules.

Parameters:
str The string to check
mask the mask to check against
use_cidr_match True if CIDR matching rules should be applied first
Returns:
true if the strings match

Definition at line 130 of file wildcard.cpp.

References match(), and irc::sockets::MatchCIDR().

00131 {
00132         if (use_cidr_match && MatchCIDR(str, mask, true))
00133                 return true;
00134         return match(str, mask);
00135 }

CoreExport bool match const char *  str,
const char *  mask
 

Match a string against a mask.

Parameters:
str The string to check
mask the mask to check against
Returns:
true if the strings match

Definition at line 80 of file wildcard.cpp.

References lowermap.

00081 {
00082         unsigned char *cp = NULL, *mp = NULL;
00083         unsigned char* string = (unsigned char*)str;
00084         unsigned char* wild = (unsigned char*)mask;
00085 
00086         while ((*string) && (*wild != '*'))
00087         {
00088                 if ((lowermap[*wild] != lowermap[*string]) && (*wild != '?'))
00089                 {
00090                         return 0;
00091                 }
00092                 wild++;
00093                 string++;
00094         }
00095 
00096         while (*string)
00097         {
00098                 if (*wild == '*')
00099                 {
00100                         if (!*++wild)
00101                         {
00102                                 return 1;
00103                         }
00104                         mp = wild;
00105                         cp = string+1;
00106                 }
00107                 else
00108                 if ((lowermap[*wild] == lowermap[*string]) || (*wild == '?'))
00109                 {
00110                         wild++;
00111                         string++;
00112                 }
00113                 else
00114                 {
00115                         wild = mp;
00116                         string = cp++;
00117                 }
00118 
00119         }
00120 
00121         while (*wild == '*')
00122         {
00123                 wild++;
00124         }
00125 
00126         return !*wild;
00127 }