summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Merten Lohse <leon@green-side.de>2012-03-27 17:46:43 +0200
committerLeon Merten Lohse <leon@green-side.de>2012-03-27 17:46:43 +0200
commit662c41ef60169d003c6de37455639e10cacb3f29 (patch)
treee45c6dbefce2c6c472c8c44ee3c3fd578c945527
parent3940726aa77d102096117fb2f47aa2bb41c8abdc (diff)
parentb052c43389f8e028211595d6f352200f7c30149a (diff)
Merge branch 'master' of ssh://git.sv.gnu.org/srv/git/libcdio
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am3
-rw-r--r--README8
-rw-r--r--README.libcdio20
-rw-r--r--example/Makefile.am45
-rw-r--r--include/cdio/sector.h2
-rw-r--r--lib/driver/gnu_linux.c13
-rw-r--r--lib/driver/track.c60
-rw-r--r--src/util.c4
-rwxr-xr-xtest/Makefile.am2
-rw-r--r--test/check_opts0.right2
-rw-r--r--test/check_opts1.right2
-rw-r--r--test/check_opts2.right2
-rw-r--r--test/check_opts3.right2
-rw-r--r--test/check_opts4.right2
-rw-r--r--test/check_opts5.right2
-rw-r--r--test/check_opts6.right2
-rw-r--r--test/check_opts7.right2
-rw-r--r--test/data/isofs-m1.cue1
-rw-r--r--test/driver/Makefile.am4
-rw-r--r--test/driver/gnu_linux.c12
-rw-r--r--test/driver/helper.c74
-rw-r--r--test/driver/helper.h17
23 files changed, 224 insertions, 59 deletions
diff --git a/.gitignore b/.gitignore
index 6b98b435..dd9ba4a2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,9 +16,9 @@
/depcomp
/install-sh
/libcdio++.pc
+/libcdio-*.sig
/libcdio-*.tar.bz2
/libcdio-*.tar.gz
-/libcdio-*.sig
/libcdio.pc
/libcdio_cdda.pc
/libiso9660++.pc
diff --git a/Makefile.am b/Makefile.am
index 0f00df16..4df3808f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2003, 2004, 2006, 2008, 2011
+# Copyright (C) 2003, 2004, 2006, 2008, 2011, 2012
# Rocky Bernstein <rocky@gnu.org>
#
# This program is free software: you can redistribute it and/or modify
@@ -116,7 +116,6 @@ check_iso.sh: $(top_builddir)/config.status check_iso.sh.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
chmod +x config_iso.sh
-# cvs2cl
MAINTAINERCLEANFILES = ChangeLog *.rej *.orig
if MAINTAINER_MODE
diff --git a/README b/README
index a3d27324..b5ee7004 100644
--- a/README
+++ b/README
@@ -9,9 +9,11 @@ A library for working with ISO-9660 filesystems libiso9660 is
included. A generic interface for issuing MMC (multimedia commands) is
also part of the libcdio library.
-Also included is a library for working with ISO-9660 filesystems as is
-also the CD-DA error/jitter correction library from cdparanoia
-(http://www.xiph.org/paranoia).
+Also included is a library for working with ISO-9660 filesystems.
+
+The CD-DA error/jitter correction library from cdparanoia
+(http://www.xiph.org/paranoia) is included as a separate library
+licenced under GPL v2.
Some support for disk image types like CDRWin's BIN/CUE format,
cdrdao's TOC format, and Nero's NRG format are available. Therefore,
diff --git a/README.libcdio b/README.libcdio
index b69cc461..7d718a3f 100644
--- a/README.libcdio
+++ b/README.libcdio
@@ -62,16 +62,16 @@ an optional dependency on libcdio).
Microsoft Windows
-------
-The building under Microsoft Windows the thing to do is to install
-cygwin (http://www.cygwin.com). It has been reported that MinGW
-(http://www.mingw.org/) also works, but it is possible you may
-encounter more problems there.
-
-Folks may have used Microsoft compilers (e.g. Visual C), but you may
-find you need to make your own "project" files. Don't undertake this
-unless you are willing to spend time hacking. xboxmediacenter team
-folks I believe go this route, so you may be able to use their project
-files as a starting point.
+Building under Microsoft Windows is supported for cygwin
+(http://www.cygwin.com). MinGW (http://www.mingw.org/) may also work,
+but it is possible you may encounter problems there.
+
+Support for Microsoft compilers (e.g. Visual C) is not officially
+supported. You need to make your own "project" files. Don't
+undertake this unless you are willing to spend time hacking. In the
+past xboxmediacenter team folks I believe have gone this route, as has
+Pete Batard in his rufus project. You may be able to use their project
+files as a starting point.
XBOX
-------
diff --git a/example/Makefile.am b/example/Makefile.am
index 3afa284c..2782dfa4 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -21,14 +21,36 @@
if ENABLE_CPP
SUBDIRS = C++
endif
-if BUILD_EXAMPLES
-noinst_PROGRAMS = audio cdchange cdio-eject cdtext device discid drives eject \
- extract isofile isofile2 isofuzzy isolist isolsn \
- mmc1 mmc2 mmc2a mmc3 \
- sample3 sample4 tracks udf1 udffile
-endif
-INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS)
+noinst_PROGRAMS = \
+ audio \
+ cdchange \
+ cdio-eject \
+ cdtext \
+ device \
+ discid \
+ drives \
+ eject \
+ extract \
+ isofile \
+ isofile2 \
+ isofuzzy \
+ isolist \
+ isolsn \
+ mmc1 \
+ mmc2 \
+ mmc2a \
+ mmc3 \
+ sample3 \
+ sample4 \
+ tracks \
+ udf1 \
+ udffile
+
+check_PROGRAMS = cdtext device drives \
+ mmc1 mmc2 mmc2a mmc3 sample4
+
+INCLUDES = $(LIBCDIO_CFLAGS)
audio_DEPENDENCIES = $(LIBCDIO_DEPS)
audio_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
@@ -36,6 +58,9 @@ audio_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
cdchange_DEPENDENCIES = $(LIBCDIO_DEPS)
cdchange_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
+cdio_eject_DEPENDENCIES = $(LIBCDIO_DEPS)
+cdio_eject_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
+
cdtext_DEPENDENCIES = $(LIBCDIO_DEPS)
cdtext_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
@@ -54,9 +79,6 @@ eject_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
extract_DEPENDENCIES = $(LIBISO9660_LIBS) $(LIBUDF_LIBS) $(LIBCDIO_DEPS)
extract_LDADD = $(LIBISO9660_LIBS) $(LIBUDF_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
-cdio_eject_DEPENDENCIES = $(LIBCDIO_DEPS)
-cdio_eject_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
-
isofile_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
isofile2_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
isofuzzy_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
@@ -89,9 +111,6 @@ udf1_LDADD = $(LIBUDF_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
udffile_DEPENDENCIES = $(LIBUDF_LIBS) $(LIBCDIO_DEPS)
udffile_LDADD = $(LIBUDF_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
-check_PROGRAMS = cdtext device drives \
- mmc1 mmc2 mmc2a mmc3 sample4
-
TESTS = $(check_PROGRAMS)
# iso programs create file "copying"
diff --git a/include/cdio/sector.h b/include/cdio/sector.h
index 86857159..c26fbd10 100644
--- a/include/cdio/sector.h
+++ b/include/cdio/sector.h
@@ -153,7 +153,7 @@
#define CDIO_CD_FRAMESIZE_RAW 2352 /**< bytes per frame, "raw" mode */
#define CDIO_CD_FRAMESIZE_RAWER 2646 /**< The maximum possible returned
bytes */
-#define CDIO_CD_FRAMESIZE_RAW1 (CDIO_CD_CD_FRAMESIZE_RAW-CDIO_CD_SYNC_SIZE) /*2340*/
+#define CDIO_CD_FRAMESIZE_RAW1 (CDIO_CD_FRAMESIZE_RAW-CDIO_CD_SYNC_SIZE) /*2340*/
#define CDIO_CD_FRAMESIZE_RAW0 (CDIO_CD_FRAMESIZE_RAW-CDIO_CD_SYNC_SIZE-CDIO_CD_HEADER_SIZE) /*2336*/
/*! "before data" part of raw XA (green, mode2) frame */
diff --git a/lib/driver/gnu_linux.c b/lib/driver/gnu_linux.c
index d8b88533..6e4b050a 100644
--- a/lib/driver/gnu_linux.c
+++ b/lib/driver/gnu_linux.c
@@ -1,7 +1,7 @@
/*
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011
- Rocky Bernstein <rocky@gnu.org>
+ 2012 Rocky Bernstein <rocky@gnu.org>
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
@@ -601,7 +601,9 @@ get_track_msf_linux(void *p_user_data, track_t i_track, msf_t *msf)
{
_img_private_t *p_env = p_user_data;
- if (NULL == msf) return false;
+ if (NULL == msf ||
+ (i_track > CDIO_CD_MAX_TRACKS && i_track != CDIO_CDROM_LEADOUT_TRACK))
+ return false;
if (!p_env->gen.toc_init) read_toc_linux (p_user_data) ;
@@ -1179,6 +1181,13 @@ read_toc_linux (void *p_user_data)
p_env->gen.i_first_track = p_env->tochdr.cdth_trk0;
p_env->gen.i_tracks = p_env->tochdr.cdth_trk1;
+ if (p_env->gen.i_tracks > CDIO_CD_MAX_TRACKS) {
+ cdio_log(CDIO_LOG_WARN, "Number of tracks exceeds maximum (%d vs. %d)\n",
+ p_env->gen.i_tracks, CDIO_CD_MAX_TRACKS);
+ p_env->gen.i_tracks = CDIO_CD_MAX_TRACKS;
+ }
+
+
/* read individual tracks */
for (i= p_env->gen.i_first_track; i<=p_env->gen.i_tracks; i++) {
struct cdrom_tocentry *p_toc =
diff --git a/lib/driver/track.c b/lib/driver/track.c
index 31fd423f..da03d93f 100644
--- a/lib/driver/track.c
+++ b/lib/driver/track.c
@@ -1,5 +1,6 @@
/*
- Copyright (C) 2003, 2004, 2005, 2008, 2011 Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 2003, 2004, 2005, 2008, 2011, 2012
+ Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software: you can redistribute it and/or modify
@@ -20,10 +21,10 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
-# define __CDIO_CONFIG_H__ 1
#endif
#include <cdio/cdio.h>
+#include <cdio/logging.h>
#include "cdio_private.h"
const char *track_format2str[6] =
@@ -39,9 +40,13 @@ enum cdio_track_enums;
CDIO_INVALID_TRACK is returned on error.
*/
track_t
-cdio_get_first_track_num (const CdIo_t *p_cdio)
+cdio_get_first_track_num(const CdIo_t *p_cdio)
{
- if (NULL == p_cdio) return CDIO_INVALID_TRACK;
+ if (NULL == p_cdio) {
+ cdio_info("Null CdIo object passed\n");
+ return CDIO_INVALID_TRACK;
+ }
+
if (p_cdio->op.get_first_track_num) {
return p_cdio->op.get_first_track_num (p_cdio->env);
@@ -57,7 +62,11 @@ cdio_get_first_track_num (const CdIo_t *p_cdio)
track_t
cdio_get_last_track_num (const CdIo_t *p_cdio)
{
- if (NULL == p_cdio) return CDIO_INVALID_TRACK;
+ if (NULL == p_cdio) {
+ cdio_info("Null CdIo object passed\n");
+ return CDIO_INVALID_TRACK;
+ }
+
{
const track_t i_first_track = cdio_get_first_track_num(p_cdio);
if ( CDIO_INVALID_TRACK != i_first_track ) {
@@ -76,6 +85,15 @@ cdio_get_last_track_num (const CdIo_t *p_cdio)
int
cdio_get_track_channels(const CdIo_t *p_cdio, track_t i_track)
{
+ if (NULL == p_cdio) {
+ cdio_info("Null CdIo object passed\n");
+ return -1;
+ }
+ if (i_track > CDIO_CD_MAX_TRACKS) {
+ cdio_log(CDIO_LOG_WARN, "Number of tracks exceeds maximum (%d vs. %d)\n",
+ i_track, CDIO_CD_MAX_TRACKS);
+ return -1;
+ }
if (p_cdio->op.get_track_channels) {
return p_cdio->op.get_track_channels (p_cdio->env, i_track);
} else {
@@ -209,7 +227,10 @@ cdio_get_track_green(const CdIo_t *p_cdio, track_t i_track)
lba_t
cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track)
{
- if (!p_cdio) return CDIO_INVALID_LBA;
+ if (NULL == p_cdio) {
+ cdio_info("Null CdIo object passed\n");
+ return CDIO_INVALID_LBA;
+ }
if (p_cdio->op.get_track_lba) {
return p_cdio->op.get_track_lba (p_cdio->env, i_track);
@@ -232,7 +253,16 @@ cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track)
lsn_t
cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track)
{
- if (p_cdio == NULL) return CDIO_INVALID_LSN;
+ if (NULL == p_cdio) {
+ cdio_info("Null CdIo object passed\n");
+ return CDIO_INVALID_LSN;
+ }
+ if (i_track > CDIO_CD_MAX_TRACKS && i_track != CDIO_CDROM_LEADOUT_TRACK) {
+ cdio_log(CDIO_LOG_WARN, "Number of tracks exceeds maximum (%d vs. %d)\n",
+ i_track, CDIO_CD_MAX_TRACKS);
+ return CDIO_INVALID_LSN;
+ }
+
if (p_cdio->op.get_track_lba) {
return cdio_lba_to_lsn(p_cdio->op.get_track_lba (p_cdio->env, i_track));
@@ -254,7 +284,16 @@ cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track)
char *
cdio_get_track_isrc (const CdIo_t *p_cdio, track_t i_track)
{
- if (p_cdio == NULL) return NULL;
+ if (NULL == p_cdio) {
+ cdio_info("Null CdIo object passed\n");
+ return NULL;
+ }
+
+ if (i_track > CDIO_CD_MAX_TRACKS) {
+ cdio_log(CDIO_LOG_WARN, "Number of tracks exceeds maximum (%d vs. %d)\n",
+ i_track, CDIO_CD_MAX_TRACKS);
+ return NULL;
+ }
if (p_cdio->op.get_track_isrc) {
return p_cdio->op.get_track_isrc (p_cdio->env, i_track);
@@ -271,7 +310,10 @@ cdio_get_track_isrc (const CdIo_t *p_cdio, track_t i_track)
lba_t
cdio_get_track_pregap_lba(const CdIo_t *p_cdio, track_t i_track)
{
- if (p_cdio == NULL) return CDIO_INVALID_LBA;
+ if (NULL == p_cdio) {
+ cdio_info("Null CdIo object passed\n");
+ return CDIO_INVALID_LBA;
+ }
if (p_cdio->op.get_track_pregap_lba) {
return p_cdio->op.get_track_pregap_lba (p_cdio->env, i_track);
diff --git a/src/util.c b/src/util.c
index 32896138..6285990a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -56,7 +56,9 @@ print_version (char *program_name, const char *version,
if (no_header == 0) {
report( stdout,
- "%s version %s\nCopyright (c) 2003, 2004, 2005, 2007, 2008, 2011 R. Bernstein\n",
+ "%s version %s\n"
+ "Copyright (c) 2003, 2004, 2005, 2007, 2008, 2011, 2012 "
+ "R. Bernstein\n",
program_name, version);
report( stdout,
_("This is free software; see the source for copying conditions.\n\
diff --git a/test/Makefile.am b/test/Makefile.am
index 5c6d267a..6a7eef1d 100755
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -31,7 +31,7 @@ hack = check_sizeof testassert testgetdevices testischar \
EXTRA_PROGRAMS = testdefault
DATA_DIR = @abs_top_srcdir@/test/data
-INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS) $(LIBISO9660_CFLAGS)
+INCLUDES = $(LIBCDIO_CFLAGS) $(LIBISO9660_CFLAGS)
check_sizeof_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
testassert_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
diff --git a/test/check_opts0.right b/test/check_opts0.right
index f5e163fc..5b6d6873 100644
--- a/test/check_opts0.right
+++ b/test/check_opts0.right
@@ -1,7 +1,7 @@
__________________________________
Disc mode is listed as: CD-DATA (Mode 1)
-Media Catalog Number (MCN): not available
+Media Catalog Number (MCN): 0000012101954
Last CD Session LSN: not supported by drive/driver
__________________________________
CD Analysis Report
diff --git a/test/check_opts1.right b/test/check_opts1.right
index f5e163fc..5b6d6873 100644
--- a/test/check_opts1.right
+++ b/test/check_opts1.right
@@ -1,7 +1,7 @@
__________________________________
Disc mode is listed as: CD-DATA (Mode 1)
-Media Catalog Number (MCN): not available
+Media Catalog Number (MCN): 0000012101954
Last CD Session LSN: not supported by drive/driver
__________________________________
CD Analysis Report
diff --git a/test/check_opts2.right b/test/check_opts2.right
index c4712945..6477819f 100644
--- a/test/check_opts2.right
+++ b/test/check_opts2.right
@@ -5,5 +5,5 @@ CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? Copy?
1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
-Media Catalog Number (MCN): not available
+Media Catalog Number (MCN): 0000012101954
Last CD Session LSN: not supported by drive/driver
diff --git a/test/check_opts3.right b/test/check_opts3.right
index c4712945..6477819f 100644
--- a/test/check_opts3.right
+++ b/test/check_opts3.right
@@ -5,5 +5,5 @@ CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? Copy?
1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
-Media Catalog Number (MCN): not available
+Media Catalog Number (MCN): 0000012101954
Last CD Session LSN: not supported by drive/driver
diff --git a/test/check_opts4.right b/test/check_opts4.right
index e4977f34..aed4e947 100644
--- a/test/check_opts4.right
+++ b/test/check_opts4.right
@@ -5,7 +5,7 @@ CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? Copy?
1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
-Media Catalog Number (MCN): not available
+Media Catalog Number (MCN): 0000012101954
Last CD Session LSN: not supported by drive/driver
__________________________________
CD Analysis Report
diff --git a/test/check_opts5.right b/test/check_opts5.right
index e4977f34..aed4e947 100644
--- a/test/check_opts5.right
+++ b/test/check_opts5.right
@@ -5,7 +5,7 @@ CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? Copy?
1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
-Media Catalog Number (MCN): not available
+Media Catalog Number (MCN): 0000012101954
Last CD Session LSN: not supported by drive/driver
__________________________________
CD Analysis Report
diff --git a/test/check_opts6.right b/test/check_opts6.right
index e4977f34..aed4e947 100644
--- a/test/check_opts6.right
+++ b/test/check_opts6.right
@@ -5,7 +5,7 @@ CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? Copy?
1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
-Media Catalog Number (MCN): not available
+Media Catalog Number (MCN): 0000012101954
Last CD Session LSN: not supported by drive/driver
__________________________________
CD Analysis Report
diff --git a/test/check_opts7.right b/test/check_opts7.right
index e4977f34..aed4e947 100644
--- a/test/check_opts7.right
+++ b/test/check_opts7.right
@@ -5,7 +5,7 @@ CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? Copy?
1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
-Media Catalog Number (MCN): not available
+Media Catalog Number (MCN): 0000012101954
Last CD Session LSN: not supported by drive/driver
__________________________________
CD Analysis Report
diff --git a/test/data/isofs-m1.cue b/test/data/isofs-m1.cue
index 677a803f..bead774e 100644
--- a/test/data/isofs-m1.cue
+++ b/test/data/isofs-m1.cue
@@ -1,3 +1,4 @@
+CATALOG 0000012101954
FILE "ISOFS-M1.BIN" BINARY
TRACK 01 MODE1/2352
INDEX 01 00:00:00
diff --git a/test/driver/Makefile.am b/test/driver/Makefile.am
index f8f4f9e4..6f8b12c0 100644
--- a/test/driver/Makefile.am
+++ b/test/driver/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2009, 2010 Rocky Bernstein <rocky@gnu.org>
+# Copyright (C) 2009, 2010, 2012 Rocky Bernstein <rocky@gnu.org>
#
# 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
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS) $(LIBISO9660_CFLAGS)
+INCLUDES = $(LIBCDIO_CFLAGS) $(LIBISO9660_CFLAGS)
DATA_DIR = $(abs_top_srcdir)/test/data
abs_path_SOURCES = abs_path.c
diff --git a/test/driver/gnu_linux.c b/test/driver/gnu_linux.c
index fdf998e5..f4571b3e 100644
--- a/test/driver/gnu_linux.c
+++ b/test/driver/gnu_linux.c
@@ -36,8 +36,6 @@
#include <string.h>
#endif
-#include <cdio/cdio.h>
-#include <cdio/logging.h>
#include "helper.h"
int
@@ -46,6 +44,7 @@ main(int argc, const char *argv[])
CdIo_t *p_cdio;
char **ppsz_drives=NULL;
+ cdio_log_set_handler(log_handler);
cdio_loglevel_default = (argc > 1) ? CDIO_LOG_DEBUG : CDIO_LOG_INFO;
/* snprintf(psz_nrgfile, sizeof(psz_nrgfile)-1,
"%s/%s", TEST_DIR, cue_file[i]);
@@ -60,7 +59,14 @@ main(int argc, const char *argv[])
p_cdio = cdio_open_linux(ppsz_drives[0]);
if (p_cdio) {
const char *psz_source = NULL, *psz_scsi_tuple;
-
+ lsn_t lsn;
+
+ reset_counts();
+ lsn = cdio_get_track_lsn(p_cdio, CDIO_CD_MAX_TRACKS+1);
+ assert_equal_int(CDIO_INVALID_LSN, lsn,
+ "cdio_get_track_lsn with too large of a track number");
+ reset_counts();
+
check_get_arg_source(p_cdio, ppsz_drives[0]);
check_mmc_supported(p_cdio, 3);
diff --git a/test/driver/helper.c b/test/driver/helper.c
index b000de40..37aecfb4 100644
--- a/test/driver/helper.c
+++ b/test/driver/helper.c
@@ -16,7 +16,6 @@
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
-#define __CDIO_CONFIG_H__ 1
#endif
#ifdef HAVE_STDIO_H
@@ -29,9 +28,51 @@
#include <stdlib.h>
#endif
-#include <cdio/cdio.h>
#include "helper.h"
+unsigned int info_msg_count=0;
+unsigned int debug_msg_count=0;
+unsigned int warn_msg_count=0;
+unsigned int error_msg_count=0;
+const char *info_messages[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
+const char *debug_messages[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
+const char *warn_messages[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
+const char *error_messages[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
+
+void
+assert_equal_int(int expect, int got, const char *msg)
+{
+ if (expect != got) {
+ fprintf(stderr, "ERROR: Expected %d, got %d\n", expect, got);
+ if (NULL != msg) fprintf(stderr, "%s\n", msg);
+ exit(1);
+ }
+}
+
+void
+assert_no_warn(const char *msg)
+{
+ if (warn_msg_count != 0) {
+ unsigned int i;
+ fprintf(stderr, "ERROR: got unexpected warnings:\n");
+ for (i=0; i<warn_msg_count; i++) {
+ fprintf(stderr, "%s\n", warn_messages[i]);
+ }
+ exit(1);
+ }
+}
+
+void
+assert_warn(const char *msg)
+{
+ if (warn_msg_count == 0) {
+ fprintf(stderr,
+ "ERROR: should have gotten a warning message:\n%s\n",
+ msg);
+ exit(1);
+ }
+}
+
void check_access_mode(CdIo_t *p_cdio, const char *psz_expected_access_mode)
{
const char *psz_access_mode = cdio_get_arg(p_cdio, "access-mode");
@@ -78,3 +119,32 @@ void check_mmc_supported(CdIo_t *p_cdio, int i_expected) {
exit(32);
}
}
+
+void
+log_handler(cdio_log_level_t level, const char message[])
+{
+ switch(level) {
+ case CDIO_LOG_DEBUG:
+ debug_messages[debug_msg_count] = message;
+ debug_msg_count++;
+ return;
+ case CDIO_LOG_INFO:
+ info_messages[info_msg_count] = message;
+ info_msg_count++;
+ return;
+ case CDIO_LOG_ERROR:
+ error_messages[info_msg_count] = message;
+ error_msg_count++;
+ return;
+ default:
+ warn_messages[warn_msg_count] = message;
+ warn_msg_count++;
+ return;
+ }
+}
+
+void
+reset_counts(void)
+{
+ info_msg_count = debug_msg_count = warn_msg_count = 0;
+}
diff --git a/test/driver/helper.h b/test/driver/helper.h
index 7483eefe..cffd303e 100644
--- a/test/driver/helper.h
+++ b/test/driver/helper.h
@@ -1,5 +1,5 @@
/* -*- C -*-
- Copyright (C) 2010 Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 2010, 2012 Rocky Bernstein <rocky@gnu.org>
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
@@ -14,8 +14,23 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
+#include <cdio/cdio.h>
+
void check_access_mode(CdIo_t *p_cdio, const char *psz_expected_access_mode);
void check_get_arg_source(CdIo_t *p_cdio, const char *psz_expected_source);
void check_mmc_supported(CdIo_t *p_cdio, int i_expected);
+#include <cdio/logging.h>
+void log_handler(cdio_log_level_t level, const char message[]);
+extern unsigned int info_msg_count;
+extern unsigned int debug_msg_count;
+extern unsigned int warn_msg_count;
+extern const char *info_messages[6];
+extern const char *debug_messages[6];
+extern const char *warn_messages[6];
+extern void assert_equal_int(int expect, int got, const char *msg);
+extern void reset_counts(void);
+extern void assert_warn(const char *msg);
+extern void assert_no_warn(const char *msg);