diff libmpdvdkit2/libdvdcss.c @ 10720:f23c35ce0d16

synced to libdvdcss 1.2.8 (except the DVDCSS_PATH guessing, we use our get_path() instead). anyway it's mostly cosmetics only.
author arpi
date Sat, 30 Aug 2003 13:35:25 +0000
parents 454d8a4bd4f9
children e482b16c7145
line wrap: on
line diff
--- a/libmpdvdkit2/libdvdcss.c	Fri Aug 29 21:57:40 2003 +0000
+++ b/libmpdvdkit2/libdvdcss.c	Sat Aug 30 13:35:25 2003 +0000
@@ -151,6 +151,7 @@
  */
 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 @@
      */
     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 @@
         }
     }
 
-#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 @@
         }
 
         /* 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 )
+        /* 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++ )
         {
-            psz_data = p_sector + 813;
-            psz_data[16] = '\0';
-
-            /* 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 @@
             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 @@
     }
     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 );