Back to home page

Nginx displayed by LXR

Source navigation ]
Diff markup ]
Identifier search ]
general search ]
 
 
Version: nginx-1.13.12 ]​[ nginx-1.12.2 ]​

0001 
0002 /*
0003  * Copyright (C) Igor Sysoev
0004  * Copyright (C) Nginx, Inc.
0005  */
0006 
0007 
0008 #ifndef _NGX_HASH_H_INCLUDED_
0009 #define _NGX_HASH_H_INCLUDED_
0010 
0011 
0012 #include <ngx_config.h>
0013 #include <ngx_core.h>
0014 
0015 
0016 typedef struct {
0017     void             *value;
0018     u_short           len;
0019     u_char            name[1];
0020 } ngx_hash_elt_t;
0021 
0022 
0023 typedef struct {
0024     ngx_hash_elt_t  **buckets;
0025     ngx_uint_t        size;
0026 } ngx_hash_t;
0027 
0028 
0029 typedef struct {
0030     ngx_hash_t        hash;
0031     void             *value;
0032 } ngx_hash_wildcard_t;
0033 
0034 
0035 typedef struct {
0036     ngx_str_t         key;
0037     ngx_uint_t        key_hash;
0038     void             *value;
0039 } ngx_hash_key_t;
0040 
0041 
0042 typedef ngx_uint_t (*ngx_hash_key_pt) (u_char *data, size_t len);
0043 
0044 
0045 typedef struct {
0046     ngx_hash_t            hash;
0047     ngx_hash_wildcard_t  *wc_head;
0048     ngx_hash_wildcard_t  *wc_tail;
0049 } ngx_hash_combined_t;
0050 
0051 
0052 typedef struct {
0053     ngx_hash_t       *hash;
0054     ngx_hash_key_pt   key;
0055 
0056     ngx_uint_t        max_size;
0057     ngx_uint_t        bucket_size;
0058 
0059     char             *name;
0060     ngx_pool_t       *pool;
0061     ngx_pool_t       *temp_pool;
0062 } ngx_hash_init_t;
0063 
0064 
0065 #define NGX_HASH_SMALL            1
0066 #define NGX_HASH_LARGE            2
0067 
0068 #define NGX_HASH_LARGE_ASIZE      16384
0069 #define NGX_HASH_LARGE_HSIZE      10007
0070 
0071 #define NGX_HASH_WILDCARD_KEY     1
0072 #define NGX_HASH_READONLY_KEY     2
0073 
0074 
0075 typedef struct {
0076     ngx_uint_t        hsize;
0077 
0078     ngx_pool_t       *pool;
0079     ngx_pool_t       *temp_pool;
0080 
0081     ngx_array_t       keys;
0082     ngx_array_t      *keys_hash;
0083 
0084     ngx_array_t       dns_wc_head;
0085     ngx_array_t      *dns_wc_head_hash;
0086 
0087     ngx_array_t       dns_wc_tail;
0088     ngx_array_t      *dns_wc_tail_hash;
0089 } ngx_hash_keys_arrays_t;
0090 
0091 
0092 typedef struct {
0093     ngx_uint_t        hash;
0094     ngx_str_t         key;
0095     ngx_str_t         value;
0096     u_char           *lowcase_key;
0097 } ngx_table_elt_t;
0098 
0099 
0100 void *ngx_hash_find(ngx_hash_t *hash, ngx_uint_t key, u_char *name, size_t len);
0101 void *ngx_hash_find_wc_head(ngx_hash_wildcard_t *hwc, u_char *name, size_t len);
0102 void *ngx_hash_find_wc_tail(ngx_hash_wildcard_t *hwc, u_char *name, size_t len);
0103 void *ngx_hash_find_combined(ngx_hash_combined_t *hash, ngx_uint_t key,
0104     u_char *name, size_t len);
0105 
0106 ngx_int_t ngx_hash_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names,
0107     ngx_uint_t nelts);
0108 ngx_int_t ngx_hash_wildcard_init(ngx_hash_init_t *hinit, ngx_hash_key_t *names,
0109     ngx_uint_t nelts);
0110 
0111 #define ngx_hash(key, c)   ((ngx_uint_t) key * 31 + c)
0112 ngx_uint_t ngx_hash_key(u_char *data, size_t len);
0113 ngx_uint_t ngx_hash_key_lc(u_char *data, size_t len);
0114 ngx_uint_t ngx_hash_strlow(u_char *dst, u_char *src, size_t n);
0115 
0116 
0117 ngx_int_t ngx_hash_keys_array_init(ngx_hash_keys_arrays_t *ha, ngx_uint_t type);
0118 ngx_int_t ngx_hash_add_key(ngx_hash_keys_arrays_t *ha, ngx_str_t *key,
0119     void *value, ngx_uint_t flags);
0120 
0121 
0122 #endif /* _NGX_HASH_H_INCLUDED_ */