More MinGW things. Need generic routine for determining if a string is a device
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/* -*- c -*-
|
/* -*- c -*-
|
||||||
$Id: cdio.h,v 1.11 2003/06/07 01:19:47 rocky Exp $
|
$Id: cdio.h,v 1.12 2003/06/07 16:53:21 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
@@ -283,7 +283,7 @@ extern "C" {
|
|||||||
|
|
||||||
NULL is returned on error.
|
NULL is returned on error.
|
||||||
*/
|
*/
|
||||||
CdIo * cdio_open_cd (const char *cue_name);
|
CdIo * cdio_open_cd (const char *device_name);
|
||||||
|
|
||||||
/*! cdrao BIN/CUE CD disk-image routines. Source is the .cue file
|
/*! cdrao BIN/CUE CD disk-image routines. Source is the .cue file
|
||||||
|
|
||||||
@@ -344,6 +344,10 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
char *cdio_is_binfile(const char *bin_name);
|
char *cdio_is_binfile(const char *bin_name);
|
||||||
|
|
||||||
|
/*! Return true if source name is a device.
|
||||||
|
*/
|
||||||
|
bool cdio_is_device(const char *source_name, driver_id_t driver_id);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: _cdio_win32.c,v 1.4 2003/06/07 12:47:19 rocky Exp $
|
$Id: _cdio_win32.c,v 1.5 2003/06/07 16:53:21 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char _rcsid[] = "$Id: _cdio_win32.c,v 1.4 2003/06/07 12:47:19 rocky Exp $";
|
static const char _rcsid[] = "$Id: _cdio_win32.c,v 1.5 2003/06/07 16:53:21 rocky Exp $";
|
||||||
|
|
||||||
#include <cdio/cdio.h>
|
#include <cdio/cdio.h>
|
||||||
#include <cdio/sector.h>
|
#include <cdio/sector.h>
|
||||||
@@ -176,7 +176,6 @@ struct SRB_ExecSCSICmd
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
lsn_t start_lsn;
|
lsn_t start_lsn;
|
||||||
track_format_t track_format;
|
|
||||||
} track_info_t;
|
} track_info_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -386,7 +385,7 @@ _cdio_init_win32 (void *user_data)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
c_drive = c_drive > 'Z' ? c_drive - 'a' : c_drive - 'A';
|
c_drive = toupper(c_drive) - 'A';
|
||||||
|
|
||||||
for( i = 0; i < i_hostadapters; i++ ) {
|
for( i = 0; i < i_hostadapters; i++ ) {
|
||||||
for( j = 0; j < 15; j++ ) {
|
for( j = 0; j < 15; j++ ) {
|
||||||
@@ -418,7 +417,7 @@ _cdio_init_win32 (void *user_data)
|
|||||||
_obj->i_sid = MAKEWORD( i, j );
|
_obj->i_sid = MAKEWORD( i, j );
|
||||||
_obj->hASPI = (long)hASPI;
|
_obj->hASPI = (long)hASPI;
|
||||||
_obj->lpSendCommand = lpSendCommand;
|
_obj->lpSendCommand = lpSendCommand;
|
||||||
cdio_debug("using ASPI layer");
|
cdio_debug("Using ASPI layer");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -432,7 +431,7 @@ _cdio_init_win32 (void *user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FreeLibrary( hASPI );
|
FreeLibrary( hASPI );
|
||||||
cdio_debug( "unable to get haid and target (aspi)" );
|
cdio_debug( "Unable to get HaId and target (ASPI)" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -625,10 +624,9 @@ _cdio_read_mode2_sectors (void *user_data, void *data, lsn_t lsn,
|
|||||||
static uint32_t
|
static uint32_t
|
||||||
_cdio_stat_size (void *user_data)
|
_cdio_stat_size (void *user_data)
|
||||||
{
|
{
|
||||||
/* _img_private_t *_obj = user_data; */
|
_img_private_t *_obj = user_data;
|
||||||
|
|
||||||
/* FIXME! */
|
return _obj->tocent[_obj->total_tracks].start_lsn;
|
||||||
return 65536;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -812,7 +810,6 @@ _cdio_eject_media (void *user_data) {
|
|||||||
|
|
||||||
memset( &op, 0, sizeof(MCI_OPEN_PARMS) );
|
memset( &op, 0, sizeof(MCI_OPEN_PARMS) );
|
||||||
op.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO;
|
op.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO;
|
||||||
|
|
||||||
strcpy( psz_drive, "X:" );
|
strcpy( psz_drive, "X:" );
|
||||||
psz_drive[0] = _obj->gen.source_name[0];
|
psz_drive[0] = _obj->gen.source_name[0];
|
||||||
op.lpstrElementName = psz_drive;
|
op.lpstrElementName = psz_drive;
|
||||||
@@ -888,10 +885,46 @@ _cdio_get_num_tracks(void *user_data)
|
|||||||
static track_format_t
|
static track_format_t
|
||||||
_cdio_get_track_format(void *user_data, track_t track_num)
|
_cdio_get_track_format(void *user_data, track_t track_num)
|
||||||
{
|
{
|
||||||
/* _img_private_t *_obj = user_data; */
|
_img_private_t *_obj = user_data;
|
||||||
|
|
||||||
/* FIXME! */
|
MCI_OPEN_PARMS op;
|
||||||
|
MCI_STATUS_PARMS st;
|
||||||
|
DWORD i_flags;
|
||||||
|
char psz_drive[4];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
memset( &op, 0, sizeof(MCI_OPEN_PARMS) );
|
||||||
|
op.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO;
|
||||||
|
strcpy( psz_drive, "X:" );
|
||||||
|
psz_drive[0] = _obj->gen.source_name[0];
|
||||||
|
op.lpstrElementName = psz_drive;
|
||||||
|
|
||||||
|
/* Set the flags for the device type */
|
||||||
|
i_flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID |
|
||||||
|
MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE;
|
||||||
|
|
||||||
|
if( !mciSendCommand( 0, MCI_OPEN, i_flags, (unsigned long)&op ) ) {
|
||||||
|
st.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
|
||||||
|
st.dwTrack = track_num;
|
||||||
|
i_flags = MCI_TRACK | MCI_STATUS_ITEM ;
|
||||||
|
ret = mciSendCommand( op.wDeviceID, MCI_STATUS, i_flags,
|
||||||
|
(unsigned long) &st );
|
||||||
|
mciSendCommand( op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0 );
|
||||||
|
|
||||||
|
switch(st.dwReturn) {
|
||||||
|
case MCI_CDA_TRACK_AUDIO:
|
||||||
|
return TRACK_FORMAT_AUDIO;
|
||||||
|
case MCI_CDA_TRACK_OTHER:
|
||||||
|
return TRACK_FORMAT_DATA;
|
||||||
|
default:
|
||||||
return TRACK_FORMAT_XA;
|
return TRACK_FORMAT_XA;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release access to the device */
|
||||||
|
mciSendCommand( op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRACK_FORMAT_ERROR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
62
lib/cdio.c
62
lib/cdio.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
$Id: cdio.c,v 1.17 2003/06/07 01:19:46 rocky Exp $
|
$Id: cdio.c,v 1.18 2003/06/07 16:53:21 rocky Exp $
|
||||||
|
|
||||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||||
@@ -35,7 +35,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.17 2003/06/07 01:19:46 rocky Exp $";
|
static const char _rcsid[] = "$Id: cdio.c,v 1.18 2003/06/07 16:53:21 rocky Exp $";
|
||||||
|
|
||||||
|
|
||||||
const char *track_format2str[5] =
|
const char *track_format2str[5] =
|
||||||
@@ -73,6 +73,7 @@ CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1] = {
|
|||||||
"No driver",
|
"No driver",
|
||||||
&cdio_have_false,
|
&cdio_have_false,
|
||||||
NULL,
|
NULL,
|
||||||
|
NULL,
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -81,8 +82,9 @@ CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1] = {
|
|||||||
"BSDI",
|
"BSDI",
|
||||||
"BSDI ATAPI and SCSI driver",
|
"BSDI ATAPI and SCSI driver",
|
||||||
&cdio_have_bsdi,
|
&cdio_have_bsdi,
|
||||||
cdio_open_bsdi,
|
&cdio_open_bsdi,
|
||||||
&cdio_get_default_device_bsdi
|
&cdio_get_default_device_bsdi,
|
||||||
|
&cdio_is_device_generic
|
||||||
},
|
},
|
||||||
|
|
||||||
{DRIVER_FREEBSD,
|
{DRIVER_FREEBSD,
|
||||||
@@ -91,7 +93,8 @@ CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1] = {
|
|||||||
"FreeBSD driver",
|
"FreeBSD driver",
|
||||||
&cdio_have_freebsd,
|
&cdio_have_freebsd,
|
||||||
&cdio_open_freebsd,
|
&cdio_open_freebsd,
|
||||||
&cdio_get_default_device_freebsd
|
&cdio_get_default_device_freebsd,
|
||||||
|
&cdio_is_device_generic
|
||||||
},
|
},
|
||||||
|
|
||||||
{DRIVER_LINUX,
|
{DRIVER_LINUX,
|
||||||
@@ -100,7 +103,8 @@ CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1] = {
|
|||||||
"Linux ioctl and packet driver",
|
"Linux ioctl and packet driver",
|
||||||
&cdio_have_linux,
|
&cdio_have_linux,
|
||||||
&cdio_open_linux,
|
&cdio_open_linux,
|
||||||
&cdio_get_default_device_linux
|
&cdio_get_default_device_linux,
|
||||||
|
&cdio_is_device_generic
|
||||||
},
|
},
|
||||||
|
|
||||||
{DRIVER_SOLARIS,
|
{DRIVER_SOLARIS,
|
||||||
@@ -109,7 +113,8 @@ CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1] = {
|
|||||||
"Solaris ATAPI and SCSI driver",
|
"Solaris ATAPI and SCSI driver",
|
||||||
&cdio_have_solaris,
|
&cdio_have_solaris,
|
||||||
&cdio_open_solaris,
|
&cdio_open_solaris,
|
||||||
&cdio_get_default_device_solaris
|
&cdio_get_default_device_solaris,
|
||||||
|
&cdio_is_device_generic
|
||||||
},
|
},
|
||||||
|
|
||||||
{DRIVER_WIN32,
|
{DRIVER_WIN32,
|
||||||
@@ -118,7 +123,8 @@ CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1] = {
|
|||||||
"Windows 32-bit ASPI and winNT/2K/XP ioctl driver",
|
"Windows 32-bit ASPI and winNT/2K/XP ioctl driver",
|
||||||
&cdio_have_win32,
|
&cdio_have_win32,
|
||||||
&cdio_open_win32,
|
&cdio_open_win32,
|
||||||
&cdio_get_default_device_win32
|
&cdio_get_default_device_win32,
|
||||||
|
&cdio_is_device_win32
|
||||||
},
|
},
|
||||||
|
|
||||||
{DRIVER_BINCUE,
|
{DRIVER_BINCUE,
|
||||||
@@ -127,7 +133,8 @@ CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1] = {
|
|||||||
"bin/cuesheet disk image driver",
|
"bin/cuesheet disk image driver",
|
||||||
&cdio_have_bincue,
|
&cdio_have_bincue,
|
||||||
&cdio_open_bincue,
|
&cdio_open_bincue,
|
||||||
&cdio_get_default_device_bincue
|
&cdio_get_default_device_bincue,
|
||||||
|
NULL
|
||||||
},
|
},
|
||||||
|
|
||||||
{DRIVER_NRG,
|
{DRIVER_NRG,
|
||||||
@@ -136,7 +143,8 @@ CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1] = {
|
|||||||
"Nero NRG disk image driver",
|
"Nero NRG disk image driver",
|
||||||
&cdio_have_nrg,
|
&cdio_have_nrg,
|
||||||
&cdio_open_nrg,
|
&cdio_open_nrg,
|
||||||
&cdio_get_default_device_nrg
|
&cdio_get_default_device_nrg,
|
||||||
|
NULL
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -211,12 +219,19 @@ cdio_get_default_device (const CdIo *obj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
cdio_driver_describe(driver_id_t driver_id)
|
||||||
|
{
|
||||||
|
return CdIo_all_drivers[driver_id].describe;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Return a string containing the name of the driver in use.
|
Return a string containing the name of the driver in use.
|
||||||
if CdIo is NULL (we haven't initialized a specific device driver),
|
if CdIo is NULL (we haven't initialized a specific device driver),
|
||||||
then return NULL.
|
then return NULL.
|
||||||
*/
|
*/
|
||||||
const char * cdio_get_driver_name (const CdIo *obj)
|
const char *
|
||||||
|
cdio_get_driver_name (const CdIo *obj)
|
||||||
{
|
{
|
||||||
return CdIo_all_drivers[obj->driver_id].name;
|
return CdIo_all_drivers[obj->driver_id].name;
|
||||||
}
|
}
|
||||||
@@ -375,10 +390,11 @@ cdio_have_driver(driver_id_t driver_id)
|
|||||||
return (*CdIo_all_drivers[driver_id].have_driver)();
|
return (*CdIo_all_drivers[driver_id].have_driver)();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
bool
|
||||||
cdio_driver_describe(driver_id_t driver_id)
|
cdio_is_device(const char *source_name, driver_id_t driver_id)
|
||||||
{
|
{
|
||||||
return CdIo_all_drivers[driver_id].describe;
|
if (CdIo_all_drivers[driver_id].is_device == NULL) return false;
|
||||||
|
return (*CdIo_all_drivers[driver_id].is_device)(source_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -429,11 +445,12 @@ cdio_new (void *user_data, const cdio_funcs *funcs)
|
|||||||
void
|
void
|
||||||
cdio_destroy (CdIo *obj)
|
cdio_destroy (CdIo *obj)
|
||||||
{
|
{
|
||||||
cdio_assert (obj != NULL);
|
CdIo_last_driver = CDIO_DRIVER_UNINIT;
|
||||||
|
if (obj == NULL) return;
|
||||||
|
|
||||||
|
if (obj->op.free != NULL)
|
||||||
obj->op.free (obj->user_data);
|
obj->op.free (obj->user_data);
|
||||||
free (obj);
|
free (obj);
|
||||||
CdIo_last_driver = CDIO_DRIVER_UNINIT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -579,15 +596,16 @@ cdio_open (const char *orig_source_name, driver_id_t driver_id)
|
|||||||
switch (driver_id) {
|
switch (driver_id) {
|
||||||
case DRIVER_UNKNOWN:
|
case DRIVER_UNKNOWN:
|
||||||
{
|
{
|
||||||
|
CdIo *cdio=scan_for_driver(MIN_DEVICE_DRIVER, MAX_DEVICE_DRIVER,
|
||||||
|
source_name);
|
||||||
|
if (cdio != NULL && cdio_is_device(source_name, cdio->driver_id)) {
|
||||||
|
driver_id = cdio->driver_id;
|
||||||
|
} else {
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (0 != stat(source_name, &buf)) {
|
if (0 != stat(source_name, &buf)) {
|
||||||
cdio_error ("Can't get file status for %s:\n%s", source_name,
|
|
||||||
strerror(errno));
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (S_ISBLK(buf.st_mode) || S_ISCHR(buf.st_mode)) {
|
if (S_ISREG(buf.st_mode)) {
|
||||||
driver_id = DRIVER_DEVICE;
|
|
||||||
} else if (S_ISREG(buf.st_mode)) {
|
|
||||||
/* FIXME: check to see if is a text file. If so, then
|
/* FIXME: check to see if is a text file. If so, then
|
||||||
set SOURCE_CUE. */
|
set SOURCE_CUE. */
|
||||||
int i=strlen(source_name)-strlen("bin");
|
int i=strlen(source_name)-strlen("bin");
|
||||||
@@ -604,6 +622,8 @@ cdio_open (const char *orig_source_name, driver_id_t driver_id)
|
|||||||
else
|
else
|
||||||
driver_id = DRIVER_BINCUE;
|
driver_id = DRIVER_BINCUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
cdio_destroy(cdio);
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
case DRIVER_DEVICE:
|
case DRIVER_DEVICE:
|
||||||
|
|||||||
Reference in New Issue
Block a user