00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef lint
00024 static const char rcsid[] = "$Id: irccmp.c,v 1.4 2003-12-17 07:52:14 wcc Exp $";
00025 #endif
00026
00027 #include "irccmp.h"
00028
00029 static const unsigned char ToLowerTab[] = {
00030 0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa,
00031 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14,
00032 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
00033 0x1e, 0x1f,
00034 ' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')',
00035 '*', '+', ',', '-', '.', '/',
00036 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
00037 ':', ';', '<', '=', '>', '?',
00038 '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
00039 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
00040 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
00041 '_',
00042 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
00043 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
00044 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
00045 0x7f,
00046 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
00047 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
00048 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
00049 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
00050 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
00051 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
00052 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9,
00053 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
00054 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
00055 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
00056 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
00057 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
00058 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
00059 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
00060 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
00061 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
00062 };
00063
00064 static const unsigned char ToUpperTab[] = {
00065 0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa,
00066 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14,
00067 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
00068 0x1e, 0x1f,
00069 ' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')',
00070 '*', '+', ',', '-', '.', '/',
00071 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
00072 ':', ';', '<', '=', '>', '?',
00073 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
00074 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
00075 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^',
00076 0x5f,
00077 '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
00078 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
00079 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^',
00080 0x7f,
00081 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
00082 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
00083 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
00084 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
00085 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
00086 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
00087 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9,
00088 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
00089 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
00090 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
00091 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
00092 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
00093 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
00094 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
00095 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
00096 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
00097 };
00098
00099
00100
00101
00102
00103
00104
00105 int irccmp(const char *s1, const char *s2)
00106 {
00107 const unsigned char *str1 = (const unsigned char *) s1, *str2 = (const unsigned char *) s2;
00108 int res;
00109
00110 while ((res = ToUpper(*str1) - ToUpper(*str2)) == 0) {
00111 if (*str1 == '\0') return(0);
00112 str1++;
00113 str2++;
00114 }
00115 return(res);
00116 }
00117
00118
00119
00120
00121
00122
00123
00124 int ircncmp(const char* s1, const char *s2, int n)
00125 {
00126 const unsigned char *str1 = (const unsigned char *) s1, *str2 = (const unsigned char *) s2;
00127 int res;
00128
00129 while ((res = ToUpper(*str1) - ToUpper(*str2)) == 0) {
00130 str1++;
00131 str2++;
00132 n--;
00133 if (n == 0 || (*str1 == '\0' && *str2 == '\0')) return(0);
00134 }
00135 return(res);
00136 }