diff --git a/src/Makefile.am b/src/Makefile.am index 8efb1f4f..298fc26f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.16 2003/09/21 04:21:39 rocky Exp $ +# $Id: Makefile.am,v 1.17 2003/09/22 01:00:10 rocky Exp $ # # Copyright (C) 2003 Rocky Bernstein # @@ -22,6 +22,7 @@ CDDB_LIBS=@CDDB_LIBS@ if BUILD_CDINFO +man_MANS = cd-info.1 cd-read.1 cd_info_SOURCES = cd-info.c util.c util.h cd_info_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(CDDB_LIBS) $(VCDINFO_LIBS) @@ -34,11 +35,15 @@ cdinfo_linux_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) bin_PROGRAMS = cd-info cd-read cdinfo-linux else bin_PROGRAMS = cd-info cd-read -EXTRA_DIST = cdinfo-linux.c +EXTRA_DIST = cdinfo-linux.c $(man_MANS) endif else -EXTRA_DIST = cdinfo-linux.c cd-info.c cd-read.c +EXTRA_DIST = cdinfo-linux.c cd-info.c cd-read.c $(man_MANS) +man_MANS = endif INCLUDES = -I$(top_srcdir) $(LIBPOPT_CFLAGS) $(LIBCDIO_CFLAGS) $(VCDINFO_CFLAGS) - +if MAINTAINER_MODE +$(man_MANS): %.1: % + -$(HELP2MAN) --output=$@ ./$< +endif diff --git a/src/cd-read.c b/src/cd-read.c index 834a2699..3a3c1248 100644 --- a/src/cd-read.c +++ b/src/cd-read.c @@ -1,5 +1,5 @@ /* - $Id: cd-read.c,v 1.6 2003/09/21 18:43:36 rocky Exp $ + $Id: cd-read.c,v 1.7 2003/09/22 01:00:10 rocky Exp $ Copyright (C) 2003 Rocky Bernstein @@ -297,10 +297,29 @@ parse_options (int argc, const char *argv[]) } /* Check consistency between start_lsn, end_lsn and num_sectors. */ - if (opts.end_lsn == CDIO_INVALID_LSN) { - if (0 == opts.num_sectors) { - opts.num_sectors = 1; + + if (opts.start_lsn == CDIO_INVALID_LSN) { + /* Maybe we derive the start from the end and num sectors. */ + if (opts.end_lsn == CDIO_INVALID_LSN) { + /* No start or end LSN, so use 0 for the start */ + opts.start_lsn = 0; + if (opts.num_sectors == 0) opts.num_sectors = 1; + } else if (opts.num_sectors != 0) { + if (opts.end_lsn <= opts.num_sectors) { + fprintf(stderr, + "%s: end LSN (%d) needs to be greater than " + " the sector to read (%d)\n", + program_name, opts.end_lsn, opts.num_sectors); + exit(12); + } + opts.start_lsn = opts.end_lsn - opts.num_sectors + 1; } + } + + /* opts.start_lsn has been set somehow or we've aborted. */ + + if (opts.end_lsn == CDIO_INVALID_LSN) { + if (0 == opts.num_sectors) opts.num_sectors = 1; opts.end_lsn = opts.start_lsn + opts.num_sectors - 1; } else { /* We were given an end lsn. */ @@ -308,7 +327,7 @@ parse_options (int argc, const char *argv[]) fprintf(stderr, "%s: end LSN (%d) needs to be less than start LSN (%d)\n", program_name, opts.start_lsn, opts.end_lsn); - exit(12); + exit(13); } if (opts.num_sectors != opts.end_lsn - opts.start_lsn + 1) if (opts.num_sectors != 0) { @@ -316,12 +335,11 @@ parse_options (int argc, const char *argv[]) "%s: inconsistency between start LSN (%d), end (%d), " "and count (%d)\n", program_name, opts.start_lsn, opts.end_lsn, opts.num_sectors); - exit(13); + exit(14); } opts.num_sectors = opts.end_lsn - opts.start_lsn + 1; } - return true; } @@ -345,7 +363,7 @@ static void init(void) { opts.debug_level = 0; - opts.start_lsn = 0; + opts.start_lsn = CDIO_INVALID_LSN; opts.end_lsn = CDIO_INVALID_LSN; opts.num_sectors = 0; opts.read_mode = READ_MODE_UNINIT;