Added check for inet_aton and a simple implementation for platforms

that are missing it.
This commit is contained in:
crs 2004-03-10 20:35:03 +00:00
parent 3920c63af6
commit 6c7039490d
2 changed files with 24 additions and 0 deletions

View File

@ -243,6 +243,7 @@ AC_DEFUN([ACX_CHECK_INET_ATON], [
LIBS="$save_LIBS" LIBS="$save_LIBS"
AC_MSG_RESULT($acx_inet_aton_ok) AC_MSG_RESULT($acx_inet_aton_ok)
if test x"$acx_inet_aton_ok" = xyes; then if test x"$acx_inet_aton_ok" = xyes; then
AC_DEFINE(HAVE_INET_ATON,1,[Define if you have the \`inet_aton\' function.])
break; break;
fi fi
INET_ATON_LIBS="" INET_ATON_LIBS=""

View File

@ -51,6 +51,29 @@ static const int s_type[] = {
SOCK_STREAM SOCK_STREAM
}; };
#if !HAVE_INET_ATON
// parse dotted quad addresses. we don't bother with the weird BSD'ism
// of handling octal and hex and partial forms.
static
in_addr_t
inet_aton(const char* cp, struct in_addr* inp)
{
unsigned int a, b, c, d;
if (sscanf(cp, "%u.%u.%u.%u", &a, &b, &c, &d) != 4) {
return 0;
}
if (a >= 256 || b >= 256 || c >= 256 || d >= 256) {
return 0;
}
unsigned char* incp = (unsigned char*)inp;
incp[0] = (unsigned char)(a & 0xffu);
incp[1] = (unsigned char)(b & 0xffu);
incp[2] = (unsigned char)(c & 0xffu);
incp[3] = (unsigned char)(d & 0xffu);
return inp->s_addr;
}
#endif
// //
// CArchNetworkBSD // CArchNetworkBSD
// //