ref: d2edf451feb3e8762c4895665bc356f5f9bb12a9
parent: f5c2c0ffec64c0c04085e2f33e08ce1b29e17869
author: Sam Hocevar <sam@videolan.org>
date: Thu Dec 5 05:24:42 EST 2002
* ./src/libdvdcss.c: fixed Win32 mkdir() call. * ALL: removed trailing spaces in files. * ALL: moved everything to C99 integer types.
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,7 @@
AC_C_INLINE
AC_TYPE_SIZE_T
-AC_CHECK_HEADERS(unistd.h)
+AC_CHECK_HEADERS(unistd.h sys/param.h)
dnl
dnl Check the operating system
@@ -24,6 +24,9 @@
case x"${target_os}" in
xdarwin*)
CFLAGS="${CFLAGS} -no-cpp-precomp"
+ ;;
+ x*cygwin*)
+ AC_DEFINE(SYS_CYGWIN, 1, Have a BeOS system.)
;;
xbeos*)
AC_DEFINE(SYS_BEOS, 1, Have a BeOS system.)
--- a/src/common.h
+++ b/src/common.h
@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: common.h,v 1.2 2002/08/09 14:10:43 sam Exp $
+ * $Id: common.h,v 1.3 2002/12/05 10:24:42 sam Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
@@ -13,7 +13,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -27,14 +27,22 @@
/*****************************************************************************
* Basic types definitions
*****************************************************************************/
-
-/* Basic types definitions */
-typedef unsigned char u8;
-typedef signed char s8;
-typedef unsigned int u32;
-typedef signed int s32;
-
-typedef u8 byte_t;
+#if defined( HAVE_STDINT_H )
+# include <stdint.h>
+#elif defined( HAVE_INTTYPES_H )
+# include <inttypes.h>
+#elif defined( SYS_CYGWIN )
+# include <sys/types.h>
+ /* Cygwin only defines half of these... */
+ typedef u_int8_t uint8_t;
+ typedef u_int32_t uint32_t;
+#else
+ /* Fallback types (very x86-centric, sorry) */
+ typedef unsigned char uint8_t;
+ typedef signed char int8_t;
+ typedef unsigned int uint32_t;
+ typedef signed int int32_t;
+#endif
#if defined( WIN32 )
--- a/src/css.c
+++ b/src/css.c
@@ -2,7 +2,7 @@
* css.c: Functions for DVD authentication and descrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: css.c,v 1.20 2002/11/24 17:34:23 sam Exp $
+ * $Id: css.c,v 1.21 2002/12/05 10:24:42 sam Exp $
*
* Author: St�phane Borel <stef@via.ecp.fr>
* H�kan Hjort <d95hjort@dtek.chalmers.se>
@@ -14,7 +14,7 @@
* - DeCSSPlus by Ethan Hawke
* - DecVOB
* see http://www.lemuria.org/DeCSS/ by Tom Vogt for more information.
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -40,7 +40,9 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/param.h>
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
#include <fcntl.h>
#include "dvdcss/dvdcss.h"
@@ -58,19 +60,21 @@
static int GetBusKey ( dvdcss_t );
static int GetASF ( dvdcss_t );
-static void CryptKey ( int, int, u8 const *, u8 * );
-static void DecryptKey ( u8, u8 const *, u8 const *, u8 * );
+static void CryptKey ( int, int, uint8_t const *, uint8_t * );
+static void DecryptKey ( uint8_t,
+ uint8_t const *, uint8_t const *, uint8_t * );
-static int DecryptDiscKey ( u8 const *, dvd_key_t );
-static int CrackDiscKey ( dvdcss_t, u8 * );
+static int DecryptDiscKey ( uint8_t const *, dvd_key_t );
+static int CrackDiscKey ( dvdcss_t, uint8_t * );
static void DecryptTitleKey ( dvd_key_t, dvd_key_t );
-static int RecoverTitleKey ( int, u8 const *, u8 const *, u8 const *, u8 * );
+static int RecoverTitleKey ( int, uint8_t const *,
+ uint8_t const *, uint8_t const *, uint8_t * );
static int CrackTitleKey ( dvdcss_t, int, int, dvd_key_t );
-static int AttackPattern ( u8 const[], int, u8 * );
+static int AttackPattern ( uint8_t const[], int, uint8_t * );
#if 0
-static int AttackPadding ( u8 const[], int, u8 * );
+static int AttackPadding ( uint8_t const[], int, uint8_t * );
#endif
/*****************************************************************************
@@ -117,17 +121,17 @@
* and stops when a session key (called bus key) has been established.
* Always do the full auth sequence. Some drives seem to lie and always
* respond with ASF=1. For instance the old DVD roms on Compaq Armada says
- * that ASF=1 from the start and then later fail with a 'read of scrambled
+ * 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 )
{
- u8 p_buffer[10];
- u8 p_challenge[2*KEY_SIZE];
+ 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;
- u8 i_variant = 0;
+ uint8_t i_variant = 0;
char psz_warning[80];
int i_ret = -1;
int i;
@@ -135,7 +139,7 @@
_dvdcss_debug( dvdcss, "requesting AGID" );
i_ret = ioctl_ReportAgid( dvdcss->i_fd, &dvdcss->css.i_agid );
- /* We might have to reset hung authentication processes in the drive
+ /* We might have to reset hung authentication processes in the drive
by invalidating the corresponding AGID'. As long as we haven't got
an AGID, invalidate one (in sequence) and try again. */
for( i = 0; i_ret == -1 && i < 4 ; ++i )
@@ -218,7 +222,7 @@
}
/* Get challenge from LU */
- if( ioctl_ReportChallenge( dvdcss->i_fd,
+ if( ioctl_ReportChallenge( dvdcss->i_fd,
&dvdcss->css.i_agid, p_buffer ) < 0 )
{
_dvdcss_error( dvdcss, "ioctl ReportKeyChallenge failed" );
@@ -260,9 +264,9 @@
}
/*****************************************************************************
- * PrintKey : debug function that dumps a key value
+ * PrintKey : debug function that dumps a key value
*****************************************************************************/
-static void PrintKey( dvdcss_t dvdcss, char *prefix, u8 const *data )
+static void PrintKey( dvdcss_t dvdcss, char *prefix, uint8_t const *data )
{
char psz_output[80];
@@ -395,7 +399,7 @@
* _dvdcss_disckey: get disc key.
*****************************************************************************
* This function should only be called if DVD ioctls are present.
- * It will set dvdcss->i_method = DVDCSS_METHOD_TITLE if it fails to find
+ * It will set dvdcss->i_method = DVDCSS_METHOD_TITLE if it fails to find
* a valid disc key.
* Two decryption methods are offered:
* -disc key hash crack,
@@ -422,7 +426,7 @@
/* This should have invaidated the AGID and got us ASF=1. */
if( GetASF( dvdcss ) != 1 )
{
- /* Region mismatch (or region not set) is the most likely source. */
+ /* Region mismatch (or region not set) is the most likely source. */
_dvdcss_error( dvdcss,
"ASF not 1 after reading disc key (region mismatch?)" );
ioctl_InvalidateAgid( dvdcss->i_fd, &dvdcss->css.i_agid );
@@ -488,11 +492,11 @@
*****************************************************************************/
int _dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key_t p_title_key )
{
- static u8 p_garbage[ 2048 ]; /* static because we never read it */
- u8 p_key[KEY_SIZE];
+ static uint8_t p_garbage[ 2048 ]; /* static because we never read it */
+ uint8_t p_key[ KEY_SIZE ];
int i, i_ret = 0;
- if( dvdcss->b_ioctls && ( dvdcss->i_method == DVDCSS_METHOD_KEY ||
+ if( dvdcss->b_ioctls && ( dvdcss->i_method == DVDCSS_METHOD_KEY ||
dvdcss->i_method == DVDCSS_METHOD_DISC ) )
{
/* We have a decrypted Disc key and the ioctls are available,
@@ -527,7 +531,7 @@
break;
case 0:
- /* This might either be a title that has no key,
+ /* This might either be a title that has no key,
* or we encountered a region error. */
_dvdcss_debug( dvdcss, "lost ASF reqesting title key" );
break;
@@ -601,10 +605,10 @@
* sec : sector to unscramble
* key : title key for this sector
*****************************************************************************/
-int _dvdcss_unscramble( dvd_key_t p_key, u8 *p_sec )
+int _dvdcss_unscramble( dvd_key_t p_key, uint8_t *p_sec )
{
unsigned int i_t1, i_t2, i_t3, i_t4, i_t5, i_t6;
- u8 *p_end = p_sec + 0x800;
+ uint8_t *p_end = p_sec + 0x800;
/* PES_scrambling_control */
if( p_sec[0x14] & 0x30)
@@ -680,16 +684,16 @@
* i_variant : between 0 and 31.
*****************************************************************************/
static void CryptKey( int i_key_type, int i_variant,
- u8 const *p_challenge, u8 *p_key )
+ uint8_t const *p_challenge, uint8_t *p_key )
{
/* Permutation table for challenge */
- u8 pp_perm_challenge[3][10] =
+ uint8_t pp_perm_challenge[3][10] =
{ { 1, 3, 0, 7, 5, 2, 9, 6, 4, 8 },
{ 6, 1, 9, 3, 8, 5, 7, 4, 0, 2 },
{ 4, 0, 3, 5, 7, 2, 8, 6, 1, 9 } };
/* Permutation table for variant table for key2 and buskey */
- u8 pp_perm_variant[2][32] =
+ uint8_t pp_perm_variant[2][32] =
{ { 0x0a, 0x08, 0x0e, 0x0c, 0x0b, 0x09, 0x0f, 0x0d,
0x1a, 0x18, 0x1e, 0x1c, 0x1b, 0x19, 0x1f, 0x1d,
0x02, 0x00, 0x06, 0x04, 0x03, 0x01, 0x07, 0x05,
@@ -699,7 +703,7 @@
0x13, 0x1b, 0x17, 0x1f, 0x03, 0x0b, 0x07, 0x0f,
0x11, 0x19, 0x15, 0x1d, 0x01, 0x09, 0x05, 0x0d } };
- u8 p_variants[32] =
+ uint8_t p_variants[32] =
{ 0xB7, 0x74, 0x85, 0xD0, 0xCC, 0xDB, 0xCA, 0x73,
0x03, 0xFE, 0x31, 0x03, 0x52, 0xE0, 0xB7, 0x42,
0x63, 0x16, 0xF2, 0x2A, 0x79, 0x52, 0xFF, 0x1B,
@@ -706,17 +710,17 @@
0x7A, 0x11, 0xCA, 0x1A, 0x9B, 0x40, 0xAD, 0x01 };
/* The "secret" key */
- u8 p_secret[5] = { 0x55, 0xD6, 0xC4, 0xC5, 0x28 };
+ uint8_t p_secret[5] = { 0x55, 0xD6, 0xC4, 0xC5, 0x28 };
- u8 p_bits[30], p_scratch[10], p_tmp1[5], p_tmp2[5];
- u8 i_lfsr0_o; /* 1 bit used */
- u8 i_lfsr1_o; /* 1 bit used */
- u32 i_lfsr0, i_lfsr1;
- u8 i_css_variant, i_cse, i_index, i_combined, i_carry;
- u8 i_val = 0;
- int i_term = 0;
- int i_bit;
- int i;
+ uint8_t p_bits[30], p_scratch[10], p_tmp1[5], p_tmp2[5];
+ uint8_t i_lfsr0_o; /* 1 bit used */
+ uint8_t i_lfsr1_o; /* 1 bit used */
+ uint8_t i_css_variant, i_cse, i_index, i_combined, i_carry;
+ uint8_t i_val = 0;
+ uint32_t i_lfsr0, i_lfsr1;
+ int i_term = 0;
+ int i_bit;
+ int i;
for (i = 9; i >= 0; --i)
p_scratch[i] = p_challenge[pp_perm_challenge[i_key_type][i]];
@@ -874,25 +878,25 @@
/*****************************************************************************
* DecryptKey: decrypt p_crypted with p_key.
*****************************************************************************
- * Used to decrypt the disc key, with a player key, after requesting it
- * in _dvdcss_disckey and to decrypt title keys, with a disc key, requested
+ * Used to decrypt the disc key, with a player key, after requesting it
+ * in _dvdcss_disckey and to decrypt title keys, with a disc key, requested
* in _dvdcss_titlekey.
- * The player keys and the resulting disc key are only used as KEKs
+ * The player keys and the resulting disc key are only used as KEKs
* (key encryption keys).
* Decryption is slightly dependant on the type of key:
* -for disc key, invert is 0x00,
- * -for title key, invert if 0xff.
+ * -for title key, invert if 0xff.
*****************************************************************************/
-static void DecryptKey( u8 invert, u8 const *p_key,
- u8 const *p_crypted, u8 *p_result )
+static void DecryptKey( uint8_t invert, uint8_t const *p_key,
+ uint8_t const *p_crypted, uint8_t *p_result )
{
unsigned int i_lfsr1_lo;
unsigned int i_lfsr1_hi;
unsigned int i_lfsr0;
unsigned int i_combined;
- u8 o_lfsr0;
- u8 o_lfsr1;
- u8 k[5];
+ uint8_t o_lfsr0;
+ uint8_t o_lfsr1;
+ uint8_t k[5];
int i;
i_lfsr1_lo = p_key[0] | 0x100;
@@ -947,12 +951,13 @@
* p_struct_disckey: the 2048 byte DVD_STRUCT_DISCKEY data
* p_disc_key: result, the 5 byte disc key
*****************************************************************************/
-static int DecryptDiscKey( u8 const *p_struct_disckey, dvd_key_t p_disc_key )
+static int DecryptDiscKey( uint8_t const *p_struct_disckey,
+ dvd_key_t p_disc_key )
{
- u8 p_verify[KEY_SIZE];
+ uint8_t p_verify[KEY_SIZE];
int i, n = 0;
- static const dvd_key_t player_keys[] =
+ static const dvd_key_t player_keys[] =
{
{ 0x01, 0xaf, 0xe3, 0x12, 0x80 },
{ 0x12, 0x11, 0xca, 0x04, 0x3b },
@@ -996,8 +1001,8 @@
DecryptKey( 0, player_keys[n], p_struct_disckey + 5 * i,
p_disc_key );
- /* The first part in the struct_disckey block is the
- * 'disc key' encrypted with it self. Using this we
+ /* The first part in the struct_disckey block is the
+ * 'disc key' encrypted with it self. Using this we
* can check if we decrypted the correct key. */
DecryptKey( 0, p_disc_key, p_struct_disckey, p_verify );
@@ -1010,7 +1015,7 @@
n++;
}
- /* Have tried all combinations of positions and keys,
+ /* Have tried all combinations of positions and keys,
* and we still didn't succeed. */
memset( p_disc_key, 0, KEY_SIZE );
return -1;
@@ -1032,7 +1037,7 @@
* CrackDiscKey: brute force disc key
* CSS hash reversal function designed by Frank Stevenson
*****************************************************************************
- * This function uses a big amount of memory to crack the disc key from the
+ * This function uses a big amount of memory to crack the disc key from the
* disc key hash, if player keys are not available.
*****************************************************************************/
#define K1TABLEWIDTH 10
@@ -1049,7 +1054,7 @@
return memcmp( key, ckey, KEY_SIZE );
}
-static int CrackDiscKey( dvdcss_t dvdcss, u8 *p_disc_key )
+static int CrackDiscKey( dvdcss_t 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
@@ -1067,7 +1072,7 @@
unsigned int nTry; /* iterator for K[1] possibilities */
unsigned int nPossibleK1; /* #of possible K[1] values */
unsigned char* K1table; /* Lookup table for possible K[1] */
- unsigned int* BigTable; /* LFSR2 startstate indexed by
+ unsigned int* BigTable; /* LFSR2 startstate indexed by
* 1,2,5 output byte */
_dvdcss_debug( dvdcss, "cracking disc key" );
@@ -1246,11 +1251,11 @@
* Called from Attack* which are in turn called by CrackTitleKey. Given
* a guessed(?) plain text and the chiper text. Returns -1 on failure.
*****************************************************************************/
-static int RecoverTitleKey( int i_start, u8 const *p_crypted,
- u8 const *p_decrypted,
- u8 const *p_sector_seed, u8 *p_key )
+static int RecoverTitleKey( int i_start, uint8_t const *p_crypted,
+ uint8_t const *p_decrypted,
+ uint8_t const *p_sector_seed, uint8_t *p_key )
{
- u8 p_buffer[10];
+ uint8_t p_buffer[10];
unsigned int i_t1, i_t2, i_t3, i_t4, i_t5, i_t6;
unsigned int i_try;
unsigned int i_candidate;
@@ -1377,7 +1382,7 @@
* The data of the PES packet begins at 0x15 (if there isn't any PTS/DTS)
* or at 0x?? if there are both PTS and DTS's.
* The seed value used with the unscrambling key is the 5 bytes at 0x54-0x58.
- * The scrabled part of a sector begins at 0x80.
+ * The scrabled part of a sector begins at 0x80.
*****************************************************************************/
/* Statistics */
@@ -1391,15 +1396,15 @@
* 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( dvdcss_t dvdcss, int i_pos, int i_len,
dvd_key_t p_titlekey )
{
- u8 p_buf[0x800];
- const u8 p_packstart[4] = { 0x00, 0x00, 0x01, 0xba };
- int i_reads = 0;
- int i_encrypted = 0;
- int b_stop_scanning = 0;
- int i_ret;
+ uint8_t p_buf[0x800];
+ const uint8_t p_packstart[4] = { 0x00, 0x00, 0x01, 0xba };
+ int i_reads = 0;
+ int i_encrypted = 0;
+ int b_stop_scanning = 0;
+ int i_ret;
_dvdcss_debug( dvdcss, "cracking title key" );
@@ -1416,7 +1421,7 @@
}
i_ret = dvdcss_read( dvdcss, p_buf, 1, DVDCSS_NOFLAGS );
-
+
/* Either we are at the end of the physical device or the auth
* have failed / were not done and we got a read error. */
if( i_ret <= 0 )
@@ -1428,7 +1433,7 @@
break;
}
- /* Stop when we find a non MPEG stream block.
+ /* Stop when we find a non MPEG stream block.
* (We must have reached the end of the stream).
* For now, allow all blocks that begin with a start code. */
if( memcmp( p_buf, p_packstart, 3 ) )
@@ -1438,12 +1443,12 @@
}
if( p_buf[0x0d] & 0x07 )
- _dvdcss_debug( dvdcss, "stuffing in pack header" );
+ _dvdcss_debug( dvdcss, "stuffing in pack header" );
/* PES_scrambling_control does not exist in a system_header,
* a padding_stream or a private_stream2 (and others?). */
- if( p_buf[0x14] & 0x30 && ! ( p_buf[0x11] == 0xbb
- || p_buf[0x11] == 0xbe
+ if( p_buf[0x14] & 0x30 && ! ( p_buf[0x11] == 0xbb
+ || p_buf[0x11] == 0xbe
|| p_buf[0x11] == 0xbf ) )
{
i_encrypted++;
@@ -1465,7 +1470,7 @@
i_reads++;
/* Emit a progress indication now and then. */
- if( !( i_reads & 0xfff ) )
+ if( !( i_reads & 0xfff ) )
{
_dvdcss_debug( dvdcss, "still cracking..." );
}
@@ -1480,8 +1485,8 @@
{ /* Print some statistics. */
char psz_info[128];
- snprintf( psz_info, sizeof(psz_info),
- "%d of %d attempts successful, %d of %d blocks scrambled",
+ snprintf( psz_info, sizeof(psz_info),
+ "%d of %d attempts successful, %d of %d blocks scrambled",
i_success, i_tries, i_encrypted, i_reads );
_dvdcss_debug( dvdcss, psz_info );
}
@@ -1505,13 +1510,14 @@
/******************************************************************************
- * The original Ethan Hawke (DeCSSPlus) attack (modified).
+ * The original Ethan Hawke (DeCSSPlus) attack (modified).
******************************************************************************
* Tries to find a repeating pattern just before the encrypted part starts.
* Then it guesses that the plain text for first encrypted bytes are
* a contiuation of that pattern.
*****************************************************************************/
-static int AttackPattern( u8 const p_sec[0x800], int i_pos, u8 *p_key )
+static int AttackPattern( uint8_t const p_sec[0x800],
+ int i_pos, uint8_t *p_key )
{
unsigned int i_best_plen = 0;
unsigned int i_best_p = 0;
@@ -1552,7 +1558,7 @@
{
fprintf( stderr, "key is %02x:%02x:%02x:%02x:%02x ",
p_key[0], p_key[1], p_key[2], p_key[3], p_key[4] );
- fprintf( stderr, "at block %5d pattern len %3d period %3d %s\n",
+ fprintf( stderr, "at block %5d pattern len %3d period %3d %s\n",
i_pos, i_best_plen, i_best_p, (res>=0?"y":"n") );
}
#endif
@@ -1570,13 +1576,14 @@
* DVD specifies that there must only be one type of data in every sector.
* Every sector is one pack and so must obviously be 2048 bytes long.
* For the last pice of video data before a VOBU boundary there might not
- * be exactly the right amount of data to fill a sector. They one has to
+ * be exactly the right amount of data to fill a sector. They one has to
* pad the pack to 2048 bytes. For just a few bytes this is doen in the
- * header but for any large amount you insert a PES packet from the
+ * header but for any large amount you insert a PES packet from the
* Padding stream. This looks like 0x00 00 01 be xx xx ff ff ...
* where xx xx is the length of the padding stream.
*****************************************************************************/
-static int AttackPadding( u8 const p_sec[0x800], int i_pos, u8 *p_key )
+static int AttackPadding( uint8_t const p_sec[0x800],
+ int i_pos, uint8_t *p_key )
{
unsigned int i_pes_length;
/*static int i_tries = 0, i_success = 0;*/
@@ -1586,7 +1593,7 @@
/* Coverd by the test below but usfull for debuging. */
if( i_pes_length == 0x800 - 0x14 ) return 0;
- /* There must be room for at least 4? bytes of padding stream,
+ /* There must be room for at least 4? bytes of padding stream,
* and it must be encrypted.
* sector size - pack/pes header - padding startcode - padding length */
if( ( 0x800 - 0x14 - 4 - 2 - i_pes_length < 4 ) ||
@@ -1593,8 +1600,8 @@
( p_sec[0x14 + i_pes_length + 0] == 0x00 &&
p_sec[0x14 + i_pes_length + 1] == 0x00 &&
p_sec[0x14 + i_pes_length + 2] == 0x01 ) )
- {
- fprintf( stderr, "plain %d %02x:%02x:%02x:%02x (type %02x sub %02x)\n",
+ {
+ fprintf( stderr, "plain %d %02x:%02x:%02x:%02x (type %02x sub %02x)\n",
0x800 - 0x14 - 4 - 2 - i_pes_length,
p_sec[0x14 + i_pes_length + 0],
p_sec[0x14 + i_pes_length + 1],
@@ -1605,16 +1612,16 @@
}
/* If we are here we know that there is a where in the pack a
- encrypted PES header is (startcode + lenght). It's never more
- than two packets in the pack, so we 'know' the length. The
- plaintext at offset (0x14 + i_pes_length) will then be
- 00 00 01 e0/bd/be xx xx, in the case of be the following bytes
+ encrypted PES header is (startcode + lenght). It's never more
+ than two packets in the pack, so we 'know' the length. The
+ plaintext at offset (0x14 + i_pes_length) will then be
+ 00 00 01 e0/bd/be xx xx, in the case of be the following bytes
are also known. */
/* An encrypted SPU PES packet with another encrypted PES packet following.
Normaly if the following was a padding stream that would be in plain
text. So it will be another SPU PES packet. */
- if( p_sec[0x11] == 0xbd &&
+ if( p_sec[0x11] == 0xbd &&
p_sec[0x17 + p_sec[0x16]] >= 0x20 &&
p_sec[0x17 + p_sec[0x16]] <= 0x3f )
{
@@ -1625,16 +1632,16 @@
* No reason execpt for time stamps to break the data into two packets.
* So it's likely that the following PES packet is a padding stream. */
if( p_sec[0x11] == 0xe0 )
- {
+ {
i_tries++;
}
-
+
if( 1 )
{
/*fprintf( stderr, "key is %02x:%02x:%02x:%02x:%02x ",
p_key[0], p_key[1], p_key[2], p_key[3], p_key[4] );*/
fprintf( stderr, "at block %5d padding len %4d "
- "type %02x sub %02x\n", i_pos, i_pes_length,
+ "type %02x sub %02x\n", i_pos, i_pes_length,
p_sec[0x11], p_sec[0x17 + p_sec[0x16]]);
}
--- a/src/css.h
+++ b/src/css.h
@@ -2,7 +2,7 @@
* css.h: Structures for DVD authentication and unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: css.h,v 1.7 2002/08/10 14:27:26 sam Exp $
+ * $Id: css.h,v 1.8 2002/12/05 10:24:42 sam Exp $
*
* Author: St�phane Borel <stef@via.ecp.fr>
*
@@ -28,7 +28,7 @@
*****************************************************************************/
#define KEY_SIZE 5
-typedef u8 dvd_key_t[KEY_SIZE];
+typedef uint8_t dvd_key_t[KEY_SIZE];
typedef struct dvd_title_s
{
@@ -52,5 +52,5 @@
int _dvdcss_title ( dvdcss_t, int );
int _dvdcss_disckey ( dvdcss_t );
int _dvdcss_titlekey ( dvdcss_t, int , dvd_key_t );
-int _dvdcss_unscramble ( u8 *, u8 * );
+int _dvdcss_unscramble ( uint8_t *, uint8_t * );
--- a/src/csstables.h
+++ b/src/csstables.h
@@ -2,7 +2,7 @@
* csstables.h: CSS Tables for DVD unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: csstables.h,v 1.1 2001/12/22 00:08:13 sam Exp $
+ * $Id: csstables.h,v 1.2 2002/12/05 10:24:42 sam Exp $
*
* Author: St�phane Borel <stef@via.ecp.fr>
*
@@ -13,7 +13,7 @@
* - DeCSSPlus by Ethan Hawke
* - DecVOB
* see http://www.lemuria.org/DeCSS/ by Tom Vogt for more information.
- *
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -30,7 +30,7 @@
*****************************************************************************/
-static u8 p_css_tab1[ 256 ] =
+static uint8_t p_css_tab1[ 256 ] =
{
0x33, 0x73, 0x3b, 0x26, 0x63, 0x23, 0x6b, 0x76,
0x3e, 0x7e, 0x36, 0x2b, 0x6e, 0x2e, 0x66, 0x7b,
@@ -66,7 +66,7 @@
0xba, 0xfa, 0xb2, 0xaf, 0xea, 0xaa, 0xe2, 0xff
};
-static u8 p_css_tab2[ 256 ] =
+static uint8_t p_css_tab2[ 256 ] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x09, 0x08, 0x0b, 0x0a, 0x0d, 0x0c, 0x0f, 0x0e,
@@ -102,7 +102,7 @@
0xe4, 0xe5, 0xe6, 0xe7, 0xe0, 0xe1, 0xe2, 0xe3
};
-static u8 p_css_tab3[ 512 ] =
+static uint8_t p_css_tab3[ 512 ] =
{
0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff,
0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff,
@@ -170,7 +170,7 @@
0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff
};
-static u8 p_css_tab4[ 256 ] =
+static uint8_t p_css_tab4[ 256 ] =
{
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
@@ -206,7 +206,7 @@
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
-static u8 p_css_tab5[ 256 ] =
+static uint8_t p_css_tab5[ 256 ] =
{
0xff, 0x7f, 0xbf, 0x3f, 0xdf, 0x5f, 0x9f, 0x1f,
0xef, 0x6f, 0xaf, 0x2f, 0xcf, 0x4f, 0x8f, 0x0f,
@@ -242,7 +242,7 @@
0xe0, 0x60, 0xa0, 0x20, 0xc0, 0x40, 0x80, 0x00
};
-static u8 p_crypt_tab0[ 256 ] =
+static uint8_t p_crypt_tab0[ 256 ] =
{
0xB7, 0xF4, 0x82, 0x57, 0xDA, 0x4D, 0xDB, 0xE2,
0x2F, 0x52, 0x1A, 0xA8, 0x68, 0x5A, 0x8A, 0xFF,
@@ -278,7 +278,7 @@
0xAD, 0x94, 0x77, 0x04, 0x9A, 0x39, 0xCF, 0x7C
};
-static u8 p_crypt_tab1[ 256 ] =
+static uint8_t p_crypt_tab1[ 256 ] =
{
0x8C, 0x47, 0xB0, 0xE1, 0xEB, 0xFC, 0xEB, 0x56,
0x10, 0xE5, 0x2C, 0x1A, 0x5D, 0xEF, 0xBE, 0x4F,
@@ -314,7 +314,7 @@
0xAA, 0x1B, 0x79, 0x8E, 0x97, 0xB4, 0xC3, 0xF4
};
-static u8 p_crypt_tab2[ 256 ] =
+static uint8_t p_crypt_tab2[ 256 ] =
{
0xB7, 0x75, 0x81, 0xD5, 0xDC, 0xCA, 0xDE, 0x66,
0x23, 0xDF, 0x15, 0x26, 0x62, 0xD1, 0x83, 0x77,
@@ -347,10 +347,10 @@
0x4B, 0x3B, 0x03, 0xBB, 0x1C, 0x2A, 0xAC, 0x0C,
0x3F, 0x93, 0xC7, 0x72, 0x7A, 0x09, 0x22, 0x3D,
0x45, 0x78, 0xA9, 0xA8, 0xEA, 0xC9, 0x6A, 0xF7,
- 0x29, 0x91, 0xF0, 0x02, 0x18, 0x3A, 0x4E, 0x7C
+ 0x29, 0x91, 0xF0, 0x02, 0x18, 0x3A, 0x4E, 0x7C
};
-static u8 p_crypt_tab3[ 288 ] =
+static uint8_t p_crypt_tab3[ 288 ] =
{
0x73, 0x51, 0x95, 0xE1, 0x12, 0xE4, 0xC0, 0x58,
0xEE, 0xF2, 0x08, 0x1B, 0xA9, 0xFA, 0x98, 0x4C,
--- a/src/device.c
+++ b/src/device.c
@@ -2,7 +2,7 @@
* device.h: DVD device access
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: device.c,v 1.7 2002/11/24 17:34:23 sam Exp $
+ * $Id: device.c,v 1.8 2002/12/05 10:24:42 sam Exp $
*
* Authors: St�phane Borel <stef@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
@@ -12,7 +12,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -33,7 +33,9 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/param.h>
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
@@ -100,22 +102,22 @@
{
return 1; /* What to do? Be conservative and try to use the ioctls */
}
-
- /* Complete this list and check that we test for the right things
+
+ /* Complete this list and check that we test for the right things
* (I've assumed for all OSs that 'r', (raw) device, are char devices
* and those that don't contain/use an 'r' in the name are block devices)
*
* Linux needs a block device
* Solaris needs a char device
- * Darwin needs a char device
+ * Darwin needs a char device
* OpenBSD needs a char device
* NetBSD needs a char device
* FreeBSD can use either the block or the char device
* BSD/OS can use either the block or the char device
*/
-
+
/* Check if this is a block/char device */
- if( S_ISBLK( fileinfo.st_mode ) ||
+ if( S_ISBLK( fileinfo.st_mode ) ||
S_ISCHR( fileinfo.st_mode ) )
{
return 1;
@@ -298,7 +300,7 @@
long (*lpGetSupport)( void );
long (*lpSendCommand)( void* );
char c_drive = psz_device[0];
-
+
/* load aspi and init w32_aspidev structure */
hASPI = LoadLibrary( "wnaspi32.dll" );
if( hASPI == NULL )
@@ -309,7 +311,7 @@
(FARPROC) lpGetSupport = GetProcAddress( hASPI, "GetASPI32SupportInfo" );
(FARPROC) lpSendCommand = GetProcAddress( hASPI, "SendASPI32Command" );
-
+
if(lpGetSupport == NULL || lpSendCommand == NULL )
{
_dvdcss_error( dvdcss, "unable to get aspi function pointers" );
@@ -459,7 +461,7 @@
int i_old_blocks;
char sz_buf[ DVDCSS_BLOCK_SIZE ];
struct w32_aspidev *fd = (struct w32_aspidev *) dvdcss->i_fd;
-
+
i_old_blocks = fd->i_blocks;
fd->i_blocks = i_blocks;
@@ -481,7 +483,7 @@
static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
{
int i_ret;
- /* TODO: partial reads are wrong,i.e 2200/2048 = 1
+ /* TODO: partial reads are wrong,i.e 2200/2048 = 1
* but the location has advanced 2200 bytes (lseek possition that is) */
i_ret = read( dvdcss->i_read_fd, p_buffer,
(off_t)i_blocks * DVDCSS_BLOCK_SIZE );
@@ -595,7 +597,7 @@
for( i_index = i_blocks; i_index; i_index-- )
{
- i_blocks_total += p_iovec[i_index-1].iov_len;
+ i_blocks_total += p_iovec[i_index-1].iov_len;
}
if( i_blocks_total <= 0 ) return 0;
@@ -640,7 +642,7 @@
* garbage, this isn't an issue as we return the number of
* blocks actually read */
i_blocks_total -= ( p_iovec[i_index].iov_len / DVDCSS_BLOCK_SIZE );
- }
+ }
return i_blocks_read;
}
@@ -665,17 +667,17 @@
ssc.SRB_HaId = LOBYTE( fd->i_sid );
ssc.SRB_Target = HIBYTE( fd->i_sid );
ssc.SRB_SenseLen = SENSE_LEN;
-
+
ssc.SRB_PostProc = (LPVOID) hEvent;
ssc.SRB_BufPointer = p_data;
ssc.SRB_CDBLen = 12;
-
+
ssc.CDBByte[0] = 0xA8; /* RAW */
ssc.CDBByte[2] = (UCHAR) (fd->i_blocks >> 24);
ssc.CDBByte[3] = (UCHAR) (fd->i_blocks >> 16) & 0xff;
ssc.CDBByte[4] = (UCHAR) (fd->i_blocks >> 8) & 0xff;
ssc.CDBByte[5] = (UCHAR) (fd->i_blocks) & 0xff;
-
+
/* We have to break down the reads into 64kb pieces (ASPI restriction) */
if( i_blocks > 32 )
{
@@ -683,14 +685,15 @@
ssc.CDBByte[9] = 32;
fd->i_blocks += 32;
- /* Initiate transfer */
+ /* Initiate transfer */
ResetEvent( hEvent );
fd->lpSendCommand( (void*) &ssc );
/* transfer the next 64kb (aspi_read_internal is called recursively)
* We need to check the status of the read on return */
- if( aspi_read_internal( i_fd, (u8*) p_data + 32 * DVDCSS_BLOCK_SIZE,
- i_blocks - 32) < 0 )
+ if( aspi_read_internal( i_fd,
+ (uint8_t*) p_data + 32 * DVDCSS_BLOCK_SIZE,
+ i_blocks - 32) < 0 )
{
return -1;
}
@@ -702,7 +705,7 @@
ssc.CDBByte[9] = (UCHAR) i_blocks;
fd->i_blocks += i_blocks;
- /* Initiate transfer */
+ /* Initiate transfer */
ResetEvent( hEvent );
fd->lpSendCommand( (void*) &ssc );
--- a/src/device.h
+++ b/src/device.h
@@ -2,7 +2,7 @@
* device.h: DVD device access
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: device.h,v 1.5 2002/12/02 07:38:21 jlj Exp $
+ * $Id: device.h,v 1.6 2002/12/05 10:24:42 sam Exp $
*
* Authors: St�phane Borel <stef@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
@@ -12,7 +12,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- a/src/error.c
+++ b/src/error.c
@@ -2,7 +2,7 @@
* error.c: error management functions
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: error.c,v 1.3 2002/11/24 17:34:23 sam Exp $
+ * $Id: error.c,v 1.4 2002/12/05 10:24:42 sam Exp $
*
* Author: Samuel Hocevar <sam@zoy.org>
*
@@ -10,7 +10,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -24,7 +24,9 @@
#include "config.h"
#include <stdio.h>
-#include <sys/param.h>
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
#include "dvdcss/dvdcss.h"
--- a/src/ioctl.c
+++ b/src/ioctl.c
@@ -2,7 +2,7 @@
* ioctl.c: DVD ioctl replacement function
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: ioctl.c,v 1.21 2002/11/25 18:44:31 jlj Exp $
+ * $Id: ioctl.c,v 1.22 2002/12/05 10:24:42 sam Exp $
*
* Authors: Markus Kuespert <ltlBeBoy@beosmail.com>
* Samuel Hocevar <sam@zoy.org>
@@ -188,7 +188,7 @@
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, 8 );
-
+
rs_cdb.cdb_opaque[ 6 ] = i_layer;
rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_COPYRIGHT;
@@ -197,7 +197,7 @@
if( i_ret < 0 || sc.uscsi_status ) {
i_ret = -1;
}
-
+
*pi_copyright = p_buffer[ 4 ];
/* s->copyright.rmi = p_buffer[ 5 ]; */
@@ -214,9 +214,9 @@
#elif defined( WIN32 )
if( WIN2K ) /* NT/2k/XP */
{
- INIT_SPTD( GPCMD_READ_DVD_STRUCTURE, 8 );
+ INIT_SPTD( GPCMD_READ_DVD_STRUCTURE, 8 );
- /* When using IOCTL_DVD_READ_STRUCTURE and
+ /* When using IOCTL_DVD_READ_STRUCTURE and
DVD_COPYRIGHT_DESCRIPTOR, CopyrightProtectionType
seems to be always 6 ???
To work around this MS bug we try to send a raw scsi command
@@ -277,7 +277,7 @@
/*****************************************************************************
* ioctl_ReadDiscKey: get the disc key
*****************************************************************************/
-int ioctl_ReadDiscKey( int i_fd, int *pi_agid, u8 *p_key )
+int ioctl_ReadDiscKey( int i_fd, int *pi_agid, uint8_t *p_key )
{
int i_ret;
@@ -320,7 +320,7 @@
rdc.command[ 7 ] = DVD_STRUCT_DISCKEY;
rdc.command[ 10 ] = *pi_agid << 6;
-
+
i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) );
if( i_ret < 0 )
@@ -335,7 +335,7 @@
sctl_io.cdb[ 7 ] = DVD_STRUCT_DISCKEY;
sctl_io.cdb[ 10 ] = *pi_agid << 6;
-
+
i_ret = ioctl( i_fd, SIOC_IO, &sctl_io );
if( i_ret < 0 )
@@ -347,12 +347,12 @@
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 );
-
+
rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_DISCKEY;
rs_cdb.cdb_opaque[ 10 ] = *pi_agid << 6;
-
+
i_ret = ioctl( i_fd, USCSICMD, &sc );
-
+
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
@@ -364,7 +364,7 @@
#elif defined( DARWIN_DVD_IOCTL )
INIT_DVDIOCTL( dk_dvd_read_structure_t, DVDDiscKeyInfo,
kDVDStructureFormatDiscKeyInfo );
-
+
dvd.grantID = *pi_agid;
i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd );
@@ -375,7 +375,7 @@
if( WIN2K ) /* NT/2k/XP */
{
DWORD tmp;
- u8 buffer[DVD_DISK_KEY_LENGTH];
+ uint8_t buffer[DVD_DISK_KEY_LENGTH];
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
memset( &buffer, 0, sizeof( buffer ) );
@@ -385,11 +385,11 @@
key->KeyType = DvdDiskKey;
key->KeyFlags = 0;
- i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
+ i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
if( i_ret < 0 )
- {
+ {
return i_ret;
}
@@ -401,7 +401,7 @@
ssc.CDBByte[ 7 ] = DVD_STRUCT_DISCKEY;
ssc.CDBByte[ 10 ] = *pi_agid << 6;
-
+
i_ret = WinSendSSC( i_fd, &ssc );
if( i_ret < 0 )
@@ -428,7 +428,7 @@
sdc.command[ 7 ] = DVD_STRUCT_DISCKEY;
sdc.command[ 10 ] = *pi_agid << 6;
-
+
i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD,
&sdc, sizeof(sdc), &ulParamLen,
p_buffer, sizeof(p_buffer), &ulDataLen);
@@ -450,7 +450,7 @@
/*****************************************************************************
* ioctl_ReadTitleKey: get the title key
*****************************************************************************/
-int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, u8 *p_key )
+int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, uint8_t *p_key )
{
int i_ret;
@@ -506,15 +506,15 @@
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 12 );
-
+
rs_cdb.cdb_opaque[ 2 ] = ( i_pos >> 24 ) & 0xff;
rs_cdb.cdb_opaque[ 3 ] = ( i_pos >> 16 ) & 0xff;
rs_cdb.cdb_opaque[ 4 ] = ( i_pos >> 8 ) & 0xff;
rs_cdb.cdb_opaque[ 5 ] = ( i_pos ) & 0xff;
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6);
-
+
i_ret = ioctl( i_fd, USCSICMD, &sc );
-
+
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
@@ -524,9 +524,9 @@
/* a->lstk.cpm = (buf[ 4 ] >> 7) & 1; */
/* a->lstk.cp_sec = (buf[ 4 ] >> 6) & 1; */
/* a->lstk.cgms = (buf[ 4 ] >> 4) & 3; */
-
- memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
-
+
+ memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE );
+
#elif defined( DARWIN_DVD_IOCTL )
INIT_DVDIOCTL( dk_dvd_report_key_t, DVDTitleKeyInfo,
kDVDKeyFormatTitleKey );
@@ -543,7 +543,7 @@
if( WIN2K ) /* NT/2k/XP */
{
DWORD tmp;
- u8 buffer[DVD_TITLE_KEY_LENGTH];
+ uint8_t buffer[DVD_TITLE_KEY_LENGTH];
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
memset( &buffer, 0, sizeof( buffer ) );
@@ -555,7 +555,7 @@
key->Parameters.TitleOffset.QuadPart = (LONGLONG) i_pos *
2048 /*DVDCSS_BLOCK_SIZE*/;
- i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
+ i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
memcpy( p_key, key->KeyData, DVD_KEY_SIZE );
@@ -662,11 +662,11 @@
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 8 );
-
+
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6);
-
+
i_ret = ioctl( i_fd, USCSICMD, &sc );
-
+
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
@@ -673,11 +673,11 @@
}
*pi_agid = p_buffer[ 7 ] >> 6;
-
+
#elif defined( DARWIN_DVD_IOCTL )
INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationGrantIDInfo,
kDVDKeyFormatAGID_CSS );
-
+
dvd.grantID = *pi_agid;
dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
@@ -691,7 +691,7 @@
ULONG id;
DWORD tmp;
- i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION,
+ i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION,
&tmp, 4, &id, sizeof( id ), &tmp, NULL ) ? 0 : -1;
*pi_agid = id;
@@ -738,7 +738,7 @@
/*****************************************************************************
* ioctl_ReportChallenge: get challenge from the drive
*****************************************************************************/
-int ioctl_ReportChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
+int ioctl_ReportChallenge( int i_fd, int *pi_agid, uint8_t *p_challenge )
{
int i_ret;
@@ -784,11 +784,11 @@
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 16 );
-
+
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6);
-
+
i_ret = ioctl( i_fd, USCSICMD, &sc );
-
+
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
@@ -795,11 +795,11 @@
}
memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE );
-
+
#elif defined( DARWIN_DVD_IOCTL )
INIT_DVDIOCTL( dk_dvd_report_key_t, DVDChallengeKeyInfo,
kDVDKeyFormatChallengeKey );
-
+
dvd.grantID = *pi_agid;
i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
@@ -810,7 +810,7 @@
if( WIN2K ) /* NT/2k/XP */
{
DWORD tmp;
- u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
+ uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH];
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
memset( &buffer, 0, sizeof( buffer ) );
@@ -820,7 +820,7 @@
key->KeyType = DvdChallengeKey;
key->KeyFlags = 0;
- i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
+ i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
if( i_ret < 0 )
@@ -918,11 +918,11 @@
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 8 );
-
+
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF;
-
+
i_ret = ioctl( i_fd, USCSICMD, &sc );
-
+
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
@@ -929,11 +929,11 @@
}
*pi_asf = p_buffer[ 7 ] & 1;
-
+
#elif defined( DARWIN_DVD_IOCTL )
INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationSuccessFlagInfo,
kDVDKeyFormatASF );
-
+
i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
*pi_asf = dvdbs.successFlag;
@@ -942,7 +942,7 @@
if( WIN2K ) /* NT/2k/XP */
{
DWORD tmp;
- u8 buffer[DVD_ASF_LENGTH];
+ uint8_t buffer[DVD_ASF_LENGTH];
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
memset( &buffer, 0, sizeof( buffer ) );
@@ -953,7 +953,7 @@
((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf;
- i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
+ i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
if( i_ret < 0 )
@@ -1005,7 +1005,7 @@
/*****************************************************************************
* ioctl_ReportKey1: get the first key from the drive
*****************************************************************************/
-int ioctl_ReportKey1( int i_fd, int *pi_agid, u8 *p_key )
+int ioctl_ReportKey1( int i_fd, int *pi_agid, uint8_t *p_key )
{
int i_ret;
@@ -1051,11 +1051,11 @@
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 12 );
-
+
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6);
-
+
i_ret = ioctl( i_fd, USCSICMD, &sc );
-
+
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
@@ -1062,13 +1062,13 @@
}
memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE );
-
+
#elif defined( DARWIN_DVD_IOCTL )
INIT_DVDIOCTL( dk_dvd_report_key_t, DVDKey1Info,
kDVDKeyFormatKey1 );
-
+
dvd.grantID = *pi_agid;
-
+
i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd );
memcpy( p_key, dvdbs.key1Value, DVD_KEY_SIZE );
@@ -1077,7 +1077,7 @@
if( WIN2K ) /* NT/2k/XP */
{
DWORD tmp;
- u8 buffer[DVD_BUS_KEY_LENGTH];
+ uint8_t buffer[DVD_BUS_KEY_LENGTH];
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
memset( &buffer, 0, sizeof( buffer ) );
@@ -1087,7 +1087,7 @@
key->KeyType = DvdBusKey1;
key->KeyFlags = 0;
- i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
+ i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
memcpy( p_key, key->KeyData, DVD_KEY_SIZE );
@@ -1172,11 +1172,11 @@
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 0 );
-
+
rs_cdb.cdb_opaque[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6);
-
+
i_ret = ioctl( i_fd, USCSICMD, &sc );
-
+
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
@@ -1185,9 +1185,9 @@
#elif defined( DARWIN_DVD_IOCTL )
INIT_DVDIOCTL( dk_dvd_send_key_t, DVDAuthenticationGrantIDInfo,
kDVDKeyFormatAGID_Invalidate );
-
+
dvd.grantID = *pi_agid;
-
+
i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd );
#elif defined( WIN32 )
@@ -1195,7 +1195,7 @@
{
DWORD tmp;
- i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_END_SESSION,
+ i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_END_SESSION,
pi_agid, sizeof( *pi_agid ), NULL, 0, &tmp, NULL ) ? 0 : -1;
}
else
@@ -1245,7 +1245,7 @@
/*****************************************************************************
* ioctl_SendChallenge: send challenge to the drive
*****************************************************************************/
-int ioctl_SendChallenge( int i_fd, int *pi_agid, u8 *p_challenge )
+int ioctl_SendChallenge( int i_fd, int *pi_agid, uint8_t *p_challenge )
{
int i_ret;
@@ -1293,12 +1293,12 @@
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_SEND_KEY, 16 );
-
+
rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6);
-
+
p_buffer[ 1 ] = 0xe;
memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE );
-
+
if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
{
return -1;
@@ -1305,11 +1305,11 @@
}
return 0;
-
+
#elif defined( DARWIN_DVD_IOCTL )
INIT_DVDIOCTL( dk_dvd_send_key_t, DVDChallengeKeyInfo,
kDVDKeyFormatChallengeKey );
-
+
dvd.grantID = *pi_agid;
dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM;
@@ -1322,7 +1322,7 @@
if( WIN2K ) /* NT/2k/XP */
{
DWORD tmp;
- u8 buffer[DVD_CHALLENGE_KEY_LENGTH];
+ uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH];
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
memset( &buffer, 0, sizeof( buffer ) );
@@ -1334,7 +1334,7 @@
memcpy( key->KeyData, p_challenge, DVD_CHALLENGE_SIZE );
- return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
+ return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
}
else
@@ -1382,7 +1382,7 @@
/*****************************************************************************
* ioctl_SendKey2: send the second key to the drive
*****************************************************************************/
-int ioctl_SendKey2( int i_fd, int *pi_agid, u8 *p_key )
+int ioctl_SendKey2( int i_fd, int *pi_agid, uint8_t *p_key )
{
int i_ret;
@@ -1430,12 +1430,12 @@
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_SEND_KEY, 12 );
-
+
rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6);
-
+
p_buffer[ 1 ] = 0xa;
memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE );
-
+
if( ioctl( i_fd, USCSICMD, &sc ) < 0 || sc.uscsi_status )
{
return -1;
@@ -1442,7 +1442,7 @@
}
return 0;
-
+
#elif defined( DARWIN_DVD_IOCTL )
INIT_DVDIOCTL( dk_dvd_send_key_t, DVDKey2Info,
kDVDKeyFormatKey2 );
@@ -1459,7 +1459,7 @@
if( WIN2K ) /* NT/2k/XP */
{
DWORD tmp;
- u8 buffer[DVD_BUS_KEY_LENGTH];
+ uint8_t buffer[DVD_BUS_KEY_LENGTH];
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
memset( &buffer, 0, sizeof( buffer ) );
@@ -1471,7 +1471,7 @@
memcpy( key->KeyData, p_key, DVD_KEY_SIZE );
- return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
+ return DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
}
else
@@ -1575,20 +1575,20 @@
#elif defined( SOLARIS_USCSI )
INIT_USCSI( GPCMD_REPORT_KEY, 8 );
-
+
rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_RPC;
-
+
i_ret = ioctl( i_fd, USCSICMD, &sc );
-
+
if( i_ret < 0 || sc.uscsi_status )
{
i_ret = -1;
}
-
+
*p_type = p_buffer[ 4 ] >> 6;
*p_mask = p_buffer[ 5 ];
*p_scheme = p_buffer[ 6 ];
-
+
#elif defined( DARWIN_DVD_IOCTL )
INIT_DVDIOCTL( dk_dvd_report_key_t, DVDRegionPlaybackControlInfo,
kDVDKeyFormatRegionState );
@@ -1605,7 +1605,7 @@
if( WIN2K ) /* NT/2k/XP */
{
DWORD tmp;
- u8 buffer[DVD_RPC_KEY_LENGTH];
+ uint8_t buffer[DVD_RPC_KEY_LENGTH];
PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer;
memset( &buffer, 0, sizeof( buffer ) );
@@ -1614,7 +1614,7 @@
key->KeyType = DvdGetRpcKey;
key->KeyFlags = 0;
- i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
+ i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key,
key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
if( i_ret < 0 )
@@ -1724,7 +1724,7 @@
INIT_USCSI( GPCMD_SEND_KEY, 8 );
rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_RPC;
-
+
p_buffer[ 1 ] = 6;
p_buffer[ 4 ] = i_pdrc;
@@ -1734,7 +1734,7 @@
{
i_ret = -1;
}
-
+
#elif defined( DARWIN_DVD_IOCTL )
INIT_DVDIOCTL( dk_dvd_send_key_t, DVDRegionPlaybackControlInfo,
kDVDKeyFormatSetRegion );
@@ -1761,7 +1761,7 @@
INIT_SSC( GPCMD_SEND_KEY, 8 );
ssc.CDBByte[ 10 ] = DVD_SEND_RPC;
-
+
p_buffer[ 1 ] = 6;
p_buffer[ 4 ] = i_pdrc;
@@ -1773,7 +1773,7 @@
INIT_CPT( GPCMD_SEND_KEY, 8 );
p_cpt->cam_cdb[ 10 ] = DVD_SEND_RPC;
-
+
p_buffer[ 1 ] = 6;
p_buffer[ 4 ] = i_pdrc;
@@ -1783,7 +1783,7 @@
INIT_SSC( GPCMD_SEND_KEY, 8 );
sdc.command[ 10 ] = DVD_SEND_RPC;
-
+
p_buffer[ 1 ] = 6;
p_buffer[ 4 ] = i_pdrc;
@@ -1870,15 +1870,15 @@
/*****************************************************************************
* SolarisInitUSCSI: initialize a USCSICMD structure for the Solaris kernel
*****************************************************************************
- * This function initializes a Solaris userspace scsi command structure for
+ * This function initializes a Solaris userspace scsi command structure for
* future use, either a read command or a write command.
*****************************************************************************/
static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type )
-{
+{
union scsi_cdb *rs_cdb;
memset( p_sc->uscsi_cdb, 0, sizeof( union scsi_cdb ) );
memset( p_sc->uscsi_bufaddr, 0, p_sc->uscsi_buflen );
-
+
switch( i_type )
{
case GPCMD_SEND_KEY:
@@ -1890,9 +1890,9 @@
p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_READ;
break;
}
-
+
rs_cdb = (union scsi_cdb *)p_sc->uscsi_cdb;
-
+
rs_cdb->scc_cmd = i_type;
rs_cdb->cdb_opaque[ 8 ] = (p_sc->uscsi_buflen >> 8) & 0xff;
@@ -1927,8 +1927,8 @@
}
p_sptd->Cdb[ 0 ] = i_type;
- p_sptd->Cdb[ 8 ] = (u8)(p_sptd->DataTransferLength >> 8) & 0xff;
- p_sptd->Cdb[ 9 ] = (u8) p_sptd->DataTransferLength & 0xff;
+ p_sptd->Cdb[ 8 ] = (uint8_t)(p_sptd->DataTransferLength >> 8) & 0xff;
+ p_sptd->Cdb[ 9 ] = (uint8_t) p_sptd->DataTransferLength & 0xff;
p_sptd->CdbLength = 12;
p_sptd->TimeOutValue = 2;
@@ -1961,8 +1961,8 @@
p_ssc->CDBByte[ 0 ] = i_type;
- p_ssc->CDBByte[ 8 ] = (u8)(p_ssc->SRB_BufLen >> 8) & 0xff;
- p_ssc->CDBByte[ 9 ] = (u8) p_ssc->SRB_BufLen & 0xff;
+ p_ssc->CDBByte[ 8 ] = (uint8_t)(p_ssc->SRB_BufLen >> 8) & 0xff;
+ p_ssc->CDBByte[ 9 ] = (uint8_t) p_ssc->SRB_BufLen & 0xff;
p_ssc->SRB_CDBLen = 12;
p_ssc->SRB_SenseLen = SENSE_LEN;
@@ -2031,7 +2031,7 @@
/*****************************************************************************
* OS2InitSDC: initialize a SDC structure for the Execute SCSI-command
*****************************************************************************
- * This function initializes a OS2 'execute SCSI command' structure for
+ * This function initializes a OS2 'execute SCSI command' structure for
* future use, either a read command or a write command.
*****************************************************************************/
static void OS2InitSDC( struct OS2_ExecSCSICmd *p_sdc, int i_type )
--- a/src/ioctl.h
+++ b/src/ioctl.h
@@ -2,7 +2,7 @@
* ioctl.h: DVD ioctl replacement function
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: ioctl.h,v 1.12 2002/11/25 18:44:31 jlj Exp $
+ * $Id: ioctl.h,v 1.13 2002/12/05 10:24:42 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
@@ -22,15 +22,15 @@
*****************************************************************************/
int ioctl_ReadCopyright ( int, int, int * );
-int ioctl_ReadDiscKey ( int, int *, u8 * );
-int ioctl_ReadTitleKey ( int, int *, int, u8 * );
+int ioctl_ReadDiscKey ( int, int *, uint8_t * );
+int ioctl_ReadTitleKey ( int, int *, int, uint8_t * );
int ioctl_ReportAgid ( int, int * );
-int ioctl_ReportChallenge ( int, int *, u8 * );
-int ioctl_ReportKey1 ( int, int *, u8 * );
+int ioctl_ReportChallenge ( int, int *, uint8_t * );
+int ioctl_ReportKey1 ( int, int *, uint8_t * );
int ioctl_ReportASF ( int, int *, int * );
int ioctl_InvalidateAgid ( int, int * );
-int ioctl_SendChallenge ( int, int *, u8 * );
-int ioctl_SendKey2 ( int, int *, u8 * );
+int ioctl_SendChallenge ( int, int *, uint8_t * );
+int ioctl_SendKey2 ( int, int *, uint8_t * );
int ioctl_ReportRPC ( int, int *, int *, int * );
int ioctl_SendRPC ( int, int );
@@ -44,7 +44,7 @@
#if defined( SYS_BEOS )
#define INIT_RDC( TYPE, SIZE ) \
raw_device_command rdc; \
- u8 p_buffer[ (SIZE) ]; \
+ uint8_t p_buffer[ (SIZE) ]; \
memset( &rdc, 0, sizeof( raw_device_command ) ); \
rdc.data = (char *)p_buffer; \
rdc.data_length = (SIZE); \
@@ -57,7 +57,7 @@
#if defined( HPUX_SCTL_IO )
#define INIT_SCTL_IO( TYPE, SIZE ) \
struct sctl_io sctl_io; \
- u8 p_buffer[ (SIZE) ]; \
+ uint8_t p_buffer[ (SIZE) ]; \
memset( &sctl_io, 0, sizeof( sctl_io ) ); \
sctl_io.data = (void *)p_buffer; \
sctl_io.data_length = (SIZE); \
@@ -73,7 +73,7 @@
#define INIT_USCSI( TYPE, SIZE ) \
struct uscsi_cmd sc; \
union scsi_cdb rs_cdb; \
- u8 p_buffer[ (SIZE) ]; \
+ uint8_t p_buffer[ (SIZE) ]; \
memset( &sc, 0, sizeof( struct uscsi_cmd ) ); \
sc.uscsi_cdb = (caddr_t)&rs_cdb; \
sc.uscsi_bufaddr = p_buffer; \
@@ -102,7 +102,7 @@
#define INIT_SPTD( TYPE, SIZE ) \
DWORD tmp; \
SCSI_PASS_THROUGH_DIRECT sptd; \
- u8 p_buffer[ (SIZE) ]; \
+ uint8_t p_buffer[ (SIZE) ]; \
memset( &sptd, 0, sizeof( SCSI_PASS_THROUGH_DIRECT ) ); \
sptd.Length = sizeof( SCSI_PASS_THROUGH_DIRECT ); \
sptd.DataBuffer = p_buffer; \
@@ -115,7 +115,7 @@
(TMP), NULL ) ? 0 : -1)
#define INIT_SSC( TYPE, SIZE ) \
struct SRB_ExecSCSICmd ssc; \
- u8 p_buffer[ (SIZE) ]; \
+ uint8_t p_buffer[ (SIZE) ]; \
memset( &ssc, 0, sizeof( struct SRB_ExecSCSICmd ) ); \
ssc.SRB_BufPointer = (char *)p_buffer; \
ssc.SRB_BufLen = (SIZE); \
@@ -144,7 +144,7 @@
#if defined( SYS_OS2 )
#define INIT_SSC( TYPE, SIZE ) \
struct OS2_ExecSCSICmd sdc; \
- u8 p_buffer[ (SIZE) ]; \
+ uint8_t p_buffer[ (SIZE) ]; \
unsigned long ulParamLen; \
unsigned long ulDataLen; \
memset( &sdc, 0, sizeof( OS2_ExecSCSICmd ) ); \
--- a/src/libdvdcss.c
+++ b/src/libdvdcss.c
@@ -5,13 +5,13 @@
* H�kan Hjort <d95hjort@dtek.chalmers.se>
*
* Copyright (C) 1998-2002 VideoLAN
- * $Id: libdvdcss.c,v 1.20 2002/11/24 17:34:23 sam Exp $
+ * $Id: libdvdcss.c,v 1.21 2002/12/05 10:24:42 sam Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -22,7 +22,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
-/**
+/**
* \mainpage libdvdcss developer documentation
*
* \section intro Introduction
@@ -78,7 +78,7 @@
* on an RPC2 drive.
*
* \li \b DVDCSS_RAW_DEVICE: specify the raw device to use.
- *
+ *
* \li \b DVDCSS_CACHE: specify a directory in which to store title key
* values. This will speed up descrambling of DVDs which are in the
* cache. The DVDCSS_CACHE directory is created if it does not exist,
@@ -96,7 +96,9 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/param.h>
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
#include <fcntl.h>
#include <errno.h>
@@ -244,7 +246,7 @@
free( dvdcss );
return NULL;
}
-
+
dvdcss->b_scrambled = 1; /* Assume the worst */
dvdcss->b_ioctls = _dvdcss_use_ioctls( dvdcss );
@@ -290,7 +292,7 @@
/* If the cache is enabled, extract a unique disc ID */
if( psz_cache )
{
- u8 p_sector[DVDCSS_BLOCK_SIZE];
+ uint8_t p_sector[DVDCSS_BLOCK_SIZE];
unsigned char psz_debug[PATH_MAX+30];
unsigned char * psz_data;
int i;
@@ -351,7 +353,11 @@
/* We have a disc name or ID, we can create the cache dir */
i = sprintf( dvdcss->psz_cachefile, "%s", psz_cache );
+#ifndef WIN32
i_ret = mkdir( dvdcss->psz_cachefile, 0755 );
+#else
+ i_ret = mkdir( dvdcss->psz_cachefile );
+#endif
if( i_ret < 0 && errno != EEXIST )
{
_dvdcss_error( dvdcss, "failed creating cache directory" );
@@ -360,7 +366,11 @@
}
i += sprintf( dvdcss->psz_cachefile + i, "/%s/", psz_data );
+#ifndef WIN32
i_ret = mkdir( dvdcss->psz_cachefile, 0755 );
+#else
+ i_ret = mkdir( dvdcss->psz_cachefile );
+#endif
if( i_ret < 0 && errno != EEXIST )
{
_dvdcss_error( dvdcss, "failed creating cache subdirectory" );
@@ -427,11 +437,11 @@
{
/* title cracking method is too slow to be used at each seek */
if( ( ( i_flags & DVDCSS_SEEK_MPEG )
- && ( dvdcss->i_method != DVDCSS_METHOD_TITLE ) )
+ && ( dvdcss->i_method != DVDCSS_METHOD_TITLE ) )
|| ( i_flags & DVDCSS_SEEK_KEY ) )
{
/* check the title key */
- if( _dvdcss_title( dvdcss, i_blocks ) )
+ if( _dvdcss_title( dvdcss, i_blocks ) )
{
return -1;
}
@@ -480,11 +490,11 @@
if( ! memcmp( dvdcss->css.p_title_key, "\0\0\0\0\0", 5 ) )
{
- /* For what we believe is an unencrypted title,
+ /* For what we believe is an unencrypted title,
* check that there are no encrypted blocks */
for( i_index = i_ret; i_index; i_index-- )
{
- if( ((u8*)p_buffer)[0x14] & 0x30 )
+ if( ((uint8_t*)p_buffer)[0x14] & 0x30 )
{
_dvdcss_error( dvdcss, "no key but found encrypted block" );
/* Only return the initial range of unscrambled blocks? */
@@ -491,20 +501,20 @@
/* or fail completely? return 0; */
break;
}
- p_buffer = (void *) ((u8 *)p_buffer + DVDCSS_BLOCK_SIZE);
+ p_buffer = (void *) ((uint8_t *)p_buffer + DVDCSS_BLOCK_SIZE);
}
}
- else
+ else
{
/* 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 );
- ((u8*)p_buffer)[0x14] &= 0x8f;
- p_buffer = (void *) ((u8 *)p_buffer + DVDCSS_BLOCK_SIZE);
+ ((uint8_t*)p_buffer)[0x14] &= 0x8f;
+ p_buffer = (void *) ((uint8_t *)p_buffer + DVDCSS_BLOCK_SIZE);
}
}
-
+
return i_ret;
}
@@ -575,9 +585,9 @@
}
_dvdcss_unscramble( dvdcss->css.p_title_key, iov_base );
- ((u8*)iov_base)[0x14] &= 0x8f;
+ ((uint8_t*)iov_base)[0x14] &= 0x8f;
- iov_base = (void *) ((u8*)iov_base + DVDCSS_BLOCK_SIZE);
+ iov_base = (void *) ((uint8_t*)iov_base + DVDCSS_BLOCK_SIZE);
iov_len -= DVDCSS_BLOCK_SIZE;
}
--- a/src/libdvdcss.h
+++ b/src/libdvdcss.h
@@ -2,7 +2,7 @@
* private.h: private DVD reading library data
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
- * $Id: libdvdcss.h,v 1.6 2002/11/24 17:34:23 sam Exp $
+ * $Id: libdvdcss.h,v 1.7 2002/12/05 10:24:42 sam Exp $
*
* Authors: St�phane Borel <stef@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
@@ -11,7 +11,7 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the