00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 #ifndef INCLUDED_ircd_chattr_h
00024 #define INCLUDED_ircd_chattr_h
00025 
00026 #ifndef USE_PCH
00027 #include <limits>
00028 #endif
00029 
00030 
00031 
00032 
00033 typedef unsigned int ntl_type;
00034 ntl_type const NTL_ALNUM  =  0x0001;  
00035 ntl_type const NTL_ALPHA  =  0x0002;  
00036 ntl_type const NTL_CNTRL  =  0x0004;  
00037 ntl_type const NTL_DIGIT  =  0x0008;  
00038 ntl_type const NTL_GRAPH  =  0x0010;  
00039 ntl_type const NTL_LOWER  =  0x0020;  
00040 ntl_type const NTL_PRINT  =  0x0040;  
00041 ntl_type const NTL_PUNCT  =  0x0080;  
00042 ntl_type const NTL_SPACE  =  0x0100;  
00043 ntl_type const NTL_UPPER  =  0x0200;  
00044 ntl_type const NTL_IRCCH  =  0x0400;  
00045 ntl_type const NTL_IRCCL  =  0x0800;  
00046 ntl_type const NTL_IRCNK  =  0x1000;  
00047 ntl_type const NTL_IRCUI  =  0x2000;  
00048 ntl_type const NTL_IRCHN  =  0x4000;  
00049 ntl_type const NTL_IRCIP  =  0x8000;  
00050 ntl_type const NTL_EOL    = 0x10000;  
00051 ntl_type const NTL_KTIME  = 0x20000;  
00052 ntl_type const NTL_CHPFX  = 0x40000;  
00053 ntl_type const NTL_IRCIP6 = 0x80000;  
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 extern char const ToLowerTab_8859_1[];
00062 
00063 
00064 extern char const ToUpperTab_8859_1[];
00065 
00066 extern ntl_type const IRCD_CharAttrTab[];
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 inline char ToLower(char c) __attribute__((const));
00075 inline char ToUpper(char c) __attribute__((const));
00076 inline bool IsAlnum(char c) __attribute__((const));
00077 inline bool IsAlpha(char c) __attribute__((const));
00078 inline bool IsDigit(char c) __attribute__((const));
00079 inline bool IsLower(char c) __attribute__((const));
00080 inline bool IsSpace(char c) __attribute__((const));
00081 inline bool IsUpper(char c) __attribute__((const));
00082 inline bool IsCntrl(char c) __attribute__((const));
00083 inline bool IsChannelChar(char c) __attribute__((const));
00084 inline bool IsChannelLower(char c) __attribute__((const));
00085 inline bool IsChannelPrefix(char c) __attribute__((const));
00086 inline bool IsNickChar(char c) __attribute__((const));
00087 inline bool IsUserChar(char c) __attribute__((const));
00088 inline bool IsHostChar(char c) __attribute__((const));
00089 inline bool IsIPChar(char c) __attribute__((const));
00090 inline bool IsIP6Char(char c) __attribute__((const));
00091 inline bool IsEol(char c) __attribute__((const));
00092 inline bool IsKTimeChar(char c) __attribute__((const));
00093 
00094 
00095 inline char ToLower(char c)
00096 {
00097   return ToLowerTab_8859_1[c - std::numeric_limits<char>::min()];
00098 }
00099 
00100 
00101 inline char ToUpper(char c)
00102 {
00103   return ToUpperTab_8859_1[c - std::numeric_limits<char>::min()];
00104 }
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 inline bool IsAlnum(char c)
00115 {
00116   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_ALNUM;
00117 }
00118 
00119 
00120 inline bool IsAlpha(char c)
00121 {
00122   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_ALPHA;
00123 }
00124 
00125 
00126 inline bool IsDigit(char c)
00127 {
00128   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_DIGIT;
00129 }
00130 
00131 
00132 inline bool IsLower(char c)
00133 {
00134   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_LOWER;
00135 }
00136 
00137 
00138 inline bool IsSpace(char c)
00139 {
00140   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_SPACE;
00141 }
00142 
00143 
00144 inline bool IsUpper(char c)
00145 {
00146   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_UPPER;
00147 }
00148 
00149 
00150 inline bool IsCntrl(char c)
00151 {
00152   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_CNTRL;
00153 }
00154 
00155 
00156 inline bool IsChannelChar(char c)
00157 {
00158   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_IRCCH;
00159 }
00160 
00161 
00162 inline bool IsChannelLower(char c)
00163 {
00164   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_IRCCL;
00165 }
00166 
00167 
00168 inline bool IsChannelPrefix(char c)
00169 {
00170   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_CHPFX;
00171 }
00172 
00173 
00174 inline bool IsNickChar(char c)
00175 {
00176   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_IRCNK;
00177 }
00178 
00179 
00180 inline bool IsUserChar(char c)
00181 {
00182   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_IRCUI;
00183 }
00184 
00185 
00186 inline bool IsHostChar(char c)
00187 {
00188   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_IRCHN;
00189 }
00190 
00191 
00192 inline bool IsIPChar(char c)
00193 {
00194   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_IRCIP;
00195 }
00196 
00197 
00198 inline bool IsIP6Char(char c)
00199 {
00200   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_IRCIP6;
00201 }
00202 
00203 
00204 inline bool IsEol(char c)
00205 {
00206   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_EOL;
00207 }
00208 
00209 
00210 inline bool IsKTimeChar(char c)
00211 {
00212   return IRCD_CharAttrTab[c - std::numeric_limits<char>::min()] & NTL_KTIME;
00213 }
00214 
00215 #endif 
00216