/[resiprocate]/main/sip/resiprocate/ParameterHash.cxx
ViewVC logotype

Contents of /main/sip/resiprocate/ParameterHash.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4599 - (show annotations) (download)
Wed May 11 23:10:19 2005 UTC (14 years, 7 months ago) by derek
File size: 10771 byte(s)
set svn:eol-style to LF
1 /* C++ code produced by gperf version 2.7.2 */
2 /* Command-line: gperf -D --enum -E -L C++ -t -k '*' --compare-strncmp -Z ParameterHash ParameterHash.gperf */
3 #include <string.h>
4 #include <ctype.h>
5 #include "resiprocate/ParameterTypes.hxx"
6 namespace resip {
7 using namespace std;
8 struct params { char *name; ParameterTypes::Type type; };
9 /* maximum key range = 380, duplicates = 1 */
10
11 class ParameterHash
12 {
13 private:
14 static inline unsigned int hash (const char *str, unsigned int len);
15 public:
16 static struct params *in_word_set (const char *str, unsigned int len);
17 };
18
19 inline unsigned int
20 ParameterHash::hash (register const char *str, register unsigned int len)
21 {
22 static unsigned short asso_values[] =
23 {
24 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
25 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
26 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
27 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
28 384, 384, 384, 15, 384, 25, 0, 384, 384, 384,
29 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
30 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
31 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
32 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
33 384, 384, 384, 384, 384, 384, 384, 0, 30, 10,
34 90, 0, 45, 105, 45, 0, 384, 5, 55, 25,
35 40, 0, 0, 5, 0, 0, 0, 40, 35, 0,
36 60, 20, 5, 384, 384, 384, 384, 384, 384, 384,
37 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
38 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
39 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
40 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
41 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
42 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
43 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
44 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
45 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
46 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
47 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
48 384, 384, 384, 384, 384, 384, 384, 384, 384, 384,
49 384, 384, 384, 384, 384, 384
50 };
51 register int hval = len;
52
53 switch (hval)
54 {
55 default:
56 case 13:
57 hval += asso_values[(unsigned char)tolower(str[12])];
58 case 12:
59 hval += asso_values[(unsigned char)tolower(str[11])];
60 case 11:
61 hval += asso_values[(unsigned char)tolower(str[10])];
62 case 10:
63 hval += asso_values[(unsigned char)tolower(str[9])];
64 case 9:
65 hval += asso_values[(unsigned char)tolower(str[8])];
66 case 8:
67 hval += asso_values[(unsigned char)tolower(str[7])];
68 case 7:
69 hval += asso_values[(unsigned char)tolower(str[6])];
70 case 6:
71 hval += asso_values[(unsigned char)tolower(str[5])];
72 case 5:
73 hval += asso_values[(unsigned char)tolower(str[4])];
74 case 4:
75 hval += asso_values[(unsigned char)tolower(str[3])];
76 case 3:
77 hval += asso_values[(unsigned char)tolower(str[2])];
78 case 2:
79 hval += asso_values[(unsigned char)tolower(str[1])];
80 case 1:
81 hval += asso_values[(unsigned char)tolower(str[0])];
82 break;
83 }
84 return hval;
85 }
86
87 struct params *
88 ParameterHash::in_word_set (register const char *str, register unsigned int len)
89 {
90 enum
91 {
92 TOTAL_KEYWORDS = 81,
93 MIN_WORD_LENGTH = 1,
94 MAX_WORD_LENGTH = 13,
95 MIN_HASH_VALUE = 4,
96 MAX_HASH_VALUE = 383
97 };
98
99 static struct params wordlist[] =
100 {
101 {"site", ParameterTypes::site},
102 {"rport", ParameterTypes::rport},
103 {"q", ParameterTypes::q},
104 {"qop", ParameterTypes::qopFactory},
105 {"size", ParameterTypes::size},
106 {"actor", ParameterTypes::actor},
107 {"type", ParameterTypes::type},
108 {"priority", ParameterTypes::priority},
109 {"comp", ParameterTypes::comp},
110 {"server", ParameterTypes::server},
111 {"uri", ParameterTypes::uri},
112 {"user", ParameterTypes::user},
113 {"reason", ParameterTypes::reason},
114 {"purpose", ParameterTypes::purpose},
115 {"response", ParameterTypes::response},
116 {"transport", ParameterTypes::transport},
117 {"opaque", ParameterTypes::opaque},
118 {"nc", ParameterTypes::nc},
119 {"lr", ParameterTypes::lr},
120 {"ttl", ParameterTypes::ttl},
121 {"stale", ParameterTypes::stale},
122 {"charset", ParameterTypes::charset},
123 {"text", ParameterTypes::text},
124 {"expires", ParameterTypes::expires},
125 {"name", ParameterTypes::name},
126 {"name", ParameterTypes::name},
127 {"protocol", ParameterTypes::protocol},
128 {"permission", ParameterTypes::permission},
129 {"access-type", ParameterTypes::accessType},
130 {"events", ParameterTypes::events},
131 {"version", ParameterTypes::version},
132 {"realm", ParameterTypes::realm},
133 {"schemes", ParameterTypes::schemes},
134 {"id", ParameterTypes::id},
135 {"data", ParameterTypes::data},
136 {"nonce", ParameterTypes::nonce},
137 {"url", ParameterTypes::url},
138 {"refresher", ParameterTypes::refresher},
139 {"retry-after", ParameterTypes::retryAfter},
140 {"isfocus", ParameterTypes::isFocus},
141 {"smime-type", ParameterTypes::smimeType},
142 {"cnonce", ParameterTypes::cnonce},
143 {"tag", ParameterTypes::tag},
144 {"expiration", ParameterTypes::expiration},
145 {"control", ParameterTypes::control},
146 {"username", ParameterTypes::username},
147 {"application", ParameterTypes::application},
148 {"+sip.instance", ParameterTypes::Instance},
149 {"mode", ParameterTypes::mode},
150 {"app-id", ParameterTypes::appId},
151 {"network-user", ParameterTypes::networkUser},
152 {"d-qop", ParameterTypes::dQop},
153 {"directory", ParameterTypes::directory},
154 {"video", ParameterTypes::video},
155 {"branch", ParameterTypes::branch},
156 {"to-tag", ParameterTypes::toTag},
157 {"mobility", ParameterTypes::mobility},
158 {"received", ParameterTypes::received},
159 {"extensions", ParameterTypes::extensions},
160 {"description", ParameterTypes::description},
161 {"d-ver", ParameterTypes::dVer},
162 {"profile-type", ParameterTypes::profileType},
163 {"domain", ParameterTypes::domain},
164 {"method", ParameterTypes::method},
165 {"methods", ParameterTypes::methods},
166 {"vendor", ParameterTypes::vendor},
167 {"filename", ParameterTypes::filename},
168 {"model", ParameterTypes::model},
169 {"duration", ParameterTypes::duration},
170 {"gruu", ParameterTypes::gruu},
171 {"micalg", ParameterTypes::micalg},
172 {"from-tag", ParameterTypes::fromTag},
173 {"maddr", ParameterTypes::maddr},
174 {"document", ParameterTypes::document},
175 {"effective-by", ParameterTypes::effectiveBy},
176 {"early-only", ParameterTypes::earlyOnly},
177 {"boundary", ParameterTypes::boundary},
178 {"algorithm", ParameterTypes::algorithm},
179 {"d-alg", ParameterTypes::dAlg},
180 {"language", ParameterTypes::language},
181 {"handling", ParameterTypes::handling}
182 };
183
184 static short lookup[] =
185 {
186 -1, -1, -1, -1, 0, 1, 2, -1,
187 3, 4, -1, -1, -1, -1, -1, 5,
188 -1, -1, -1, -1, -1, -1, -1, -1,
189 6, -1, -1, -1, 7, -1, -1, -1,
190 -1, -1, -1, -1, -1, -1, -1, 8,
191 -1, 9, -1, 10, 11, -1, 12, 13,
192 14, 15, -1, 16, 17, -1, -1, -1,
193 -1, 18, 19, -1, 20, -1, 21, -1,
194 22, -1, -1, 23, -1, -152, -57, -2,
195 -1, 26, -1, 27, 28, -1, -1, -1,
196 -1, 29, 30, -1, -1, 31, -1, 32,
197 -1, -1, -1, -1, 33, -1, 34, 35,
198 -1, -1, 36, 37, -1, 38, 39, -1,
199 -1, 40, 41, -1, 42, -1, 43, -1,
200 44, 45, -1, -1, 46, -1, 47, 48,
201 -1, 49, 50, -1, -1, 51, -1, -1,
202 -1, 52, 53, 54, -1, -1, -1, -1,
203 55, -1, 56, -1, -1, -1, -1, 57,
204 -1, -1, -1, -1, -1, -1, 58, 59,
205 -1, -1, -1, 60, -1, 61, -1, -1,
206 -1, 62, -1, -1, -1, -1, 63, 64,
207 -1, -1, -1, 65, -1, 66, -1, 67,
208 -1, -1, 68, -1, -1, -1, -1, -1,
209 -1, -1, -1, -1, -1, 69, -1, -1,
210 -1, -1, -1, -1, -1, -1, -1, -1,
211 -1, 70, -1, -1, -1, -1, -1, -1,
212 71, -1, 72, -1, -1, 73, -1, -1,
213 -1, -1, -1, -1, -1, -1, 74, -1,
214 -1, 75, -1, -1, 76, -1, -1, -1,
215 -1, -1, -1, -1, -1, -1, -1, 77,
216 -1, -1, -1, -1, -1, -1, -1, -1,
217 -1, -1, -1, -1, -1, -1, -1, -1,
218 -1, -1, -1, -1, -1, -1, -1, -1,
219 -1, -1, -1, -1, -1, -1, -1, -1,
220 -1, -1, -1, -1, -1, -1, -1, -1,
221 78, -1, -1, -1, -1, -1, -1, -1,
222 -1, -1, -1, -1, -1, -1, -1, -1,
223 -1, -1, -1, -1, -1, -1, -1, -1,
224 -1, -1, -1, -1, -1, -1, -1, -1,
225 -1, -1, -1, -1, -1, -1, -1, -1,
226 -1, -1, -1, -1, -1, -1, -1, -1,
227 -1, -1, -1, -1, -1, -1, -1, -1,
228 -1, -1, -1, -1, -1, -1, -1, -1,
229 -1, -1, -1, -1, -1, -1, -1, -1,
230 -1, 79, -1, -1, -1, -1, -1, -1,
231 -1, -1, -1, -1, -1, -1, -1, -1,
232 -1, -1, -1, -1, -1, -1, -1, -1,
233 -1, -1, -1, -1, -1, -1, -1, 80
234 };
235
236 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
237 {
238 register int key = hash (str, len);
239
240 if (key <= MAX_HASH_VALUE && key >= 0)
241 {
242 register int index = lookup[key];
243
244 if (index >= 0)
245 {
246 register const char *s = wordlist[index].name;
247
248 if (tolower(*str) == *s && !strncasecmp (str + 1, s + 1, len - 1) && s[len] == '\0')
249 return &wordlist[index];
250 }
251 else if (index < -TOTAL_KEYWORDS)
252 {
253 register int offset = - 1 - TOTAL_KEYWORDS - index;
254 register struct params *wordptr = &wordlist[TOTAL_KEYWORDS + lookup[offset]];
255 register struct params *wordendptr = wordptr + -lookup[offset + 1];
256
257 while (wordptr < wordendptr)
258 {
259 register const char *s = wordptr->name;
260
261 if (tolower(*str) == *s && !strncasecmp (str + 1, s + 1, len - 1) && s[len] == '\0')
262 return wordptr;
263 wordptr++;
264 }
265 }
266 }
267 }
268 return 0;
269 }
270 }

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27