Discussion:
[libdvdcss-devel] more intrusive patches
Diego Biurrun
2014-11-04 19:14:59 UTC
Permalink
Now that most of my patches are out of the way, it's time for the leftover
more interesting, but probably also more controversial, patches.

Diego

[PATCH 1/7] Update NEWS file with latest changes.
[PATCH 2/7] error: const correctness
[PATCH 3/7] Do not invade the _t namespace with (typedeffed) struct
[PATCH 4/7] Replace dvdcss_t typedef by "struct dvdcss *".
[PATCH 5/7] Add more const correctness changes.
[PATCH 6/7] Directly expose struct iovec in the API instead of hiding
[PATCH 7/7] Directly expose uint8_t in the API instead of hiding it
Diego Biurrun
2014-11-04 19:15:00 UTC
Permalink
---

Should I use bigger words? Awesome code cleanup! 21st century library!

NEWS | 1 +
1 file changed, 1 insertion(+)

diff --git a/NEWS b/NEWS
index 72a6092..9a13bf9 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Changes between 1.2.13 and 1.3.0:
* Drop support for HP-UX, Windows 9x, and Windows NT 4.0.
Windows NT 4.0 SP4 with IE 5.0 is now required.
* Replace BeOS support by Haiku support.
+ * Miscellaneous cleanups to code, documentation, build system.


Changes between 1.2.12 and 1.2.13:
--
1.9.1
Jean-Baptiste Kempf
2014-11-04 19:18:04 UTC
Permalink
Seems fine, but isn't 1.3.0 already tagged?
Post by Diego Biurrun
---
Should I use bigger words? Awesome code cleanup! 21st century library!
NEWS | 1 +
1 file changed, 1 insertion(+)
diff --git a/NEWS b/NEWS
index 72a6092..9a13bf9 100644
--- a/NEWS
+++ b/NEWS
* Drop support for HP-UX, Windows 9x, and Windows NT 4.0.
Windows NT 4.0 SP4 with IE 5.0 is now required.
* Replace BeOS support by Haiku support.
+ * Miscellaneous cleanups to code, documentation, build system.
--
1.9.1
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Diego Biurrun
2014-11-04 19:23:17 UTC
Permalink
Indeed, I'll update the NEWS file to make more sense..
Post by Jean-Baptiste Kempf
Seems fine, but isn't 1.3.0 already tagged?
Post by Diego Biurrun
---
Should I use bigger words? Awesome code cleanup! 21st century library!
NEWS | 1 +
1 file changed, 1 insertion(+)
diff --git a/NEWS b/NEWS
index 72a6092..9a13bf9 100644
--- a/NEWS
+++ b/NEWS
* Drop support for HP-UX, Windows 9x, and Windows NT 4.0.
Windows NT 4.0 SP4 with IE 5.0 is now required.
* Replace BeOS support by Haiku support.
+ * Miscellaneous cleanups to code, documentation, build system.
--
1.9.1
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
Diego Biurrun
2014-11-05 10:19:03 UTC
Permalink
---

Now fixed to not mess up the 1.3.0 release changelog.

NEWS | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 72a6092..ef617b5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+Changes since 1.3.0:
+--------------------
+ * Drop support for HP-UX.
+ * Drop support for Windows 9x.
+ Windows NT 4.0 SP4 with IE 5.0 is now required.
+ * Replace BeOS support by Haiku support.
+ * Miscellaneous cleanups to code, documentation, build system.
+
+
Changes between 1.2.13 and 1.3.0:
---------------------------------

@@ -5,10 +14,9 @@ Changes between 1.2.13 and 1.3.0:
- the function dvdcss_title()
- the type dvdcss_handle
- the variable dvdcss_interface_2
+ * Drop support for Windows 98 and Windows NT 4.0.
+ Windows 98 SE with IE 5.0 and Windows NT 4.0 SP4 with IE 5.0 are required.
* Support for Android
- * Drop support for HP-UX, Windows 9x, and Windows NT 4.0.
- Windows NT 4.0 SP4 with IE 5.0 is now required.
- * Replace BeOS support by Haiku support.


Changes between 1.2.12 and 1.2.13:
--
1.9.1
Jean-Baptiste Kempf
2014-11-05 10:32:13 UTC
Permalink
LGTM
Post by Diego Biurrun
---
Now fixed to not mess up the 1.3.0 release changelog.
NEWS | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index 72a6092..ef617b5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+--------------------
+ * Drop support for HP-UX.
+ * Drop support for Windows 9x.
+ Windows NT 4.0 SP4 with IE 5.0 is now required.
+ * Replace BeOS support by Haiku support.
+ * Miscellaneous cleanups to code, documentation, build system.
+
+
---------------------------------
- the function dvdcss_title()
- the type dvdcss_handle
- the variable dvdcss_interface_2
+ * Drop support for Windows 98 and Windows NT 4.0.
+ Windows 98 SE with IE 5.0 and Windows NT 4.0 SP4 with IE 5.0 are required.
* Support for Android
- * Drop support for HP-UX, Windows 9x, and Windows NT 4.0.
- Windows NT 4.0 SP4 with IE 5.0 is now required.
- * Replace BeOS support by Haiku support.
--
1.9.1
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Diego Biurrun
2014-11-04 19:15:02 UTC
Permalink
The _t namespace is reserved by POSIX.
---
src/css.c | 36 ++++++++++++++++++------------------
src/css.h | 22 +++++++++++-----------
src/libdvdcss.c | 4 ++--
src/libdvdcss.h | 4 ++--
4 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/src/css.c b/src/css.c
index 73a4906..f986424 100644
--- a/src/css.c
+++ b/src/css.c
@@ -75,20 +75,20 @@ 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 ( dvdcss_t, const uint8_t *, dvd_key_t );
+static int DecryptDiscKey ( dvdcss_t, const uint8_t *, dvd_key );
static int CrackDiscKey ( dvdcss_t, uint8_t * );

-static void DecryptTitleKey ( dvd_key_t, dvd_key_t );
+static void DecryptTitleKey ( dvd_key, dvd_key );
static int RecoverTitleKey ( int, const uint8_t *,
const uint8_t *, const uint8_t *, uint8_t * );
-static int CrackTitleKey ( dvdcss_t, int, int, dvd_key_t );
+static int CrackTitleKey ( dvdcss_t, int, int, dvd_key );

static int AttackPattern ( const uint8_t[], uint8_t * );
#if 0
static int AttackPadding ( const uint8_t[] );
#endif

-static int dvdcss_titlekey ( dvdcss_t, int , dvd_key_t );
+static int dvdcss_titlekey ( dvdcss_t, int, dvd_key );

/*****************************************************************************
* dvdcss_test: check if the disc is encrypted or not
@@ -182,10 +182,10 @@ int dvdcss_test( dvdcss_t dvdcss )
*****************************************************************************/
int dvdcss_title ( dvdcss_t dvdcss, int i_block )
{
- dvd_title_t *p_title;
- dvd_title_t *p_newtitle;
- dvd_key_t p_title_key;
- int i_fd, i_ret = -1, b_cache = 0;
+ struct dvd_title *p_title;
+ struct dvd_title *p_newtitle;
+ dvd_key p_title_key;
+ int i_fd, i_ret = -1, b_cache = 0;

if( ! dvdcss->b_scrambled )
{
@@ -335,7 +335,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
int dvdcss_disckey( dvdcss_t dvdcss )
{
unsigned char p_buffer[ DVD_DISCKEY_SIZE ];
- dvd_key_t p_disc_key;
+ dvd_key p_disc_key;
int i;

if( GetBusKey( dvdcss ) < 0 )
@@ -418,7 +418,7 @@ int dvdcss_disckey( dvdcss_t dvdcss )
/*****************************************************************************
* 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 p_title_key )
{
static uint8_t p_garbage[ DVDCSS_BLOCK_SIZE ]; /* we never read it back */
uint8_t p_key[ KEY_SIZE ];
@@ -536,7 +536,7 @@ static int dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key_t p_title_key )
* 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 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;
@@ -592,9 +592,9 @@ static int GetBusKey( dvdcss_t dvdcss )
{
uint8_t p_buffer[10];
uint8_t p_challenge[2*KEY_SIZE];
- dvd_key_t p_key1;
- dvd_key_t p_key2;
- dvd_key_t p_key_check;
+ dvd_key p_key1;
+ dvd_key p_key2;
+ dvd_key p_key_check;
uint8_t i_variant = 0;
int i_ret = -1;
int i;
@@ -1037,7 +1037,7 @@ static void DecryptKey( uint8_t invert, const uint8_t *p_key,
* cracker. A copy of his article can be found here:
* http://www-2.cs.cmu.edu/~dst/DeCSS/FrankStevenson/mail2.txt
*****************************************************************************/
-static const dvd_key_t player_keys[] =
+static const dvd_key player_keys[] =
{
{ 0x01, 0xaf, 0xe3, 0x12, 0x80 },
{ 0x12, 0x11, 0xca, 0x04, 0x3b },
@@ -1081,7 +1081,7 @@ static const dvd_key_t player_keys[] =
* p_disc_key: result, the 5 byte disc key
*****************************************************************************/
static int DecryptDiscKey( dvdcss_t dvdcss, const uint8_t *p_struct_disckey,
- dvd_key_t p_disc_key )
+ dvd_key p_disc_key )
{
uint8_t p_verify[KEY_SIZE];
unsigned int i, n = 0;
@@ -1123,7 +1123,7 @@ static int DecryptDiscKey( dvdcss_t dvdcss, const uint8_t *p_struct_disckey,
* 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_t p_disc_key, dvd_key_t p_titlekey )
+static void DecryptTitleKey( dvd_key p_disc_key, dvd_key p_titlekey )
{
DecryptKey( 0xff, p_disc_key, p_titlekey, p_titlekey );
}
@@ -1488,7 +1488,7 @@ static int i_tries = 0, i_success = 0;
* i_pos is the starting sector, i_len is the maximum number of sectors to read
*****************************************************************************/
static int CrackTitleKey( dvdcss_t dvdcss, int i_pos, int i_len,
- dvd_key_t p_titlekey )
+ dvd_key p_titlekey )
{
uint8_t p_buf[ DVDCSS_BLOCK_SIZE ];
const uint8_t p_packstart[4] = { 0x00, 0x00, 0x01, 0xba };
diff --git a/src/css.h b/src/css.h
index 573de3f..f576e63 100644
--- a/src/css.h
+++ b/src/css.h
@@ -37,22 +37,22 @@

#define KEY_SIZE 5

-typedef uint8_t dvd_key_t[KEY_SIZE];
+typedef uint8_t dvd_key[KEY_SIZE];

-typedef struct dvd_title_s
+typedef struct dvd_title
{
- int i_startlb;
- dvd_key_t p_key;
- struct dvd_title_s *p_next;
-} dvd_title_t;
+ int i_startlb;
+ dvd_key p_key;
+ struct dvd_title *p_next;
+} dvd_title;

-typedef struct css_s
+typedef struct css
{
int i_agid; /* Current Authentication Grant ID. */
- dvd_key_t p_bus_key; /* Current session key. */
- dvd_key_t p_disc_key; /* This DVD disc's key. */
- dvd_key_t p_title_key; /* Current title key. */
-} css_t;
+ dvd_key p_bus_key; /* Current session key. */
+ dvd_key p_disc_key; /* This DVD disc's key. */
+ dvd_key p_title_key; /* Current title key. */
+} css;

/*****************************************************************************
* Prototypes in css.c
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index ab80b9c..00aa4bd 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -763,13 +763,13 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t dvdcss, void *p_iovec,
*/
LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t dvdcss )
{
- dvd_title_t *p_title;
+ struct dvd_title *p_title;

/* Free our list of keys */
p_title = dvdcss->p_titles;
while( p_title )
{
- dvd_title_t *p_tmptitle = p_title->p_next;
+ struct dvd_title *p_tmptitle = p_title->p_next;
free( p_title );
p_title = p_tmptitle;
}
diff --git a/src/libdvdcss.h b/src/libdvdcss.h
index 221e6fe..9750c37 100644
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -60,10 +60,10 @@ struct dvdcss_s

/* Decryption stuff */
enum dvdcss_method i_method;
- css_t css;
+ struct css css;
int b_ioctls;
int b_scrambled;
- dvd_title_t *p_titles;
+ struct dvd_title *p_titles;

/* Key cache directory and pointer to the filename */
char psz_cachefile[PATH_MAX];
--
1.9.1
Jean-Baptiste Kempf
2014-11-04 19:19:02 UTC
Permalink
LGTM.
Post by Diego Biurrun
The _t namespace is reserved by POSIX.
---
src/css.c | 36 ++++++++++++++++++------------------
src/css.h | 22 +++++++++++-----------
src/libdvdcss.c | 4 ++--
src/libdvdcss.h | 4 ++--
4 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/src/css.c b/src/css.c
index 73a4906..f986424 100644
--- a/src/css.c
+++ b/src/css.c
@@ -75,20 +75,20 @@ 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 ( dvdcss_t, const uint8_t *, dvd_key_t );
+static int DecryptDiscKey ( dvdcss_t, const uint8_t *, dvd_key );
static int CrackDiscKey ( dvdcss_t, uint8_t * );
-static void DecryptTitleKey ( dvd_key_t, dvd_key_t );
+static void DecryptTitleKey ( dvd_key, dvd_key );
static int RecoverTitleKey ( int, const uint8_t *,
const uint8_t *, const uint8_t *, uint8_t * );
-static int CrackTitleKey ( dvdcss_t, int, int, dvd_key_t );
+static int CrackTitleKey ( dvdcss_t, int, int, dvd_key );
static int AttackPattern ( const uint8_t[], uint8_t * );
#if 0
static int AttackPadding ( const uint8_t[] );
#endif
-static int dvdcss_titlekey ( dvdcss_t, int , dvd_key_t );
+static int dvdcss_titlekey ( dvdcss_t, int, dvd_key );
/*****************************************************************************
* dvdcss_test: check if the disc is encrypted or not
@@ -182,10 +182,10 @@ int dvdcss_test( dvdcss_t dvdcss )
*****************************************************************************/
int dvdcss_title ( dvdcss_t dvdcss, int i_block )
{
- dvd_title_t *p_title;
- dvd_title_t *p_newtitle;
- dvd_key_t p_title_key;
- int i_fd, i_ret = -1, b_cache = 0;
+ struct dvd_title *p_title;
+ struct dvd_title *p_newtitle;
+ dvd_key p_title_key;
+ int i_fd, i_ret = -1, b_cache = 0;
if( ! dvdcss->b_scrambled )
{
@@ -335,7 +335,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
int dvdcss_disckey( dvdcss_t dvdcss )
{
unsigned char p_buffer[ DVD_DISCKEY_SIZE ];
- dvd_key_t p_disc_key;
+ dvd_key p_disc_key;
int i;
if( GetBusKey( dvdcss ) < 0 )
@@ -418,7 +418,7 @@ int dvdcss_disckey( dvdcss_t dvdcss )
/*****************************************************************************
* 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 p_title_key )
{
static uint8_t p_garbage[ DVDCSS_BLOCK_SIZE ]; /* we never read it back */
uint8_t p_key[ KEY_SIZE ];
@@ -536,7 +536,7 @@ static int dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key_t p_title_key )
* 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 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;
@@ -592,9 +592,9 @@ static int GetBusKey( dvdcss_t dvdcss )
{
uint8_t p_buffer[10];
uint8_t p_challenge[2*KEY_SIZE];
- dvd_key_t p_key1;
- dvd_key_t p_key2;
- dvd_key_t p_key_check;
+ dvd_key p_key1;
+ dvd_key p_key2;
+ dvd_key p_key_check;
uint8_t i_variant = 0;
int i_ret = -1;
int i;
@@ -1037,7 +1037,7 @@ static void DecryptKey( uint8_t invert, const uint8_t *p_key,
* http://www-2.cs.cmu.edu/~dst/DeCSS/FrankStevenson/mail2.txt
*****************************************************************************/
-static const dvd_key_t player_keys[] =
+static const dvd_key player_keys[] =
{
{ 0x01, 0xaf, 0xe3, 0x12, 0x80 },
{ 0x12, 0x11, 0xca, 0x04, 0x3b },
@@ -1081,7 +1081,7 @@ static const dvd_key_t player_keys[] =
* p_disc_key: result, the 5 byte disc key
*****************************************************************************/
static int DecryptDiscKey( dvdcss_t dvdcss, const uint8_t *p_struct_disckey,
- dvd_key_t p_disc_key )
+ dvd_key p_disc_key )
{
uint8_t p_verify[KEY_SIZE];
unsigned int i, n = 0;
@@ -1123,7 +1123,7 @@ static int DecryptDiscKey( dvdcss_t dvdcss, const uint8_t *p_struct_disckey,
* 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_t p_disc_key, dvd_key_t p_titlekey )
+static void DecryptTitleKey( dvd_key p_disc_key, dvd_key p_titlekey )
{
DecryptKey( 0xff, p_disc_key, p_titlekey, p_titlekey );
}
@@ -1488,7 +1488,7 @@ static int i_tries = 0, i_success = 0;
* i_pos is the starting sector, i_len is the maximum number of sectors to read
*****************************************************************************/
static int CrackTitleKey( dvdcss_t dvdcss, int i_pos, int i_len,
- dvd_key_t p_titlekey )
+ dvd_key p_titlekey )
{
uint8_t p_buf[ DVDCSS_BLOCK_SIZE ];
const uint8_t p_packstart[4] = { 0x00, 0x00, 0x01, 0xba };
diff --git a/src/css.h b/src/css.h
index 573de3f..f576e63 100644
--- a/src/css.h
+++ b/src/css.h
@@ -37,22 +37,22 @@
#define KEY_SIZE 5
-typedef uint8_t dvd_key_t[KEY_SIZE];
+typedef uint8_t dvd_key[KEY_SIZE];
-typedef struct dvd_title_s
+typedef struct dvd_title
{
- int i_startlb;
- dvd_key_t p_key;
- struct dvd_title_s *p_next;
-} dvd_title_t;
+ int i_startlb;
+ dvd_key p_key;
+ struct dvd_title *p_next;
+} dvd_title;
-typedef struct css_s
+typedef struct css
{
int i_agid; /* Current Authentication Grant ID. */
- dvd_key_t p_bus_key; /* Current session key. */
- dvd_key_t p_disc_key; /* This DVD disc's key. */
- dvd_key_t p_title_key; /* Current title key. */
-} css_t;
+ dvd_key p_bus_key; /* Current session key. */
+ dvd_key p_disc_key; /* This DVD disc's key. */
+ dvd_key p_title_key; /* Current title key. */
+} css;
/*****************************************************************************
* Prototypes in css.c
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index ab80b9c..00aa4bd 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -763,13 +763,13 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t dvdcss, void *p_iovec,
*/
LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t dvdcss )
{
- dvd_title_t *p_title;
+ struct dvd_title *p_title;
/* Free our list of keys */
p_title = dvdcss->p_titles;
while( p_title )
{
- dvd_title_t *p_tmptitle = p_title->p_next;
+ struct dvd_title *p_tmptitle = p_title->p_next;
free( p_title );
p_title = p_tmptitle;
}
diff --git a/src/libdvdcss.h b/src/libdvdcss.h
index 221e6fe..9750c37 100644
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -60,10 +60,10 @@ struct dvdcss_s
/* Decryption stuff */
enum dvdcss_method i_method;
- css_t css;
+ struct css css;
int b_ioctls;
int b_scrambled;
- dvd_title_t *p_titles;
+ struct dvd_title *p_titles;
/* Key cache directory and pointer to the filename */
char psz_cachefile[PATH_MAX];
--
1.9.1
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Diego Biurrun
2014-11-04 19:15:01 UTC
Permalink
---

Returning "const char *" feels slightly weird, for some reason..

src/dvdcss/dvdcss.h | 2 +-
src/error.c | 2 +-
src/libdvdcss.c | 2 +-
src/libdvdcss.h | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/dvdcss/dvdcss.h b/src/dvdcss/dvdcss.h
index 64f95cf..ea62b8b 100644
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -85,7 +85,7 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t,
void *p_iovec,
int i_blocks,
int i_flags );
-LIBDVDCSS_EXPORT char * dvdcss_error ( dvdcss_t );
+LIBDVDCSS_EXPORT const char *dvdcss_error ( const dvdcss_t );

LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( dvdcss_t );

diff --git a/src/error.c b/src/error.c
index 9d5f242..00aee4a 100644
--- a/src/error.c
+++ b/src/error.c
@@ -29,7 +29,7 @@
/*****************************************************************************
* Error messages
*****************************************************************************/
-void print_error( dvdcss_t dvdcss, char *psz_string )
+void print_error( dvdcss_t dvdcss, const char *psz_string )
{
if( dvdcss->b_errors )
{
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 975d745..ab80b9c 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -562,7 +562,7 @@ error:
* Return a string with the last error message produced by \e libdvdcss.
* Useful to conveniently format error messages in external applications.
*/
-LIBDVDCSS_EXPORT char * dvdcss_error ( dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT const char * dvdcss_error ( const dvdcss_t dvdcss )
{
return dvdcss->psz_error;
}
diff --git a/src/libdvdcss.h b/src/libdvdcss.h
index 399a1a3..221e6fe 100644
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -70,7 +70,7 @@ struct dvdcss_s
char * psz_block;

/* Error management */
- char * psz_error;
+ const char *psz_error;
int b_errors;
int b_debug;

@@ -96,6 +96,6 @@ struct dvdcss_s
fprintf( stderr, "\n" ); \
}

-void print_error ( dvdcss_t, char * );
+void print_error ( dvdcss_t, const char * );

#endif /* DVDCSS_LIBDVDCSS_H */
--
1.9.1
Jean-Baptiste Kempf
2014-11-04 19:18:34 UTC
Permalink
Does it break ABI/API?
Post by Diego Biurrun
---
Returning "const char *" feels slightly weird, for some reason..
src/dvdcss/dvdcss.h | 2 +-
src/error.c | 2 +-
src/libdvdcss.c | 2 +-
src/libdvdcss.h | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/dvdcss/dvdcss.h b/src/dvdcss/dvdcss.h
index 64f95cf..ea62b8b 100644
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -85,7 +85,7 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t,
void *p_iovec,
int i_blocks,
int i_flags );
-LIBDVDCSS_EXPORT char * dvdcss_error ( dvdcss_t );
+LIBDVDCSS_EXPORT const char *dvdcss_error ( const dvdcss_t );
LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( dvdcss_t );
diff --git a/src/error.c b/src/error.c
index 9d5f242..00aee4a 100644
--- a/src/error.c
+++ b/src/error.c
@@ -29,7 +29,7 @@
/*****************************************************************************
* Error messages
*****************************************************************************/
-void print_error( dvdcss_t dvdcss, char *psz_string )
+void print_error( dvdcss_t dvdcss, const char *psz_string )
{
if( dvdcss->b_errors )
{
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 975d745..ab80b9c 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
* Return a string with the last error message produced by \e libdvdcss.
* Useful to conveniently format error messages in external applications.
*/
-LIBDVDCSS_EXPORT char * dvdcss_error ( dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT const char * dvdcss_error ( const dvdcss_t dvdcss )
{
return dvdcss->psz_error;
}
diff --git a/src/libdvdcss.h b/src/libdvdcss.h
index 399a1a3..221e6fe 100644
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -70,7 +70,7 @@ struct dvdcss_s
char * psz_block;
/* Error management */
- char * psz_error;
+ const char *psz_error;
int b_errors;
int b_debug;
@@ -96,6 +96,6 @@ struct dvdcss_s
fprintf( stderr, "\n" ); \
}
-void print_error ( dvdcss_t, char * );
+void print_error ( dvdcss_t, const char * );
#endif /* DVDCSS_LIBDVDCSS_H */
--
1.9.1
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Diego Elio Pettenò
2014-11-04 21:12:15 UTC
Permalink
It could, although it sounds unlikely that somebody is writing on the
error returned string, it is a formal API/ABI breakage.
Diego Elio Pettenò — Flameeyes
Post by Jean-Baptiste Kempf
Does it break ABI/API?
Post by Diego Biurrun
---
Returning "const char *" feels slightly weird, for some reason..
src/dvdcss/dvdcss.h | 2 +-
src/error.c | 2 +-
src/libdvdcss.c | 2 +-
src/libdvdcss.h | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/dvdcss/dvdcss.h b/src/dvdcss/dvdcss.h
index 64f95cf..ea62b8b 100644
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -85,7 +85,7 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t,
void *p_iovec,
int i_blocks,
int i_flags );
-LIBDVDCSS_EXPORT char * dvdcss_error ( dvdcss_t );
+LIBDVDCSS_EXPORT const char *dvdcss_error ( const dvdcss_t );
LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( dvdcss_t );
diff --git a/src/error.c b/src/error.c
index 9d5f242..00aee4a 100644
--- a/src/error.c
+++ b/src/error.c
@@ -29,7 +29,7 @@
/*****************************************************************************
* Error messages
*****************************************************************************/
-void print_error( dvdcss_t dvdcss, char *psz_string )
+void print_error( dvdcss_t dvdcss, const char *psz_string )
{
if( dvdcss->b_errors )
{
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 975d745..ab80b9c 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
* Return a string with the last error message produced by \e libdvdcss.
* Useful to conveniently format error messages in external applications.
*/
-LIBDVDCSS_EXPORT char * dvdcss_error ( dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT const char * dvdcss_error ( const dvdcss_t dvdcss )
{
return dvdcss->psz_error;
}
diff --git a/src/libdvdcss.h b/src/libdvdcss.h
index 399a1a3..221e6fe 100644
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -70,7 +70,7 @@ struct dvdcss_s
char * psz_block;
/* Error management */
- char * psz_error;
+ const char *psz_error;
int b_errors;
int b_debug;
@@ -96,6 +96,6 @@ struct dvdcss_s
fprintf( stderr, "\n" ); \
}
-void print_error ( dvdcss_t, char * );
+void print_error ( dvdcss_t, const char * );
#endif /* DVDCSS_LIBDVDCSS_H */
--
1.9.1
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
Jean-Baptiste Kempf
2014-11-05 10:34:00 UTC
Permalink
Ship it, but mention the minor change in NEWS.
Post by Diego Biurrun
---
Returning "const char *" feels slightly weird, for some reason..
src/dvdcss/dvdcss.h | 2 +-
src/error.c | 2 +-
src/libdvdcss.c | 2 +-
src/libdvdcss.h | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/dvdcss/dvdcss.h b/src/dvdcss/dvdcss.h
index 64f95cf..ea62b8b 100644
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -85,7 +85,7 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t,
void *p_iovec,
int i_blocks,
int i_flags );
-LIBDVDCSS_EXPORT char * dvdcss_error ( dvdcss_t );
+LIBDVDCSS_EXPORT const char *dvdcss_error ( const dvdcss_t );
LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( dvdcss_t );
diff --git a/src/error.c b/src/error.c
index 9d5f242..00aee4a 100644
--- a/src/error.c
+++ b/src/error.c
@@ -29,7 +29,7 @@
/*****************************************************************************
* Error messages
*****************************************************************************/
-void print_error( dvdcss_t dvdcss, char *psz_string )
+void print_error( dvdcss_t dvdcss, const char *psz_string )
{
if( dvdcss->b_errors )
{
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 975d745..ab80b9c 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
* Return a string with the last error message produced by \e libdvdcss.
* Useful to conveniently format error messages in external applications.
*/
-LIBDVDCSS_EXPORT char * dvdcss_error ( dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT const char * dvdcss_error ( const dvdcss_t dvdcss )
{
return dvdcss->psz_error;
}
diff --git a/src/libdvdcss.h b/src/libdvdcss.h
index 399a1a3..221e6fe 100644
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -70,7 +70,7 @@ struct dvdcss_s
char * psz_block;
/* Error management */
- char * psz_error;
+ const char *psz_error;
int b_errors;
int b_debug;
@@ -96,6 +96,6 @@ struct dvdcss_s
fprintf( stderr, "\n" ); \
}
-void print_error ( dvdcss_t, char * );
+void print_error ( dvdcss_t, const char * );
#endif /* DVDCSS_LIBDVDCSS_H */
--
1.9.1
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Diego Biurrun
2014-11-04 19:15:03 UTC
Permalink
The _t namespace is reserved by POSIX, so dvdcss_t invades the POSIX namespace.
Furthermore typedeffing a pointer to a struct makes declaring the structure as
const harder. Structs as parameters allow for more complete const correctness.
---

Don't like this? Look at the next patch, which this one makes possible.

src/css.c | 33 +++++++++++++++++----------------
src/css.h | 6 +++---
src/device.c | 42 +++++++++++++++++++++---------------------
src/device.h | 10 +++++-----
src/dvdcss/dvdcss.h | 16 ++++++++--------
src/error.c | 2 +-
src/libdvdcss.c | 28 ++++++++++++++--------------
src/libdvdcss.h | 10 +++++-----
test/csstest.c | 2 +-
test/dvd_region.c | 2 +-
10 files changed, 76 insertions(+), 75 deletions(-)

diff --git a/src/css.c b/src/css.c
index f986424..8995de8 100644
--- a/src/css.c
+++ b/src/css.c
@@ -66,29 +66,29 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static void PrintKey ( dvdcss_t, const char *, const uint8_t * );
+static void PrintKey ( struct dvdcss *, const char *, const uint8_t * );

-static int GetBusKey ( dvdcss_t );
-static int GetASF ( dvdcss_t );
+static int GetBusKey ( struct dvdcss * );
+static int GetASF ( struct dvdcss * );

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 ( dvdcss_t, const uint8_t *, dvd_key );
-static int CrackDiscKey ( dvdcss_t, uint8_t * );
+static int DecryptDiscKey ( struct dvdcss *, const uint8_t *, dvd_key );
+static int CrackDiscKey ( struct dvdcss *, uint8_t * );

static void DecryptTitleKey ( dvd_key, dvd_key );
static int RecoverTitleKey ( int, const uint8_t *,
const uint8_t *, const uint8_t *, uint8_t * );
-static int CrackTitleKey ( dvdcss_t, int, int, dvd_key );
+static int CrackTitleKey ( struct dvdcss *, int, int, dvd_key );

static int AttackPattern ( const uint8_t[], uint8_t * );
#if 0
static int AttackPadding ( const uint8_t[] );
#endif

-static int dvdcss_titlekey ( dvdcss_t, int, dvd_key );
+static int dvdcss_titlekey ( struct dvdcss *, int, dvd_key );

/*****************************************************************************
* dvdcss_test: check if the disc is encrypted or not
@@ -101,7 +101,7 @@ static int dvdcss_titlekey ( dvdcss_t, int, dvd_key );
* -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( struct dvdcss *dvdcss )
{
const char *psz_type, *psz_rpc;
int i_ret, i_copyright, i_type, i_mask, i_rpc;
@@ -180,7 +180,7 @@ int dvdcss_test( dvdcss_t dvdcss )
* 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 ( struct dvdcss *dvdcss, int i_block )
{
struct dvd_title *p_title;
struct dvd_title *p_newtitle;
@@ -332,7 +332,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
* -disc key hash crack,
* -decryption with player keys if they are available.
*****************************************************************************/
-int dvdcss_disckey( dvdcss_t dvdcss )
+int dvdcss_disckey( struct dvdcss *dvdcss )
{
unsigned char p_buffer[ DVD_DISCKEY_SIZE ];
dvd_key p_disc_key;
@@ -418,7 +418,7 @@ int dvdcss_disckey( dvdcss_t dvdcss )
/*****************************************************************************
* dvdcss_titlekey: get title key.
*****************************************************************************/
-static int dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key p_title_key )
+static int dvdcss_titlekey( struct dvdcss *dvdcss, int i_pos, dvd_key p_title_key )
{
static uint8_t p_garbage[ DVDCSS_BLOCK_SIZE ]; /* we never read it back */
uint8_t p_key[ KEY_SIZE ];
@@ -588,7 +588,7 @@ int dvdcss_unscramble( dvd_key p_key, uint8_t *p_sec )
* that ASF=1 from the start and then later fail with a 'read of scrambled
* block without authentication' error.
*****************************************************************************/
-static int GetBusKey( dvdcss_t dvdcss )
+static int GetBusKey( struct dvdcss *dvdcss )
{
uint8_t p_buffer[10];
uint8_t p_challenge[2*KEY_SIZE];
@@ -740,7 +740,7 @@ static void PrintKey( dvdcss_t dvdcss, const char *prefix, const uint8_t *data )
* 0 if the device needs to be authenticated,
* 1 either.
*****************************************************************************/
-static int GetASF( dvdcss_t dvdcss )
+static int GetASF( struct dvdcss *dvdcss )
{
int i_asf = 0;

@@ -1080,7 +1080,8 @@ 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( dvdcss_t dvdcss, const uint8_t *p_struct_disckey,
+static int DecryptDiscKey( struct dvdcss *dvdcss,
+ const uint8_t *p_struct_disckey,
dvd_key p_disc_key )
{
uint8_t p_verify[KEY_SIZE];
@@ -1149,7 +1150,7 @@ static int investigate( unsigned char *hash, unsigned char *ckey )
return memcmp( key, ckey, KEY_SIZE );
}

-static int CrackDiscKey( dvdcss_t dvdcss, uint8_t *p_disc_key )
+static int CrackDiscKey( 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
@@ -1487,7 +1488,7 @@ static int i_tries = 0, i_success = 0;
* 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
*****************************************************************************/
-static int CrackTitleKey( dvdcss_t dvdcss, int i_pos, int i_len,
+static int CrackTitleKey( struct dvdcss *dvdcss, int i_pos, int i_len,
dvd_key p_titlekey )
{
uint8_t p_buf[ DVDCSS_BLOCK_SIZE ];
diff --git a/src/css.h b/src/css.h
index f576e63..bd6a804 100644
--- a/src/css.h
+++ b/src/css.h
@@ -57,9 +57,9 @@ typedef struct css
/*****************************************************************************
* Prototypes in css.c
*****************************************************************************/
-int dvdcss_test ( dvdcss_t );
-int dvdcss_title ( dvdcss_t, int );
-int dvdcss_disckey ( dvdcss_t );
+int dvdcss_test ( struct dvdcss * );
+int dvdcss_title ( struct dvdcss *, int );
+int dvdcss_disckey ( struct dvdcss * );
int dvdcss_unscramble ( uint8_t *, uint8_t * );

#endif /* DVDCSS_CSS_H */
diff --git a/src/device.c b/src/device.c
index aeafe31..5735d8b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -77,16 +77,16 @@
/*****************************************************************************
* Device reading prototypes
*****************************************************************************/
-static int libc_open ( dvdcss_t, const char * );
-static int libc_seek ( dvdcss_t, int );
-static int libc_read ( dvdcss_t, void *, int );
-static int libc_readv ( dvdcss_t, struct iovec *, int );
+static int libc_open ( struct dvdcss *, const char * );
+static int libc_seek ( struct dvdcss *, int );
+static int libc_read ( struct dvdcss *, void *, int );
+static int libc_readv ( struct dvdcss *, struct iovec *, int );

#ifdef WIN32
-static int win2k_open ( dvdcss_t, const char * );
-static int win2k_seek ( dvdcss_t, int );
-static int win2k_read ( dvdcss_t, void *, int );
-static int win2k_readv ( dvdcss_t, struct iovec *, int );
+static int win2k_open ( struct dvdcss *, const char * );
+static int win2k_seek ( struct dvdcss *, int );
+static int win2k_read ( struct dvdcss *, void *, int );
+static int win2k_readv ( struct dvdcss *, struct iovec *, int );

#elif defined( __OS2__ )
static int os2_open ( dvdcss_t, const char * );
@@ -96,7 +96,7 @@ static int os2_open ( dvdcss_t, const char * );
# define os2_readv libc_readv
#endif

-int dvdcss_use_ioctls( dvdcss_t dvdcss )
+int dvdcss_use_ioctls( struct dvdcss *dvdcss )
{
#if defined( WIN32 )
if( dvdcss->b_file )
@@ -151,7 +151,7 @@ int dvdcss_use_ioctls( dvdcss_t dvdcss )
#endif
}

-void dvdcss_check_device ( dvdcss_t dvdcss )
+void dvdcss_check_device ( struct dvdcss *dvdcss )
{
#if defined( WIN32 )
DWORD drives;
@@ -341,7 +341,7 @@ void dvdcss_check_device ( dvdcss_t dvdcss )
print_error( dvdcss, "could not find a suitable default drive" );
}

-int dvdcss_open_device ( dvdcss_t dvdcss )
+int dvdcss_open_device ( struct dvdcss *dvdcss )
{
const char *psz_device = dvdcss->psz_device;

@@ -390,7 +390,7 @@ int dvdcss_open_device ( dvdcss_t dvdcss )
}

#ifdef DVDCSS_RAW_OPEN
-int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device )
+int dvdcss_raw_open ( struct dvdcss *dvdcss, const char *psz_device )
{
dvdcss->i_raw_fd = open( psz_device, 0 );

@@ -410,7 +410,7 @@ int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device )
}
#endif /* DVDCSS_RAW_OPEN */

-void dvdcss_close_device ( dvdcss_t dvdcss )
+void dvdcss_close_device ( struct dvdcss *dvdcss )
{
#if defined( WIN32 )
if( dvdcss->b_file )
@@ -444,7 +444,7 @@ void dvdcss_close_device ( dvdcss_t dvdcss )
/*****************************************************************************
* Open commands.
*****************************************************************************/
-static int libc_open ( dvdcss_t dvdcss, const char *psz_device )
+static int libc_open ( struct dvdcss *dvdcss, const char *psz_device )
{
dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, O_BINARY );

@@ -462,7 +462,7 @@ static int libc_open ( dvdcss_t dvdcss, const char *psz_device )
}

#if defined( WIN32 )
-static int win2k_open ( dvdcss_t dvdcss, const char *psz_device )
+static int win2k_open ( struct dvdcss *dvdcss, const char *psz_device )
{
char psz_dvd[7] = "\\\\.\\\0:";
psz_dvd[4] = psz_device[0];
@@ -533,7 +533,7 @@ static int os2_open ( dvdcss_t dvdcss, const char *psz_device )
/*****************************************************************************
* Seek commands.
*****************************************************************************/
-static int libc_seek( dvdcss_t dvdcss, int i_blocks )
+static int libc_seek( struct dvdcss *dvdcss, int i_blocks )
{
off_t i_seek;

@@ -559,7 +559,7 @@ static int libc_seek( dvdcss_t dvdcss, int i_blocks )
}

#if defined( WIN32 )
-static int win2k_seek( dvdcss_t dvdcss, int i_blocks )
+static int win2k_seek( struct dvdcss *dvdcss, int i_blocks )
{
LARGE_INTEGER li_seek;

@@ -590,7 +590,7 @@ static int win2k_seek( dvdcss_t dvdcss, int i_blocks )
/*****************************************************************************
* Read commands.
*****************************************************************************/
-static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
+static int libc_read ( struct dvdcss *dvdcss, void *p_buffer, int i_blocks )
{
off_t i_size, i_ret, i_ret_blocks;

@@ -627,7 +627,7 @@ static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
}

#if defined( WIN32 )
-static int win2k_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
+static int win2k_read ( struct dvdcss *dvdcss, void *p_buffer, int i_blocks )
{
DWORD i_bytes;

@@ -648,7 +648,7 @@ static int win2k_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
/*****************************************************************************
* Readv commands.
*****************************************************************************/
-static int libc_readv ( dvdcss_t dvdcss, struct iovec *p_iovec, int i_blocks )
+static int libc_readv ( struct dvdcss *dvdcss, struct iovec *p_iovec, int i_blocks )
{
#if defined( WIN32 )
int i_index, i_len, i_total = 0;
@@ -721,7 +721,7 @@ static int libc_readv ( dvdcss_t dvdcss, struct iovec *p_iovec, int i_blocks )
/*****************************************************************************
* win2k_readv: vectored read using ReadFile for Win2K
*****************************************************************************/
-static int win2k_readv ( dvdcss_t dvdcss, struct iovec *p_iovec, int i_blocks )
+static int win2k_readv ( struct dvdcss *dvdcss, struct iovec *p_iovec, int i_blocks )
{
int i_index;
int i_blocks_read, i_blocks_total = 0;
diff --git a/src/device.h b/src/device.h
index f56489f..a7ea982 100644
--- a/src/device.h
+++ b/src/device.h
@@ -52,14 +52,14 @@ struct iovec
/*****************************************************************************
* Device reading prototypes
*****************************************************************************/
-int dvdcss_use_ioctls ( dvdcss_t );
-void dvdcss_check_device ( dvdcss_t );
-int dvdcss_open_device ( dvdcss_t );
-void dvdcss_close_device ( dvdcss_t );
+int dvdcss_use_ioctls ( struct dvdcss * );
+void dvdcss_check_device ( struct dvdcss * );
+int dvdcss_open_device ( struct dvdcss * );
+void dvdcss_close_device ( struct dvdcss * );

/*****************************************************************************
* Device reading prototypes, raw-device specific
*****************************************************************************/
-int dvdcss_raw_open ( dvdcss_t, const char * );
+int dvdcss_raw_open ( struct dvdcss *, const char * );

#endif /* DVDCSS_DEVICE_H */
diff --git a/src/dvdcss/dvdcss.h b/src/dvdcss/dvdcss.h
index ea62b8b..f7c6e71 100644
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -36,7 +36,7 @@ extern "C" {
#endif

/** Library instance handle, to be used for each library call. */
-typedef struct dvdcss_s* dvdcss_t;
+typedef struct dvdcss* dvdcss_t;


/** The block size of a DVD. */
@@ -72,22 +72,22 @@ typedef struct dvdcss_s* dvdcss_t;
/*
* Exported prototypes.
*/
-LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target );
-LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t );
-LIBDVDCSS_EXPORT int dvdcss_seek ( dvdcss_t,
+LIBDVDCSS_EXPORT struct dvdcss *dvdcss_open ( const char *psz_target );
+LIBDVDCSS_EXPORT int dvdcss_close ( struct dvdcss * );
+LIBDVDCSS_EXPORT int dvdcss_seek ( struct dvdcss *,
int i_blocks,
int i_flags );
-LIBDVDCSS_EXPORT int dvdcss_read ( dvdcss_t,
+LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *,
void *p_buffer,
int i_blocks,
int i_flags );
-LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t,
+LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *,
void *p_iovec,
int i_blocks,
int i_flags );
-LIBDVDCSS_EXPORT const char *dvdcss_error ( const dvdcss_t );
+LIBDVDCSS_EXPORT const char *dvdcss_error ( const struct dvdcss * );

-LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( dvdcss_t );
+LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( struct dvdcss * );

#ifdef __cplusplus
}
diff --git a/src/error.c b/src/error.c
index 00aee4a..560fb5c 100644
--- a/src/error.c
+++ b/src/error.c
@@ -29,7 +29,7 @@
/*****************************************************************************
* Error messages
*****************************************************************************/
-void print_error( dvdcss_t dvdcss, const char *psz_string )
+void print_error( struct dvdcss *dvdcss, const char *psz_string )
{
if( dvdcss->b_errors )
{
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 00aa4bd..98c18dc 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -145,7 +145,7 @@
#define MANUFACTURING_DATE_LENGTH 16


-static void set_verbosity( dvdcss_t dvdcss )
+static void set_verbosity( struct dvdcss *dvdcss )
{
const char *psz_verbose = getenv( "DVDCSS_VERBOSE" );

@@ -163,7 +163,7 @@ static void set_verbosity( dvdcss_t dvdcss )
}
}

-static int set_access_method( dvdcss_t dvdcss )
+static int set_access_method( struct dvdcss *dvdcss )
{
const char *psz_method = getenv( "DVDCSS_METHOD" );

@@ -191,7 +191,7 @@ static int set_access_method( dvdcss_t dvdcss )
return 0;
}

-static char *set_cache_directory( dvdcss_t dvdcss )
+static char *set_cache_directory( struct dvdcss *dvdcss )
{
char *psz_cache = getenv( "DVDCSS_CACHE" );

@@ -272,7 +272,7 @@ static char *set_cache_directory( dvdcss_t dvdcss )
return psz_cache;
}

-static void init_cache_dir( dvdcss_t dvdcss, const char *psz_cache )
+static void init_cache_dir( struct dvdcss *dvdcss, const char *psz_cache )
{
static const char psz_tag[] =
"Signature: 8a477f597d28d172789f06886806bc55\r\n"
@@ -304,7 +304,7 @@ static void init_cache_dir( dvdcss_t dvdcss, const char *psz_cache )
}
}

-static void create_cache_subdir( dvdcss_t dvdcss, const char *psz_cache )
+static void create_cache_subdir( struct dvdcss *dvdcss, const char *psz_cache )
{
uint8_t p_sector[DVDCSS_BLOCK_SIZE];
char psz_key[STRING_KEY_SIZE + 1];
@@ -420,7 +420,7 @@ static void create_cache_subdir( dvdcss_t dvdcss, const char *psz_cache )
dvdcss->psz_cachefile );
}

-static void init_cache( dvdcss_t dvdcss )
+static void init_cache( struct dvdcss *dvdcss )
{
/* Set CSS key cache directory. */
const char *psz_cache = set_cache_directory( dvdcss );
@@ -450,7 +450,7 @@ static void init_cache( dvdcss_t dvdcss )
* calls. \e libdvdcss checks whether ioctls can be performed on the disc,
* and when possible, the disc key is retrieved.
*/
-LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
+LIBDVDCSS_EXPORT struct dvdcss *dvdcss_open ( const char *psz_target )
{
int i_ret;

@@ -459,7 +459,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
#endif

/* Allocate the library structure. */
- dvdcss_t dvdcss = malloc( sizeof( *dvdcss ) );
+ struct dvdcss *dvdcss = malloc( sizeof( *dvdcss ) );
if( dvdcss == NULL )
{
return NULL;
@@ -562,7 +562,7 @@ error:
* Return a string with the last error message produced by \e libdvdcss.
* Useful to conveniently format error messages in external applications.
*/
-LIBDVDCSS_EXPORT const char * dvdcss_error ( const dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT const char *dvdcss_error ( const struct dvdcss *dvdcss )
{
return dvdcss->psz_error;
}
@@ -590,7 +590,7 @@ LIBDVDCSS_EXPORT const char * dvdcss_error ( const dvdcss_t dvdcss )
* even with the "title" method. This flag is typically used when seeking
* in a new title.
*/
-LIBDVDCSS_EXPORT int dvdcss_seek ( dvdcss_t dvdcss, int i_blocks, int i_flags )
+LIBDVDCSS_EXPORT int dvdcss_seek ( struct dvdcss *dvdcss, int i_blocks, int i_flags )
{
/* title cracking method is too slow to be used at each seek */
if( ( ( i_flags & DVDCSS_SEEK_MPEG )
@@ -630,7 +630,7 @@ LIBDVDCSS_EXPORT int dvdcss_seek ( dvdcss_t dvdcss, int i_blocks, int i_flags )
* \warning dvdcss_read() expects to be able to write \p i_blocks *
* #DVDCSS_BLOCK_SIZE bytes into \p p_buffer.
*/
-LIBDVDCSS_EXPORT int dvdcss_read ( dvdcss_t dvdcss, void *p_buffer,
+LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, void *p_buffer,
int i_blocks,
int i_flags )
{
@@ -704,7 +704,7 @@ LIBDVDCSS_EXPORT int dvdcss_read ( dvdcss_t dvdcss, void *p_buffer,
* Moreover, all iov_len members of the iovec structures should be
* multiples of #DVDCSS_BLOCK_SIZE.
*/
-LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t dvdcss, void *p_iovec,
+LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *dvdcss, void *p_iovec,
int i_blocks,
int i_flags )
{
@@ -761,7 +761,7 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t dvdcss, void *p_iovec,
* Close the DVD device and free all the memory allocated by \e libdvdcss.
* On return, the #dvdcss_t is invalidated and may not be used again.
*/
-LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT int dvdcss_close ( struct dvdcss *dvdcss )
{
struct dvd_title *p_title;

@@ -788,7 +788,7 @@ LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t dvdcss )
* \param dvdcss a \e libdvdcss instance.
* \return 1 if the DVD is scrambled, 0 otherwise.
*/
-LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( struct dvdcss *dvdcss )
{
return dvdcss->b_scrambled;
}
diff --git a/src/libdvdcss.h b/src/libdvdcss.h
index 9750c37..752a764 100644
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -45,7 +45,7 @@ enum dvdcss_method {
/*****************************************************************************
* The libdvdcss structure
*****************************************************************************/
-struct dvdcss_s
+struct dvdcss
{
/* File descriptor */
char * psz_device;
@@ -54,9 +54,9 @@ struct dvdcss_s
int i_pos;

/* File handling */
- int ( * pf_seek ) ( dvdcss_t, int );
- int ( * pf_read ) ( dvdcss_t, void *, int );
- int ( * pf_readv ) ( dvdcss_t, struct iovec *, int );
+ int ( * pf_seek ) ( struct dvdcss *, int );
+ int ( * pf_read ) ( struct dvdcss *, void *, int );
+ int ( * pf_readv ) ( struct dvdcss *, struct iovec *, int );

/* Decryption stuff */
enum dvdcss_method i_method;
@@ -96,6 +96,6 @@ struct dvdcss_s
fprintf( stderr, "\n" ); \
}

-void print_error ( dvdcss_t, const char * );
+void print_error ( struct dvdcss *, const char * );

#endif /* DVDCSS_LIBDVDCSS_H */
diff --git a/test/csstest.c b/test/csstest.c
index d09565a..e0f9651 100644
--- a/test/csstest.c
+++ b/test/csstest.c
@@ -17,7 +17,7 @@ static void dumpsector ( unsigned char * );

int main( int i_argc, char *ppsz_argv[] )
{
- dvdcss_t dvdcss;
+ struct dvdcss *dvdcss;
unsigned char p_data[ DVDCSS_BLOCK_SIZE * 2 ];
unsigned char *p_buffer;
unsigned int i_sector;
diff --git a/test/dvd_region.c b/test/dvd_region.c
index 52fcc9d..53d4693 100644
--- a/test/dvd_region.c
+++ b/test/dvd_region.c
@@ -230,7 +230,7 @@ int main(int argc, char *argv[])
{
char device_name[FILENAME_MAX], c, set, region = 0;
int ret;
- dvdcss_t dvdcss;
+ struct dvdcss *dvdcss;

strcpy(device_name, DEFAULT_DEVICE);
set = 0;
--
1.9.1
Jean-Baptiste Kempf
2014-11-04 19:19:24 UTC
Permalink
I don't think breaking the API is a good idea.
Post by Diego Biurrun
The _t namespace is reserved by POSIX, so dvdcss_t invades the POSIX namespace.
Furthermore typedeffing a pointer to a struct makes declaring the structure as
const harder. Structs as parameters allow for more complete const correctness.
---
Don't like this? Look at the next patch, which this one makes possible.
src/css.c | 33 +++++++++++++++++----------------
src/css.h | 6 +++---
src/device.c | 42 +++++++++++++++++++++---------------------
src/device.h | 10 +++++-----
src/dvdcss/dvdcss.h | 16 ++++++++--------
src/error.c | 2 +-
src/libdvdcss.c | 28 ++++++++++++++--------------
src/libdvdcss.h | 10 +++++-----
test/csstest.c | 2 +-
test/dvd_region.c | 2 +-
10 files changed, 76 insertions(+), 75 deletions(-)
diff --git a/src/css.c b/src/css.c
index f986424..8995de8 100644
--- a/src/css.c
+++ b/src/css.c
@@ -66,29 +66,29 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static void PrintKey ( dvdcss_t, const char *, const uint8_t * );
+static void PrintKey ( struct dvdcss *, const char *, const uint8_t * );
-static int GetBusKey ( dvdcss_t );
-static int GetASF ( dvdcss_t );
+static int GetBusKey ( struct dvdcss * );
+static int GetASF ( struct dvdcss * );
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 ( dvdcss_t, const uint8_t *, dvd_key );
-static int CrackDiscKey ( dvdcss_t, uint8_t * );
+static int DecryptDiscKey ( struct dvdcss *, const uint8_t *, dvd_key );
+static int CrackDiscKey ( struct dvdcss *, uint8_t * );
static void DecryptTitleKey ( dvd_key, dvd_key );
static int RecoverTitleKey ( int, const uint8_t *,
const uint8_t *, const uint8_t *, uint8_t * );
-static int CrackTitleKey ( dvdcss_t, int, int, dvd_key );
+static int CrackTitleKey ( struct dvdcss *, int, int, dvd_key );
static int AttackPattern ( const uint8_t[], uint8_t * );
#if 0
static int AttackPadding ( const uint8_t[] );
#endif
-static int dvdcss_titlekey ( dvdcss_t, int, dvd_key );
+static int dvdcss_titlekey ( struct dvdcss *, int, dvd_key );
/*****************************************************************************
* dvdcss_test: check if the disc is encrypted or not
@@ -101,7 +101,7 @@ static int dvdcss_titlekey ( dvdcss_t, int, dvd_key );
* -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( struct dvdcss *dvdcss )
{
const char *psz_type, *psz_rpc;
int i_ret, i_copyright, i_type, i_mask, i_rpc;
@@ -180,7 +180,7 @@ int dvdcss_test( dvdcss_t dvdcss )
* 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 ( struct dvdcss *dvdcss, int i_block )
{
struct dvd_title *p_title;
struct dvd_title *p_newtitle;
@@ -332,7 +332,7 @@ int dvdcss_title ( dvdcss_t dvdcss, int i_block )
* -disc key hash crack,
* -decryption with player keys if they are available.
*****************************************************************************/
-int dvdcss_disckey( dvdcss_t dvdcss )
+int dvdcss_disckey( struct dvdcss *dvdcss )
{
unsigned char p_buffer[ DVD_DISCKEY_SIZE ];
dvd_key p_disc_key;
@@ -418,7 +418,7 @@ int dvdcss_disckey( dvdcss_t dvdcss )
/*****************************************************************************
* dvdcss_titlekey: get title key.
*****************************************************************************/
-static int dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key p_title_key )
+static int dvdcss_titlekey( struct dvdcss *dvdcss, int i_pos, dvd_key p_title_key )
{
static uint8_t p_garbage[ DVDCSS_BLOCK_SIZE ]; /* we never read it back */
uint8_t p_key[ KEY_SIZE ];
@@ -588,7 +588,7 @@ int dvdcss_unscramble( dvd_key p_key, uint8_t *p_sec )
* that ASF=1 from the start and then later fail with a 'read of scrambled
* block without authentication' error.
*****************************************************************************/
-static int GetBusKey( dvdcss_t dvdcss )
+static int GetBusKey( struct dvdcss *dvdcss )
{
uint8_t p_buffer[10];
uint8_t p_challenge[2*KEY_SIZE];
@@ -740,7 +740,7 @@ static void PrintKey( dvdcss_t dvdcss, const char *prefix, const uint8_t *data )
* 0 if the device needs to be authenticated,
* 1 either.
*****************************************************************************/
-static int GetASF( dvdcss_t dvdcss )
+static int GetASF( struct dvdcss *dvdcss )
{
int i_asf = 0;
@@ -1080,7 +1080,8 @@ 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( dvdcss_t dvdcss, const uint8_t *p_struct_disckey,
+static int DecryptDiscKey( struct dvdcss *dvdcss,
+ const uint8_t *p_struct_disckey,
dvd_key p_disc_key )
{
uint8_t p_verify[KEY_SIZE];
@@ -1149,7 +1150,7 @@ static int investigate( unsigned char *hash, unsigned char *ckey )
return memcmp( key, ckey, KEY_SIZE );
}
-static int CrackDiscKey( dvdcss_t dvdcss, uint8_t *p_disc_key )
+static int CrackDiscKey( 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
@@ -1487,7 +1488,7 @@ static int i_tries = 0, i_success = 0;
* 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
*****************************************************************************/
-static int CrackTitleKey( dvdcss_t dvdcss, int i_pos, int i_len,
+static int CrackTitleKey( struct dvdcss *dvdcss, int i_pos, int i_len,
dvd_key p_titlekey )
{
uint8_t p_buf[ DVDCSS_BLOCK_SIZE ];
diff --git a/src/css.h b/src/css.h
index f576e63..bd6a804 100644
--- a/src/css.h
+++ b/src/css.h
@@ -57,9 +57,9 @@ typedef struct css
/*****************************************************************************
* Prototypes in css.c
*****************************************************************************/
-int dvdcss_test ( dvdcss_t );
-int dvdcss_title ( dvdcss_t, int );
-int dvdcss_disckey ( dvdcss_t );
+int dvdcss_test ( struct dvdcss * );
+int dvdcss_title ( struct dvdcss *, int );
+int dvdcss_disckey ( struct dvdcss * );
int dvdcss_unscramble ( uint8_t *, uint8_t * );
#endif /* DVDCSS_CSS_H */
diff --git a/src/device.c b/src/device.c
index aeafe31..5735d8b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -77,16 +77,16 @@
/*****************************************************************************
* Device reading prototypes
*****************************************************************************/
-static int libc_open ( dvdcss_t, const char * );
-static int libc_seek ( dvdcss_t, int );
-static int libc_read ( dvdcss_t, void *, int );
-static int libc_readv ( dvdcss_t, struct iovec *, int );
+static int libc_open ( struct dvdcss *, const char * );
+static int libc_seek ( struct dvdcss *, int );
+static int libc_read ( struct dvdcss *, void *, int );
+static int libc_readv ( struct dvdcss *, struct iovec *, int );
#ifdef WIN32
-static int win2k_open ( dvdcss_t, const char * );
-static int win2k_seek ( dvdcss_t, int );
-static int win2k_read ( dvdcss_t, void *, int );
-static int win2k_readv ( dvdcss_t, struct iovec *, int );
+static int win2k_open ( struct dvdcss *, const char * );
+static int win2k_seek ( struct dvdcss *, int );
+static int win2k_read ( struct dvdcss *, void *, int );
+static int win2k_readv ( struct dvdcss *, struct iovec *, int );
#elif defined( __OS2__ )
static int os2_open ( dvdcss_t, const char * );
@@ -96,7 +96,7 @@ static int os2_open ( dvdcss_t, const char * );
# define os2_readv libc_readv
#endif
-int dvdcss_use_ioctls( dvdcss_t dvdcss )
+int dvdcss_use_ioctls( struct dvdcss *dvdcss )
{
#if defined( WIN32 )
if( dvdcss->b_file )
@@ -151,7 +151,7 @@ int dvdcss_use_ioctls( dvdcss_t dvdcss )
#endif
}
-void dvdcss_check_device ( dvdcss_t dvdcss )
+void dvdcss_check_device ( struct dvdcss *dvdcss )
{
#if defined( WIN32 )
DWORD drives;
@@ -341,7 +341,7 @@ void dvdcss_check_device ( dvdcss_t dvdcss )
print_error( dvdcss, "could not find a suitable default drive" );
}
-int dvdcss_open_device ( dvdcss_t dvdcss )
+int dvdcss_open_device ( struct dvdcss *dvdcss )
{
const char *psz_device = dvdcss->psz_device;
@@ -390,7 +390,7 @@ int dvdcss_open_device ( dvdcss_t dvdcss )
}
#ifdef DVDCSS_RAW_OPEN
-int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device )
+int dvdcss_raw_open ( struct dvdcss *dvdcss, const char *psz_device )
{
dvdcss->i_raw_fd = open( psz_device, 0 );
@@ -410,7 +410,7 @@ int dvdcss_raw_open ( dvdcss_t dvdcss, const char *psz_device )
}
#endif /* DVDCSS_RAW_OPEN */
-void dvdcss_close_device ( dvdcss_t dvdcss )
+void dvdcss_close_device ( struct dvdcss *dvdcss )
{
#if defined( WIN32 )
if( dvdcss->b_file )
@@ -444,7 +444,7 @@ void dvdcss_close_device ( dvdcss_t dvdcss )
/*****************************************************************************
* Open commands.
*****************************************************************************/
-static int libc_open ( dvdcss_t dvdcss, const char *psz_device )
+static int libc_open ( struct dvdcss *dvdcss, const char *psz_device )
{
dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, O_BINARY );
@@ -462,7 +462,7 @@ static int libc_open ( dvdcss_t dvdcss, const char *psz_device )
}
#if defined( WIN32 )
-static int win2k_open ( dvdcss_t dvdcss, const char *psz_device )
+static int win2k_open ( struct dvdcss *dvdcss, const char *psz_device )
{
char psz_dvd[7] = "\\\\.\\\0:";
psz_dvd[4] = psz_device[0];
@@ -533,7 +533,7 @@ static int os2_open ( dvdcss_t dvdcss, const char *psz_device )
/*****************************************************************************
* Seek commands.
*****************************************************************************/
-static int libc_seek( dvdcss_t dvdcss, int i_blocks )
+static int libc_seek( struct dvdcss *dvdcss, int i_blocks )
{
off_t i_seek;
@@ -559,7 +559,7 @@ static int libc_seek( dvdcss_t dvdcss, int i_blocks )
}
#if defined( WIN32 )
-static int win2k_seek( dvdcss_t dvdcss, int i_blocks )
+static int win2k_seek( struct dvdcss *dvdcss, int i_blocks )
{
LARGE_INTEGER li_seek;
@@ -590,7 +590,7 @@ static int win2k_seek( dvdcss_t dvdcss, int i_blocks )
/*****************************************************************************
* Read commands.
*****************************************************************************/
-static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
+static int libc_read ( struct dvdcss *dvdcss, void *p_buffer, int i_blocks )
{
off_t i_size, i_ret, i_ret_blocks;
@@ -627,7 +627,7 @@ static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
}
#if defined( WIN32 )
-static int win2k_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
+static int win2k_read ( struct dvdcss *dvdcss, void *p_buffer, int i_blocks )
{
DWORD i_bytes;
@@ -648,7 +648,7 @@ static int win2k_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
/*****************************************************************************
* Readv commands.
*****************************************************************************/
-static int libc_readv ( dvdcss_t dvdcss, struct iovec *p_iovec, int i_blocks )
+static int libc_readv ( struct dvdcss *dvdcss, struct iovec *p_iovec, int i_blocks )
{
#if defined( WIN32 )
int i_index, i_len, i_total = 0;
@@ -721,7 +721,7 @@ static int libc_readv ( dvdcss_t dvdcss, struct iovec *p_iovec, int i_blocks )
/*****************************************************************************
* win2k_readv: vectored read using ReadFile for Win2K
*****************************************************************************/
-static int win2k_readv ( dvdcss_t dvdcss, struct iovec *p_iovec, int i_blocks )
+static int win2k_readv ( struct dvdcss *dvdcss, struct iovec *p_iovec, int i_blocks )
{
int i_index;
int i_blocks_read, i_blocks_total = 0;
diff --git a/src/device.h b/src/device.h
index f56489f..a7ea982 100644
--- a/src/device.h
+++ b/src/device.h
@@ -52,14 +52,14 @@ struct iovec
/*****************************************************************************
* Device reading prototypes
*****************************************************************************/
-int dvdcss_use_ioctls ( dvdcss_t );
-void dvdcss_check_device ( dvdcss_t );
-int dvdcss_open_device ( dvdcss_t );
-void dvdcss_close_device ( dvdcss_t );
+int dvdcss_use_ioctls ( struct dvdcss * );
+void dvdcss_check_device ( struct dvdcss * );
+int dvdcss_open_device ( struct dvdcss * );
+void dvdcss_close_device ( struct dvdcss * );
/*****************************************************************************
* Device reading prototypes, raw-device specific
*****************************************************************************/
-int dvdcss_raw_open ( dvdcss_t, const char * );
+int dvdcss_raw_open ( struct dvdcss *, const char * );
#endif /* DVDCSS_DEVICE_H */
diff --git a/src/dvdcss/dvdcss.h b/src/dvdcss/dvdcss.h
index ea62b8b..f7c6e71 100644
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -36,7 +36,7 @@ extern "C" {
#endif
/** Library instance handle, to be used for each library call. */
-typedef struct dvdcss_s* dvdcss_t;
+typedef struct dvdcss* dvdcss_t;
/** The block size of a DVD. */
@@ -72,22 +72,22 @@ typedef struct dvdcss_s* dvdcss_t;
/*
* Exported prototypes.
*/
-LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target );
-LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t );
-LIBDVDCSS_EXPORT int dvdcss_seek ( dvdcss_t,
+LIBDVDCSS_EXPORT struct dvdcss *dvdcss_open ( const char *psz_target );
+LIBDVDCSS_EXPORT int dvdcss_close ( struct dvdcss * );
+LIBDVDCSS_EXPORT int dvdcss_seek ( struct dvdcss *,
int i_blocks,
int i_flags );
-LIBDVDCSS_EXPORT int dvdcss_read ( dvdcss_t,
+LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *,
void *p_buffer,
int i_blocks,
int i_flags );
-LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t,
+LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *,
void *p_iovec,
int i_blocks,
int i_flags );
-LIBDVDCSS_EXPORT const char *dvdcss_error ( const dvdcss_t );
+LIBDVDCSS_EXPORT const char *dvdcss_error ( const struct dvdcss * );
-LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( dvdcss_t );
+LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( struct dvdcss * );
#ifdef __cplusplus
}
diff --git a/src/error.c b/src/error.c
index 00aee4a..560fb5c 100644
--- a/src/error.c
+++ b/src/error.c
@@ -29,7 +29,7 @@
/*****************************************************************************
* Error messages
*****************************************************************************/
-void print_error( dvdcss_t dvdcss, const char *psz_string )
+void print_error( struct dvdcss *dvdcss, const char *psz_string )
{
if( dvdcss->b_errors )
{
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 00aa4bd..98c18dc 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -145,7 +145,7 @@
#define MANUFACTURING_DATE_LENGTH 16
-static void set_verbosity( dvdcss_t dvdcss )
+static void set_verbosity( struct dvdcss *dvdcss )
{
const char *psz_verbose = getenv( "DVDCSS_VERBOSE" );
@@ -163,7 +163,7 @@ static void set_verbosity( dvdcss_t dvdcss )
}
}
-static int set_access_method( dvdcss_t dvdcss )
+static int set_access_method( struct dvdcss *dvdcss )
{
const char *psz_method = getenv( "DVDCSS_METHOD" );
@@ -191,7 +191,7 @@ static int set_access_method( dvdcss_t dvdcss )
return 0;
}
-static char *set_cache_directory( dvdcss_t dvdcss )
+static char *set_cache_directory( struct dvdcss *dvdcss )
{
char *psz_cache = getenv( "DVDCSS_CACHE" );
@@ -272,7 +272,7 @@ static char *set_cache_directory( dvdcss_t dvdcss )
return psz_cache;
}
-static void init_cache_dir( dvdcss_t dvdcss, const char *psz_cache )
+static void init_cache_dir( struct dvdcss *dvdcss, const char *psz_cache )
{
static const char psz_tag[] =
"Signature: 8a477f597d28d172789f06886806bc55\r\n"
@@ -304,7 +304,7 @@ static void init_cache_dir( dvdcss_t dvdcss, const char *psz_cache )
}
}
-static void create_cache_subdir( dvdcss_t dvdcss, const char *psz_cache )
+static void create_cache_subdir( struct dvdcss *dvdcss, const char *psz_cache )
{
uint8_t p_sector[DVDCSS_BLOCK_SIZE];
char psz_key[STRING_KEY_SIZE + 1];
@@ -420,7 +420,7 @@ static void create_cache_subdir( dvdcss_t dvdcss, const char *psz_cache )
dvdcss->psz_cachefile );
}
-static void init_cache( dvdcss_t dvdcss )
+static void init_cache( struct dvdcss *dvdcss )
{
/* Set CSS key cache directory. */
const char *psz_cache = set_cache_directory( dvdcss );
@@ -450,7 +450,7 @@ static void init_cache( dvdcss_t dvdcss )
* calls. \e libdvdcss checks whether ioctls can be performed on the disc,
* and when possible, the disc key is retrieved.
*/
-LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
+LIBDVDCSS_EXPORT struct dvdcss *dvdcss_open ( const char *psz_target )
{
int i_ret;
@@ -459,7 +459,7 @@ LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( const char *psz_target )
#endif
/* Allocate the library structure. */
- dvdcss_t dvdcss = malloc( sizeof( *dvdcss ) );
+ struct dvdcss *dvdcss = malloc( sizeof( *dvdcss ) );
if( dvdcss == NULL )
{
return NULL;
* Return a string with the last error message produced by \e libdvdcss.
* Useful to conveniently format error messages in external applications.
*/
-LIBDVDCSS_EXPORT const char * dvdcss_error ( const dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT const char *dvdcss_error ( const struct dvdcss *dvdcss )
{
return dvdcss->psz_error;
}
@@ -590,7 +590,7 @@ LIBDVDCSS_EXPORT const char * dvdcss_error ( const dvdcss_t dvdcss )
* even with the "title" method. This flag is typically used when seeking
* in a new title.
*/
-LIBDVDCSS_EXPORT int dvdcss_seek ( dvdcss_t dvdcss, int i_blocks, int i_flags )
+LIBDVDCSS_EXPORT int dvdcss_seek ( struct dvdcss *dvdcss, int i_blocks, int i_flags )
{
/* title cracking method is too slow to be used at each seek */
if( ( ( i_flags & DVDCSS_SEEK_MPEG )
@@ -630,7 +630,7 @@ LIBDVDCSS_EXPORT int dvdcss_seek ( dvdcss_t dvdcss, int i_blocks, int i_flags )
* \warning dvdcss_read() expects to be able to write \p i_blocks *
* #DVDCSS_BLOCK_SIZE bytes into \p p_buffer.
*/
-LIBDVDCSS_EXPORT int dvdcss_read ( dvdcss_t dvdcss, void *p_buffer,
+LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, void *p_buffer,
int i_blocks,
int i_flags )
{
@@ -704,7 +704,7 @@ LIBDVDCSS_EXPORT int dvdcss_read ( dvdcss_t dvdcss, void *p_buffer,
* Moreover, all iov_len members of the iovec structures should be
* multiples of #DVDCSS_BLOCK_SIZE.
*/
-LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t dvdcss, void *p_iovec,
+LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *dvdcss, void *p_iovec,
int i_blocks,
int i_flags )
{
@@ -761,7 +761,7 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t dvdcss, void *p_iovec,
* Close the DVD device and free all the memory allocated by \e libdvdcss.
* On return, the #dvdcss_t is invalidated and may not be used again.
*/
-LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT int dvdcss_close ( struct dvdcss *dvdcss )
{
struct dvd_title *p_title;
@@ -788,7 +788,7 @@ LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t dvdcss )
* \param dvdcss a \e libdvdcss instance.
* \return 1 if the DVD is scrambled, 0 otherwise.
*/
-LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( dvdcss_t dvdcss )
+LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( struct dvdcss *dvdcss )
{
return dvdcss->b_scrambled;
}
diff --git a/src/libdvdcss.h b/src/libdvdcss.h
index 9750c37..752a764 100644
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -45,7 +45,7 @@ enum dvdcss_method {
/*****************************************************************************
* The libdvdcss structure
*****************************************************************************/
-struct dvdcss_s
+struct dvdcss
{
/* File descriptor */
char * psz_device;
@@ -54,9 +54,9 @@ struct dvdcss_s
int i_pos;
/* File handling */
- int ( * pf_seek ) ( dvdcss_t, int );
- int ( * pf_read ) ( dvdcss_t, void *, int );
- int ( * pf_readv ) ( dvdcss_t, struct iovec *, int );
+ int ( * pf_seek ) ( struct dvdcss *, int );
+ int ( * pf_read ) ( struct dvdcss *, void *, int );
+ int ( * pf_readv ) ( struct dvdcss *, struct iovec *, int );
/* Decryption stuff */
enum dvdcss_method i_method;
@@ -96,6 +96,6 @@ struct dvdcss_s
fprintf( stderr, "\n" ); \
}
-void print_error ( dvdcss_t, const char * );
+void print_error ( struct dvdcss *, const char * );
#endif /* DVDCSS_LIBDVDCSS_H */
diff --git a/test/csstest.c b/test/csstest.c
index d09565a..e0f9651 100644
--- a/test/csstest.c
+++ b/test/csstest.c
@@ -17,7 +17,7 @@ static void dumpsector ( unsigned char * );
int main( int i_argc, char *ppsz_argv[] )
{
- dvdcss_t dvdcss;
+ struct dvdcss *dvdcss;
unsigned char p_data[ DVDCSS_BLOCK_SIZE * 2 ];
unsigned char *p_buffer;
unsigned int i_sector;
diff --git a/test/dvd_region.c b/test/dvd_region.c
index 52fcc9d..53d4693 100644
--- a/test/dvd_region.c
+++ b/test/dvd_region.c
@@ -230,7 +230,7 @@ int main(int argc, char *argv[])
{
char device_name[FILENAME_MAX], c, set, region = 0;
int ret;
- dvdcss_t dvdcss;
+ struct dvdcss *dvdcss;
strcpy(device_name, DEFAULT_DEVICE);
set = 0;
--
1.9.1
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Diego Biurrun
2014-11-05 11:11:59 UTC
Permalink
Post by Jean-Baptiste Kempf
I don't think breaking the API is a good idea.
I don't think it breaks API as the dvdcss_t typedef is left in place.
Yeah, it should go away eventually, but for now it is not removed.

Diego
Diego Biurrun
2014-11-04 19:15:04 UTC
Permalink
---
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
Jean-Baptiste Kempf
2014-11-04 19:25:00 UTC
Permalink
Same question about ABI
Post by Diego Biurrun
---
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
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Diego Elio Pettenò
2014-11-04 21:13:55 UTC
Permalink
Accepting const rather than non-const is fine API/ABI wise. I don't
see any return doing the same change so it's fine.
Diego Elio Pettenò — Flameeyes
Post by Jean-Baptiste Kempf
Same question about ABI
Post by Diego Biurrun
---
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
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
Jean-Baptiste Kempf
2014-11-05 10:34:56 UTC
Permalink
Ship it, then, but I prefer having the dvdcss typedef than the struct*.
Post by Diego Elio Pettenò
Accepting const rather than non-const is fine API/ABI wise. I don't
see any return doing the same change so it's fine.
Diego Elio Pettenò — Flameeyes
Post by Jean-Baptiste Kempf
Same question about ABI
Post by Diego Biurrun
---
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
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Diego Biurrun
2014-11-05 11:13:22 UTC
Permalink
Not sure what exactly you mean by "the dvdcss typedef" here...
Post by Jean-Baptiste Kempf
Ship it, then, but I prefer having the dvdcss typedef than the struct*.
Post by Diego Elio Pettenò
Accepting const rather than non-const is fine API/ABI wise. I don't
see any return doing the same change so it's fine.
Diego Elio Pettenò — Flameeyes
Post by Jean-Baptiste Kempf
Same question about ABI
Post by Diego Biurrun
---
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
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
Diego Biurrun
2014-11-04 19:15:06 UTC
Permalink
---

unsigned char might also work.

src/dvdcss/dvdcss.h | 4 +++-
src/libdvdcss.c | 18 ++++++++----------
2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/dvdcss/dvdcss.h b/src/dvdcss/dvdcss.h
index db418fc..4cf86a6 100644
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -35,6 +35,8 @@
extern "C" {
#endif

+#include <stdint.h>
+
/** Library instance handle, to be used for each library call. */
typedef struct dvdcss* dvdcss_t;

@@ -79,7 +81,7 @@ LIBDVDCSS_EXPORT int dvdcss_seek ( struct dvdcss *,
int i_blocks,
int i_flags );
LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *,
- void *p_buffer,
+ uint8_t *p_buffer,
int i_blocks,
int i_flags );
LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *,
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index a72dffb..9e10095 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -630,14 +630,12 @@ LIBDVDCSS_EXPORT int dvdcss_seek ( struct dvdcss *dvdcss, int i_blocks, int i_fl
* \warning dvdcss_read() expects to be able to write \p i_blocks *
* #DVDCSS_BLOCK_SIZE bytes into \p p_buffer.
*/
-LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, void *p_buffer,
- int i_blocks,
- int i_flags )
+LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, uint8_t *p_buffer,
+ int i_blocks, int i_flags )
{
- uint8_t *_p_buffer = p_buffer;
int i_ret, i_index;

- i_ret = dvdcss->pf_read( dvdcss, _p_buffer, i_blocks );
+ i_ret = dvdcss->pf_read( dvdcss, p_buffer, i_blocks );

if( i_ret <= 0
|| !dvdcss->b_scrambled
@@ -652,14 +650,14 @@ LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, void *p_buffer,
* check that there are no encrypted blocks */
for( i_index = i_ret; i_index; i_index-- )
{
- if( _p_buffer[0x14] & 0x30 )
+ if( p_buffer[0x14] & 0x30 )
{
print_error( dvdcss, "no key but found encrypted block" );
/* Only return the initial range of unscrambled blocks? */
/* or fail completely? return 0; */
break;
}
- _p_buffer = _p_buffer + DVDCSS_BLOCK_SIZE;
+ p_buffer = p_buffer + DVDCSS_BLOCK_SIZE;
}
}
else
@@ -667,9 +665,9 @@ LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, void *p_buffer,
/* 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 );
- _p_buffer[0x14] &= 0x8f;
- _p_buffer = _p_buffer + DVDCSS_BLOCK_SIZE;
+ dvdcss_unscramble( dvdcss->css.p_title_key, p_buffer );
+ p_buffer[0x14] &= 0x8f;
+ p_buffer = p_buffer + DVDCSS_BLOCK_SIZE;
}
}
--
1.9.1
Diego Biurrun
2014-11-04 19:15:05 UTC
Permalink
---

The new callback API should get a similar treatment.

src/dvdcss/dvdcss.h | 3 ++-
src/libdvdcss.c | 19 +++++++++----------
2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/dvdcss/dvdcss.h b/src/dvdcss/dvdcss.h
index a86b57c..db418fc 100644
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -69,6 +69,7 @@ typedef struct dvdcss* dvdcss_t;
#endif


+struct iovec;
/*
* Exported prototypes.
*/
@@ -82,7 +83,7 @@ LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *,
int i_blocks,
int i_flags );
LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *,
- void *p_iovec,
+ struct iovec *p_iovec,
int i_blocks,
int i_flags );
LIBDVDCSS_EXPORT const char *dvdcss_error ( const struct dvdcss * );
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 6f5d3af..a72dffb 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -704,16 +704,15 @@ LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, void *p_buffer,
* Moreover, all iov_len members of the iovec structures should be
* multiples of #DVDCSS_BLOCK_SIZE.
*/
-LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *dvdcss, void *p_iovec,
- int i_blocks,
- int i_flags )
+LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *dvdcss,
+ struct iovec *p_iovec,
+ int i_blocks, int i_flags )
{
- struct iovec *_p_iovec = p_iovec;
int i_ret, i_index;
void *iov_base;
size_t iov_len;

- i_ret = dvdcss->pf_readv( dvdcss, _p_iovec, i_blocks );
+ i_ret = dvdcss->pf_readv( dvdcss, p_iovec, i_blocks );

if( i_ret <= 0
|| !dvdcss->b_scrambled
@@ -723,8 +722,8 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *dvdcss, void *p_iovec,
}

/* Initialize loop for decryption */
- iov_base = _p_iovec->iov_base;
- iov_len = _p_iovec->iov_len;
+ iov_base = p_iovec->iov_base;
+ iov_len = p_iovec->iov_len;

/* Decrypt the blocks we managed to read */
for( i_index = i_ret; i_index; i_index-- )
@@ -737,9 +736,9 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *dvdcss, void *p_iovec,

while( iov_len == 0 )
{
- _p_iovec++;
- iov_base = _p_iovec->iov_base;
- iov_len = _p_iovec->iov_len;
+ p_iovec++;
+ iov_base = p_iovec->iov_base;
+ iov_len = p_iovec->iov_len;
}

dvdcss_unscramble( dvdcss->css.p_title_key, iov_base );
--
1.9.1
Jean-Baptiste Kempf
2014-11-05 10:37:07 UTC
Permalink
Wouldn't that break a lot the applications?
Post by Diego Biurrun
---
The new callback API should get a similar treatment.
src/dvdcss/dvdcss.h | 3 ++-
src/libdvdcss.c | 19 +++++++++----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/dvdcss/dvdcss.h b/src/dvdcss/dvdcss.h
index a86b57c..db418fc 100644
--- a/src/dvdcss/dvdcss.h
+++ b/src/dvdcss/dvdcss.h
@@ -69,6 +69,7 @@ typedef struct dvdcss* dvdcss_t;
#endif
+struct iovec;
/*
* Exported prototypes.
*/
@@ -82,7 +83,7 @@ LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *,
int i_blocks,
int i_flags );
LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *,
- void *p_iovec,
+ struct iovec *p_iovec,
int i_blocks,
int i_flags );
LIBDVDCSS_EXPORT const char *dvdcss_error ( const struct dvdcss * );
diff --git a/src/libdvdcss.c b/src/libdvdcss.c
index 6f5d3af..a72dffb 100644
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -704,16 +704,15 @@ LIBDVDCSS_EXPORT int dvdcss_read ( struct dvdcss *dvdcss, void *p_buffer,
* Moreover, all iov_len members of the iovec structures should be
* multiples of #DVDCSS_BLOCK_SIZE.
*/
-LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *dvdcss, void *p_iovec,
- int i_blocks,
- int i_flags )
+LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *dvdcss,
+ struct iovec *p_iovec,
+ int i_blocks, int i_flags )
{
- struct iovec *_p_iovec = p_iovec;
int i_ret, i_index;
void *iov_base;
size_t iov_len;
- i_ret = dvdcss->pf_readv( dvdcss, _p_iovec, i_blocks );
+ i_ret = dvdcss->pf_readv( dvdcss, p_iovec, i_blocks );
if( i_ret <= 0
|| !dvdcss->b_scrambled
@@ -723,8 +722,8 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *dvdcss, void *p_iovec,
}
/* Initialize loop for decryption */
- iov_base = _p_iovec->iov_base;
- iov_len = _p_iovec->iov_len;
+ iov_base = p_iovec->iov_base;
+ iov_len = p_iovec->iov_len;
/* Decrypt the blocks we managed to read */
for( i_index = i_ret; i_index; i_index-- )
@@ -737,9 +736,9 @@ LIBDVDCSS_EXPORT int dvdcss_readv ( struct dvdcss *dvdcss, void *p_iovec,
while( iov_len == 0 )
{
- _p_iovec++;
- iov_base = _p_iovec->iov_base;
- iov_len = _p_iovec->iov_len;
+ p_iovec++;
+ iov_base = p_iovec->iov_base;
+ iov_len = p_iovec->iov_len;
}
dvdcss_unscramble( dvdcss->css.p_title_key, iov_base );
--
1.9.1
_______________________________________________
libdvdcss-devel mailing list
https://mailman.videolan.org/listinfo/libdvdcss-devel
--
With my kindest regards,
--
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device
Diego Biurrun
2014-11-05 11:02:14 UTC
Permalink
libdvdcss | branch: master | Diego Biurrun <***@biurrun.de> | Wed Nov 5 11:17:44 2014 +0100| [cfa35f3035f5b090711e2b1115c031c7668855ca] | committer: Diego Biurrun

Adjust NEWS file to reflect changes since 1.3.0 release.
http://git.videolan.org/gitweb.cgi/libdvdcss.git/?a=commit;h=cfa35f3035f5b090711e2b1115c031c7668855ca
---

NEWS | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 72a6092..ef617b5 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+Changes since 1.3.0:
+--------------------
+ * Drop support for HP-UX.
+ * Drop support for Windows 9x.
+ Windows NT 4.0 SP4 with IE 5.0 is now required.
+ * Replace BeOS support by Haiku support.
+ * Miscellaneous cleanups to code, documentation, build system.
+
+
Changes between 1.2.13 and 1.3.0:
---------------------------------

@@ -5,10 +14,9 @@ Changes between 1.2.13 and 1.3.0:
- the function dvdcss_title()
- the type dvdcss_handle
- the variable dvdcss_interface_2
+ * Drop support for Windows 98 and Windows NT 4.0.
+ Windows 98 SE with IE 5.0 and Windows NT 4.0 SP4 with IE 5.0 are required.
* Support for Android
- * Drop support for HP-UX, Windows 9x, and Windows NT 4.0.
- Windows NT 4.0 SP4 with IE 5.0 is now required.
- * Replace BeOS support by Haiku support.


Changes between 1.2.12 and 1.2.13:
Loading...