shithub: libdvdcss

Download patch

ref: 2a6cd147d7347e509d628c1b9fe5763a97110920
parent: 1ee4cfdfd0b57372111aec320597376805f4cc9d
author: Diego Elio Pettenò <flameeyes@flameeyes.eu>
date: Wed Feb 13 14:04:24 EST 2013

dvd_region: move ioctl_SendRPC in dvd_region.c; mark functions static.

This basically ensures that no unused, unexported functions are built
into the library.

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>

--- a/Makefile.am
+++ b/Makefile.am
@@ -44,7 +44,7 @@
 csstest_LDADD = libdvdcss.la
 csstest_CFLAGS = -I $(top_srcdir)/src
 
-dvd_region_SOURCES = test/dvd_region.c
+dvd_region_SOURCES = test/dvd_region.c src/ioctl.c
 dvd_region_LDADD = libdvdcss.la
 dvd_region_CFLAGS = -I $(top_srcdir)/src
 
--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -1673,133 +1673,6 @@
     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( __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( __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( __BEOS__ )
--- a/src/ioctl.h
+++ b/src/ioctl.h
@@ -35,7 +35,6 @@
 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
--- a/test/dvd_region.c
+++ b/test/dvd_region.c
@@ -24,8 +24,135 @@
 
 #define DEFAULT_DEVICE "/dev/dvd"
 
-int set_region(int fd, int region)
+/*****************************************************************************
+ * ioctl_SendRPC: set RPC status for the drive
+ *****************************************************************************/
+static 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( __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( __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;
+}
+
+static int set_region(int fd, int region)
+{
   int ret, region_mask;
 
   if(region > 8 || region <= 0) {
@@ -46,7 +173,7 @@
   return 0;
 }
 
-int print_region(int fd)
+static int print_region(int fd)
 {
   int type, region_mask, rpc_scheme;
   int region = 1;