ref: eeaf7ef062e799d49c8d56db3c7938acfa81e8ce
parent: 9ae8f9d21ccad4155c7d379e071b04cb9712041b
author: Sam Hocevar <[email protected]>
date: Tue Sep 9 09:17:24 EDT 2003
* src/css.c, src/device.c: more meaningful error messages.
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@
AC_C_INLINE
AC_TYPE_SIZE_T
-AC_CHECK_HEADERS(unistd.h sys/param.h limits.h pwd.h)
+AC_CHECK_HEADERS(unistd.h sys/param.h limits.h pwd.h errno.h)
dnl
dnl Check the operating system
--- 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.27 2003/09/09 10:03:48 sam Exp $
+ * $Id: css.c,v 1.28 2003/09/09 13:17:24 sam Exp $
*
* Author: St�phane Borel <[email protected]>
* H�kan Hjort <[email protected]>
@@ -147,17 +147,16 @@
i_ret = ioctl_ReportAgid( dvdcss->i_fd, &dvdcss->css.i_agid );
/* 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. */
+ * 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 )
{
- sprintf( psz_warning,
- "ioctl ReportAgid failed, invalidating AGID %d", i );
- print_debug( dvdcss, psz_warning );
+ print_debug( dvdcss, "ioctl ReportAgid failed, "
+ "invalidating AGID %d", i );
/* This is really _not good_, should be handled by the OS.
- Invalidating an AGID could make another process fail some
- where in it's authentication process. */
+ * Invalidating an AGID could make another process fail somewhere
+ * in its authentication process. */
dvdcss->css.i_agid = i;
ioctl_InvalidateAgid( dvdcss->i_fd, &dvdcss->css.i_agid );
@@ -213,9 +212,7 @@
if( memcmp( p_key_check, p_key1, KEY_SIZE ) == 0 )
{
- snprintf( psz_warning, sizeof(psz_warning),
- "drive authenticated, using variant %d", i );
- print_debug( dvdcss, psz_warning );
+ print_debug( dvdcss, "drive authenticated, using variant %d", i );
i_variant = i;
break;
}
@@ -275,11 +272,8 @@
*****************************************************************************/
static void PrintKey( dvdcss_t dvdcss, char *prefix, uint8_t const *data )
{
- char psz_output[80];
-
- sprintf( psz_output, "%s%02x:%02x:%02x:%02x:%02x", prefix,
- data[0], data[1], data[2], data[3], data[4] );
- print_debug( dvdcss, psz_output );
+ print_debug( dvdcss, "%s%02x:%02x:%02x:%02x:%02x", prefix,
+ data[0], data[1], data[2], data[3], data[4] );
}
/*****************************************************************************
@@ -509,7 +503,8 @@
* read the title key and decrypt it.
*/
- print_debug( dvdcss, "getting title key the classic way" );
+ print_debug( dvdcss, "getting title key at block %i the classic way",
+ i_pos );
/* We need to authenticate again every time to get a new session key */
if( GetBusKey( dvdcss ) < 0 )
@@ -1413,7 +1408,7 @@
int b_read_error = 0;
int i_ret;
- print_debug( dvdcss, "cracking title key" );
+ print_debug( dvdcss, "cracking title key at block %i", i_pos );
i_tries = 0;
i_success = 0;
@@ -1439,8 +1434,8 @@
}
else if( !b_read_error )
{
- print_debug( dvdcss, "read error, resorting to secret "
- "arcanes to recover" );
+ print_debug( dvdcss, "read error at block %i, resorting to "
+ "secret arcanes to recover", i_pos );
/* Reset the drive before trying to continue */
_dvdcss_close( dvdcss );
@@ -1457,7 +1452,8 @@
* For now, allow all blocks that begin with a start code. */
if( memcmp( p_buf, p_packstart, 3 ) )
{
- print_debug( dvdcss, "non MPEG block found (end of title)" );
+ print_debug( dvdcss, "non MPEG block found at block %i "
+ "(end of title)", i_pos );
break;
}
@@ -1491,7 +1487,7 @@
/* Emit a progress indication now and then. */
if( !( i_reads & 0xfff ) )
{
- print_debug( dvdcss, "still cracking..." );
+ print_debug( dvdcss, "at block %i, still cracking...", i_pos );
}
/* Stop after 2000 blocks if we haven't seen any encrypted blocks. */
--- 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.17 2003/09/09 10:03:48 sam Exp $
+ * $Id: device.c,v 1.18 2003/09/09 13:17:24 sam Exp $
*
* Authors: St�phane Borel <[email protected]>
* Samuel Hocevar <[email protected]>
@@ -31,6 +31,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_ERRNO_H
+# include <errno.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_PARAM_H
@@ -135,12 +138,9 @@
int _dvdcss_open ( dvdcss_t dvdcss )
{
- char psz_debug[200];
char const *psz_device = dvdcss->psz_device;
- snprintf( psz_debug, 199, "opening target `%s'", psz_device );
- psz_debug[199] = '\0';
- print_debug( dvdcss, psz_debug );
+ print_debug( dvdcss, "opening target `%s'", psz_device );
#if defined( WIN32 )
/* If device is not "X:", we are actually opening a file. */
@@ -184,7 +184,9 @@
if( dvdcss->i_raw_fd == -1 )
{
- print_error( dvdcss, "failed opening raw device, continuing" );
+ print_debug( dvdcss, "cannot open %s (%s)",
+ psz_device, strerror(errno) );
+ print_error( dvdcss, "failed to open raw device, but continuing" );
return -1;
}
else
@@ -253,7 +255,9 @@
if( dvdcss->i_fd == -1 )
{
- print_error( dvdcss, "failed opening device" );
+ print_debug( dvdcss, "cannot open %s (%s)",
+ psz_device, strerror(errno) );
+ print_error( dvdcss, "failed to open device" );
return -1;
}