static char * ngx_http_image_filter_offset(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_image_filter_conf_t *imcf = conf; ngx_str_t *value; ngx_http_complex_value_t cv; ngx_http_compile_complex_value_t ccv; value = cf->args->elts; ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = &cv; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } if (cv.lengths == NULL) { imcf->offset_x = ngx_http_image_filter_value(&value[1]); } else { imcf->oxcv = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (imcf->oxcv == NULL) { return NGX_CONF_ERROR; } *imcf->oxcv = cv; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[2]; ccv.complex_value = &cv; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } if (cv.lengths == NULL) { imcf->offset_y = ngx_http_image_filter_value(&value[2]); } else { imcf->oycv = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (imcf->oycv == NULL) { return NGX_CONF_ERROR; } *imcf->oycv = cv; } return NGX_CONF_OK; }
static char * ngx_http_redis2_raw_queries(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_redis2_loc_conf_t *rlcf = conf; ngx_str_t *value; ngx_http_compile_complex_value_t ccv; value = cf->args->elts; /* compile the N argument */ rlcf->complex_query_count = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (rlcf->complex_query_count == NULL) { return NGX_CONF_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = rlcf->complex_query_count; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } /* compile the CMDS argument */ rlcf->complex_query = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (rlcf->complex_query == NULL) { return NGX_CONF_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[2]; ccv.complex_value = rlcf->complex_query; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
static char * ngx_http_headers_add(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_headers_conf_t *hcf = conf; ngx_str_t *value; ngx_uint_t i; ngx_http_header_val_t *hv; ngx_http_set_header_t *set; ngx_http_compile_complex_value_t ccv; value = cf->args->elts; if (hcf->headers == NULL) { hcf->headers = ngx_array_create(cf->pool, 1, sizeof(ngx_http_header_val_t)); if (hcf->headers == NULL) { return NGX_CONF_ERROR; } } hv = ngx_array_push(hcf->headers); if (hv == NULL) { return NGX_CONF_ERROR; } hv->hash = 1; hv->key = value[1]; hv->handler = ngx_http_add_header; hv->offset = 0; set = ngx_http_set_headers; for (i = 0; set[i].name.len; i++) { if (ngx_strcasecmp(value[1].data, set[i].name.data) != 0) { continue; } hv->offset = set[i].offset; hv->handler = set[i].handler; break; } if (value[2].len == 0) { ngx_memzero(&hv->value, sizeof(ngx_http_complex_value_t)); return NGX_CONF_OK; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[2]; ccv.complex_value = &hv->value; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
static char * ngx_http_pngquant_store_command(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_pngquant_conf_t *pqlc = conf; ngx_str_t *value; ngx_http_compile_complex_value_t ccv; value = cf->args->elts; pqlc->store = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if(pqlc->store == NULL) { return NGX_CONF_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = pqlc->store; if(ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
static char * ngx_http_static_delete(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_static_delete_loc_conf_t *sdlcf = conf; ngx_http_compile_complex_value_t ccv; ngx_http_core_loc_conf_t *clcf; ngx_str_t *value; value = cf->args->elts; ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = &sdlcf->filename; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); clcf->handler = ngx_http_static_delete_handler; return NGX_CONF_OK; }
static char* ngx_http_hello_world(ngx_conf_t* cf, ngx_command_t* cmd, void* conf) { ngx_http_core_loc_conf_t* clcf1; clcf1 = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); ngx_http_hello_world_loc_conf_t *clcf = (ngx_http_hello_world_loc_conf_t*) conf; ngx_str_t *value; ngx_http_complex_value_t cv; ngx_http_compile_complex_value_t ccv; value = (ngx_str_t*) cf->args->elts; ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = &cv; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return (char*) NGX_CONF_ERROR ; } if (cv.lengths == NULL) { clcf->output_words = (ngx_str_t) ngx_string(&value[1]); //clcf->output_words.len = sizeof(&value[1]); } else { clcf->owcv = (ngx_http_complex_value_t*) ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (clcf->owcv == NULL) { return (char*) NGX_CONF_ERROR; } *clcf->owcv = cv; } //clcf1->handler = ngx_http_hello_world_handler; //ngx_conf_set_str_slot(cf, cmd, conf); return NGX_CONF_OK; }
ngx_int_t ndk_http_complex_path_value_compile (ngx_conf_t *cf, ngx_http_complex_value_t *cv, ngx_str_t *value, ngx_uint_t prefix) { ngx_http_compile_complex_value_t ccv; ngx_memzero (&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = value; ccv.complex_value = cv; switch (prefix) { case 1 : ccv.root_prefix = 1; break; case 2 : ccv.conf_prefix = 1; break; } ndk_path_to_dir_safe (value, 1, 0); if (!value->len) return NGX_OK; return ngx_http_compile_complex_value (&ccv); }
static char * ngx_http_sub_filter(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_sub_loc_conf_t *slcf = conf; ngx_str_t *value; ngx_http_compile_complex_value_t ccv; if (slcf->match.data) { return "is duplicate"; } value = cf->args->elts; ngx_strlow(value[1].data, value[1].data, value[1].len); slcf->match = value[1]; ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[2]; ccv.complex_value = &slcf->value; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
static char *nchan_set_channel_id(ngx_conf_t *cf, ngx_command_t *cmd, void *conf, nchan_chid_loc_conf_t *chid) { ngx_int_t i; ngx_str_t *value; ngx_http_complex_value_t **cv; ngx_http_compile_complex_value_t ccv; chid->n = cf->args->nelts - 1; for(i=1; i < cf->args->nelts; i++) { value = &((ngx_str_t *) cf->args->elts)[i]; cv = &chid->id[i-1]; *cv = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (*cv == NULL) { return NGX_CONF_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = value; ccv.complex_value = *cv; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } } return NGX_CONF_OK; }
static char * ngx_http_auth_basic_user_file(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_auth_basic_loc_conf_t *alcf = conf; ngx_str_t *value; ngx_http_compile_complex_value_t ccv; if (alcf->user_file.value.data) { return "is duplicate"; } value = cf->args->elts; ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = &alcf->user_file; ccv.zero = 1; ccv.conf_prefix = 1; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
static char * ngx_http_drizzle_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_drizzle_loc_conf_t *dlcf = conf; ngx_http_core_loc_conf_t *clcf; ngx_str_t *value; ngx_http_compile_complex_value_t ccv; ngx_url_t url; ngx_uint_t n; if (dlcf->upstream.upstream) { return "is duplicate"; } clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); clcf->handler = ngx_http_drizzle_handler; if (clcf->name.data[clcf->name.len - 1] == '/') { clcf->auto_redirect = 1; } value = cf->args->elts; n = ngx_http_script_variables_count(&value[1]); if (n) { dlcf->complex_target = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (dlcf->complex_target == NULL) { return NGX_CONF_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = dlcf->complex_target; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; } dlcf->complex_target = NULL; ngx_memzero(&url, sizeof(ngx_url_t)); url.url = value[1]; url.no_resolve = 1; dlcf->upstream.upstream = ngx_http_upstream_add(cf, &url, 0); if (dlcf->upstream.upstream == NULL) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
static char * ngx_http_scgi_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_scgi_loc_conf_t *scf = conf; ngx_str_t *value; ngx_http_compile_complex_value_t ccv; value = cf->args->elts; if (scf->cache_key.value.len) { return "is duplicate"; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = &scf->cache_key; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
static char * ngx_http_sub_filter(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_sub_loc_conf_t *slcf = conf; ngx_str_t *value, *pattern; ngx_http_compile_complex_value_t ccv; value = cf->args->elts; pattern = ngx_array_push(slcf->patterns); *pattern = value[1]; ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[2]; ccv.complex_value = ngx_array_push(slcf->values); if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
static char * ngx_http_beanstalkd_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_beanstalkd_loc_conf_t *blcf = conf; ngx_str_t *value; ngx_http_core_loc_conf_t *clcf; ngx_uint_t n; ngx_url_t url; ngx_http_compile_complex_value_t ccv; if (blcf->upstream.upstream || blcf->complex_target) { return "is duplicate"; } clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); clcf->handler = ngx_http_beanstalkd_handler; value = cf->args->elts; n = ngx_http_script_variables_count(&value[1]); if (n) { blcf->complex_target = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (blcf->complex_target == NULL) { return NGX_CONF_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = blcf->complex_target; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; } blcf->complex_target = NULL; ngx_memzero(&url, sizeof(ngx_url_t)); url.url = value[1]; url.no_resolve = 1; blcf->upstream.upstream = ngx_http_upstream_add(cf, &url, 0); if (blcf->upstream.upstream == NULL) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
static char * ngx_http_auth_request_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_auth_request_conf_t *arcf = conf; ngx_str_t *value; ngx_http_variable_t *v; ngx_http_auth_request_variable_t *av; ngx_http_compile_complex_value_t ccv; value = cf->args->elts; if (value[1].data[0] != '$') { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid variable name \"%V\"", &value[1]); return NGX_CONF_ERROR; } value[1].len--; value[1].data++; if (arcf->vars == NGX_CONF_UNSET_PTR) { arcf->vars = ngx_array_create(cf->pool, 1, sizeof(ngx_http_auth_request_variable_t)); if (arcf->vars == NULL) { return NGX_CONF_ERROR; } } av = ngx_array_push(arcf->vars); if (av == NULL) { return NGX_CONF_ERROR; } v = ngx_http_add_variable(cf, &value[1], NGX_HTTP_VAR_CHANGEABLE); if (v == NULL) { return NGX_CONF_ERROR; } av->index = ngx_http_get_variable_index(cf, &value[1]); if (av->index == NGX_ERROR) { return NGX_CONF_ERROR; } if (v->get_handler == NULL) { v->get_handler = ngx_http_auth_request_variable; v->data = (uintptr_t) av; } av->set_handler = v->set_handler; ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[2]; ccv.complex_value = &av->value; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
char * ngx_http_fastcgi_cache_purge_conf(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_compile_complex_value_t ccv; ngx_http_core_loc_conf_t *clcf; ngx_http_fastcgi_loc_conf_t *flcf; ngx_str_t *value; flcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_fastcgi_module); /* check for duplicates / collisions */ if (flcf->upstream.cache != NGX_CONF_UNSET_PTR && flcf->upstream.cache != NULL) { return "is either duplicate or collides with \"fastcgi_cache\""; } if (flcf->upstream.upstream || flcf->fastcgi_lengths) { return "is incompatible with \"fastcgi_pass\""; } if (flcf->upstream.store > 0 || flcf->upstream.store_lengths) { return "is incompatible with \"fastcgi_store\""; } value = cf->args->elts; /* set fastcgi_cache part */ flcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0, &ngx_http_fastcgi_module); if (flcf->upstream.cache == NULL) { return NGX_CONF_ERROR; } /* set fastcgi_cache_key part */ ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[2]; ccv.complex_value = &flcf->cache_key; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } /* set handler */ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); clcf->handler = ngx_http_fastcgi_cache_purge_handler; return NGX_CONF_OK; }
static char * ngx_http_image_filter_sharpen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_image_filter_conf_t *imcf = conf; ngx_str_t *value; ngx_int_t n; ngx_http_complex_value_t cv; ngx_http_compile_complex_value_t ccv; value = cf->args->elts; ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = &cv; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } if (cv.lengths == NULL) { n = ngx_http_image_filter_value(&value[1]); if (n < 0) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid value \"%V\"", &value[1]); return NGX_CONF_ERROR; } imcf->sharpen = (ngx_uint_t) n; } else { imcf->shcv = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (imcf->shcv == NULL) { return NGX_CONF_ERROR; } *imcf->shcv = cv; } return NGX_CONF_OK; }
static char * ngx_http_xrlt_param(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_xrlt_loc_conf_t *xlcf = conf; ngx_http_xrlt_param_t *param; ngx_http_compile_complex_value_t ccv; ngx_str_t *value; value = cf->args->elts; if (xlcf->params == NULL) { xlcf->params = ngx_array_create(cf->pool, 2, sizeof(ngx_http_xrlt_param_t)); if (xlcf->params == NULL) { return NGX_CONF_ERROR; } } param = ngx_array_push(xlcf->params); if (param == NULL) { return NGX_CONF_ERROR; } param->name.data = ngx_pstrdup(cf->pool, &value[1]); if (param->name.data == NULL) { return NGX_CONF_ERROR; } param->name.len = value[1].len; ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[2]; ccv.complex_value = ¶m->value; ccv.zero = 1; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
char * ngx_http_no_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { char *p = conf; ngx_str_t *value; ngx_uint_t i; ngx_array_t **a; ngx_http_complex_value_t *cv; ngx_http_compile_complex_value_t ccv; a = (ngx_array_t **) (p + cmd->offset); if (*a == NGX_CONF_UNSET_PTR) { *a = ngx_array_create(cf->pool, 1, sizeof(ngx_http_complex_value_t)); if (*a == NULL) { return NGX_CONF_ERROR; } } value = cf->args->elts; for (i = 1; i < cf->args->nelts; i++) { cv = ngx_array_push(*a); if (cv == NULL) { return NGX_CONF_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[i]; ccv.complex_value = cv; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } } return NGX_CONF_OK; }
static char * ngx_http_image_water_min(ngx_conf_t *cf, ngx_command_t *cmd,void *conf) { ngx_image_conf_t *info = conf; ngx_str_t *value; ngx_http_complex_value_t cv; ngx_http_compile_complex_value_t ccv; value = cf->args->elts; ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = &cv; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } if (cv.lengths == NULL) { info->water_width_min = (int)ngx_http_image_value(&value[1]); info->water_height_min = (int)ngx_http_image_value(&value[2]); } return NGX_CONF_OK; }
char* ngx_lua_content_readconf(ngx_conf_t* cf, ngx_command_t* cmd, void* conf) { ngx_str_t* value; ngx_http_core_loc_conf_t* pconf; ngx_http_compile_complex_value_t ccv; ngx_lua_loc_conf_t* plocconf = conf; dbg("ngx_lua_content_readconf\n"); value = cf->args->elts; if (value[1].len == 0) { ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "invalid location config: no runable lua code"); return NGX_CONF_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; pconf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); if (ngx_strcmp(cmd->name.data, "lua_content") == 0) { ccv.complex_value = &plocconf->lua_content_code; pconf->handler = ngx_lua_content_handler; } else { ccv.complex_value = &plocconf->lua_content_file; pconf->handler = ngx_lua_content_by_file_handler; } if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { pconf->handler = NULL; ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "invalid location config: ngx_http_compile_complex_value error"); return NGX_CONF_ERROR; } return NGX_CONF_OK; }
static char * ngx_http_drizzle_set_complex_value_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { char *p = conf; ngx_http_complex_value_t **field; ngx_str_t *value; ngx_http_compile_complex_value_t ccv; field = (ngx_http_complex_value_t **) (p + cmd->offset); if (*field) { return "is duplicate"; } *field = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (*field == NULL) { return NGX_CONF_ERROR; } value = cf->args->elts; if (value[1].len == 0) { ngx_memzero(*field, sizeof(ngx_http_complex_value_t)); return NGX_OK; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = *field; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
static char * ngx_http_poller_set(ngx_conf_t *cf, ngx_str_t *value, ngx_http_complex_value_t *complex) { ngx_http_compile_complex_value_t ccv; if (complex->value.data != NULL) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "[poller] duplicate declaration"); return NGX_CONF_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = value; ccv.complex_value = complex; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } return NGX_CONF_OK; }
char * ngx_postgres_conf_query(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value = cf->args->elts; ngx_str_t sql = value[cf->args->nelts - 1]; ngx_postgres_loc_conf_t *pglcf = conf; ngx_http_compile_complex_value_t ccv; ngx_postgres_mixed_t *query; ngx_conf_bitmask_t *b; ngx_uint_t methods, i, j; dd("entering"); if (sql.len == 0) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "postgres: empty query in \"%V\" directive", &cmd->name); dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } if (cf->args->nelts == 2) { /* default query */ dd("default query"); if (pglcf->query.def != NULL) { dd("returning"); return "is duplicate"; } pglcf->query.def = ngx_palloc(cf->pool, sizeof(ngx_postgres_mixed_t)); if (pglcf->query.def == NULL) { dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } methods = 0xFFFF; query = pglcf->query.def; } else { /* method-specific query */ dd("method-specific query"); methods = 0; for (i = 1; i < cf->args->nelts - 1; i++) { b = ngx_postgres_http_methods; for (j = 0; b[j].name.len; j++) { if ((b[j].name.len == value[i].len) && (ngx_strcasecmp(b[j].name.data, value[i].data) == 0)) { if (pglcf->query.methods_set & b[j].mask) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "postgres: method \"%V\" is" " duplicate in \"%V\" directive", &value[i], &cmd->name); dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } methods |= b[j].mask; break; } } if (b[j].name.len == 0) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "postgres: invalid method \"%V\"" " in \"%V\" directive", &value[i], &cmd->name); dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } } if (pglcf->query.methods == NULL) { pglcf->query.methods = ngx_array_create(cf->pool, 4, sizeof(ngx_postgres_mixed_t)); if (pglcf->query.methods == NULL) { dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } } query = ngx_array_push(pglcf->query.methods); if (query == NULL) { dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } pglcf->query.methods_set |= methods; } if (ngx_http_script_variables_count(&sql)) { /* complex value */ dd("complex value"); query->key = methods; query->cv = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (query->cv == NULL) { dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &sql; ccv.complex_value = query->cv; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } } else { /* simple value */ dd("simple value"); query->key = methods; query->sv = sql; query->cv = NULL; } dd("returning NGX_CONF_OK"); return NGX_CONF_OK; }
char * ngx_postgres_conf_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value = cf->args->elts; ngx_postgres_loc_conf_t *pglcf = conf; ngx_http_core_loc_conf_t *clcf; ngx_http_compile_complex_value_t ccv; ngx_url_t url; dd("entering"); if ((pglcf->upstream.upstream != NULL) || (pglcf->upstream_cv != NULL)) { dd("returning"); return "is duplicate"; } if (value[1].len == 0) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "postgres: empty upstream in \"%V\" directive", &cmd->name); dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); clcf->handler = ngx_postgres_handler; if (clcf->name.data[clcf->name.len - 1] == '/') { clcf->auto_redirect = 1; } if (ngx_http_script_variables_count(&value[1])) { /* complex value */ dd("complex value"); pglcf->upstream_cv = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (pglcf->upstream_cv == NULL) { dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = pglcf->upstream_cv; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } dd("returning NGX_CONF_OK"); return NGX_CONF_OK; } else { /* simple value */ dd("simple value"); ngx_memzero(&url, sizeof(ngx_url_t)); url.url = value[1]; url.no_resolve = 1; pglcf->upstream.upstream = ngx_http_upstream_add(cf, &url, 0); if (pglcf->upstream.upstream == NULL) { dd("returning NGX_CONF_ERROR"); return NGX_CONF_ERROR; } dd("returning NGX_CONF_OK"); return NGX_CONF_OK; } }
static ngx_int_t ngx_http_ssl_compile_certificates(ngx_conf_t *cf, ngx_http_ssl_srv_conf_t *conf) { ngx_str_t *cert, *key; ngx_uint_t i, nelts; ngx_http_complex_value_t *cv; ngx_http_compile_complex_value_t ccv; cert = conf->certificates->elts; key = conf->certificate_keys->elts; nelts = conf->certificates->nelts; for (i = 0; i < nelts; i++) { if (ngx_http_script_variables_count(&cert[i])) { goto found; } if (ngx_http_script_variables_count(&key[i])) { goto found; } } return NGX_OK; found: conf->certificate_values = ngx_array_create(cf->pool, nelts, sizeof(ngx_http_complex_value_t)); if (conf->certificate_values == NULL) { return NGX_ERROR; } conf->certificate_key_values = ngx_array_create(cf->pool, nelts, sizeof(ngx_http_complex_value_t)); if (conf->certificate_key_values == NULL) { return NGX_ERROR; } for (i = 0; i < nelts; i++) { cv = ngx_array_push(conf->certificate_values); if (cv == NULL) { return NGX_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &cert[i]; ccv.complex_value = cv; ccv.zero = 1; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_ERROR; } cv = ngx_array_push(conf->certificate_key_values); if (cv == NULL) { return NGX_ERROR; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &key[i]; ccv.complex_value = cv; ccv.zero = 1; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_ERROR; } } conf->passwords = ngx_ssl_preserve_passwords(cf, conf->passwords); if (conf->passwords == NULL) { return NGX_ERROR; } return NGX_OK; }
char * ngx_http_lua_content_by_lua(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value; ngx_http_core_loc_conf_t *clcf; ngx_http_lua_loc_conf_t *llcf = conf; u_char *p; ngx_http_compile_complex_value_t ccv; dd("enter"); /* must specifiy a content handler */ if (cmd->post == NULL) { return NGX_CONF_ERROR; } if (llcf->content_handler) { return "is duplicate"; } value = cf->args->elts; if (value[1].len == 0) { /* Oops...Invalid location conf */ ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "Invalid location config: no runnable Lua code"); return NGX_CONF_ERROR; } if (cmd->post == ngx_http_lua_content_handler_inline) { /* Don't eval nginx variables for inline lua code */ llcf->content_src.value = value[1]; p = ngx_palloc(cf->pool, NGX_HTTP_LUA_INLINE_KEY_LEN + 1); if (p == NULL) { return NGX_CONF_ERROR; } llcf->content_src_key = p; p = ngx_copy(p, NGX_HTTP_LUA_INLINE_TAG, NGX_HTTP_LUA_INLINE_TAG_LEN); p = ngx_http_lua_digest_hex(p, value[1].data, value[1].len); *p = '\0'; } else { ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = &llcf->content_src; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } if (llcf->content_src.lengths == NULL) { /* no variable found */ p = ngx_palloc(cf->pool, NGX_HTTP_LUA_FILE_KEY_LEN + 1); if (p == NULL) { return NGX_CONF_ERROR; } llcf->content_src_key = p; p = ngx_copy(p, NGX_HTTP_LUA_FILE_TAG, NGX_HTTP_LUA_FILE_TAG_LEN); p = ngx_http_lua_digest_hex(p, value[1].data, value[1].len); *p = '\0'; } } llcf->content_handler = cmd->post; /* register location content handler */ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); if (clcf == NULL) { return NGX_CONF_ERROR; } clcf->handler = ngx_http_lua_content_handler; return NGX_CONF_OK; }
char * ngx_http_lua_rewrite_by_lua(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_str_t *value; ngx_http_lua_loc_conf_t *llcf = conf; u_char *p; ngx_http_compile_complex_value_t ccv; dd("enter"); #if defined(nginx_version) && nginx_version >= 8042 && nginx_version <= 8053 return "does not work with " NGINX_VER; #endif /* must specifiy a content handler */ if (cmd->post == NULL) { return NGX_CONF_ERROR; } if (llcf->rewrite_handler) { return "is duplicate"; } value = cf->args->elts; if (value[1].len == 0) { /* Oops...Invalid location conf */ ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "Invalid location config: no runnable Lua code"); return NGX_CONF_ERROR; } if (cmd->post == ngx_http_lua_rewrite_handler_inline) { /* Don't eval nginx variables for inline lua code */ llcf->rewrite_src.value = value[1]; p = ngx_palloc(cf->pool, NGX_HTTP_LUA_INLINE_KEY_LEN + 1); if (p == NULL) { return NGX_CONF_ERROR; } llcf->rewrite_src_key = p; p = ngx_copy(p, NGX_HTTP_LUA_INLINE_TAG, NGX_HTTP_LUA_INLINE_TAG_LEN); p = ngx_http_lua_digest_hex(p, value[1].data, value[1].len); *p = '\0'; } else { ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[1]; ccv.complex_value = &llcf->rewrite_src; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } if (llcf->rewrite_src.lengths == NULL) { /* no variable found */ p = ngx_palloc(cf->pool, NGX_HTTP_LUA_FILE_KEY_LEN + 1); if (p == NULL) { return NGX_CONF_ERROR; } llcf->rewrite_src_key = p; p = ngx_copy(p, NGX_HTTP_LUA_FILE_TAG, NGX_HTTP_LUA_FILE_TAG_LEN); p = ngx_http_lua_digest_hex(p, value[1].data, value[1].len); *p = '\0'; } } llcf->rewrite_handler = cmd->post; if (! ngx_http_lua_requires_rewrite) { ngx_http_lua_requires_rewrite = 1; } return NGX_CONF_OK; }
char * ngx_http_uwsgi_cache_purge_conf(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_compile_complex_value_t ccv; ngx_http_cache_purge_loc_conf_t *cplcf; ngx_http_core_loc_conf_t *clcf; ngx_http_uwsgi_loc_conf_t *ulcf; ngx_str_t *value; cplcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_cache_purge_module); /* check for duplicates / collisions */ if (cplcf->uwsgi.enable != NGX_CONF_UNSET) { return "is duplicate"; } if (cf->args->nelts != 3) { return ngx_http_cache_purge_conf(cf, &cplcf->uwsgi); } if (cf->cmd_type & (NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF)) { return "(separate location syntax) is not allowed here"; } ulcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_uwsgi_module); if (ulcf->upstream.cache != NGX_CONF_UNSET_PTR && ulcf->upstream.cache != NULL) { return "is incompatible with \"uwsgi_cache\""; } if (ulcf->upstream.upstream || ulcf->uwsgi_lengths) { return "is incompatible with \"uwsgi_pass\""; } if (ulcf->upstream.store > 0 || ulcf->upstream.store_lengths) { return "is incompatible with \"uwsgi_store\""; } value = cf->args->elts; /* set uwsgi_cache part */ ulcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0, &ngx_http_uwsgi_module); if (ulcf->upstream.cache == NULL) { return NGX_CONF_ERROR; } /* set uwsgi_cache_key part */ ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[2]; ccv.complex_value = &ulcf->cache_key; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } /* set handler */ clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module); cplcf->uwsgi.enable = 0; clcf->handler = ngx_http_uwsgi_cache_purge_handler; return NGX_CONF_OK; }
//redis2_query static char * ngx_http_redis2_query(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_redis2_loc_conf_t *rlcf = conf; ngx_str_t *value; ngx_array_t **query; ngx_uint_t n; ngx_http_complex_value_t **arg; ngx_uint_t i; ngx_http_compile_complex_value_t ccv; if (rlcf->literal_query.len) { return "conflicts with redis2_literal_raw_query"; } if (rlcf->complex_query) { return "conflicts with redis2_raw_query"; } if (rlcf->queries == NULL) { rlcf->queries = ngx_array_create(cf->pool, 1, sizeof(ngx_array_t *)); if (rlcf->queries == NULL) { return NGX_CONF_ERROR; } } query = ngx_array_push(rlcf->queries); if (query == NULL) { return NGX_CONF_ERROR; } n = cf->args->nelts - 1; *query = ngx_array_create(cf->pool, n, sizeof(ngx_http_complex_value_t *)); if (*query == NULL) { return NGX_CONF_ERROR; } value = cf->args->elts; for (i = 1; i <= n; i++) { arg = ngx_array_push(*query); if (arg == NULL) { return NGX_CONF_ERROR; } *arg = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); if (*arg == NULL) { return NGX_CONF_ERROR; } if (value[i].len == 0) { ngx_memzero(*arg, sizeof(ngx_http_complex_value_t)); continue; } ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); ccv.cf = cf; ccv.value = &value[i]; ccv.complex_value = *arg; if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { return NGX_CONF_ERROR; } } return NGX_CONF_OK; }