cdio.{c,h}: get_drive_cap -> get_drive_cap_dev and add get_drive_cap.

cd-info.c, sample2.c: use it.
This commit is contained in:
rocky
2004-04-23 22:10:52 +00:00
parent a516b22565
commit b05dc3aab0
6 changed files with 98 additions and 17 deletions

5
NEWS
View File

@@ -1,3 +1,6 @@
0.69
- Add interface returning drive capabilityes (cdio_get_drive_cap).
0.68
- More honest about mode1 reading in backends. Remove some of the bogusness.
- Fixes and simplifications to Solaris (from Ian MacIntosh): no longer
@@ -105,4 +108,4 @@
0.1
Routines split off from VCDImager.
$Id: NEWS,v 1.37 2004/03/23 02:25:43 rocky Exp $
$Id: NEWS,v 1.38 2004/04/23 22:10:52 rocky Exp $

View File

@@ -1,5 +1,5 @@
/*
$Id: sample2.c,v 1.6 2004/04/23 01:01:35 rocky Exp $
$Id: sample2.c,v 1.7 2004/04/23 22:10:52 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -45,7 +45,7 @@ main(int argc, const char *argv[])
printf("The driver selected is %s\n", cdio_get_driver_name(cdio));
if (default_device) {
cdio_drive_cap_t i_drive_cap = cdio_get_drive_cap(default_device);
cdio_drive_cap_t i_drive_cap = cdio_get_drive_cap(cdio);
printf("The default device for this driver is %s\n", default_device);
printf("drive capability in hex: %x\n", i_drive_cap);
if (CDIO_DRIVE_ERROR == i_drive_cap) {

View File

@@ -1,5 +1,5 @@
/* -*- c -*-
$Id: cdio.h,v 1.38 2004/04/22 03:24:38 rocky Exp $
$Id: cdio.h,v 1.39 2004/04/23 22:10:52 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -55,7 +55,10 @@
\brief Drive types returned by cdio_get_drive_cap()
*/
#define CDIO_DRIVE_ERROR 0x0000 /**< Error */
#define CDIO_DRIVE_UNKNOWN 0x0001 /**< Dunno */
#define CDIO_DRIVE_UNKNOWN 0x0001 /**< Dunno. It can be on if we
have only partial information or
are not completely certain
*/
#define CDIO_DRIVE_FILE 0x1000 /**< drive is really a file, i.e a
CD file image */
#define CDIO_DRIVE_CD_R 0x2000 /**< drive is a CD-R */
@@ -188,7 +191,14 @@ extern "C" {
See above for a list of bitmasks for the drive type;
*/
cdio_drive_cap_t cdio_get_drive_cap (const char *device);
cdio_drive_cap_t cdio_get_drive_cap (const CdIo *obj);
/*!
Return the what kind of device we've got. Device version.
See above for a list of bitmasks for the drive type;
*/
cdio_drive_cap_t cdio_get_drive_cap_dev (const char *device);
/*!
Return the media catalog number (MCN) from the CD or NULL if there

View File

@@ -1,5 +1,5 @@
/*
$Id: ioctl.c,v 1.4 2004/03/10 10:57:44 rocky Exp $
$Id: ioctl.c,v 1.5 2004/04/23 22:10:53 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -26,7 +26,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: ioctl.c,v 1.4 2004/03/10 10:57:44 rocky Exp $";
static const char _rcsid[] = "$Id: ioctl.c,v 1.5 2004/04/23 22:10:53 rocky Exp $";
#include <cdio/cdio.h>
#include <cdio/sector.h>
@@ -35,7 +35,7 @@ static const char _rcsid[] = "$Id: ioctl.c,v 1.4 2004/03/10 10:57:44 rocky Exp $
#ifdef HAVE_WIN32_CDROM
#include <windows.h>
#include <winioctl.h>
#include <ddk/ntddstor.h>
#include <stdio.h>
#include <sys/stat.h>
@@ -469,4 +469,54 @@ win32ioctl_get_track_format(_img_private_t *env, track_t track_num)
}
/*!
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.
*/
cdio_drive_cap_t
win32ioctl_get_drive_cap (const void *env) {
const _img_private_t *_obj = env;
int32_t i_drivetype;
unsigned int len = strlen(_obj->gen.source_name);
char psz_drive[4];
strcpy( psz_drive, "X:" );
psz_drive[0] = _obj->gen.source_name[len-2];
i_drivetype = GetDriveType(psz_drive);
switch (i_drivetype) {
case DRIVE_CDROM:
{
#if 0
DWORD dwBytesReturned;
GET_MEDIA_TYPES mediaTypes;
i_drivetype = CDIO_DRIVE_CD_R;
if ( DeviceIoControl(_obj->h_device_handle,
IOCTL_STORAGE_GET_MEDIA_TYPES_EX,
NULL, 0, &mediaTypes, sizeof(GET_MEDIA_TYPES),
&dwBytesReturned, NULL) ) {
switch (mediaTypes.DeviceType) {
case FILE_DEVICE_DVD:
i_drivetype = CDIO_DRIVE_DVD_R;
break;
case FILE_DEVICE_CD_ROM:
i_drivetype = CDIO_DRIVE_CD_R;
break;
default:
;
}
}
#else
i_drivetype = CDIO_DRIVE_CD_R;
#endif
return i_drivetype;
default:
return CDIO_DRIVE_ERROR;
}
}
}
#endif /*HAVE_WIN32_CDROM*/

View File

@@ -1,5 +1,5 @@
/*
$Id: cdio.c,v 1.44 2004/04/22 03:24:38 rocky Exp $
$Id: cdio.c,v 1.45 2004/04/23 22:10:52 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
@@ -37,7 +37,7 @@
#include <cdio/logging.h>
#include "cdio_private.h"
static const char _rcsid[] = "$Id: cdio.c,v 1.44 2004/04/22 03:24:38 rocky Exp $";
static const char _rcsid[] = "$Id: cdio.c,v 1.45 2004/04/23 22:10:52 rocky Exp $";
const char *track_format2str[6] =
@@ -384,15 +384,33 @@ cdio_get_devices_with_cap (char* search_devices[],
*/
unsigned int
cdio_get_drive_cap (const char *device)
cdio_get_drive_cap (const CdIo *cdio)
{
cdio_drive_cap_t i_drivetype = CDIO_DRIVE_UNKNOWN;
if (cdio && cdio->op.get_drive_cap) {
i_drivetype=cdio->op.get_drive_cap(cdio->env);
}
return i_drivetype;
}
/*!
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.
*/
unsigned int
cdio_get_drive_cap_dev (const char *device)
{
cdio_drive_cap_t i_drivetype = CDIO_DRIVE_UNKNOWN;
CdIo *cdio=scan_for_driver(CDIO_MIN_DRIVER, CDIO_MAX_DRIVER,
device);
if (cdio && cdio->op.get_drive_cap) {
i_drivetype=cdio->op.get_drive_cap(cdio->env);
if (cdio) {
i_drivetype=cdio_get_drive_cap(cdio);
cdio_destroy(cdio);
}
return i_drivetype;

View File

@@ -1,5 +1,5 @@
/*
$Id: cd-info.c,v 1.53 2004/04/23 01:01:37 rocky Exp $
$Id: cd-info.c,v 1.54 2004/04/23 22:10:53 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
@@ -830,7 +830,7 @@ main(int argc, const char *argv[])
}
{
cdio_drive_cap_t i_drive_cap = cdio_get_drive_cap(source_name);
cdio_drive_cap_t i_drive_cap = cdio_get_drive_cap(cdio);
if (CDIO_DRIVE_ERROR == i_drive_cap) {
printf("Error in getting drive properties\n");
} else if (CDIO_DRIVE_UNKNOWN == i_drive_cap) {