diff --git a/example/sample10.c b/example/sample10.c index 76d27d22..e8a0d084 100644 --- a/example/sample10.c +++ b/example/sample10.c @@ -1,5 +1,5 @@ /* - $Id: sample10.c,v 1.7 2004/08/10 02:29:46 rocky Exp $ + $Id: sample10.c,v 1.8 2004/08/10 11:58:14 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -291,7 +291,7 @@ main(int argc, const char *argv[]) " RPC\n"); break; case CDIO_MMC_FEATURE_RT_STREAMING: - printf("\tAbility to read and write using Initiator requested performance parameters\n"); + printf("Ability to read and write using Initiator requested performance parameters\n"); break; case CDIO_MMC_FEATURE_LU_SN: { uint8_t i_serial = *(p+3); diff --git a/lib/MSWindows/win32.c b/lib/MSWindows/win32.c index 0d098d74..2e360903 100644 --- a/lib/MSWindows/win32.c +++ b/lib/MSWindows/win32.c @@ -1,5 +1,5 @@ /* - $Id: win32.c,v 1.42 2004/08/10 03:44:55 rocky Exp $ + $Id: win32.c,v 1.43 2004/08/10 11:58: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.42 2004/08/10 03:44:55 rocky Exp $"; +static const char _rcsid[] = "$Id: win32.c,v 1.43 2004/08/10 11:58:15 rocky Exp $"; #include #include @@ -482,34 +482,6 @@ _get_arg_win32 (void *user_data, const char key[]) return NULL; } -/*! - Return the value associated with the key "arg". -*/ -static const cdtext_t * -_get_cdtext_win32 (void *user_data, track_t i_track) -{ - _img_private_t *p_env = user_data; - - if (NULL == p_env) return NULL; - - if ( NULL == p_env || - (0 != i_track - && i_track >= p_env->gen.i_tracks + p_env->gen.i_first_track ) ) - return NULL; - - if (!p_env->gen.b_cdtext_init) - init_cdtext_generic( &(p_env->gen) ); - - if (!p_env->gen.b_cdtext_init) return NULL; - - if (0 == i_track) - return &(p_env->gen.cdtext); - else - return &(p_env->gen.cdtext_track[i_track-p_env->gen.i_first_track]); - - return NULL; -} - /*! Return the media catalog number MCN. @@ -741,7 +713,7 @@ cdio_open_am_win32 (const char *psz_orig_source, const char *psz_access_mode) .eject_media = _cdio_eject_media, .free = _free_win32, .get_arg = _get_arg_win32, - .get_cdtext = _get_cdtext_win32, + .get_cdtext = _get_cdtext_generic, .get_default_device = cdio_get_default_device_win32, .get_devices = cdio_get_devices_win32, .get_discmode = get_discmode_win32, diff --git a/lib/Makefile.am b/lib/Makefile.am index b3f22abc..4e6fafaa 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.44 2004/08/08 14:55:35 rocky Exp $ +# $Id: Makefile.am,v 1.45 2004/08/10 11:58:15 rocky Exp $ # # Copyright (C) 2003, 2004 Rocky Bernstein # @@ -75,6 +75,7 @@ libcdio_sources = \ FreeBSD/freebsd.h \ FreeBSD/freebsd_cam.c \ FreeBSD/freebsd_ioctl.c \ + generic.h \ image.h \ image/bincue.c \ image/cdrdao.c \ diff --git a/lib/_cdio_bsdi.c b/lib/_cdio_bsdi.c index 9637c141..0d6b31c1 100644 --- a/lib/_cdio_bsdi.c +++ b/lib/_cdio_bsdi.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_bsdi.c,v 1.39 2004/08/10 03:37:16 rocky Exp $ + $Id: _cdio_bsdi.c,v 1.40 2004/08/10 11:58: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.39 2004/08/10 03:37:16 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.40 2004/08/10 11:58:15 rocky Exp $"; #include #include @@ -513,33 +513,6 @@ read_toc_bsdi (void *p_user_data) return true; } -/*! - Get cdtext information for a CdIo object . - - @param obj the CD object that may contain CD-TEXT information. - @return the CD-TEXT object or NULL if obj is NULL - or CD-TEXT information does not exist. -*/ -static const cdtext_t * -get_cdtext_bsdi (void *p_user_data, track_t i_track) -{ - _img_private_t *p_env = p_user_data; - - if ( NULL == p_env || - (0 != i_track - && i_track >= p_env->gen.i_tracks+p_env->gen.i_first_track ) ) - return NULL; - - if (!p_env->gen.b_cdtext_init) - init_cdtext_generic(&(p_env->gen)); - if (!p_env->gen.b_cdtext_init) return NULL; - - if (0 == i_track) - return &(p_env->gen.cdtext); - else - return &(p_env->gen.cdtext_track[i_track-p_env->gen.i_first_track]); -} - /*! Eject media in CD drive. If successful, as a side effect we also free obj. @@ -794,7 +767,7 @@ cdio_open_bsdi (const char *psz_orig_source) .eject_media = _eject_media_bsdi, .free = cdio_generic_free, .get_arg = _get_arg_bsdi, - .get_cdtext = get_cdtext_bsdi, + .get_cdtext = get_cdtext_generic, .get_default_device = cdio_get_default_device_bsdi, .get_devices = cdio_get_devices_bsdi, .get_drive_cap = scsi_mmc_get_drive_cap_generic, diff --git a/lib/_cdio_generic.c b/lib/_cdio_generic.c index f03c8d4d..4c7bcd27 100644 --- a/lib/_cdio_generic.c +++ b/lib/_cdio_generic.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_generic.c,v 1.22 2004/08/10 03:03:27 rocky Exp $ + $Id: _cdio_generic.c,v 1.23 2004/08/10 11:58: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_generic.c,v 1.22 2004/08/10 03:03:27 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.23 2004/08/10 11:58:15 rocky Exp $"; #include #include @@ -227,6 +227,34 @@ cdio_add_device_list(char **device_list[], const char *drive, int *num_drives) } +/*! + Get cdtext information for a CdIo object . + + @param obj the CD object that may contain CD-TEXT information. + @return the CD-TEXT object or NULL if obj is NULL + or CD-TEXT information does not exist. +*/ +const cdtext_t * +get_cdtext_generic (void *p_user_data, track_t i_track) +{ + generic_img_private_t *p_env = p_user_data; + + if ( NULL == p_env || + (0 != i_track + && i_track >= p_env->i_tracks+p_env->i_first_track ) ) + return NULL; + + if (!p_env->b_cdtext_init) + init_cdtext_generic(p_env); + if (!p_env->b_cdtext_init) return NULL; + + if (0 == i_track) + return &(p_env->cdtext); + else + return &(p_env->cdtext_track[i_track-p_env->i_first_track]); + +} + /*! Get disc type associated with cd object. */ @@ -365,7 +393,7 @@ set_cdtext_field_generic(void *user_data, track_t i_track, } /*! - Read cdtext information for a CdIo object . + Read CD-Text information for a CdIo object . return true on success, false on error or CD-TEXT information does not exist. diff --git a/lib/_cdio_linux.c b/lib/_cdio_linux.c index 751575dc..654b06f8 100644 --- a/lib/_cdio_linux.c +++ b/lib/_cdio_linux.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_linux.c,v 1.90 2004/08/10 03:03:27 rocky Exp $ + $Id: _cdio_linux.c,v 1.91 2004/08/10 11:58: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.90 2004/08/10 03:03:27 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.91 2004/08/10 11:58:15 rocky Exp $"; #include @@ -951,34 +951,6 @@ set_arg_linux (void *p_user_data, const char key[], const char value[]) return 0; } -/*! - Get cdtext information for a CdIo object . - - @param obj the CD object that may contain CD-TEXT information. - @return the CD-TEXT object or NULL if obj is NULL - or CD-TEXT information does not exist. -*/ -static const cdtext_t * -get_cdtext_linux (void *p_user_data, track_t i_track) -{ - _img_private_t *p_env = p_user_data; - - if ( NULL == p_env || - (0 != i_track - && i_track >= p_env->gen.i_tracks+p_env->gen.i_first_track ) ) - return NULL; - - if (!p_env->gen.b_cdtext_init) - init_cdtext_generic(&(p_env->gen)); - if (!p_env->gen.b_cdtext_init) return NULL; - - if (0 == i_track) - return &(p_env->gen.cdtext); - else - return &(p_env->gen.cdtext_track[i_track-p_env->gen.i_first_track]); - -} - /* checklist: /dev/cdrom, /dev/dvd /dev/hd?, /dev/scd? /dev/sr? */ static char checklist1[][40] = { {"cdrom"}, {"dvd"}, {""} @@ -1131,7 +1103,7 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode) .eject_media = eject_media_linux, .free = cdio_generic_free, .get_arg = get_arg_linux, - .get_cdtext = get_cdtext_linux, + .get_cdtext = get_cdtext_generic, .get_default_device = cdio_get_default_device_linux, .get_devices = cdio_get_devices_linux, .get_discmode = get_discmode_linux, diff --git a/lib/_cdio_sunos.c b/lib/_cdio_sunos.c index 84398756..7b3fc113 100644 --- a/lib/_cdio_sunos.c +++ b/lib/_cdio_sunos.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_sunos.c,v 1.71 2004/08/10 03:10:46 rocky Exp $ + $Id: _cdio_sunos.c,v 1.72 2004/08/10 11:58:15 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2002, 2003, 2004 Rocky Bernstein @@ -38,7 +38,7 @@ #ifdef HAVE_SOLARIS_CDROM -static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.71 2004/08/10 03:10:46 rocky Exp $"; +static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.72 2004/08/10 11:58:15 rocky Exp $"; #ifdef HAVE_GLOB_H #include @@ -445,34 +445,6 @@ read_toc_solaris (void *p_user_data) return true; } -/*! - Get cdtext information for a CdIo object . - - @param obj the CD object that may contain CD-TEXT information. - @return the CD-TEXT object or NULL if obj is NULL - or CD-TEXT information does not exist. -*/ -static const cdtext_t * -get_cdtext_solaris (void *p_user_data, track_t i_track) -{ - _img_private_t *p_env = p_user_data; - - if ( NULL == p_env || - (0 != i_track - && i_track >= p_env->gen.i_tracks+p_env->gen.i_first_track ) ) - return NULL; - - if (!p_env->gen.b_cdtext_init) - init_cdtext_generic( (&p_env->gen) ); - - if (!p_env->gen.b_cdtext_init) return NULL; - - if (0 == i_track) - return &(p_env->gen.cdtext); - else - return &(p_env->gen.cdtext_track[i_track-p_env->gen.i_first_track]); -} - /*! Eject media in CD drive. If successful, as a side effect we also free obj. @@ -860,7 +832,7 @@ cdio_open_am_solaris (const char *psz_orig_source, const char *access_mode) .eject_media = eject_media_solaris, .free = cdio_generic_free, .get_arg = get_arg_solaris, - .get_cdtext = get_cdtext_solaris, + .get_cdtext = get_cdtext_generic, .get_default_device = cdio_get_default_device_solaris, .get_devices = cdio_get_devices_solaris, .get_discmode = get_discmode_solaris, diff --git a/lib/cdio_private.h b/lib/cdio_private.h index df13bb9e..72b3e127 100644 --- a/lib/cdio_private.h +++ b/lib/cdio_private.h @@ -1,5 +1,5 @@ /* - $Id: cdio_private.h,v 1.38 2004/08/10 03:03:27 rocky Exp $ + $Id: cdio_private.h,v 1.39 2004/08/10 11:58:15 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -39,6 +39,18 @@ extern "C" { /* Opaque type */ typedef struct _CdioDataSource CdioDataSource; +#ifdef __cplusplus +} + +#endif /* __cplusplus */ + +#include "generic.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + typedef struct { /*! @@ -232,41 +244,14 @@ extern "C" { } cdio_funcs; - /* Implementation of CdIo type */ + /*! Implementation of CdIo type */ struct _CdIo { - driver_id_t driver_id; /* Particular driver opened. */ - cdio_funcs op; /* driver-specific routines handling implimentatin*/ - void *env; /* environment. Passed to routine above. */ + driver_id_t driver_id; /**< Particular driver opened. */ + cdio_funcs op; /**< driver-specific routines handling + implementation*/ + void *env; /**< environment. Passed to routine above. */ }; - /*! - Things common to private device structures. Even though not all - devices may have some of these fields, by listing common ones - we facilitate writing generic routines and even cut-and-paste - code. - */ - typedef struct { - char *source_name; /**< Name used in open. */ - bool init; /**< True if structure has been initialized */ - bool toc_init; /**< True if TOC read in */ - bool b_cdtext_init; /**< True if CD-Text read in */ - bool b_cdtext_error; /**< True if trouble reading CD-Text */ - - int ioctls_debugged; /**< for debugging */ - - /* Only one of the below is used. The first is for CD-ROM devices - and the second for stream reading (bincue, nrg, toc, network). - */ - int fd; /**< File descriptor of device */ - track_t i_first_track; /**< The starting track number. */ - track_t i_tracks; /**< The number of tracks. */ - CdioDataSource *data_source; - CdIo *cdio; /**< a way to call general cdio routines. */ - cdtext_t cdtext; /**< CD-Text for disc. */ - cdtext_t cdtext_track[CDIO_CD_MAX_TRACKS+1]; /*CD-TEXT for each track*/ - - } generic_img_private_t; - /* This is used in drivers that must keep their own internal position pointer for doing seeks. Stream-based drivers (like bincue, nrg, toc, network) would use this. @@ -316,94 +301,6 @@ extern "C" { void cdio_add_device_list(char **device_list[], const char *drive, int *num_drives); - /*! - Bogus eject media when there is no ejectable media, e.g. a disk image - We always return 2. Should we also free resources? - */ - int cdio_generic_bogus_eject_media (void *env); - - /*! - Release and free resources associated with cd. - */ - void cdio_generic_free (void *env); - - /*! - Initialize CD device. - */ - bool cdio_generic_init (void *env); - - /*! - Reads into buf the next size bytes. - Returns -1 on error. - Is in fact libc's read(). - */ - off_t cdio_generic_lseek (void *env, off_t offset, int whence); - - /*! - Reads into buf the next size bytes. - Returns -1 on error. - Is in fact libc's read(). - */ - ssize_t cdio_generic_read (void *env, void *buf, size_t size); - - /*! - Reads a single form1 sector from cd device into data starting - from lsn. Returns 0 if no error. - */ - int cdio_generic_read_form1_sector (void * user_data, void *data, - lsn_t lsn); - - /*! - Release and free resources associated with stream or disk image. - */ - void cdio_generic_stdio_free (void *env); - - /*! - Return true if source_name could be a device containing a CD-ROM on - Win32 - */ - bool cdio_is_device_win32(const char *source_name); - - - /*! - Return true if source_name could be a device containing a CD-ROM on - most Unix servers with block and character devices. - */ - bool cdio_is_device_generic(const char *source_name); - - - /*! - Like above, but don't give a warning device doesn't exist. - */ - bool cdio_is_device_quiet_generic(const char *source_name); - - /*! - Return the number of of the first track. - CDIO_INVALID_TRACK is returned on error. - */ - track_t get_first_track_num_generic(void *p_user_data); - - /*! - Return the number of tracks in the current medium. - */ - track_t get_num_tracks_generic(void *p_user_data); - - /*! - Get disc type associated with cd object. - */ - discmode_t get_discmode_generic (void *p_user_data ); - - void set_cdtext_field_generic(void *user_data, track_t i_track, - track_t i_first_track, - cdtext_field_t e_field, const char *psz_value); - /*! - Read cdtext information for a CdIo object . - - return true on success, false on error or CD-Text information does - not exist. - */ - bool init_cdtext_generic (generic_img_private_t *p_env); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lib/generic.h b/lib/generic.h new file mode 100644 index 00000000..32cda655 --- /dev/null +++ b/lib/generic.h @@ -0,0 +1,167 @@ +/* + $Id: generic.h,v 1.1 2004/08/10 11:58:15 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 +*/ + +/* Internal routines for CD I/O drivers. */ + + +#ifndef __CDIO_GENERIC_H__ +#define __CDIO_GENERIC_H__ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + /*! + Things common to private device structures. Even though not all + devices may have some of these fields, by listing common ones + we facilitate writing generic routines and even cut-and-paste + code. + */ + typedef struct { + char *source_name; /**< Name used in open. */ + bool init; /**< True if structure has been initialized */ + bool toc_init; /**< True if TOC read in */ + bool b_cdtext_init; /**< True if CD-Text read in */ + bool b_cdtext_error; /**< True if trouble reading CD-Text */ + + int ioctls_debugged; /**< for debugging */ + + /* Only one of the below is used. The first is for CD-ROM devices + and the second for stream reading (bincue, nrg, toc, network). + */ + int fd; /**< File descriptor of device */ + track_t i_first_track; /**< The starting track number. */ + track_t i_tracks; /**< The number of tracks. */ + CdioDataSource *data_source; + CdIo *cdio; /**< a way to call general cdio routines. */ + cdtext_t cdtext; /**< CD-Text for disc. */ + cdtext_t cdtext_track[CDIO_CD_MAX_TRACKS+1]; /*CD-TEXT for each track*/ + + } generic_img_private_t; + + /*! + Bogus eject media when there is no ejectable media, e.g. a disk image + We always return 2. Should we also free resources? + */ + int cdio_generic_bogus_eject_media (void *env); + + /*! + Release and free resources associated with cd. + */ + void cdio_generic_free (void *env); + + /*! + Initialize CD device. + */ + bool cdio_generic_init (void *env); + + /*! + Reads into buf the next size bytes. + Returns -1 on error. + Is in fact libc's read(). + */ + off_t cdio_generic_lseek (void *env, off_t offset, int whence); + + /*! + Reads into buf the next size bytes. + Returns -1 on error. + Is in fact libc's read(). + */ + ssize_t cdio_generic_read (void *env, void *buf, size_t size); + + /*! + Reads a single form1 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ + int cdio_generic_read_form1_sector (void * user_data, void *data, + lsn_t lsn); + + /*! + Release and free resources associated with stream or disk image. + */ + void cdio_generic_stdio_free (void *env); + + /*! + Return true if source_name could be a device containing a CD-ROM on + Win32 + */ + bool cdio_is_device_win32(const char *source_name); + + + /*! + Return true if source_name could be a device containing a CD-ROM on + most Unix servers with block and character devices. + */ + bool cdio_is_device_generic(const char *source_name); + + + /*! + Like above, but don't give a warning device doesn't exist. + */ + bool cdio_is_device_quiet_generic(const char *source_name); + + /*! + Get cdtext information for a CdIo object . + + @param obj the CD object that may contain CD-TEXT information. + @return the CD-TEXT object or NULL if obj is NULL + or CD-TEXT information does not exist. + */ + const cdtext_t *get_cdtext_generic (void *p_user_data, track_t i_track); + + /*! + Return the number of of the first track. + CDIO_INVALID_TRACK is returned on error. + */ + track_t get_first_track_num_generic(void *p_user_data); + + /*! + Return the number of tracks in the current medium. + */ + track_t get_num_tracks_generic(void *p_user_data); + + /*! + Get disc type associated with cd object. + */ + discmode_t get_discmode_generic (void *p_user_data ); + + void set_cdtext_field_generic(void *user_data, track_t i_track, + track_t i_first_track, + cdtext_field_t e_field, const char *psz_value); + /*! + Read cdtext information for a CdIo object . + + return true on success, false on error or CD-Text information does + not exist. + */ + bool init_cdtext_generic (generic_img_private_t *p_env); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __CDIO_GENERIC_H__ */ diff --git a/src/util.c b/src/util.c index fbf633e0..9941034d 100644 --- a/src/util.c +++ b/src/util.c @@ -1,5 +1,5 @@ /* - $Id: util.c,v 1.22 2004/08/10 03:47:57 rocky Exp $ + $Id: util.c,v 1.23 2004/08/10 11:58:15 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -348,7 +348,7 @@ print_mmc_drive_features(CdIo *p_cdio) printf("\t\n"); break; case CDIO_MMC_FEATURE_RT_STREAMING: - printf("\tAbility to read and write using Initiator requested performance parameters\n"); + printf("Ability to read and write using Initiator requested performance parameters\n"); break; case CDIO_MMC_FEATURE_LU_SN: { uint8_t i_serial = *(p+3);