version 1.10.2.1, 2012/04/02 09:10:31
|
version 1.11.2.1, 2012/05/14 15:08:26
|
Line 465 io_n2addr(io_sockaddr_t * __restrict addr, ait_val_t *
|
Line 465 io_n2addr(io_sockaddr_t * __restrict addr, ait_val_t *
|
return ret; |
return ret; |
} |
} |
|
|
if (!AIT_ISEMPTY(val)) |
|
AIT_FREE_VAL(val); |
|
AIT_SET_STR(val, ret); |
AIT_SET_STR(val, ret); |
return (const char*) AIT_GET_STR(val); |
return (const char*) AIT_GET_STR(val); |
} |
} |
Line 482 io_n2addr(io_sockaddr_t * __restrict addr, ait_val_t *
|
Line 480 io_n2addr(io_sockaddr_t * __restrict addr, ait_val_t *
|
io_sockaddr_t * |
io_sockaddr_t * |
io_gethostbyname(const char *psHost, u_short port, io_sockaddr_t * __restrict addr) |
io_gethostbyname(const char *psHost, u_short port, io_sockaddr_t * __restrict addr) |
{ |
{ |
struct hostent *host; | struct hostent *host = NULL; |
|
|
if (!psHost || !addr) |
if (!psHost || !addr) |
return NULL; |
return NULL; |
|
|
/* resolver */ | if (*psHost != '/') { |
if (!addr->sa.sa_family) | /* resolver */ |
host = gethostbyname(psHost); | if (!addr->sa.sa_family) |
else | host = gethostbyname(psHost); |
host = gethostbyname2(psHost, addr->sa.sa_family); | else |
if (!host) { | host = gethostbyname2(psHost, addr->sa.sa_family); |
io_SetErr(EINVAL, "Resolver #%d - %s", h_errno, hstrerror(h_errno)); | if (!host) { |
return NULL; | io_SetErr(EINVAL, "Resolver #%d - %s", h_errno, hstrerror(h_errno)); |
} | return NULL; |
| } else |
| addr->sa.sa_family = host->h_addrtype; |
| } else |
| addr->sa.sa_family = AF_LOCAL; |
|
|
memset(addr, 0, sizeof(io_sockaddr_t)); |
memset(addr, 0, sizeof(io_sockaddr_t)); |
switch (host->h_addrtype) { | switch (addr->sa.sa_family) { |
case AF_INET: |
case AF_INET: |
addr->sin.sin_len = sizeof(struct sockaddr_in); |
addr->sin.sin_len = sizeof(struct sockaddr_in); |
addr->sin.sin_family = AF_INET; |
addr->sin.sin_family = AF_INET; |
Line 511 io_gethostbyname(const char *psHost, u_short port, io_
|
Line 513 io_gethostbyname(const char *psHost, u_short port, io_
|
addr->sin6.sin6_port = htons(port); |
addr->sin6.sin6_port = htons(port); |
memcpy(&addr->sin6.sin6_addr, host->h_addr, sizeof addr->sin6.sin6_addr); |
memcpy(&addr->sin6.sin6_addr, host->h_addr, sizeof addr->sin6.sin6_addr); |
return addr; |
return addr; |
|
case AF_LOCAL: |
|
addr->sun.sun_len = sizeof(struct sockaddr_un); |
|
addr->sun.sun_family = AF_LOCAL; |
|
strlcpy(addr->sun.sun_path, psHost, sizeof addr->sun.sun_path); |
|
return addr; |
default: |
default: |
io_SetErr(EPROTONOSUPPORT, "Unsuported address family %d", | io_SetErr(EPROTONOSUPPORT, "Unsuported address family %d", addr->sa.sa_family); |
host->h_addrtype); | |
break; |
break; |
} |
} |
|
|