lib/*c, include/cdio/*.h: Add more drive capability info

util.{c,h}: common routine for printing capbilities
cd-info.c: use above.
*.right: update for capability display of above

cd-drive.c: new program to show drive capabilities
This commit is contained in:
rocky
2004-04-25 00:46:34 +00:00
parent dee62a7917
commit 52e0a80503
28 changed files with 609 additions and 124 deletions

View File

@@ -1,5 +1,5 @@
/* -*- c -*- /* -*- 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 <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -51,32 +51,6 @@
#define CDIO_SRC_IS_SCSI_MASK 0x0004 /**< Read source SCSI device. */ #define CDIO_SRC_IS_SCSI_MASK 0x0004 /**< Read source SCSI device. */
#define CDIO_SRC_IS_NATIVE_MASK 0x0008 #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 #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@@ -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 <hvr@gnu.org> Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -216,9 +216,6 @@ extern "C" {
/*! The type of an track number 0..99. */ /*! The type of an track number 0..99. */
typedef uint8_t track_t; typedef uint8_t track_t;
/*! The type of an Logical Sector Number. */
typedef uint32_t cdio_drive_cap_t;
/*! /*!
Constant for invalid track number Constant for invalid track number
*/ */
@@ -236,6 +233,57 @@ extern "C" {
typedef int cdio_fs_anal_t; 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 #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@@ -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 <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -26,7 +26,7 @@
# include "config.h" # include "config.h"
#endif #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 <cdio/cdio.h> #include <cdio/cdio.h>
#include <cdio/sector.h> #include <cdio/sector.h>
@@ -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] & 0x01) i_drivetype |= CDIO_DRIVE_CD_R;
if (sptwb.DataBuf[n+3] & 0x10) i_drivetype |= CDIO_DRIVE_DVD_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+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; return i_drivetype;
} else { } else {

View File

@@ -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 <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
@@ -37,7 +37,7 @@
#include <cdio/logging.h> #include <cdio/logging.h>
#include "cdio_private.h" #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] = const char *track_format2str[6] =
@@ -138,7 +138,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = {
{DRIVER_WIN32, {DRIVER_WIN32,
CDIO_SRC_IS_DEVICE_MASK|CDIO_SRC_IS_NATIVE_MASK|CDIO_SRC_IS_SCSI_MASK, CDIO_SRC_IS_DEVICE_MASK|CDIO_SRC_IS_NATIVE_MASK|CDIO_SRC_IS_SCSI_MASK,
"WIN32", "WIN32",
"Windows 32-bit ASPI and winNT/2K/XP ioctl driver", "MS Windows ASPI and ioctl driver",
&cdio_have_win32, &cdio_have_win32,
&cdio_open_win32, &cdio_open_win32,
&cdio_get_default_device_win32, &cdio_get_default_device_win32,

View File

@@ -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 <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -24,7 +24,7 @@
(*.cue). (*.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_assert.h"
#include "cdio_private.h" #include "cdio_private.h"
@@ -742,6 +742,23 @@ cdio_get_default_device_bincue(void)
return drive; 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. Return the number of tracks in the current medium.
CDIO_INVALID_TRACK is returned on error. CDIO_INVALID_TRACK is returned on error.
@@ -895,7 +912,7 @@ cdio_open_cue (const char *cue_name)
.free = _cdio_bincue_destroy, .free = _cdio_bincue_destroy,
.get_arg = _cdio_get_arg, .get_arg = _cdio_get_arg,
.get_default_device = cdio_get_default_device_bincue, .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_first_track_num= _cdio_image_get_first_track_num,
.get_mcn = _cdio_image_get_mcn, .get_mcn = _cdio_image_get_mcn,
.get_num_tracks = _cdio_image_get_num_tracks, .get_num_tracks = _cdio_image_get_num_tracks,

View File

@@ -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 <hvr@gnu.org> Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -48,7 +48,7 @@
#include "cdio_private.h" #include "cdio_private.h"
#include "_cdio_stdio.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 */ /* structures used */
@@ -1076,6 +1076,23 @@ cdio_get_default_device_nrg(void)
return drive; 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. Return the number of tracks in the current medium.
CDIO_INVALID_TRACK is returned on error. CDIO_INVALID_TRACK is returned on error.
@@ -1134,7 +1151,7 @@ cdio_open_nrg (const char *source_name)
.get_arg = _cdio_get_arg, .get_arg = _cdio_get_arg,
.get_devices = cdio_get_devices_nrg, .get_devices = cdio_get_devices_nrg,
.get_default_device = cdio_get_default_device_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_first_track_num= _cdio_image_get_first_track_num,
.get_mcn = _cdio_image_get_mcn, .get_mcn = _cdio_image_get_mcn,
.get_num_tracks = _cdio_image_get_num_tracks, .get_num_tracks = _cdio_image_get_num_tracks,

View File

@@ -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 <rocky@panix.com> Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -20,24 +20,6 @@
/* Common image routines. */ /* 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 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. is none or we don't have the ability to get it.

View File

@@ -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 <rocky@panix.com> # Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
# #
@@ -23,7 +23,7 @@ CDDB_LIBS=@CDDB_LIBS@
if MAINTAINER_MODE if MAINTAINER_MODE
MAINTAINERCLEANFILES = $(man_MANS) 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: % $(man_MANS): %.1: %
-$(HELP2MAN) --output=$@ ./$< -$(HELP2MAN) --output=$@ ./$<
endif endif
@@ -32,6 +32,9 @@ if BUILD_CDINFO
cd_info_SOURCES = cd-info.c util.c util.h cd_info_SOURCES = cd-info.c util.c util.h
cd_info_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) $(CDDB_LIBS) $(VCDINFO_LIBS) 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_SOURCES = cd-read.c util.c util.h
cd_read_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) cd_read_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS)
@@ -44,13 +47,13 @@ iso_read_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBPOPT_LIBS)
if BUILD_CDINFO_LINUX if BUILD_CDINFO_LINUX
cdinfo_linux_SOURCES = cdinfo-linux.c cdinfo_linux_SOURCES = cdinfo-linux.c
cdinfo_linux_LDADD = $(LIBCDIO_LIBS) $(LIBPOPT_LIBS) 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 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) EXTRA_DIST = cdinfo-linux.c $(man_MANS)
endif endif
else 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 = man_MANS =
endif endif

252
src/cd-drive.c Normal file
View File

@@ -0,0 +1,252 @@
/*
$Id: cd-drive.c,v 1.1 2004/04/25 00:46:34 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
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 <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio/cdio.h>
/* 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);
}

View File

@@ -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 <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org> Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
@@ -779,42 +779,43 @@ main(int argc, const char *argv[])
case IMAGE_AUTO: case IMAGE_AUTO:
cdio = cdio_open (source_name, DRIVER_UNKNOWN); cdio = cdio_open (source_name, DRIVER_UNKNOWN);
if (cdio==NULL) { if (cdio==NULL) {
err_exit("%s: Error in automatically selecting driver with input\n", err_exit("%s: Error in automatically selecting driver for input %s\n",
program_name); program_name, source_name);
} }
break; break;
case IMAGE_DEVICE: case IMAGE_DEVICE:
cdio = cdio_open (source_name, DRIVER_DEVICE); cdio = cdio_open (source_name, DRIVER_DEVICE);
if (cdio==NULL) { if (cdio==NULL) {
err_exit("%s: Error in automatically selecting device with input\n", err_exit("%s: Error in automatically selecting device for input %s\n",
program_name); program_name, source_name);
} }
break; break;
case IMAGE_BIN: case IMAGE_BIN:
cdio = cdio_open (source_name, DRIVER_BINCUE); cdio = cdio_open (source_name, DRIVER_BINCUE);
if (cdio==NULL) { if (cdio==NULL) {
err_exit("%s: Error in opeing bin/cue\n", err_exit("%s: Error in opening bin/cue for input %s\n",
program_name); program_name, source_name);
} }
break; break;
case IMAGE_CUE: case IMAGE_CUE:
cdio = cdio_open_cue(source_name); cdio = cdio_open_cue(source_name);
if (cdio==NULL) { if (cdio==NULL) {
err_exit("%s: Error in opening cue/bin with input\n", err_exit("%s: Error in opening cue/bin with input %s\n",
program_name); program_name, source_name);
} }
break; break;
case IMAGE_NRG: case IMAGE_NRG:
cdio = cdio_open (source_name, DRIVER_NRG); cdio = cdio_open (source_name, DRIVER_NRG);
if (cdio==NULL) { if (cdio==NULL) {
err_exit("%s: Error in opening NRG with input\n", err_exit("%s: Error in opening NRG with input %s\n",
program_name); program_name, source_name);
} }
break; break;
} }
if (cdio==NULL) { 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) { if (source_name==NULL) {
@@ -826,37 +827,12 @@ main(int argc, const char *argv[])
if (opts.silent == 0) { if (opts.silent == 0) {
printf("CD location : %s\n", source_name); 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); cdio_drive_cap_t i_drive_cap = cdio_get_drive_cap(cdio);
if (CDIO_DRIVE_ERROR == i_drive_cap) { print_drive_capabilities(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");
}
}
} }
if (opts.list_drives) { if (opts.list_drives) {

View File

@@ -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 <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -86,3 +86,37 @@ fillout_device_name(const char *device_name)
#endif #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");
}
}

View File

@@ -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 <rocky@panix.com> Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
This program is free software; you can redistribute it and/or modify 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 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); 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 */ #endif /* UTIL_H */

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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 Media Catalog Number (MCN): 0000010271955
__________________________________ __________________________________
CD Analysis Report CD Analysis Report

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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 Media Catalog Number (MCN): 0000010271955
__________________________________ __________________________________
CD Analysis Report CD Analysis Report

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 1)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 2)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 2)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 2)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 3)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 3)
#: MSF LSN Type Green? #: MSF LSN Type Green?

View File

@@ -1,7 +1,18 @@
This is free software; see the source for copying conditions. This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. 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) CD-ROM Track List (1 - 5)
#: MSF LSN Type Green? #: MSF LSN Type Green?