1 /* -*- buffer-read-only: t -*- vi: set ro:
3 * DO NOT EDIT THIS FILE (stdin.c)
5 * It has been AutoGen-ed
6 * From the definitions stdin
7 * and the template file str2enum
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name ``Bruce Korb'' nor the name of any other
18 * contributor may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include "option-value-type.h"
34 /* ANSI-C code produced by gperf version 3.0.4 */
35 /* Command-line: gperf option-value-type.gp */
36 /* Computed positions: -k'1' */
40 # if 0 /* gperf build options: */
49 // %define slot-name vtp_name
50 // %define hash-function-name option_value_type_hash
51 // %define lookup-function-name find_option_value_type_name
52 // %define word-array-name option_value_type_table
53 // %define initializer-suffix ,VTP_COUNT_CMD
57 #include "option-value-type.h"
59 char const * vtp_name;
60 option_value_type_enum_t vtp_id;
61 } option_value_type_map_t;
64 /* maximum key range = 15, duplicates = 0 */
67 option_value_type_hash (register const char *str, register unsigned int len)
69 static const unsigned char asso_values[] =
71 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
72 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
73 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
74 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
75 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
76 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
77 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
78 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
79 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
80 18, 18, 18, 18, 18, 18, 18, 18, 0, 18,
81 18, 18, 18, 18, 0, 10, 18, 5, 18, 18,
82 5, 18, 18, 18, 18, 0, 18, 18, 18, 18,
83 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
84 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
85 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
86 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
87 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
88 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
89 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
90 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
91 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
92 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
93 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
94 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
95 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
96 18, 18, 18, 18, 18, 18
98 return len + asso_values[(unsigned char)str[0]];
101 static const option_value_type_map_t option_value_type_table[] =
103 {"",VTP_COUNT_CMD}, {"",VTP_COUNT_CMD},
105 {"set", VTP_CMD_SET},
106 {"bool", VTP_CMD_BOOL},
108 {"string", VTP_CMD_STRING},
109 {"boolean", VTP_CMD_BOOLEAN},
111 {"hierarchy", VTP_CMD_HIERARCHY},
113 {"nested", VTP_CMD_NESTED},
114 {"keyword", VTP_CMD_KEYWORD},
116 {"set-membership", VTP_CMD_SET_MEMBERSHIP},
117 {"",VTP_COUNT_CMD}, {"",VTP_COUNT_CMD},
118 {"integer", VTP_CMD_INTEGER}
121 static inline const option_value_type_map_t *
122 find_option_value_type_name (register const char *str, register unsigned int len)
124 if (len <= 14 && len >= 3)
126 register int key = (int)option_value_type_hash (str, len);
128 if (key <= 17 && key >= 0)
130 register const char *s = option_value_type_table[key].vtp_name;
132 if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
133 return &option_value_type_table[key];
140 * Convert a command (keyword) to a option_value_type_enum_t enumeration value.
142 * @param[in] str a string that should start with a known key word.
143 * @param[in] len the provided length of the keyword at \a str.
144 * @returns the enumeration value.
145 * If not found, that value is VTP_INVALID_CMD.
147 option_value_type_enum_t
148 find_option_value_type_cmd(char const * str, size_t len)
150 option_value_type_map_t const * map;
152 map = find_option_value_type_name(str, (unsigned int)len);
153 return (map == NULL) ? VTP_INVALID_CMD : map->vtp_id;
156 /* end of option-value-type.c */