[libdvdcss-devel] dvd_region: move ioctl_SendRPC in dvd_region.c; mark functions static.

Diego Elio Pettenò git at videolan.org
Thu Feb 14 12:56:23 CET 2013


libdvdcss | branch: master | Diego Elio Pettenò <flameeyes at flameeyes.eu> | Wed Feb 13 19:04:24 2013 -0800| [2a6cd147d7347e509d628c1b9fe5763a97110920] | committer: Jean-Baptiste Kempf

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 at videolan.org>

> http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=2a6cd147d7347e509d628c1b9fe5763a97110920
---

 Makefile.am       |    2 +-
 src/ioctl.c       |  127 ---------------------------------------------------
 src/ioctl.h       |    1 -
 test/dvd_region.c |  131 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 4 files changed, 130 insertions(+), 131 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 1452021..fbae779 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -44,7 +44,7 @@ csstest_SOURCES = test/csstest.c
 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
 
diff --git a/src/ioctl.c b/src/ioctl.c
index b10c274..a096d78 100644
--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -1673,133 +1673,6 @@ int ioctl_ReportRPC( int i_fd, int *p_type, int *p_mask, int *p_scheme )
     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__ )
diff --git a/src/ioctl.h b/src/ioctl.h
index 28a0c2e..fd12387 100644
--- a/src/ioctl.h
+++ b/src/ioctl.h
@@ -35,7 +35,6 @@ int ioctl_InvalidateAgid    ( int, int * );
 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
diff --git a/test/dvd_region.c b/test/dvd_region.c
index ed645b9..7466b5d 100644
--- a/test/dvd_region.c
+++ b/test/dvd_region.c
@@ -24,7 +24,134 @@
 
 #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;
 
@@ -46,7 +173,7 @@ int set_region(int fd, int region)
   return 0;
 }
 
-int print_region(int fd)
+static int print_region(int fd)
 {
   int type, region_mask, rpc_scheme;
   int region = 1;



More information about the libdvdcss-devel mailing list