Add option to nuke header for regression tests.

With M$ can no longer assume file descriptors do the right thing.
Have pay more attention to track formats.
This commit is contained in:
rocky
2003-06-07 20:40:47 +00:00
parent 3db829442a
commit f07eb71a90

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cd-info.c,v 1.8 2003/06/07 10:43:32 rocky Exp $ $Id: cd-info.c,v 1.9 2003/06/07 20:40:47 rocky Exp $
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org> Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org>
@@ -25,7 +25,6 @@
*/ */
#define PROGRAM_NAME "CD Info" #define PROGRAM_NAME "CD Info"
#define CDINFO_VERSION "2.0"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -224,7 +223,7 @@ int num_audio = 0; /* # of audio tracks */
char *source_name = NULL; char *source_name = NULL;
char *program_name; char *program_name;
const char *argp_program_version = PROGRAM_NAME CDINFO_VERSION; const char *argp_program_version = PROGRAM_NAME " " VERSION;
const char *argp_program_bug_address = "rocky@panix.com"; const char *argp_program_bug_address = "rocky@panix.com";
typedef enum typedef enum
@@ -259,7 +258,8 @@ struct arguments
#endif #endif
uint32_t debug_level; uint32_t debug_level;
int silent; int silent;
bool version_only; int version_only;
int no_header;
source_image_t source_image; source_image_t source_image;
} opts; } opts;
@@ -349,6 +349,9 @@ struct poptOption optionsTable[] = {
OP_SOURCE_DEVICE, OP_SOURCE_DEVICE,
"set CD-ROM device as source", "DEVICE"}, "set CD-ROM device as source", "DEVICE"},
{"no-header", '\0', POPT_ARG_NONE, &opts.no_header,
0, "Don't display header and copyright (for regression testing)"},
{"nrg-file", 'N', POPT_ARG_STRING|POPT_ARGFLAG_OPTIONAL, &source_name, {"nrg-file", 'N', POPT_ARG_STRING|POPT_ARGFLAG_OPTIONAL, &source_name,
OP_SOURCE_NRG, "set Nero CD-ROM disk image file as source", "FILE"}, OP_SOURCE_NRG, "set Nero CD-ROM disk image file as source", "FILE"},
@@ -457,12 +460,13 @@ print_version (bool version_only)
driver_id_t driver_id; driver_id_t driver_id;
printf( _("CD Info %s | (c) 2003 Gerd Knorr, Heiko Ei<45>feldt & R. Bernstein\n\ if (!opts.no_header)
This is free software; see the source for copying conditions.\n\ printf( _("CD Info %s (c) 2003 Gerd Knorr, Heiko Ei<45>feldt & R. Bernstein\n"),
VERSION);
printf( _("This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\ There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n\
PARTICULAR PURPOSE.\n\ PARTICULAR PURPOSE.\n\
"), "));
CDINFO_VERSION);
if (version_only) { if (version_only) {
for (driver_id=DRIVER_UNKNOWN+1; driver_id<=MAX_DRIVER; driver_id++) { for (driver_id=DRIVER_UNKNOWN+1; driver_id<=MAX_DRIVER; driver_id++) {
@@ -493,12 +497,15 @@ read_block(int superblock, uint32_t offset, uint8_t bufnum, track_t track_num)
dbg_print(2, "about to read sector %u\n", offset+superblock); dbg_print(2, "about to read sector %u\n", offset+superblock);
if (0 > cdio_lseek(cdio, CDIO_CD_FRAMESIZE*(offset+superblock),SEEK_SET)) if (cdio_get_track_green(cdio, track_num)) {
return -1; if (0 > cdio_read_mode2_sector(cdio, buffer[bufnum],
offset+superblock, false))
return -1;
if (0 > cdio_read(cdio, buffer[bufnum], CDIO_CD_FRAMESIZE)) } else {
return -1; if (0 > cdio_read_yellow_sector(cdio, buffer[bufnum],
offset+superblock, false))
return -1;
}
return 0; return 0;
} }
@@ -506,15 +513,11 @@ read_block(int superblock, uint32_t offset, uint8_t bufnum, track_t track_num)
static bool static bool
is_it(int num) is_it(int num)
{ {
signature_t *sigp; signature_t *sigp=&sigs[num];
int len; int len=strlen(sigp->sig_str);
/* TODO: check that num < largest sig. */ /* TODO: check that num < largest sig. */
sigp = &sigs[num]; return 0 == memcmp(&buffer[sigp->buf_num][sigp->offset], sigp->sig_str, len);
len = strlen(sigp->sig_str);
return 0 == memcmp(&buffer[sigp->buf_num][sigp->offset],
sigp->sig_str, len);
} }
static int static int
@@ -1002,6 +1005,7 @@ main(int argc, const char *argv[])
/* Default option values. */ /* Default option values. */
opts.silent = false; opts.silent = false;
opts.no_header = false;
opts.debug_level = 0; opts.debug_level = 0;
opts.no_tracks = 0; opts.no_tracks = 0;
#ifdef HAVE_CDDB #ifdef HAVE_CDDB