293
ngx_http_conf_ctx_t *
294
ndk_conf_create_http_location (ngx_conf_t *cf)
296
ngx_http_conf_ctx_t *ctx, *pctx;
298
ngx_http_core_loc_conf_t *clcf, *pclcf;
300
ngx_http_module_t *module;
302
ndk_pcallocp_rce (ctx, cf->pool);
305
ctx->main_conf = pctx->main_conf;
306
ctx->srv_conf = pctx->srv_conf;
308
ndk_pcalloc_rce (ctx->loc_conf, cf->pool, sizeof(void *) * ngx_http_max_module);
311
for (i = 0; ngx_modules[i]; i++) {
312
if (ngx_modules[i]->type != NGX_HTTP_MODULE) {
316
module = ngx_modules[i]->ctx;
318
if (module->create_loc_conf) {
320
mconf = module->create_loc_conf(cf);
322
return NGX_CONF_ERROR;
325
ctx->loc_conf[ngx_modules[i]->ctx_index] = mconf;
329
pclcf = pctx->loc_conf[ngx_http_core_module.ctx_index];
331
clcf = ctx->loc_conf[ngx_http_core_module.ctx_index];
332
clcf->loc_conf = ctx->loc_conf;
333
clcf->name = pclcf->name;
336
if (ngx_http_add_location(cf, &pclcf->locations, clcf) != NGX_OK) {
337
return NGX_CONF_ERROR;
344
ngx_http_conf_ctx_t *
345
ngx_conf_create_http_named_location (ngx_conf_t *cf, ngx_str_t *name)
347
ngx_http_conf_ctx_t *ctx;
348
ngx_http_core_loc_conf_t *clcf;
350
ctx = ndk_conf_create_http_location (cf);
351
if (ctx == NGX_CONF_ERROR)
352
return NGX_CONF_ERROR;
354
clcf = ctx->loc_conf[ngx_http_core_module.ctx_index];
356
// in case the developer forgets to add '@' at the beginning of the named location
358
if (name->data[0] != '@' && ndk_catstrf (cf->pool, name, "sS", "@", name) == NULL)
359
return NGX_CONF_ERROR;
361
clcf->name = *name; // TODO : copy?
370
ndk_replace_command (ngx_command_t *new_cmd, ngx_uint_t module_type)
375
for (i = 0; ngx_modules[i]; i++) {
377
if (ngx_modules[i]->type != module_type)
380
cmd = ngx_modules[i]->commands;
385
for ( /* void */ ; cmd->name.len; cmd++) {
387
if (ndk_cmpstr (&new_cmd->name, &cmd->name) == 0) {
389
ndk_memcpyp (cmd, new_cmd);
b'\\ No newline at end of file'