Skip to content

Commit

Permalink
Add compatibility inet_aton() function for MinGW build
Browse files Browse the repository at this point in the history
Based on a patch from Nikos Mavrogiannopoulos.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Feb 6, 2014
1 parent 1f34d35 commit 76df598
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions compat.c
Expand Up @@ -190,3 +190,11 @@ void openconnect__unsetenv(const char *name)
putenv(buf);
}
#endif

#ifndef HAVE_INET_ATON
int openconnect__inet_aton(const char *cp, struct in_addr *addr)
{
addr->s_addr = inet_addr(cp);
return (addr->s_addr == 0xffffffff) ? 0 : 1;
}
#endif
8 changes: 7 additions & 1 deletion configure.ac
Expand Up @@ -141,7 +141,13 @@ AS_COMPILER_FLAGS(WFLAGS,
AC_SUBST(WFLAGS, [$WFLAGS])

AC_CHECK_FUNC(socket, [], AC_CHECK_LIB(socket, socket, [], AC_ERROR(Cannot find socket() function)))
AC_CHECK_FUNC(inet_aton, [], AC_CHECK_LIB(nsl, inet_aton, [], AC_ERROR(Cannot find inet_aton() function)))

have_inet_aton=yes
AC_CHECK_FUNC(inet_aton, [], AC_CHECK_LIB(nsl, inet_aton, [], have_inet_aton=no))
if test "$have_inet_aton" = "yes"; then
AC_DEFINE(HAVE_INET_ATON, 1)
fi

AC_CHECK_FUNC(__android_log_vprint, [], AC_CHECK_LIB(log, __android_log_vprint, [], []))

AC_CHECK_FUNCS(setenv unsetenv)
Expand Down
5 changes: 5 additions & 0 deletions openconnect-internal.h
Expand Up @@ -364,6 +364,11 @@ int openconnect__setenv(const char *name, const char *value, int overwrite);
void openconnect__unsetenv(const char *name);
#endif

#ifndef HAVE_INET_ATON
#define inet_aton openconnect__inet_aton
int openconnect__inet_aton(const char *cp, struct in_addr *addr);
#endif

/* I always coded as if it worked like this. Now it does. */
#define realloc_inplace(p, size) do { \
void *__realloc_old = p; \
Expand Down

0 comments on commit 76df598

Please sign in to comment.