diff --git a/doc/libcdio.texi b/doc/libcdio.texi index 6ac97c95..0a48ca6a 100644 --- a/doc/libcdio.texi +++ b/doc/libcdio.texi @@ -46,7 +46,7 @@ development.'' @titlepage @title GNU libcdio library -@subtitle $Id: libcdio.texi,v 1.21 2004/04/25 17:19:50 rocky Exp $ +@subtitle $Id: libcdio.texi,v 1.22 2004/04/30 06:54:15 rocky Exp $ @author Rocky Bernstein et al. @page @@ -217,7 +217,9 @@ libcddb (@url{http://libcdddb.sourceforge.net}) is available, the @command{cd-info} program will display CDDB matches on CD-DA discs. And if a new enough version of libvcdinfo is available (from the vcdimager project), then @command{cd-info} shows basic VCD -information. +information. The command @command{cd-drive} shows what drivers are +available and some basic properties of cd-drives attached to the +system. (But media may have to be inserted in order to get this info.) Other utility programs in the libcdio package are @command{cd-read}, for performing low-level block reading of a CD or CD image, diff --git a/include/cdio/cdio.h b/include/cdio/cdio.h index b461431f..c024cd5e 100644 --- a/include/cdio/cdio.h +++ b/include/cdio/cdio.h @@ -1,5 +1,5 @@ /* -*- c -*- - $Id: cdio.h,v 1.43 2004/04/25 16:38:06 rocky Exp $ + $Id: cdio.h,v 1.44 2004/04/30 06:54:15 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -368,21 +368,40 @@ extern "C" { const char *cdio_driver_describe (driver_id_t driver_id); /*! Sets up to read from place specified by source_name and - driver_id This should be called before using any other routine, - except cdio_init. This will call cdio_init, if that hasn't been - done previously. to call one of the specific cdio_open_xxx - routines. + driver_id. This or cdio_open_* should be called before using any + other routine, except cdio_init. This will call cdio_init, if + that hasn't been done previously. to call one of the specific + cdio_open_xxx routines. NULL is returned on error. */ CdIo * cdio_open (const char *source_name, driver_id_t driver_id); + /*! Sets up to read from place specified by source_name, driver_id + and access mode. This or cdio_open should be called before using + any other routine, except cdio_init. This will call cdio_init, if + that hasn't been done previously. to call one of the specific + cdio_open_xxx routines. + + NULL is returned on error. + */ + CdIo * cdio_open_am (const char *psz_source_name, + driver_id_t driver_id, const char *psz_access_mode); + /*! Set up BIN/CUE CD disk-image for reading. Source is the .bin or .cue file NULL is returned on error. */ - CdIo * cdio_open_bincue (const char *bin_name); + CdIo * cdio_open_bincue (const char *psz_cue_name); + + /*! Set up BIN/CUE CD disk-image for reading. Source is the .bin or + .cue file + + NULL is returned on error. + */ + CdIo * cdio_open_am_bincue (const char *psz_cue_name, + const char *psz_access_mode); /*! Return a string containing the default CUE file that would be used when none is specified. @@ -413,7 +432,17 @@ extern "C" { @see cdio_open */ - CdIo * cdio_open_bsdi (const char *source_name); + CdIo * cdio_open_bsdi (const char *psz_source_name); + + /*! Set up CD-ROM for reading using the BSDI driver. The device_name is + the some sort of device name. + + NULL is returned on error or there is no BSDI driver. + + @see cdio_open + */ + CdIo * cdio_open_am_bsdi (const char *psz_source_name, + const char *psz_access_mode); /*! Return a string containing the default device name that the BSDI driver would use when none is specified. @@ -438,7 +467,18 @@ extern "C" { @see cdio_open_cd @see cdio_open */ - CdIo * cdio_open_freebsd (const char *source_name); + CdIo * cdio_open_freebsd (const char *paz_source_name); + + /*! Set up CD-ROM for reading using the FreeBSD driver. The device_name is + the some sort of device name. + + NULL is returned on error or there is no FreeBSD driver. + + @see cdio_open_cd + @see cdio_open + */ + CdIo * cdio_open_am_freebsd (const char *psz_source_name, + const char *psz_access_mode); /*! Return a string containing the default device name that the FreeBSD driver would use when none is specified. @@ -459,6 +499,14 @@ extern "C" { */ CdIo * cdio_open_linux (const char *source_name); + /*! Set up CD-ROM for reading using the GNU/Linux driver. The device_name is + the some sort of device name. + + NULL is returned on error or there is no GNU/Linux driver. + */ + CdIo * cdio_open_am_linux (const char *source_name, + const char *access_mode); + /*! Return a string containing the default device name that the GNU/Linux driver would use when none is specified. A scan is made for CD-ROM drives with CDs in them. @@ -482,6 +530,14 @@ extern "C" { */ CdIo * cdio_open_solaris (const char *source_name); + /*! Set up CD-ROM for reading using the Sun Solaris driver. The + device_name is the some sort of device name. + + NULL is returned on error or there is no Solaris driver. + */ + CdIo * cdio_open_am_solaris (const char *psz_source_name, + const char *psz_access_mode); + /*! Return a string containing the default device name that the Solaris driver would use when none is specified. A scan is made for CD-ROM drives with CDs in them. @@ -506,7 +562,18 @@ extern "C" { @see cdio_open_cd @see cdio_open */ - CdIo * cdio_open_osx (const char *source_name); + CdIo * cdio_open_osx (const char *psz_source_name); + + /*! Set up CD-ROM for reading using the Apple OSX driver. The + device_name is the some sort of device name. + + NULL is returned on error or there is no OSX driver. + + @see cdio_open_cd + @see cdio_open + */ + CdIo * cdio_open_am_osx (const char *psz_source_name, + const char *psz_access_mode); /*! Return a string containing the default device name that the OSX driver would use when none is specified. A scan is made @@ -528,6 +595,14 @@ extern "C" { */ CdIo * cdio_open_win32 (const char *source_name); + /*! Set up CD-ROM for reading using the Microsoft Windows driver. The + device_name is the some sort of device name. + + NULL is returned on error or there is no Microsof Windows driver. + */ + CdIo * cdio_open_am_win32 (const char *psz_source_name, + const char *psz_access_mode); + /*! Return a string containing the default device name that the Win32 driver would use when none is specified. A scan is made for CD-ROM drives with CDs in them. @@ -548,6 +623,14 @@ extern "C" { */ CdIo * cdio_open_nrg (const char *source_name); + /*! Set up CD-ROM for reading using the Nero driver. The + device_name is the some sort of device name. + + NULL is returned on error or there is no Nero driver. + */ + CdIo * cdio_open_am_nrg (const char *psz_source_name, + const char *psz_access_mode); + /*! Return a string containing the default device name that the NRG driver would use when none is specified. A scan is made for NRG disk images in the current directory.. diff --git a/lib/MSWindows/aspi32.c b/lib/MSWindows/aspi32.c index 6733bf7a..2aab265f 100644 --- a/lib/MSWindows/aspi32.c +++ b/lib/MSWindows/aspi32.c @@ -1,5 +1,5 @@ /* - $Id: aspi32.c,v 1.1 2004/03/05 12:32:45 rocky Exp $ + $Id: aspi32.c,v 1.2 2004/04/30 06:54:15 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: aspi32.c,v 1.1 2004/03/05 12:32:45 rocky Exp $"; +static const char _rcsid[] = "$Id: aspi32.c,v 1.2 2004/04/30 06:54:15 rocky Exp $"; #include #include @@ -205,19 +205,19 @@ wnaspi32_init_win32 (_img_private_t *env) if( HIBYTE( LOWORD ( dwSupportInfo ) ) == SS_NO_ADAPTERS ) { cdio_debug("no host adapters found (ASPI)"); FreeLibrary( hASPI ); - return -1; + return false; } if( HIBYTE( LOWORD ( dwSupportInfo ) ) != SS_COMP ) { cdio_debug("unable to initalize ASPI layer"); FreeLibrary( hASPI ); - return -1; + return false; } i_num_adapters = LOBYTE( LOWORD( dwSupportInfo ) ); if( i_num_adapters == 0 ) { FreeLibrary( hASPI ); - return -1; + return false; } c_drive = toupper(c_drive) - 'A'; @@ -258,8 +258,9 @@ wnaspi32_init_win32 (_img_private_t *env) env->i_sid = MAKEWORD( i, j ); env->hASPI = (long)hASPI; env->lpSendCommand = lpSendCommand; + env->b_aspi_init = true; cdio_debug("Using ASPI layer"); - + return true; } else { FreeLibrary( hASPI ); diff --git a/lib/MSWindows/ioctl.c b/lib/MSWindows/ioctl.c index 6a93920e..7e2d6731 100644 --- a/lib/MSWindows/ioctl.c +++ b/lib/MSWindows/ioctl.c @@ -1,5 +1,5 @@ /* - $Id: ioctl.c,v 1.10 2004/04/25 14:07:23 rocky Exp $ + $Id: ioctl.c,v 1.11 2004/04/30 06:54:15 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -26,7 +26,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: ioctl.c,v 1.10 2004/04/25 14:07:23 rocky Exp $"; +static const char _rcsid[] = "$Id: ioctl.c,v 1.11 2004/04/30 06:54:15 rocky Exp $"; #include #include @@ -334,6 +334,7 @@ win32ioctl_init_win32 (_img_private_t *env) NULL ); return (env->h_device_handle == NULL) ? false : true; } + env->b_ioctl_init = true; return true; } return false; diff --git a/lib/MSWindows/win32.c b/lib/MSWindows/win32.c index fd4d20b0..5b7c1d61 100644 --- a/lib/MSWindows/win32.c +++ b/lib/MSWindows/win32.c @@ -1,5 +1,5 @@ /* - $Id: win32.c,v 1.7 2004/04/24 19:13:10 rocky Exp $ + $Id: win32.c,v 1.8 2004/04/30 06:54:15 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -26,7 +26,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: win32.c,v 1.7 2004/04/24 19:13:10 rocky Exp $"; +static const char _rcsid[] = "$Id: win32.c,v 1.8 2004/04/30 06:54:15 rocky Exp $"; #include #include @@ -72,6 +72,24 @@ _cdio_mciSendCommand(int id, UINT msg, DWORD flags, void *arg) return(mci_error == 0); } +static access_mode_t +str_to_access_mode_linux(const char *psz_access_mode) +{ + const access_mode_t default_access_mode = + WIN_NT ? _AM_IOCTL : _AM_ASPI; + + if (NULL==psz_access_mode) return default_access_mode; + + if (!strcmp(psz_access_mode, "IOCTL")) + return _AM_IOCTL; + else if (!strcmp(psz_access_mode, "ASPI")) + return _AM_READ_CD; + cdio_warn ("unknown access type: %s. Default IOCTL used.", + psz_access_mode); + return default_access_mode; + } +} + static const char * cdio_is_cdrom(const char drive_letter) { if ( WIN_NT ) { @@ -117,10 +135,12 @@ _cdio_init_win32 (void *user_data) /* Initializations */ env->h_device_handle = NULL; - env->i_sid = 0; - env->hASPI = 0; - env->lpSendCommand = 0; - + env->i_sid = 0; + env->hASPI = 0; + env->lpSendCommand = 0; + env->b_aspi_init = false; + env->b_ioctl_init = false; + if ( WIN_NT ) { return win32ioctl_init_win32(env); } else { @@ -301,7 +321,7 @@ _cdio_stat_size (void *user_data) Set the key "arg" to "value" in source device. */ static int -_cdio_set_arg (void *user_data, const char key[], const char value[]) +_set_arg_win32 (void *user_data, const char key[], const char value[]) { _img_private_t *env = user_data; @@ -314,6 +334,10 @@ _cdio_set_arg (void *user_data, const char key[], const char value[]) env->gen.source_name = strdup (value); } + else if (!strcmp (key, "access-mode")) + { + return str_to_access_mode_linux(value); + } else return -1; @@ -388,7 +412,7 @@ _cdio_get_arg (void *user_data, const char key[]) if (env->hASPI) return "ASPI"; else if ( WIN_NT ) - return "winNT/2K/XP ioctl"; + return "IOCTL"; else return "undefined WIN32"; } @@ -627,6 +651,25 @@ cdio_is_device_win32(const char *source_name) CdIo * cdio_open_win32 (const char *source_name) { +#ifdef HAVE_WIN32_CDROM + if ( WIN_NT ) { + return cdio_open_am_win32(psz_source_name, "IOCTL"); + } else { + return cdio_open_am_win32(psz_source_name, "ASPI"); + } +#else + return NULL; +#endif /* HAVE_WIN32_CDROM */ +} + +/*! + Initialization routine. This is the only thing that doesn't + get called via a function pointer. In fact *we* are the + ones to set that up. + */ +CdIo * +cdio_open_am_win32 (const char *psz_source_name, const char *psz_access_mode) +{ #ifdef HAVE_WIN32_CDROM CdIo *ret; @@ -653,7 +696,7 @@ cdio_open_win32 (const char *source_name) .read_mode1_sectors = _cdio_read_mode1_sectors, .read_mode2_sector = _cdio_read_mode2_sector, .read_mode2_sectors = _cdio_read_mode2_sectors, - .set_arg = _cdio_set_arg, + .set_arg = _set_arg_win32, .stat_size = _cdio_stat_size }; @@ -661,8 +704,8 @@ cdio_open_win32 (const char *source_name) _data->gen.init = false; _data->gen.fd = -1; - _cdio_set_arg(_data, "source", (NULL == source_name) - ? cdio_get_default_device_win32(): source_name); + _set_arg_win32(_data, "source", (NULL == source_name) + ? cdio_get_default_device_win32(): source_name); ret = cdio_new (_data, &_funcs); if (ret == NULL) return NULL; diff --git a/lib/MSWindows/win32.h b/lib/MSWindows/win32.h index 01140b84..3a01d162 100644 --- a/lib/MSWindows/win32.h +++ b/lib/MSWindows/win32.h @@ -1,5 +1,5 @@ /* - $Id: win32.h,v 1.2 2004/04/24 04:46:33 rocky Exp $ + $Id: win32.h,v 1.3 2004/04/30 06:54:15 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -28,11 +28,23 @@ typedef struct { UCHAR Format; } track_info_t; +typedef enum { + _AM_NONE, + _AM_IOCTL, + _AM_READ_CD, + _AM_READ_10 +} access_mode_t; + typedef struct { /* Things common to all drivers like this. This must be first. */ generic_img_private_t gen; + access_mode_t access_mode; + + bool b_ioctl_init; + bool b_aspi_init; + HANDLE h_device_handle; /* device descriptor */ long hASPI; short i_sid; diff --git a/lib/_cdio_bsdi.c b/lib/_cdio_bsdi.c index 9ce94d97..9797db28 100644 --- a/lib/_cdio_bsdi.c +++ b/lib/_cdio_bsdi.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_bsdi.c,v 1.21 2004/04/25 17:05:07 rocky Exp $ + $Id: _cdio_bsdi.c,v 1.22 2004/04/30 06:54:15 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.21 2004/04/25 17:05:07 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.22 2004/04/30 06:54:15 rocky Exp $"; #include #include @@ -58,19 +58,19 @@ static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.21 2004/04/25 17:05:07 rocky #define TOTAL_TRACKS (_obj->tochdr.cdth_trk1) #define FIRST_TRACK_NUM (_obj->tochdr.cdth_trk0) +typedef enum { + _AM_NONE, + _AM_IOCTL, +} access_mode_t; + typedef struct { /* Things common to all drivers like this. This must be first. */ generic_img_private_t gen; - enum { - _AM_NONE, - _AM_IOCTL, - } access_mode; - char *source_name; - bool init; + access_mode_t access_mode; /* Track information */ bool toc_init; /* if true, info below is valid. */ @@ -684,6 +684,21 @@ cdio_get_default_device_bsdi(void) return strdup(DEFAULT_CDIO_DEVICE); } +/*! + Initialization routine. This is the only thing that doesn't + get called via a function pointer. In fact *we* are the + ones to set that up. + */ +CdIo * +cdio_open_am_bsdi (const char *psz_source_name, const char *psz_access_mode) +{ + if (psz_access_mode != NULL) + cdio_warn ("there is only one access mode for bsdi. Arg %s ignored", + psz_access_mode); + return cdio_open_bsdi(psz_source_name); +} + + /*! Initialization routine. This is the only thing that doesn't get called via a function pointer. In fact *we* are the diff --git a/lib/_cdio_freebsd.c b/lib/_cdio_freebsd.c index f085c1ba..fe645c61 100644 --- a/lib/_cdio_freebsd.c +++ b/lib/_cdio_freebsd.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_freebsd.c,v 1.24 2004/04/26 07:54:47 rocky Exp $ + $Id: _cdio_freebsd.c,v 1.25 2004/04/30 06:54:15 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_freebsd.c,v 1.24 2004/04/26 07:54:47 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_freebsd.c,v 1.25 2004/04/30 06:54:15 rocky Exp $"; #include #include @@ -60,16 +60,16 @@ static const char _rcsid[] = "$Id: _cdio_freebsd.c,v 1.24 2004/04/26 07:54:47 ro - _obj->tochdr.starting_track + 1) #define FIRST_TRACK_NUM (_obj->tochdr.starting_track) +typedef enum { + _AM_NONE, + _AM_IOCTL, +} access_mode_t; + typedef struct { /* Things common to all drivers like this. This must be first. */ generic_img_private_t gen; - enum { - _AM_NONE, - _AM_IOCTL, - } access_mode; - char *source_name; bool init; @@ -541,6 +541,21 @@ cdio_get_default_device_freebsd() return strdup(DEFAULT_CDIO_DEVICE); } +/*! + Initialization routine. This is the only thing that doesn't + get called via a function pointer. In fact *we* are the + ones to set that up. + */ +CdIo * +cdio_open_am_freebsd (const char *psz_source_name, const char *psz_access_mode) +{ + if (psz_access_mode != NULL) + cdio_warn ("there is only one access mode for freebsd. Arg %s ignored", + psz_access_mode); + return cdio_open_freebsd(psz_source_name); +} + + /*! Initialization routine. This is the only thing that doesn't get called via a function pointer. In fact *we* are the diff --git a/lib/_cdio_linux.c b/lib/_cdio_linux.c index 1de32ab7..214b81e2 100644 --- a/lib/_cdio_linux.c +++ b/lib/_cdio_linux.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_linux.c,v 1.39 2004/04/26 07:54:47 rocky Exp $ + $Id: _cdio_linux.c,v 1.40 2004/04/30 06:54:15 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.39 2004/04/26 07:54:47 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.40 2004/04/30 06:54:15 rocky Exp $"; #include @@ -70,17 +70,19 @@ static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.39 2004/04/26 07:54:47 rock #define TOTAL_TRACKS (_obj->tochdr.cdth_trk1) #define FIRST_TRACK_NUM (_obj->tochdr.cdth_trk0) +typedef enum { + _AM_NONE, + _AM_IOCTL, + _AM_READ_CD, + _AM_READ_10 +} access_mode_t; + typedef struct { /* Things common to all drivers like this. This must be first. */ generic_img_private_t gen; - enum { - _AM_NONE, - _AM_IOCTL, - _AM_READ_CD, - _AM_READ_10 - } access_mode; + access_mode_t access_mode; /* Track information */ struct cdrom_tochdr tochdr; @@ -92,6 +94,25 @@ typedef struct { #define ERRNO_TRAYEMPTY(errno) \ ((errno == EIO) || (errno == ENOENT) || (errno == EINVAL)) +static access_mode_t +str_to_access_mode_linux(const char *psz_access_mode) +{ + const access_mode_t default_access_mode = _AM_IOCTL; + + if (NULL==psz_access_mode) return default_access_mode; + + if (!strcmp(psz_access_mode, "IOCTL")) + return _AM_IOCTL; + else if (!strcmp(psz_access_mode, "READ_CD")) + return _AM_READ_CD; + else if (!strcmp(psz_access_mode, "READ_10")) + return _AM_READ_10; + else { + cdio_warn ("unknown access type: %s. Default IOCTL used.", + psz_access_mode); + return default_access_mode; + } +} /* Check a drive to see if it is a CD-ROM Return 1 if a CD-ROM. 0 if it exists but isn't a CD-ROM drive @@ -587,15 +608,7 @@ _set_arg_linux (void *env, const char key[], const char value[]) } else if (!strcmp (key, "access-mode")) { - if (!strcmp(value, "IOCTL")) - _obj->access_mode = _AM_IOCTL; - else if (!strcmp(value, "READ_CD")) - _obj->access_mode = _AM_READ_CD; - else if (!strcmp(value, "READ_10")) - _obj->access_mode = _AM_READ_10; - else { - cdio_warn ("unknown access type: %s. ignored.", value); - } + return str_to_access_mode_linux(value); } else return -1; @@ -1066,7 +1079,18 @@ cdio_get_default_device_linux(void) ones to set that up. */ CdIo * -cdio_open_linux (const char *orig_source_name) +cdio_open_linux (const char *psz_source_name) +{ + return cdio_open_am_linux(psz_source_name, NULL); +} + +/*! + Initialization routine. This is the only thing that doesn't + get called via a function pointer. In fact *we* are the + ones to set that up. + */ +CdIo * +cdio_open_am_linux (const char *orig_source_name, const char *access_mode) { #ifdef HAVE_LINUX_CDROM @@ -1100,7 +1124,8 @@ cdio_open_linux (const char *orig_source_name) }; _data = _cdio_malloc (sizeof (_img_private_t)); - _data->access_mode = _AM_READ_CD; + + _data->access_mode = str_to_access_mode_linux(access_mode); _data->gen.init = false; _data->gen.fd = -1; diff --git a/lib/_cdio_osx.c b/lib/_cdio_osx.c index 2d2545ff..2b6c2332 100644 --- a/lib/_cdio_osx.c +++ b/lib/_cdio_osx.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_osx.c,v 1.18 2004/04/25 17:05:07 rocky Exp $ + $Id: _cdio_osx.c,v 1.19 2004/04/30 06:54:15 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein from vcdimager code: @@ -33,7 +33,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_osx.c,v 1.18 2004/04/25 17:05:07 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_osx.c,v 1.19 2004/04/30 06:54:15 rocky Exp $"; #include #include @@ -67,15 +67,17 @@ static const char _rcsid[] = "$Id: _cdio_osx.c,v 1.18 2004/04/25 17:05:07 rocky #define TOTAL_TRACKS (_obj->num_tracks) +typedef_ enum { + _AM_NONE, + _AM_OSX, +} access_mode_t; + typedef struct { /* Things common to all drivers like this. This must be first. */ generic_img_private_t gen; - enum { - _AM_NONE, - _AM_OSX, - } access_mode; + access_mode_t access_mode; /* Track information */ bool toc_init; /* if true, info below is valid. */ @@ -839,6 +841,22 @@ cdio_get_default_device_osx(void) #endif /* HAVE_DARWIN_CDROM */ } +/*! + Initialization routine. This is the only thing that doesn't + get called via a function pointer. In fact *we* are the + ones to set that up. + */ +CdIo * +cdio_open_am_osx (const char *psz_source_name, const char *psz_access_mode) +{ + + if (psz_access_mode != NULL) + cdio_warn ("there is only one access mode for OS X. Arg %s ignored", + psz_access_mode); + return cdio_open_osx(psz_source_name); +} + + /*! Initialization routine. This is the only thing that doesn't get called via a function pointer. In fact *we* are the diff --git a/lib/_cdio_sunos.c b/lib/_cdio_sunos.c index 2bc79679..aaf6000a 100644 --- a/lib/_cdio_sunos.c +++ b/lib/_cdio_sunos.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_sunos.c,v 1.27 2004/04/25 14:07:23 rocky Exp $ + $Id: _cdio_sunos.c,v 1.28 2004/04/30 06:54:15 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004 Rocky Bernstein @@ -41,7 +41,7 @@ #ifdef HAVE_SOLARIS_CDROM -static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.27 2004/04/25 14:07:23 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.28 2004/04/30 06:54:15 rocky Exp $"; #include #include @@ -68,12 +68,7 @@ static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.27 2004/04/25 14:07:23 rock /* reader */ -typedef struct { - /* Things common to all drivers like this. - This must be first. */ - generic_img_private_t gen; - - enum { +typedef enum { _AM_NONE, _AM_SUN_CTRL_ATAPI, _AM_SUN_CTRL_SCSI @@ -81,15 +76,42 @@ typedef struct { _AM_READ_CD, _AM_READ_10 #endif - } access_mode; +} access_mode_t; +typedef struct { + /* Things common to all drivers like this. + This must be first. */ + generic_img_private_t gen; + + access_mode_t access_mode; + /* Track information */ struct cdrom_tochdr tochdr; struct cdrom_tocentry tocent[100]; /* entry info for each track */ } _img_private_t; +static access_mode_t +str_to_access_mode_sunos(const char *psz_access_mode) +{ + const access_mode_t default_access_mode = _AM_SUN_CTRL_SCSI_; + + if (NULL==psz_access_mode) return default_access_mode; + + if (!strcmp(value, "ATAPI")) + _obj->access_mode = _AM_SUN_CTRL_SCSI; /* force ATAPI to be SCSI */ + else if (!strcmp(value, "SCSI")) + _obj->access_mode = _AM_SUN_CTRL_SCSI; + else + else { + cdio_warn ("unknown access type: %s. Default SCSI used.", + psz_access_mode); + return default_access_mode; + } +} + + /*! Initialize CD device. */ @@ -330,12 +352,7 @@ _cdio_set_arg (void *env, const char key[], const char value[]) } else if (!strcmp (key, "access-mode")) { - if (!strcmp(value, "ATAPI")) - _obj->access_mode = _AM_SUN_CTRL_SCSI; /* force ATAPI to be SCSI */ - else if (!strcmp(value, "SCSI")) - _obj->access_mode = _AM_SUN_CTRL_SCSI; - else - cdio_warn ("unknown access type: %s. ignored.", value); + _obj->access_mode = str_to_access_mode_sunos(key); } else return -1; @@ -759,7 +776,18 @@ cdio_get_devices_solaris (void) ones to set that up. */ CdIo * -cdio_open_solaris (const char *source_name) +cdio_open_solaris (const char *psz_source_name) +{ + return cdio_open_am_solaris(psz_source_name, NULL); +} + +/*! + Initialization routine. This is the only thing that doesn't + get called via a function pointer. In fact *we* are the + ones to set that up. + */ +CdIo * +cdio_open_am_solaris (const char *source_name, const char *access_mode) { #ifdef HAVE_SOLARIS_CDROM @@ -792,6 +820,9 @@ cdio_open_solaris (const char *source_name) }; _data = _cdio_malloc (sizeof (_img_private_t)); + + _data->access_mode = _AM_SUN_SCSI; + _data->gen.init = false; _data->gen.fd = -1; _cdio_set_arg(_data, "source", (NULL == source_name) diff --git a/lib/cdio.c b/lib/cdio.c index 6177ecb8..8c01f72a 100644 --- a/lib/cdio.c +++ b/lib/cdio.c @@ -1,5 +1,5 @@ /* - $Id: cdio.c,v 1.47 2004/04/25 14:07:23 rocky Exp $ + $Id: cdio.c,v 1.48 2004/04/30 06:54:15 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.47 2004/04/25 14:07:23 rocky Exp $"; +static const char _rcsid[] = "$Id: cdio.c,v 1.48 2004/04/30 06:54:15 rocky Exp $"; const char *track_format2str[6] = @@ -77,6 +77,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = { NULL, NULL, NULL, + NULL, NULL }, @@ -86,6 +87,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = { "BSDI ATAPI and SCSI driver", &cdio_have_bsdi, &cdio_open_bsdi, + &cdio_open_am_bsdi, &cdio_get_default_device_bsdi, &cdio_is_device_generic, &cdio_get_devices_bsdi @@ -97,6 +99,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = { "FreeBSD driver", &cdio_have_freebsd, &cdio_open_freebsd, + &cdio_open_am_freebsd, &cdio_get_default_device_freebsd, &cdio_is_device_generic, NULL @@ -108,6 +111,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = { "GNU/Linux ioctl and MMC driver", &cdio_have_linux, &cdio_open_linux, + &cdio_open_am_linux, &cdio_get_default_device_linux, &cdio_is_device_generic, &cdio_get_devices_linux @@ -119,6 +123,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = { "Solaris ATAPI and SCSI driver", &cdio_have_solaris, &cdio_open_solaris, + &cdio_open_am_solaris, &cdio_get_default_device_solaris, &cdio_is_device_generic, &cdio_get_devices_solaris @@ -130,6 +135,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = { "Apple Darwin OS X driver", &cdio_have_osx, &cdio_open_osx, + &cdio_open_am_osx, &cdio_get_default_device_osx, &cdio_is_device_generic, &cdio_get_devices_osx @@ -141,6 +147,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = { "MS Windows ASPI and ioctl driver", &cdio_have_win32, &cdio_open_win32, + &cdio_open_am_win32, &cdio_get_default_device_win32, &cdio_is_device_win32, &cdio_get_devices_win32 @@ -152,6 +159,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = { "bin/cuesheet disk image driver", &cdio_have_bincue, &cdio_open_bincue, + &cdio_open_am_bincue, &cdio_get_default_device_bincue, NULL, &cdio_get_devices_bincue @@ -163,6 +171,7 @@ CdIo_driver_t CdIo_all_drivers[CDIO_MAX_DRIVER+1] = { "Nero NRG disk image driver", &cdio_have_nrg, &cdio_open_nrg, + &cdio_open_am_nrg, &cdio_get_default_device_nrg, NULL, &cdio_get_devices_nrg diff --git a/lib/cdio_private.h b/lib/cdio_private.h index cc13b638..47db5263 100644 --- a/lib/cdio_private.h +++ b/lib/cdio_private.h @@ -1,5 +1,5 @@ /* - $Id: cdio_private.h,v 1.21 2004/04/25 03:52:37 rocky Exp $ + $Id: cdio_private.h,v 1.22 2004/04/30 06:54:15 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -238,9 +238,11 @@ extern "C" { const char *name; const char *describe; bool (*have_driver) (void); - CdIo *(*driver_open) (const char *source_name); + CdIo *(*driver_open) (const char *psz_source_name); + CdIo *(*driver_open_am) (const char *psz_source_name, + const char *psz_access_mode); char *(*get_default_device) (void); - bool (*is_device) (const char *source_name); + bool (*is_device) (const char *psz_source_name); char **(*get_devices) (void); } CdIo_driver_t; diff --git a/lib/image/bincue.c b/lib/image/bincue.c index cc55b899..c8e3d3b5 100644 --- a/lib/image/bincue.c +++ b/lib/image/bincue.c @@ -1,5 +1,5 @@ /* - $Id: bincue.c,v 1.15 2004/04/25 14:48:17 rocky Exp $ + $Id: bincue.c,v 1.16 2004/04/30 06:54:15 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.15 2004/04/25 14:48:17 rocky Exp $"; +static const char _rcsid[] = "$Id: bincue.c,v 1.16 2004/04/30 06:54:15 rocky Exp $"; #include "cdio_assert.h" #include "cdio_private.h" @@ -895,6 +895,25 @@ cdio_is_binfile(const char *bin_name) return NULL; } +/*! + Initialization routine. This is the only thing that doesn't + get called via a function pointer. In fact *we* are the + ones to set that up. + */ +CdIo * +cdio_open_am_bincue (const char *psz_source_name, const char *psz_access_mode) +{ + if (psz_access_mode != NULL) + cdio_warn ("there is only one access mode for bincue. Arg %s ignored", + psz_access_mode); + return cdio_open_bincue(psz_source_name); +} + +/*! + Initialization routine. This is the only thing that doesn't + get called via a function pointer. In fact *we* are the + ones to set that up. + */ CdIo * cdio_open_bincue (const char *source_name) { diff --git a/lib/image/nrg.c b/lib/image/nrg.c index d049b4d6..b6d8dcc6 100644 --- a/lib/image/nrg.c +++ b/lib/image/nrg.c @@ -1,5 +1,5 @@ /* - $Id: nrg.c,v 1.10 2004/04/25 14:48:17 rocky Exp $ + $Id: nrg.c,v 1.11 2004/04/30 06:54:15 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.10 2004/04/25 14:48:17 rocky Exp $"; +static const char _rcsid[] = "$Id: nrg.c,v 1.11 2004/04/30 06:54:15 rocky Exp $"; /* structures used */ @@ -1150,6 +1150,21 @@ _get_track_green_nrg(void *env, track_t track_num) return _obj->tocent[track_num-1].track_green; } +/*! + Initialization routine. This is the only thing that doesn't + get called via a function pointer. In fact *we* are the + ones to set that up. + */ +CdIo * +cdio_open_am_nrg (const char *psz_source_name, const char *psz_access_mode) +{ + if (psz_access_mode != NULL) + cdio_warn ("there is only one access mode for nrg. Arg %s ignored", + psz_access_mode); + return cdio_open_nrg(psz_source_name); +} + + CdIo * cdio_open_nrg (const char *source_name) {