summaryrefslogtreecommitdiffstats
path: root/libmpdvdkit2/libdvdcss.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmpdvdkit2/libdvdcss.c')
-rw-r--r--libmpdvdkit2/libdvdcss.c75
1 files changed, 35 insertions, 40 deletions
diff --git a/libmpdvdkit2/libdvdcss.c b/libmpdvdkit2/libdvdcss.c
index 4ea767ea9c..32bfbfcfd4 100644
--- a/libmpdvdkit2/libdvdcss.c
+++ b/libmpdvdkit2/libdvdcss.c
@@ -151,6 +151,7 @@ char * dvdcss_interface_2 = VERSION;
*/
extern dvdcss_t dvdcss_open ( char *psz_target )
{
+ char psz_buffer[PATH_MAX];
int i_ret;
char *psz_method = getenv( "DVDCSS_METHOD" );
@@ -190,15 +191,10 @@ extern dvdcss_t dvdcss_open ( char *psz_target )
*/
if( psz_verbose != NULL )
{
- switch( atoi( psz_verbose ) )
- {
- case 2:
- dvdcss->b_debug = 1;
- case 1:
- dvdcss->b_errors = 1;
- case 0:
- break;
- }
+ int i = atoi( psz_verbose );
+
+ if( i >= 2 ) dvdcss->b_debug = 1;
+ if( i >= 1 ) dvdcss->b_errors = 1;
}
/*
@@ -292,19 +288,12 @@ extern dvdcss_t dvdcss_open ( char *psz_target )
}
}
-#ifndef WIN32
- if( psz_raw_device != NULL )
- {
- _dvdcss_raw_open( dvdcss, psz_raw_device );
- }
-#endif
-
/* If the cache is enabled, extract a unique disc ID */
if( psz_cache )
{
uint8_t p_sector[DVDCSS_BLOCK_SIZE];
unsigned char psz_debug[PATH_MAX+30];
- unsigned char * psz_data;
+ unsigned char * psz_title, * psz_serial;
int i;
/* We read sector 0. If it starts with 0x000001ba (BE), we are
@@ -345,40 +334,37 @@ extern dvdcss_t dvdcss_open ( char *psz_target )
}
/* Get the disc title */
- psz_data = p_sector + 40;
- psz_data[32] = '\0';
+ psz_title = p_sector + 40;
+ psz_title[32] = '\0';
for( i = 0 ; i < 32 ; i++ )
{
- if( psz_data[i] <= ' ' )
+ if( psz_title[i] <= ' ' )
{
- psz_data[i] = '\0';
+ psz_title[i] = '\0';
break;
}
- else if( psz_data[i] == '/' || psz_data[i] == '\\' )
+ else if( psz_title[i] == '/' || psz_title[i] == '\\' )
{
- psz_data[i] = '-';
+ psz_title[i] = '-';
}
}
- /* If it's not long enough, try the date + serial */
- if( strlen( psz_data ) < 6 )
- {
- psz_data = p_sector + 813;
- psz_data[16] = '\0';
+ /* Get the date + serial */
+ psz_serial = p_sector + 813;
+ psz_serial[16] = '\0';
- /* Check that all characters are digits, otherwise convert. */
- for( i = 0 ; i < 16 ; i++ )
+ /* Check that all characters are digits, otherwise convert. */
+ for( i = 0 ; i < 16 ; i++ )
+ {
+ if( psz_serial[i] < '0' || psz_serial[i] > '9' )
{
- if( psz_data[i] < '0' || psz_data[i] > '9' )
- {
- sprintf( psz_data,
- "%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X",
- psz_data[0], psz_data[1], psz_data[2],
- psz_data[3], psz_data[4], psz_data[5],
- psz_data[6], psz_data[7] );
- break;
- }
+ sprintf( psz_serial,
+ "%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X",
+ psz_serial[0], psz_serial[1], psz_serial[2],
+ psz_serial[3], psz_serial[4], psz_serial[5],
+ psz_serial[6], psz_serial[7] );
+ break;
}
}
@@ -395,8 +381,10 @@ extern dvdcss_t dvdcss_open ( char *psz_target )
dvdcss->psz_cachefile[0] = '\0';
goto nocache;
}
+ i += sprintf( dvdcss->psz_cachefile + i, "/");
- i += sprintf( dvdcss->psz_cachefile + i, "/%s", psz_data );
+// i += sprintf( dvdcss->psz_cachefile + i, "/%s", psz_data );
+ i += sprintf( dvdcss->psz_cachefile + i, "/%s#%s", psz_title, psz_serial );
#if !defined( WIN32 ) || defined( SYS_CYGWIN )
i_ret = mkdir( dvdcss->psz_cachefile, 0755 );
#else
@@ -419,6 +407,13 @@ extern dvdcss_t dvdcss_open ( char *psz_target )
}
nocache:
+#ifndef WIN32
+ if( psz_raw_device != NULL )
+ {
+ _dvdcss_raw_open( dvdcss, psz_raw_device );
+ }
+#endif
+
/* Seek at the beginning, just for safety. */
dvdcss->pf_seek( dvdcss, 0 );