mirror of
https://github.com/nginx/nginx.git
synced 2025-06-07 17:52:38 +08:00
Browser: style.
Removed custom variable type and renamed function that adds variables.
This commit is contained in:
parent
aa953f5346
commit
83be971bc7
@ -37,13 +37,6 @@ typedef struct {
|
|||||||
} ngx_http_modern_browser_t;
|
} ngx_http_modern_browser_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
ngx_str_t name;
|
|
||||||
ngx_http_get_variable_pt handler;
|
|
||||||
uintptr_t data;
|
|
||||||
} ngx_http_browser_variable_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ngx_array_t *modern_browsers;
|
ngx_array_t *modern_browsers;
|
||||||
ngx_array_t *ancient_browsers;
|
ngx_array_t *ancient_browsers;
|
||||||
@ -63,7 +56,7 @@ static ngx_int_t ngx_http_browser_variable(ngx_http_request_t *r,
|
|||||||
static ngx_uint_t ngx_http_browser(ngx_http_request_t *r,
|
static ngx_uint_t ngx_http_browser(ngx_http_request_t *r,
|
||||||
ngx_http_browser_conf_t *cf);
|
ngx_http_browser_conf_t *cf);
|
||||||
|
|
||||||
static ngx_int_t ngx_http_browser_add_variable(ngx_conf_t *cf);
|
static ngx_int_t ngx_http_browser_add_variables(ngx_conf_t *cf);
|
||||||
static void *ngx_http_browser_create_conf(ngx_conf_t *cf);
|
static void *ngx_http_browser_create_conf(ngx_conf_t *cf);
|
||||||
static char *ngx_http_browser_merge_conf(ngx_conf_t *cf, void *parent,
|
static char *ngx_http_browser_merge_conf(ngx_conf_t *cf, void *parent,
|
||||||
void *child);
|
void *child);
|
||||||
@ -114,7 +107,7 @@ static ngx_command_t ngx_http_browser_commands[] = {
|
|||||||
|
|
||||||
|
|
||||||
static ngx_http_module_t ngx_http_browser_module_ctx = {
|
static ngx_http_module_t ngx_http_browser_module_ctx = {
|
||||||
ngx_http_browser_add_variable, /* preconfiguration */
|
ngx_http_browser_add_variables, /* preconfiguration */
|
||||||
NULL, /* postconfiguration */
|
NULL, /* postconfiguration */
|
||||||
|
|
||||||
NULL, /* create main configuration */
|
NULL, /* create main configuration */
|
||||||
@ -218,13 +211,18 @@ static ngx_http_modern_browser_mask_t ngx_http_modern_browser_masks[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static ngx_http_browser_variable_t ngx_http_browsers[] = {
|
static ngx_http_variable_t ngx_http_browser_vars[] = {
|
||||||
{ ngx_string("msie"), ngx_http_msie_variable, 0 },
|
|
||||||
{ ngx_string("modern_browser"), ngx_http_browser_variable,
|
{ ngx_string("msie"), NULL, ngx_http_msie_variable,
|
||||||
NGX_HTTP_MODERN_BROWSER },
|
0, NGX_HTTP_VAR_CHANGEABLE, 0 },
|
||||||
{ ngx_string("ancient_browser"), ngx_http_browser_variable,
|
|
||||||
NGX_HTTP_ANCIENT_BROWSER },
|
{ ngx_string("modern_browser"), NULL, ngx_http_browser_variable,
|
||||||
{ ngx_null_string, NULL, 0 }
|
NGX_HTTP_MODERN_BROWSER, NGX_HTTP_VAR_CHANGEABLE, 0 },
|
||||||
|
|
||||||
|
{ ngx_string("ancient_browser"), NULL, ngx_http_browser_variable,
|
||||||
|
NGX_HTTP_ANCIENT_BROWSER, NGX_HTTP_VAR_CHANGEABLE, 0 },
|
||||||
|
|
||||||
|
{ ngx_null_string, NULL, NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -397,20 +395,19 @@ ngx_http_msie_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
|||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_http_browser_add_variable(ngx_conf_t *cf)
|
ngx_http_browser_add_variables(ngx_conf_t *cf)
|
||||||
{
|
{
|
||||||
ngx_http_browser_variable_t *var;
|
ngx_http_variable_t *var, *v;
|
||||||
ngx_http_variable_t *v;
|
|
||||||
|
|
||||||
for (var = ngx_http_browsers; var->name.len; var++) {
|
for (v = ngx_http_browser_vars; v->name.len; v++) {
|
||||||
|
|
||||||
v = ngx_http_add_variable(cf, &var->name, NGX_HTTP_VAR_CHANGEABLE);
|
var = ngx_http_add_variable(cf, &v->name, v->flags);
|
||||||
if (v == NULL) {
|
if (var == NULL) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
v->get_handler = var->handler;
|
var->get_handler = v->get_handler;
|
||||||
v->data = var->data;
|
var->data = v->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user