Mercurial > hg > nginx
diff src/core/ngx_inet.c @ 425:bd39260a1383
nginx-0.0.10-2004-09-14-19:55:24 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 14 Sep 2004 15:55:24 +0000 |
parents | 37b5381fb6d8 |
children | da8c5707af39 |
line wrap: on
line diff
--- a/src/core/ngx_inet.c +++ b/src/core/ngx_inet.c @@ -210,3 +210,58 @@ ngx_int_t ngx_ptocidr(ngx_str_t *text, v return NGX_OK; } + + +#if 0 + +ngx_int_t ngx_inet_addr_port(ngx_conf_t *cf, ngx_command_t *cmd, + ngx_str_t *addr_port) +{ + u_char *host; + ngx_int_t port; + ngx_uint_t p; + struct hostent *h; + + for (p = 0; p < addr_port->len; p++) { + if (addr_port->data[p] == ':') { + break; + } + } + + in_addr->host.len = p; + if (!(in_addr->host.data = ngx_palloc(pool, p + 1))) { + return NGX_ERROR; + } + + ngx_cpystrn(in_addr->host.data, addr_port->data, p + 1); + + if (p == addr_port->len) { + p = 0; + } + + port = ngx_atoi(&addr[p], args[1].len - p); + if (port == NGX_ERROR && p == 0) { + + /* default port */ + iap->port = 0; + + } else if ((port == NGX_ERROR && p != 0) /* "listen host:NONNUMBER" */ + || (port < 1 || port > 65536)) { /* "listen 99999" */ + + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, + "invalid port \"%s\" in \"%s\" directive, " + "it must be a number between 1 and 65535", + &addr[p], cmd->name.data); + + return NGX_CONF_ERROR; + + } else if (p == 0) { + ls->addr = INADDR_ANY; + ls->port = (in_port_t) port; + return NGX_CONF_OK; + } + + return NGX_OK; +} + +#endif