off_t
ngx_parse_offset(ngx_str_t *line)
{
    u_char     unit;
    off_t      offset;
    size_t     len;
    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;
    case 'G':
    case 'g':
        len--;
        scale = 1024 * 1024 * 1024;
        break;
    default:
        scale = 1;
    }
    offset = ngx_atoof(line->data, len);
    if (offset == NGX_ERROR) {
        return NGX_ERROR;
    }
    offset *= scale;
    return offset;
}
['static char *\nngx_http_core_directio(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)\n{\n    ngx_http_core_loc_conf_t *clcf = conf;\n    ngx_str_t  *value;\n    if (clcf->directio != NGX_CONF_UNSET) {\n        return "is duplicate";\n    }\n    value = cf->args->elts;\n    if (ngx_strcmp(value[1].data, "off") == 0) {\n        clcf->directio = NGX_OPEN_FILE_DIRECTIO_OFF;\n        return NGX_CONF_OK;\n    }\n    clcf->directio = ngx_parse_offset(&value[1]);\n    if (clcf->directio == (off_t) NGX_ERROR) {\n        return "invalid value";\n    }\n    return NGX_CONF_OK;\n}', "off_t\nngx_parse_offset(ngx_str_t *line)\n{\n    u_char     unit;\n    off_t      offset;\n    size_t     len;\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    case 'G':\n    case 'g':\n        len--;\n        scale = 1024 * 1024 * 1024;\n        break;\n    default:\n        scale = 1;\n    }\n    offset = ngx_atoof(line->data, len);\n    if (offset == NGX_ERROR) {\n        return NGX_ERROR;\n    }\n    offset *= scale;\n    return offset;\n}"]