1
0
mirror of https://frontier.innolan.net/rainlance/c-ares.git synced 2025-10-05 18:42:01 +00:00

use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling

This commit is contained in:
Yang Tse
2007-02-16 15:04:44 +00:00
parent 10a035e128
commit 69fa447354
6 changed files with 47 additions and 33 deletions

View File

@ -68,6 +68,11 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size);
* convert a network format address to presentation format.
* return:
* pointer to presentation format address (`dst'), or NULL (see errno).
* note:
* On Windows we store the error in the thread errno, not
* in the winsock error code. This is to avoid loosing the
* actual last winsock error. So use macro ERRNO to fetch the
* errno this funtion sets when returning NULL, not SOCKERRNO.
* author:
* Paul Vixie, 1996.
*/
@ -81,7 +86,7 @@ ares_inet_ntop(int af, const void *src, char *dst, size_t size)
case AF_INET6:
return (inet_ntop6(src, dst, size));
default:
errno = EAFNOSUPPORT;
SET_ERRNO(EAFNOSUPPORT);
return (NULL);
}
/* NOTREACHED */
@ -106,7 +111,7 @@ inet_ntop4(const unsigned char *src, char *dst, size_t size)
if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size)
{
errno = ENOSPC;
SET_ERRNO(ENOSPC);
return (NULL);
}
strcpy(dst, tmp);
@ -218,7 +223,7 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
*/
if ((size_t)(tp - tmp) > size)
{
errno = ENOSPC;
SET_ERRNO(ENOSPC);
return (NULL);
}
strcpy(dst, tmp);