summaryrefslogtreecommitdiff
path: root/inet_ntop.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2007-02-16 15:04:44 +0000
committerYang Tse <yangsita@gmail.com>2007-02-16 15:04:44 +0000
commit69fa44735497e10ca7c49075455da1370b7d7484 (patch)
tree35a7749e2b33d5bdcbf755853873e19012781f75 /inet_ntop.c
parent10a035e128165a09d7d7a0958ac5c706bf41a6ab (diff)
downloadc-ares-69fa44735497e10ca7c49075455da1370b7d7484.tar.gz
c-ares-69fa44735497e10ca7c49075455da1370b7d7484.tar.bz2
c-ares-69fa44735497e10ca7c49075455da1370b7d7484.zip
use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling
Diffstat (limited to 'inet_ntop.c')
-rw-r--r--inet_ntop.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/inet_ntop.c b/inet_ntop.c
index 097e776..f076e06 100644
--- a/inet_ntop.c
+++ b/inet_ntop.c
@@ -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);