/[cvs]/eggdrop1.4/src/rfc1459.c
ViewVC logotype

Annotation of /eggdrop1.4/src/rfc1459.c

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


Revision 1.2 - (hide annotations) (download) (as text)
Thu Oct 7 23:12:02 1999 UTC (19 years, 10 months ago) by guppy
Branch: MAIN
Changes since 1.1: +16 -17 lines
File MIME type: text/x-chdr
more patches for today

1 segfault 1.1 /*
2     * ===================================================================
3     * This code was more or less cloned from the ircd-hybrid 5.3 source.
4     * The original code was written by Otto Harkoonen and even though it
5     * it not entirely in synch with section 2.2 of RFC1459 in that it
6     * additionally defines carat as an uppercase version of tilde, it's
7     * what is in the servers themselves so we're going with it this way.
8     *
9     * If for some reason someone who maintains the source for ircd decides
10     * to change the code to be completely RFC compliant, the change here
11     * would be absolutely miniscule.
12     *
13     * BTW, since carat characters are allowed in nicknames and tildes are
14     * not, I stronly suggest that people convert to uppercase when doing
15     * comparisons or creation of hash elements (which tcl laughably calls
16     * arrays) to avoid making entries with impossible nicknames in them.
17     *
18     * --+ Dagmar
19     * ===================================================================
20     */
21    
22 guppy 1.2 #include "main.h"
23 segfault 1.1
24 guppy 1.2 int _rfc_casecmp(const char *s1, const char *s2)
25 segfault 1.1 {
26     register unsigned char *str1 = (unsigned char *) s1;
27     register unsigned char *str2 = (unsigned char *) s2;
28     register int res;
29    
30     while ((res = rfc_toupper(*str1) - rfc_toupper(*str2)) == 0) {
31     if (*str1 == '\0')
32     return 0;
33     str1++;
34     str2++;
35     }
36     return (res);
37     }
38    
39 guppy 1.2 int _rfc_ncasecmp(const char *str1, const char *str2, int n)
40 segfault 1.1 {
41     register unsigned char *s1 = (unsigned char *) str1;
42     register unsigned char *s2 = (unsigned char *) str2;
43     register int res;
44    
45     while ((res = rfc_toupper(*s1) - rfc_toupper(*s2)) == 0) {
46     s1++;
47     s2++;
48     n--;
49     if (n == 0 || (*s1 == '\0' && *s2 == '\0'))
50     return 0;
51     }
52     return (res);
53     }
54    
55 guppy 1.2 unsigned char rfc_tolowertab[];
56     unsigned char rfc_touppertab[];
57    
58     int _rfc_tolower(int c)
59     {
60     return rfc_tolowertab[(unsigned char)(c)];
61     }
62    
63     int _rfc_toupper(int c)
64     {
65     return rfc_touppertab[(unsigned char)(c)];
66     }
67    
68 segfault 1.1 unsigned char rfc_tolowertab[] =
69     {0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa,
70     0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14,
71     0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d,
72     0x1e, 0x1f,
73     ' ', '!', '"', '#', '$', '%', '&', 0x27, '(', ')',
74     '*', '+', ',', '-', '.', '/',
75     '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
76     ':', ';', '<', '=', '>', '?',
77     '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
78     'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
79     't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
80     '_',
81     '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
82     'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
83     't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~',
84     0x7f,
85     0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
86     0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
87     0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
88     0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
89     0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9,
90     0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
91     0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9,
92     0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
93     0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
94     0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
95     0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9,
96     0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
97     0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9,
98     0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
99     0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9,
100     0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff};
101    
102     unsigned char rfc_touppertab[] =
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     0x5f,
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    

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23