1/* $NetBSD: xat-attribute.c,v 1.1.1.1 2009/12/13 16:55:15 kardel Exp $ */ 2 3/* ANSI-C code produced by gperf version 3.0.2 */ 4 5 6#if 0 /* gperf build options: */ 7// %struct-type 8// %language=ANSI-C 9// %includes 10// %global-table 11// %omit-struct-type 12// %readonly-tables 13// %compare-strncmp 14// 15// %define slot-name xat_name 16// %define hash-function-name xat_attribute_hash 17// %define lookup-function-name find_xat_attribute_name 18// %define word-array-name xat_attribute_table 19// %define initializer-suffix ,XAT_COUNT_KWD 20#endif /* gperf build options: */ 21 22#include "xat-attribute.h" 23 24typedef struct { 25 char const * xat_name; 26 xat_attribute_enum_t xat_id; 27} xat_attribute_map_t; 28#include <string.h> 29 30/* maximum key range = 9, duplicates = 0 */ 31 32#ifdef __GNUC__ 33#else 34#ifdef __cplusplus 35#endif 36#endif 37inline static unsigned int 38xat_attribute_hash (register const char *str, register unsigned int len) 39{ 40 static const unsigned char asso_values[] = 41 { 42 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 43 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 44 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 45 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 46 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 47 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 48 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 49 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 50 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 51 13, 13, 13, 13, 13, 13, 13, 13, 13, 0, 52 13, 13, 13, 13, 13, 5, 13, 5, 13, 0, 53 13, 13, 13, 13, 13, 13, 0, 0, 13, 0, 54 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 55 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 56 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 57 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 58 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 59 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 60 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 61 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 62 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 63 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 64 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 65 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 66 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 67 13, 13, 13, 13, 13, 13 68 }; 69 return len + asso_values[(unsigned char)str[0]]; 70} 71 72static const xat_attribute_map_t xat_attribute_table[] = 73 { 74 {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD}, 75 {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD}, 76 {"type", XAT_KWD_TYPE}, 77 {"words", XAT_KWD_WORDS}, 78 {"cooked", XAT_KWD_COOKED}, 79 {"members", XAT_KWD_MEMBERS}, 80 {"uncooked", XAT_KWD_UNCOOKED}, 81 {"keep", XAT_KWD_KEEP}, 82 {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD}, 83 {"invalid", XAT_KWD_INVALID} 84 }; 85 86#ifdef __GNUC__ 87#endif 88static inline const xat_attribute_map_t * 89find_xat_attribute_name (register const char *str, register unsigned int len) 90{ 91 if (len <= 8 && len >= 4) 92 { 93 register int key = xat_attribute_hash (str, len); 94 95 if (key <= 12 && key >= 0) 96 { 97 register const char *s = xat_attribute_table[key].xat_name; 98 99 if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') 100 return &xat_attribute_table[key]; 101 } 102 } 103 return 0; 104} 105 106 107xat_attribute_enum_t 108find_xat_attribute_id(char const * str, unsigned int len) 109{ 110 const xat_attribute_map_t * p = 111 find_xat_attribute_name(str, len); 112 return (p == 0) ? XAT_KWD_INVALID : p->xat_id; 113} 114