[libdvdcss-devel] [PATCH 4/4] Replace check for WIN32 define with check for _WIN32 define

Diego Biurrun diego at biurrun.de
Tue Dec 2 19:37:15 CET 2014


The former is deprecated, the latter should be used nowadays.
---
 src/common.h      |  4 ++--
 src/css.c         |  4 ++--
 src/device.c      | 40 ++++++++++++++++++++--------------------
 src/ioctl.c       | 30 +++++++++++++++---------------
 src/ioctl.h       |  6 +++---
 src/libdvdcss.c   |  6 +++---
 src/libdvdcss.h   |  6 +++---
 test/dvd_region.c |  2 +-
 8 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/src/common.h b/src/common.h
index d00a6f5..1e15a18 100644
--- 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 @@ typedef __int64 off_t;
 #       define write _write
 #   endif /* defined( _MSC_VER ) */
 
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
 #ifdef __ANDROID__
 # undef  lseek
diff --git a/src/css.c b/src/css.c
index fef2ae5..f7e5a88 100644
--- a/src/css.c
+++ b/src/css.c
@@ -109,7 +109,7 @@ int dvdcss_test( dvdcss_t dvdcss )
 
     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 @@ int dvdcss_test( dvdcss_t dvdcss )
                      " and that you have used the correct device node." );
 
         return -1;
-#endif /* WIN32 */
+#endif /* _WIN32 */
     }
 
     print_debug( dvdcss, "disc reports copyright information 0x%x",
diff --git a/src/device.c b/src/device.c
index 75c1e6b..00d005e 100644
--- a/src/device.c
+++ b/src/device.c
@@ -79,7 +79,7 @@ static int libc_seek  ( dvdcss_t, int );
 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 @@ static int os2_open ( dvdcss_t, const char * );
 
 int dvdcss_use_ioctls( dvdcss_t dvdcss )
 {
-#if defined( WIN32 )
+#if defined( _WIN32 )
     if( dvdcss->p_handle )
     {
         return 0;
@@ -146,7 +146,7 @@ int dvdcss_use_ioctls( dvdcss_t dvdcss )
 
 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 @@ void dvdcss_check_device ( dvdcss_t dvdcss )
         return;
     }
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
     drives = GetLogicalDrives();
 
     for( i = 0; drives; i++ )
@@ -343,18 +343,18 @@ int dvdcss_open_device ( dvdcss_t dvdcss )
     }
     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 @@ int dvdcss_open_device ( dvdcss_t dvdcss )
         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_open_device ( dvdcss_t dvdcss )
 
 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 @@ static int libc_open ( dvdcss_t dvdcss, const char *psz_device )
     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 @@ static int win2k_open ( dvdcss_t dvdcss, const char *psz_device )
 
     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 @@ static int libc_seek( dvdcss_t dvdcss, int i_blocks )
     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 @@ static int win2k_seek( dvdcss_t dvdcss, int i_blocks )
 
     return dvdcss->i_pos;
 }
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
 /*****************************************************************************
  * Read commands.
@@ -586,7 +586,7 @@ static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
     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 @@ static int win2k_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
     dvdcss->i_pos += i_bytes;
     return i_bytes;
 }
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
 /*****************************************************************************
  * Readv commands.
@@ -610,7 +610,7 @@ static int win2k_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
 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 @@ static int libc_readv ( dvdcss_t dvdcss, const struct iovec *p_iovec,
 #endif
 }
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
 /*****************************************************************************
  * win2k_readv: vectored read using ReadFile for Win2K
  *****************************************************************************/
@@ -743,4 +743,4 @@ static int win2k_readv ( dvdcss_t dvdcss, const struct iovec *p_iovec,
     dvdcss->i_pos += i_blocks_read;
     return i_blocks_read;
 }
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
diff --git a/src/ioctl.c b/src/ioctl.c
index fe5e08e..07bcb0d 100644
--- 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 @@ static void BeInitRDC ( raw_device_command *, int );
 #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 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
 
     *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 @@ int ioctl_ReadDiscKey( int i_fd, const int *pi_agid, uint8_t *p_key )
 
     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 @@ int ioctl_ReadTitleKey( int i_fd, const int *pi_agid, int i_pos, uint8_t *p_key
 
     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 @@ int ioctl_ReportAgid( int i_fd, int *pi_agid )
 
     *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 @@ int ioctl_ReportChallenge( int i_fd, const int *pi_agid, uint8_t *p_challenge )
 
     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 @@ int ioctl_ReportASF( int i_fd, int *pi_asf )
 
     *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 @@ int ioctl_ReportKey1( int i_fd, const int *pi_agid, uint8_t *p_key )
 
     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 @@ int ioctl_InvalidateAgid( int i_fd, int *pi_agid )
 
     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 @@ int ioctl_SendChallenge( int i_fd, const int *pi_agid, const uint8_t *p_challeng
 
     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 @@ int ioctl_SendKey2( int i_fd, const int *pi_agid, const uint8_t *p_key )
 
     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 @@ int ioctl_ReportRPC( int i_fd, int *p_type, int *p_mask, int *p_scheme )
     *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 @@ static int SolarisSendUSCSI( int i_fd, struct uscsi_cmd *p_sc )
 }
 #endif /* defined( SOLARIS_USCSI ) */
 
-#if defined( WIN32 )
+#if defined( _WIN32 )
 /*****************************************************************************
  * WinInitSPTD: initialize a sptd structure
  *****************************************************************************
@@ -1500,7 +1500,7 @@ static void WinInitSPTD( SCSI_PASS_THROUGH_DIRECT *p_sptd, int i_type )
 
     p_sptd->TimeOutValue = 2;
 }
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
 #if defined( __QNXNTO__ )
 /*****************************************************************************
diff --git a/src/ioctl.h b/src/ioctl.h
index cc8ffac..9cf3b41 100644
--- a/src/ioctl.h
+++ b/src/ioctl.h
@@ -123,9 +123,9 @@ typedef union dvd_authinfo dvd_authinfo;
 /*****************************************************************************
  * 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 @@ typedef struct SCSI_PASS_THROUGH_DIRECT
     UCHAR Cdb[16];
 } SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
 
-#endif /* defined( WIN32 ) */
+#endif /* defined( _WIN32 ) */
 
 /*****************************************************************************
  * OS/2-ioctl-specific
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 59a6e16..73a91e8 100644
--- 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 @@ static int set_cache_directory( dvdcss_t dvdcss )
 
     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 @@ static int set_cache_directory( dvdcss_t dvdcss )
             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
diff --git a/src/libdvdcss.h b/src/libdvdcss.h
index 9447124..9a9ac4c 100644
--- 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 @@ struct dvdcss_s
     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 */
 };
 
 /*****************************************************************************
diff --git a/test/dvd_region.c b/test/dvd_region.c
index 2ab5db3..40b15c8 100644
--- a/test/dvd_region.c
+++ b/test/dvd_region.c
@@ -92,7 +92,7 @@ static int ioctl_SendRPC( int i_fd, int i_pdrc )
 
     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];
-- 
2.1.1



More information about the libdvdcss-devel mailing list