Probably closer towards compiling on those architectures.

This commit is contained in:
rocky
2003-03-29 20:28:05 +00:00
parent f488280282
commit 4b1e1307ea
2 changed files with 27 additions and 40 deletions

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_freebsd.c,v 1.2 2003/03/29 17:32:00 rocky Exp $ $Id: _cdio_freebsd.c,v 1.3 2003/03/29 20:28:05 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_freebsd.c,v 1.2 2003/03/29 17:32:00 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_freebsd.c,v 1.3 2003/03/29 20:28:05 rocky Exp $";
#include "cdio_assert.h" #include "cdio_assert.h"
#include "cdio_private.h" #include "cdio_private.h"
@@ -59,7 +59,9 @@ static const char _rcsid[] = "$Id: _cdio_freebsd.c,v 1.2 2003/03/29 17:32:00 roc
#define FIRST_TRACK_NUM (_obj->tochdr.starting_track) #define FIRST_TRACK_NUM (_obj->tochdr.starting_track)
typedef struct { typedef struct {
int fd; /* Things common to all drivers like this.
This must be first. */
generic_img_private_t gen;
int ioctls_debugged; /* for debugging */ int ioctls_debugged; /* for debugging */
@@ -70,8 +72,6 @@ typedef struct {
char *source_name; char *source_name;
bool init;
/* Track information */ /* Track information */
bool toc_init; /* if true, info below is valid. */ bool toc_init; /* if true, info below is valid. */
struct ioc_toc_header tochdr; struct ioc_toc_header tochdr;
@@ -85,39 +85,24 @@ typedef struct {
static bool static bool
_cdio_init (_img_private_t *_obj) _cdio_init (_img_private_t *_obj)
{ {
if (_obj->init) { if (_obj->gen.init) {
cdio_error ("init called more than once"); cdio_error ("init called more than once");
return false; return false;
} }
_obj->fd = open (_obj->source_name, O_RDONLY, 0); _obj->gen.fd = open (_obj->gen.source_name, O_RDONLY, 0);
if (_obj->fd < 0) if (_obj->gen.fd < 0)
{ {
cdio_error ("open (%s): %s", _obj->source_name, strerror (errno)); cdio_error ("open (%s): %s", _obj->gen.source_name, strerror (errno));
return false; return false;
} }
_obj->init = true; _obj->gen.init = true;
_obj->toc_init = false; _obj->toc_init = false;
return true; return true;
} }
/*!
Release and free resources associated with cd.
*/
static void
_cdio_free (void *user_data)
{
_img_private_t *_obj = user_data;
if (NULL == _obj) return;
free (_obj->source_name);
if (_obj->fd >= 0) close (_obj->fd);
free (_obj);
}
static int static int
_set_bsize (int fd, unsigned int bsize) _set_bsize (int fd, unsigned int bsize)
{ {
@@ -197,7 +182,7 @@ _read_mode2_sector (void *user_data, void *data, lsn_t lsn,
break; break;
case _AM_IOCTL: case _AM_IOCTL:
if (ioctl (_obj->fd, CDROMREADMODE2, &buf) == -1) if (ioctl (_obj->gen.fd, CDROMREADMODE2, &buf) == -1)
{ {
perror ("ioctl()"); perror ("ioctl()");
return 1; return 1;
@@ -258,7 +243,7 @@ _cdio_stat_size (void *user_data)
tocent.cdte_track = CDROM_LEADOUT; tocent.cdte_track = CDROM_LEADOUT;
tocent.cdte_format = CDROM_LBA; tocent.cdte_format = CDROM_LBA;
if (ioctl (_obj->fd, CDROMREADTOCENTRY, &tocent) == -1) if (ioctl (_obj->gen.fd, CDROMREADTOCENTRY, &tocent) == -1)
{ {
perror ("ioctl(CDROMREADTOCENTRY)"); perror ("ioctl(CDROMREADTOCENTRY)");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
@@ -282,9 +267,9 @@ _cdio_set_arg (void *user_data, const char key[], const char value[])
if (!value) if (!value)
return -2; return -2;
free (_obj->source_name); free (_obj->gen.source_name);
_obj->source_name = strdup (value); _obj->gen.source_name = strdup (value);
} }
else if (!strcmp (key, "access-mode")) else if (!strcmp (key, "access-mode"))
{ {
@@ -314,7 +299,7 @@ _cdio_read_toc (_img_private_t *_obj)
struct ioc_read_toc_entry te; struct ioc_read_toc_entry te;
/* read TOC header */ /* read TOC header */
if ( ioctl(_obj->fd, CDROMREADTOCHDR, &_obj->tochdr) == -1 ) { if ( ioctl(_obj->gen.fd, CDROMREADTOCHDR, &_obj->tochdr) == -1 ) {
cdio_error("error in ioctl(CDROMREADTOCHDR): %s\n", strerror(errno)); cdio_error("error in ioctl(CDROMREADTOCHDR): %s\n", strerror(errno));
return false; return false;
} }
@@ -325,7 +310,7 @@ _cdio_read_toc (_img_private_t *_obj)
te.data = _obj->tocent; te.data = _obj->tocent;
if ( ioctl(_obj->fd, CDIOREADTOCENTRYS, &te) == -1 ) { if ( ioctl(_obj->gen.fd, CDIOREADTOCENTRYS, &te) == -1 ) {
cdio_error("%s %d: %s\n", cdio_error("%s %d: %s\n",
"error in ioctl CDROMREADTOCENTRY for track", "error in ioctl CDROMREADTOCENTRY for track",
i, strerror(errno)); i, strerror(errno));
@@ -347,7 +332,7 @@ _cdio_eject_media (void *user_data) {
int status; int status;
int fd; int fd;
if ((fd = open(_obj->source_name, O_RDONLY|O_NONBLOCK)) > -1) { if ((fd = open(_obj->gen.source_name, O_RDONLY|O_NONBLOCK)) > -1) {
ret = 1; ret = 1;
if (ioctl(fd, CDIOCALLOW) == -1) { if (ioctl(fd, CDIOCALLOW) == -1) {
cdio_error("ioctl(fd, CDIOCALLOW) failed: %s\n", strerror(errno)); cdio_error("ioctl(fd, CDIOCALLOW) failed: %s\n", strerror(errno));
@@ -357,7 +342,7 @@ _cdio_eject_media (void *user_data) {
ret = 0; ret = 0;
} }
close(fd); close(fd);
_cdio_free((void *) _obj); _cdio_generic_free((void *) _obj);
} }
return ret; return ret;
@@ -372,7 +357,7 @@ _cdio_get_arg (void *user_data, const char key[])
_img_private_t *_obj = user_data; _img_private_t *_obj = user_data;
if (!strcmp (key, "source")) { if (!strcmp (key, "source")) {
return _obj->source_name; return _obj->gen.source_name;
} else if (!strcmp (key, "access-mode")) { } else if (!strcmp (key, "access-mode")) {
switch (_obj->access_mode) { switch (_obj->access_mode) {
case _AM_IOCTL: case _AM_IOCTL:
@@ -521,7 +506,7 @@ cdio_open_freebsd (const char *source_name)
cdio_funcs _funcs = { cdio_funcs _funcs = {
.eject_media = _cdio_eject_media, .eject_media = _cdio_eject_media,
.free = _cdio_free, .free = _cdio_generic_free,
.get_arg = _cdio_get_arg, .get_arg = _cdio_get_arg,
.get_default_device = _cdio_get_default_device, .get_default_device = _cdio_get_default_device,
.get_first_track_num= _cdio_get_first_track_num, .get_first_track_num= _cdio_get_first_track_num,
@@ -530,6 +515,8 @@ cdio_open_freebsd (const char *source_name)
.get_track_green = _cdio_get_track_green, .get_track_green = _cdio_get_track_green,
.get_track_lba = NULL, /* This could be implemented if need be. */ .get_track_lba = NULL, /* This could be implemented if need be. */
.get_track_msf = _cdio_get_track_msf, .get_track_msf = _cdio_get_track_msf,
.lseek = cdio_generic_lseek,
.read = cdio_generic_read,
.read_mode2_sector = _read_mode2_sector, .read_mode2_sector = _read_mode2_sector,
.read_mode2_sectors = _read_mode2_sectors, .read_mode2_sectors = _read_mode2_sectors,
.set_arg = _cdio_set_arg, .set_arg = _cdio_set_arg,
@@ -539,7 +526,7 @@ cdio_open_freebsd (const char *source_name)
_data = _cdio_malloc (sizeof (_img_private_t)); _data = _cdio_malloc (sizeof (_img_private_t));
_data->access_mode = _AM_READ_CD; _data->access_mode = _AM_READ_CD;
_data->init = false; _data->init = false;
_data->fd = -1; _data->gen.fd = -1;
_cdio_set_arg(_data, "source", (NULL == source_name) _cdio_set_arg(_data, "source", (NULL == source_name)
? DEFAULT_CDIO_DEVICE: source_name); ? DEFAULT_CDIO_DEVICE: source_name);
@@ -550,7 +537,7 @@ cdio_open_freebsd (const char *source_name)
if (_cdio_init(_data)) if (_cdio_init(_data))
return ret; return ret;
else { else {
_cdio_free (_data); _cdio_generic_free (_data);
return NULL; return NULL;
} }

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_sunos.c,v 1.2 2003/03/29 17:32:00 rocky Exp $ $Id: _cdio_sunos.c,v 1.3 2003/03/29 20:28:05 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
@@ -31,7 +31,7 @@
#ifdef HAVE_SOLARIS_CDROM #ifdef HAVE_SOLARIS_CDROM
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.2 2003/03/29 17:32:00 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.3 2003/03/29 20:28:05 rocky Exp $";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -609,7 +609,7 @@ cdio_open_solaris (const char *source_name)
}; };
_data = _cdio_malloc (sizeof (_img_private_t)); _data = _cdio_malloc (sizeof (_img_private_t));
_data->fd = -1; _data->gen.fd = -1;
_cdio_set_arg(_data, "source", (NULL == source_name) _cdio_set_arg(_data, "source", (NULL == source_name)
? DEFAULT_CDIO_DEVICE: source_name); ? DEFAULT_CDIO_DEVICE: source_name);