Discussion:
[libdvdcss-devel] ioctl: Drop single-use INIT_SPTD/SEND_SPTD macros
Diego Biurrun
2014-11-18 23:11:37 UTC
Permalink
libdvdcss | branch: master | Diego Biurrun <***@biurrun.de> | Sun Nov 16 22:40:27 2014 +0100| [41dc1176c4590bb2047b614547fa230838f2c335] | committer: Diego Biurrun

ioctl: Drop single-use INIT_SPTD/SEND_SPTD macros
http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=41dc1176c4590bb2047b614547fa230838f2c335
---

src/ioctl.c | 13 +++++++++++--
src/ioctl.h | 14 --------------
test/dvd_region.c | 13 +++++++++++--
3 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/src/ioctl.c b/src/ioctl.c
index 7219017..6e078d6 100644
--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -169,7 +169,13 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
*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 @@ int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright )
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 )
{
diff --git a/src/ioctl.h b/src/ioctl.h
index ab8c42e..cc8ffac 100644
--- a/src/ioctl.h
+++ b/src/ioctl.h
@@ -65,20 +65,6 @@ int ioctl_ReportRPC ( int, int *, int *, int * );
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 }; \
diff --git a/test/dvd_region.c b/test/dvd_region.c
index a596fe7..f35b869 100644
--- a/test/dvd_region.c
+++ b/test/dvd_region.c
@@ -93,14 +93,23 @@ static int ioctl_SendRPC( int i_fd, int i_pdrc )
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;

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__ )

Loading...