static char *
ngx_http_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
{
    ngx_int_t                   rc, index;
    ngx_str_t                  *value, name;
    ngx_uint_t                  i, key;
    ngx_http_map_conf_ctx_t    *ctx;
    ngx_http_variable_value_t  *var, **vp;
    ctx = cf->ctx;
    value = cf->args->elts;
    if (cf->args->nelts == 1
        && ngx_strcmp(value[0].data, "hostnames") == 0)
    {
        ctx->hostnames = 1;
        return NGX_CONF_OK;
    } else if (cf->args->nelts != 2) {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "invalid number of the map parameters");
        return NGX_CONF_ERROR;
    }
    if (ngx_strcmp(value[0].data, "include") == 0) {
        return ngx_conf_include(cf, dummy, conf);
    }
    if (value[1].data[0] == '$') {
        name = value[1];
        name.len--;
        name.data++;
        index = ngx_http_get_variable_index(ctx->cf, &name);
        if (index == NGX_ERROR) {
            return NGX_CONF_ERROR;
        }
        var = ctx->var_values.elts;
        for (i = 0; i < ctx->var_values.nelts; i++) {
            if (index == (ngx_int_t) var[i].data) {
                var = &var[i];
                goto found;
            }
        }
        var = ngx_array_push(&ctx->var_values);
        if (var == NULL) {
            return NGX_CONF_ERROR;
        }
        var->valid = 0;
        var->no_cacheable = 0;
        var->not_found = 0;
        var->len = 0;
        var->data = (u_char *) index;
        goto found;
    }
    key = 0;
    for (i = 0; i < value[1].len; i++) {
        key = ngx_hash(key, value[1].data[i]);
    }
    key %= ctx->keys.hsize;
    vp = ctx->values_hash[key].elts;
    if (vp) {
        for (i = 0; i < ctx->values_hash[key].nelts; i++) {
            if (value[1].len != (size_t) vp[i]->len) {
                continue;
            }
            if (ngx_strncmp(value[1].data, vp[i]->data, value[1].len) == 0) {
                var = vp[i];
                goto found;
            }
        }
    } else {
        if (ngx_array_init(&ctx->values_hash[key], cf->pool, 4,
                           sizeof(ngx_http_variable_value_t *))
            != NGX_OK)
        {
            return NGX_CONF_ERROR;
        }
    }
    var = ngx_palloc(ctx->keys.pool, sizeof(ngx_http_variable_value_t));
    if (var == NULL) {
        return NGX_CONF_ERROR;
    }
    var->len = value[1].len;
    var->data = ngx_pstrdup(ctx->keys.pool, &value[1]);
    if (var->data == NULL) {
        return NGX_CONF_ERROR;
    }
    var->valid = 1;
    var->no_cacheable = 0;
    var->not_found = 0;
    vp = ngx_array_push(&ctx->values_hash[key]);
    if (vp == NULL) {
        return NGX_CONF_ERROR;
    }
    *vp = var;
found:
    if (ngx_strcmp(value[0].data, "default") == 0) {
        if (ctx->default_value) {
            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                               "duplicate default map parameter");
            return NGX_CONF_ERROR;
        }
        ctx->default_value = var;
        return NGX_CONF_OK;
    }
#if (NGX_PCRE)
    if (value[0].len && value[0].data[0] == '~') {
        ngx_regex_compile_t    rc;
        ngx_http_map_regex_t  *regex;
        u_char                 errstr[NGX_MAX_CONF_ERRSTR];
        regex = ngx_array_push(&ctx->regexes);
        if (regex == NULL) {
            return NGX_CONF_ERROR;
        }
        value[0].len--;
        value[0].data++;
        ngx_memzero(&rc, sizeof(ngx_regex_compile_t));
        if (value[0].data[0] == '*') {
            value[0].len--;
            value[0].data++;
            rc.options = NGX_REGEX_CASELESS;
        }
        rc.pattern = value[0];
        rc.err.len = NGX_MAX_CONF_ERRSTR;
        rc.err.data = errstr;
        regex->regex = ngx_http_regex_compile(ctx->cf, &rc);
        if (regex->regex == NULL) {
            return NGX_CONF_ERROR;
        }
        regex->value = var;
        return NGX_CONF_OK;
    }
#endif
    if (value[0].len && value[0].data[0] == '\\') {
        value[0].len--;
        value[0].data++;
    }
    rc = ngx_hash_add_key(&ctx->keys, &value[0], var,
                          (ctx->hostnames) ? NGX_HASH_WILDCARD_KEY : 0);
    if (rc == NGX_OK) {
        return NGX_CONF_OK;
    }
    if (rc == NGX_DECLINED) {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "invalid hostname or wildcard \"%V\"", &value[0]);
    }
    if (rc == NGX_BUSY) {
        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                           "conflicting parameter \"%V\"", &value[0]);
    }
    return NGX_CONF_ERROR;
}
['static char *\nngx_http_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)\n{\n    ngx_int_t                   rc, index;\n    ngx_str_t                  *value, name;\n    ngx_uint_t                  i, key;\n    ngx_http_map_conf_ctx_t    *ctx;\n    ngx_http_variable_value_t  *var, **vp;\n    ctx = cf->ctx;\n    value = cf->args->elts;\n    if (cf->args->nelts == 1\n        && ngx_strcmp(value[0].data, "hostnames") == 0)\n    {\n        ctx->hostnames = 1;\n        return NGX_CONF_OK;\n    } else if (cf->args->nelts != 2) {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "invalid number of the map parameters");\n        return NGX_CONF_ERROR;\n    }\n    if (ngx_strcmp(value[0].data, "include") == 0) {\n        return ngx_conf_include(cf, dummy, conf);\n    }\n    if (value[1].data[0] == \'$\') {\n        name = value[1];\n        name.len--;\n        name.data++;\n        index = ngx_http_get_variable_index(ctx->cf, &name);\n        if (index == NGX_ERROR) {\n            return NGX_CONF_ERROR;\n        }\n        var = ctx->var_values.elts;\n        for (i = 0; i < ctx->var_values.nelts; i++) {\n            if (index == (ngx_int_t) var[i].data) {\n                var = &var[i];\n                goto found;\n            }\n        }\n        var = ngx_array_push(&ctx->var_values);\n        if (var == NULL) {\n            return NGX_CONF_ERROR;\n        }\n        var->valid = 0;\n        var->no_cacheable = 0;\n        var->not_found = 0;\n        var->len = 0;\n        var->data = (u_char *) index;\n        goto found;\n    }\n    key = 0;\n    for (i = 0; i < value[1].len; i++) {\n        key = ngx_hash(key, value[1].data[i]);\n    }\n    key %= ctx->keys.hsize;\n    vp = ctx->values_hash[key].elts;\n    if (vp) {\n        for (i = 0; i < ctx->values_hash[key].nelts; i++) {\n            if (value[1].len != (size_t) vp[i]->len) {\n                continue;\n            }\n            if (ngx_strncmp(value[1].data, vp[i]->data, value[1].len) == 0) {\n                var = vp[i];\n                goto found;\n            }\n        }\n    } else {\n        if (ngx_array_init(&ctx->values_hash[key], cf->pool, 4,\n                           sizeof(ngx_http_variable_value_t *))\n            != NGX_OK)\n        {\n            return NGX_CONF_ERROR;\n        }\n    }\n    var = ngx_palloc(ctx->keys.pool, sizeof(ngx_http_variable_value_t));\n    if (var == NULL) {\n        return NGX_CONF_ERROR;\n    }\n    var->len = value[1].len;\n    var->data = ngx_pstrdup(ctx->keys.pool, &value[1]);\n    if (var->data == NULL) {\n        return NGX_CONF_ERROR;\n    }\n    var->valid = 1;\n    var->no_cacheable = 0;\n    var->not_found = 0;\n    vp = ngx_array_push(&ctx->values_hash[key]);\n    if (vp == NULL) {\n        return NGX_CONF_ERROR;\n    }\n    *vp = var;\nfound:\n    if (ngx_strcmp(value[0].data, "default") == 0) {\n        if (ctx->default_value) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "duplicate default map parameter");\n            return NGX_CONF_ERROR;\n        }\n        ctx->default_value = var;\n        return NGX_CONF_OK;\n    }\n#if (NGX_PCRE)\n    if (value[0].len && value[0].data[0] == \'~\') {\n        ngx_regex_compile_t    rc;\n        ngx_http_map_regex_t  *regex;\n        u_char                 errstr[NGX_MAX_CONF_ERRSTR];\n        regex = ngx_array_push(&ctx->regexes);\n        if (regex == NULL) {\n            return NGX_CONF_ERROR;\n        }\n        value[0].len--;\n        value[0].data++;\n        ngx_memzero(&rc, sizeof(ngx_regex_compile_t));\n        if (value[0].data[0] == \'*\') {\n            value[0].len--;\n            value[0].data++;\n            rc.options = NGX_REGEX_CASELESS;\n        }\n        rc.pattern = value[0];\n        rc.err.len = NGX_MAX_CONF_ERRSTR;\n        rc.err.data = errstr;\n        regex->regex = ngx_http_regex_compile(ctx->cf, &rc);\n        if (regex->regex == NULL) {\n            return NGX_CONF_ERROR;\n        }\n        regex->value = var;\n        return NGX_CONF_OK;\n    }\n#endif\n    if (value[0].len && value[0].data[0] == \'\\\\\') {\n        value[0].len--;\n        value[0].data++;\n    }\n    rc = ngx_hash_add_key(&ctx->keys, &value[0], var,\n                          (ctx->hostnames) ? NGX_HASH_WILDCARD_KEY : 0);\n    if (rc == NGX_OK) {\n        return NGX_CONF_OK;\n    }\n    if (rc == NGX_DECLINED) {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "invalid hostname or wildcard \\"%V\\"", &value[0]);\n    }\n    if (rc == NGX_BUSY) {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "conflicting parameter \\"%V\\"", &value[0]);\n    }\n    return NGX_CONF_ERROR;\n}']