shithub: libdvdcss

Download patch

ref: d1f3068297b729d38d15a9b4732409f250e9d763
parent: 6ea4a6589a96aa90cc7e1e3968f28fd5e40e4b93
author: Diego Biurrun <diego@biurrun.de>
date: Sat Nov 29 12:02:54 EST 2014

Replace check for WIN32 define with check for _WIN32 define.

The former is deprecated, the latter should be used nowadays.

--- a/src/common.h
+++ b/src/common.h
@@ -26,7 +26,7 @@
 #ifndef DVDCSS_COMMON_H
 #define DVDCSS_COMMON_H
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
 #   include <io.h>                                             /* _lseeki64 */
 
 /* several type definitions */
@@ -60,7 +60,7 @@
 #       define write _write
 #   endif /* defined( _MSC_VER ) */
 
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
 #ifdef __ANDROID__
 # undef  lseek
--- a/src/css.c
+++ b/src/css.c
@@ -109,7 +109,7 @@
 
     if( i_ret < 0 )
     {
-#ifdef WIN32
+#ifdef _WIN32
         /* Maybe we didn't have enough privileges to read the copyright
          * (see ioctl_ReadCopyright comments).
          * Apparently, on unencrypted DVDs dvdcss_disckey() always fails, so
@@ -129,7 +129,7 @@
                      " and that you have used the correct device node." );
 
         return -1;
-#endif /* WIN32 */
+#endif /* _WIN32 */
     }
 
     print_debug( dvdcss, "disc reports copyright information 0x%x",
--- a/src/device.c
+++ b/src/device.c
@@ -79,7 +79,7 @@
 static int libc_read  ( dvdcss_t, void *, int );
 static int libc_readv ( dvdcss_t, const struct iovec *, int );
 
-#ifdef WIN32
+#ifdef _WIN32
 static int win2k_open  ( dvdcss_t, const char * );
 static int win2k_seek  ( dvdcss_t, int );
 static int win2k_read  ( dvdcss_t, void *, int );
@@ -91,7 +91,7 @@
 
 int dvdcss_use_ioctls( dvdcss_t dvdcss )
 {
-#if defined( WIN32 )
+#if defined( _WIN32 )
     if( dvdcss->p_handle )
     {
         return 0;
@@ -146,7 +146,7 @@
 
 void dvdcss_check_device ( dvdcss_t dvdcss )
 {
-#if defined( WIN32 )
+#if defined( _WIN32 )
     DWORD drives;
     int i;
 #elif defined( DARWIN_DVD_IOCTL )
@@ -188,7 +188,7 @@
         return;
     }
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
     drives = GetLogicalDrives();
 
     for( i = 0; drives; i++ )
@@ -343,18 +343,18 @@
     }
     print_debug( dvdcss, "opening target `%s'", psz_device );
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
     dvdcss->p_handle         = NULL;
     dvdcss->p_readv_buffer   = NULL;
     dvdcss->i_readv_buf_size = 0;
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
-#if defined( WIN32 ) || defined( __OS2__ )
+#if defined( _WIN32 ) || 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] ) ) )
     {
-#if defined( WIN32 )
+#if defined( _WIN32 )
         print_debug( dvdcss, "using Win2K API for access" );
         dvdcss->pf_seek  = win2k_seek;
         dvdcss->pf_read  = win2k_read;
@@ -366,10 +366,10 @@
         dvdcss->pf_read  = libc_read;
         dvdcss->pf_readv = libc_readv;
         return os2_open( dvdcss, psz_device );
-#endif /* ! ( defined( WIN32 ) || defined( __OS2__ ) ) */
+#endif /* ! ( defined( _WIN32 ) || defined( __OS2__ ) ) */
     }
     else
-#endif /* defined( WIN32 ) || defined( __OS2__ ) */
+#endif /* defined( _WIN32 ) || defined( __OS2__ ) */
     {
         print_debug( dvdcss, "using libc API for access" );
         dvdcss->pf_seek  = libc_seek;
@@ -381,7 +381,7 @@
 
 int dvdcss_close_device ( dvdcss_t dvdcss )
 {
-#if defined( WIN32 )
+#if defined( _WIN32 )
     /* Free readv temporary buffer */
     free( dvdcss->p_readv_buffer );
     dvdcss->p_readv_buffer   = NULL;
@@ -424,7 +424,7 @@
     return 0;
 }
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
 static int win2k_open ( dvdcss_t dvdcss, const char *psz_device )
 {
     char psz_dvd[7] = "\\\\.\\\0:";
@@ -458,7 +458,7 @@
 
     return 0;
 }
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
 #ifdef __OS2__
 static int os2_open ( dvdcss_t dvdcss, const char *psz_device )
@@ -519,7 +519,7 @@
     return dvdcss->i_pos;
 }
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
 static int win2k_seek( dvdcss_t dvdcss, int i_blocks )
 {
     LARGE_INTEGER li_seek;
@@ -545,7 +545,7 @@
 
     return dvdcss->i_pos;
 }
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
 /*****************************************************************************
  * Read commands.
@@ -586,7 +586,7 @@
     return i_ret_blocks;
 }
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
 static int win2k_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
 {
     DWORD i_bytes;
@@ -602,7 +602,7 @@
     dvdcss->i_pos += i_bytes;
     return i_bytes;
 }
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
 /*****************************************************************************
  * Readv commands.
@@ -610,7 +610,7 @@
 static int libc_readv ( dvdcss_t dvdcss, const struct iovec *p_iovec,
                         int i_blocks )
 {
-#if defined( WIN32 )
+#if defined( _WIN32 )
     int i_index, i_len, i_total = 0;
     unsigned char *p_base;
     int i_bytes;
@@ -677,7 +677,7 @@
 #endif
 }
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
 /*****************************************************************************
  * win2k_readv: vectored read using ReadFile for Win2K
  *****************************************************************************/
@@ -743,4 +743,4 @@
     dvdcss->i_pos += i_blocks_read;
     return i_blocks_read;
 }
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -37,7 +37,7 @@
 #include <string.h>                                    /* memcpy(), memset() */
 #include <sys/types.h>
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
 #   include <windows.h>
 #   include <winioctl.h>
 #elif defined ( __OS2__ )
@@ -98,7 +98,7 @@
 #elif defined( SOLARIS_USCSI )
 static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type );
 static int SolarisSendUSCSI( int fd, struct uscsi_cmd *p_sc );
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
 static void WinInitSPTD ( SCSI_PASS_THROUGH_DIRECT *, int );
 #elif defined( __QNXNTO__ )
 static void QNXInitCPT ( CAM_PASS_THRU *, int );
@@ -168,7 +168,7 @@
 
     *pi_copyright = dvdbs.copyrightProtectionSystemType;
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp;
     SCSI_PASS_THROUGH_DIRECT sptd = { 0 };
     uint8_t p_buffer[8];
@@ -304,7 +304,7 @@
 
     memcpy( p_key, dvdbs.discKeyStructures, DVD_DISCKEY_SIZE );
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp;
     uint8_t buffer[DVD_DISK_KEY_LENGTH] = { 0 };
     PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
@@ -436,7 +436,7 @@
 
     memcpy( p_key, dvdbs.titleKeyValue, DVD_KEY_SIZE );
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp;
     uint8_t buffer[DVD_TITLE_KEY_LENGTH] = { 0 };
     PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
@@ -552,7 +552,7 @@
 
     *pi_agid = dvdbs.grantID;
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp = 0;
 
     i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION, &tmp, 4,
@@ -646,7 +646,7 @@
 
     memcpy( p_challenge, dvdbs.challengeKeyValue, DVD_CHALLENGE_SIZE );
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp;
     uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH] = { 0 };
     PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
@@ -752,7 +752,7 @@
 
     *pi_asf = dvdbs.successFlag;
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp;
     uint8_t buffer[DVD_ASF_LENGTH] = { 0 };
     PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
@@ -864,7 +864,7 @@
 
     memcpy( p_key, dvdbs.key1Value, DVD_KEY_SIZE );
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp;
     uint8_t buffer[DVD_BUS_KEY_LENGTH] = { 0 };
     PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
@@ -957,7 +957,7 @@
 
     i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp;
 
     i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_END_SESSION,
@@ -1054,7 +1054,7 @@
 
     i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp;
     uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH] = { 0 };
     PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
@@ -1163,7 +1163,7 @@
 
     i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp;
     uint8_t buffer[DVD_BUS_KEY_LENGTH] = { 0 };
     PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
@@ -1280,7 +1280,7 @@
     *p_mask = dvdbs.driveRegion;
     *p_scheme = dvdbs.rpcScheme;
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp;
     uint8_t buffer[DVD_RPC_KEY_LENGTH] = { 0 };
     PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
@@ -1470,7 +1470,7 @@
 }
 #endif /* defined( SOLARIS_USCSI ) */
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
 /*****************************************************************************
  * WinInitSPTD: initialize a sptd structure
  *****************************************************************************
@@ -1500,7 +1500,7 @@
 
     p_sptd->TimeOutValue = 2;
 }
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
 #if defined( __QNXNTO__ )
 /*****************************************************************************
--- a/src/ioctl.h
+++ b/src/ioctl.h
@@ -123,9 +123,9 @@
 /*****************************************************************************
  * Win32-ioctl-specific
  *****************************************************************************/
-#if defined( WIN32 )
+#if defined( _WIN32 )
 
-#define WIN32_LEAN_AND_MEAN
+#define _WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <winioctl.h>
 
@@ -245,7 +245,7 @@
     UCHAR Cdb[16];
 } SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
 
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
 /*****************************************************************************
  * OS/2-ioctl-specific
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -116,7 +116,7 @@
 #   include <unistd.h>
 #endif
 
-#ifdef WIN32
+#ifdef _WIN32
 #   include <shlobj.h>
 #endif
 
@@ -200,7 +200,7 @@
 
     if( psz_cache == NULL || psz_cache[0] == '\0' )
     {
-#ifdef WIN32
+#ifdef _WIN32
         char psz_home[PATH_MAX];
 
         /* Cache our keys in
@@ -255,7 +255,7 @@
             dvdcss->psz_cachefile[PATH_MAX - 1] = '\0';
             psz_cache = dvdcss->psz_cachefile;
         }
-#endif /* ! defined( WIN32 ) */
+#endif /* ! defined( _WIN32 ) */
     }
 
     /* Check that there is enough space for the cache directory path and the
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -26,7 +26,7 @@
 
 #include <limits.h>
 
-#ifdef WIN32
+#ifdef _WIN32
 #    include "config.h"
 #    include <windows.h>
 #endif
@@ -74,11 +74,11 @@
     int    b_errors;
     int    b_debug;
 
-#ifdef WIN32
+#ifdef _WIN32
     HANDLE p_handle;
     char * p_readv_buffer;
     int    i_readv_buf_size;
-#endif /* WIN32 */
+#endif /* _WIN32 */
 };
 
 /*****************************************************************************
--- a/test/dvd_region.c
+++ b/test/dvd_region.c
@@ -92,7 +92,7 @@
 
     i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
 
-#elif defined( WIN32 )
+#elif defined( _WIN32 )
     DWORD tmp;
     SCSI_PASS_THROUGH_DIRECT sptd = { 0 };
     uint8_t p_buffer[8];