[PATCH] inet_aton fallback support (Re: [MPlayer-dev-eng] Patches)

Joey Parrish joey at yunamusic.com
Wed Aug 28 19:46:23 CEST 2002


On Wed, Aug 28, 2002 at 07:12:42PM +0200, Alex Beregszaszi wrote:
> Hi,
> 
> today i spend some time applying patches, but probably i've left out some.
> Please tell which patches are waiting, thx.

This is a patch to allow network code to fallback on inet_aton
when inet_pton is unavailable.  This is relevant for cygwin,
but I do not know if other systems will benefit as well.
If inet_pton is found by configure, then mplayer behaves
exactly as always.  The limitation of falling back to inet_aton
is that there would be no IPv6 support, but without this patch
there would be no network support for such systems at all.

--Joey

-- 

"All you need is love." --Darth Vader
-------------- next part --------------
diff -ur main.cvs/configure main.dev/configure
--- main.cvs/configure	Wed Aug 28 12:24:20 2002
+++ main.dev/configure	Wed Aug 28 12:24:55 2002
@@ -1549,6 +1549,7 @@
 fi
 
 
+_use_aton=no
 echocheck "inet_pton()"
 cat > $TMPC << EOF
 #include <sys/types.h>
@@ -1565,10 +1566,35 @@
   _ld_sock="$_ld_sock -lresolv"
   echores "yes (using $_ld_sock)"
 else
-  echores "no (=> streaming support disabled)"
-  _streaming=no
+  echores "no (=> i'll try inet_aton next)"
+  
+  echocheck "inet_aton()"
+  cat > $TMPC << EOF
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+int main(void) { (void) inet_aton(0, 0); return 0; }
+EOF
+  _use_aton=yes
+  if cc_check $_ld_sock ; then
+      # NOTE: Linux has libresolv but does not need it
+    :
+    echores "yes (using $_ld_sock)"
+  elif cc_check $_ld_sock -lresolv ; then
+    # NOTE: needed for SunOS at least
+    _ld_sock="$_ld_sock -lresolv"
+    echores "yes (using $_ld_sock)"
+  else
+    _use_aton=no
+    _streaming=no
+    echores "no (=> streaming support disabled)"
+  fi
 fi
 
+_def_use_aton='#undef USE_ATON'
+if test "$_use_aton" != no; then
+  _def_use_aton='#define USE_ATON 1'
+fi
 
 echocheck "inttypes.h (required)"
 cat > $TMPC << EOF
@@ -4620,6 +4646,9 @@
 
 /* enable streaming */
 $_def_streaming
+
+/* define this to use inet_aton instead of inet_pton */
+$_def_use_aton
 
 /* enables / disables cdparanoia support */
 $_def_cdparanoia
Only in main.dev/: configure.orig
diff -ur main.cvs/libmpdemux/network.h main.dev/libmpdemux/network.h
--- main.cvs/libmpdemux/network.h	Thu Jul  4 21:35:19 2002
+++ main.dev/libmpdemux/network.h	Wed Aug 28 12:24:55 2002
@@ -52,4 +52,8 @@
 int http_send_request(URL_t *url);
 HTTP_header_t *http_read_response(int fd);
 
+#ifdef USE_ATON
+# define inet_pton(a, b, c) inet_aton(b, c)
+#endif
+
 #endif


More information about the MPlayer-dev-eng mailing list