[Mplayer-cvslog] CVS: main/libmpdvdkit input_iovec.h,NONE,1.1 bswap.h,1.2,1.3 common.h,1.3,1.4 css.c,1.4,1.5 dvd_reader.c,1.6,1.7 ioctl.c,1.3,1.4 ioctl.h,1.3,1.4 libdvdcss.c,1.6,1.7

Atmosfear atmos4 at mplayerhq.hu
Wed Jul 10 05:01:39 CEST 2002


Update of /cvsroot/mplayer/main/libmpdvdkit
In directory mail:/var/tmp.root/cvs-serv15267

Modified Files:
	bswap.h common.h css.c dvd_reader.c ioctl.c ioctl.h 
	libdvdcss.c 
Added Files:
	input_iovec.h 
Log Message:
Cygwin/win32 mpdvdkit support.


--- NEW FILE ---
/*****************************************************************************
 * input_iovec.h: iovec structure
 *****************************************************************************
 * Copyright (C) 2001 VideoLAN
 *
 * Authors: Samuel Hocevar <sam at zoy.org>
 *          Jon Lech Johansen <jon-vl at nanocrew.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * iovec structure: vectored data entry
 *****************************************************************************/
struct iovec
{
    void *iov_base;     /* Pointer to data. */
    size_t iov_len;     /* Length of data.  */
};

/*****************************************************************************
 * 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 */

Index: bswap.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit/bswap.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- bswap.h	4 Jun 2002 20:11:15 -0000	1.2
+++ bswap.h	10 Jul 2002 03:01:33 -0000	1.3
@@ -48,6 +48,44 @@
 #define B2N_32(x) x = swap32(x)
 #define B2N_64(x) x = swap64(x)
 
+#elif defined(ARCH_X86)
+inline static unsigned short bswap_16(unsigned short x)
+{
+  __asm("xchgb %b0,%h0" :
+        "=q" (x)        :
+        "0" (x));
+    return x;
+}
+#define B2N_16(x) x = bswap_16(x)
+
+inline static unsigned int bswap_32(unsigned int x)
+{
+ __asm(
+#if __CPU__ > 386
+      "bswap   %0":
+      "=r" (x)     :
+#else
+      "xchgb   %b0,%h0\n"
+      " rorl    $16,%0\n"
+      " xchgb   %b0,%h0":
+      "=q" (x)          :
+#endif
+      "0" (x));
+  return x;
+}
+#define B2N_32(x) x = bswap_32(x)
+
+inline static unsigned long long int bswap_64(unsigned long long int x)
+{
+  register union { __extension__ uint64_t __ll;
+          uint32_t __l[2]; } __x;
+  asm("xchgl    %0,%1":
+      "=r"(__x.__l[0]),"=r"(__x.__l[1]):
+      "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
+  return __x.__ll;
+}
+#define B2N_64(x) x = bswap_64(x)
+
 /* This is a slow but portable implementation, it has multiple evaluation 
  * problems so beware.
  * FreeBSD and Solaris don't have <byteswap.h> or any other such 

Index: common.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit/common.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- common.h	17 Jun 2002 21:40:00 -0000	1.3
+++ common.h	10 Jul 2002 03:01:33 -0000	1.4
@@ -140,7 +140,7 @@
  *****************************************************************************/
 #ifdef NTOHL_IN_SYS_PARAM_H
 #   include <sys/param.h>
-#elif defined(WIN32) && !defined(__CYGWIN__)
+#elif defined(WIN32)
 #   include <winsock.h>
 #else
 #   include <netinet/in.h>

Index: css.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit/css.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- css.c	25 Apr 2002 17:08:03 -0000	1.4
+++ css.c	10 Jul 2002 03:01:33 -0000	1.5
@@ -33,6 +33,12 @@
  * Preamble
  *****************************************************************************/
 
+#include "config.h"
+
+#if defined(WIN32)
+# define __USE_W32_SOCKETS 1
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -40,7 +46,6 @@
 
 #include <sys/types.h>
 
-#include "config.h"
 #include "common.h"
 
 #include "dvdcss.h"

Index: dvd_reader.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit/dvd_reader.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- dvd_reader.c	13 Jun 2002 01:08:45 -0000	1.6
+++ dvd_reader.c	10 Jul 2002 03:01:33 -0000	1.7
@@ -16,6 +16,9 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+
+#include "config.h"
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h> /* For the timing of dvdcss_title crack. */
@@ -40,12 +43,18 @@
 #include <mntent.h>
 #endif
 
-#if defined(SYS_BSD) || defined(__CYGWIN__)
+#if defined(SYS_BSD)
 typedef off_t off64_t;
 #define lseek64 lseek
 #define stat64 stat
 #endif
 
+#if defined(WIN32)
+typedef u_int64_t off64_t;
+#define lseek64 lseek
+#define stat64 stat
+#endif
+
 #if defined(SYS_DARWIN)
 typedef u_int64_t off64_t;
 #define lseek64 lseek
@@ -252,11 +261,13 @@
 
 dvd_reader_t *DVDOpen( const char *path )
 {
+#if !defined(WIN32)
     struct stat64 fileinfo;
+#endif
     int ret;
     char * dir;
 
-
+#if !defined(WIN32)
     if( !path ) return 0;
 
     ret = stat64( path, &fileinfo );
@@ -266,17 +277,22 @@
 	perror("");
 	return 0;
     }
-
+#endif
+    
     dir=get_path( "" );
     if ( dir ) { mkdir( dir,493 ); free( dir ); }
     dir=get_path( "DVDKeys" );
     if ( !dir ) dir=strdup( "/tmp" );
     mkdir( dir,493 );
 
+#if !defined(WIN32)
     /* First check if this is a block/char device or a file*/
     if( S_ISBLK( fileinfo.st_mode ) || 
 	S_ISCHR( fileinfo.st_mode ) || 
 	S_ISREG( fileinfo.st_mode ) ) {
+#else
+    {
+#endif
 
 	/**
 	 * Block devices and regular files are assumed to be DVD-Video images.
@@ -293,6 +309,7 @@
 	device = path;
 #endif
 
+#if !defined(WIN32)
 	if ( (img=fopen( device,"r" )) )
 	 {
 	  int i;
@@ -311,6 +328,10 @@
 
 	if ( (dvd_key_dir=(char *)calloc( 1,strlen( dir ) + 18 )) == NULL ) return 0;
 	sprintf( dvd_key_dir,"%s/%.16s",dir,discid );
+#else
+	if ( (dvd_key_dir=(char *)calloc( 1,strlen( dir ) + 18 )) == NULL ) return 0;
+	sprintf( dvd_key_dir,"%s/oops",dir);
+#endif
 	mkdir( dvd_key_dir,493 );
 
 	free( dir );
@@ -318,7 +339,9 @@
         return DVDOpenImageFile( device );
 // ---
 
-    } else if( S_ISDIR( fileinfo.st_mode ) ) {
+    }
+#if !defined(WIN32)
+    else if( S_ISDIR( fileinfo.st_mode ) ) {
 	dvd_reader_t *auth_drive = 0;
 	char *path_copy;
 #if defined(SYS_BSD)
@@ -441,6 +464,7 @@
 	fprintf( stderr, "libdvdread: Using normal filesystem access.\n" );
         return DVDOpenPath( path );
     }
+#endif
 
     /* If it's none of the above, screw it. */
     fprintf( stderr, "libdvdread: Could not open %s\n", path );
@@ -780,7 +804,6 @@
 		     lb_number );
             return 0;
         }
-
         return (int64_t) ( dvdcss_read( device->dev, (char *) data, 
 					(int) block_count, encrypted ) 
 			   * (uint64_t) DVD_VIDEO_LB_LEN );

Index: ioctl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit/ioctl.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ioctl.c	13 Jun 2002 22:39:50 -0000	1.3
+++ ioctl.c	10 Jul 2002 03:01:33 -0000	1.4
@@ -29,6 +29,10 @@
  *****************************************************************************/
 #include "config.h"
 
+#if defined(WIN32)
+# define __USE_W32_SOCKETS 1
+#endif
+
 #include <string.h>                                    /* memcpy(), memset() */
 #include <sys/types.h>
 

Index: ioctl.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit/ioctl.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ioctl.h	4 Jun 2002 20:11:15 -0000	1.3
+++ ioctl.h	10 Jul 2002 03:01:33 -0000	1.4
@@ -32,13 +32,6 @@
 int ioctl_SendChallenge     ( int, int *, u8 * );
 int ioctl_SendKey2          ( int, int *, u8 * );
 
-#if defined (__CYGWIN__)
-#include <w32api/windef.h>
-#include <w32api/winnt.h>
-#define va_list void
-#include <w32api/winbase.h>
-#endif
-
 /*****************************************************************************
  * Common macro, BeOS specific
  *****************************************************************************/

Index: libdvdcss.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdvdkit/libdvdcss.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- libdvdcss.c	4 Jun 2002 20:11:15 -0000	1.6
+++ libdvdcss.c	10 Jul 2002 03:01:33 -0000	1.7
@@ -26,6 +26,12 @@
  * Preamble
  *****************************************************************************/
 
+#include "config.h"
+
+#if defined(WIN32)
+# define __USE_W32_SOCKETS 1
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -34,16 +40,15 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#if defined( WIN32 ) && !defined(__CYGWIN__)
+#if defined( WIN32 )
 #   include <io.h>                                                 /* read() */
 #else
 #   include <sys/uio.h>                                      /* struct iovec */
 #endif
 
-#include "config.h"
 #include "common.h"
 
-#if defined( WIN32 ) && !defined(__CYGWIN__)
+#if defined( WIN32 )
 #   include "input_iovec.h"
 #endif
 
@@ -505,7 +510,7 @@
 
         li_read.LowPart = SetFilePointer( (HANDLE) dvdcss->i_fd,
                                           li_read.LowPart,
-                                          &li_read.HighPart, FILE_BEGIN );
+                                          &(li_read.HighPart), FILE_BEGIN );
         if( (li_read.LowPart == INVALID_SET_FILE_POINTER)
             && GetLastError() != NO_ERROR)
         {




More information about the MPlayer-cvslog mailing list