gperf creates optimum hash table for stroke keywords
[strongswan.git] / src / stroke / stroke_keywords.c
1 /* C code produced by gperf version 3.0.1 */
2 /* Command-line: /usr/bin/gperf -C -G -t */
3 /* Computed positions: -k'2,4' */
4
5 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
6 && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
7 && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
8 && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
9 && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
10 && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
11 && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
12 && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
13 && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
14 && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
15 && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
16 && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
17 && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
18 && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
19 && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
20 && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
21 && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
22 && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
23 && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
24 && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
25 && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
26 && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
27 && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
28 /* The character set is not based on ISO-646. */
29 error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
30 #endif
31
32
33 /* stroke keywords
34 * Copyright (C) 2006 Andreas Steffen
35 * Hochschule fuer Technik Rapperswil, Switzerland
36 *
37 * This program is free software; you can redistribute it and/or modify it
38 * under the terms of the GNU General Public License as published by the
39 * Free Software Foundation; either version 2 of the License, or (at your
40 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
41 *
42 * This program is distributed in the hope that it will be useful, but
43 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
44 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
45 * for more details.
46 *
47 * RCSID $Id: keywords.txt,v 1.6 2006/04/17 10:30:27 as Exp $
48 */
49
50 #include <string.h>
51
52 #include "stroke_keywords.h"
53
54 struct stroke_token {
55 char *name;
56 stroke_keyword_t kw;
57 };
58
59 #define TOTAL_KEYWORDS 14
60 #define MIN_WORD_LENGTH 2
61 #define MAX_WORD_LENGTH 11
62 #define MIN_HASH_VALUE 2
63 #define MAX_HASH_VALUE 36
64 /* maximum key range = 35, duplicates = 0 */
65
66 #ifdef __GNUC__
67 __inline
68 #else
69 #ifdef __cplusplus
70 inline
71 #endif
72 #endif
73 static unsigned int
74 hash (str, len)
75 register const char *str;
76 register unsigned int len;
77 {
78 static const unsigned char asso_values[] =
79 {
80 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
81 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
82 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
83 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
84 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
85 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
86 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
87 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
88 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
89 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
90 0, 15, 37, 37, 37, 5, 37, 37, 10, 0,
91 37, 0, 0, 37, 37, 37, 0, 37, 37, 37,
92 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
93 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
94 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
95 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
96 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
97 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
98 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
99 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
100 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
101 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
102 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
103 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
104 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
105 37, 37, 37, 37, 37, 37
106 };
107 register int hval = len;
108
109 switch (hval)
110 {
111 default:
112 hval += asso_values[(unsigned char)str[3]];
113 /*FALLTHROUGH*/
114 case 3:
115 case 2:
116 hval += asso_values[(unsigned char)str[1]];
117 break;
118 }
119 return hval;
120 }
121
122 static const struct stroke_token wordlist[] =
123 {
124 {""}, {""},
125 {"up", STROKE_UP},
126 {"add", STROKE_ADD},
127 {"dowm", STROKE_DOWN},
128 {"route", STROKE_ROUTE},
129 {"status", STROKE_STATUS},
130 {"logtype", STROKE_LOGTYPE},
131 {""},
132 {"statusall", STROKE_STATUSALL},
133 {""}, {""},
134 {"listall", STROKE_LIST_ALL},
135 {"listcrls", STROKE_LIST_CRLS},
136 {"listcerts", STROKE_LIST_CERTS},
137 {""},
138 {"listcacerts", STROKE_LIST_CACERTS},
139 {"logleve", STROKE_LOGLEVEL},
140 {"del", STROKE_DEL},
141 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
142 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
143 {"delete", STROKE_DELETE}
144 };
145
146 #ifdef __GNUC__
147 __inline
148 #endif
149 const struct stroke_token *
150 in_word_set (str, len)
151 register const char *str;
152 register unsigned int len;
153 {
154 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
155 {
156 register int key = hash (str, len);
157
158 if (key <= MAX_HASH_VALUE && key >= 0)
159 {
160 register const char *s = wordlist[key].name;
161
162 if (*str == *s && !strcmp (str + 1, s + 1))
163 return &wordlist[key];
164 }
165 }
166 return 0;
167 }