diff --git a/include/cdio/cdio.h b/include/cdio/cdio.h index 002f52c5..fa4c1b4f 100644 --- a/include/cdio/cdio.h +++ b/include/cdio/cdio.h @@ -1,5 +1,5 @@ /* -*- c -*- - $Id: cdio.h,v 1.60 2004/07/28 22:03:35 rocky Exp $ + $Id: cdio.h,v 1.61 2004/08/27 02:50:13 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -55,6 +55,19 @@ extern "C" { #endif /* __cplusplus */ +/*! Size of fields returned by an INQUIRY command */ +#define CDIO_MMC_HW_VENDOR_LEN 8 /**< length of vendor field */ +#define CDIO_MMC_HW_MODEL_LEN 16 /**< length of model field */ +#define CDIO_MMC_HW_REVISION_LEN 4 /**< length of revision field */ + + /*! Structure to return data given by the INQUIRY command */ + typedef struct cdio_hwinfo + { + char vendor [CDIO_MMC_HW_VENDOR_LEN+1]; + char model [CDIO_MMC_HW_MODEL_LEN+1]; + char revision[CDIO_MMC_HW_REVISION_LEN+1]; + } cdio_hwinfo_t; + /** This is an opaque structure for the CD object. */ typedef struct _CdIo CdIo; @@ -245,6 +258,14 @@ extern "C" { cdio_drive_write_cap_t *p_write_cap, cdio_drive_misc_cap_t *p_misc_cap); + /*! + Get the CD-ROM hardware info via a SCSI MMC INQUIRY command. + False is returned if we had an error getting the information. + */ + bool cdio_get_hwinfo ( const CdIo *p_cdio, + /* out*/ cdio_hwinfo_t *p_hw_info ); + + /*! Get the media catalog number (MCN) from the CD. diff --git a/include/cdio/scsi_mmc.h b/include/cdio/scsi_mmc.h index fa10207e..f8490596 100644 --- a/include/cdio/scsi_mmc.h +++ b/include/cdio/scsi_mmc.h @@ -1,5 +1,5 @@ /* - $Id: scsi_mmc.h,v 1.31 2004/08/10 02:29:46 rocky Exp $ + $Id: scsi_mmc.h,v 1.32 2004/08/27 02:50:13 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -252,19 +252,6 @@ conform to any Profile. */ -/*! Size of fields returned by an INQUIRY command */ -#define CDIO_MMC_HW_VENDOR_LEN 8 /**< length of vendor field */ -#define CDIO_MMC_HW_MODEL_LEN 16 /**< length of model field */ -#define CDIO_MMC_HW_REVISION_LEN 4 /**< length of revision field */ - -/*! Structure to return data given by the INQUIRY command */ -typedef struct scsi_mmc_hwinfo -{ - char vendor [CDIO_MMC_HW_VENDOR_LEN+1]; - char model [CDIO_MMC_HW_MODEL_LEN+1]; - char revision[CDIO_MMC_HW_REVISION_LEN+1]; -} scsi_mmc_hwinfo_t; - /*! This is listed as optional in ATAPI 2.6, but is (curiously) missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji Table 377 as an MMC command for SCSi devices though... Most ATAPI @@ -407,7 +394,7 @@ discmode_t scsi_mmc_get_dvd_struct_physical ( const CdIo *p_cdio, False is returned if we had an error getting the information. */ bool scsi_mmc_get_hwinfo ( const CdIo *p_cdio, - /* out*/ scsi_mmc_hwinfo_t *p_hw_info ); + /* out*/ cdio_hwinfo_t *p_hw_info ); /*! diff --git a/lib/cdio.c b/lib/cdio.c index b2df5ff3..935e0517 100644 --- a/lib/cdio.c +++ b/lib/cdio.c @@ -1,5 +1,5 @@ /* - $Id: cdio.c,v 1.67 2004/07/28 22:03:35 rocky Exp $ + $Id: cdio.c,v 1.68 2004/08/27 02:50:13 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein Copyright (C) 2001 Herbert Valerio Riedel @@ -39,7 +39,7 @@ #include #include "cdio_private.h" -static const char _rcsid[] = "$Id: cdio.c,v 1.67 2004/07/28 22:03:35 rocky Exp $"; +static const char _rcsid[] = "$Id: cdio.c,v 1.68 2004/08/27 02:50:13 rocky Exp $"; const char *track_format2str[6] = @@ -431,6 +431,21 @@ cdio_get_devices_with_cap (char* search_devices[], return drives_ret; } +/*! + Get medium associated with cd_obj. +*/ +discmode_t +cdio_get_discmode (CdIo *cd_obj) +{ + if (cd_obj == NULL) return CDIO_DISC_MODE_ERROR; + + if (cd_obj->op.get_discmode) { + return cd_obj->op.get_discmode (cd_obj->env); + } else { + return CDIO_DISC_MODE_NO_INFO; + } +} + /*! Return the the kind of drive capabilities of device. @@ -439,7 +454,7 @@ cdio_get_devices_with_cap (char* search_devices[], */ void -cdio_get_drive_cap (const CdIo *cdio, +cdio_get_drive_cap (const CdIo *p_cdio, cdio_drive_read_cap_t *p_read_cap, cdio_drive_write_cap_t *p_write_cap, cdio_drive_misc_cap_t *p_misc_cap) @@ -449,8 +464,8 @@ cdio_get_drive_cap (const CdIo *cdio, *p_write_cap = CDIO_DRIVE_CAP_UNKNOWN; *p_misc_cap = CDIO_DRIVE_CAP_UNKNOWN; - if (cdio && cdio->op.get_drive_cap) { - cdio->op.get_drive_cap(cdio->env, p_read_cap, p_write_cap, p_misc_cap); + if (p_cdio && p_cdio->op.get_drive_cap) { + p_cdio->op.get_drive_cap(p_cdio->env, p_read_cap, p_write_cap, p_misc_cap); } } @@ -511,29 +526,32 @@ cdio_get_driver_id (const CdIo *cdio) CDIO_INVALID_TRACK is returned on error. */ track_t -cdio_get_first_track_num (const CdIo *cdio) +cdio_get_first_track_num (const CdIo *p_cdio) { - if (NULL == cdio) return CDIO_INVALID_TRACK; + if (NULL == p_cdio) return CDIO_INVALID_TRACK; - if (cdio->op.get_first_track_num) { - return cdio->op.get_first_track_num (cdio->env); + if (p_cdio->op.get_first_track_num) { + return p_cdio->op.get_first_track_num (p_cdio->env); } else { return CDIO_INVALID_TRACK; } } -/*! - Get medium associated with cd_obj. +/*! + Return a string containing the name of the driver in use. + if CdIo is NULL (we haven't initialized a specific device driver), + then return NULL. */ -discmode_t -cdio_get_discmode (CdIo *cd_obj) +bool +cdio_get_hwinfo (const CdIo *p_cdio, cdio_hwinfo_t *hw_info) { - if (cd_obj == NULL) return CDIO_DISC_MODE_ERROR; - - if (cd_obj->op.get_discmode) { - return cd_obj->op.get_discmode (cd_obj->env); + if (!p_cdio) return false; + if (p_cdio->op.get_hwinfo) { + return p_cdio->op.get_hwinfo (p_cdio, hw_info); } else { - return CDIO_DISC_MODE_NO_INFO; + /* Perhaps driver forgot to initialize. We are no worse off Using + scsi_mmc than returning false here. */ + return scsi_mmc_get_hwinfo(p_cdio, hw_info); } } diff --git a/lib/cdio_private.h b/lib/cdio_private.h index 72b3e127..62a46572 100644 --- a/lib/cdio_private.h +++ b/lib/cdio_private.h @@ -1,5 +1,5 @@ /* - $Id: cdio_private.h,v 1.39 2004/08/10 11:58:15 rocky Exp $ + $Id: cdio_private.h,v 1.40 2004/08/27 02:50:13 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein @@ -109,18 +109,25 @@ extern "C" { cdio_drive_read_cap_t *p_read_cap, cdio_drive_write_cap_t *p_write_cap, cdio_drive_misc_cap_t *p_misc_cap); - /*! - 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. - */ - char * (*get_mcn) (const void *env); - /*! Return the number of of the first track. CDIO_INVALID_TRACK is returned on error. */ track_t (*get_first_track_num) (void *env); + /*! + Get the CD-ROM hardware info via a SCSI MMC INQUIRY command. + False is returned if we had an error getting the information. + */ + bool (*get_hwinfo) ( const CdIo *p_cdio, + /* out*/ cdio_hwinfo_t *p_hw_info ); + + /*! + 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. + */ + char * (*get_mcn) (const void *env); + /*! Return the number of tracks in the current medium. CDIO_INVALID_TRACK is returned on error. diff --git a/lib/scsi_mmc.c b/lib/scsi_mmc.c index da167089..7ca2a59a 100644 --- a/lib/scsi_mmc.c +++ b/lib/scsi_mmc.c @@ -1,6 +1,6 @@ /* Common SCSI Multimedia Command (MMC) routines. - $Id: scsi_mmc.c,v 1.25 2004/08/27 01:24:40 rocky Exp $ + $Id: scsi_mmc.c,v 1.26 2004/08/27 02:50:13 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -429,7 +429,7 @@ scsi_mmc_get_dvd_struct_physical ( const CdIo *p_cdio, cdio_dvd_struct_t *s) */ bool scsi_mmc_get_hwinfo ( const CdIo *p_cdio, - /*out*/ scsi_mmc_hwinfo_t *hw_info ) + /*out*/ cdio_hwinfo_t *hw_info ) { int i_status; /* Result of SCSI MMC command */ char buf[36] = { 0, }; /* Place to hold returned data */ diff --git a/src/cd-drive.c b/src/cd-drive.c index 0b2e272c..77a7f04b 100644 --- a/src/cd-drive.c +++ b/src/cd-drive.c @@ -1,5 +1,5 @@ /* - $Id: cd-drive.c,v 1.6 2004/08/07 11:26:01 rocky Exp $ + $Id: cd-drive.c,v 1.7 2004/08/27 02:50:13 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -233,17 +233,17 @@ main(int argc, const char *argv[]) cdio_drive_read_cap_t i_read_cap; cdio_drive_write_cap_t i_write_cap; cdio_drive_misc_cap_t i_misc_cap; + cdio_hwinfo_t hwinfo; CdIo *p_cdio = cdio_open(*ppsz_cd, DRIVER_UNKNOWN); - scsi_mmc_hwinfo_t scsi_mmc_hwinfo; cdio_get_drive_cap_dev(*ppsz_cd, &i_read_cap, &i_write_cap, &i_misc_cap); printf("%28s: %s\n", "Drive", *ppsz_cd); - if (scsi_mmc_get_hwinfo(p_cdio, &scsi_mmc_hwinfo)) { + if (cdio_get_hwinfo(p_cdio, &hwinfo)) { printf("%-28s: %s\n%-28s: %s\n%-28s: %s\n", - "Vendor" , scsi_mmc_hwinfo.vendor, - "Model" , scsi_mmc_hwinfo.model, - "Revision", scsi_mmc_hwinfo.revision); + "Vendor" , hwinfo.vendor, + "Model" , hwinfo.model, + "Revision", hwinfo.revision); } print_mmc_drive_features(p_cdio); print_drive_capabilities(i_read_cap, i_write_cap, i_misc_cap); @@ -259,17 +259,17 @@ main(int argc, const char *argv[]) cdio_drive_read_cap_t i_read_cap; cdio_drive_write_cap_t i_write_cap; cdio_drive_misc_cap_t i_misc_cap; - scsi_mmc_hwinfo_t scsi_mmc_hwinfo; + cdio_hwinfo_t hwinfo; printf("Drive %s\n", source_name); p_cdio = cdio_open (source_name, DRIVER_UNKNOWN); if (NULL != p_cdio) { - if (scsi_mmc_get_hwinfo(p_cdio, &scsi_mmc_hwinfo)) { + if (cdio_get_hwinfo(p_cdio, &hwinfo)) { printf("%-28s: %s\n%-28s: %s\n%-28s: %s\n", - "Vendor" , scsi_mmc_hwinfo.vendor, - "Model" , scsi_mmc_hwinfo.model, - "Revision", scsi_mmc_hwinfo.revision); + "Vendor" , hwinfo.vendor, + "Model" , hwinfo.model, + "Revision", hwinfo.revision); } print_mmc_drive_features(p_cdio); } diff --git a/src/cd-info.c b/src/cd-info.c index 85063e4e..e411c886 100644 --- a/src/cd-info.c +++ b/src/cd-info.c @@ -1,5 +1,5 @@ /* - $Id: cd-info.c,v 1.81 2004/08/06 00:53:58 rocky Exp $ + $Id: cd-info.c,v 1.82 2004/08/27 02:50:13 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein Copyright (C) 1996, 1997, 1998 Gerd Knorr @@ -985,12 +985,12 @@ main(int argc, const char *argv[]) cdio_drive_read_cap_t i_read_cap; cdio_drive_write_cap_t i_write_cap; cdio_drive_misc_cap_t i_misc_cap; - scsi_mmc_hwinfo_t scsi_mmc_hwinfo; - if (scsi_mmc_get_hwinfo(p_cdio, &scsi_mmc_hwinfo)) { + cdio_hwinfo_t hwinfo; + if (cdio_get_hwinfo(p_cdio, &hwinfo)) { printf("%-28s: %s\n%-28s: %s\n%-28s: %s\n", - "Vendor" , scsi_mmc_hwinfo.vendor, - "Model" , scsi_mmc_hwinfo.model, - "Revision", scsi_mmc_hwinfo.revision); + "Vendor" , hwinfo.vendor, + "Model" , hwinfo.model, + "Revision", hwinfo.revision); } cdio_get_drive_cap(p_cdio, &i_read_cap, &i_write_cap, &i_misc_cap); print_drive_capabilities(i_read_cap, i_write_cap, i_misc_cap); @@ -1004,13 +1004,13 @@ main(int argc, const char *argv[]) if (NULL != d) { for ( ; *d != NULL ; d++ ) { CdIo *p_cdio = cdio_open(source_name, DRIVER_UNKNOWN); - scsi_mmc_hwinfo_t scsi_mmc_hwinfo; + cdio_hwinfo_t hwinfo; printf("Drive %s\n", *d); - if (scsi_mmc_get_hwinfo(p_cdio, &scsi_mmc_hwinfo)) { + if (scsi_mmc_get_hwinfo(p_cdio, &hwinfo)) { printf("%-8s: %s\n%-8s: %s\n%-8s: %s\n", - "Vendor" , scsi_mmc_hwinfo.vendor, - "Model" , scsi_mmc_hwinfo.model, - "Revision", scsi_mmc_hwinfo.revision); + "Vendor" , hwinfo.vendor, + "Model" , hwinfo.model, + "Revision", hwinfo.revision); } if (p_cdio) cdio_destroy(p_cdio); }