ref: 41dc1176c4590bb2047b614547fa230838f2c335
parent: 00abe6bb8626e950f64df2f28b899c4d793b278a
author: Diego Biurrun <diego@biurrun.de>
date: Sun Nov 16 17:40:27 EST 2014
ioctl: Drop single-use INIT_SPTD/SEND_SPTD macros
--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -169,7 +169,13 @@
*pi_copyright = dvdbs.copyrightProtectionSystemType;
#elif defined( WIN32 )
- INIT_SPTD( GPCMD_READ_DVD_STRUCTURE, 8 );
+ DWORD tmp;
+ SCSI_PASS_THROUGH_DIRECT sptd = { 0 };
+ uint8_t p_buffer[8];
+ sptd.Length = sizeof( SCSI_PASS_THROUGH_DIRECT );
+ sptd.DataBuffer = p_buffer;
+ sptd.DataTransferLength = sizeof( p_buffer );
+ WinInitSPTD( &sptd, GPCMD_READ_DVD_STRUCTURE );
/* When using IOCTL_DVD_READ_STRUCTURE and
DVD_COPYRIGHT_DESCRIPTOR, CopyrightProtectionType
@@ -180,7 +186,10 @@
sptd.Cdb[ 6 ] = i_layer;
sptd.Cdb[ 7 ] = DVD_STRUCT_COPYRIGHT;
- i_ret = SEND_SPTD( i_fd, &sptd, &tmp );
+ i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_SCSI_PASS_THROUGH_DIRECT,
+ &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
+ &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
+ &tmp, NULL ) ? 0 : -1;
if( i_ret == 0 )
{
--- a/src/ioctl.h
+++ b/src/ioctl.h
@@ -65,20 +65,6 @@
dvd.format = FORMAT; \
dvd.buffer = &dvdbs; \
dvd.bufferLength = sizeof(dvdbs);
-#elif defined( WIN32 )
-#define INIT_SPTD( TYPE, SIZE ) \
- DWORD tmp; \
- SCSI_PASS_THROUGH_DIRECT sptd = { 0 }; \
- uint8_t p_buffer[ (SIZE) ]; \
- sptd.Length = sizeof( SCSI_PASS_THROUGH_DIRECT ); \
- sptd.DataBuffer = p_buffer; \
- sptd.DataTransferLength = (SIZE); \
- WinInitSPTD( &sptd, (TYPE) );
-#define SEND_SPTD( DEV, SPTD, TMP ) \
- (DeviceIoControl( (HANDLE)(DEV), IOCTL_SCSI_PASS_THROUGH_DIRECT, \
- (SPTD), sizeof( SCSI_PASS_THROUGH_DIRECT ), \
- (SPTD), sizeof( SCSI_PASS_THROUGH_DIRECT ), \
- (TMP), NULL ) ? 0 : -1)
#elif defined( __QNXNTO__ )
#define INIT_CPT( TYPE, SIZE ) \
CAM_PASS_THRU * p_cpt = { 0 }; \
--- a/test/dvd_region.c
+++ b/test/dvd_region.c
@@ -93,7 +93,13 @@
i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
#elif defined( WIN32 )
- INIT_SPTD( GPCMD_SEND_KEY, 8 );
+ DWORD tmp;
+ SCSI_PASS_THROUGH_DIRECT sptd = { 0 };
+ uint8_t p_buffer[8];
+ sptd.Length = sizeof( SCSI_PASS_THROUGH_DIRECT );
+ sptd.DataBuffer = p_buffer;
+ sptd.DataTransferLength = sizeof( p_buffer );
+ WinInitSPTD( &sptd, GPCMD_SEND_KEY );
sptd.Cdb[ 10 ] = DVD_SEND_RPC;
@@ -100,7 +106,10 @@
p_buffer[ 1 ] = 6;
p_buffer[ 4 ] = i_pdrc;
- i_ret = SEND_SPTD( i_fd, &sptd, &tmp );
+ i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_SCSI_PASS_THROUGH_DIRECT,
+ &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
+ &sptd, sizeof( SCSI_PASS_THROUGH_DIRECT ),
+ &tmp, NULL ) ? 0 : -1;
#elif defined( __QNXNTO__ )