3 * Copyright (C) Igor Sysoev
7 #ifndef _NGX_HASH_H_INCLUDED_
8 #define _NGX_HASH_H_INCLUDED_
11 #include <ngx_config.h>
23 ngx_hash_elt_t
**buckets
;
31 } ngx_hash_wildcard_t
;
41 typedef ngx_uint_t (*ngx_hash_key_pt
) (u_char
*data
, size_t len
);
46 ngx_hash_wildcard_t
*wc_head
;
47 ngx_hash_wildcard_t
*wc_tail
;
48 } ngx_hash_combined_t
;
56 ngx_uint_t bucket_size
;
60 ngx_pool_t
*temp_pool
;
64 #define NGX_HASH_SMALL 1
65 #define NGX_HASH_LARGE 2
67 #define NGX_HASH_LARGE_ASIZE 16384
68 #define NGX_HASH_LARGE_HSIZE 10007
70 #define NGX_HASH_WILDCARD_KEY 1
71 #define NGX_HASH_READONLY_KEY 2
78 ngx_pool_t
*temp_pool
;
81 ngx_array_t
*keys_hash
;
83 ngx_array_t dns_wc_head
;
84 ngx_array_t
*dns_wc_head_hash
;
86 ngx_array_t dns_wc_tail
;
87 ngx_array_t
*dns_wc_tail_hash
;
88 } ngx_hash_keys_arrays_t
;
99 void *ngx_hash_find(ngx_hash_t
*hash
, ngx_uint_t key
, u_char
*name
, size_t len
);
100 void *ngx_hash_find_wc_head(ngx_hash_wildcard_t
*hwc
, u_char
*name
, size_t len
);
101 void *ngx_hash_find_wc_tail(ngx_hash_wildcard_t
*hwc
, u_char
*name
, size_t len
);
102 void *ngx_hash_find_combined(ngx_hash_combined_t
*hash
, ngx_uint_t key
,
103 u_char
*name
, size_t len
);
105 ngx_int_t
ngx_hash_init(ngx_hash_init_t
*hinit
, ngx_hash_key_t
*names
,
107 ngx_int_t
ngx_hash_wildcard_init(ngx_hash_init_t
*hinit
, ngx_hash_key_t
*names
,
110 #define ngx_hash(key, c) ((ngx_uint_t) key * 31 + c)
111 ngx_uint_t
ngx_hash_key(u_char
*data
, size_t len
);
112 ngx_uint_t
ngx_hash_key_lc(u_char
*data
, size_t len
);
113 ngx_uint_t
ngx_hash_strlow(u_char
*dst
, u_char
*src
, size_t n
);
116 ngx_int_t
ngx_hash_keys_array_init(ngx_hash_keys_arrays_t
*ha
, ngx_uint_t type
);
117 ngx_int_t
ngx_hash_add_key(ngx_hash_keys_arrays_t
*ha
, ngx_str_t
*key
,
118 void *value
, ngx_uint_t flags
);
121 #endif /* _NGX_HASH_H_INCLUDED_ */