56
|
1
|
|
2 /*
|
|
3 * Copyright (C) Igor Sysoev
|
|
4 */
|
|
5
|
|
6
|
|
7 #ifndef _NGX_HASH_H_INCLUDED_
|
|
8 #define _NGX_HASH_H_INCLUDED_
|
|
9
|
|
10
|
|
11 #include <ngx_config.h>
|
|
12 #include <ngx_core.h>
|
|
13
|
|
14
|
|
15 typedef struct {
|
138
|
16 void *value;
|
|
17 u_char len;
|
|
18 u_char name[1];
|
|
19 } ngx_hash_elt_t;
|
56
|
20
|
138
|
21
|
|
22 typedef struct {
|
|
23 ngx_hash_elt_t **buckets;
|
|
24 ngx_uint_t size;
|
56
|
25 } ngx_hash_t;
|
|
26
|
|
27
|
|
28 typedef struct {
|
138
|
29 ngx_hash_t hash;
|
|
30 void *value;
|
|
31 } ngx_hash_wildcard_t;
|
|
32
|
|
33
|
|
34 typedef struct {
|
|
35 ngx_str_t key;
|
|
36 ngx_uint_t key_hash;
|
|
37 void *value;
|
|
38 } ngx_hash_key_t;
|
|
39
|
|
40
|
|
41 typedef ngx_uint_t (*ngx_hash_key_pt) (u_char *data, size_t len);
|
|
42
|
|
43
|
|
44 typedef struct {
|
|
45 ngx_hash_t *hash;
|
|
46 ngx_hash_key_pt key;
|
|
47
|
|
48 ngx_uint_t max_size;
|
|
49 ngx_uint_t bucket_size;
|
|
50
|
|
51 char *name;
|
|
52 ngx_pool_t *pool;
|
|
53 ngx_pool_t *temp_pool;
|
|
54 } ngx_hash_init_t;
|
|
55
|
|
56
|
|
57 typedef struct {
|
|
58 void **buckets;
|
|
59 ngx_uint_t hash_size;
|
|
60
|
|
61 ngx_uint_t max_size;
|
|
62 ngx_uint_t bucket_limit;
|
|
63 size_t bucket_size;
|
|
64 char *name;
|
|
65 ngx_uint_t min_buckets;
|
|
66 } ngx_hash0_t;
|
|
67
|
|
68
|
|
69 typedef struct {
|
|
70 ngx_uint_t hash;
|
|
71 ngx_str_t key;
|
|
72 ngx_str_t value;
|
56
|
73 } ngx_table_elt_t;
|
|
74
|
|
75
|
138
|
76 void *ngx_hash_find(ngx_hash_t *hash, ngx_uint_t key, u_char *name, size_t len);
|
|
77 void *ngx_hash_find_wildcard(ngx_hash_wildcard_t *hwc, u_char *name,
|
|
78 size_t len);
|
|
79
|
|
80 ngx_int_t ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names,
|
|
81 ngx_uint_t nelts);
|
|
82 ngx_int_t ngx_hash_wildcard_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names,
|
|
83 ngx_uint_t nelts);
|
|
84
|
|
85 #define ngx_hash(key, c) key * 31 + c
|
|
86 ngx_uint_t ngx_hash_key(u_char *data, size_t len);
|
|
87 ngx_uint_t ngx_hash_key_lc(u_char *data, size_t len);
|
|
88
|
|
89
|
|
90 ngx_int_t ngx_hash0_init(ngx_hash0_t *hash, ngx_pool_t *pool, void *names,
|
58
|
91 ngx_uint_t nelts);
|
56
|
92
|
|
93
|
|
94 #endif /* _NGX_HASH_H_INCLUDED_ */
|