Home | History | Annotate | Download | only in registry_controlled_domains
      1 /* C++ code produced by gperf version 3.0.3 */
      2 /* Command-line: gperf -a -L C++ -C -c -o -t -k '*' -NFindDomain -ZPerfect_Hash_Test1 -P -K name_offset -Q stringpool1 -D effective_tld_names_unittest1.gperf  */
      3 
      4 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
      5       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
      6       && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
      7       && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
      8       && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
      9       && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
     10       && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
     11       && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
     12       && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
     13       && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
     14       && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
     15       && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
     16       && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
     17       && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
     18       && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
     19       && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
     20       && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
     21       && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
     22       && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
     23       && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
     24       && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
     25       && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
     26       && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
     27 /* The character set is not based on ISO-646.  */
     28 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf (at) gnu.org>."
     29 #endif
     30 
     31 #line 1 "effective_tld_names_unittest1.gperf"
     32 
     33 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
     34 // Use of this source code is governed by a BSD-style license that can be
     35 // found in the LICENSE file.
     36 // Test file used by registry_controlled_domain_unittest.
     37 // We edit this file manually, then run
     38 // gperf -a -L "C++" -C -c -o -t -k '*' -NFindDomain -ZPerfect_Hash_Test1 -P -K name_offset -Q stringpool1 -D effective_tld_names_unittest1.gperf >  effective_tld_names_unittest1.cc
     39 // to generate the perfect hashmap.
     40 #line 10 "effective_tld_names_unittest1.gperf"
     41 struct DomainRule {
     42   int name_offset;
     43   int type;  // 1: exception, 2: wildcard, 4: private
     44 };
     45 
     46 #define TOTAL_KEYWORDS 11
     47 #define MIN_WORD_LENGTH 1
     48 #define MAX_WORD_LENGTH 11
     49 #define MIN_HASH_VALUE 1
     50 #define MAX_HASH_VALUE 17
     51 /* maximum key range = 17, duplicates = 0 */
     52 
     53 class Perfect_Hash_Test1
     54 {
     55 private:
     56   static inline unsigned int hash (const char *str, unsigned int len);
     57 public:
     58   static const struct DomainRule *FindDomain (const char *str, unsigned int len);
     59 };
     60 
     61 inline unsigned int
     62 Perfect_Hash_Test1::hash (register const char *str, register unsigned int len)
     63 {
     64   static const unsigned char asso_values[] =
     65     {
     66       18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
     67       18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
     68       18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
     69       18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
     70       18, 18, 18, 18, 18, 18,  0, 18, 18, 18,
     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,  0,  0,  0,
     76       18,  5,  0, 18, 18,  0,  0, 18, 18,  0,
     77        5,  0,  0, 18,  0, 18,  5, 18,  0, 18,
     78       18, 18,  0, 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, 18, 18,
     81       18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
     82       18, 18, 18, 18, 18, 18, 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
     92     };
     93   register int hval = len;
     94 
     95   switch (hval)
     96     {
     97       default:
     98         hval += asso_values[(unsigned char)str[10]];
     99       /*FALLTHROUGH*/
    100       case 10:
    101         hval += asso_values[(unsigned char)str[9]];
    102       /*FALLTHROUGH*/
    103       case 9:
    104         hval += asso_values[(unsigned char)str[8]];
    105       /*FALLTHROUGH*/
    106       case 8:
    107         hval += asso_values[(unsigned char)str[7]];
    108       /*FALLTHROUGH*/
    109       case 7:
    110         hval += asso_values[(unsigned char)str[6]];
    111       /*FALLTHROUGH*/
    112       case 6:
    113         hval += asso_values[(unsigned char)str[5]];
    114       /*FALLTHROUGH*/
    115       case 5:
    116         hval += asso_values[(unsigned char)str[4]];
    117       /*FALLTHROUGH*/
    118       case 4:
    119         hval += asso_values[(unsigned char)str[3]];
    120       /*FALLTHROUGH*/
    121       case 3:
    122         hval += asso_values[(unsigned char)str[2]];
    123       /*FALLTHROUGH*/
    124       case 2:
    125         hval += asso_values[(unsigned char)str[1]];
    126       /*FALLTHROUGH*/
    127       case 1:
    128         hval += asso_values[(unsigned char)str[0]];
    129         break;
    130     }
    131   return hval;
    132 }
    133 
    134 struct stringpool1_t
    135   {
    136     char stringpool1_str0[sizeof("c")];
    137     char stringpool1_str1[sizeof("jp")];
    138     char stringpool1_str2[sizeof("b.c")];
    139     char stringpool1_str3[sizeof("ac.jp")];
    140     char stringpool1_str4[sizeof("bar.jp")];
    141     char stringpool1_str5[sizeof("no")];
    142     char stringpool1_str6[sizeof("baz.bar.jp")];
    143     char stringpool1_str7[sizeof("bar.baz.com")];
    144     char stringpool1_str8[sizeof("priv.no")];
    145     char stringpool1_str9[sizeof("pref.bar.jp")];
    146     char stringpool1_str10[sizeof("private")];
    147   };
    148 static const struct stringpool1_t stringpool1_contents =
    149   {
    150     "c",
    151     "jp",
    152     "b.c",
    153     "ac.jp",
    154     "bar.jp",
    155     "no",
    156     "baz.bar.jp",
    157     "bar.baz.com",
    158     "priv.no",
    159     "pref.bar.jp",
    160     "private"
    161   };
    162 #define stringpool1 ((const char *) &stringpool1_contents)
    163 const struct DomainRule *
    164 Perfect_Hash_Test1::FindDomain (register const char *str, register unsigned int len)
    165 {
    166   static const struct DomainRule wordlist[] =
    167     {
    168 #line 21 "effective_tld_names_unittest1.gperf"
    169       {(int)(long)&((struct stringpool1_t *)0)->stringpool1_str0, 2},
    170 #line 15 "effective_tld_names_unittest1.gperf"
    171       {(int)(long)&((struct stringpool1_t *)0)->stringpool1_str1, 0},
    172 #line 22 "effective_tld_names_unittest1.gperf"
    173       {(int)(long)&((struct stringpool1_t *)0)->stringpool1_str2, 1},
    174 #line 16 "effective_tld_names_unittest1.gperf"
    175       {(int)(long)&((struct stringpool1_t *)0)->stringpool1_str3, 0},
    176 #line 17 "effective_tld_names_unittest1.gperf"
    177       {(int)(long)&((struct stringpool1_t *)0)->stringpool1_str4, 2},
    178 #line 23 "effective_tld_names_unittest1.gperf"
    179       {(int)(long)&((struct stringpool1_t *)0)->stringpool1_str5, 0},
    180 #line 18 "effective_tld_names_unittest1.gperf"
    181       {(int)(long)&((struct stringpool1_t *)0)->stringpool1_str6, 2},
    182 #line 20 "effective_tld_names_unittest1.gperf"
    183       {(int)(long)&((struct stringpool1_t *)0)->stringpool1_str7, 0},
    184 #line 24 "effective_tld_names_unittest1.gperf"
    185       {(int)(long)&((struct stringpool1_t *)0)->stringpool1_str8, 4},
    186 #line 19 "effective_tld_names_unittest1.gperf"
    187       {(int)(long)&((struct stringpool1_t *)0)->stringpool1_str9, 1},
    188 #line 25 "effective_tld_names_unittest1.gperf"
    189       {(int)(long)&((struct stringpool1_t *)0)->stringpool1_str10, 4}
    190     };
    191 
    192   static const signed char lookup[] =
    193     {
    194       -1,  0,  1,  2, -1,  3,  4,  5, -1, -1,  6,  7,  8, -1,
    195       -1, -1,  9, 10
    196     };
    197 
    198   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    199     {
    200       register int key = hash (str, len);
    201 
    202       if (key <= MAX_HASH_VALUE && key >= 0)
    203         {
    204           register int index = lookup[key];
    205 
    206           if (index >= 0)
    207             {
    208               register const char *s = wordlist[index].name_offset + stringpool1;
    209 
    210               if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
    211                 return &wordlist[index];
    212             }
    213         }
    214     }
    215   return 0;
    216 }
    217 #line 26 "effective_tld_names_unittest1.gperf"
    218 
    219