More common routiens and structures moved to cdio_generic.c or
cdio_private.h respectively.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_bincue.c,v 1.3 2003/03/29 21:13:55 rocky Exp $
|
||||
$Id: _cdio_bincue.c,v 1.4 2003/03/30 13:01:22 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -28,7 +28,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.3 2003/03/29 21:13:55 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.4 2003/03/30 13:01:22 rocky Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
@@ -64,8 +64,10 @@ typedef struct {
|
||||
|
||||
|
||||
typedef struct {
|
||||
char *source_name;
|
||||
bool init;
|
||||
/* Things common to all drivers like this.
|
||||
This must be first. */
|
||||
generic_img_private_t gen;
|
||||
|
||||
bool sector_2336_flag;
|
||||
|
||||
CdioDataSource *data_source;
|
||||
@@ -87,10 +89,10 @@ _cdio_init (_img_private_t *_obj)
|
||||
{
|
||||
lsn_t lead_lsn;
|
||||
|
||||
if (_obj->init)
|
||||
if (_obj->gen.init)
|
||||
return false;
|
||||
|
||||
if (!(_obj->data_source = cdio_stdio_new (_obj->source_name))) {
|
||||
if (!(_obj->data_source = cdio_stdio_new (_obj->gen.source_name))) {
|
||||
cdio_error ("init failed");
|
||||
return false;
|
||||
}
|
||||
@@ -98,7 +100,7 @@ _cdio_init (_img_private_t *_obj)
|
||||
/* Have to set init before calling _cdio_stat_size() or we will
|
||||
get into infinite recursion calling passing right here.
|
||||
*/
|
||||
_obj->init = true;
|
||||
_obj->gen.init = true;
|
||||
|
||||
lead_lsn = _cdio_stat_size( (_img_private_t *) _obj);
|
||||
|
||||
@@ -364,7 +366,7 @@ _cdio_free (void *user_data)
|
||||
{
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
free (_obj->source_name);
|
||||
free (_obj->gen.source_name);
|
||||
|
||||
if (_obj->data_source)
|
||||
cdio_stream_destroy (_obj->data_source);
|
||||
@@ -438,12 +440,12 @@ _cdio_set_arg (void *user_data, const char key[], const char value[])
|
||||
|
||||
if (!strcmp (key, "source"))
|
||||
{
|
||||
free (_obj->source_name);
|
||||
free (_obj->gen.source_name);
|
||||
|
||||
if (!value)
|
||||
return -2;
|
||||
|
||||
_obj->source_name = strdup (value);
|
||||
_obj->gen.source_name = strdup (value);
|
||||
}
|
||||
else if (!strcmp (key, "sector"))
|
||||
{
|
||||
@@ -469,16 +471,6 @@ _cdio_set_arg (void *user_data, const char key[], const char value[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Eject media -- there's nothing to do here. We always return 2.
|
||||
also free obj.
|
||||
*/
|
||||
static int
|
||||
_cdio_eject_media (void *user_data) {
|
||||
/* Sort of a stub here. Perhaps log a message? */
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the value associated with the key "arg".
|
||||
*/
|
||||
@@ -488,7 +480,7 @@ _cdio_get_arg (void *user_data, const char key[])
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!strcmp (key, "source")) {
|
||||
return _obj->source_name;
|
||||
return _obj->gen.source_name;
|
||||
} else if (!strcmp (key, "cue")) {
|
||||
return _obj->cue_name;
|
||||
}
|
||||
@@ -542,7 +534,7 @@ _cdio_get_track_format(void *user_data, track_t track_num)
|
||||
{
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!_obj->init) _cdio_init(_obj);
|
||||
if (!_obj->gen.init) _cdio_init(_obj);
|
||||
|
||||
if (track_num > _obj->total_tracks || track_num == 0)
|
||||
return TRACK_FORMAT_ERROR;
|
||||
@@ -563,7 +555,7 @@ _cdio_get_track_green(void *user_data, track_t track_num)
|
||||
{
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!_obj->init) _cdio_init(_obj);
|
||||
if (!_obj->gen.init) _cdio_init(_obj);
|
||||
|
||||
if (track_num > _obj->total_tracks || track_num == 0)
|
||||
return false;
|
||||
@@ -623,7 +615,7 @@ cdio_open_bincue (const char *source_name)
|
||||
_img_private_t *_data;
|
||||
|
||||
cdio_funcs _funcs = {
|
||||
.eject_media = _cdio_eject_media,
|
||||
.eject_media = cdio_generic_bogus_eject_media,
|
||||
.free = _cdio_free,
|
||||
.get_arg = _cdio_get_arg,
|
||||
.get_default_device = _cdio_get_default_device,
|
||||
@@ -640,7 +632,7 @@ cdio_open_bincue (const char *source_name)
|
||||
};
|
||||
|
||||
_data = _cdio_malloc (sizeof (_img_private_t));
|
||||
_data->init = false;
|
||||
_data->gen.init = false;
|
||||
|
||||
/* FIXME: should set cue initially. */
|
||||
_data->cue_name = NULL;
|
||||
@@ -661,7 +653,7 @@ cdio_open_cue (const char *cue_name)
|
||||
_img_private_t *_data;
|
||||
|
||||
cdio_funcs _funcs = {
|
||||
.eject_media = _cdio_eject_media,
|
||||
.eject_media = cdio_generic_bogus_eject_media,
|
||||
.free = _cdio_free,
|
||||
.get_arg = _cdio_get_arg,
|
||||
.get_default_device = _cdio_get_default_device,
|
||||
@@ -680,7 +672,7 @@ cdio_open_cue (const char *cue_name)
|
||||
};
|
||||
|
||||
_data = _cdio_malloc (sizeof (_img_private_t));
|
||||
_data->init = false;
|
||||
_data->gen.init = false;
|
||||
|
||||
if (cue_name != NULL) {
|
||||
char *source_name=strdup(cue_name);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_bsdi.c,v 1.4 2003/03/30 01:11:35 rocky Exp $
|
||||
$Id: _cdio_bsdi.c,v 1.5 2003/03/30 13:01:22 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -27,7 +27,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.4 2003/03/30 01:11:35 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.5 2003/03/30 13:01:22 rocky Exp $";
|
||||
|
||||
#include "cdio_assert.h"
|
||||
#include "cdio_private.h"
|
||||
@@ -48,7 +48,7 @@ static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.4 2003/03/30 01:11:35 rocky
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#define DEFAULT_CDIO_DEVICE "/dev/sr0"
|
||||
#define DEFAULT_CDIO_DEVICE "/dev/rsr0c"
|
||||
|
||||
#define TOTAL_TRACKS (_obj->tochdr.cdth_trk1)
|
||||
#define FIRST_TRACK_NUM (_obj->tochdr.cdth_trk0)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_generic.c,v 1.2 2003/03/29 21:13:55 rocky Exp $
|
||||
$Id: _cdio_generic.c,v 1.3 2003/03/30 13:01:22 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -27,7 +27,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.2 2003/03/29 21:13:55 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.3 2003/03/30 13:01:22 rocky Exp $";
|
||||
|
||||
#include "cdio_assert.h"
|
||||
#include "cdio_private.h"
|
||||
@@ -45,6 +45,17 @@ static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.2 2003/03/29 21:13:55 roc
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
/*!
|
||||
Eject media -- there's nothing to do here. We always return 2.
|
||||
Should we also free resources?
|
||||
*/
|
||||
int
|
||||
cdio_generic_bogus_eject_media (void *user_data) {
|
||||
/* Sort of a stub here. Perhaps log a message? */
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Release and free resources associated with cd.
|
||||
*/
|
||||
@@ -62,6 +73,31 @@ cdio_generic_free (void *user_data)
|
||||
free (_obj);
|
||||
}
|
||||
|
||||
/*!
|
||||
Initialize CD device.
|
||||
*/
|
||||
bool
|
||||
cdio_generic_init (void *user_data)
|
||||
{
|
||||
generic_img_private_t *_obj = user_data;
|
||||
if (_obj->init) {
|
||||
cdio_error ("init called more than once");
|
||||
return false;
|
||||
}
|
||||
|
||||
_obj->fd = open (_obj->source_name, O_RDONLY, 0);
|
||||
|
||||
if (_obj->fd < 0)
|
||||
{
|
||||
cdio_error ("open (%s): %s", _obj->source_name, strerror (errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
_obj->init = true;
|
||||
_obj->toc_init = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads into buf the next size bytes.
|
||||
Returns -1 on error.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_linux.c,v 1.3 2003/03/29 17:32:00 rocky Exp $
|
||||
$Id: _cdio_linux.c,v 1.4 2003/03/30 13:01:22 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -27,7 +27,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.3 2003/03/29 17:32:00 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.4 2003/03/30 13:01:22 rocky Exp $";
|
||||
|
||||
#include "cdio_assert.h"
|
||||
#include "cdio_private.h"
|
||||
@@ -76,39 +76,12 @@ typedef struct {
|
||||
_AM_READ_10
|
||||
} access_mode;
|
||||
|
||||
int ioctls_debugged; /* for debugging */
|
||||
|
||||
/* Track information */
|
||||
bool toc_init; /* if true, info below is valid. */
|
||||
struct cdrom_tochdr tochdr;
|
||||
struct cdrom_tocentry tocent[100]; /* entry info for each track */
|
||||
|
||||
} _img_private_t;
|
||||
|
||||
/*!
|
||||
Initialize CD device.
|
||||
*/
|
||||
static bool
|
||||
_cdio_init (_img_private_t *_obj)
|
||||
{
|
||||
if (_obj->gen.init) {
|
||||
cdio_error ("init called more than once");
|
||||
return false;
|
||||
}
|
||||
|
||||
_obj->gen.fd = open (_obj->gen.source_name, O_RDONLY, 0);
|
||||
|
||||
if (_obj->gen.fd < 0)
|
||||
{
|
||||
cdio_error ("open (%s): %s", _obj->gen.source_name, strerror (errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
_obj->gen.init = true;
|
||||
_obj->toc_init = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int
|
||||
_set_bsize (int fd, unsigned int bsize)
|
||||
{
|
||||
@@ -249,20 +222,20 @@ _cdio_read_mode2_sector (void *user_data, void *data, lsn_t lsn,
|
||||
msf->cdmsf_sec0 = from_bcd8(_msf.s);
|
||||
msf->cdmsf_frame0 = from_bcd8(_msf.f);
|
||||
|
||||
if (_obj->ioctls_debugged == 75)
|
||||
if (_obj->gen.ioctls_debugged == 75)
|
||||
cdio_debug ("only displaying every 75th ioctl from now on");
|
||||
|
||||
if (_obj->ioctls_debugged == 30 * 75)
|
||||
if (_obj->gen.ioctls_debugged == 30 * 75)
|
||||
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
||||
|
||||
if (_obj->ioctls_debugged < 75
|
||||
|| (_obj->ioctls_debugged < (30 * 75)
|
||||
&& _obj->ioctls_debugged % 75 == 0)
|
||||
|| _obj->ioctls_debugged % (30 * 75) == 0)
|
||||
if (_obj->gen.ioctls_debugged < 75
|
||||
|| (_obj->gen.ioctls_debugged < (30 * 75)
|
||||
&& _obj->gen.ioctls_debugged % 75 == 0)
|
||||
|| _obj->gen.ioctls_debugged % (30 * 75) == 0)
|
||||
cdio_debug ("reading %2.2d:%2.2d:%2.2d",
|
||||
msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
|
||||
|
||||
_obj->ioctls_debugged++;
|
||||
_obj->gen.ioctls_debugged++;
|
||||
|
||||
retry:
|
||||
switch (_obj->access_mode)
|
||||
@@ -539,7 +512,7 @@ _cdio_get_first_track_num(void *user_data)
|
||||
{
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!_obj->toc_init) _cdio_read_toc (_obj) ;
|
||||
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
||||
|
||||
return FIRST_TRACK_NUM;
|
||||
}
|
||||
@@ -553,7 +526,7 @@ _cdio_get_num_tracks(void *user_data)
|
||||
{
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!_obj->toc_init) _cdio_read_toc (_obj) ;
|
||||
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
||||
|
||||
return TOTAL_TRACKS;
|
||||
}
|
||||
@@ -566,7 +539,7 @@ _cdio_get_track_format(void *user_data, track_t track_num)
|
||||
{
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!_obj->toc_init) _cdio_read_toc (_obj) ;
|
||||
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
||||
|
||||
if (track_num > TOTAL_TRACKS || track_num == 0)
|
||||
return TRACK_FORMAT_ERROR;
|
||||
@@ -599,7 +572,7 @@ _cdio_get_track_green(void *user_data, track_t track_num)
|
||||
{
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!_obj->toc_init) _cdio_read_toc (_obj) ;
|
||||
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
||||
|
||||
if (track_num == CDIO_LEADOUT_TRACK) track_num = TOTAL_TRACKS+1;
|
||||
|
||||
@@ -626,7 +599,7 @@ _cdio_get_track_msf(void *user_data, track_t track_num, msf_t *msf)
|
||||
|
||||
if (NULL == msf) return false;
|
||||
|
||||
if (!_obj->toc_init) _cdio_read_toc (_obj) ;
|
||||
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
||||
|
||||
if (track_num == CDIO_LEADOUT_TRACK) track_num = TOTAL_TRACKS+1;
|
||||
|
||||
@@ -686,7 +659,7 @@ cdio_open_linux (const char *source_name)
|
||||
ret = cdio_new (_data, &_funcs);
|
||||
if (ret == NULL) return NULL;
|
||||
|
||||
if (_cdio_init(_data))
|
||||
if (cdio_generic_init(_data))
|
||||
return ret;
|
||||
else {
|
||||
cdio_generic_free (_data);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_nrg.c,v 1.3 2003/03/29 21:13:55 rocky Exp $
|
||||
$Id: _cdio_nrg.c,v 1.4 2003/03/30 13:01:22 rocky Exp $
|
||||
|
||||
Copyright (C) 2001,2003 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "util.h"
|
||||
#include "_cdio_stdio.h"
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_nrg.c,v 1.3 2003/03/29 21:13:55 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_nrg.c,v 1.4 2003/03/30 13:01:22 rocky Exp $";
|
||||
|
||||
/* structures used */
|
||||
|
||||
@@ -121,15 +121,17 @@ typedef struct {
|
||||
|
||||
|
||||
typedef struct {
|
||||
/* Things common to all drivers like this.
|
||||
This must be first. */
|
||||
generic_img_private_t gen;
|
||||
|
||||
bool sector_2336_flag;
|
||||
CdioDataSource *data_source;
|
||||
char *source_name;
|
||||
track_info_t tocent[100]; /* entry info for each track */
|
||||
track_t total_tracks; /* number of tracks in image */
|
||||
track_t first_track_num; /* track number of first track */
|
||||
CdioList *mapping; /* List of track information */
|
||||
uint32_t size;
|
||||
bool init;
|
||||
} _img_private_t;
|
||||
|
||||
static bool _cdio_parse_nero_footer (_img_private_t *_obj);
|
||||
@@ -143,7 +145,7 @@ _cdio_free (void *user_data)
|
||||
{
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
free(_obj->source_name);
|
||||
free(_obj->gen.source_name);
|
||||
|
||||
if (_obj->data_source)
|
||||
cdio_stream_destroy (_obj->data_source);
|
||||
@@ -481,18 +483,18 @@ PRAGMA_END_PACKED
|
||||
static bool
|
||||
_cdio_init (_img_private_t *_obj)
|
||||
{
|
||||
if (_obj->init) {
|
||||
if (_obj->gen.init) {
|
||||
cdio_error ("init called more than once");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(_obj->data_source = cdio_stdio_new (_obj->source_name))) {
|
||||
if (!(_obj->data_source = cdio_stdio_new (_obj->gen.source_name))) {
|
||||
cdio_error ("init failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
_cdio_parse_nero_footer (_obj);
|
||||
_obj->init = true;
|
||||
_obj->gen.init = true;
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -663,12 +665,12 @@ _cdio_set_arg (void *user_data, const char key[], const char value[])
|
||||
|
||||
if (!strcmp (key, "source"))
|
||||
{
|
||||
free (_obj->source_name);
|
||||
free (_obj->gen.source_name);
|
||||
|
||||
if (!value)
|
||||
return -2;
|
||||
|
||||
_obj->source_name = strdup (value);
|
||||
_obj->gen.source_name = strdup (value);
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
@@ -676,16 +678,6 @@ _cdio_set_arg (void *user_data, const char key[], const char value[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Eject media -- there's nothing to do here. We always return 2.
|
||||
also free obj.
|
||||
*/
|
||||
static int
|
||||
_cdio_eject_media (void *user_data) {
|
||||
/* Sort of a stub here. Perhaps log a message? */
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*!
|
||||
Return the value associated with the key "arg".
|
||||
*/
|
||||
@@ -695,7 +687,7 @@ _cdio_get_arg (void *user_data, const char key[])
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!strcmp (key, "source")) {
|
||||
return _obj->source_name;
|
||||
return _obj->gen.source_name;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -796,7 +788,7 @@ cdio_open_nrg (const char *source_name)
|
||||
_img_private_t *_data;
|
||||
|
||||
cdio_funcs _funcs = {
|
||||
.eject_media = _cdio_eject_media,
|
||||
.eject_media = cdio_generic_bogus_eject_media,
|
||||
.free = _cdio_free,
|
||||
.get_arg = _cdio_get_arg,
|
||||
.get_default_device = _cdio_get_default_device,
|
||||
@@ -815,7 +807,7 @@ cdio_open_nrg (const char *source_name)
|
||||
};
|
||||
|
||||
_data = _cdio_malloc (sizeof (_img_private_t));
|
||||
_data->init = false;
|
||||
_data->gen.init = false;
|
||||
|
||||
|
||||
_data->total_tracks = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_sunos.c,v 1.4 2003/03/29 21:13:55 rocky Exp $
|
||||
$Id: _cdio_sunos.c,v 1.5 2003/03/30 13:01:22 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#ifdef HAVE_SOLARIS_CDROM
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.4 2003/03/29 21:13:55 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.5 2003/03/30 13:01:22 rocky Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -77,10 +77,7 @@ typedef struct {
|
||||
} access_mode;
|
||||
|
||||
|
||||
int ioctls_debugged; /* for debugging */
|
||||
|
||||
/* Track information */
|
||||
bool toc_init; /* if true, info below is valid. */
|
||||
struct cdrom_tochdr tochdr;
|
||||
struct cdrom_tocentry tocent[100]; /* entry info for each track */
|
||||
|
||||
@@ -95,13 +92,7 @@ _cdio_init (_img_private_t *_obj)
|
||||
|
||||
struct dk_cinfo cinfo;
|
||||
|
||||
_obj->gen.fd = open (_obj->gen.source_name, O_RDONLY, 0);
|
||||
|
||||
if (_obj->gen.fd < 0)
|
||||
{
|
||||
cdio_error ("open (%s): %s", _obj->gen.source_name, strerror (errno));
|
||||
return false;
|
||||
}
|
||||
if (!cdio_generic_init(_obj)) return false;
|
||||
|
||||
/*
|
||||
* CDROMCDXA/CDROMREADMODE2 are broken on IDE/ATAPI devices.
|
||||
@@ -116,9 +107,6 @@ _cdio_init (_img_private_t *_obj)
|
||||
_obj->access_mode = _AM_SUN_CTRL_SCSI;
|
||||
}
|
||||
|
||||
_obj->gen.init = true;
|
||||
_obj->toc_init = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -141,20 +129,20 @@ _read_mode2_sector (void *user_data, void *data, lsn_t lsn,
|
||||
msf->cdmsf_sec0 = from_bcd8(_msf.s);
|
||||
msf->cdmsf_frame0 = from_bcd8(_msf.f);
|
||||
|
||||
if (_obj->ioctls_debugged == 75)
|
||||
if (_obj->gen.ioctls_debugged == 75)
|
||||
cdio_debug ("only displaying every 75th ioctl from now on");
|
||||
|
||||
if (_obj->ioctls_debugged == 30 * 75)
|
||||
if (_obj->gen.ioctls_debugged == 30 * 75)
|
||||
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
||||
|
||||
if (_obj->ioctls_debugged < 75
|
||||
|| (_obj->ioctls_debugged < (30 * 75)
|
||||
&& _obj->ioctls_debugged % 75 == 0)
|
||||
|| _obj->ioctls_debugged % (30 * 75) == 0)
|
||||
if (_obj->gen.ioctls_debugged < 75
|
||||
|| (_obj->gen.ioctls_debugged < (30 * 75)
|
||||
&& _obj->gen.ioctls_debugged % 75 == 0)
|
||||
|| _obj->gen.ioctls_debugged % (30 * 75) == 0)
|
||||
cdio_debug ("reading %2.2d:%2.2d:%2.2d",
|
||||
msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0);
|
||||
|
||||
_obj->ioctls_debugged++;
|
||||
_obj->gen.ioctls_debugged++;
|
||||
|
||||
switch (_obj->access_mode)
|
||||
{
|
||||
@@ -470,7 +458,7 @@ _cdio_get_first_track_num(void *user_data)
|
||||
{
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!_obj->toc_init) _cdio_read_toc (_obj) ;
|
||||
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
||||
|
||||
return FIRST_TRACK_NUM;
|
||||
}
|
||||
@@ -483,7 +471,7 @@ _cdio_get_num_tracks(void *user_data)
|
||||
{
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!_obj->toc_init) _cdio_read_toc (_obj) ;
|
||||
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
||||
|
||||
return TOTAL_TRACKS;
|
||||
}
|
||||
@@ -497,7 +485,7 @@ _cdio_get_track_format(void *user_data, track_t track_num)
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!_obj->gen.init) _cdio_init(_obj);
|
||||
if (!_obj->toc_init) _cdio_read_toc (_obj) ;
|
||||
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
||||
|
||||
if (track_num > TOTAL_TRACKS || track_num == 0)
|
||||
return TRACK_FORMAT_ERROR;
|
||||
@@ -531,7 +519,7 @@ _cdio_get_track_green(void *user_data, track_t track_num)
|
||||
_img_private_t *_obj = user_data;
|
||||
|
||||
if (!_obj->gen.init) _cdio_init(_obj);
|
||||
if (!_obj->toc_init) _cdio_read_toc (_obj) ;
|
||||
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
||||
|
||||
if (track_num == CDIO_LEADOUT_TRACK) track_num = TOTAL_TRACKS+1;
|
||||
|
||||
@@ -559,7 +547,7 @@ _cdio_get_track_msf(void *user_data, track_t track_num, msf_t *msf)
|
||||
if (NULL == msf) return false;
|
||||
|
||||
if (!_obj->gen.init) _cdio_init(_obj);
|
||||
if (!_obj->toc_init) _cdio_read_toc (_obj) ;
|
||||
if (!_obj->gen.toc_init) _cdio_read_toc (_obj) ;
|
||||
|
||||
if (track_num == CDIO_LEADOUT_TRACK) track_num = TOTAL_TRACKS+1;
|
||||
|
||||
|
||||
20
lib/cdio.c
20
lib/cdio.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cdio.c,v 1.3 2003/03/29 17:32:00 rocky Exp $
|
||||
$Id: cdio.c,v 1.4 2003/03/30 13:01:22 rocky Exp $
|
||||
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "logging.h"
|
||||
#include "cdio_private.h"
|
||||
|
||||
static const char _rcsid[] = "$Id: cdio.c,v 1.3 2003/03/29 17:32:00 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: cdio.c,v 1.4 2003/03/30 13:01:22 rocky Exp $";
|
||||
|
||||
|
||||
const char *track_format2str[5] =
|
||||
@@ -97,20 +97,20 @@ CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1] = {
|
||||
&cdio_open_solaris
|
||||
},
|
||||
|
||||
{DRIVER_NRG,
|
||||
CDIO_SRC_IS_DISK_IMAGE_MASK,
|
||||
"NRG",
|
||||
"Nero NRG disk image driver",
|
||||
&cdio_have_nrg,
|
||||
&cdio_open_nrg
|
||||
},
|
||||
|
||||
{DRIVER_BINCUE,
|
||||
CDIO_SRC_IS_DISK_IMAGE_MASK,
|
||||
"BIN/CUE",
|
||||
"bin/cuesheet disk image driver",
|
||||
&cdio_have_bincue,
|
||||
&cdio_open_bincue
|
||||
},
|
||||
|
||||
{DRIVER_NRG,
|
||||
CDIO_SRC_IS_DISK_IMAGE_MASK,
|
||||
"NRG",
|
||||
"Nero NRG disk image driver",
|
||||
&cdio_have_nrg,
|
||||
&cdio_open_nrg
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
17
lib/cdio.h
17
lib/cdio.h
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cdio.h,v 1.3 2003/03/29 17:32:00 rocky Exp $
|
||||
$Id: cdio.h,v 1.4 2003/03/30 13:01:22 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -51,6 +51,15 @@ extern "C" {
|
||||
/* The below enumerations may be used to tag a specific driver
|
||||
that is opened or is desired to be opened. Note that this is
|
||||
different than what is available on a given host.
|
||||
|
||||
Order is a little significant since the order is used in scans.
|
||||
We have to start with UNKNOWN and devices should come before
|
||||
disk-image readers. By putting something towards the top (a lower
|
||||
enumeration number), in an iterative scan we prefer that to something
|
||||
with a higher enumeration number.
|
||||
|
||||
NOTE: IF YOU MODIFY ENUM MAKE SURE INITIALIZATION IN CDIO.C AGREES.
|
||||
|
||||
*/
|
||||
typedef enum {
|
||||
DRIVER_UNKNOWN,
|
||||
@@ -58,15 +67,15 @@ extern "C" {
|
||||
DRIVER_FREEBSD,
|
||||
DRIVER_LINUX,
|
||||
DRIVER_SOLARIS,
|
||||
DRIVER_BINCUE, /* Prefer bincue over nrg when both exist */
|
||||
DRIVER_NRG,
|
||||
DRIVER_BINCUE,
|
||||
DRIVER_DEVICE,
|
||||
DRIVER_DEVICE, /* Is really a set of the above; should come last */
|
||||
} driver_id_t;
|
||||
|
||||
/* Make sure what's listed below is the last one above. Since we have
|
||||
a bogus (but useful) 0th entry above we don't have to add one below.
|
||||
*/
|
||||
#define MAX_DRIVER DRIVER_BINCUE
|
||||
#define MAX_DRIVER DRIVER_NRG
|
||||
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cdio_private.h,v 1.2 2003/03/29 17:32:00 rocky Exp $
|
||||
$Id: cdio_private.h,v 1.3 2003/03/30 13:01:22 rocky Exp $
|
||||
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -147,11 +147,21 @@ extern "C" {
|
||||
} cdio_funcs;
|
||||
|
||||
|
||||
/* Things that just about all private device structures have. */
|
||||
/*!
|
||||
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 TOC read in */
|
||||
int ioctls_debugged; /* for debugging */
|
||||
int fd; /* File descriptor of device */
|
||||
off_t buff_offset; /* buffer offset in disk-image seeks.
|
||||
(Not used in CD device access)
|
||||
*/
|
||||
} generic_img_private_t;
|
||||
|
||||
CdIo * cdio_new (void *user_data, const cdio_funcs *funcs);
|
||||
@@ -180,11 +190,22 @@ extern "C" {
|
||||
on a particular host. */
|
||||
extern CdIo_driver_t CdIo_all_drivers[MAX_DRIVER+1];
|
||||
|
||||
/*!
|
||||
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 *user_data);
|
||||
|
||||
/*!
|
||||
Release and free resources associated with cd.
|
||||
*/
|
||||
void cdio_generic_free (void *user_data);
|
||||
|
||||
/*!
|
||||
Initialize CD device.
|
||||
*/
|
||||
bool cdio_generic_init (void *user_data);
|
||||
|
||||
/*!
|
||||
Reads into buf the next size bytes.
|
||||
Returns -1 on error.
|
||||
@@ -212,7 +233,6 @@ extern "C" {
|
||||
cdio_funcs op;
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
Reference in New Issue
Block a user