Diff of /src/libdvdcss.c [d040ac] .. [083432]  Maximize  Restore

  Switch to side-by-side view

--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -2,7 +2,7 @@
  * libdvdcss.c: DVD reading library.
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: libdvdcss.c,v 1.1 2001/12/22 00:08:13 sam Exp $
+ * $Id: libdvdcss.c,v 1.2 2001/12/22 00:52:46 sam Exp $
  *
  * Authors: Stéphane Borel <stef@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -45,10 +45,6 @@
 #   include <sys/uio.h>                                      /* struct iovec */
 #endif
 
-#if defined( WIN32 )
-#   include "input_iovec.h"
-#endif
-
 #include "dvdcss.h"
 
 #include "common.h"
@@ -56,6 +52,17 @@
 #include "libdvdcss.h"
 #include "csstables.h"
 #include "ioctl.h"
+
+/*****************************************************************************
+ * iovec structure: vectored data entry
+ *****************************************************************************/
+#if defined( WIN32 )
+struct iovec
+{
+    void *iov_base;     /* Pointer to data. */
+    size_t iov_len;     /* Length of data.  */
+};
+#endif
 
 /*****************************************************************************
  * Local prototypes
@@ -77,6 +84,54 @@
 #else
 static int _dvdcss_raw_open     ( dvdcss_handle, char *psz_target );
 #endif
+
+/*****************************************************************************
+ * readv_*: readv() replacements for iovec-impaired C libraries
+ *****************************************************************************/
+#if defined( WIN32 )
+static __inline__ int readv( int i_fd, struct iovec *p_iovec, int i_count )
+{
+    int i_index, i_len, i_total = 0;
+    unsigned char *p_base;
+    int i_bytes;
+
+    for( i_index = i_count; i_index; i_index-- )
+    {
+
+        i_len  = p_iovec->iov_len;
+        p_base = p_iovec->iov_base;
+
+        /* Loop is unrolled one time to spare the (i_bytes <= 0) test */
+
+        if( i_len > 0 )
+        {
+            i_bytes = read( i_fd, p_base, i_len );
+
+            if( i_bytes < 0 )
+            {
+                /* One of the reads failed, too bad.
+                   We won't even bother returning the reads that went ok,
+                   and as in the posix spec the file postition is left
+                   unspecified after a failure */
+                return -1;
+            }
+
+            i_total += i_bytes;
+
+            if( i_bytes != i_len )
+            {
+                /* we reached the end of the file or a signal interrupted
+                   the read */
+                return i_total;
+            }
+        }
+
+        p_iovec++;
+    }
+
+    return i_total;
+}
+#endif /* WIN32 */
 
 /*****************************************************************************
  * dvdcss_open: initialize library, open a DVD device, crack CSS key

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks