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;
}
['static char *\nngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)\n{\n    ngx_http_core_srv_conf_t *scf = conf;\n    ngx_str_t          *value, size;\n    ngx_url_t           u;\n    ngx_uint_t          n;\n    ngx_http_listen_t  *ls;\n    value = cf->args->elts;\n    ngx_memzero(&u, sizeof(ngx_url_t));\n    u.url = value[1];\n    u.listen = 1;\n    u.default_port = 80;\n    if (ngx_parse_url(cf->pool, &u) != NGX_OK) {\n        if (u.err) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "%s in \\"%V\\" of the \\"listen\\" directive",\n                               u.err, &u.url);\n        }\n        return NGX_CONF_ERROR;\n    }\n    ls = ngx_array_push(&scf->listen);\n    if (ls == NULL) {\n        return NGX_CONF_ERROR;\n    }\n    ngx_memzero(ls, sizeof(ngx_http_listen_t));\n    ngx_memcpy(ls->sockaddr, u.sockaddr, u.socklen);\n    ls->socklen = u.socklen;\n    ls->file_name = cf->conf_file->file.name.data;\n    ls->line = cf->conf_file->line;\n    ls->conf.backlog = NGX_LISTEN_BACKLOG;\n    ls->conf.rcvbuf = -1;\n    ls->conf.sndbuf = -1;\n    ls->conf.wildcard = u.wildcard;\n    (void) ngx_sock_ntop((struct sockaddr *) &ls->sockaddr, ls->conf.addr,\n                         NGX_SOCKADDR_STRLEN, 1);\n    if (cf->args->nelts == 2) {\n        return NGX_CONF_OK;\n    }\n    if (ngx_strcmp(value[2].data, "default") == 0) {\n        ls->conf.default_server = 1;\n        n = 3;\n    } else {\n        n = 2;\n    }\n    for (   ; n < cf->args->nelts; n++) {\n        if (ls->conf.default_server == 0) {\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "\\"%V\\" parameter can be specified for "\n                               "the default \\"listen\\" directive only",\n                               &value[n]);\n            return NGX_CONF_ERROR;\n        }\n        if (ngx_strcmp(value[n].data, "bind") == 0) {\n            ls->conf.bind = 1;\n            continue;\n        }\n        if (ngx_strncmp(value[n].data, "backlog=", 8) == 0) {\n            ls->conf.backlog = ngx_atoi(value[n].data + 8, value[n].len - 8);\n            ls->conf.bind = 1;\n            if (ls->conf.backlog == NGX_ERROR || ls->conf.backlog == 0) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "invalid backlog \\"%V\\"", &value[n]);\n                return NGX_CONF_ERROR;\n            }\n            continue;\n        }\n        if (ngx_strncmp(value[n].data, "rcvbuf=", 7) == 0) {\n            size.len = value[n].len - 7;\n            size.data = value[n].data + 7;\n            ls->conf.rcvbuf = ngx_parse_size(&size);\n            ls->conf.bind = 1;\n            if (ls->conf.rcvbuf == NGX_ERROR) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "invalid rcvbuf \\"%V\\"", &value[n]);\n                return NGX_CONF_ERROR;\n            }\n            continue;\n        }\n        if (ngx_strncmp(value[n].data, "sndbuf=", 7) == 0) {\n            size.len = value[n].len - 7;\n            size.data = value[n].data + 7;\n            ls->conf.sndbuf = ngx_parse_size(&size);\n            ls->conf.bind = 1;\n            if (ls->conf.sndbuf == NGX_ERROR) {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "invalid sndbuf \\"%V\\"", &value[n]);\n                return NGX_CONF_ERROR;\n            }\n            continue;\n        }\n        if (ngx_strncmp(value[n].data, "accept_filter=", 14) == 0) {\n#if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)\n            ls->conf.accept_filter = (char *) &value[n].data[14];\n            ls->conf.bind = 1;\n#else\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "accept filters \\"%V\\" are not supported "\n                               "on this platform, ignored",\n                               &value[n]);\n#endif\n            continue;\n        }\n        if (ngx_strcmp(value[n].data, "deferred") == 0) {\n#if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)\n            ls->conf.deferred_accept = 1;\n            ls->conf.bind = 1;\n#else\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "the deferred accept is not supported "\n                               "on this platform, ignored");\n#endif\n            continue;\n        }\n        if (ngx_strncmp(value[n].data, "ipv6only=o", 10) == 0) {\n#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)\n            struct sockaddr  *sa;\n            sa = (struct sockaddr *) ls->sockaddr;\n            if (sa->sa_family == AF_INET6) {\n                if (ngx_strcmp(&value[n].data[10], "n") == 0) {\n                    ls->conf.ipv6only = 1;\n                } else if (ngx_strcmp(&value[n].data[10], "ff") == 0) {\n                    ls->conf.ipv6only = 2;\n                } else {\n                    ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                       "invalid ipv6only flags \\"%s\\"",\n                                       &value[n].data[9]);\n                    return NGX_CONF_ERROR;\n                }\n                ls->conf.bind = 1;\n            } else {\n                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                                   "ipv6only is not supported "\n                                   "on addr \\"%s\\", ignored",\n                                   ls->conf.addr);\n            }\n            continue;\n#else\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "bind ipv6only is not supported "\n                               "on this platform");\n            return NGX_CONF_ERROR;\n#endif\n        }\n        if (ngx_strcmp(value[n].data, "ssl") == 0) {\n#if (NGX_HTTP_SSL)\n            ls->conf.ssl = 1;\n            continue;\n#else\n            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                               "the \\"ssl\\" parameter requires "\n                               "ngx_http_ssl_module");\n            return NGX_CONF_ERROR;\n#endif\n        }\n        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,\n                           "the invalid \\"%V\\" parameter", &value[n]);\n        return NGX_CONF_ERROR;\n    }\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}"]