diff options
author | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-08-30 13:35:25 +0000 |
---|---|---|
committer | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-08-30 13:35:25 +0000 |
commit | 7a58bc01979b9de4cfc942805bed8cab923c2ff6 (patch) | |
tree | af92a578330622ec74044897dd594e74319c4989 /libmpdvdkit2/libdvdcss.c | |
parent | 4e291ef76c2951fd9fc5686c101a04b725727af1 (diff) | |
download | mpv-7a58bc01979b9de4cfc942805bed8cab923c2ff6.tar.bz2 mpv-7a58bc01979b9de4cfc942805bed8cab923c2ff6.tar.xz |
synced to libdvdcss 1.2.8 (except the DVDCSS_PATH guessing, we use our
get_path() instead). anyway it's mostly cosmetics only.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10721 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdvdkit2/libdvdcss.c')
-rw-r--r-- | libmpdvdkit2/libdvdcss.c | 75 |
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 ); |