ssize_t
ngx_parse_size(ngx_str_t *line)
{
    u_char     unit;
    size_t     len;
    ssize_t    size;
    ngx_int_t  scale;
    len = line->len;
    unit = line->data[len - 1];
    switch (unit) {
    case 'K':
    case 'k':
        len--;
        scale = 1024;
        break;
    case 'M':
    case 'm':
        len--;
        scale = 1024 * 1024;
        break;
    default:
        scale = 1;
    }
    size = ngx_atosz(line->data, len);
    if (size == NGX_ERROR) {
        return NGX_ERROR;
    }
    size *= scale;
    return size;
}
['char *\nngx_http_file_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)\n{\n    off_t                   max_size;\n    u_char                 *last, *p;\n    time_t                  inactive;\n    ssize_t                 size;\n    ngx_str_t               s, name, *value;\n    ngx_uint_t              i, n;\n    ngx_http_file_cache_t  *cache;\n    cache = ngx_pcalloc(cf->pool, sizeof(ngx_http_file_cache_t));\n    if (cache == NULL) {\n        return NGX_CONF_ERROR;\n    }\n    cache->path = ngx_pcalloc(cf->pool, sizeof(ngx_path_t));\n    if (cache->path == NULL) {\n        return NGX_CONF_ERROR;\n    }\n    inactive = 600;\n    name.len = 0;\n    size = 0;\n    max_size = NGX_MAX_OFF_T_VALUE;\n    value = cf->args->elts;\n    cache->path->name = value[1];\n    if (cache->path->name.data[cache->path->name.len - 1] == \'/\') {\n        cache->path->name.len--;\n    }\n    if (ngx_conf_full_name(cf->cycle, &cache->path->name, 0) != NGX_OK) {\n        return NGX_CONF_ERROR;\n    }\n    for (i = 2; i < cf->args->nelts; i++) {\n        if (ngx_strncmp(value[i].data, "levels=", 7) == 0) {\n            p = value[i].data + 7;\n            last = value[i].data + value[i].len;\n            for (n = 0; n < 3 && p < last; n++) {\n                if (*p > \'0\' && *p < \'3\') {\n                    cache->path->level[n] = *p++ - \'0\';\n                    cache->path->len += cache->path->level[n] + 1;\n                    if (p == last) {\n                        break;\n                    }\n                    if (*p++ == \':\' && n < 2 && p != last) {\n                        continue;\n                    }\n                    goto invalid_levels;\n                }\n                goto invalid_levels;\n            }\n            if (cache->path->len < 10 + 3) {\n                continue;\n            }\n        invalid_levels:\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "invalid \\"levels\\" \\"%V\\"", &value[i]);\n            return NGX_CONF_ERROR;\n        }\n        if (ngx_strncmp(value[i].data, "keys_zone=", 10) == 0) {\n            name.data = value[i].data + 10;\n            p = (u_char *) ngx_strchr(name.data, \':\');\n            if (p) {\n                name.len = p - name.data;\n                p++;\n                s.len = value[i].data + value[i].len - p;\n                s.data = p;\n                size = ngx_parse_size(&s);\n                if (size > 8191) {\n                    continue;\n                }\n            }\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "invalid keys zone size \\"%V\\"", &value[i]);\n            return NGX_CONF_ERROR;\n        }\n        if (ngx_strncmp(value[i].data, "inactive=", 9) == 0) {\n            s.len = value[i].len - 9;\n            s.data = value[i].data + 9;\n            inactive = ngx_parse_time(&s, 1);\n            if (inactive < 0) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "invalid inactive value \\"%V\\"", &value[i]);\n                return NGX_CONF_ERROR;\n            }\n            continue;\n        }\n        if (ngx_strncmp(value[i].data, "max_size=", 9) == 0) {\n            s.len = value[i].len - 9;\n            s.data = value[i].data + 9;\n            max_size = ngx_parse_offset(&s);\n            if (max_size < 0) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "invalid max_size value \\"%V\\"", &value[i]);\n                return NGX_CONF_ERROR;\n            }\n            continue;\n        }\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "invalid parameter \\"%V\\"", &value[i]);\n        return NGX_CONF_ERROR;\n    }\n    if (name.len == 0 || size == 0) {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "\\"%V\\" must have \\"keys_zone\\" parameter",\n                           &cmd->name);\n        return NGX_CONF_ERROR;\n    }\n    cache->path->manager = ngx_http_file_cache_manager;\n    cache->path->data = cache;\n    if (ngx_add_path(cf, &cache->path) != NGX_OK) {\n        return NGX_CONF_ERROR;\n    }\n    cache->shm_zone = ngx_shared_memory_add(cf, &name, size, cmd->post);\n    if (cache->shm_zone == NULL) {\n        return NGX_CONF_ERROR;\n    }\n    if (cache->shm_zone->data) {\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "duplicate zone \\"%V\\"", &name);\n        return NGX_CONF_ERROR;\n    }\n    cache->shm_zone->init = ngx_http_file_cache_init;\n    cache->shm_zone->data = cache;\n    cache->inactive = inactive;\n    cache->max_size = max_size;\n    return NGX_CONF_OK;\n}', "ssize_t\nngx_parse_size(ngx_str_t *line)\n{\n    u_char     unit;\n    size_t     len;\n    ssize_t    size;\n    ngx_int_t  scale;\n    len = line->len;\n    unit = line->data[len - 1];\n    switch (unit) {\n    case 'K':\n    case 'k':\n        len--;\n        scale = 1024;\n        break;\n    case 'M':\n    case 'm':\n        len--;\n        scale = 1024 * 1024;\n        break;\n    default:\n        scale = 1;\n    }\n    size = ngx_atosz(line->data, len);\n    if (size == NGX_ERROR) {\n        return NGX_ERROR;\n    }\n    size *= scale;\n    return size;\n}"]