src/http/ngx_http_config.h - nginx-1.7.10

Data types defined

Macros defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #ifndef _NGX_HTTP_CONFIG_H_INCLUDED_
  6. #define _NGX_HTTP_CONFIG_H_INCLUDED_


  7. #include <ngx_config.h>
  8. #include <ngx_core.h>
  9. #include <ngx_http.h>


  10. typedef struct {
  11.     void        **main_conf;
  12.     void        **srv_conf;
  13.     void        **loc_conf;
  14. } ngx_http_conf_ctx_t;


  15. typedef struct {
  16.     ngx_int_t   (*preconfiguration)(ngx_conf_t *cf);
  17.     ngx_int_t   (*postconfiguration)(ngx_conf_t *cf);

  18.     void       *(*create_main_conf)(ngx_conf_t *cf);
  19.     char       *(*init_main_conf)(ngx_conf_t *cf, void *conf);

  20.     void       *(*create_srv_conf)(ngx_conf_t *cf);
  21.     char       *(*merge_srv_conf)(ngx_conf_t *cf, void *prev, void *conf);

  22.     void       *(*create_loc_conf)(ngx_conf_t *cf);
  23.     char       *(*merge_loc_conf)(ngx_conf_t *cf, void *prev, void *conf);
  24. } ngx_http_module_t;


  25. #define NGX_HTTP_MODULE           0x50545448   /* "HTTP" */

  26. #define NGX_HTTP_MAIN_CONF        0x02000000
  27. #define NGX_HTTP_SRV_CONF         0x04000000
  28. #define NGX_HTTP_LOC_CONF         0x08000000
  29. #define NGX_HTTP_UPS_CONF         0x10000000
  30. #define NGX_HTTP_SIF_CONF         0x20000000
  31. #define NGX_HTTP_LIF_CONF         0x40000000
  32. #define NGX_HTTP_LMT_CONF         0x80000000


  33. #define NGX_HTTP_MAIN_CONF_OFFSET  offsetof(ngx_http_conf_ctx_t, main_conf)
  34. #define NGX_HTTP_SRV_CONF_OFFSET   offsetof(ngx_http_conf_ctx_t, srv_conf)
  35. #define NGX_HTTP_LOC_CONF_OFFSET   offsetof(ngx_http_conf_ctx_t, loc_conf)


  36. #define ngx_http_get_module_main_conf(r, module)                             \
  37.     (r)->main_conf[module.ctx_index]
  38. #define ngx_http_get_module_srv_conf(r, module)  (r)->srv_conf[module.ctx_index]
  39. #define ngx_http_get_module_loc_conf(r, module)  (r)->loc_conf[module.ctx_index]


  40. #define ngx_http_conf_get_module_main_conf(cf, module)                        \
  41.     ((ngx_http_conf_ctx_t *) cf->ctx)->main_conf[module.ctx_index]
  42. #define ngx_http_conf_get_module_srv_conf(cf, module)                         \
  43.     ((ngx_http_conf_ctx_t *) cf->ctx)->srv_conf[module.ctx_index]
  44. #define ngx_http_conf_get_module_loc_conf(cf, module)                         \
  45.     ((ngx_http_conf_ctx_t *) cf->ctx)->loc_conf[module.ctx_index]

  46. #define ngx_http_cycle_get_module_main_conf(cycle, module)                    \
  47.     (cycle->conf_ctx[ngx_http_module.index] ?                                 \
  48.         ((ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index])      \
  49.             ->main_conf[module.ctx_index]:                                    \
  50.         NULL)


  51. #endif /* _NGX_HTTP_CONFIG_H_INCLUDED_ */