ngx_conf_set_str_slot函数解析
来源:互联网 发布:川师大杀人案知乎 编辑:程序博客网 时间:2024/04/25 11:40
文章来自:http://blog.chinaunix.net/uid-22400280-id-3218765.html
ngx_command_t
static ngx_command_t ngx_http_get_method_commands[]={ { ngx_string("test"), NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, getMethodset, NGX_HTTP_LOC_CONF_OFFSET, 0, NULL, }, ngx_null_command};
struct ngx_command_s { ngx_str_t name; ngx_uint_t type; char *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); ngx_uint_t conf; ngx_uint_t offset; void *post;};
char *ngx_conf_set_str_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf){ char *p = conf; //获取当前配置结构体信息ngx_http___conf_t ngx_str_t *field, *value; ngx_conf_post_t *post; field = (ngx_str_t *) (p + cmd->offset); //ngx_command_t的offset作为p的偏移量/*ngx_command_t的 ngx_uint_t conf指明offset的位置是在哪个配置结构体信息中(main\server\loc)在ngx_http_config.h中定义了conf的三个取值,如下#define NGX_HTTP_MAIN_CONF_OFFSET offsetof(ngx_http_conf_ctx_t, main_conf)#define NGX_HTTP_SRV_CONF_OFFSET offsetof(ngx_http_conf_ctx_t, srv_conf)#define NGX_HTTP_LOC_CONF_OFFSET offsetof(ngx_http_conf_ctx_t, loc_conf)typedef struct { void **main_conf; void **srv_conf; void **loc_conf;} ngx_http_conf_ctx_t; 获取到保存指令参数的配置结构体conf中,offset指的是在结构体重偏移位置ngx_conf_t *cf是获取当前环境中的读取配置文件的配置信息包含指令名称指令参数*/ if (field->data) { return "is duplicate"; } value = cf->args->elts; //获取指令数组 *field = value[1]; //获取第一个参数 if (cmd->post) { post = cmd->post; return post->post_handler(cf, post, field); } return NGX_CONF_OK;}
struct ngx_array_s { void *elts; //数组数据区起始位置 ngx_uint_t nelts; //实际存放的元素个数 size_t size; //每个元素大小 ngx_uint_t nalloc; //数组所含空间个数,即实际分配的小空间的个数 ngx_pool_t *pool; //该数组在此内存池中分配 };
0 0
- ngx_conf_set_str_slot函数解析
- 函数调用约定解析
- 函数解析字符串(ZT)
- setsockopt函数解析(转)
- ARX函数解析
- 成员函数重载解析
- js 函数深入解析
- Linux wait函数解析
- 函数调用约定解析
- 钩子函数解析
- 虚函数解析
- 函数表达式解析器
- PartitionMotionSearch()函数解析
- fcntl函数解析
- main函数参数解析
- json解析函数。
- 虚函数详细解析
- 虚析构函数解析
- C++中堆和栈的区别,自由存储区、全局静态存储区和常量存储区
- 零基础学习openstack
- eclipse不能进行保存
- SQL中的cast()函数
- oracle json 解析函数
- ngx_conf_set_str_slot函数解析
- navicat for mysql注册码
- 深入浅出LSTM神经网络
- select2 插件使用
- SSL 协议通讯建立过程
- mysql 数据插入优化方法
- 嵌入式程序地址解析
- 关于STM32 PB3 PB4 如何设置成普通GPIO的配置
- 13.c/c++程序员面试宝典-宏定义