[MPlayer-cvslog] r36046 - in trunk: Copyright Makefile configure libdvdcss/bsdi_dvd.h libdvdcss/common.h libdvdcss/css.c libdvdcss/css.h libdvdcss/csstables.h libdvdcss/device.c libdvdcss/device.h libdvdcss/dvdcss/...

diego subversion at mplayerhq.hu
Sat Mar 23 15:32:26 CET 2013


Author: diego
Date: Sat Mar 23 15:32:26 2013
New Revision: 36046

Log:
Update internal libdvdcss to Git revision 39e0e2b.

Deleted:
   trunk/libdvdcss/bsdi_dvd.h
Modified:
   trunk/Copyright
   trunk/Makefile
   trunk/configure
   trunk/libdvdcss/common.h
   trunk/libdvdcss/css.c
   trunk/libdvdcss/css.h
   trunk/libdvdcss/csstables.h
   trunk/libdvdcss/device.c
   trunk/libdvdcss/device.h
   trunk/libdvdcss/dvdcss/dvdcss.h
   trunk/libdvdcss/error.c
   trunk/libdvdcss/ioctl.c
   trunk/libdvdcss/ioctl.h
   trunk/libdvdcss/libdvdcss.c
   trunk/libdvdcss/libdvdcss.h
   trunk/stream/stream.h

Modified: trunk/Copyright
==============================================================================
--- trunk/Copyright	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/Copyright	Sat Mar 23 15:32:26 2013	(r36046)
@@ -22,7 +22,7 @@ License:    GNU Lesser General Public Li
 
 
 Name:       libdvdcss
-Version:    Subversion r256 + local changes
+Version:    Git 39e0e2b
 URL:        http://developers.videolan.org/libdvdcss/
 Directory:  libdvdcss
 Copyright:  1998-2008 VideoLAN

Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/Makefile	Sat Mar 23 15:32:26 2013	(r36046)
@@ -859,7 +859,7 @@ osdep/mplayer-rc.o: osdep/mplayer.exe.ma
 
 gui/%: CFLAGS += -Wno-strict-prototypes
 
-libdvdcss/%:   CFLAGS := -Ilibdvdcss -DVERSION=\"1.2.12\" $(CFLAGS_LIBDVDCSS) $(CFLAGS)
+libdvdcss/%:   CFLAGS := $(CFLAGS_LIBDVDCSS) $(CFLAGS)
 libdvdnav/%:   CFLAGS := -Ilibdvdnav -DHAVE_CONFIG_H -DVERSION=\"MPlayer-custom\" $(CFLAGS)
 libdvdread4/%: CFLAGS := -Ilibdvdread4 $(CFLAGS_LIBDVDCSS_DVDREAD) $(CFLAGS)
 

Modified: trunk/configure
==============================================================================
--- trunk/configure	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/configure	Sat Mar 23 15:32:26 2013	(r36046)
@@ -3843,13 +3843,8 @@ fi #if win32; then
 
 echocheck "direct.h"
 _direct_h=no
-header_check direct.h && _direct_h=yes
-if [ $_direct_h = yes ]; then
-  def_direct_h='#define HAVE_DIRECT_H 1'
-else
-  # libdvdcss checks this via #ifdef, so we need #undef here.
-  def_direct_h='#undef HAVE_DIRECT_H'
-fi
+def_direct_h='#define HAVE_DIRECT_H 0'
+header_check direct.h && _direct_h=yes && def_direct_h='#define HAVE_DIRECT_H 1'
 echores "$_direct_h"
 
 
@@ -5958,20 +5953,20 @@ echores "$_dvdread"
 
 
 echocheck "internal libdvdcss"
+def_broken_mkdir='#undef HAVE_BROKEN_MKDIR'
 def_dvdio='#undef DVD_STRUCT_IN_SYS_DVDIO_H'
 def_dvd='#undef DVD_STRUCT_IN_DVD_H'
 def_cdio='#undef DVD_STRUCT_IN_SYS_CDIO_H'
 def_cdrom='#undef DVD_STRUCT_IN_LINUX_CDROM_H'
-def_bsdi_dvd='#undef DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H'
 def_hpux_scsi_h='#undef HPUX_SCTL_IO'
 def_sol_scsi_h='#undef SOLARIS_USCSI'
+def_sys_uio_h='#undef HAVE_SYS_UIO_H'
 _dvdio=no
 _dvd=no
 _cdio=no
 _cdrom=no
 _sol_scsi_h=no
 _hpux_scsi_h=no
-_bsdi_dvd=no
 if test "$_libdvdcss_internal" = auto && test "$_dvdread_internal" = yes ; then
   _libdvdcss_internal=no
   test -d libdvdcss && _libdvdcss_internal=yes
@@ -6001,13 +5996,17 @@ if test "$_libdvdcss_internal" = auto &&
     header_check sys/scsi.h && _hpux_scsi_h=yes &&
       def_hpux_scsi_h='#define HPUX_SCTL_IO 1' ||
       _libdvdcss_internal=no
-  elif bsdos; then
-    header_check dvd.h && _bsdi_dvd=yes &&
-      def_bsdi_dvd='#define DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H 1'
   fi
+
+  statement_check_broken stddef.h sys/stat.h 'mkdir(NULL, 0)' ||
+    def_broken_mkdir='#define HAVE_BROKEN_MKDIR 1'
+
+  header_check "sys/uio.h" &&
+    def_sys_uio_h='#define HAVE_SYS_UIO_H 1'
+
 fi
 if test "$_libdvdcss_internal" = yes ; then
-  if linux || netbsd || openbsd || bsdos || wine ; then
+  if linux || netbsd || openbsd || wine ; then
     def_dvd_linux='#define HAVE_LINUX_DVD_STRUCT 1'
     openbsd && def_dvd_openbsd='#define HAVE_OPENBSD_DVD_STRUCT 1'
   elif freebsd || dragonfly ; then
@@ -6016,9 +6015,9 @@ if test "$_libdvdcss_internal" = yes ; t
     def_dvd_darwin='#define DARWIN_DVD_IOCTL'
     extra_ldflags="$extra_ldflags -framework IOKit -framework Carbon"
   elif cygwin ; then
-    cflags_libdvdcss="-DSYS_CYGWIN -DWIN32"
-  elif os2 ; then
-    cflags_libdvdcss="-DSYS_OS2"
+    cflags_libdvdcss="-D_WIN32_IE=0x0500 -mwin32"
+  elif mingw ; then
+    cflags_libdvdcss="-D_WIN32_IE=0x0500"
   fi
   cflags_libdvdcss_dvdread="-Ilibdvdcss"
   def_dvdcss="#define HAVE_DVDCSS_DVDCSS_H 1"
@@ -8618,6 +8617,11 @@ cat > $TMPH << EOF
 #undef FAST_OSD
 #undef FAST_OSD_TABLE
 
+/* Required for libdvdcss and some files below stream/. */
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
 /* Define this to enable MPEG-1/2 image postprocessing in libmpeg2 */
 #define MPEG12_POSTPROC 1
 #define ATTRIBUTE_ALIGNED_MAX 16
@@ -8637,7 +8641,7 @@ $def_fast_inttypes
 #define HAVE_ERRNO_H 1
 #define HAVE_INTTYPES_H 1
 #define HAVE_UNISTD_H 1
-$def_bsdi_dvd
+$def_broken_mkdir
 $def_cdio
 $def_cdrom
 $def_dvd
@@ -8649,6 +8653,7 @@ $def_dvdcss
 $def_dvdio
 $def_hpux_scsi_h
 $def_sol_scsi_h
+$def_sys_uio_h
 
 /* libdvdcss + libdvdread */
 #define HAVE_LIMITS_H 1

Modified: trunk/libdvdcss/common.h
==============================================================================
--- trunk/libdvdcss/common.h	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/common.h	Sat Mar 23 15:32:26 2013	(r36046)
@@ -3,7 +3,6 @@
  * Collection of useful common types and macros definitions
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id$
  *
  * Authors: Sam Hocevar <sam at via.ecp.fr>
  *          Vincent Seguin <seguin at via.ecp.fr>
@@ -34,11 +33,6 @@
 #   include <stdint.h>
 #elif defined( HAVE_INTTYPES_H )
 #   include <inttypes.h>
-#elif defined( SYS_CYGWIN )
-#   include <sys/types.h>
-    /* Cygwin only defines half of these... */
-    typedef u_int8_t            uint8_t;
-    typedef u_int32_t           uint32_t;
 #else
     /* Fallback types (very x86-centric, sorry) */
     typedef unsigned char       uint8_t;
@@ -48,6 +42,7 @@
 #endif
 
 #if defined( WIN32 )
+#   include <io.h>                                             /* _lseeki64 */
 
 #   ifndef PATH_MAX
 #      define PATH_MAX MAX_PATH
@@ -74,6 +69,7 @@ typedef __int64 off_t;
 #           define off_t __int64
 #       endif
 #       define stat _stati64
+#       define snprintf _snprintf
 #   endif
 
 #endif

Modified: trunk/libdvdcss/css.c
==============================================================================
--- trunk/libdvdcss/css.c	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/css.c	Sat Mar 23 15:32:26 2013	(r36046)
@@ -2,7 +2,6 @@
  * css.c: Functions for DVD authentication and descrambling
  *****************************************************************************
  * Copyright (C) 1999-2008 VideoLAN
- * $Id$
  *
  * Authors: Stéphane Borel <stef at via.ecp.fr>
  *          Håkan Hjort <d95hjort at dtek.chalmers.se>
@@ -62,6 +61,8 @@
 #include "ioctl.h"
 #include "device.h"
 
+#define PSZ_KEY_SIZE (KEY_SIZE * 3)
+
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
@@ -87,44 +88,54 @@ static int  AttackPattern   ( uint8_t co
 static int  AttackPadding   ( uint8_t const[], int, uint8_t * );
 #endif
 
+static int  _dvdcss_titlekey    ( dvdcss_t, int , dvd_key_t );
+
 /*****************************************************************************
  * _dvdcss_test: check if the disc is encrypted or not
  *****************************************************************************
- * Sets b_scrambled, b_ioctls
+ * Return values:
+ *   1: DVD is scrambled but can be read
+ *   0: DVD is not scrambled and can be read
+ *  -1: could not get "copyright" information
+ *  -2: could not get RPC information (reading the disc might be possible)
+ *  -3: drive is RPC-II, region is not set, and DVD is scrambled: the RPC
+ *      scheme will prevent us from reading the scrambled data
  *****************************************************************************/
-void _dvdcss_test( dvdcss_t dvdcss )
+int _dvdcss_test( dvdcss_t dvdcss )
 {
     char const *psz_type, *psz_rpc;
     int i_ret, i_copyright, i_type, i_mask, i_rpc;
 
     i_ret = ioctl_ReadCopyright( dvdcss->i_fd, 0 /* i_layer */, &i_copyright );
 
+#ifdef WIN32
     if( i_ret < 0 )
     {
         /* Maybe we didn't have enough privileges to read the copyright
          * (see ioctl_ReadCopyright comments).
          * Apparently, on unencrypted DVDs _dvdcss_disckey() always fails, so
          * we can check this as a workaround. */
-#ifdef WIN32
         i_ret = 0;
-#else
-        /* Since it's the first ioctl we try to issue, we add a notice */
-        print_error( dvdcss, "css error: could not get \"copyright\""
-                     " information, make sure there is a DVD in the drive,"
-                     " and that you have used the correct device node." );
-        /* Try without ioctls */
-        dvdcss->b_ioctls = 0;
-#endif
         i_copyright = 1;
         if( _dvdcss_disckey( dvdcss ) < 0 )
         {
             i_copyright = 0;
         }
     }
+#endif
+
+    if( i_ret < 0 )
+    {
+        /* Since it's the first ioctl we try to issue, we add a notice */
+        print_error( dvdcss, "css error: could not get \"copyright\""
+                     " information, make sure there is a DVD in the drive,"
+                     " and that you have used the correct device node." );
+
+        return -1;
+    }
 
     print_debug( dvdcss, "disc reports copyright information 0x%x",
                          i_copyright );
-    dvdcss->b_scrambled = i_copyright;
 
     i_ret = ioctl_ReportRPC( dvdcss->i_fd, &i_type, &i_mask, &i_rpc);
 
@@ -157,7 +168,10 @@ void _dvdcss_test( dvdcss_t dvdcss )
     {
         print_error( dvdcss, "css error: drive will prevent access to "
                              "scrambled data" );
+        return -3;
     }
+
+    return i_copyright ? 1 : 0;
 }
 
 /*****************************************************************************
@@ -205,12 +219,12 @@ int _dvdcss_title ( dvdcss_t dvdcss, int
 
         if( i_fd >= 0 )
         {
-            char psz_key[KEY_SIZE * 3];
+            char psz_key[PSZ_KEY_SIZE];
             unsigned int k0, k1, k2, k3, k4;
 
-            psz_key[KEY_SIZE * 3 - 1] = '\0';
+            psz_key[PSZ_KEY_SIZE - 1] = '\0';
 
-            if( read( i_fd, psz_key, KEY_SIZE * 3 - 1 ) == KEY_SIZE * 3 - 1
+            if( read( i_fd, psz_key, PSZ_KEY_SIZE - 1 ) == PSZ_KEY_SIZE - 1
                  && sscanf( psz_key, "%x:%x:%x:%x:%x",
                             &k0, &k1, &k2, &k3, &k4 ) == 5 )
             {
@@ -237,7 +251,7 @@ int _dvdcss_title ( dvdcss_t dvdcss, int
 
         if( i_ret < 0 )
         {
-            print_error( dvdcss, "fatal error in vts css key" );
+            print_error( dvdcss, "fatal error in VTS CSS key" );
             return i_ret;
         }
 
@@ -254,13 +268,17 @@ int _dvdcss_title ( dvdcss_t dvdcss, int
         i_fd = open( dvdcss->psz_cachefile, O_RDWR|O_CREAT, 0644 );
         if( i_fd >= 0 )
         {
-            char psz_key[KEY_SIZE * 3 + 2];
+            char psz_key[PSZ_KEY_SIZE + 2];
 
             sprintf( psz_key, "%02x:%02x:%02x:%02x:%02x\r\n",
                               p_title_key[0], p_title_key[1], p_title_key[2],
                               p_title_key[3], p_title_key[4] );
 
-            write( i_fd, psz_key, KEY_SIZE * 3 + 1 );
+            if( write( i_fd, psz_key, PSZ_KEY_SIZE + 1 ) < PSZ_KEY_SIZE + 1 )
+            {
+                print_error( dvdcss,
+                             "Error caching key on disk, continuing..\n" );
+            }
             close( i_fd );
         }
     }
@@ -327,7 +345,7 @@ int _dvdcss_disckey( dvdcss_t dvdcss )
         return -1;
     }
 
-    /* This should have invaidated the AGID and got us ASF=1. */
+    /* This should have invalidated the AGID and got us ASF=1. */
     if( GetASF( dvdcss ) != 1 )
     {
         /* Region mismatch (or region not set) is the most likely source. */
@@ -395,7 +413,7 @@ int _dvdcss_disckey( dvdcss_t dvdcss )
 /*****************************************************************************
  * _dvdcss_titlekey: get title key.
  *****************************************************************************/
-int _dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key_t p_title_key )
+static int _dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key_t p_title_key )
 {
     static uint8_t p_garbage[ DVDCSS_BLOCK_SIZE ];  /* we never read it back */
     uint8_t p_key[ KEY_SIZE ];
@@ -443,9 +461,9 @@ int _dvdcss_titlekey( dvdcss_t dvdcss, i
                 break;
 
             case 1:
-                /* Drive status is ok. */
+                /* Drive status is OK. */
                 /* If the title key request failed, but we did not loose ASF,
-                 * we might stil have the AGID.  Other code assume that we
+                 * we might still have the AGID.  Other code assumes that we
                  * will not after this so invalidate it(?). */
                 if( i_ret < 0 )
                 {
@@ -498,7 +516,7 @@ int _dvdcss_titlekey( dvdcss_t dvdcss, i
     /* METHOD is TITLE, we can't use the ioctls or requesting the title key
      * failed above.  For these cases we try to crack the key instead. */
 
-    /* For now, the read limit is 9Gb / 2048 =  4718592 sectors. */
+    /* For now, the read limit is 9GB / 2048 =  4718592 sectors. */
     i_ret = CrackTitleKey( dvdcss, i_pos, 4718592, p_key );
 
     memcpy( p_title_key, p_key, KEY_SIZE );
@@ -561,7 +579,7 @@ int _dvdcss_unscramble( dvd_key_t p_key,
  * It simulates the mutual authentication between logical unit and host,
  * and stops when a session key (called bus key) has been established.
  * Always do the full auth sequence. Some drives seem to lie and always
- * respond with ASF=1.  For instance the old DVD roms on Compaq Armada says
+ * respond with ASF=1. For instance the old DVD-ROMs on Compaq Armada says
  * that ASF=1 from the start and then later fail with a 'read of scrambled
  * block without authentication' error.
  *****************************************************************************/
@@ -743,7 +761,7 @@ static int GetASF( dvdcss_t dvdcss )
 /*****************************************************************************
  * CryptKey : shuffles bits and unencrypt keys.
  *****************************************************************************
- * Used during authentication and disc key negociation in GetBusKey.
+ * Used during authentication and disc key negotiation in GetBusKey.
  * i_key_type : 0->key1, 1->key2, 2->buskey.
  * i_variant : between 0 and 31.
  *****************************************************************************/
@@ -751,13 +769,13 @@ static void CryptKey( int i_key_type, in
                       uint8_t const *p_challenge, uint8_t *p_key )
 {
     /* Permutation table for challenge */
-    uint8_t pp_perm_challenge[3][10] =
+    static const uint8_t pp_perm_challenge[3][10] =
             { { 1, 3, 0, 7, 5, 2, 9, 6, 4, 8 },
               { 6, 1, 9, 3, 8, 5, 7, 4, 0, 2 },
               { 4, 0, 3, 5, 7, 2, 8, 6, 1, 9 } };
 
     /* Permutation table for variant table for key2 and buskey */
-    uint8_t pp_perm_variant[2][32] =
+    static const uint8_t pp_perm_variant[2][32] =
             { { 0x0a, 0x08, 0x0e, 0x0c, 0x0b, 0x09, 0x0f, 0x0d,
                 0x1a, 0x18, 0x1e, 0x1c, 0x1b, 0x19, 0x1f, 0x1d,
                 0x02, 0x00, 0x06, 0x04, 0x03, 0x01, 0x07, 0x05,
@@ -767,14 +785,14 @@ static void CryptKey( int i_key_type, in
                 0x13, 0x1b, 0x17, 0x1f, 0x03, 0x0b, 0x07, 0x0f,
                 0x11, 0x19, 0x15, 0x1d, 0x01, 0x09, 0x05, 0x0d } };
 
-    uint8_t p_variants[32] =
+    static const uint8_t p_variants[32] =
             {   0xB7, 0x74, 0x85, 0xD0, 0xCC, 0xDB, 0xCA, 0x73,
                 0x03, 0xFE, 0x31, 0x03, 0x52, 0xE0, 0xB7, 0x42,
                 0x63, 0x16, 0xF2, 0x2A, 0x79, 0x52, 0xFF, 0x1B,
                 0x7A, 0x11, 0xCA, 0x1A, 0x9B, 0x40, 0xAD, 0x01 };
 
     /* The "secret" key */
-    uint8_t p_secret[5] = { 0x55, 0xD6, 0xC4, 0xC5, 0x28 };
+    static const uint8_t p_secret[5] = { 0x55, 0xD6, 0xC4, 0xC5, 0x28 };
 
     uint8_t p_bits[30], p_scratch[10], p_tmp1[5], p_tmp2[5];
     uint8_t i_lfsr0_o;  /* 1 bit used */
@@ -824,7 +842,7 @@ static void CryptKey( int i_key_type, in
      * The first LFSR is of degree 25,  and has a polynomial of:
      * x^13 + x^5 + x^4 + x^1 + 1
      *
-     * The second LSFR is of degree 17,  and has a (primitive) polynomial of:
+     * The second LFSR is of degree 17,  and has a (primitive) polynomial of:
      * x^15 + x^1 + 1
      *
      * I don't know if these polynomials are primitive modulo 2,  and thus
@@ -838,7 +856,7 @@ static void CryptKey( int i_key_type, in
      */
 
     /* In order to ensure that the LFSR works we need to ensure that the
-     * initial values are non-zero.  Thus when we initialise them from
+     * initial values are non-zero.  Thus when we initialize them from
      * the seed,  we ensure that a bit is set.
      */
     i_lfsr0 = ( p_tmp1[0] << 17 ) | ( p_tmp1[1] << 9 ) |
@@ -947,7 +965,7 @@ static void CryptKey( int i_key_type, in
  * in _dvdcss_titlekey.
  * The player keys and the resulting disc key are only used as KEKs
  * (key encryption keys).
- * Decryption is slightly dependant on the type of key:
+ * Decryption is slightly dependent on the type of key:
  *  -for disc key, invert is 0x00,
  *  -for title key, invert if 0xff.
  *****************************************************************************/
@@ -1182,7 +1200,7 @@ static int CrackDiscKey( dvdcss_t dvdcss
         }
     }
 
-    /* Initing our Really big table */
+    /* Initializing our really big table */
     BigTable = calloc( 16777216, sizeof(int) );
     if( BigTable == NULL )
     {
@@ -1211,7 +1229,7 @@ static int CrackDiscKey( dvdcss_t dvdcss
     }
 
     /*
-     * We are done initing, now reverse hash
+     * We are done initializing, now reverse hash
      */
     tmp5 = p_disc_key[0] ^ p_css_tab1[ p_disc_key[1] ];
 
@@ -1229,7 +1247,7 @@ static int CrackDiscKey( dvdcss_t dvdcss
             out1[ i ] = p_css_tab4[ tmp ];
         }
 
-        /* cumpute and cache some variables */
+        /* compute and cache some variables */
         C[0] = nStepA >> 8;
         C[1] = nStepA & 0xff;
         tmp = p_disc_key[3] ^ p_css_tab1[ p_disc_key[4] ];
@@ -1345,7 +1363,7 @@ static int RecoverTitleKey( int i_start,
         /* iterate cipher 4 times to reconstruct LFSR2 */
         for( i = 0 ; i < 4 ; i++ )
         {
-            /* advance LFSR1 normaly */
+            /* advance LFSR1 normally */
             i_t4 = p_css_tab2[i_t2] ^ p_css_tab3[i_t1];
             i_t2 = i_t1 >> 1;
             i_t1 = ( ( i_t1 & 1 ) << 8 ) ^ i_t4;
@@ -1398,7 +1416,7 @@ static int RecoverTitleKey( int i_start,
             {
                 i_t1 = i_t3 & 0xff;
                 i_t3 = ( i_t3 >> 8 );
-                /* easy to code, and fast enough bruteforce
+                /* easy to code, and fast enough brute-force
                  * search for byte shifted in */
                 for( j = 0 ; j < 256 ; j++ )
                 {
@@ -1446,11 +1464,11 @@ static int RecoverTitleKey( int i_start,
  * Various pieces for the title crack engine.
  ******************************************************************************
  * The length of the PES packet is located at 0x12-0x13.
- * The the copyrigth protection bits are located at 0x14 (bits 0x20 and 0x10).
+ * The the copyright protection bits are located at 0x14 (bits 0x20 and 0x10).
  * The data of the PES packet begins at 0x15 (if there isn't any PTS/DTS)
  * or at 0x?? if there are both PTS and DTS's.
  * The seed value used with the unscrambling key is the 5 bytes at 0x54-0x58.
- * The scrabled part of a sector begins at 0x80.
+ * The scrambled part of a sector begins at 0x80.
  *****************************************************************************/
 
 /* Statistics */
@@ -1594,7 +1612,7 @@ static int CrackTitleKey( dvdcss_t dvdcs
  ******************************************************************************
  * Tries to find a repeating pattern just before the encrypted part starts.
  * Then it guesses that the plain text for first encrypted bytes are
- * a contiuation of that pattern.
+ * a continuation of that pattern.
  *****************************************************************************/
 static int AttackPattern( uint8_t const p_sec[ DVDCSS_BLOCK_SIZE ],
                           int i_pos, uint8_t *p_key )
@@ -1655,7 +1673,7 @@ static int AttackPattern( uint8_t const 
  ******************************************************************************
  * DVD specifies that there must only be one type of data in every sector.
  * Every sector is one pack and so must obviously be 2048 bytes long.
- * For the last pice of video data before a VOBU boundary there might not
+ * For the last piece of video data before a VOBU boundary there might not
  * be exactly the right amount of data to fill a sector. Then one has to
  * pad the pack to 2048 bytes. For just a few bytes this is done in the
  * header but for any large amount you insert a PES packet from the
@@ -1670,7 +1688,7 @@ static int AttackPadding( uint8_t const 
 
     i_pes_length = (p_sec[0x12]<<8) | p_sec[0x13];
 
-    /* Coverd by the test below but usfull for debuging. */
+    /* Covered by the test below but useful for debugging. */
     if( i_pes_length == DVDCSS_BLOCK_SIZE - 0x14 ) return 0;
 
     /* There must be room for at least 4? bytes of padding stream,
@@ -1699,7 +1717,7 @@ static int AttackPadding( uint8_t const 
        are also known. */
 
     /* An encrypted SPU PES packet with another encrypted PES packet following.
-       Normaly if the following was a padding stream that would be in plain
+       Normally if the following was a padding stream that would be in plain
        text. So it will be another SPU PES packet. */
     if( p_sec[0x11] == 0xbd &&
         p_sec[0x17 + p_sec[0x16]] >= 0x20 &&
@@ -1709,7 +1727,7 @@ static int AttackPadding( uint8_t const 
     }
 
     /* A Video PES packet with another encrypted PES packet following.
-     * No reason execpt for time stamps to break the data into two packets.
+     * No reason except for time stamps to break the data into two packets.
      * So it's likely that the following PES packet is a padding stream. */
     if( p_sec[0x11] == 0xe0 )
     {

Modified: trunk/libdvdcss/css.h
==============================================================================
--- trunk/libdvdcss/css.h	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/css.h	Sat Mar 23 15:32:26 2013	(r36046)
@@ -2,7 +2,6 @@
  * css.h: Structures for DVD authentication and unscrambling
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id$
  *
  * Author: Stéphane Borel <stef at via.ecp.fr>
  *
@@ -45,7 +44,7 @@ typedef struct dvd_title_s
 
 typedef struct css_s
 {
-    int             i_agid;      /* Current Authenication Grant ID. */
+    int             i_agid;      /* Current Authentication Grant ID. */
     dvd_key_t       p_bus_key;   /* Current session key. */
     dvd_key_t       p_disc_key;  /* This DVD disc's key. */
     dvd_key_t       p_title_key; /* Current title key. */
@@ -54,10 +53,9 @@ typedef struct css_s
 /*****************************************************************************
  * Prototypes in css.c
  *****************************************************************************/
-void  _dvdcss_test        ( dvdcss_t );
+int   _dvdcss_test        ( dvdcss_t );
 int   _dvdcss_title       ( dvdcss_t, int );
 int   _dvdcss_disckey     ( dvdcss_t );
-int   _dvdcss_titlekey    ( dvdcss_t, int , dvd_key_t );
 int   _dvdcss_unscramble  ( uint8_t *, uint8_t * );
 
 #endif /* DVDCSS_CSS_H */

Modified: trunk/libdvdcss/csstables.h
==============================================================================
--- trunk/libdvdcss/csstables.h	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/csstables.h	Sat Mar 23 15:32:26 2013	(r36046)
@@ -2,7 +2,6 @@
  * csstables.h: CSS Tables for DVD unscrambling
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id$
  *
  * Author: Stéphane Borel <stef at via.ecp.fr>
  *
@@ -32,7 +31,7 @@
 #ifndef DVDCSS_CSSTABLES_H
 #define DVDCSS_CSSTABLES_H
 
-static uint8_t p_css_tab1[ 256 ] =
+static const uint8_t p_css_tab1[ 256 ] =
 {
     0x33, 0x73, 0x3b, 0x26, 0x63, 0x23, 0x6b, 0x76,
     0x3e, 0x7e, 0x36, 0x2b, 0x6e, 0x2e, 0x66, 0x7b,
@@ -68,7 +67,7 @@ static uint8_t p_css_tab1[ 256 ] =
     0xba, 0xfa, 0xb2, 0xaf, 0xea, 0xaa, 0xe2, 0xff
 };
 
-static uint8_t p_css_tab2[ 256 ] =
+static const uint8_t p_css_tab2[ 256 ] =
 {
     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
     0x09, 0x08, 0x0b, 0x0a, 0x0d, 0x0c, 0x0f, 0x0e,
@@ -104,7 +103,7 @@ static uint8_t p_css_tab2[ 256 ] =
     0xe4, 0xe5, 0xe6, 0xe7, 0xe0, 0xe1, 0xe2, 0xe3
 };
 
-static uint8_t p_css_tab3[ 512 ] =
+static const uint8_t p_css_tab3[ 512 ] =
 {
     0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff,
     0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff,
@@ -172,7 +171,7 @@ static uint8_t p_css_tab3[ 512 ] =
     0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff
 };
 
-static uint8_t p_css_tab4[ 256 ] =
+static const uint8_t p_css_tab4[ 256 ] =
 {
     0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
     0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
@@ -208,7 +207,7 @@ static uint8_t p_css_tab4[ 256 ] =
     0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
 };
 
-static uint8_t p_css_tab5[ 256 ] =
+static const uint8_t p_css_tab5[ 256 ] =
 {
     0xff, 0x7f, 0xbf, 0x3f, 0xdf, 0x5f, 0x9f, 0x1f,
     0xef, 0x6f, 0xaf, 0x2f, 0xcf, 0x4f, 0x8f, 0x0f,
@@ -244,7 +243,7 @@ static uint8_t p_css_tab5[ 256 ] =
     0xe0, 0x60, 0xa0, 0x20, 0xc0, 0x40, 0x80, 0x00
 };
 
-static uint8_t p_crypt_tab0[ 256 ] =
+static const uint8_t p_crypt_tab0[ 256 ] =
 {
     0xB7, 0xF4, 0x82, 0x57, 0xDA, 0x4D, 0xDB, 0xE2,
     0x2F, 0x52, 0x1A, 0xA8, 0x68, 0x5A, 0x8A, 0xFF,
@@ -280,7 +279,7 @@ static uint8_t p_crypt_tab0[ 256 ] =
     0xAD, 0x94, 0x77, 0x04, 0x9A, 0x39, 0xCF, 0x7C
 };
 
-static uint8_t p_crypt_tab1[ 256 ] =
+static const uint8_t p_crypt_tab1[ 256 ] =
 {
     0x8C, 0x47, 0xB0, 0xE1, 0xEB, 0xFC, 0xEB, 0x56,
     0x10, 0xE5, 0x2C, 0x1A, 0x5D, 0xEF, 0xBE, 0x4F,
@@ -316,7 +315,7 @@ static uint8_t p_crypt_tab1[ 256 ] =
     0xAA, 0x1B, 0x79, 0x8E, 0x97, 0xB4, 0xC3, 0xF4
 };
 
-static uint8_t p_crypt_tab2[ 256 ] =
+static const uint8_t p_crypt_tab2[ 256 ] =
 {
     0xB7, 0x75, 0x81, 0xD5, 0xDC, 0xCA, 0xDE, 0x66,
     0x23, 0xDF, 0x15, 0x26, 0x62, 0xD1, 0x83, 0x77,
@@ -352,7 +351,7 @@ static uint8_t p_crypt_tab2[ 256 ] =
     0x29, 0x91, 0xF0, 0x02, 0x18, 0x3A, 0x4E, 0x7C
 };
 
-static uint8_t p_crypt_tab3[ 288 ] =
+static const uint8_t p_crypt_tab3[ 288 ] =
 {
     0x73, 0x51, 0x95, 0xE1, 0x12, 0xE4, 0xC0, 0x58,
     0xEE, 0xF2, 0x08, 0x1B, 0xA9, 0xFA, 0x98, 0x4C,

Modified: trunk/libdvdcss/device.c
==============================================================================
--- trunk/libdvdcss/device.c	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/device.c	Sat Mar 23 15:32:26 2013	(r36046)
@@ -2,7 +2,6 @@
  * device.h: DVD device access
  *****************************************************************************
  * Copyright (C) 1998-2006 VideoLAN
- * $Id$
  *
  * Authors: Stéphane Borel <stef at via.ecp.fr>
  *          Sam Hocevar <sam at zoy.org>
@@ -49,12 +48,6 @@
 #   include <limits.h>
 #endif
 
-#if defined( WIN32 ) && !defined( SYS_CYGWIN )
-#   include <io.h>                                                 /* read() */
-#else
-#   include <sys/uio.h>                                      /* struct iovec */
-#endif
-
 #ifdef DARWIN_DVD_IOCTL
 #   include <paths.h>
 #   include <CoreFoundation/CoreFoundation.h>
@@ -65,7 +58,7 @@
 #   include <IOKit/storage/IODVDMedia.h>
 #endif
 
-#ifdef SYS_OS2
+#ifdef __OS2__
 #   define INCL_DOS
 #   define INCL_DOSDEVIOCTL
 #   include <os2.h>
@@ -99,7 +92,7 @@ static int aspi_read  ( dvdcss_t, void *
 static int win_readv  ( dvdcss_t, struct iovec *, int );
 
 static int aspi_read_internal  ( int, void *, int );
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
 static int os2_open ( dvdcss_t, char const * );
 /* just use macros for libc */
 #   define os2_seek     libc_seek
@@ -124,7 +117,7 @@ int _dvdcss_use_ioctls( dvdcss_t dvdcss 
     {
         return 1;
     }
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     ULONG ulMode;
 
     if( DosQueryFHState( dvdcss->i_fd, &ulMode ) != 0 )
@@ -154,7 +147,6 @@ int _dvdcss_use_ioctls( dvdcss_t dvdcss 
      * OpenBSD  needs a char device
      * NetBSD   needs a char device
      * FreeBSD  can use either the block or the char device
-     * BSD/OS   can use either the block or the char device
      */
 
     /* Check if this is a block/char device */
@@ -181,7 +173,7 @@ void _dvdcss_check ( dvdcss_t dvdcss )
     kern_return_t kern_result;
     io_iterator_t media_iterator;
     CFMutableDictionaryRef classes_to_match;
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
 #pragma pack( 1 )
     struct
     {
@@ -239,7 +231,7 @@ void _dvdcss_check ( dvdcss_t dvdcss )
         /* Remove trailing backslash */
         psz_device[2] = '\0';
 
-        /* FIXME: we want to differenciate between CD and DVD drives
+        /* FIXME: we want to differentiate between CD and DVD drives
          * using DeviceIoControl() */
         print_debug( dvdcss, "defaulting to drive `%s'", psz_device );
         free( dvdcss->psz_device );
@@ -316,7 +308,7 @@ void _dvdcss_check ( dvdcss_t dvdcss )
     }
 
     IOObjectRelease( media_iterator );
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     for( i = 0; i < 26; i++ )
     {
         param.bCmdInfo = 0;
@@ -394,7 +386,7 @@ int _dvdcss_open ( dvdcss_t dvdcss )
         return aspi_open( dvdcss, psz_device );
     }
     else
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     /* If device is "X:" or "X:\", we are not actually opening a file. */
     if( psz_device[0] && psz_device[1] == ':' &&
         ( !psz_device[2] || ( psz_device[2] == '\\' && !psz_device[3] ) ) )
@@ -416,7 +408,7 @@ int _dvdcss_open ( dvdcss_t dvdcss )
     }
 }
 
-#if !defined(WIN32) && !defined(SYS_OS2)
+#ifdef DVDCSS_RAW_OPEN
 int _dvdcss_raw_open ( dvdcss_t dvdcss, char const *psz_device )
 {
     dvdcss->i_raw_fd = open( psz_device, 0 );
@@ -452,7 +444,7 @@ int _dvdcss_close ( dvdcss_t dvdcss )
     {
         struct w32_aspidev *fd = (struct w32_aspidev *) dvdcss->i_fd;
 
-        /* Unload aspi and free w32_aspidev structure */
+        /* Unload ASPI and free w32_aspidev structure */
         FreeLibrary( (HMODULE) fd->hASPI );
         free( (void*) dvdcss->i_fd );
     }
@@ -469,7 +461,7 @@ int _dvdcss_close ( dvdcss_t dvdcss )
 #else
     close( dvdcss->i_fd );
 
-#ifndef SYS_OS2
+#ifdef DVDCSS_RAW_OPEN
     if( dvdcss->i_raw_fd >= 0 )
     {
         close( dvdcss->i_raw_fd );
@@ -488,11 +480,7 @@ int _dvdcss_close ( dvdcss_t dvdcss )
  *****************************************************************************/
 static int libc_open ( dvdcss_t dvdcss, char const *psz_device )
 {
-#if !defined( WIN32 ) && !defined( SYS_OS2 )
-    dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, 0 );
-#else
     dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, O_BINARY );
-#endif
 
     if( dvdcss->i_fd == -1 )
     {
@@ -516,7 +504,7 @@ static int win2k_open ( dvdcss_t dvdcss,
     /* To work around an M$ bug in IOCTL_DVD_READ_STRUCTURE, we need read
      * _and_ write access to the device (so we can make SCSI Pass Through
      * Requests). Unfortunately this is only allowed if you have
-     * administrator priviledges so we allow for a fallback method with
+     * administrator privileges so we allow for a fallback method with
      * only read access to the device (in this case ioctl_ReadCopyright()
      * won't send back the right result).
      * (See Microsoft Q241374: Read and Write Access Required for SCSI
@@ -554,7 +542,7 @@ static int aspi_open( dvdcss_t dvdcss, c
     SENDASPI32COMMAND lpSendCommand;
     char c_drive = psz_device[0];
 
-    /* load aspi and init w32_aspidev structure */
+    /* load ASPI and init w32_aspidev structure */
     hASPI = LoadLibrary( "wnaspi32.dll" );
     if( hASPI == NULL )
     {
@@ -567,7 +555,7 @@ static int aspi_open( dvdcss_t dvdcss, c
 
     if(lpGetSupport == NULL || lpSendCommand == NULL )
     {
-        print_error( dvdcss, "unable to get aspi function pointers" );
+        print_error( dvdcss, "unable to get ASPI function pointers" );
         FreeLibrary( hASPI );
         return -1;
     }
@@ -583,7 +571,7 @@ static int aspi_open( dvdcss_t dvdcss, c
 
     if( HIBYTE( LOWORD ( dwSupportInfo ) ) != SS_COMP )
     {
-        print_error( dvdcss, "unable to initalize aspi layer" );
+        print_error( dvdcss, "unable to initialize ASPI layer" );
         FreeLibrary( hASPI );
         return -1;
     }
@@ -628,10 +616,9 @@ static int aspi_open( dvdcss_t dvdcss, c
             if( (srbDiskInfo.SRB_Status == SS_COMP) &&
                 (srbDiskInfo.SRB_Int13HDriveInfo == c_drive) )
             {
-                /* Make sure this is a cdrom device */
-                struct SRB_GDEVBlock srbGDEVBlock;
+                /* Make sure this is a CD-ROM device */
+                struct SRB_GDEVBlock srbGDEVBlock = { 0 };
 
-                memset( &srbGDEVBlock, 0, sizeof(struct SRB_GDEVBlock) );
                 srbGDEVBlock.SRB_Cmd    = SC_GET_DEV_TYPE;
                 srbGDEVBlock.SRB_HaId   = i;
                 srbGDEVBlock.SRB_Target = j;
@@ -650,7 +637,7 @@ static int aspi_open( dvdcss_t dvdcss, c
                 {
                     free( (void*) fd );
                     FreeLibrary( hASPI );
-                    print_error( dvdcss,"this is not a cdrom drive" );
+                    print_error( dvdcss,"this is not a CD-ROM drive" );
                     return -1;
                 }
             }
@@ -659,12 +646,12 @@ static int aspi_open( dvdcss_t dvdcss, c
 
     free( (void*) fd );
     FreeLibrary( hASPI );
-    print_error( dvdcss, "unable to get haid and target (aspi)" );
+    print_error( dvdcss, "unable to get haid and target (ASPI)" );
     return -1;
 }
 #endif
 
-#ifdef SYS_OS2
+#ifdef __OS2__
 static int os2_open ( dvdcss_t dvdcss, char const *psz_device )
 {
     char  psz_dvd[] = "X:";
@@ -881,8 +868,8 @@ static int libc_readv ( dvdcss_t dvdcss,
         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
+             * We won't even bother returning the reads that went OK,
+             * and as in the POSIX spec the file position is left
              * unspecified after a failure */
             dvdcss->i_pos = -1;
             return -1;
@@ -968,7 +955,7 @@ static int win_readv ( dvdcss_t dvdcss, 
                        i_blocks_total * DVDCSS_BLOCK_SIZE, &i_bytes, NULL ) )
         {
             /* The read failed... too bad.
-             * As in the posix spec the file postition is left
+             * As in the POSIX spec the file position is left
              * unspecified after a failure */
             dvdcss->i_pos = -1;
             return -1;
@@ -1010,7 +997,7 @@ static int win_readv ( dvdcss_t dvdcss, 
 static int aspi_read_internal( int i_fd, void *p_data, int i_blocks )
 {
     HANDLE hEvent;
-    struct SRB_ExecSCSICmd ssc;
+    struct SRB_ExecSCSICmd ssc = { 0 };
     struct w32_aspidev *fd = (struct w32_aspidev *) i_fd;
 
     /* Create the transfer completion event */
@@ -1020,8 +1007,6 @@ static int aspi_read_internal( int i_fd,
         return -1;
     }
 
-    memset( &ssc, 0, sizeof( ssc ) );
-
     ssc.SRB_Cmd         = SC_EXEC_SCSI_CMD;
     ssc.SRB_Flags       = SRB_DIR_IN | SRB_EVENT_NOTIFY;
     ssc.SRB_HaId        = LOBYTE( fd->i_sid );
@@ -1038,7 +1023,7 @@ static int aspi_read_internal( int i_fd,
     ssc.CDBByte[4]      = (UCHAR) (fd->i_blocks >> 8) & 0xff;
     ssc.CDBByte[5]      = (UCHAR) (fd->i_blocks) & 0xff;
 
-    /* We have to break down the reads into 64kb pieces (ASPI restriction) */
+    /* We have to break down the reads into 64KB pieces (ASPI restriction) */
     if( i_blocks > 32 )
     {
         ssc.SRB_BufLen = 32 * DVDCSS_BLOCK_SIZE;
@@ -1049,7 +1034,7 @@ static int aspi_read_internal( int i_fd,
         ResetEvent( hEvent );
         fd->lpSendCommand( (void*) &ssc );
 
-        /* transfer the next 64kb (aspi_read_internal is called recursively)
+        /* transfer the next 64KB (aspi_read_internal is called recursively)
          * We need to check the status of the read on return */
         if( aspi_read_internal( i_fd,
                                 (uint8_t*) p_data + 32 * DVDCSS_BLOCK_SIZE,

Modified: trunk/libdvdcss/device.h
==============================================================================
--- trunk/libdvdcss/device.h	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/device.h	Sat Mar 23 15:32:26 2013	(r36046)
@@ -2,7 +2,6 @@
  * device.h: DVD device access
  *****************************************************************************
  * Copyright (C) 1998-2002 VideoLAN
- * $Id$
  *
  * Authors: Stéphane Borel <stef at via.ecp.fr>
  *          Sam Hocevar <sam at zoy.org>
@@ -26,11 +25,18 @@
 #ifndef DVDCSS_DEVICE_H
 #define DVDCSS_DEVICE_H
 
+#include "config.h"
+
 /*****************************************************************************
  * iovec structure: vectored data entry
  *****************************************************************************/
-#if defined( WIN32 ) && !defined( SYS_CYGWIN )
+#ifndef HAVE_SYS_UIO_H
 #   include <io.h>                                                 /* read() */
+struct iovec
+{
+    void *iov_base;     /* Pointer to data. */
+    size_t iov_len;     /* Length of data.  */
+};
 #else
 #   include <sys/types.h>
 #   include <sys/uio.h>                                      /* struct iovec */
@@ -38,14 +44,11 @@
 
 #include "dvdcss/dvdcss.h"
 
-#if defined( WIN32 ) && !defined( SYS_CYGWIN )
-struct iovec
-{
-    void *iov_base;     /* Pointer to data. */
-    size_t iov_len;     /* Length of data.  */
-};
+#if !defined(WIN32) && !defined(__OS2__)
+#   define DVDCSS_RAW_OPEN
 #endif
 
+
 /*****************************************************************************
  * Device reading prototypes
  *****************************************************************************/
@@ -57,8 +60,6 @@ int  _dvdcss_close      ( dvdcss_t );
 /*****************************************************************************
  * Device reading prototypes, raw-device specific
  *****************************************************************************/
-#if !defined(WIN32) && !defined(SYS_OS2)
 int _dvdcss_raw_open     ( dvdcss_t, char const * );
-#endif
 
 #endif /* DVDCSS_DEVICE_H */

Modified: trunk/libdvdcss/dvdcss/dvdcss.h
==============================================================================
--- trunk/libdvdcss/dvdcss/dvdcss.h	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/dvdcss/dvdcss.h	Sat Mar 23 15:32:26 2013	(r36046)
@@ -10,7 +10,6 @@
 
 /*
  * Copyright (C) 1998-2008 VideoLAN
- * $Id$
  *
  * 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
@@ -60,17 +59,12 @@ typedef struct dvdcss_s* dvdcss_t;
 #define LIBDVDCSS_EXPORT __declspec(dllexport) extern
 #elif defined(LIBDVDCSS_IMPORTS)
 #define LIBDVDCSS_EXPORT __declspec(dllimport) extern
-#elif defined(HAVE_VISIBILITY)
+#elif defined(SUPPORT_ATTRIBUTE_VISIBILITY_DEFAULT)
 #define LIBDVDCSS_EXPORT __attribute__((visibility("default"))) extern
 #else
 #define LIBDVDCSS_EXPORT extern
 #endif
 
-/*
- * Our version number. The variable name contains the interface version.
- */
-LIBDVDCSS_EXPORT char *        dvdcss_interface_2;
-
 
 /*
  * Exported prototypes.
@@ -92,16 +86,6 @@ LIBDVDCSS_EXPORT char *   dvdcss_error (
 
 LIBDVDCSS_EXPORT int      dvdcss_is_scrambled ( dvdcss_t );
 
-
-/*
- * Deprecated stuff.
- */
-#ifndef _DOXYGEN_SKIP_ME
-#define dvdcss_title(a,b) dvdcss_seek(a,b,DVDCSS_SEEK_KEY)
-#define dvdcss_handle dvdcss_t
-#endif
-
-
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/libdvdcss/error.c
==============================================================================
--- trunk/libdvdcss/error.c	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/error.c	Sat Mar 23 15:32:26 2013	(r36046)
@@ -2,7 +2,6 @@
  * error.c: error management functions
  *****************************************************************************
  * Copyright (C) 1998-2002 VideoLAN
- * $Id$
  *
  * Author: Sam Hocevar <sam at zoy.org>
  *

Modified: trunk/libdvdcss/ioctl.c
==============================================================================
--- trunk/libdvdcss/ioctl.c	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/ioctl.c	Sat Mar 23 15:32:26 2013	(r36046)
@@ -2,7 +2,6 @@
  * ioctl.c: DVD ioctl replacement function
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id$
  *
  * Authors: Markus Kuespert <ltlBeBoy at beosmail.com>
  *          Sam Hocevar <sam at zoy.org>
@@ -41,7 +40,7 @@
 #if defined( WIN32 )
 #   include <windows.h>
 #   include <winioctl.h>
-#elif defined ( SYS_OS2 )
+#elif defined ( __OS2__ )
 #   define INCL_DOSFILEMGR
 #   define INCL_DOSDEVICES
 #   define INCL_DOSDEVIOCTL
@@ -65,10 +64,7 @@
 #ifdef DVD_STRUCT_IN_DVD_H
 #   include <dvd.h>
 #endif
-#ifdef DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H
-#   include "bsdi_dvd.h"
-#endif
-#ifdef SYS_BEOS
+#ifdef __BEOS__
 #   include <malloc.h>
 #   include <scsi.h>
 #endif
@@ -97,7 +93,7 @@
 /*****************************************************************************
  * Local prototypes, BeOS specific
  *****************************************************************************/
-#if defined( SYS_BEOS )
+#if defined( __BEOS__ )
 static void BeInitRDC ( raw_device_command *, int );
 #endif
 
@@ -135,7 +131,7 @@ static void QNXInitCPT ( CAM_PASS_THRU *
 /*****************************************************************************
  * Local prototypes, OS2 specific
  *****************************************************************************/
-#if defined( SYS_OS2 )
+#if defined( __OS2__ )
 static void OS2InitSDC( struct OS2_ExecSCSICmd *, int );
 #endif
 
@@ -147,9 +143,8 @@ int ioctl_ReadCopyright( int i_fd, int i
     int i_ret;
 
 #if defined( HAVE_LINUX_DVD_STRUCT )
-    dvd_struct dvd;
+    dvd_struct dvd = { 0 };
 
-    memset( &dvd, 0, sizeof( dvd ) );
     dvd.type = DVD_STRUCT_COPYRIGHT;
     dvd.copyright.layer_num = i_layer;
 
@@ -158,9 +153,8 @@ int ioctl_ReadCopyright( int i_fd, int i
     *pi_copyright = dvd.copyright.cpst;
 
 #elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_struct dvd;
+    struct dvd_struct dvd = { 0 };
 
-    memset( &dvd, 0, sizeof( dvd ) );
     dvd.format = DVD_STRUCT_COPYRIGHT;
     dvd.layer_num = i_layer;
 
@@ -168,7 +162,7 @@ int ioctl_ReadCopyright( int i_fd, int i
 
     *pi_copyright = dvd.cpst;
 
-#elif defined( SYS_BEOS )
+#elif defined( __BEOS__ )
     INIT_RDC( GPCMD_READ_DVD_STRUCTURE, 8 );
 
     rdc.command[ 6 ] = i_layer;
@@ -221,7 +215,7 @@ int ioctl_ReadCopyright( int i_fd, int i
         /*  When using IOCTL_DVD_READ_STRUCTURE and
             DVD_COPYRIGHT_DESCRIPTOR, CopyrightProtectionType
             seems to be always 6 ???
-            To work around this MS bug we try to send a raw scsi command
+            To work around this MS bug we try to send a raw SCSI command
             instead (if we've got enough privileges to do so). */
 
         sptd.Cdb[ 6 ] = i_layer;
@@ -257,7 +251,7 @@ int ioctl_ReadCopyright( int i_fd, int i
 
     *pi_copyright = p_buffer[4];
 
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 );
 
     sdc.command[ 6 ] = i_layer;
@@ -284,12 +278,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi
     int i_ret;
 
 #if defined( HAVE_LINUX_DVD_STRUCT )
-    dvd_struct dvd;
+    dvd_struct dvd = { 0 };
 
-    memset( &dvd, 0, sizeof( dvd ) );
     dvd.type = DVD_STRUCT_DISCKEY;
     dvd.disckey.agid = *pi_agid;
-    memset( dvd.disckey.value, 0, DVD_DISCKEY_SIZE );
 
     i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd );
 
@@ -301,12 +293,10 @@ int ioctl_ReadDiscKey( int i_fd, int *pi
     memcpy( p_key, dvd.disckey.value, DVD_DISCKEY_SIZE );
 
 #elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_struct dvd;
+    struct dvd_struct dvd = { 0 };
 
-    memset( &dvd, 0, sizeof( dvd ) );
     dvd.format = DVD_STRUCT_DISCKEY;
     dvd.agid = *pi_agid;
-    memset( dvd.data, 0, DVD_DISCKEY_SIZE );
 
     i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd );
 
@@ -317,7 +307,7 @@ int ioctl_ReadDiscKey( int i_fd, int *pi
 
     memcpy( p_key, dvd.data, DVD_DISCKEY_SIZE );
 
-#elif defined( SYS_BEOS )
+#elif defined( __BEOS__ )
     INIT_RDC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
 
     rdc.command[ 7 ]  = DVD_STRUCT_DISCKEY;
@@ -377,11 +367,9 @@ int ioctl_ReadDiscKey( int i_fd, int *pi
     if( WIN2K ) /* NT/2k/XP */
     {
         DWORD tmp;
-        uint8_t buffer[DVD_DISK_KEY_LENGTH];
+        uint8_t buffer[DVD_DISK_KEY_LENGTH] = { 0 };
         PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
 
-        memset( &buffer, 0, sizeof( buffer ) );
-
         key->KeyLength  = DVD_DISK_KEY_LENGTH;
         key->SessionId  = *pi_agid;
         key->KeyType    = DvdDiskKey;
@@ -425,7 +413,7 @@ int ioctl_ReadDiscKey( int i_fd, int *pi
 
     memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE );
 
-#elif defined ( SYS_OS2 )
+#elif defined ( __OS2__ )
     INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
 
     sdc.command[ 7 ]  = DVD_STRUCT_DISCKEY;
@@ -457,9 +445,8 @@ int ioctl_ReadTitleKey( int i_fd, int *p
     int i_ret;
 
 #if defined( HAVE_LINUX_DVD_STRUCT )
-    dvd_authinfo auth_info;
+    dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.type = DVD_LU_SEND_TITLE_KEY;
     auth_info.lstk.agid = *pi_agid;
     auth_info.lstk.lba = i_pos;
@@ -469,9 +456,8 @@ int ioctl_ReadTitleKey( int i_fd, int *p
     memcpy( p_key, auth_info.lstk.title_key, DVD_KEY_SIZE );
 
 #elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_authinfo auth_info;
+    struct dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.format = DVD_REPORT_TITLE_KEY;
     auth_info.agid = *pi_agid;
     auth_info.lba = i_pos;
@@ -480,7 +466,7 @@ int ioctl_ReadTitleKey( int i_fd, int *p
 
     memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE );
 
-#elif defined( SYS_BEOS )
+#elif defined( __BEOS__ )
     INIT_RDC( GPCMD_REPORT_KEY, 12 );
 
     rdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff;
@@ -545,11 +531,9 @@ int ioctl_ReadTitleKey( int i_fd, int *p
     if( WIN2K ) /* NT/2k/XP */
     {
         DWORD tmp;
-        uint8_t buffer[DVD_TITLE_KEY_LENGTH];
+        uint8_t buffer[DVD_TITLE_KEY_LENGTH] = { 0 };
         PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
 
-        memset( &buffer, 0, sizeof( buffer ) );
-
         key->KeyLength  = DVD_TITLE_KEY_LENGTH;
         key->SessionId  = *pi_agid;
         key->KeyType    = DvdTitleKey;
@@ -591,7 +575,7 @@ int ioctl_ReadTitleKey( int i_fd, int *p
 
     memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
 
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     INIT_SSC( GPCMD_REPORT_KEY, 12 );
 
     sdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff;
@@ -623,9 +607,8 @@ int ioctl_ReportAgid( int i_fd, int *pi_
     int i_ret;
 
 #if defined( HAVE_LINUX_DVD_STRUCT )
-    dvd_authinfo auth_info;
+    dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.type = DVD_LU_SEND_AGID;
     auth_info.lsa.agid = *pi_agid;
 
@@ -634,9 +617,8 @@ int ioctl_ReportAgid( int i_fd, int *pi_
     *pi_agid = auth_info.lsa.agid;
 
 #elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_authinfo auth_info;
+    struct dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.format = DVD_REPORT_AGID;
     auth_info.agid = *pi_agid;
 
@@ -644,7 +626,7 @@ int ioctl_ReportAgid( int i_fd, int *pi_
 
     *pi_agid = auth_info.agid;
 
-#elif defined( SYS_BEOS )
+#elif defined( __BEOS__ )
     INIT_RDC( GPCMD_REPORT_KEY, 8 );
 
     rdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
@@ -719,7 +701,7 @@ int ioctl_ReportAgid( int i_fd, int *pi_
 
     *pi_agid = p_buffer[ 7 ] >> 6;
 
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     INIT_SSC( GPCMD_REPORT_KEY, 8 );
 
     sdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
@@ -745,9 +727,8 @@ int ioctl_ReportChallenge( int i_fd, int
     int i_ret;
 
 #if defined( HAVE_LINUX_DVD_STRUCT )
-    dvd_authinfo auth_info;
+    dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.type = DVD_LU_SEND_CHALLENGE;
     auth_info.lsc.agid = *pi_agid;
 
@@ -756,9 +737,8 @@ int ioctl_ReportChallenge( int i_fd, int
     memcpy( p_challenge, auth_info.lsc.chal, DVD_CHALLENGE_SIZE );
 
 #elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_authinfo auth_info;
+    struct dvd_authinfo auth_info =  { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.format = DVD_REPORT_CHALLENGE;
     auth_info.agid = *pi_agid;
 
@@ -766,7 +746,7 @@ int ioctl_ReportChallenge( int i_fd, int
 
     memcpy( p_challenge, auth_info.keychal, DVD_CHALLENGE_SIZE );
 
-#elif defined( SYS_BEOS )
+#elif defined( __BEOS__ )
     INIT_RDC( GPCMD_REPORT_KEY, 16 );
 
     rdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
@@ -812,11 +792,9 @@ int ioctl_ReportChallenge( int i_fd, int
     if( WIN2K ) /* NT/2k/XP */
     {
         DWORD tmp;
-        uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH];
+        uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH] = { 0 };
         PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
 
-        memset( &buffer, 0, sizeof( buffer ) );
-
         key->KeyLength  = DVD_CHALLENGE_KEY_LENGTH;
         key->SessionId  = *pi_agid;
         key->KeyType    = DvdChallengeKey;
@@ -853,7 +831,7 @@ int ioctl_ReportChallenge( int i_fd, int
 
     memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
 
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     INIT_SSC( GPCMD_REPORT_KEY, 16 );
 
     sdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
@@ -879,9 +857,8 @@ int ioctl_ReportASF( int i_fd, int *pi_r
     int i_ret;
 
 #if defined( HAVE_LINUX_DVD_STRUCT )
-    dvd_authinfo auth_info;
+    dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.type = DVD_LU_SEND_ASF;
     auth_info.lsasf.asf = *pi_asf;
 
@@ -890,9 +867,8 @@ int ioctl_ReportASF( int i_fd, int *pi_r
     *pi_asf = auth_info.lsasf.asf;
 
 #elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_authinfo auth_info;
+    struct dvd_authinfo auth_info =  { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.format = DVD_REPORT_ASF;
     auth_info.asf = *pi_asf;
 
@@ -900,7 +876,7 @@ int ioctl_ReportASF( int i_fd, int *pi_r
 
     *pi_asf = auth_info.asf;
 
-#elif defined( SYS_BEOS )
+#elif defined( __BEOS__ )
     INIT_RDC( GPCMD_REPORT_KEY, 8 );
 
     rdc.command[ 10 ] = DVD_REPORT_ASF;
@@ -944,16 +920,16 @@ int ioctl_ReportASF( int i_fd, int *pi_r
     if( WIN2K ) /* NT/2k/XP */
     {
         DWORD tmp;
-        uint8_t buffer[DVD_ASF_LENGTH];
+        uint8_t buffer[DVD_ASF_LENGTH] = { 0 };
         PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
-
-        memset( &buffer, 0, sizeof( buffer ) );
+        PDVD_ASF keyData;
 
         key->KeyLength  = DVD_ASF_LENGTH;
         key->KeyType    = DvdAsf;
         key->KeyFlags   = 0;
 
-        ((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf;
+        keyData = (PDVD_ASF)key->KeyData;
+        keyData->SuccessFlag = *pi_asf;
 
         i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
                 key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
@@ -963,7 +939,8 @@ int ioctl_ReportASF( int i_fd, int *pi_r
             return i_ret;
         }
 
-        *pi_asf = ((PDVD_ASF)key->KeyData)->SuccessFlag;
+        keyData = (PDVD_ASF)key->KeyData;
+        *pi_asf = keyData->SuccessFlag;
     }
     else
     {
@@ -986,7 +963,7 @@ int ioctl_ReportASF( int i_fd, int *pi_r
 
     *pi_asf = p_buffer[ 7 ] & 1;
 
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     INIT_SSC( GPCMD_REPORT_KEY, 8 );
 
     sdc.command[ 10 ] = DVD_REPORT_ASF;
@@ -1012,9 +989,8 @@ int ioctl_ReportKey1( int i_fd, int *pi_
     int i_ret;
 
 #if defined( HAVE_LINUX_DVD_STRUCT )
-    dvd_authinfo auth_info;
+    dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.type = DVD_LU_SEND_KEY1;
     auth_info.lsk.agid = *pi_agid;
 
@@ -1023,9 +999,8 @@ int ioctl_ReportKey1( int i_fd, int *pi_
     memcpy( p_key, auth_info.lsk.key, DVD_KEY_SIZE );
 
 #elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_authinfo auth_info;
+    struct dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.format = DVD_REPORT_KEY1;
     auth_info.agid = *pi_agid;
 
@@ -1033,7 +1008,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_
 
     memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE );
 
-#elif defined( SYS_BEOS )
+#elif defined( __BEOS__ )
     INIT_RDC( GPCMD_REPORT_KEY, 12 );
 
     rdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
@@ -1079,11 +1054,9 @@ int ioctl_ReportKey1( int i_fd, int *pi_
     if( WIN2K ) /* NT/2k/XP */
     {
         DWORD tmp;
-        uint8_t buffer[DVD_BUS_KEY_LENGTH];
+        uint8_t buffer[DVD_BUS_KEY_LENGTH] = { 0 };
         PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
 
-        memset( &buffer, 0, sizeof( buffer ) );
-
         key->KeyLength  = DVD_BUS_KEY_LENGTH;
         key->SessionId  = *pi_agid;
         key->KeyType    = DvdBusKey1;
@@ -1115,7 +1088,7 @@ int ioctl_ReportKey1( int i_fd, int *pi_
 
     memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
 
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     INIT_SSC( GPCMD_REPORT_KEY, 12 );
 
     sdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
@@ -1141,41 +1114,39 @@ int ioctl_InvalidateAgid( int i_fd, int 
     int i_ret;
 
 #if defined( HAVE_LINUX_DVD_STRUCT )
-    dvd_authinfo auth_info;
+    dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
-    auth_info.type = DVD_INVALIDATE_AGID;
+    auth_info.type = DVDCSS_INVALIDATE_AGID;
     auth_info.lsa.agid = *pi_agid;
 
     i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
 
 #elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_authinfo auth_info;
+    struct dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
-    auth_info.format = DVD_INVALIDATE_AGID;
+    auth_info.format = DVDCSS_INVALIDATE_AGID;
     auth_info.agid = *pi_agid;
 
     i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
 
-#elif defined( SYS_BEOS )
+#elif defined( __BEOS__ )
     INIT_RDC( GPCMD_REPORT_KEY, 0 );
 
-    rdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
+    rdc.command[ 10 ] = DVDCSS_INVALIDATE_AGID | (*pi_agid << 6);
 
     i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
 
 #elif defined( HPUX_SCTL_IO )
     INIT_SCTL_IO( GPCMD_REPORT_KEY, 0 );
 
-    sctl_io.cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
+    sctl_io.cdb[ 10 ] = DVDCSS_INVALIDATE_AGID | (*pi_agid << 6);
 
     i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
 
 #elif defined( SOLARIS_USCSI )
     INIT_USCSI( GPCMD_REPORT_KEY, 0 );
 
-    rs_cdb.cdb_opaque[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
+    rs_cdb.cdb_opaque[ 10 ] = DVDCSS_INVALIDATE_AGID | (*pi_agid << 6);
 
     i_ret = SolarisSendUSCSI( i_fd, &sc );
 
@@ -1212,7 +1183,7 @@ int ioctl_InvalidateAgid( int i_fd, int 
         ssc.CDBByte[ 9 ]  = 0;
 #endif
 
-        ssc.CDBByte[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
+        ssc.CDBByte[ 10 ] = DVDCSS_INVALIDATE_AGID | (*pi_agid << 6);
 
         i_ret = WinSendSSC( i_fd, &ssc );
     }
@@ -1221,18 +1192,18 @@ int ioctl_InvalidateAgid( int i_fd, int 
 
     INIT_CPT( GPCMD_REPORT_KEY, 0 );
 
-    p_cpt->cam_cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
+    p_cpt->cam_cdb[ 10 ] = DVDCSS_INVALIDATE_AGID | (*pi_agid << 6);
 
     i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
 
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     INIT_SSC( GPCMD_REPORT_KEY, 1 );
 
     sdc.data_length = 0;
     sdc.command[ 8 ] = 0;
     sdc.command[ 9 ] = 0;
 
-    sdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
+    sdc.command[ 10 ] = DVDCSS_INVALIDATE_AGID | (*pi_agid << 6);
 
     i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
                         &sdc, sizeof(sdc), &ulParamLen,
@@ -1252,9 +1223,8 @@ int ioctl_SendChallenge( int i_fd, int *
     int i_ret;
 
 #if defined( HAVE_LINUX_DVD_STRUCT )
-    dvd_authinfo auth_info;
+    dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.type = DVD_HOST_SEND_CHALLENGE;
     auth_info.hsc.agid = *pi_agid;
 
@@ -1263,9 +1233,8 @@ int ioctl_SendChallenge( int i_fd, int *
     i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
 
 #elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_authinfo auth_info;
+    struct dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.format = DVD_SEND_CHALLENGE;
     auth_info.agid = *pi_agid;
 
@@ -1273,7 +1242,7 @@ int ioctl_SendChallenge( int i_fd, int *
 
     i_ret = ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
 
-#elif defined( SYS_BEOS )
+#elif defined( __BEOS__ )
     INIT_RDC( GPCMD_SEND_KEY, 16 );
 
     rdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
@@ -1324,11 +1293,9 @@ int ioctl_SendChallenge( int i_fd, int *
     if( WIN2K ) /* NT/2k/XP */
     {
         DWORD tmp;
-        uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH];
+        uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH] = { 0 };
         PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
 
-        memset( &buffer, 0, sizeof( buffer ) );
-
         key->KeyLength  = DVD_CHALLENGE_KEY_LENGTH;
         key->SessionId  = *pi_agid;
         key->KeyType    = DvdChallengeKey;
@@ -1362,7 +1329,7 @@ int ioctl_SendChallenge( int i_fd, int *
 
     i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
 
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     INIT_SSC( GPCMD_SEND_KEY, 16 );
 
     sdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
@@ -1389,9 +1356,8 @@ int ioctl_SendKey2( int i_fd, int *pi_ag
     int i_ret;
 
 #if defined( HAVE_LINUX_DVD_STRUCT )
-    dvd_authinfo auth_info;
+    dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.type = DVD_HOST_SEND_KEY2;
     auth_info.hsk.agid = *pi_agid;
 
@@ -1400,9 +1366,8 @@ int ioctl_SendKey2( int i_fd, int *pi_ag
     i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
 
 #elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_authinfo auth_info;
+    struct dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.format = DVD_SEND_KEY2;
     auth_info.agid = *pi_agid;
 
@@ -1410,7 +1375,7 @@ int ioctl_SendKey2( int i_fd, int *pi_ag
 
     i_ret = ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
 
-#elif defined( SYS_BEOS )
+#elif defined( __BEOS__ )
     INIT_RDC( GPCMD_SEND_KEY, 12 );
 
     rdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
@@ -1461,11 +1426,9 @@ int ioctl_SendKey2( int i_fd, int *pi_ag
     if( WIN2K ) /* NT/2k/XP */
     {
         DWORD tmp;
-        uint8_t buffer[DVD_BUS_KEY_LENGTH];
+        uint8_t buffer[DVD_BUS_KEY_LENGTH] = { 0 };
         PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
 
-        memset( &buffer, 0, sizeof( buffer ) );
-
         key->KeyLength  = DVD_BUS_KEY_LENGTH;
         key->SessionId  = *pi_agid;
         key->KeyType    = DvdBusKey2;
@@ -1499,7 +1462,7 @@ int ioctl_SendKey2( int i_fd, int *pi_ag
 
     i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
 
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     INIT_SSC( GPCMD_SEND_KEY, 12 );
 
     sdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
@@ -1526,9 +1489,8 @@ int ioctl_ReportRPC( int i_fd, int *p_ty
     int i_ret;
 
 #if defined( HAVE_LINUX_DVD_STRUCT ) && defined( DVD_LU_SEND_RPC_STATE )
-    dvd_authinfo auth_info;
+    dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.type = DVD_LU_SEND_RPC_STATE;
 
     i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
@@ -1542,9 +1504,8 @@ int ioctl_ReportRPC( int i_fd, int *p_ty
     i_ret = -1;
 
 #elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_authinfo auth_info;
+    struct dvd_authinfo auth_info = { 0 };
 
-    memset( &auth_info, 0, sizeof( auth_info ) );
     auth_info.format = DVD_REPORT_RPC;
 
     i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info );
@@ -1553,7 +1514,7 @@ int ioctl_ReportRPC( int i_fd, int *p_ty
     *p_mask = auth_info.region; // ??
     *p_scheme = auth_info.rpc_scheme;
 
-#elif defined( SYS_BEOS )
+#elif defined( __BEOS__ )
     INIT_RDC( GPCMD_REPORT_KEY, 8 );
 
     rdc.command[ 10 ] = DVD_REPORT_RPC;
@@ -1607,10 +1568,9 @@ int ioctl_ReportRPC( int i_fd, int *p_ty
     if( WIN2K ) /* NT/2k/XP */
     {
         DWORD tmp;
-        uint8_t buffer[DVD_RPC_KEY_LENGTH];
+        uint8_t buffer[DVD_RPC_KEY_LENGTH] = { 0 };
         PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
-
-        memset( &buffer, 0, sizeof( buffer ) );
+        PDVD_RPC_KEY keyData;
 
         key->KeyLength  = DVD_RPC_KEY_LENGTH;
         key->KeyType    = DvdGetRpcKey;
@@ -1624,9 +1584,10 @@ int ioctl_ReportRPC( int i_fd, int *p_ty
             return i_ret;
         }
 
-        *p_type = ((PDVD_RPC_KEY)key->KeyData)->TypeCode;
-        *p_mask = ((PDVD_RPC_KEY)key->KeyData)->RegionMask;
-        *p_scheme = ((PDVD_RPC_KEY)key->KeyData)->RpcScheme;
+        keyData = (PDVD_RPC_KEY)key->KeyData;
+        *p_type = keyData->TypeCode;
+        *p_mask = keyData->RegionMask;
+        *p_scheme = keyData->RpcScheme;
     }
     else
     {
@@ -1653,7 +1614,7 @@ int ioctl_ReportRPC( int i_fd, int *p_ty
     *p_mask = p_buffer[ 5 ];
     *p_scheme = p_buffer[ 6 ];
 
-#elif defined( SYS_OS2 )
+#elif defined( __OS2__ )
     INIT_SSC( GPCMD_REPORT_KEY, 8 );
 
     sdc.command[ 10 ] = DVD_REPORT_RPC;
@@ -1673,136 +1634,9 @@ int ioctl_ReportRPC( int i_fd, int *p_ty
     return i_ret;
 }
 
-/*****************************************************************************
- * ioctl_SendRPC: set RPC status for the drive
- *****************************************************************************/
-int ioctl_SendRPC( int i_fd, int i_pdrc )
-{
-    int i_ret;
-
-#if defined( HAVE_LINUX_DVD_STRUCT ) && defined( DVD_HOST_SEND_RPC_STATE )
-    dvd_authinfo auth_info;
-
-    memset( &auth_info, 0, sizeof( auth_info ) );
-    auth_info.type = DVD_HOST_SEND_RPC_STATE;
-    auth_info.hrpcs.pdrc = i_pdrc;
-
-    i_ret = ioctl( i_fd, DVD_AUTH, &auth_info );
-
-#elif defined( HAVE_LINUX_DVD_STRUCT )
-    /* FIXME: OpenBSD doesn't know this */
-    i_ret = -1;
-
-#elif defined( HAVE_BSD_DVD_STRUCT )
-    struct dvd_authinfo auth_info;
-
-    memset( &auth_info, 0, sizeof( auth_info ) );
-    auth_info.format = DVD_SEND_RPC;
-    auth_info.region = i_pdrc;
-
-    i_ret = ioctl( i_fd, DVDIOCSENDKEY, &auth_info );
-
-#elif defined( SYS_BEOS )
-    INIT_RDC( GPCMD_SEND_KEY, 8 );
-
-    rdc.command[ 10 ] = DVD_SEND_RPC;
-
-    p_buffer[ 1 ] = 6;
-    p_buffer[ 4 ] = i_pdrc;
-
-    i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
-
-#elif defined( HPUX_SCTL_IO )
-    INIT_SCTL_IO( GPCMD_SEND_KEY, 8 );
-
-    sctl_io.cdb[ 10 ] = DVD_SEND_RPC;
-
-    p_buffer[ 1 ] = 6;
-    p_buffer[ 4 ] = i_pdrc;
-
-    i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
-
-#elif defined( SOLARIS_USCSI )
-    INIT_USCSI( GPCMD_SEND_KEY, 8 );
-
-    rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_RPC;
-
-    p_buffer[ 1 ] = 6;
-    p_buffer[ 4 ] = i_pdrc;
-
-    i_ret = SolarisSendUSCSI( i_fd, &sc );
-
-    if( i_ret < 0 || sc.uscsi_status )
-    {
-        i_ret = -1;
-    }
-
-#elif defined( DARWIN_DVD_IOCTL )
-    INIT_DVDIOCTL( dk_dvd_send_key_t, DVDRegionPlaybackControlInfo,
-                   kDVDKeyFormatSetRegion );
-
-    dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
-    dvdbs.driveRegion = i_pdrc;
-
-    i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
-
-#elif defined( WIN32 )
-    if( WIN2K ) /* NT/2k/XP */
-    {
-        INIT_SPTD( GPCMD_SEND_KEY, 8 );
-
-        sptd.Cdb[ 10 ] = DVD_SEND_RPC;
-
-        p_buffer[ 1 ] = 6;
-        p_buffer[ 4 ] = i_pdrc;
-
-        i_ret = SEND_SPTD( i_fd, &sptd, &tmp );
-    }
-    else
-    {
-        INIT_SSC( GPCMD_SEND_KEY, 8 );
-
-        ssc.CDBByte[ 10 ] = DVD_SEND_RPC;
-
-        p_buffer[ 1 ] = 6;
-        p_buffer[ 4 ] = i_pdrc;
-
-        i_ret = WinSendSSC( i_fd, &ssc );
-    }
-
-#elif defined( __QNXNTO__ )
-
-    INIT_CPT( GPCMD_SEND_KEY, 8 );
-
-    p_cpt->cam_cdb[ 10 ] = DVD_SEND_RPC;
-
-    p_buffer[ 1 ] = 6;
-    p_buffer[ 4 ] = i_pdrc;
-
-    i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL);
-
-#elif defined( SYS_OS2 )
-    INIT_SSC( GPCMD_SEND_KEY, 8 );
-
-    sdc.command[ 10 ] = DVD_SEND_RPC;
-
-    p_buffer[ 1 ] = 6;
-    p_buffer[ 4 ] = i_pdrc;
-
-    i_ret = DosDevIOCtl( i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
-                         &sdc, sizeof(sdc), &ulParamLen,
-                         p_buffer, sizeof(p_buffer), &ulDataLen );
-
-#else
-#   error "DVD ioctls are unavailable on this system"
-
-#endif
-    return i_ret;
-}
-
 /* Local prototypes */
 
-#if defined( SYS_BEOS )
+#if defined( __BEOS__ )
 /*****************************************************************************
  * BeInitRDC: initialize a RDC structure for the BeOS kernel
  *****************************************************************************
@@ -1872,7 +1706,7 @@ static void HPUXInitSCTL( struct sctl_io
 /*****************************************************************************
  * SolarisInitUSCSI: initialize a USCSICMD structure for the Solaris kernel
  *****************************************************************************
- * This function initializes a Solaris userspace scsi command structure for
+ * This function initializes a Solaris userspace SCSI command structure for
  * future use, either a read command or a write command.
  *****************************************************************************/
 static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type )
@@ -1917,8 +1751,8 @@ static void SolarisInitUSCSI( struct usc
  *
  * The code will fall back to the USCSICMD ioctl method, when
  * libsmedia.so is not available or does not export the
- * smedia_uscsi_cmd() function (on Solaris releases upto and including
- * Solaris 8). Fortunatelly, on these old releases non-root users are
+ * smedia_uscsi_cmd() function (on Solaris releases up to and including
+ * Solaris 8). Fortunately, on these old releases non-root users are
  * allowed to perform USCSICMD ioctls on removable media devices.
  *****************************************************************************/
 static int SolarisSendUSCSI( int i_fd, struct uscsi_cmd *p_sc )
@@ -2093,7 +1927,7 @@ static void QNXInitCPT( CAM_PASS_THRU * 
 }
 #endif
 
-#if defined( SYS_OS2 )
+#if defined( __OS2__ )
 /*****************************************************************************
  * OS2InitSDC: initialize a SDC structure for the Execute SCSI-command
  *****************************************************************************

Modified: trunk/libdvdcss/ioctl.h
==============================================================================
--- trunk/libdvdcss/ioctl.h	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/ioctl.h	Sat Mar 23 15:32:26 2013	(r36046)
@@ -2,7 +2,6 @@
  * ioctl.h: DVD ioctl replacement function
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id$
  *
  * Authors: Sam Hocevar <sam at zoy.org>
  *
@@ -35,7 +34,6 @@ int ioctl_InvalidateAgid    ( int, int *
 int ioctl_SendChallenge     ( int, int *, uint8_t * );
 int ioctl_SendKey2          ( int, int *, uint8_t * );
 int ioctl_ReportRPC         ( int, int *, int *, int * );
-int ioctl_SendRPC           ( int, int );
 
 #define DVD_KEY_SIZE 5
 #define DVD_CHALLENGE_SIZE 10
@@ -44,11 +42,10 @@ int ioctl_SendRPC           ( int, int )
 /*****************************************************************************
  * Common macro, BeOS specific
  *****************************************************************************/
-#if defined( SYS_BEOS )
+#if defined( __BEOS__ )
 #define INIT_RDC( TYPE, SIZE ) \
-    raw_device_command rdc; \
+    raw_device_command rdc = { 0 }; \
     uint8_t p_buffer[ (SIZE)+1 ]; \
-    memset( &rdc, 0, sizeof( raw_device_command ) ); \
     rdc.data = (char *)p_buffer; \
     rdc.data_length = (SIZE); \
     BeInitRDC( &rdc, (TYPE) );
@@ -59,9 +56,8 @@ int ioctl_SendRPC           ( int, int )
  *****************************************************************************/
 #if defined( HPUX_SCTL_IO )
 #define INIT_SCTL_IO( TYPE, SIZE ) \
-    struct sctl_io sctl_io; \
+    struct sctl_io sctl_io = { 0 }; \
     uint8_t p_buffer[ (SIZE)+1 ]; \
-    memset( &sctl_io, 0, sizeof( sctl_io ) ); \
     sctl_io.data = (void *)p_buffer; \
     sctl_io.data_length = (SIZE); \
     HPUXInitSCTL( &sctl_io, (TYPE) );
@@ -74,10 +70,9 @@ int ioctl_SendRPC           ( int, int )
 #define USCSI_TIMEOUT( SC, TO ) ( (SC)->uscsi_timeout = (TO) )
 #define USCSI_RESID( SC )       ( (SC)->uscsi_resid )
 #define INIT_USCSI( TYPE, SIZE ) \
-    struct uscsi_cmd sc; \
+    struct uscsi_cmd sc = { 0 }; \
     union scsi_cdb rs_cdb; \
     uint8_t p_buffer[ (SIZE)+1 ]; \
-    memset( &sc, 0, sizeof( struct uscsi_cmd ) ); \
     sc.uscsi_cdb = (caddr_t)&rs_cdb; \
     sc.uscsi_bufaddr = (caddr_t)p_buffer; \
     sc.uscsi_buflen = (SIZE); \
@@ -89,10 +84,8 @@ int ioctl_SendRPC           ( int, int )
  *****************************************************************************/
 #if defined( DARWIN_DVD_IOCTL )
 #define INIT_DVDIOCTL( DKDVD_TYPE, BUFFER_TYPE, FORMAT ) \
-    DKDVD_TYPE dvd; \
-    BUFFER_TYPE dvdbs; \
-    memset( &dvd, 0, sizeof(dvd) ); \
-    memset( &dvdbs, 0, sizeof(dvdbs) ); \
+    DKDVD_TYPE dvd = { 0 }; \
+    BUFFER_TYPE dvdbs = { 0 }; \
     dvd.format = FORMAT; \
     dvd.buffer = &dvdbs; \
     dvd.bufferLength = sizeof(dvdbs);
@@ -104,9 +97,8 @@ int ioctl_SendRPC           ( int, int )
 #if defined( WIN32 )
 #define INIT_SPTD( TYPE, SIZE ) \
     DWORD tmp; \
-    SCSI_PASS_THROUGH_DIRECT sptd; \
+    SCSI_PASS_THROUGH_DIRECT sptd = { 0 }; \
     uint8_t p_buffer[ (SIZE) ]; \
-    memset( &sptd, 0, sizeof( SCSI_PASS_THROUGH_DIRECT ) ); \
     sptd.Length = sizeof( SCSI_PASS_THROUGH_DIRECT ); \
     sptd.DataBuffer = p_buffer; \
     sptd.DataTransferLength = (SIZE); \
@@ -117,10 +109,9 @@ int ioctl_SendRPC           ( int, int )
                       (SPTD), sizeof( SCSI_PASS_THROUGH_DIRECT ), \
                       (TMP), NULL ) ? 0 : -1)
 #define INIT_SSC( TYPE, SIZE ) \
-    struct SRB_ExecSCSICmd ssc; \
+    struct SRB_ExecSCSICmd ssc = { 0 }; \
     uint8_t p_buffer[ (SIZE)+1 ]; \
-    memset( &ssc, 0, sizeof( struct SRB_ExecSCSICmd ) ); \
-    ssc.SRB_BufPointer = (char *)p_buffer; \
+    ssc.SRB_BufPointer = (unsigned char *)p_buffer; \
     ssc.SRB_BufLen = (SIZE); \
     WinInitSSC( &ssc, (TYPE) );
 #endif
@@ -130,12 +121,11 @@ int ioctl_SendRPC           ( int, int )
  *****************************************************************************/
 #if defined( __QNXNTO__ )
 #define INIT_CPT( TYPE, SIZE ) \
-    CAM_PASS_THRU * p_cpt; \
+    CAM_PASS_THRU * p_cpt = { 0 }; \
     uint8_t * p_buffer; \
     int structSize = sizeof( CAM_PASS_THRU ) + (SIZE); \
     p_cpt = (CAM_PASS_THRU *) malloc ( structSize ); \
     p_buffer = (uint8_t *) p_cpt + sizeof( CAM_PASS_THRU ); \
-    memset( p_cpt, 0, structSize ); \
       p_cpt->cam_data_ptr = sizeof( CAM_PASS_THRU ); \
       p_cpt->cam_dxfer_len = (SIZE); \
     QNXInitCPT( p_cpt, (TYPE) );
@@ -144,14 +134,12 @@ int ioctl_SendRPC           ( int, int )
 /*****************************************************************************
  * Common macro, OS2 specific
  *****************************************************************************/
-#if defined( SYS_OS2 )
+#if defined( __OS2__ )
 #define INIT_SSC( TYPE, SIZE ) \
-    struct OS2_ExecSCSICmd sdc; \
-    uint8_t p_buffer[ (SIZE)+1 ]; \
+    struct OS2_ExecSCSICmd sdc = { 0 }; \
+    uint8_t p_buffer[ (SIZE) + 1 ] = { 0 }; \
     unsigned long ulParamLen; \
     unsigned long ulDataLen; \
-    memset( &sdc, 0, sizeof( OS2_ExecSCSICmd ) ); \
-    memset( &p_buffer, 0, SIZE ); \
     sdc.data_length = (SIZE); \
     ulParamLen = sizeof(sdc); \
     OS2InitSDC( &sdc, (TYPE) )
@@ -168,30 +156,28 @@ typedef union dvd_authinfo dvd_authinfo;
 /*****************************************************************************
  * Various DVD I/O tables
  *****************************************************************************/
-#if defined( SYS_BEOS ) || defined( WIN32 ) || defined ( SOLARIS_USCSI ) || defined ( HPUX_SCTL_IO ) || defined ( __QNXNTO__ ) || defined ( SYS_OS2 )
-    /* The generic packet command opcodes for CD/DVD Logical Units,
-     * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
-#   define GPCMD_READ_DVD_STRUCTURE 0xad
-#   define GPCMD_REPORT_KEY         0xa4
-#   define GPCMD_SEND_KEY           0xa3
-    /* DVD struct types */
-#   define DVD_STRUCT_PHYSICAL      0x00
-#   define DVD_STRUCT_COPYRIGHT     0x01
-#   define DVD_STRUCT_DISCKEY       0x02
-#   define DVD_STRUCT_BCA           0x03
-#   define DVD_STRUCT_MANUFACT      0x04
-    /* Key formats */
-#   define DVD_REPORT_AGID          0x00
-#   define DVD_REPORT_CHALLENGE     0x01
-#   define DVD_SEND_CHALLENGE       0x01
-#   define DVD_REPORT_KEY1          0x02
-#   define DVD_SEND_KEY2            0x03
-#   define DVD_REPORT_TITLE_KEY     0x04
-#   define DVD_REPORT_ASF           0x05
-#   define DVD_SEND_RPC             0x06
-#   define DVD_REPORT_RPC           0x08
-#   define DVD_INVALIDATE_AGID      0x3f
-#endif
+/* The generic packet command opcodes for CD/DVD Logical Units,
+ * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */
+#define GPCMD_READ_DVD_STRUCTURE 0xad
+#define GPCMD_REPORT_KEY         0xa4
+#define GPCMD_SEND_KEY           0xa3
+ /* DVD struct types */
+#define DVD_STRUCT_PHYSICAL      0x00
+#define DVD_STRUCT_COPYRIGHT     0x01
+#define DVD_STRUCT_DISCKEY       0x02
+#define DVD_STRUCT_BCA           0x03
+#define DVD_STRUCT_MANUFACT      0x04
+ /* Key formats */
+#define DVD_REPORT_AGID          0x00
+#define DVD_REPORT_CHALLENGE     0x01
+#define DVD_SEND_CHALLENGE       0x01
+#define DVD_REPORT_KEY1          0x02
+#define DVD_SEND_KEY2            0x03
+#define DVD_REPORT_TITLE_KEY     0x04
+#define DVD_REPORT_ASF           0x05
+#define DVD_SEND_RPC             0x06
+#define DVD_REPORT_RPC           0x08
+#define DVDCSS_INVALIDATE_AGID   0x3f
 
 /*****************************************************************************
  * win32 ioctl specific
@@ -408,7 +394,7 @@ struct SRB_ExecSCSICmd
 /*****************************************************************************
  * OS2 ioctl specific
  *****************************************************************************/
-#if defined( SYS_OS2 )
+#if defined( __OS2__ )
 
 #define CDROMDISK_EXECMD      0x7A
 

Modified: trunk/libdvdcss/libdvdcss.c
==============================================================================
--- trunk/libdvdcss/libdvdcss.c	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/libdvdcss.c	Sat Mar 23 15:32:26 2013	(r36046)
@@ -5,7 +5,6 @@
  *          Håkan Hjort <d95hjort at dtek.chalmers.se>
  *
  * Copyright (C) 1998-2008 VideoLAN
- * $Id$
  *
  * This library is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -31,7 +30,7 @@
  * device without having to bother about the decryption. The important features
  * are:
  * \li portability: currently supported platforms are GNU/Linux, FreeBSD,
- *     NetBSD, OpenBSD, BSD/OS, BeOS, Windows 95/98, Windows NT/2000, MacOS X,
+ *     NetBSD, OpenBSD, BeOS, Windows 98/ME, Windows NT/2000/XP, Mac OS X,
  *     Solaris, HP-UX and OS/2.
  * \li adaptability: unlike most similar projects, libdvdcss doesn't require
  *     the region of your drive to be set and will try its best to read from
@@ -50,7 +49,7 @@
  *
  * \section env Environment variables
  *
- * Some environment variables can be used to change the behaviour of
+ * Some environment variables can be used to change the behavior of
  * \e libdvdcss without having to modify the program which uses it. These
  * variables are:
  *
@@ -120,8 +119,8 @@
 #   include <limits.h>
 #endif
 
-#ifdef HAVE_DIRECT_H
-#   include <direct.h>
+#if defined(_WIN32_IE) && _WIN32_IE >= 0x500
+#   include <shlobj.h>
 #endif
 
 #include "dvdcss/dvdcss.h"
@@ -132,17 +131,10 @@
 #include "ioctl.h"
 #include "device.h"
 
-/**
- * \brief Symbol for version checks.
- *
- * The name of this symbol contains the library major number, which makes it
- * easy to check which \e libdvdcss development headers are installed on the
- * system with tools such as autoconf.
- *
- * The variable itself contains the exact version number of the library,
- * which can be useful for specific feature needs.
- */
-char * dvdcss_interface_2 = VERSION;
+#ifdef HAVE_BROKEN_MKDIR
+#include <direct.h>
+#define mkdir(a, b) _mkdir(a)
+#endif
 
 /**
  * \brief Open a DVD device or directory and return a dvdcss instance.
@@ -166,7 +158,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 
     char *psz_method = getenv( "DVDCSS_METHOD" );
     char *psz_verbose = getenv( "DVDCSS_VERBOSE" );
     char *psz_cache = getenv( "DVDCSS_CACHE" );
-#if !defined(WIN32) && !defined(SYS_OS2)
+#ifdef DVDCSS_RAW_OPEN
     char *psz_raw_device = getenv( "DVDCSS_RAW_DEVICE" );
 #endif
 
@@ -184,7 +176,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 
     /*
      *  Initialize structure with default values
      */
-#if !defined(WIN32) && !defined(SYS_OS2)
+#ifdef DVDCSS_RAW_OPEN
     dvdcss->i_raw_fd = -1;
 #endif
     dvdcss->p_titles = NULL;
@@ -238,42 +230,15 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 
      */
     if( psz_cache == NULL || psz_cache[0] == '\0' )
     {
-#ifdef WIN32
-        typedef HRESULT( WINAPI *SHGETFOLDERPATH )
-                       ( HWND, int, HANDLE, DWORD, LPTSTR );
-
-#   define CSIDL_FLAG_CREATE 0x8000
-#   define CSIDL_APPDATA 0x1A
-#   define SHGFP_TYPE_CURRENT 0
-
+#if defined(_WIN32_IE) && _WIN32_IE >= 0x500
         char psz_home[MAX_PATH];
-        HINSTANCE p_dll;
-        SHGETFOLDERPATH p_getpath;
-
-        *psz_home = '\0';
-
-        /* Load the shfolder dll to retrieve SHGetFolderPath */
-        p_dll = LoadLibrary( "shfolder.dll" );
-        if( p_dll )
-        {
-            p_getpath = (void*)GetProcAddress( p_dll, "SHGetFolderPathA" );
-            if( p_getpath )
-            {
-                /* Get the "Application Data" folder for the current user */
-                if( p_getpath( NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
-                               NULL, SHGFP_TYPE_CURRENT, psz_home ) != S_OK )
-                {
-                    *psz_home = '\0';
-                }
-            }
-            FreeLibrary( p_dll );
-        }
 
         /* Cache our keys in
          * C:\Documents and Settings\$USER\Application Data\dvdcss\ */
-        if( *psz_home )
+        if (SHGetFolderPathA (NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
+                              NULL, SHGFP_TYPE_CURRENT, psz_home ) == S_OK)
         {
-            snprintf( psz_buffer, PATH_MAX, "%s/dvdcss", psz_home );
+            snprintf( psz_buffer, PATH_MAX, "%s\\dvdcss", psz_home );
             psz_buffer[PATH_MAX-1] = '\0';
             psz_cache = psz_buffer;
         }
@@ -304,7 +269,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 
         {
             int home_pos = 0;
 
-#ifdef SYS_OS2
+#ifdef __OS2__
             if( *psz_home == '/' || *psz_home == '\\')
             {
                 char *psz_unixroot = getenv("UNIXROOT");
@@ -362,9 +327,30 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 
 
     if( dvdcss->b_ioctls )
     {
-        _dvdcss_test( dvdcss );
+        i_ret = _dvdcss_test( dvdcss );
+
+        if( i_ret == -3 )
+        {
+            print_debug( dvdcss, "scrambled disc on a region-free RPC-II "
+                                 "drive: possible failure, but continuing "
+                                 "anyway" );
+        }
+        else if( i_ret < 0 )
+        {
+            /* Disable the CSS ioctls and hope that it works? */
+            print_debug( dvdcss,
+                         "could not check whether the disc was scrambled" );
+            dvdcss->b_ioctls = 0;
+        }
+        else
+        {
+            print_debug( dvdcss, i_ret ? "disc is scrambled"
+                                       : "disc is unscrambled" );
+            dvdcss->b_scrambled = i_ret;
+        }
     }
 
+    memset( dvdcss->css.p_disc_key, 0, KEY_SIZE );
     /* If disc is CSS protected and the ioctls work, authenticate the drive */
     if( dvdcss->b_scrambled && dvdcss->b_ioctls )
     {
@@ -375,15 +361,12 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 
             print_debug( dvdcss, "could not get disc key" );
         }
     }
-    else
-    {
-        memset( dvdcss->css.p_disc_key, 0, KEY_SIZE );
-    }
 
     /* If the cache is enabled, write the cache directory tag */
     if( psz_cache )
     {
-        char *psz_tag = "Signature: 8a477f597d28d172789f06886806bc55\r\n"
+        static const char psz_tag[] =
+            "Signature: 8a477f597d28d172789f06886806bc55\r\n"
             "# This file is a cache directory tag created by libdvdcss.\r\n"
             "# For information about cache directory tags, see:\r\n"
             "#   http://www.brynosaurus.com/cachedir/\r\n";
@@ -394,7 +377,12 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 
         i_fd = open( psz_tagfile, O_RDWR|O_CREAT, 0644 );
         if( i_fd >= 0 )
         {
-            write( i_fd, psz_tag, strlen(psz_tag) );
+            size_t len = strlen(psz_tag);
+            if( write( i_fd, psz_tag, len ) < (long)len )
+            {
+                print_error( dvdcss,
+                             "Error writing cache directory tag, continuing..\n" );
+            }
             close( i_fd );
         }
     }
@@ -500,11 +488,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 
 
         /* We have a disc name or ID, we can create the cache dir */
         i = sprintf( dvdcss->psz_cachefile, "%s", psz_cache );
-#if !defined( WIN32 ) || defined( SYS_CYGWIN )
         i_ret = mkdir( dvdcss->psz_cachefile, 0755 );
-#else
-        i_ret = mkdir( dvdcss->psz_cachefile );
-#endif
         if( i_ret < 0 && errno != EEXIST )
         {
             print_error( dvdcss, "failed creating cache directory" );
@@ -514,11 +498,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 
 
         i += sprintf( dvdcss->psz_cachefile + i, "/%s-%s%s", psz_title,
                       psz_serial, psz_key );
-#if !defined( WIN32 ) || defined( SYS_CYGWIN )
         i_ret = mkdir( dvdcss->psz_cachefile, 0755 );
-#else
-        i_ret = mkdir( dvdcss->psz_cachefile );
-#endif
         if( i_ret < 0 && errno != EEXIST )
         {
             print_error( dvdcss, "failed creating cache subdirectory" );
@@ -535,7 +515,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( 
     }
     nocache:
 
-#if !defined(WIN32) && !defined(SYS_OS2)
+#ifdef DVDCSS_RAW_OPEN
     if( psz_raw_device != NULL )
     {
         _dvdcss_raw_open( dvdcss, psz_raw_device );
@@ -569,7 +549,7 @@ LIBDVDCSS_EXPORT char * dvdcss_error ( d
  *
  * \param dvdcss a \e libdvdcss instance.
  * \param i_blocks an absolute block offset to seek to.
- * \param i_flags #DVDCSS_NOFLAGS, optionally ored with one of #DVDCSS_SEEK_KEY
+ * \param i_flags #DVDCSS_NOFLAGS, optionally ORed with one of #DVDCSS_SEEK_KEY
  *        or #DVDCSS_SEEK_MPEG.
  * \return the new position in blocks, or a negative value in case an error
  *         happened.
@@ -579,13 +559,12 @@ LIBDVDCSS_EXPORT char * dvdcss_error ( d
  * You typically set \p i_flags to #DVDCSS_NOFLAGS when seeking in a .IFO.
  *
  * If #DVDCSS_SEEK_MPEG is specified in \p i_flags and if \e libdvdcss finds it
- * reasonable to do so (ie, if the dvdcss method is not "title"), the current
+ * reasonable to do so (i.e., if the dvdcss method is not "title"), the current
  * title key will be checked and a new one will be calculated if necessary.
  * This flag is typically used when reading data from a VOB.
  *
  * If #DVDCSS_SEEK_KEY is specified, the title key will be always checked,
- * even with the "title" method. This is equivalent to using the now
- * deprecated dvdcss_title() call. This flag is typically used when seeking
+ * even with the "title" method. This flag is typically used when seeking
  * in a new title.
  */
 LIBDVDCSS_EXPORT int dvdcss_seek ( dvdcss_t dvdcss, int i_blocks, int i_flags )
@@ -611,7 +590,7 @@ LIBDVDCSS_EXPORT int dvdcss_seek ( dvdcs
  * \param dvdcss a \e libdvdcss instance.
  * \param p_buffer a buffer that will contain the data read from the disc.
  * \param i_blocks the amount of blocks to read.
- * \param i_flags #DVDCSS_NOFLAGS, optionally ored with #DVDCSS_READ_DECRYPT.
+ * \param i_flags #DVDCSS_NOFLAGS, optionally ORed with #DVDCSS_READ_DECRYPT.
  * \return the amount of blocks read, or a negative value in case an
  *         error happened.
  *
@@ -681,7 +660,7 @@ LIBDVDCSS_EXPORT int dvdcss_read ( dvdcs
  * \param p_iovec a pointer to an array of iovec structures that will contain
  *        the data read from the disc.
  * \param i_blocks the amount of blocks to read.
- * \param i_flags #DVDCSS_NOFLAGS, optionally ored with #DVDCSS_READ_DECRYPT.
+ * \param i_flags #DVDCSS_NOFLAGS, optionally ORed with #DVDCSS_READ_DECRYPT.
  * \return the amount of blocks read, or a negative value in case an
  *         error happened.
  *
@@ -786,15 +765,6 @@ LIBDVDCSS_EXPORT int dvdcss_close ( dvdc
     return 0;
 }
 
-/*
- *  Deprecated. See dvdcss_seek().
- */
-#undef dvdcss_title
-LIBDVDCSS_EXPORT int dvdcss_title ( dvdcss_t dvdcss, int i_block )
-{
-    return _dvdcss_title( dvdcss, i_block );
-}
-
 /**
  * \brief Return 1 if the DVD is scrambled, 0 otherwise.
  *

Modified: trunk/libdvdcss/libdvdcss.h
==============================================================================
--- trunk/libdvdcss/libdvdcss.h	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/libdvdcss/libdvdcss.h	Sat Mar 23 15:32:26 2013	(r36046)
@@ -2,7 +2,6 @@
  * libdvdcss.h: private DVD reading library data
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id$
  *
  * Authors: Stéphane Borel <stef at via.ecp.fr>
  *          Sam Hocevar <sam at zoy.org>
@@ -27,8 +26,7 @@
 
 #include "dvdcss/dvdcss.h"
 #include "css.h"
-
-struct iovec;
+#include "device.h"
 
 /*****************************************************************************
  * The libdvdcss structure
@@ -68,7 +66,7 @@ struct dvdcss_s
     int    i_readv_buf_size;
 #endif
 
-#if !defined(WIN32) && !defined(SYS_OS2)
+#ifdef DVDCSS_RAW_OPEN
     int    i_raw_fd;
 #endif
 };

Modified: trunk/stream/stream.h
==============================================================================
--- trunk/stream/stream.h	Sat Mar 23 01:50:51 2013	(r36045)
+++ trunk/stream/stream.h	Sat Mar 23 15:32:26 2013	(r36046)
@@ -29,10 +29,6 @@
 #include <sys/types.h>
 #include <fcntl.h>
 
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
 #define STREAMTYPE_DUMMY -1    // for placeholders, when the actual reading is handled in the demuxer
 #define STREAMTYPE_FILE 0      // read from seekable file
 #define STREAMTYPE_VCD  1      // raw mode-2 CDROM reading, 2324 bytes/sector


More information about the MPlayer-cvslog mailing list