From 5f10277136136bde39a46717b8e93b04dd1a09ec Mon Sep 17 00:00:00 2001 From: rocky Date: Fri, 29 Feb 2008 11:34:15 +0000 Subject: [PATCH] Add option to cd-paranoia to log summary output to a file. Patch from and thanks to Daniel Schwarz. --- NEWS | 10 ++- THANKS | 2 + src/cd-paranoia/cd-paranoia.c | 81 ++++++++++++++++--------- src/cd-paranoia/doc/en/cd-paranoia.1.in | 4 ++ src/cd-paranoia/usage-copy.h | 1 + src/cd-paranoia/usage.txt.in | 1 + test/check_paranoia.sh.in | 10 ++- 7 files changed, 75 insertions(+), 34 deletions(-) diff --git a/NEWS b/NEWS index f871c4d6..cc5dcae8 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,12 @@ -$Id: NEWS,v 1.114 2008/01/05 12:12:52 rocky Exp $ +$Id: NEWS,v 1.115 2008/02/29 11:34:15 rocky Exp $ version 0.80 +2008-03-15 + - Add get_media_changed for FreeBSD -- Savannah bug #21910 +- Add option to log summary output in cd-paranoia +- More string bounds checking to eliminate known string overflow conditions, + e.g. Savannah bug #21910 version 0.79 2007-10-27 @@ -391,4 +395,4 @@ version 0.1 Routines split off from VCDImager. -$Id: NEWS,v 1.114 2008/01/05 12:12:52 rocky Exp $ +$Id: NEWS,v 1.115 2008/02/29 11:34:15 rocky Exp $ diff --git a/THANKS b/THANKS index 22dd540a..8bd83b86 100644 --- a/THANKS +++ b/THANKS @@ -50,3 +50,5 @@ Svend S. Sorensen xboxmediacenter team (www.xboxmediacenter.de) X-Box detection and XDF filesystem things +Daniel Schwarz + log-summary option in cd-paranoia. diff --git a/src/cd-paranoia/cd-paranoia.c b/src/cd-paranoia/cd-paranoia.c index 84018cdf..6eb8d3dc 100644 --- a/src/cd-paranoia/cd-paranoia.c +++ b/src/cd-paranoia/cd-paranoia.c @@ -20,33 +20,6 @@ * * See ChangeLog for recent changes. * - * last changes: - * 22.01.98 - first version - * 15.02.98 - alpha 2: juggled two includes from interface/low_interface.h - * that move contents in Linux 2.1 - * Linked status bar to isatty to avoid it appearing - * in a redirected file. - * Played with making TOC less verbose. - * 04.04.98 - alpha 3: zillions of bugfixes, also added MMC and IDE_SCSI - * emulation support - * 05.04.98 - alpha 4: Segfault fix, cosmetic repairs - * 05.04.98 - alpha 5: another segfault fix, cosmetic repairs, - * Gadi Oxman provided code to identify/fix nonstandard - * ATAPI CDROMs - * 07.04.98 - alpha 6: Bugfixes to autodetection - * 18.06.98 - alpha 7: Additional SCSI error handling code - * cosmetic fixes - * segfault fixes - * new sync/silence code, smaller fft - * 15.07.98 - alpha 8: More new SCSI code, better error recovery - * more segfault fixes (two linux bugs, one my fault) - * Fixup reporting fixes, smilie fixes. - * AIFF support (in addition to AIFC) - * Path parsing fixes - * Changes are becoming TNTC. Will resume the log at beta. - * - * 09.04.04 - conversion to use libcdio. See top-level Changelog for - * libcdio history. */ #ifdef HAVE_CONFIG_H @@ -317,6 +290,7 @@ long callscript=0; static int skipped_flag=0; static int abort_on_skip=0; +FILE *logfile = NULL; #if TRACE_PARANOIA static void @@ -557,6 +531,12 @@ callback(long int inpos, paranoia_cb_mode_t function) } fprintf(stderr,buffer); + + if (logfile != NULL && function==-1) { + fprintf(logfile,buffer+1); + fprintf(logfile,"\n\n"); + fflush(logfile); + } } } } @@ -567,7 +547,7 @@ callback(long int inpos, paranoia_cb_mode_t function) } #endif /* !TRACE_PARANOIA */ -const char *optstring = "aBcCd:efg:hi:m:n:o:O:pqQrRsS:Tt:VvwWx:XYZz::"; +const char *optstring = "aBcCd:efg:hi:l:m:n:o:O:pqQrRsS:Tt:VvwWx:XYZz::"; struct option options [] = { {"abort-on-skip", no_argument, NULL, 'X'}, @@ -583,6 +563,7 @@ struct option options [] = { {"force-read-speed", required_argument, NULL, 'S'}, {"force-search-overlap", required_argument, NULL, 'o'}, {"help", no_argument, NULL, 'h'}, + {"log-summary", required_argument, NULL, 'l'}, {"mmc-timeout", required_argument, NULL, 'm'}, {"never-skip", optional_argument, NULL, 'z'}, {"output-aifc", no_argument, NULL, 'a'}, @@ -638,6 +619,10 @@ cleanup (void) free_and_null(force_cdrom_device); free_and_null(span); free_and_null(info_file); + if(logfile && logfile != stdout) { + fclose(logfile); + logfile = NULL; + } } /* Returns true if we have an integer argument. @@ -747,6 +732,19 @@ main(int argc,char *argv[]) if(info_file)free(info_file); info_file=strdup(info_file); break; + case 'l': + if(logfile && logfile != stdout)fclose(logfile); + if(!strcmp(optarg,"-")) + logfile=stdout; + else{ + logfile=fopen(optarg,"w"); + if(logfile==NULL){ + report3("Cannot open log summary file %s: %s",(char*)optarg, + strerror(errno)); + exit(1); + } + } + break; case 'm': { long int mmc_timeout_sec; @@ -839,6 +837,18 @@ main(int argc,char *argv[]) exit(1); } } + + if(logfile){ + /* log command line and version */ + int i; + for (i = 0; i < argc; i++) + fprintf(logfile,"%s ",argv[i]); + fprintf(logfile,"\n"); + + fprintf(logfile,VERSION); + fprintf(logfile,"\n"); + fflush(logfile); + } if(optind>=argc && !query_only){ if(batch) @@ -919,6 +929,8 @@ main(int argc,char *argv[]) report("Search overlap sectors must be 0<= n <=75\n"); cdda_close(d); d=NULL; + if(logfile && logfile != stdout) + fclose(logfile); exit(1); } { @@ -1138,6 +1150,10 @@ main(int argc,char *argv[]) report("Are you sure you wanted 'batch' " "(-B) output with stdout?"); report("outputting to stdout\n"); + if(logfile){ + fprintf(logfile,"outputting to stdout\n"); + fflush(logfile); + } outfile_name[0]='\0'; } else { char path[256]; @@ -1181,6 +1197,10 @@ main(int argc,char *argv[]) exit(1); } report2("outputting to %s\n", outfile_name); + if(logfile){ + fprintf(logfile,"outputting to %s\n",outfile_name); + fflush(logfile); + } } } else { /* default */ @@ -1211,6 +1231,11 @@ main(int argc,char *argv[]) exit(1); } report2("outputting to %s\n", outfile_name); + if(logfile){ + fprintf(logfile,"outputting to %s\n",outfile_name); + fflush(logfile); + } + } switch(output_type) { diff --git a/src/cd-paranoia/doc/en/cd-paranoia.1.in b/src/cd-paranoia/doc/en/cd-paranoia.1.in index fd732255..0d6fa4af 100644 --- a/src/cd-paranoia/doc/en/cd-paranoia.1.in +++ b/src/cd-paranoia/doc/en/cd-paranoia.1.in @@ -57,6 +57,10 @@ Print a brief synopsis of .B @CDPARANOIA_NAME@ usage and options. +.TP +.BI "\-l --log-summary " file +Save result summary to file. + .TP .B \-p --output-raw Output headerless data as raw 16 bit PCM data with interleaved samples in host byte order. To force little or big endian byte order, use diff --git a/src/cd-paranoia/usage-copy.h b/src/cd-paranoia/usage-copy.h index 53d450ff..32ad6187 100644 --- a/src/cd-paranoia/usage-copy.h +++ b/src/cd-paranoia/usage-copy.h @@ -23,6 +23,7 @@ const char usage_help[] = " -v --verbose : extra verbose operation\n" " -q --quiet : quiet operation\n" " -e --stderr-progress : force output of progress information to\n" +" -l --log-summary : save result summary to file\n" " stderr (for wrapper scripts)\n" " -V --version : print version info and quit\n" " -Q --query : autosense drive, query disc and quit\n" diff --git a/src/cd-paranoia/usage.txt.in b/src/cd-paranoia/usage.txt.in index 2049ab40..79de07b8 100644 --- a/src/cd-paranoia/usage.txt.in +++ b/src/cd-paranoia/usage.txt.in @@ -6,6 +6,7 @@ OPTIONS: -q --quiet : quiet operation -e --stderr-progress : force output of progress information to stderr (for wrapper scripts) + -l --log-summary : save result summary to file -V --version : print version info and quit -Q --query : autosense drive, query disc and quit -B --batch : 'batch' mode (saves each track to a diff --git a/test/check_paranoia.sh.in b/test/check_paranoia.sh.in index 2735c608..38b8fc23 100644 --- a/test/check_paranoia.sh.in +++ b/test/check_paranoia.sh.in @@ -1,6 +1,6 @@ #!/bin/sh -# $Id: check_paranoia.sh.in,v 1.11 2005/10/17 15:10:55 pjcreath Exp $ -# Compare our cd-paranoia with an installed cdparanoia +# $Id: check_paranoia.sh.in,v 1.12 2008/02/29 11:34:15 rocky Exp $ +# Compare our cd-paranoia with known good results. if test "X$srcdir" = "X" ; then srcdir=`pwd` @@ -68,7 +68,11 @@ if test "@CMP@" != no -a "@BUILD_CD_PARANOIA_TRUE@"X = X ; then ### FIXME: large jitter is known to fail. Investigate. exit 0 else - echo "Don't see libcdio cd-paranoia program. Test skipped." + if test "@CMP@" != no ; then + echo "Don't see 'cmp' program. Test skipped." + else + echo "Don't see libcdio 'cd-paranoia' program. Test skipped." + fi exit 77 fi fi