diff --git a/include/cdio/cdio.h b/include/cdio/cdio.h index 423060ae..08466236 100644 --- a/include/cdio/cdio.h +++ b/include/cdio/cdio.h @@ -1,5 +1,5 @@ /* -*- c -*- - $Id: cdio.h,v 1.41 2004/04/24 11:48:37 rocky Exp $ + $Id: cdio.h,v 1.42 2004/04/25 00:46:34 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -51,32 +51,6 @@ #define CDIO_SRC_IS_SCSI_MASK 0x0004 /**< Read source SCSI device. */ #define CDIO_SRC_IS_NATIVE_MASK 0x0008 -/*! - \brief Drive types returned by cdio_get_drive_cap() - */ -#define CDIO_DRIVE_ERROR 0x0000 /**< Error */ -#define CDIO_DRIVE_UNKNOWN 0x0001 /**< Dunno. It can be on if we - have only partial information or - are not completely certain - */ -#define CDIO_DRIVE_CD_AUDIO 0x100 /**< drive can play CD audio */ -#define CDIO_DRIVE_CD_R 0x2000 /**< drive can write CD-R */ -#define CDIO_DRIVE_CD_RW 0x4000 /**< drive can write CD-RW */ -#define CDIO_DRIVE_DVD 0x8000 /**< drive can read DVD */ -#define CDIO_DRIVE_DVD_R 0x10000 /**< drive can write DVD-R */ -#define CDIO_DRIVE_DVD_RAM 0x20000 /**< drive can write DVD-RAM */ -#define CDIO_DRIVE_FILE 0x80000 /**< drive is really a file, i.e a - CD file image */ - -#define CDIO_DRIVE_CD_WRITER (CDIO_DRIVE_CD_R|CDIO_DRIVE_CD_RW) -/**< Has some sort of CD writer ability */ - -#define CDIO_DRIVE_CD (CDIO_DRIVE_CD_AUDIO|CDIO_DRIVE_CD_WRITER) -/**< Has some sort of CD ability */ - -#define CDIO_DRIVE_DVD_WRITER (CDIO_DRIVE_DVD_R|CDIO_DRIVE_DVD_RAM) -/**< Has some sort of DVD writer ability */ - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/include/cdio/types.h b/include/cdio/types.h index 9b2c1f38..580499ad 100644 --- a/include/cdio/types.h +++ b/include/cdio/types.h @@ -1,5 +1,5 @@ /* - $Id: types.h,v 1.11 2004/04/22 03:24:38 rocky Exp $ + $Id: types.h,v 1.12 2004/04/25 00:46:34 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004 Rocky Bernstein @@ -216,9 +216,6 @@ extern "C" { /*! The type of an track number 0..99. */ typedef uint8_t track_t; - /*! The type of an Logical Sector Number. */ - typedef uint32_t cdio_drive_cap_t; - /*! Constant for invalid track number */ @@ -236,6 +233,57 @@ extern "C" { typedef int cdio_fs_anal_t; +/*! The type of an drive capability bit mask. See below for values*/ + typedef uint32_t cdio_drive_cap_t; + +/*! + \brief Drive types returned by cdio_get_drive_cap() + + Most are copied from the GNU/Linux the uniform CD-ROM driver header + linux/cdrom.h> NOTE: Setting a bit here means the presence of + a capability. +*/ + +#define CDIO_DRIVE_CLOSE_TRAY 0x00001 /**< caddy systems _can't_ close */ +#define CDIO_DRIVE_OPEN_TRAY 0x00002 /**< but _can_ eject. */ +#define CDIO_DRIVE_LOCK 0x00004 /**< disable manual eject */ +#define CDIO_DRIVE_SELECT_SPEED 0x00008 /**< programmable speed */ +#define CDIO_DRIVE_SELECT_DISC 0x00010 /**< select disc from juke-box */ +#define CDIO_DRIVE_MULTI_SESSION 0x00020 /**< read sessions>1 */ +#define CDIO_DRIVE_MCN 0x00040 /**< Medium Catalog Number */ +#define CDIO_DRIVE_MEDIA_CHANGED 0x00080 /**< media changed */ +#define CDIO_DRIVE_CD_AUDIO 0x00100 /**< drive can play CD audio */ +#define CDIO_DRIVE_RESET 0x00200 /**< hard reset device */ +#define CDIO_DRIVE_IOCTLS 0x00400 /**< driver has non-standard + ioctls */ +#define CDIO_DRIVE_DRIVE_STATUS 0x00800 /**< driver implements drive + status */ +#define CDIO_DRIVE_GENERIC_PACKET 0x01000 /**< driver implements generic + packets */ +#define CDIO_DRIVE_CD_R 0x02000 /**< drive can write CD-R */ +#define CDIO_DRIVE_CD_RW 0x04000 /**< drive can write CD-RW */ +#define CDIO_DRIVE_DVD 0x08000 /**< drive can read DVD */ +#define CDIO_DRIVE_DVD_R 0x10000 /**< drive can write DVD-R */ +#define CDIO_DRIVE_DVD_RAM 0x20000 /**< drive can write DVD-RAM */ + +/**< These are not taken by GNU/Linux cdrom.h (yet) */ +#define CDIO_DRIVE_ERROR 0x00000 /**< Error */ +#define CDIO_DRIVE_FILE 0x40000 /**< drive is really a file, i.e a + CD file image */ +#define CDIO_DRIVE_UNKNOWN 0x80000 /**< Dunno. It can be on if we + have only partial information + or are not completely certain + */ +/**< Masks derived from above... */ +#define CDIO_DRIVE_CD_WRITER (CDIO_DRIVE_CD_R|CDIO_DRIVE_CD_RW) +/**< Has some sort of CD writer ability */ + +#define CDIO_DRIVE_CD (CDIO_DRIVE_CD_AUDIO|CDIO_DRIVE_CD_WRITER) +/**< Has some sort of CD ability */ + +#define CDIO_DRIVE_DVD_WRITER (CDIO_DRIVE_DVD_R|CDIO_DRIVE_DVD_RAM) +/**< Has some sort of DVD writer ability */ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lib/MSWindows/ioctl.c b/lib/MSWindows/ioctl.c index 346f56b8..ce94c467 100644 --- a/lib/MSWindows/ioctl.c +++ b/lib/MSWindows/ioctl.c @@ -1,5 +1,5 @@ /* - $Id: ioctl.c,v 1.8 2004/04/24 19:15:34 rocky Exp $ + $Id: ioctl.c,v 1.9 2004/04/25 00:46:34 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -26,7 +26,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: ioctl.c,v 1.8 2004/04/24 19:15:34 rocky Exp $"; +static const char _rcsid[] = "$Id: ioctl.c,v 1.9 2004/04/25 00:46:34 rocky Exp $"; #include #include @@ -497,6 +497,9 @@ win32ioctl_get_drive_cap (const void *env) if (sptwb.DataBuf[n+3] & 0x01) i_drivetype |= CDIO_DRIVE_CD_R; if (sptwb.DataBuf[n+3] & 0x10) i_drivetype |= CDIO_DRIVE_DVD_R; if (sptwb.DataBuf[n+3] & 0x20) i_drivetype |= CDIO_DRIVE_DVD_RAM; + + if (sptwb.DataBuf[n+6] & 0x08) i_drivetype |= CDIO_DRIVE_OPEN_TRAY; + if (sptwb.DataBuf[n+6] >> 5 != 0) i_drivetype |= CDIO_DRIVE_CLOSE_TRAY; return i_drivetype; } else { diff --git a/lib/cdio.c b/lib/cdio.c index 32a3b20a..6c41b550 100644 --- a/lib/cdio.c +++ b/lib/cdio.c @@ -1,5 +1,5 @@ /* - $Id: cdio.c,v 1.45 2004/04/23 22:10:52 rocky Exp $ + $Id: cdio.c,v 1.46 2004/04/25 00:46:34 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein Copyright (C) 2001 Herbert Valerio Riedel @@ -37,7 +37,7 @@ #include #include "cdio_private.h" -static const char _rcsid[] = "$Id: cdio.c,v 1.45 2004/04/23 22:10:52 rocky Exp $"; +static const char _rcsid[] = "$Id: cdio.c,v 1.46 2004/04/25 00:46:34 rocky Exp $"; const char *track_format2str[6] = @@ -138,7 +138,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = { {DRIVER_WIN32, CDIO_SRC_IS_DEVICE_MASK|CDIO_SRC_IS_NATIVE_MASK|CDIO_SRC_IS_SCSI_MASK, "WIN32", - "Windows 32-bit ASPI and winNT/2K/XP ioctl driver", + "MS Windows ASPI and ioctl driver", &cdio_have_win32, &cdio_open_win32, &cdio_get_default_device_win32, diff --git a/lib/image/bincue.c b/lib/image/bincue.c index 724bc27d..a78f7c45 100644 --- a/lib/image/bincue.c +++ b/lib/image/bincue.c @@ -1,5 +1,5 @@ /* - $Id: bincue.c,v 1.11 2004/04/23 02:18:07 rocky Exp $ + $Id: bincue.c,v 1.12 2004/04/25 00:46:34 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004 Rocky Bernstein @@ -24,7 +24,7 @@ (*.cue). */ -static const char _rcsid[] = "$Id: bincue.c,v 1.11 2004/04/23 02:18:07 rocky Exp $"; +static const char _rcsid[] = "$Id: bincue.c,v 1.12 2004/04/25 00:46:34 rocky Exp $"; #include "cdio_assert.h" #include "cdio_private.h" @@ -742,6 +742,23 @@ cdio_get_default_device_bincue(void) return drive; } +/*! + Return the the kind of drive capabilities of device. + + Note: string is malloc'd so caller should free() then returned + string when done with it. + + */ +static cdio_drive_cap_t +_cdio_bincue_get_drive_cap (const void *env) { + + /* There may be more in the future but these we can handle now. + Also, we know we can't handle + LOCK, OPEN_TRAY, CLOSE_TRAY, SELECT_SPEED, SELECT_DISC + */ + return CDIO_DRIVE_FILE | CDIO_DRIVE_MCN | CDIO_DRIVE_CD_AUDIO ; +} + /*! Return the number of tracks in the current medium. CDIO_INVALID_TRACK is returned on error. @@ -895,7 +912,7 @@ cdio_open_cue (const char *cue_name) .free = _cdio_bincue_destroy, .get_arg = _cdio_get_arg, .get_default_device = cdio_get_default_device_bincue, - .get_drive_cap = _cdio_image_get_drive_cap, + .get_drive_cap = _cdio_bincue_get_drive_cap, .get_first_track_num= _cdio_image_get_first_track_num, .get_mcn = _cdio_image_get_mcn, .get_num_tracks = _cdio_image_get_num_tracks, diff --git a/lib/image/nrg.c b/lib/image/nrg.c index 54575d56..35dd0dbb 100644 --- a/lib/image/nrg.c +++ b/lib/image/nrg.c @@ -1,5 +1,5 @@ /* - $Id: nrg.c,v 1.6 2004/04/23 02:18:07 rocky Exp $ + $Id: nrg.c,v 1.7 2004/04/25 00:46:34 rocky Exp $ Copyright (C) 2001, 2003 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -48,7 +48,7 @@ #include "cdio_private.h" #include "_cdio_stdio.h" -static const char _rcsid[] = "$Id: nrg.c,v 1.6 2004/04/23 02:18:07 rocky Exp $"; +static const char _rcsid[] = "$Id: nrg.c,v 1.7 2004/04/25 00:46:34 rocky Exp $"; /* structures used */ @@ -1076,6 +1076,23 @@ cdio_get_default_device_nrg(void) return drive; } +/*! + Return the the kind of drive capabilities of device. + + Note: string is malloc'd so caller should free() then returned + string when done with it. + + */ +static cdio_drive_cap_t +_cdio_nrg_get_drive_cap (const void *env) { + + /* There may be more in the future but these we can handle now. + Also, we know we can't handle + LOCK, OPEN_TRAY, CLOSE_TRAY, SELECT_SPEED, SELECT_DISC + */ + return CDIO_DRIVE_FILE | CDIO_DRIVE_MCN | CDIO_DRIVE_CD_AUDIO ; +} + /*! Return the number of tracks in the current medium. CDIO_INVALID_TRACK is returned on error. @@ -1134,7 +1151,7 @@ cdio_open_nrg (const char *source_name) .get_arg = _cdio_get_arg, .get_devices = cdio_get_devices_nrg, .get_default_device = cdio_get_default_device_nrg, - .get_drive_cap = _cdio_image_get_drive_cap, + .get_drive_cap = _cdio_nrg_get_drive_cap, .get_first_track_num= _cdio_image_get_first_track_num, .get_mcn = _cdio_image_get_mcn, .get_num_tracks = _cdio_image_get_num_tracks, diff --git a/lib/image_common.h b/lib/image_common.h index bb1e1f8e..e7dcd5ea 100644 --- a/lib/image_common.h +++ b/lib/image_common.h @@ -1,5 +1,5 @@ /* - $Id: image_common.h,v 1.1 2004/04/23 02:18:07 rocky Exp $ + $Id: image_common.h,v 1.2 2004/04/25 00:46:34 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -20,24 +20,6 @@ /* Common image routines. */ -/*! - Return the the kind of drive capabilities of device. - - Note: string is malloc'd so caller should free() then returned - string when done with it. - - */ -static cdio_drive_cap_t -_cdio_image_get_drive_cap (const void *env) { - const _img_private_t *_obj = env; - - if (_obj->gen.fd < 0 ) - return CDIO_DRIVE_UNKNOWN; - else - return CDIO_DRIVE_FILE; - -} - /*! Return the media catalog number (MCN) from the CD or NULL if there is none or we don't have the ability to get it. diff --git a/src/Makefile.am b/src/Makefile.am index 8037e14e..57b3b875 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.21 2004/02/28 12:45:02 rocky Exp $ +# $Id: Makefile.am,v 1.22 2004/04/25 00:46:34 rocky Exp $ # # Copyright (C) 2003 Rocky Bernstein # @@ -23,7 +23,7 @@ CDDB_LIBS=@CDDB_LIBS@ if MAINTAINER_MODE MAINTAINERCLEANFILES = $(man_MANS) -man_MANS = cd-info.1 cd-read.1 iso-read.1 iso-info.1 +man_MANS = cd-drive.1 cd-info.1 cd-read.1 iso-read.1 iso-info.1 $(man_MANS): %.1: % -$(HELP2MAN) --output=$@ ./$< endif @@ -32,6 +32,9 @@ if BUILD_CDINFO cd_info_SOURCES = cd-info.c util.c util.h cd_info_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(CDDB_LIBS) $(VCDINFO_LIBS) +cd_drive_SOURCES = cd-drive.c util.c util.h +cd_drive_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) + cd_read_SOURCES = cd-read.c util.c util.h cd_read_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) @@ -44,13 +47,13 @@ iso_read_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) if BUILD_CDINFO_LINUX cdinfo_linux_SOURCES = cdinfo-linux.c cdinfo_linux_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) -bin_PROGRAMS = cd-info cd-read cdinfo-linux iso-info iso-read +bin_PROGRAMS = cd-drive cd-info cd-read cdinfo-linux iso-info iso-read else -bin_PROGRAMS = cd-info cd-read iso-info iso-read +bin_PROGRAMS = cd-drive cd-info cd-read iso-info iso-read EXTRA_DIST = cdinfo-linux.c $(man_MANS) endif else -EXTRA_DIST = cdinfo-linux.c cd-info.c cd-read.c $(man_MANS) +EXTRA_DIST = cdinfo-linux.c cd-drive.c cd-info.c cd-read.c $(man_MANS) man_MANS = endif diff --git a/src/cd-drive.c b/src/cd-drive.c new file mode 100644 index 00000000..bc7b2d0d --- /dev/null +++ b/src/cd-drive.c @@ -0,0 +1,252 @@ +/* + $Id: cd-drive.c,v 1.1 2004/04/25 00:46:34 rocky Exp $ + + Copyright (C) 2004 Rocky Bernstein + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* Program to show drivers installed and capibilites of CD drives. */ + +#include "util.h" + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#include + +/* Used by `main' to communicate with `parse_opt'. And global options + */ +struct arguments +{ + uint32_t debug_level; + int version_only; + int silent; + source_image_t source_image; +} opts; + +/* Configuration option codes */ +enum { + OP_SOURCE_DEVICE, + + /* These are the remaining configuration options */ + OP_VERSION, + +}; + +/* Parse a all options. */ +static bool +parse_options (int argc, const char *argv[]) +{ + int opt; + + struct poptOption optionsTable[] = { + {"debug", 'd', POPT_ARG_INT, &opts.debug_level, 0, + "Set debugging to LEVEL"}, + + {"cdrom-device", 'i', POPT_ARG_STRING|POPT_ARGFLAG_OPTIONAL, + &source_name, OP_SOURCE_DEVICE, + "show only info about CD-ROM device", "DEVICE"}, + + {"quiet", 'q', POPT_ARG_NONE, &opts.silent, 0, + "Don't produce warning output" }, + + {"version", 'V', POPT_ARG_NONE, &opts.version_only, 0, + "display version and copyright information and exit"}, + POPT_AUTOHELP {NULL, 0, 0, NULL, 0} + }; + poptContext optCon = poptGetContext (NULL, argc, argv, optionsTable, 0); + + program_name = strrchr(argv[0],'/'); + program_name = program_name ? strdup(program_name+1) : strdup(argv[0]); + + while ((opt = poptGetNextOpt (optCon)) != -1) { + switch (opt) { + + case OP_SOURCE_DEVICE: + if (opts.source_image != IMAGE_UNKNOWN) { + fprintf(stderr, + "%s: another source type option given before.\n", + program_name); + fprintf(stderr, "%s: give only one source type option.\n", + program_name); + break; + } else { + opts.source_image = IMAGE_DEVICE; + source_name = fillout_device_name(source_name); + break; + } + break; + + default: + poptFreeContext(optCon); + return false; + } + } + { + const char *remaining_arg = poptGetArg(optCon); + if ( remaining_arg != NULL) { + if (opts.source_image != IMAGE_UNKNOWN) { + fprintf (stderr, + "%s: Source specified in option %s and as %s\n", + program_name, source_name, remaining_arg); + poptFreeContext(optCon); + free(program_name); + exit (EXIT_FAILURE); + } + + if (opts.source_image == IMAGE_DEVICE) + source_name = fillout_device_name(remaining_arg); + else + source_name = strdup(remaining_arg); + + if ( (poptGetArgs(optCon)) != NULL) { + fprintf (stderr, + "%s: Source specified in previously %s and %s\n", + program_name, source_name, remaining_arg); + poptFreeContext(optCon); + free(program_name); + exit (EXIT_FAILURE); + + } + } + } + + poptFreeContext(optCon); + return true; +} + +/* CDIO logging routines */ + +static cdio_log_handler_t gl_default_cdio_log_handler = NULL; + +static void +_log_handler (cdio_log_level_t level, const char message[]) +{ + if (level == CDIO_LOG_DEBUG && opts.debug_level < 2) + return; + + if (level == CDIO_LOG_INFO && opts.debug_level < 1) + return; + + if (level == CDIO_LOG_WARN && opts.silent) + return; + + gl_default_cdio_log_handler (level, message); +} + +/* Initialize global variables. */ +static void +init(void) +{ + gl_default_cdio_log_handler = cdio_log_set_handler (_log_handler); + + /* Default option values. */ + opts.silent = false; + opts.debug_level = 0; + opts.source_image = IMAGE_UNKNOWN; +} + +int +main(int argc, const char *argv[]) +{ + CdIo *cdio=NULL; + + init(); + + /* Parse our arguments; every option seen by `parse_opt' will + be reflected in `arguments'. */ + parse_options(argc, argv); + + print_version(program_name, VERSION, false, opts.version_only); + + if (opts.debug_level == 3) { + cdio_loglevel_default = CDIO_LOG_INFO; + } else if (opts.debug_level >= 4) { + cdio_loglevel_default = CDIO_LOG_DEBUG; + } + + if (NULL == source_name) { + char *default_device; + + cdio = cdio_open (NULL, DRIVER_UNKNOWN); + default_device = cdio_get_default_device(cdio); + + printf("The driver selected is %s\n", cdio_get_driver_name(cdio)); + + if (default_device) { + printf("The default device for this driver is %s\n", default_device); + } + + free(default_device); + cdio_destroy(cdio); + cdio=NULL; + printf("\n"); + } + + /* Print out a drivers available */ + { + driver_id_t driver_id; + + printf("Drivers available...\n"); + for (driver_id=CDIO_MIN_DRIVER; driver_id<=CDIO_MAX_DRIVER; driver_id++) + printf(" %-35s: %s\n", + cdio_driver_describe(driver_id), + cdio_have_driver(driver_id) ? "Yes" : "No"); + printf("\n\n"); + } + + + if (NULL == source_name) { + /* Print out a list of CD-drives */ + + char **cd_drives=NULL, **cd; + + cd_drives = cdio_get_devices(DRIVER_DEVICE); + if (NULL != cd_drives) + for( cd = cd_drives; *cd != NULL; cd++ ) { + cdio_drive_cap_t i_drive_cap = cdio_get_drive_cap_dev(*cd); + + printf("Drive %s\n", *cd); + print_drive_capabilities(i_drive_cap); + printf("\n"); + } + + cdio_free_device_list(cd_drives); + free(cd_drives); + cd_drives = NULL; + } else { + /* Print CD-drive info for given source */ + + cdio_drive_cap_t i_drive_cap = cdio_get_drive_cap_dev(source_name); + + printf("Drive %s\n", source_name); + print_drive_capabilities(i_drive_cap); + printf("\n"); + } + + myexit(cdio, EXIT_SUCCESS); + /* Not reached:*/ + return(EXIT_SUCCESS); +} diff --git a/src/cd-info.c b/src/cd-info.c index ae5c7d00..8390f1ee 100644 --- a/src/cd-info.c +++ b/src/cd-info.c @@ -1,5 +1,5 @@ /* - $Id: cd-info.c,v 1.57 2004/04/24 19:16:57 rocky Exp $ + $Id: cd-info.c,v 1.58 2004/04/25 00:46:34 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein Copyright (C) 1996, 1997, 1998 Gerd Knorr @@ -779,42 +779,43 @@ 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("%s: Error in automatically selecting driver for input %s\n", + program_name, source_name); } 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("%s: Error in automatically selecting device for input %s\n", + program_name, source_name); } 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("%s: Error in opening bin/cue for input %s\n", + program_name, 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("%s: Error in opening cue/bin with input %s\n", + program_name, 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("%s: Error in opening NRG with input %s\n", + program_name, source_name); } break; } if (cdio==NULL) { - err_exit("%s: Error in opening device driver\n", program_name); + err_exit("%s: Error in opening device driver for input %s\n", + program_name, source_name); } if (source_name==NULL) { @@ -826,37 +827,12 @@ main(int argc, const char *argv[]) if (opts.silent == 0) { printf("CD location : %s\n", source_name); - printf("CD driver name: %s\n", cdio_get_driver_name(cdio)); + printf("CD driver name: %s\n\n", cdio_get_driver_name(cdio)); } { cdio_drive_cap_t i_drive_cap = cdio_get_drive_cap(cdio); - if (CDIO_DRIVE_ERROR == i_drive_cap) { - printf("Error in getting drive properties\n"); - } else { - if (CDIO_DRIVE_FILE == i_drive_cap) { - printf("Disc-image file\n"); - } else { - printf("Compact Disc : %s\n", - i_drive_cap & CDIO_DRIVE_CD ? "Yes" : "No"); - printf(" Can play audio : %s\n", - i_drive_cap & CDIO_DRIVE_CD_AUDIO ? "Yes" : "No"); - printf(" Can read CD-RW : %s\n", - i_drive_cap & CDIO_DRIVE_CD_RW ? "Yes" : "No"); - printf(" Can write CD-R : %s\n\n", - i_drive_cap & CDIO_DRIVE_CD_R ? "Yes" : "No"); - - printf("Digital Versital Disc: %s\n", - i_drive_cap & CDIO_DRIVE_DVD ? "Yes" : "No"); - printf(" Can write DVD-R : %s\n", - i_drive_cap & CDIO_DRIVE_DVD_R ? "Yes" : "No"); - printf(" Can write DVD-RAM : %s\n", - i_drive_cap & CDIO_DRIVE_DVD_RAM ? "Yes" : "No"); - } - if (CDIO_DRIVE_UNKNOWN == i_drive_cap) { - printf("Not sure about drive properties\n\n"); - } - } + print_drive_capabilities(i_drive_cap); } if (opts.list_drives) { diff --git a/src/util.c b/src/util.c index d0b90ef5..09024842 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,5 @@ /* - $Id: util.c,v 1.4 2004/02/07 02:40:20 rocky Exp $ + $Id: util.c,v 1.5 2004/04/25 00:46:34 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -86,3 +86,37 @@ fillout_device_name(const char *device_name) #endif } +/* Prints out drive capabilities */ +void +print_drive_capabilities(cdio_drive_cap_t i_drive_cap) +{ + if (CDIO_DRIVE_ERROR == i_drive_cap) { + printf("Error in getting drive properties\n"); + } else { + printf("Hardware : %s\n", + i_drive_cap & CDIO_DRIVE_FILE ? "Disk Image" : "CD-ROM/DVD"); + printf("Can open tray : %s\n", + i_drive_cap & CDIO_DRIVE_OPEN_TRAY ? "Yes" : "No"); + printf("Can close tray : %s\n\n", + i_drive_cap & CDIO_DRIVE_OPEN_TRAY ? "Yes" : "No"); + + printf("Compact Disc : %s\n", + i_drive_cap & CDIO_DRIVE_CD ? "Yes" : "No"); + printf(" Can play audio : %s\n", + i_drive_cap & CDIO_DRIVE_CD_AUDIO ? "Yes" : "No"); + printf(" Can read CD-RW : %s\n", + i_drive_cap & CDIO_DRIVE_CD_RW ? "Yes" : "No"); + printf(" Can write CD-R : %s\n\n", + i_drive_cap & CDIO_DRIVE_CD_R ? "Yes" : "No"); + + printf("Digital Versital Disc: %s\n", + i_drive_cap & CDIO_DRIVE_DVD ? "Yes" : "No"); + printf(" Can write DVD-R : %s\n", + i_drive_cap & CDIO_DRIVE_DVD_R ? "Yes" : "No"); + printf(" Can write DVD-RAM : %s\n", + i_drive_cap & CDIO_DRIVE_DVD_RAM ? "Yes" : "No"); + } + if (CDIO_DRIVE_UNKNOWN == i_drive_cap) { + printf("Not completely sure about drive properties\n\n"); + } +} diff --git a/src/util.h b/src/util.h index 9bedd2b2..bd90bb28 100644 --- a/src/util.h +++ b/src/util.h @@ -1,7 +1,7 @@ /* - $Id: util.h,v 1.2 2004/02/07 02:40:20 rocky Exp $ + $Id: util.h,v 1.3 2004/04/25 00:46:34 rocky Exp $ - Copyright (C) 2003 Rocky Bernstein + Copyright (C) 2003, 2004 Rocky Bernstein 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 @@ -99,4 +99,7 @@ void print_version (char *program_name, const char *version, char *fillout_device_name(const char *device_name); +/* Prints out drive capabilities */ +void print_drive_capabilities(cdio_drive_cap_t i_drive_cap); + #endif /* UTIL_H */ diff --git a/test/cdda.right b/test/cdda.right index d2a9cc2b..d0565b78 100644 --- a/test/cdda.right +++ b/test/cdda.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 1) #: MSF LSN Type Green? diff --git a/test/check_opts0.right b/test/check_opts0.right index 27a24859..38dfe29a 100644 --- a/test/check_opts0.right +++ b/test/check_opts0.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No Media Catalog Number (MCN): 0000010271955 __________________________________ CD Analysis Report diff --git a/test/check_opts1.right b/test/check_opts1.right index 27a24859..38dfe29a 100644 --- a/test/check_opts1.right +++ b/test/check_opts1.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No Media Catalog Number (MCN): 0000010271955 __________________________________ CD Analysis Report diff --git a/test/check_opts2.right b/test/check_opts2.right index eb6a09b6..e641f68e 100644 --- a/test/check_opts2.right +++ b/test/check_opts2.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 1) #: MSF LSN Type Green? diff --git a/test/check_opts3.right b/test/check_opts3.right index eb6a09b6..e641f68e 100644 --- a/test/check_opts3.right +++ b/test/check_opts3.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 1) #: MSF LSN Type Green? diff --git a/test/check_opts4.right b/test/check_opts4.right index 3983760c..ac645c52 100644 --- a/test/check_opts4.right +++ b/test/check_opts4.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 1) #: MSF LSN Type Green? diff --git a/test/check_opts5.right b/test/check_opts5.right index 3983760c..ac645c52 100644 --- a/test/check_opts5.right +++ b/test/check_opts5.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 1) #: MSF LSN Type Green? diff --git a/test/check_opts6.right b/test/check_opts6.right index 3983760c..ac645c52 100644 --- a/test/check_opts6.right +++ b/test/check_opts6.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 1) #: MSF LSN Type Green? diff --git a/test/check_opts7.right b/test/check_opts7.right index 3983760c..ac645c52 100644 --- a/test/check_opts7.right +++ b/test/check_opts7.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 1) #: MSF LSN Type Green? diff --git a/test/isofs-m1.right b/test/isofs-m1.right index 194006e0..8afb6280 100644 --- a/test/isofs-m1.right +++ b/test/isofs-m1.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 1) #: MSF LSN Type Green? diff --git a/test/monvoisin.right b/test/monvoisin.right index 60181314..c9626cfe 100644 --- a/test/monvoisin.right +++ b/test/monvoisin.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 2) #: MSF LSN Type Green? diff --git a/test/svcd_ogt_test_ntsc.right b/test/svcd_ogt_test_ntsc.right index aa44f4b1..479c4bcf 100644 --- a/test/svcd_ogt_test_ntsc.right +++ b/test/svcd_ogt_test_ntsc.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 2) #: MSF LSN Type Green? diff --git a/test/svcdgs.right b/test/svcdgs.right index 327d282c..8e5d4bf1 100644 --- a/test/svcdgs.right +++ b/test/svcdgs.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 2) #: MSF LSN Type Green? diff --git a/test/vcd_demo.right b/test/vcd_demo.right index 28bf5f39..ea9efdcf 100644 --- a/test/vcd_demo.right +++ b/test/vcd_demo.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 3) #: MSF LSN Type Green? diff --git a/test/vcd_demo_vcdinfo.right b/test/vcd_demo_vcdinfo.right index 73facb39..5fc69e1b 100644 --- a/test/vcd_demo_vcdinfo.right +++ b/test/vcd_demo_vcdinfo.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 3) #: MSF LSN Type Green? diff --git a/test/videocd.right b/test/videocd.right index 3f1800da..3033af1b 100644 --- a/test/videocd.right +++ b/test/videocd.right @@ -1,7 +1,18 @@ This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -Disc-image file +Hardware : Disk Image +Can open tray : No +Can close tray : No + +Compact Disc : Yes + Can play audio : Yes + Can read CD-RW : No + Can write CD-R : No + +Digital Versital Disc: No + Can write DVD-R : No + Can write DVD-RAM : No __________________________________ CD-ROM Track List (1 - 5) #: MSF LSN Type Green?