|
reSIProcate/stack
9694
|
00001 /* C++ code produced by gperf version 3.0.4 */ 00002 /* Command-line: gperf -C -D -E -L C++ -t -k '*' --compare-strncmp -Z MethodHash MethodHash.gperf */ 00003 00004 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ 00005 && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ 00006 && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ 00007 && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ 00008 && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ 00009 && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ 00010 && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ 00011 && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ 00012 && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ 00013 && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ 00014 && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ 00015 && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ 00016 && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ 00017 && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ 00018 && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ 00019 && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ 00020 && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ 00021 && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ 00022 && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ 00023 && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ 00024 && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ 00025 && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ 00026 && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) 00027 /* The character set is not based on ISO-646. */ 00028 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." 00029 #endif 00030 00031 #line 1 "MethodHash.gperf" 00032 00033 #include <string.h> 00034 #include <ctype.h> 00035 #include "resip/stack/MethodTypes.hxx" 00036 00037 namespace resip 00038 { 00039 #line 9 "MethodHash.gperf" 00040 struct methods { const char *name; MethodTypes type; }; 00041 /* maximum key range = 31, duplicates = 0 */ 00042 00043 class MethodHash 00044 { 00045 private: 00046 static inline unsigned int hash (const char *str, unsigned int len); 00047 public: 00048 static const struct methods *in_word_set (const char *str, unsigned int len); 00049 }; 00050 00051 inline unsigned int 00052 MethodHash::hash (register const char *str, register unsigned int len) 00053 { 00054 static const unsigned char asso_values[] = 00055 { 00056 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00057 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00058 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00059 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00060 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00061 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00062 35, 35, 35, 35, 35, 5, 10, 5, 5, 0, 00063 0, 15, 0, 0, 35, 0, 0, 0, 0, 0, 00064 0, 35, 0, 0, 0, 0, 0, 35, 35, 5, 00065 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00066 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00067 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00068 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00069 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00070 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00071 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00072 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00073 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00074 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00075 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00076 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00077 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00078 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00079 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00080 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 00081 35, 35, 35, 35, 35, 35 00082 }; 00083 register int hval = len; 00084 00085 switch (hval) 00086 { 00087 default: 00088 hval += asso_values[(unsigned char)str[8]]; 00089 /*FALLTHROUGH*/ 00090 case 8: 00091 hval += asso_values[(unsigned char)str[7]]; 00092 /*FALLTHROUGH*/ 00093 case 7: 00094 hval += asso_values[(unsigned char)str[6]]; 00095 /*FALLTHROUGH*/ 00096 case 6: 00097 hval += asso_values[(unsigned char)str[5]]; 00098 /*FALLTHROUGH*/ 00099 case 5: 00100 hval += asso_values[(unsigned char)str[4]]; 00101 /*FALLTHROUGH*/ 00102 case 4: 00103 hval += asso_values[(unsigned char)str[3]]; 00104 /*FALLTHROUGH*/ 00105 case 3: 00106 hval += asso_values[(unsigned char)str[2]]; 00107 /*FALLTHROUGH*/ 00108 case 2: 00109 hval += asso_values[(unsigned char)str[1]]; 00110 /*FALLTHROUGH*/ 00111 case 1: 00112 hval += asso_values[(unsigned char)str[0]]; 00113 break; 00114 } 00115 return hval; 00116 } 00117 00118 const struct methods * 00119 MethodHash::in_word_set (register const char *str, register unsigned int len) 00120 { 00121 enum 00122 { 00123 TOTAL_KEYWORDS = 16, 00124 MIN_WORD_LENGTH = 3, 00125 MAX_WORD_LENGTH = 9, 00126 MIN_HASH_VALUE = 4, 00127 MAX_HASH_VALUE = 34 00128 }; 00129 00130 static const struct methods wordlist[] = 00131 { 00132 #line 24 "MethodHash.gperf" 00133 {"INFO", INFO}, 00134 #line 19 "MethodHash.gperf" 00135 {"REFER", REFER}, 00136 #line 14 "MethodHash.gperf" 00137 {"INVITE", INVITE}, 00138 #line 16 "MethodHash.gperf" 00139 {"OPTIONS", OPTIONS}, 00140 #line 22 "MethodHash.gperf" 00141 {"RESPONSE", RESPONSE}, 00142 #line 15 "MethodHash.gperf" 00143 {"NOTIFY", NOTIFY}, 00144 #line 25 "MethodHash.gperf" 00145 {"SERVICE", SERVICE}, 00146 #line 11 "MethodHash.gperf" 00147 {"ACK", ACK}, 00148 #line 17 "MethodHash.gperf" 00149 {"PRACK", PRACK}, 00150 #line 26 "MethodHash.gperf" 00151 {"UPDATE", UPDATE}, 00152 #line 18 "MethodHash.gperf" 00153 {"PUBLISH", PUBLISH}, 00154 #line 12 "MethodHash.gperf" 00155 {"BYE", BYE}, 00156 #line 13 "MethodHash.gperf" 00157 {"CANCEL", CANCEL}, 00158 #line 20 "MethodHash.gperf" 00159 {"REGISTER", REGISTER}, 00160 #line 23 "MethodHash.gperf" 00161 {"MESSAGE", MESSAGE}, 00162 #line 21 "MethodHash.gperf" 00163 {"SUBSCRIBE", SUBSCRIBE} 00164 }; 00165 00166 static const signed char lookup[] = 00167 { 00168 -1, -1, -1, -1, 0, 1, 2, 3, 4, -1, -1, 5, 6, 7, 00169 -1, 8, 9, 10, 11, -1, -1, 12, -1, 13, -1, -1, -1, 14, 00170 -1, -1, -1, -1, -1, -1, 15 00171 }; 00172 00173 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) 00174 { 00175 register int key = hash (str, len); 00176 00177 if (key <= MAX_HASH_VALUE && key >= 0) 00178 { 00179 register int index = lookup[key]; 00180 00181 if (index >= 0) 00182 { 00183 register const char *s = wordlist[index].name; 00184 00185 if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') 00186 return &wordlist[index]; 00187 } 00188 } 00189 } 00190 return 0; 00191 } 00192 #line 27 "MethodHash.gperf" 00193 00194 }
1.7.5.1