[libdvdcss-devel] [PATCH 5/7] Add more const correctness changes.

Diego Biurrun diego at biurrun.de
Tue Nov 4 20:15:04 CET 2014


---
 src/css.c           | 23 ++++++++++++-----------
 src/css.h           |  2 +-
 src/device.c        |  2 +-
 src/device.h        |  2 +-
 src/dvdcss/dvdcss.h |  2 +-
 src/libdvdcss.c     |  2 +-
 6 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/src/css.c b/src/css.c
index 8995de8..ccd4989 100644
--- a/src/css.c
+++ b/src/css.c
@@ -66,7 +66,7 @@
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static void PrintKey        ( struct dvdcss *, const char *, const uint8_t * );
+static void PrintKey        ( const struct dvdcss *, const char *, const uint8_t * );
 
 static int  GetBusKey       ( struct dvdcss * );
 static int  GetASF          ( struct dvdcss * );
@@ -75,10 +75,10 @@ static void CryptKey        ( int, int, const uint8_t *, uint8_t * );
 static void DecryptKey      ( uint8_t,
                               const uint8_t *, const uint8_t *, uint8_t * );
 
-static int  DecryptDiscKey  ( struct dvdcss *, const uint8_t *, dvd_key );
-static int  CrackDiscKey    ( struct dvdcss *, uint8_t * );
+static int  DecryptDiscKey  ( const struct dvdcss *, const uint8_t *, dvd_key );
+static int  CrackDiscKey    ( const struct dvdcss *, uint8_t * );
 
-static void DecryptTitleKey ( dvd_key, dvd_key );
+static void DecryptTitleKey ( const dvd_key, dvd_key );
 static int  RecoverTitleKey ( int, const uint8_t *,
                               const uint8_t *, const uint8_t *, uint8_t * );
 static int  CrackTitleKey   ( struct dvdcss *, int, int, dvd_key );
@@ -536,10 +536,10 @@ static int dvdcss_titlekey( struct dvdcss *dvdcss, int i_pos, dvd_key p_title_ke
  * sec : sector to unscramble
  * key : title key for this sector
  *****************************************************************************/
-int dvdcss_unscramble( dvd_key p_key, uint8_t *p_sec )
+int dvdcss_unscramble( const dvd_key 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;
+    const uint8_t *p_end = p_sec + DVDCSS_BLOCK_SIZE;
 
     /* PES_scrambling_control */
     if( !(p_sec[0x14] & 0x30) )
@@ -726,7 +726,8 @@ static int GetBusKey( struct dvdcss *dvdcss )
 /*****************************************************************************
  * PrintKey : debug function that dumps a key value
  *****************************************************************************/
-static void PrintKey( dvdcss_t dvdcss, const char *prefix, const uint8_t *data )
+static void PrintKey( const struct dvdcss *dvdcss, const char *prefix,
+                      const uint8_t *data )
 {
     print_debug( dvdcss, "%s%02x:%02x:%02x:%02x:%02x", prefix,
                  data[0], data[1], data[2], data[3], data[4] );
@@ -1080,7 +1081,7 @@ static const dvd_key player_keys[] =
  * p_struct_disckey: the 2048 byte DVD_STRUCT_DISCKEY data
  * p_disc_key: result, the 5 byte disc key
  *****************************************************************************/
-static int DecryptDiscKey( struct dvdcss *dvdcss,
+static int DecryptDiscKey( const struct dvdcss *dvdcss,
                            const uint8_t *p_struct_disckey,
                            dvd_key p_disc_key )
 {
@@ -1124,7 +1125,7 @@ static int DecryptDiscKey( struct dvdcss *dvdcss,
  * p_disc_key: result, the 5 byte disc key
  * p_titlekey: the encrypted title key, gets overwritten by the decrypted key
  *****************************************************************************/
-static void DecryptTitleKey( dvd_key p_disc_key, dvd_key p_titlekey )
+static void DecryptTitleKey( const dvd_key p_disc_key, dvd_key p_titlekey )
 {
     DecryptKey( 0xff, p_disc_key, p_titlekey, p_titlekey );
 }
@@ -1141,7 +1142,7 @@ static void DecryptTitleKey( dvd_key p_disc_key, dvd_key p_titlekey )
 /*
  * Simple function to test if a candidate key produces the given hash
  */
-static int investigate( unsigned char *hash, unsigned char *ckey )
+static int investigate( const unsigned char *hash, const unsigned char *ckey )
 {
     unsigned char key[KEY_SIZE];
 
@@ -1150,7 +1151,7 @@ static int investigate( unsigned char *hash, unsigned char *ckey )
     return memcmp( key, ckey, KEY_SIZE );
 }
 
-static int CrackDiscKey( struct dvdcss *dvdcss, uint8_t *p_disc_key )
+static int CrackDiscKey( const struct dvdcss *dvdcss, uint8_t *p_disc_key )
 {
     unsigned char B[5] = { 0,0,0,0,0 }; /* Second Stage of mangle cipher */
     unsigned char C[5] = { 0,0,0,0,0 }; /* Output Stage of mangle cipher
diff --git a/src/css.h b/src/css.h
index bd6a804..9804bdf 100644
--- a/src/css.h
+++ b/src/css.h
@@ -60,6 +60,6 @@ typedef struct css
 int dvdcss_test       ( struct dvdcss * );
 int dvdcss_title      ( struct dvdcss *, int );
 int dvdcss_disckey    ( struct dvdcss * );
-int dvdcss_unscramble ( uint8_t *, uint8_t * );
+int dvdcss_unscramble ( const uint8_t *, uint8_t * );
 
 #endif /* DVDCSS_CSS_H */
diff --git a/src/device.c b/src/device.c
index 5735d8b..261b7a5 100644
--- a/src/device.c
+++ b/src/device.c
@@ -96,7 +96,7 @@ static int os2_open ( dvdcss_t, const char * );
 #   define os2_readv    libc_readv
 #endif
 
-int dvdcss_use_ioctls( struct dvdcss *dvdcss )
+int dvdcss_use_ioctls( const struct dvdcss *dvdcss )
 {
 #if defined( WIN32 )
     if( dvdcss->b_file )
diff --git a/src/device.h b/src/device.h
index a7ea982..b8aab97 100644
--- a/src/device.h
+++ b/src/device.h
@@ -52,7 +52,7 @@ struct iovec
 /*****************************************************************************
  * Device reading prototypes
  *****************************************************************************/
-int  dvdcss_use_ioctls   ( struct dvdcss * );
+int  dvdcss_use_ioctls   ( const struct dvdcss * );
 void dvdcss_check_device ( struct dvdcss * );
 int  dvdcss_open_device  ( struct dvdcss * );
 void dvdcss_close_device ( struct dvdcss * );
diff --git a/src/dvdcss/dvdcss.h b/src/dvdcss/dvdcss.h
index f7c6e71..a86b57c 100644
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -87,7 +87,7 @@ LIBDVDCSS_EXPORT int      dvdcss_readv ( struct dvdcss *,
                                int i_flags );
 LIBDVDCSS_EXPORT const char *dvdcss_error ( const struct dvdcss * );
 
-LIBDVDCSS_EXPORT int      dvdcss_is_scrambled ( struct dvdcss * );
+LIBDVDCSS_EXPORT int      dvdcss_is_scrambled ( const struct dvdcss * );
 
 #ifdef __cplusplus
 }
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 98c18dc..6f5d3af 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -788,7 +788,7 @@ LIBDVDCSS_EXPORT int dvdcss_close ( struct dvdcss *dvdcss )
  * \param dvdcss a \e libdvdcss instance.
  * \return 1 if the DVD is scrambled, 0 otherwise.
  */
-LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( struct dvdcss *dvdcss )
+LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( const struct dvdcss *dvdcss )
 {
     return dvdcss->b_scrambled;
 }
-- 
1.9.1



More information about the libdvdcss-devel mailing list