diff --git a/configure.ac b/configure.ac index 2f74596d..8f2fc25f 100644 --- a/configure.ac +++ b/configure.ac @@ -16,7 +16,7 @@ dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA dnl 02111-1307, USA. AC_PREREQ(2.54) -AC_REVISION([$Id: configure.ac,v 1.45 2003/09/22 01:05:15 rocky Exp $])dnl +AC_REVISION([$Id: configure.ac,v 1.46 2003/09/27 23:29:29 rocky Exp $])dnl AC_INIT(lib/cdio.c) AM_INIT_AUTOMAKE(libcdio, 0.64-cvs) AM_CONFIG_HEADER(config.h) @@ -177,7 +177,10 @@ AM_PROG_LIBTOOL dnl Checks for header files. AC_STDC_HEADERS -AC_HAVE_HEADERS( stdbool.h stdlib.h stdint.h stdio.h string.h strings.h linux/version.h sys/cdio.h sys/stat.h sys/types.h ) +AC_HAVE_HEADERS( errno.h fcntl.h \ + stdbool.h stdlib.h stdint.h stdio.h string.h \ + strings.h linux/version.h sys/cdio.h sys/stat.h \ + sys/types.h ) LIBCDIO_CFLAGS='-I$(top_srcdir)/lib/ -I$(top_srcdir)/include/' LIBCDIO_LIBS='$(top_builddir)/lib/libcdio.la' diff --git a/include/cdio/cdio.h b/include/cdio/cdio.h index c99d46df..327c20dd 100644 --- a/include/cdio/cdio.h +++ b/include/cdio/cdio.h @@ -1,5 +1,5 @@ /* -*- c -*- - $Id: cdio.h,v 1.21 2003/09/25 09:38:15 rocky Exp $ + $Id: cdio.h,v 1.22 2003/09/27 23:29:29 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003 Rocky Bernstein @@ -266,6 +266,7 @@ extern "C" { /*! Set the arg "key" with "value" in the source device. + 0 is returned if no error was found, and nonzero if there as an error. */ int cdio_set_arg (CdIo *obj, const char key[], const char value[]); diff --git a/lib/_cdio_bincue.c b/lib/_cdio_bincue.c index 6597abb2..5b30635f 100644 --- a/lib/_cdio_bincue.c +++ b/lib/_cdio_bincue.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_bincue.c,v 1.30 2003/09/25 09:38:16 rocky Exp $ + $Id: _cdio_bincue.c,v 1.31 2003/09/27 23:29:29 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002,2003 Rocky Bernstein @@ -24,7 +24,7 @@ (*.cue). */ -static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.30 2003/09/25 09:38:16 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.31 2003/09/27 23:29:29 rocky Exp $"; #include "cdio_assert.h" #include "cdio_private.h" @@ -563,6 +563,13 @@ _cdio_read_mode2_sectors (void *env, void *data, uint32_t lsn, #define free_if_notnull(obj) \ if (NULL != obj) free(obj); +/*! + Set the arg "key" with "value" in the source device. + Currently "source" to set the source device in I/O operations + is the only valid key. + + 0 is returned if no error was found, and nonzero if there as an error. +*/ /*! Set the device to use in I/O operations. */ diff --git a/lib/_cdio_linux.c b/lib/_cdio_linux.c index a814f050..8e024530 100644 --- a/lib/_cdio_linux.c +++ b/lib/_cdio_linux.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_linux.c,v 1.22 2003/09/25 09:38:16 rocky Exp $ + $Id: _cdio_linux.c,v 1.23 2003/09/27 23:29:29 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002,2003 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.22 2003/09/25 09:38:16 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.23 2003/09/27 23:29:29 rocky Exp $"; #include @@ -487,7 +487,7 @@ _cdio_read_mode2_sectors (void *env, void *data, lsn_t lsn, bool mode2_form2, unsigned int nblocks) { _img_private_t *_obj = env; - int i; + unsigned int i; int retval; for (i = 0; i < nblocks; i++) { @@ -534,7 +534,12 @@ _cdio_stat_size (void *env) } /*! - Set the key "arg" to "value" in source device. + Set the arg "key" with "value" in the source device. + Currently "source" and "access-mode" are valid keys. + "source" sets the source device in I/O operations + "access-mode" sets the the method of CD access + + 0 is returned if no error was found, and nonzero if there as an error. */ static int _cdio_set_arg (void *env, const char key[], const char value[]) @@ -558,8 +563,9 @@ _cdio_set_arg (void *env, const char key[], const char value[]) _obj->access_mode = _AM_READ_CD; else if (!strcmp(value, "READ_10")) _obj->access_mode = _AM_READ_10; - else - cdio_error ("unknown access type: %s. ignored.", value); + else { + cdio_warn ("unknown access type: %s. ignored.", value); + } } else return -1; diff --git a/lib/_cdio_sunos.c b/lib/_cdio_sunos.c index 9787af62..7262ca37 100644 --- a/lib/_cdio_sunos.c +++ b/lib/_cdio_sunos.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_sunos.c,v 1.18 2003/09/26 09:11:19 rocky Exp $ + $Id: _cdio_sunos.c,v 1.19 2003/09/27 23:29:29 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002,2003 Rocky Bernstein @@ -36,7 +36,7 @@ #ifdef HAVE_SOLARIS_CDROM -static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.18 2003/09/26 09:11:19 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.19 2003/09/27 23:29:29 rocky Exp $"; #include #include @@ -334,7 +334,12 @@ _cdio_stat_size (void *env) } /*! - Set the key "arg" to "value" in source device. + Set the arg "key" with "value" in the source device. + Currently "source" and "access-mode" are valid keys. + "source" sets the source device in I/O operations + "access-mode" sets the the method of CD access + + 0 is returned if no error was found, and nonzero if there as an error. */ static int _cdio_set_arg (void *env, const char key[], const char value[]) @@ -357,7 +362,7 @@ _cdio_set_arg (void *env, const char key[], const char value[]) else if (!strcmp(value, "SCSI")) _obj->access_mode = _AM_SUN_CTRL_SCSI; else - cdio_error ("unknown access type: %s. ignored.", value); + cdio_warn ("unknown access type: %s. ignored.", value); } else return -1; diff --git a/src/cd-info.c b/src/cd-info.c index 0fc8dd48..417222d1 100644 --- a/src/cd-info.c +++ b/src/cd-info.c @@ -1,5 +1,5 @@ /* - $Id: cd-info.c,v 1.38 2003/09/25 09:38:16 rocky Exp $ + $Id: cd-info.c,v 1.39 2003/09/27 23:29:29 rocky Exp $ Copyright (C) 2003 Rocky Bernstein Copyright (C) 1996,1997,1998 Gerd Knorr @@ -77,6 +77,7 @@ struct arguments int no_tracks; int no_ioctl; int no_analysis; + char *access_mode; /* Access method driver should use for control */ #ifdef HAVE_CDDB int no_cddb; /* If set the below are meaningless. */ char *cddb_email; /* email to report to CDDB server. */ @@ -121,6 +122,9 @@ parse_options (int argc, const char *argv[]) int opt; struct poptOption optionsTable[] = { + {"access-mode", 'a', POPT_ARG_STRING, &opts.access_mode, 0, + "Set CD access methed"}, + {"debug", 'd', POPT_ARG_INT, &opts.debug_level, 0, "Set debugging to LEVEL"}, @@ -800,6 +804,10 @@ main(int argc, const char *argv[]) } } + if (opts.access_mode!=NULL) { + cdio_set_arg(cdio, "access-mode", opts.access_mode); + } + first_track_num = cdio_get_first_track_num(cdio); num_tracks = cdio_get_num_tracks(cdio); @@ -847,7 +855,7 @@ main(int argc, const char *argv[]) /* get MCN */ media_catalog_number = cdio_get_mcn(cdio); - printf("Get MCN : "); fflush(stdout); + printf("Media Catalog Number (MCN): "); fflush(stdout); if (NULL == media_catalog_number) printf("not available\n"); else { diff --git a/src/cd-read.c b/src/cd-read.c index 3a3c1248..a29a439c 100644 --- a/src/cd-read.c +++ b/src/cd-read.c @@ -1,5 +1,5 @@ /* - $Id: cd-read.c,v 1.7 2003/09/22 01:00:10 rocky Exp $ + $Id: cd-read.c,v 1.8 2003/09/27 23:29:29 rocky Exp $ Copyright (C) 2003 Rocky Bernstein @@ -22,6 +22,16 @@ #include "util.h" +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_FCNTL_H +#include +#endif +#ifdef HAVE_ERRNO_H +#include +#endif + /* Configuration option codes */ enum { @@ -75,6 +85,8 @@ subopt_entry_t modes_sublist[] = { */ struct arguments { + char *access_mode; /* Access method driver should use for control */ + char *output_file; /* file to output blocks if not NULL. */ int debug_level; read_mode_t read_mode; int version_only; @@ -162,6 +174,9 @@ parse_options (int argc, const char *argv[]) /* Command-line options */ struct poptOption optionsTable[] = { + {"access-mode", 'a', POPT_ARG_STRING, &opts.access_mode, 0, + "Set CD control access mode"}, + {"mode", 'm', POPT_ARG_STRING, &opt_arg, OP_READ_MODE, @@ -201,6 +216,9 @@ parse_options (int argc, const char *argv[]) {"nrg-file", 'N', POPT_ARG_STRING|POPT_ARGFLAG_OPTIONAL, &source_name, OP_SOURCE_NRG, "set Nero CD-ROM disk image file as source", "FILE"}, + {"output-file", 'o', POPT_ARG_STRING, &opts.output_file, 0, + "Output blocks to file rather than give a hexdump."}, + {"version", 'V', POPT_ARG_NONE, NULL, OP_VERSION, "display version and copyright information and exit"}, POPT_AUTOHELP {NULL, 0, 0, NULL, 0} @@ -378,6 +396,7 @@ main(int argc, const char *argv[]) uint8_t buffer[CDIO_CD_FRAMESIZE_RAW] = { 0, }; unsigned int blocklen=CDIO_CD_FRAMESIZE_RAW; CdIo *cdio=NULL; + int output_fd=-1; init(); @@ -392,40 +411,52 @@ main(int argc, const char *argv[]) case IMAGE_AUTO: cdio = cdio_open (source_name, DRIVER_UNKNOWN); if (cdio==NULL) { - err_exit("%s: Error in automatically selecting driver with input\n", - program_name); + err_exit("Error in automatically selecting driver with input\n"); } break; case IMAGE_DEVICE: cdio = cdio_open (source_name, DRIVER_DEVICE); if (cdio==NULL) { - err_exit("%s: Error in automatically selecting device with input\n", - program_name); + err_exit("Error in automatically selecting device with input\n"); + } break; case IMAGE_BIN: cdio = cdio_open (source_name, DRIVER_BINCUE); if (cdio==NULL) { - err_exit("%s: Error in opeing bin/cue\n", - program_name); + err_exit("Error in opening bin/cue file %s\n", + source_name); } break; case IMAGE_CUE: cdio = cdio_open_cue(source_name); if (cdio==NULL) { - err_exit("%s: Error in opening cue/bin with input\n", - program_name); + err_exit("Error in opening cue/bin file %s with input\n", + source_name); } break; case IMAGE_NRG: cdio = cdio_open (source_name, DRIVER_NRG); if (cdio==NULL) { - err_exit("%s: Error in opening NRG with input\n", - program_name); + err_exit("Error in opening NRG file %s for input\n", + source_name); } break; } + if (opts.access_mode!=NULL) { + cdio_set_arg(cdio, "access-mode", opts.access_mode); + } + + if (opts.output_file!=NULL) { + output_fd = open(opts.output_file, O_WRONLY|O_CREAT|O_TRUNC, 0644); + if (-1 == output_fd) { + err_exit("Error opening output file %s: %s\n", + opts.output_file, strerror(errno)); + + } + } + for ( ; opts.start_lsn <= opts.end_lsn; opts.start_lsn++ ) { switch (opts.read_mode) { @@ -453,9 +484,15 @@ main(int argc, const char *argv[]) break; } - hexdump(buffer, blocklen); + if (opts.output_file) { + write(output_fd, buffer, blocklen); + } else { + hexdump(buffer, blocklen); + } } + if (opts.output_file) close(output_fd); + cdio_destroy(cdio); return 0; } diff --git a/test/cdda.right b/test/cdda.right index 0d2f841d..48d63b0a 100644 --- a/test/cdda.right +++ b/test/cdda.right @@ -6,7 +6,7 @@ CD-ROM Track List (1 - 1) #: MSF LSN Type 1: 00:02:00 000000 audio 170: 00:06:02 000302 leadout -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report Audio CD, CDDB disc ID is 02000401 diff --git a/test/check_opts0.right b/test/check_opts0.right index 05faba49..c4693160 100644 --- a/test/check_opts0.right +++ b/test/check_opts0.right @@ -1,7 +1,7 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/check_opts1.right b/test/check_opts1.right index 05faba49..c4693160 100644 --- a/test/check_opts1.right +++ b/test/check_opts1.right @@ -1,7 +1,7 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/check_opts2.right b/test/check_opts2.right index c9a3ddc7..05951f8f 100644 --- a/test/check_opts2.right +++ b/test/check_opts2.right @@ -6,4 +6,4 @@ CD-ROM Track List (1 - 1) #: MSF LSN Type 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout -Get MCN : not available +Media Catalog Number (MCN): not available diff --git a/test/check_opts3.right b/test/check_opts3.right index c9a3ddc7..05951f8f 100644 --- a/test/check_opts3.right +++ b/test/check_opts3.right @@ -6,4 +6,4 @@ CD-ROM Track List (1 - 1) #: MSF LSN Type 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout -Get MCN : not available +Media Catalog Number (MCN): not available diff --git a/test/check_opts4.right b/test/check_opts4.right index 54d2e136..ea03c139 100644 --- a/test/check_opts4.right +++ b/test/check_opts4.right @@ -6,7 +6,7 @@ CD-ROM Track List (1 - 1) #: MSF LSN Type 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/check_opts5.right b/test/check_opts5.right index 54d2e136..ea03c139 100644 --- a/test/check_opts5.right +++ b/test/check_opts5.right @@ -6,7 +6,7 @@ CD-ROM Track List (1 - 1) #: MSF LSN Type 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/check_opts6.right b/test/check_opts6.right index 54d2e136..ea03c139 100644 --- a/test/check_opts6.right +++ b/test/check_opts6.right @@ -6,7 +6,7 @@ CD-ROM Track List (1 - 1) #: MSF LSN Type 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/check_opts7.right b/test/check_opts7.right index 54d2e136..ea03c139 100644 --- a/test/check_opts7.right +++ b/test/check_opts7.right @@ -6,7 +6,7 @@ CD-ROM Track List (1 - 1) #: MSF LSN Type 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/isofs-m1.right b/test/isofs-m1.right index d52794b7..3d73d017 100644 --- a/test/isofs-m1.right +++ b/test/isofs-m1.right @@ -6,7 +6,7 @@ CD-ROM Track List (1 - 1) #: MSF LSN Type 1: 00:02:00 000000 data 170: 00:06:02 000302 leadout -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/monvoisin.right b/test/monvoisin.right index ddfa3aa3..161c4d97 100644 --- a/test/monvoisin.right +++ b/test/monvoisin.right @@ -7,7 +7,7 @@ CD-ROM Track List (1 - 2) 1: 00:02:00 000000 XA 2: 00:18:51 001251 XA 170: 00:39:71 002846 leadout -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem diff --git a/test/svcd_ogt_test_ntsc.right b/test/svcd_ogt_test_ntsc.right index a342bc64..f80e3cd7 100644 --- a/test/svcd_ogt_test_ntsc.right +++ b/test/svcd_ogt_test_ntsc.right @@ -7,7 +7,7 @@ CD-ROM Track List (1 - 2) 1: 00:02:00 000000 XA 2: 00:09:01 000526 XA 170: 00:56:56 004106 leadout -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem diff --git a/test/svcdgs.right b/test/svcdgs.right index 4b939f07..448df46c 100644 --- a/test/svcdgs.right +++ b/test/svcdgs.right @@ -7,7 +7,7 @@ CD-ROM Track List (1 - 2) 1: 00:02:00 000000 XA 2: 00:22:53 001553 XA 170: 01:17:62 005687 leadout -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/vcd_demo.right b/test/vcd_demo.right index 9a141028..4fcb2f2c 100644 --- a/test/vcd_demo.right +++ b/test/vcd_demo.right @@ -8,7 +8,7 @@ CD-ROM Track List (1 - 3) 2: 00:17:57 001182 XA 3: 00:24:71 001721 XA 170: 00:30:10 002110 leadout -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem diff --git a/test/videocd.right b/test/videocd.right index 0f5c9e5b..b487560f 100644 --- a/test/videocd.right +++ b/test/videocd.right @@ -10,7 +10,7 @@ CD-ROM Track List (1 - 5) 4: 00:19:01 001276 XA 5: 00:22:01 001501 XA 170: 00:25:01 001726 leadout -Get MCN : not available +Media Catalog Number (MCN): not available __________________________________ CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem