static char *flaxton_logger_log_level(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_str_t *value;
    value = cf->args->elts;
    if(ngx_strcasecmp((u_char*)"full", value[1].data) == 0)
    {
        flaxton_logger.logging_level = LOG_FULL_REQUEST;
    }
    else
    {
        if(ngx_strcasecmp((u_char*)"headers", value[1].data) == 0)
        {
            flaxton_logger.logging_level = LOG_HEADERS;
        }
        else
        {
            if(ngx_strcasecmp((u_char*)"body", value[1].data) == 0)
            {
                flaxton_logger.logging_level = LOG_BODY;
            }
        }
    }

    return NGX_CONF_OK;
}
static char* ngx_http_gridfs_type(ngx_conf_t* directive, ngx_command_t* command, void* void_conf) {
    ngx_http_gridfs_loc_conf_t* gridfs_conf = void_conf; 
    ngx_str_t* value; 
    
    value = directive->args->elts;

    if (value[1].len == 0) {
      gridfs_conf->gridfs_type = NGX_CONF_UNSET_UINT;
    }
    else if (ngx_strcasecmp(value[1].data, (u_char *)"objectid") == 0) {
      gridfs_conf->gridfs_type = bson_oid;
    }
    else if (ngx_strcasecmp(value[1].data, (u_char *)"string") == 0) {
      gridfs_conf->gridfs_type = bson_string;
    }
    else if (ngx_strcasecmp(value[1].data, (u_char *)"int") == 0) {
      gridfs_conf->gridfs_type = bson_string;
    }
    else {
      /* Currently only support for "objectid", "string", and "int" */ 
      ngx_conf_log_error(NGX_LOG_EMERG, directive, 0, 
			 "Unsupported Type: %s", (char *)value[1].data);
      return NGX_CONF_ERROR;
    }
    
    return NGX_CONF_OK;
}
char *
ngx_http_lua_rewrite_no_postpone(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_http_lua_main_conf_t    *lmcf = conf;
    ngx_str_t                   *value;
    ngx_int_t                   fp;

    value = cf->args->elts;


    if (ngx_strcasecmp(value[1].data, (u_char *) "on") == 0) {
        fp = 1;

    } else if (ngx_strcasecmp(value[1].data, (u_char *) "off") == 0) {
        fp = 0;

    } else {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                     "invalid value \"%s\" in \"%s\" directive, "
                     "it must be \"on\" or \"off\"",
                     value[1].data, cmd->name.data);
        return NGX_CONF_ERROR;
    }

    lmcf->postponed_to_rewrite_phase_end = fp;

    return NGX_CONF_OK;
}
示例#4
0
static char *
ngx_http_vod_segment_count_policy_command(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
	ngx_http_vod_loc_conf_t    *vod_conf = conf;
	ngx_str_t                       *value;

	value = cf->args->elts;

	if (ngx_strcasecmp(value[1].data, (u_char *) "last_short") == 0)
	{
		vod_conf->segmenter.get_segment_count = segmenter_get_segment_count_last_short;
	}
	else if (ngx_strcasecmp(value[1].data, (u_char *) "last_long") == 0)
	{
		vod_conf->segmenter.get_segment_count = segmenter_get_segment_count_last_long;
	}
	else if (ngx_strcasecmp(value[1].data, (u_char *) "last_rounded") == 0)
	{
		vod_conf->segmenter.get_segment_count = segmenter_get_segment_count_last_rounded;
	}
	else
	{
		ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
			"invalid value \"%s\" in \"%s\" directive, "
			"it must be \"last_short\", \"last_long\" or \"last_rounded\"",
			value[1].data, cmd->name.data);
		return NGX_CONF_ERROR;
	}

	return NGX_CONF_OK;
}
示例#5
0
static char *
ngx_http_vod_mode_command(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
	ngx_http_vod_loc_conf_t    *vod_conf = conf;
	ngx_str_t                       *value;

	value = cf->args->elts;

	if (ngx_strcasecmp(value[1].data, (u_char *) "local") == 0) 
	{
		vod_conf->request_handler = ngx_http_vod_local_request_handler;
	}
	else if (ngx_strcasecmp(value[1].data, (u_char *) "remote") == 0) 
	{
		vod_conf->request_handler = ngx_http_vod_remote_request_handler;
	}
	else if (ngx_strcasecmp(value[1].data, (u_char *) "mapped") == 0) 
	{
		vod_conf->request_handler = ngx_http_vod_mapped_request_handler;
	}
	else 
	{
		ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
			"invalid value \"%s\" in \"%s\" directive, "
			"it must be \"local\", \"remote\" or \"mapped\"",
			value[1].data, cmd->name.data);
		return NGX_CONF_ERROR;
	}

	return NGX_CONF_OK;
}
示例#6
0
static char *
ngx_http_vod_manifest_segment_durations_mode_command(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
	ngx_http_vod_loc_conf_t    *vod_conf = conf;
	ngx_str_t                       *value;

	value = cf->args->elts;

	if (ngx_strcasecmp(value[1].data, (u_char *) "estimate") == 0)
	{
		vod_conf->segmenter.get_segment_durations = segmenter_get_segment_durations_estimate;
	}
	else if (ngx_strcasecmp(value[1].data, (u_char *) "accurate") == 0)
	{
		vod_conf->segmenter.get_segment_durations = segmenter_get_segment_durations_accurate;
	}
	else
	{
		ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
			"invalid value \"%s\" in \"%s\" directive, "
			"it must be \"estimate\" or \"accurate\"",
			value[1].data, cmd->name.data);
		return NGX_CONF_ERROR;
	}

	return NGX_CONF_OK;
}
static ngx_table_elt_t *
search_headers_in(ngx_http_request_t *r, u_char *name, size_t len)
{
	ngx_list_part_t            *part;
	ngx_table_elt_t            *h;
	ngx_uint_t                  i;

	part = &r->headers_in.headers.part;
	h = part->elts;

	// Headers array may consist of more than one part, so loop throgh all of them
	for (i = 0; ; i++) {
		if (i >= part->nelts) {
			if (part->next == NULL) {
				break;
			}

			part = part->next;
			h = part->elts;
			i = 0;
		}

		// Compare names case insensitively
		if (len != h[i].key.len || ngx_strcasecmp(name, h[i].key.data) != 0) {
			continue;
		}

		// Found it
		return &h[i];
	}

	// no header was found
	return NULL;
}
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;
}
示例#9
0
/*
 * 设置配置中的 enum slot
 */
char *
ngx_conf_set_enum_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    char  *p = conf;

    ngx_uint_t       *np, i;
    ngx_str_t        *value;
    ngx_conf_enum_t  *e;

    np = (ngx_uint_t *) (p + cmd->offset);

    if (*np != NGX_CONF_UNSET_UINT) {
        return "is duplicate";
    }

    value = cf->args->elts;
    e = cmd->post;

    for (i = 0; e[i].name.len != 0; i++) {
        if (e[i].name.len != value[1].len
            || ngx_strcasecmp(e[i].name.data, value[1].data) != 0)
        {
            continue;
        }

        *np = e[i].value;

        return NGX_CONF_OK;
    }

    ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
                       "invalid value \"%s\"", value[1].data);

    return NGX_CONF_ERROR;
}
static char *
ngx_http_poller_add_header(ngx_conf_t *cf,
			   ngx_http_poller_t *poller,
			   ngx_str_t *name,
			   ngx_str_t *value)
{
  ngx_http_poller_header_t *header;

  header = ngx_array_push(&poller->headers);
  if (header == NULL) {
    return NGX_CONF_ERROR;
  }

  if (ngx_strcasecmp(name->data, (u_char *)"Content-Length") == 0) {
    ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
		       "[poller] %V: Content-Length header may not be set",
		       &poller->name);
    return NGX_CONF_ERROR;
  }

  header->name = *name;
  ngx_memzero(&header->value, sizeof(ngx_http_complex_value_t));

  return ngx_http_poller_set(cf, value, &header->value);
}
示例#11
0
static char *
ngx_tcp_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_tcp_core_srv_conf_t *cscf = conf;

    ngx_str_t               *value;
    ngx_uint_t               i;
    ngx_tcp_server_name_t   *sn;

    value = cf->args->elts;

    for (i = 1; i < cf->args->nelts; i++) {

        sn = ngx_array_push(&cscf->server_names);
        if (sn == NULL) {
            return NGX_CONF_ERROR;
        }

        if (ngx_strcasecmp(value[i].data, (u_char *) "$hostname") == 0) {
            sn->name = cf->cycle->hostname;

        } else {
            sn->name = value[i];
        }
    }

    return NGX_CONF_OK;
}
ngx_int_t
ngx_http_request_parser_headers_value(ngx_http_request_t *r, u_char *name, size_t len, ngx_str_t* value) {
    ngx_list_part_t *part;
    ngx_table_elt_t *h;
    ngx_uint_t i;
    part = &r->headers_in.headers.part;
    h = part->elts;
    for (i = 0; /* void */; i++) {
        if (i >= part->nelts) {
            if (part->next == NULL) {
                /* The last part, search is done. */
                break;
            }

            part = part->next;
            h = part->elts;
            i = 0;
        }
        if (len != h[i].key.len || ngx_strcasecmp(name, h[i].key.data) != 0) {
            continue;
        }
        value->data = h[i].value.data;
        value->len = h[i].value.len;
        return NGX_OK;
    }
    return NGX_DECLINED;
}
示例#13
0
char *ngx_conf_set_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    char  *p = conf;

    ngx_str_t        *value;
    ngx_flag_t       *fp;
    ngx_conf_post_t  *post;

    fp = (ngx_flag_t *) (p + cmd->offset);

    if (*fp != NGX_CONF_UNSET)
    {
        return "is duplicate";
    }

    value = cf->args->elts;

    if (ngx_strcasecmp(value[1].data, "on") == 0)
    {
        *fp = 1;

    }
    else if (ngx_strcasecmp(value[1].data, "off") == 0)
    {
        *fp = 0;

    }
    else
    {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "invalid value \"%s\" in \"%s\" directive, "
                           "it must be \"on\" or \"off\"",
                           value[1].data, cmd->name.data);
        return NGX_CONF_ERROR;
    }

    if (cmd->post)
    {
        post = cmd->post;
        return post->post_handler(cf, post, fp);
    }

    return NGX_CONF_OK;
}
示例#14
0
static char *
passenger_enabled(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    passenger_loc_conf_t        *passenger_conf = conf;
    ngx_http_core_loc_conf_t    *clcf;
    ngx_str_t                   *value;
    ngx_url_t                    upstream_url;

    value = cf->args->elts;
    if (ngx_strcasecmp(value[1].data, (u_char *) "on") == 0) {
        passenger_conf->enabled = 1;
        
        /* Register a placeholder value as upstream address. The real upstream
         * address (the helper agent socket filename) will be set while processing
         * requests, because we can't start the helper agent until config
         * loading is done.
         */
        ngx_memzero(&upstream_url, sizeof(ngx_url_t));
        upstream_url.url = pp_placeholder_upstream_address;
        upstream_url.no_resolve = 1;
        passenger_conf->upstream_config.upstream = ngx_http_upstream_add(cf, &upstream_url, 0);
        if (passenger_conf->upstream_config.upstream == NULL) {
            return NGX_CONF_ERROR;
        }
        
        clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
        clcf->handler = passenger_content_handler;

        if (clcf->name.data != NULL
         && clcf->name.data[clcf->name.len - 1] == '/') {
            clcf->auto_redirect = 1;
        }
    } else if (ngx_strcasecmp(value[1].data, (u_char *) "off") == 0) {
        passenger_conf->enabled = 0;
    } else {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
            "\"passenger_enabled\" must be either set to \"on\" "
            "or \"off\"");

        return NGX_CONF_ERROR;
    }

    return NGX_CONF_OK;
}
static char *flaxton_logger_turn_on_off(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_str_t *value;
    value = cf->args->elts;
    if(ngx_strcasecmp((u_char*)"on", value[1].data) == 0)
    {
        flaxton_logger.is_active = 1;
    }
    else
        if(ngx_strcasecmp((u_char*)"off", value[1].data) == 0)
        {
            flaxton_logger.is_active = 0;
        }
        else
            return NGX_CONF_ERROR;


    return NGX_CONF_OK;
}
static char *
ngx_http_prelog_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {

    ngx_uint_t                  i;
    ngx_str_t                  *value, name;
    ngx_http_log_main_conf_t   *lmcf;
    ngx_http_log_fmt_t         *fmt;

    ngx_http_prelog_loc_conf_t *preloglc = conf;
    value = cf->args->elts;

    /* prelog off; */
    if (ngx_strcmp(value[1].data, "off") == 1) {
        preloglc->enable = 0;
        if (cf->args->nelts == 2) {
            return NGX_CONF_OK;
        }

        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "invalid parameter \"%V\"", &value[2]);
        return NGX_CONF_ERROR;
    } else {
        preloglc->enable = 1;
    }

    /* prelog path; */

    preloglc->file = ngx_conf_open_file(cf->cycle, &value[1]);
    if (preloglc->file == NULL) {
        return NGX_CONF_ERROR;
    }

    /* prelog path format; */
    if (cf->args->nelts == 3) {
        name = value[2];
    } else {
        ngx_str_set(&name, "combined");
    }

    lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
    fmt = lmcf->formats.elts;
    for (i = 0; i < lmcf->formats.nelts; i++) {
        if (fmt[i].name.len == name.len
            && ngx_strcasecmp(fmt[i].name.data, name.data) == 0)
        {
            preloglc->format = &fmt[i];
            return NGX_CONF_OK;
        }
    }

    ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                       "unknown log format \"%V\"", &name);
    return NGX_CONF_ERROR;
}
static char *
ngx_http_traffic_status_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
	ngx_uint_t    i;
	ngx_str_t    *value;
	ngx_http_core_loc_conf_t  *clcf = NULL;
	ngx_http_traffic_status_local_conf_t *tslc = conf;

	value = cf->args->elts;
	for (i = 1; i < cf->args->nelts; i++)
	{
	    if (ngx_strcasecmp(value[i].data, (u_char *) "request_times") == 0) 
		{
	        tslc->req_flag = 1;
			continue;
	    } 
		else if (ngx_strcasecmp(value[i].data, (u_char *) "packet_bytes") == 0) 
		{
			tslc->pkt_flag = 1;
			continue;
	    } 
		else if (ngx_strcasecmp(value[i].data, (u_char *) "status_codes") == 0) 
		{
			tslc->status_flag = 1;
			continue;
	    } 
		else
		{
	        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
				"invalid value \"%s\" in \"%s\" directive",
				value[i].data, cmd->name.data);
        	return NGX_CONF_ERROR;
		}
	}

    clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
    clcf->handler = ngx_http_traffic_status_handler;

	return NGX_CONF_OK;
}
/**
 * Brute force search for one header with the specified name.
 */
static ngx_table_elt_t *
ngx_apikey_find_request_header(ngx_http_request_t *r, u_char *name, size_t len) {

    ngx_list_part_t            *part;
    ngx_table_elt_t            *h;
    ngx_uint_t                  i;
 
    /*
    Get the first part of the list. There is usual only one part.
    */
    part = &r->headers_in.headers.part;
    h = part->elts;
 
    /*
    Headers list array may consist of more than one part,
    so loop through all of it
    */
    for (i = 0; /* void */ ; i++) {
        if (i >= part->nelts) {
            if (part->next == NULL) {
                /* The last part, search is done. */
                break;
            }
 
            part = part->next;
            h = part->elts;
            i = 0;
        }
 
        /*
        Just compare the lengths and then the names case insensitively.
        */
		//ngx_log_debug( NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "found request header ( %s ) with value ( %s )", h[i].key.data, h[i].value.data );

        if (len != h[i].key.len || ngx_strcasecmp(name, h[i].key.data) != 0) {
            /* This header doesn't match. */
            continue;
        }
 
        /*
        Ta-da, we got one!
        Note, we'v stop the search at the first matched header
        while more then one header may fit.
        */
        return &h[i];
    }
 
    /*
    No headers was found
    */
    return NULL;
}
static char *
ngx_http_trackuri(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_http_trackuri_loc_conf_t *flcf = conf;

    if (flcf->track_uri != NGX_CONF_UNSET) {
        return "is duplicate";
    }

    ngx_str_t        *value = cf->args->elts;

    if (ngx_strcasecmp(value[1].data, (u_char *) "on") == 0) {
        flcf->track_uri = 1;
    } else if (ngx_strcasecmp(value[1].data, (u_char *) "off") == 0) {
        flcf->track_uri = 0;
    } else {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "invalid value \"%s\" in \"%s\" directive, "
                           "it must be \"on\" or \"off\"",
                           value[1].data, cmd->name.data);
        return NGX_CONF_ERROR;
    }

    if (flcf->track_uri == 1)
    {
        ngx_http_core_loc_conf_t   *clcf;
        clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
        clcf->handler = ngx_http_trackuri_handler;

        // initialize uri_table to start tracking popular uris
        if (!ngx_uri_table_init(cf->pool, cf->log, &flcf->uri_table))
            return NGX_CONF_ERROR;
        ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
                           "Initialized hash table of size: \"%d\"",
                           flcf->uri_table.hash_table->size);
    }

    return NGX_CONF_OK;
}
static char *
ngx_http_image(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
	ngx_str_t        *value;
	value = cf->args->elts;
	if (ngx_strcasecmp(value[1].data, (u_char *) "on") == 0)
	{
		ngx_http_core_loc_conf_t  *clcf;
		clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
		clcf->handler = ngx_http_image_handler;
		return NGX_CONF_OK;
	}
	else if (ngx_strcasecmp(value[1].data, (u_char *) "off") == 0)
	{
		return NGX_CONF_OK;
	}
	else
	{
		ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,"invalid value \"%s\" in \"%s\" directive, ""it must be \"on\" or \"off\"",value[1].data, cmd->name.data);
		return NGX_CONF_ERROR;
	}
	return NGX_CONF_OK;
}
示例#21
0
static char *nchan_store_messages_directive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) {
  char    *p = conf;
  ngx_str_t *val = cf->args->elts;

  
  if (ngx_strcasecmp(val[1].data, (u_char *) "off") == 0) {
    ngx_int_t *min, *max;
    min = (ngx_int_t *) (p + offsetof(nchan_loc_conf_t, min_messages));
    max = (ngx_int_t *) (p + offsetof(nchan_loc_conf_t, max_messages));
    *min=0;
    *max=0;
  }
  return NGX_CONF_OK;
}
static char *
ngx_http_ip2location_access_type(ngx_conf_t *cf, void *data, void *conf)
{
    ngx_http_ip2location_main_conf_t  *imcf;
    ngx_str_t                          value;

    imcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_ip2location_module);

    value = *((ngx_str_t *)conf);

    if (ngx_strcasecmp((u_char *)"file_io", value.data) == 0) {
        imcf->access_type = IP2LOCATION_FILE_IO;
    } else if (ngx_strcasecmp((u_char *)"cache_memory", value.data) == 0) {
        imcf->access_type = IP2LOCATION_CACHE_MEMORY;
    } else if (ngx_strcasecmp((u_char *)"shared_memory", value.data) == 0) {
        imcf->access_type = IP2LOCATION_SHARED_MEMORY;
    } else {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "unkown access type \"%V\"", &value);
        return NGX_CONF_ERROR;
    }

    return NGX_CONF_OK;
}
示例#23
0
char *
ndk_conf_set_num_flag_slot (ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    char  *p = conf;

    ngx_int_t        *np;
    ngx_str_t        *value;
    ngx_conf_post_t  *post;

    np = (ngx_int_t *) (p + cmd->offset);

    if (*np != NGX_CONF_UNSET) {
        return  "is duplicate";
    }

    value = cf->args->elts;

    if (ngx_strcasecmp (value[1].data, (u_char *) "on") == 0) {
        *np = NDK_CONF_SET_TRUE;

    } else if (ngx_strcasecmp (value[1].data, (u_char *) "off") == 0) {
        *np = NDK_CONF_SET_FALSE;

    } else {
        *np = ngx_atoi (value[1].data, value[1].len);
        if (*np == NGX_ERROR) {
            return  "invalid number and not 'on'/'off'";
        }
    }

    if (cmd->post) {
        post = cmd->post;
        return  post->post_handler (cf, post, np);
    }

    return  NGX_CONF_OK;
}
示例#24
0
char *
ndk_conf_set_sec_flag_slot (ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    char  *p = conf;

    time_t              *tp;
    ngx_str_t           *value;
    ngx_conf_post_t     *post;

    tp = (time_t *) (p + cmd->offset);

    if (*tp != NGX_CONF_UNSET) {
        return  "is duplicate";
    }

    value = cf->args->elts;

    if (ngx_strcasecmp (value[1].data, (u_char *) "on") == 0) {
        *tp = NDK_CONF_SET_TRUE;

    } else if (ngx_strcasecmp (value[1].data, (u_char *) "off") == 0) {
        *tp = NDK_CONF_SET_FALSE;

    } else {
        *tp = ngx_parse_time (&value[1], 1);
        if (*tp == NGX_ERROR) {
            return  "has an invalid time and not 'on'/'off'";
        }
    }

    if (cmd->post) {
        post = cmd->post;
        return  post->post_handler (cf, post, tp);
    }

    return  NGX_CONF_OK;
}
示例#25
0
char *ngx_conf_set_bitmask_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    char  *p = conf;

    ngx_uint_t          *np, i, m;
    ngx_str_t           *value;
    ngx_conf_bitmask_t  *mask;


    np = (ngx_uint_t *) (p + cmd->offset);
    value = cf->args->elts;
    mask = cmd->post;

    for (i = 1; i < cf->args->nelts; i++)
    {
        for (m = 0; mask[m].name.len != 0; m++)
        {

            if (mask[m].name.len != value[i].len
                    || ngx_strcasecmp(mask[m].name.data, value[i].data) != 0)
            {
                continue;
            }

            if (*np & mask[m].mask)
            {
                ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
                                   "duplicate value \"%s\"", value[i].data);

            }
            else
            {
                *np |= mask[m].mask;
            }

            break;
        }

        if (mask[m].name.len == 0)
        {
            ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
                               "invalid value \"%s\"", value[i].data);

            return NGX_CONF_ERROR;
        }
    }

    return NGX_CONF_OK;
}
static char *
ngx_http_return_uristats(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    ngx_http_trackuri_loc_conf_t *flcf = conf;

    if (flcf->return_uri_stats != NGX_CONF_UNSET) {
        return "is duplicate";
    }

    ngx_str_t        *value = cf->args->elts;

    if (ngx_strcasecmp(value[1].data, (u_char *) "on") == 0) {
        flcf->return_uri_stats = 1;
    } else if (ngx_strcasecmp(value[1].data, (u_char *) "off") == 0) {
        flcf->return_uri_stats = 0;
    } else {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "invalid value \"%s\" in \"%s\" directive, "
                           "it must be \"on\" or \"off\"",
                           value[1].data, cmd->name.data);
        return NGX_CONF_ERROR;
    }

    if (flcf->return_uri_stats)
    {
        if (!flcf->track_uri)
        {
            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                               "\"%s\" directive is set, but popular_uri_track directive is not set",
                               cmd->name.data);
            return NGX_CONF_ERROR;
        }
    }

    return NGX_CONF_OK;
}
示例#27
0
static char *
passenger_enabled(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
    passenger_loc_conf_t        *lcf = conf;

    ngx_url_t                    u;
    ngx_http_core_loc_conf_t    *clcf;
    ngx_str_t                   *value;

    value = cf->args->elts;
    if (ngx_strcasecmp(value[1].data, (u_char *) "on") == 0) {
#if NGINX_VERSION_NUM < 7000
        if (lcf->upstream.schema.len) {
            return "is duplicate";
        }
#endif

        lcf->enabled = 1;

        ngx_memzero(&u, sizeof(ngx_url_t));
        u.url.data = (u_char *) passenger_helper_server_socket;
        u.url.len  = strlen(passenger_helper_server_socket);
        u.no_resolve = 1;

        lcf->upstream.upstream = ngx_http_upstream_add(cf, &u, 0);
        if (lcf->upstream.upstream == NULL) {
            return NGX_CONF_ERROR;
        }

#if NGINX_VERSION_NUM < 7000
        lcf->upstream.schema = passenger_schema_string;
#endif

        clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);
        clcf->handler = passenger_content_handler;

        if (clcf->name.data != NULL
                && clcf->name.data[clcf->name.len - 1] == '/') {
            clcf->auto_redirect = 1;
        }
    } else {
        lcf->enabled = 0;
    }

    return NGX_CONF_OK;
}
char *
ngx_postgres_conf_output(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_postgres_output_enum_t  *e;
    ngx_uint_t                   i;

    dd("entering");

    if (pglcf->output_handler != NGX_CONF_UNSET_PTR) {
        dd("returning");
        return "is duplicate";
    }

    e = ngx_postgres_output_handlers;
    for (i = 0; e[i].name.len; i++) {
        if ((e[i].name.len == value[1].len)
            && (ngx_strcasecmp(e[i].name.data, value[1].data) == 0))
        {
            pglcf->output_handler = e[i].handler;
            break;
        }
    }

    if (e[i].name.len == 0) {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "postgres: invalid output format \"%V\""
                           " in \"%V\" directive", &value[1], &cmd->name);

        dd("returning NGX_CONF_ERROR");
        return NGX_CONF_ERROR;
    }

    pglcf->output_binary = e[i].binary;

    dd("returning NGX_CONF_OK");
    return NGX_CONF_OK;
}
static char *
ngx_http_google_inject(ngx_conf_t   * cf,
                       ngx_module_t * md,
                       void         * lcf,
                       const char   * k,
                       const int      n,
                       va_list       ap)
{
  ngx_array_t * swap = cf->args;
  cf->args = NULL;
  
  // push command first
  if (ngx_http_google_injcet_args(cf, &cf->args, k)) {
    cf->args = swap;
    return NGX_CONF_ERROR;
  }
  
  int i;
  const char * arg;
  for (i = 0; i < n; i++) {
    arg = va_arg(ap, const char *);
    if (ngx_http_google_injcet_args(cf, &cf->args, arg)) {
      cf->args = swap;
      return NGX_CONF_ERROR;
    }
  }
  
  ngx_command_t * cmd;
  for (cmd = md->commands; cmd->name.len; cmd++) {
    if (!cmd->name.len) continue;
    if (ngx_strcasecmp(cmd->name.data, (u_char *)k)) continue;
    cmd->set(cf, cmd, lcf);
    break;
  }
  cf->args = swap;
  
  return NGX_CONF_OK;
}
示例#30
0
/*
 * this function is slow for iterate all headers so it should be only used to get unknown headers
 */
static jlong JNICALL jni_ngx_http_clojure_mem_get_header(JNIEnv *env, jclass cls, jlong headers_in, jlong name, jlong len) {
    ngx_list_part_t *part = &((ngx_http_headers_in_t *) headers_in)->headers.part;
    ngx_table_elt_t *h = part->elts;
    ngx_uint_t i = 0;

    for (i = 0; /* void */ ; i++) {
        if (i >= part->nelts) {
            if (part->next == NULL) {
                break;
            }

            part = part->next;
            h = part->elts;
            i = 0;
        }

        if ((size_t)len != h[i].key.len || ngx_strcasecmp((u_char *)name, h[i].key.data) != 0) {
            continue;
        }
        return (uintptr_t)&h[i];
    }
    return 0;
}