File: uri_schemes_hash.c

package info (click to toggle)
uri 2.13.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,636 kB
  • ctags: 891
  • sloc: sh: 9,061; ansic: 8,213; makefile: 343; yacc: 318; perl: 301
file content (150 lines) | stat: -rw-r--r-- 3,624 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/* C code produced by gperf version 2.7 */
/* Command-line: gperf -k2-4 -c -G -W uri_scheme_list -H uri_scheme_hash -N uri_scheme_exists  */

#define TOTAL_KEYWORDS 40
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 8
#define MIN_HASH_VALUE 2
#define MAX_HASH_VALUE 101
/* maximum key range = 100, duplicates = 0 */

#ifdef __GNUC__
__inline
#endif
static unsigned int
uri_scheme_hash (str, len)
     register const char *str;
     register unsigned int len;
{
  static unsigned char asso_values[] =
    {
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102,  10,  45,
       10,   0,  25, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102,  41,   5,  25,
       40,   0, 102,  15,   0,   0, 102, 102,   5,  45,
       35,  55,   0,  10,   0,   0,  15,  40,   0,  25,
        5, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
      102, 102, 102, 102, 102, 102
    };
  register int hval = len;

  switch (hval)
    {
      default:
      case 4:
        hval += asso_values[(unsigned char)str[3]];
      case 3:
        hval += asso_values[(unsigned char)str[2]];
      case 2:
        hval += asso_values[(unsigned char)str[1]];
        break;
    }
  return hval;
}

static const char * uri_scheme_list[] =
  {
    "", "",
    "tv",
    "sip",
    "sips",
    "", "",
    "service",
    "",
    "file",
    "", "",
    "webster",
    "lrq",
    "h323",
    "", "", "",
    "ftp",
    "sipt",
    "", "", "", "",
    "h320",
    "", "", "",
    "irc",
    "news",
    "", "", "", "",
    "http",
    "https",
    "", "", "",
    "h324",
    "", "", "",
    "sdp",
    "sipu",
    "wais",
    "telnet",
    "",
    "videotex",
    "fax",
    "",
    "tn3270",
    "mailto",
    "",
    "nntp",
    "",
    "finger",
    "",
    "pop",
    "pop3",
    "whois",
    "gopher",
    "whois++",
    "prospero",
    "smtp",
    "snews",
    "", "", "",
    "t120",
    "", "", "", "", "", "", "", "", "",
    "", "",
    "rlogin",
    "", "", "", "",
    "rwhois",
    "", "", "", "", "", "", "", "",
    "phone",
    "", "", "", "",
    "modem",
    "data"
  };

#ifdef __GNUC__
__inline
#endif
const char *
uri_scheme_exists (str, len)
     register const char *str;
     register unsigned int len;
{
  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    {
      register int key = uri_scheme_hash (str, len);

      if (key <= MAX_HASH_VALUE && key >= 0)
        {
          register const char *s = uri_scheme_list[key];

          if (*str == *s && !strncmp (str + 1, s + 1, len - 1))
            return s;
        }
    }
  return 0;
}