Add cd-read.c for debugging CD reading problems.

This commit is contained in:
rocky
2003-09-17 12:13:07 +00:00
parent 2574f5dacb
commit 9a97232136
2 changed files with 102 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.14 2003/08/31 06:59:23 rocky Exp $
# $Id: Makefile.am,v 1.15 2003/09/17 12:13:07 rocky Exp $
#
# Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
#
@@ -25,16 +25,19 @@ if BUILD_CDINFO
cd_info_SOURCES = cd-info.c
cd_info_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(CDDB_LIBS) $(VCDINFO_LIBS)
cd_read_SOURCES = cd-read.c
cd_read_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS)
if BUILD_CDINFO_LINUX
cdinfo_linux_SOURCES = cdinfo-linux.c
cdinfo_linux_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS)
bin_PROGRAMS = cd-info cdinfo-linux
bin_PROGRAMS = cd-info cd-read cdinfo-linux
else
bin_PROGRAMS = cd-info
bin_PROGRAMS = cd-info cd-read
EXTRA_DIST = cdinfo-linux.c
endif
else
EXTRA_DIST = cdinfo-linux.c cd-info.c
EXTRA_DIST = cdinfo-linux.c cd-info.c cd-read.c
endif
INCLUDES = -I$(top_srcdir) $(LIBPOPT_CFLAGS) $(LIBCDIO_CFLAGS) $(VCDINFO_CFLAGS)

95
src/cd-read.c Normal file
View File

@@ -0,0 +1,95 @@
/*
$Id: cd-read.c,v 1.1 2003/09/17 12:13:07 rocky Exp $
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Program to debug read routines audio, mode1, mode2 forms 1 & 2. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <sys/types.h>
#include <cdio/cdio.h>
#include <stdlib.h>
#include <ctype.h>
static void
hexdump (uint8_t * buffer, unsigned int len)
{
unsigned int i;
for (i = 0; i < len; i++, buffer++)
{
if (i % 16 == 0)
printf ("0x%04x: ", i);
printf ("%02x", *buffer);
if (i % 2 == 1)
printf (" ");
if (i % 16 == 15) {
printf (" ");
uint8_t *p;
for (p=buffer-15; p <= buffer; p++) {
printf("%c", isprint(*p) ? *p : '.');
}
printf ("\n");
}
}
printf ("\n");
}
int
main(int argc, const char *argv[])
{
uint8_t buffer[CDIO_CD_FRAMESIZE_RAW] = { 0, };
lsn_t lsn;
if (argc != 4) {
printf("need to give 3 things: device/filename, type of read, & lsn\n");
return 10;
}
CdIo *cdio = cdio_open (argv[1], DRIVER_UNKNOWN);
lsn = atoi(argv[3]);
switch (argv[2][0]) {
case '1':
cdio_read_audio_sector(cdio, &buffer, lsn);
break;
case '2':
cdio_read_mode1_sector(cdio, &buffer, lsn, false);
break;
case '3':
cdio_read_mode1_sector(cdio, &buffer, 16, true);
break;
case '4':
cdio_read_mode2_sector(cdio, &buffer, 0, false);
break;
case '5':
cdio_read_mode2_sector(cdio, &buffer, 16, true);
break;
default:
printf("Expecting 1..5 as the second argument.\n");
return 20;
}
hexdump(buffer, CDIO_CD_FRAMESIZE_RAW);
cdio_destroy(cdio);
return 0;
}