/[cvs]/eggdrop1.9/src/irccmp.c
ViewVC logotype

Contents of /eggdrop1.9/src/irccmp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Fri Oct 12 17:40:46 2001 UTC (18 years ago) by tothwolf
Branch: MAIN
Changes since 1.2: +3 -1 lines
File MIME type: text/x-chdr
* splitnicks() removed
* check_queues() removed
* parse_q() removed
* purge_kicks() removed

1 /*
2 * irccmp.c
3 * heavily based on code from src/match.c in ircd-hybrid
4 *
5 * $Id: irccmp.c,v 1.2 2001/10/12 15:50:26 tothwolf Exp $
6 */
7 /*
8 * Copyright (C) 1990 Jarkko Oikarinen
9 * Copyright (C) 1999, 2000, 2001 Eggheads Development Team
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25 /*
26 * This code was more or less cloned from the ircd-hybrid 5.3 source.
27 * The original code was written by Otto Harkoonen and even though it
28 * it not entirely in synch with section 2.2 of RFC1459 in that it
29 * additionally defines carat as an uppercase version of tilde, it's
30 * what is in the servers themselves so we're going with it this way.
31 *
32 * If for some reason someone who maintains the source for ircd decides
33 * to change the code to be completely RFC compliant, the change here
34 * would be absolutely miniscule.
35 *
36 * BTW, since carat characters are allowed in nicknames and tildes are
37 * not, I stronly suggest that people convert to uppercase when doing
38 * comparisons or creation of hash elements (which tcl laughably calls
39 * arrays) to avoid making entries with impossible nicknames in them.
40 *
41 * --+ Dagmar
42 */
43
44 /* prototypes */
45 #include "irccmp.h"
46
47 #include "debug.h" /* assert */
48
49
50 /*
51 * irccmp - case insensitive comparison of two 0 terminated strings.
52 *
53 * returns 0, if s1 equal to s2
54 * <0, if s1 lexicographically less than s2
55 * >0, if s1 lexicographically greater than s2
56 */
57 int _irccmp(const char *s1, const char *s2)
58 {
59 const unsigned char* str1 = (const unsigned char*) s1;
60 const unsigned char* str2 = (const unsigned char*) s2;
61 int res;
62 assert(0 != s1);
63 assert(0 != s2);
64
65 while ((res = ToUpper(*str1) - ToUpper(*str2)) == 0) {
66 if (*str1 == '\0')
67 return 0;
68 str1++;
69 str2++;
70 }
71 return (res);
72 }
73
74 int _ircncmp(const char* s1, const char *s2, int n)
75 {
76 const unsigned char* str1 = (const unsigned char*) s1;
77 const unsigned char* str2 = (const unsigned char*) s2;
78 int res;
79 assert(0 != s1);
80 assert(0 != s2);
81
82 while ((res = ToUpper(*str1) - ToUpper(*str2)) == 0) {
83 str1++;
84 str2++;
85 n--;
86 if (n == 0 || (*str1 == '\0' && *str2 == '\0'))
87 return 0;
88 }
89 return (res);
90 }
91
92 int _irctolower(int c)
93 {
94 return ToLower(c);
95 }
96
97 int _irctoupper(int c)
98 {
99 return ToUpper(c);
100 }
101
102 const unsigned char ToLowerTab[] = {
103 0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa,
104 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14,
105 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
106 0x1e, 0x1f,
107 ' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')',
108 '*', '+', ',', '-', '.', '/',
109 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
110 ':', ';', '<', '=', '>', '?',
111 '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
112 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
113 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
114 '_',
115 '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
116 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
117 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
118 0x7f,
119 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
120 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
121 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
122 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
123 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
124 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
125 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9,
126 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
127 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
128 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
129 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
130 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
131 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
132 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
133 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
134 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
135 };
136
137 const unsigned char ToUpperTab[] = {
138 0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa,
139 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14,
140 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
141 0x1e, 0x1f,
142 ' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')',
143 '*', '+', ',', '-', '.', '/',
144 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
145 ':', ';', '<', '=', '>', '?',
146 '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
147 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
148 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^',
149 0x5f,
150 '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
151 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
152 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^',
153 0x7f,
154 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
155 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
156 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
157 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
158 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
159 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
160 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9,
161 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
162 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
163 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
164 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
165 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
166 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
167 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
168 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
169 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
170 };

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23