shithub: libdvdcss

Download patch

ref: 53bf3a846f2a5e0f14e30ce7e618f3f25d499971
parent: eb528eef3204462f53c7f42612342be4a482d220
author: Diego Biurrun <diego@biurrun.de>
date: Wed Oct 22 09:32:16 EDT 2014

Drop leading underscore from externally visible function names.

C99 reserves identifier names starting with an underscore at the file level.

--- a/src/css.c
+++ b/src/css.c
@@ -88,10 +88,10 @@
 static int  AttackPadding   ( uint8_t const[] );
 #endif
 
-static int  _dvdcss_titlekey    ( dvdcss_t, int , dvd_key_t );
+static int  dvdcss_titlekey    ( dvdcss_t, int , dvd_key_t );
 
 /*****************************************************************************
- * _dvdcss_test: check if the disc is encrypted or not
+ * dvdcss_test: check if the disc is encrypted or not
  *****************************************************************************
  * Return values:
  *   1: DVD is scrambled but can be read
@@ -101,7 +101,7 @@
  *  -3: drive is RPC-II, region is not set, and DVD is scrambled: the RPC
  *      scheme will prevent us from reading the scrambled data
  *****************************************************************************/
-int _dvdcss_test( dvdcss_t dvdcss )
+int dvdcss_test( dvdcss_t dvdcss )
 {
     char const *psz_type, *psz_rpc;
     int i_ret, i_copyright, i_type, i_mask, i_rpc;
@@ -113,11 +113,11 @@
     {
         /* Maybe we didn't have enough privileges to read the copyright
          * (see ioctl_ReadCopyright comments).
-         * Apparently, on unencrypted DVDs _dvdcss_disckey() always fails, so
+         * Apparently, on unencrypted DVDs dvdcss_disckey() always fails, so
          * we can check this as a workaround. */
         i_ret = 0;
         i_copyright = 1;
-        if( _dvdcss_disckey( dvdcss ) < 0 )
+        if( dvdcss_disckey( dvdcss ) < 0 )
         {
             i_copyright = 0;
         }
@@ -175,12 +175,12 @@
 }
 
 /*****************************************************************************
- * _dvdcss_title: crack or decrypt the current title key if needed
+ * dvdcss_title: crack or decrypt the current title key if needed
  *****************************************************************************
  * This function should only be called by dvdcss->pf_seek and should eventually
  * not be external if possible.
  *****************************************************************************/
-int _dvdcss_title ( dvdcss_t dvdcss, int i_block )
+int dvdcss_title ( dvdcss_t dvdcss, int i_block )
 {
     dvd_title_t *p_title;
     dvd_title_t *p_newtitle;
@@ -247,7 +247,7 @@
     /* Crack or decrypt CSS title key for current VTS */
     if( i_ret < 0 )
     {
-        i_ret = _dvdcss_titlekey( dvdcss, i_block, p_title_key );
+        i_ret = dvdcss_titlekey( dvdcss, i_block, p_title_key );
 
         if( i_ret < 0 )
         {
@@ -318,7 +318,7 @@
 }
 
 /*****************************************************************************
- * _dvdcss_disckey: get disc key.
+ * dvdcss_disckey: get disc key.
  *****************************************************************************
  * This function should only be called if DVD ioctls are present.
  * It will set dvdcss->i_method = DVDCSS_METHOD_TITLE if it fails to find
@@ -327,7 +327,7 @@
  *  -disc key hash crack,
  *  -decryption with player keys if they are available.
  *****************************************************************************/
-int _dvdcss_disckey( dvdcss_t dvdcss )
+int dvdcss_disckey( dvdcss_t dvdcss )
 {
     unsigned char p_buffer[ DVD_DISCKEY_SIZE ];
     dvd_key_t p_disc_key;
@@ -411,9 +411,9 @@
 
 
 /*****************************************************************************
- * _dvdcss_titlekey: get title key.
+ * dvdcss_titlekey: get title key.
  *****************************************************************************/
-static int _dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key_t p_title_key )
+static int dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key_t p_title_key )
 {
     static uint8_t p_garbage[ DVDCSS_BLOCK_SIZE ];  /* we never read it back */
     uint8_t p_key[ KEY_SIZE ];
@@ -508,7 +508,7 @@
         dvdcss->pf_seek( dvdcss, 0 );
         dvdcss->pf_read( dvdcss, p_garbage, 1 );
         dvdcss->pf_seek( dvdcss, 0 );
-        _dvdcss_disckey( dvdcss );
+        dvdcss_disckey( dvdcss );
 
         /* Fallback */
     }
@@ -526,12 +526,12 @@
 }
 
 /*****************************************************************************
- * _dvdcss_unscramble: does the actual descrambling of data
+ * dvdcss_unscramble: does the actual descrambling of data
  *****************************************************************************
  * sec : sector to unscramble
  * key : title key for this sector
  *****************************************************************************/
-int _dvdcss_unscramble( dvd_key_t p_key, uint8_t *p_sec )
+int dvdcss_unscramble( dvd_key_t p_key, uint8_t *p_sec )
 {
     unsigned int    i_t1, i_t2, i_t3, i_t4, i_t5, i_t6;
     uint8_t        *p_end = p_sec + DVDCSS_BLOCK_SIZE;
@@ -961,8 +961,8 @@
  * DecryptKey: decrypt p_crypted with p_key.
  *****************************************************************************
  * Used to decrypt the disc key, with a player key, after requesting it
- * in _dvdcss_disckey and to decrypt title keys, with a disc key, requested
- * in _dvdcss_titlekey.
+ * in dvdcss_disckey and to decrypt title keys, with a disc key, requested
+ * in dvdcss_titlekey.
  * The player keys and the resulting disc key are only used as KEKs
  * (key encryption keys).
  * Decryption is slightly dependent on the type of key:
@@ -1477,7 +1477,7 @@
 /*****************************************************************************
  * CrackTitleKey: try to crack title key from the contents of a VOB.
  *****************************************************************************
- * This function is called by _dvdcss_titlekey to find a title key, if we've
+ * This function is called by dvdcss_titlekey to find a title key, if we've
  * chosen to crack title key instead of decrypting it with the disc key.
  * The DVD should have been opened and be in an authenticated state.
  * i_pos is the starting sector, i_len is the maximum number of sectors to read
@@ -1523,8 +1523,8 @@
                                      "secret arcanes to recover", i_pos );
 
                 /* Reset the drive before trying to continue */
-                _dvdcss_close( dvdcss );
-                _dvdcss_open( dvdcss );
+                dvdcss_close_device( dvdcss );
+                dvdcss_open_device( dvdcss );
 
                 b_read_error = 1;
                 continue;
--- a/src/css.h
+++ b/src/css.h
@@ -54,9 +54,9 @@
 /*****************************************************************************
  * Prototypes in css.c
  *****************************************************************************/
-int   _dvdcss_test        ( dvdcss_t );
-int   _dvdcss_title       ( dvdcss_t, int );
-int   _dvdcss_disckey     ( dvdcss_t );
-int   _dvdcss_unscramble  ( uint8_t *, uint8_t * );
+int dvdcss_test       ( dvdcss_t );
+int dvdcss_title      ( dvdcss_t, int );
+int dvdcss_disckey    ( dvdcss_t );
+int dvdcss_unscramble ( uint8_t *, uint8_t * );
 
 #endif /* DVDCSS_CSS_H */
--- a/src/device.c
+++ b/src/device.c
@@ -100,7 +100,7 @@
 #   define os2_readv    libc_readv
 #endif
 
-int _dvdcss_use_ioctls( dvdcss_t dvdcss )
+int dvdcss_use_ioctls( dvdcss_t dvdcss )
 {
 #if defined( WIN32 )
     if( dvdcss->b_file )
@@ -162,7 +162,7 @@
 #endif
 }
 
-void _dvdcss_check ( dvdcss_t dvdcss )
+void dvdcss_check_device ( dvdcss_t dvdcss )
 {
 #if defined( WIN32 )
     DWORD drives;
@@ -352,7 +352,7 @@
     print_error( dvdcss, "could not find a suitable default drive" );
 }
 
-int _dvdcss_open ( dvdcss_t dvdcss )
+int dvdcss_open_device ( dvdcss_t dvdcss )
 {
     char const *psz_device = dvdcss->psz_device;
 
@@ -409,7 +409,7 @@
 }
 
 #ifdef DVDCSS_RAW_OPEN
-int _dvdcss_raw_open ( dvdcss_t dvdcss, char const *psz_device )
+int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device )
 {
     dvdcss->i_raw_fd = open( psz_device, 0 );
 
@@ -429,7 +429,7 @@
 }
 #endif
 
-int _dvdcss_close ( dvdcss_t dvdcss )
+int dvdcss_close_device ( dvdcss_t dvdcss )
 {
 #if defined( WIN32 )
     if( dvdcss->b_file )
--- a/src/device.h
+++ b/src/device.h
@@ -52,14 +52,14 @@
 /*****************************************************************************
  * Device reading prototypes
  *****************************************************************************/
-int  _dvdcss_use_ioctls ( dvdcss_t );
-void _dvdcss_check      ( dvdcss_t );
-int  _dvdcss_open       ( dvdcss_t );
-int  _dvdcss_close      ( dvdcss_t );
+int  dvdcss_use_ioctls   ( dvdcss_t );
+void dvdcss_check_device ( dvdcss_t );
+int  dvdcss_open_device  ( dvdcss_t );
+int  dvdcss_close_device ( dvdcss_t );
 
 /*****************************************************************************
  * Device reading prototypes, raw-device specific
  *****************************************************************************/
-int _dvdcss_raw_open     ( dvdcss_t, char const * );
+int dvdcss_raw_open      ( dvdcss_t, const char * );
 
 #endif /* DVDCSS_DEVICE_H */
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -311,8 +311,8 @@
     /*
      *  Open device
      */
-    _dvdcss_check( dvdcss );
-    i_ret = _dvdcss_open( dvdcss );
+    dvdcss_check_device( dvdcss );
+    i_ret = dvdcss_open_device( dvdcss );
     if( i_ret < 0 )
     {
         free( dvdcss->psz_device );
@@ -321,11 +321,11 @@
     }
 
     dvdcss->b_scrambled = 1; /* Assume the worst */
-    dvdcss->b_ioctls = _dvdcss_use_ioctls( dvdcss );
+    dvdcss->b_ioctls = dvdcss_use_ioctls( dvdcss );
 
     if( dvdcss->b_ioctls )
     {
-        i_ret = _dvdcss_test( dvdcss );
+        i_ret = dvdcss_test( dvdcss );
 
         if( i_ret == -3 )
         {
@@ -352,7 +352,7 @@
     /* If disc is CSS protected and the ioctls work, authenticate the drive */
     if( dvdcss->b_scrambled && dvdcss->b_ioctls )
     {
-        i_ret = _dvdcss_disckey( dvdcss );
+        i_ret = dvdcss_disckey( dvdcss );
 
         if( i_ret < 0 )
         {
@@ -516,7 +516,7 @@
 #ifdef DVDCSS_RAW_OPEN
     if( psz_raw_device != NULL )
     {
-        _dvdcss_raw_open( dvdcss, psz_raw_device );
+        dvdcss_raw_open( dvdcss, psz_raw_device );
     }
 #endif
 
@@ -572,7 +572,7 @@
        || ( i_flags & DVDCSS_SEEK_KEY ) )
     {
         /* check the title key */
-        if( _dvdcss_title( dvdcss, i_blocks ) )
+        if( dvdcss_title( dvdcss, i_blocks ) )
         {
             return -1;
         }
@@ -640,7 +640,7 @@
         /* Decrypt the blocks we managed to read */
         for( i_index = i_ret; i_index; i_index-- )
         {
-            _dvdcss_unscramble( dvdcss->css.p_title_key, p_buffer );
+            dvdcss_unscramble( dvdcss->css.p_title_key, p_buffer );
             ((uint8_t*)p_buffer)[0x14] &= 0x8f;
             p_buffer = (uint8_t *)p_buffer + DVDCSS_BLOCK_SIZE;
         }
@@ -715,7 +715,7 @@
             iov_len = _p_iovec->iov_len;
         }
 
-        _dvdcss_unscramble( dvdcss->css.p_title_key, iov_base );
+        dvdcss_unscramble( dvdcss->css.p_title_key, iov_base );
         ((uint8_t*)iov_base)[0x14] &= 0x8f;
 
         iov_base = (void *) ((uint8_t*)iov_base + DVDCSS_BLOCK_SIZE);
@@ -748,7 +748,7 @@
         p_title = p_tmptitle;
     }
 
-    i_ret = _dvdcss_close( dvdcss );
+    i_ret = dvdcss_close_device( dvdcss );
 
     if( i_ret < 0 )
     {