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

Joey Parrish joey at yunamusic.com
Thu Aug 29 07:26:03 CEST 2002


Hello,

On Wed, Aug 28, 2002 at 07:52:42PM +0200, Diego Biurrun wrote:
> Joey Parrish writes:
>  > 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.
> 
> Shouldn't you add a comment about this somewhere in the code?

You are very correct.  A revised patch is attached.

Thanks,
--Joey

-- 

"All you need is love." --Darth Vader
-------------- next part --------------
diff -ur main.cvs/configure main.dev/configure
--- main.cvs/configure	Thu Aug 29 00:18:51 2002
+++ main.dev/configure	Thu Aug 29 00:19:41 2002
@@ -1553,6 +1553,7 @@
 fi
 
 
+_use_aton=no
 echocheck "inet_pton()"
 cat > $TMPC << EOF
 #include <sys/types.h>
@@ -1569,10 +1570,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
@@ -4652,6 +4678,9 @@
 
 /* enable streaming */
 $_def_streaming
+
+/* define this to use inet_aton() instead of inet_pton() */
+$_def_use_aton
 
 /* enables / disables cdparanoia support */
 $_def_cdparanoia
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	Thu Aug 29 00:24:07 2002
@@ -52,4 +52,16 @@
 int http_send_request(URL_t *url);
 HTTP_header_t *http_read_response(int fd);
 
+/* 
+ * This define is to allow systems without inet_pton() to fallback on
+ * inet_aton().  The difference between the two is that inet_aton() is
+ * strictly for IPv4 networking, while inet_pton() is for IPv4 and IPv6
+ * both.  Slightly limited network functionality seems better than no
+ * network functionality to me, and as all systems (Cygwin) start to
+ * implement inet_pton(), configure will decide not to use this code.
+ */
+#ifdef USE_ATON
+# define inet_pton(a, b, c) inet_aton(b, c)
+#endif
+
 #endif


More information about the MPlayer-dev-eng mailing list