Lots of portability fixes to make non GNU/Linux-specific. Now runs on Solaris!

This commit is contained in:
rocky
2005-01-06 03:09:11 +00:00
parent f939e73e52
commit 97af0343c5
7 changed files with 62 additions and 67 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: common_interface.c,v 1.3 2005/01/05 04:16:11 rocky Exp $
$Id: common_interface.c,v 1.4 2005/01/06 03:09:11 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1998, 2002 Monty monty@xiph.org
@@ -32,42 +32,6 @@
#include "utils.h"
#include "smallft.h"
#include <linux/hdreg.h>
/* Test for presence of a cdrom by pinging with the 'CDROMVOLREAD' ioctl() */
int
ioctl_ping_cdrom(int fd)
{
struct cdrom_volctrl volctl;
if (ioctl(fd, CDROMVOLREAD, &volctl))
return(1); /* failure */
return(0);
/* success! */
}
/* Use the ioctl thingy above ping the cdrom; this will get model info */
char *atapi_drive_info(int fd){
/* Work around the fact that the struct grew without warning in
2.1/2.0.34 */
struct hd_driveid *id=malloc(512); /* the size in 2.0.34 */
char *ret;
if (!(ioctl(fd, HDIO_GET_IDENTITY, id))) {
if(id->model==0 || id->model[0]==0)
ret=strdup("Generic Unidentifiable ATAPI CDROM");
else
ret=strdup(id->model);
}else
ret=strdup("Generic Unidentifiable CDROM");
free(id);
return(ret);
}
int
data_bigendianp(cdrom_drive_t *d)
{

View File

@@ -1,5 +1,5 @@
/*
$Id: cooked_interface.c,v 1.4 2005/01/06 01:15:51 rocky Exp $
$Id: cooked_interface.c,v 1.5 2005/01/06 03:09:11 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Original interface.c Copyright (C) 1994-1997
@@ -77,16 +77,11 @@ static long int
cooked_read (cdrom_drive_t *d, void *p, lsn_t begin, long sectors)
{
int retry_count,err;
struct cdrom_read_audio arg;
char *buffer=(char *)p;
/* read d->nsectors at a time, max. */
sectors=( sectors > d->nsectors ? d->nsectors : sectors);
arg.addr.lba = begin;
arg.addr_format = CDROM_LBA;
arg.nframes = sectors;
arg.buf=buffer;
retry_count=0;
do {
@@ -135,7 +130,7 @@ static int
verify_read_command(cdrom_drive_t *d)
{
int i;
int16_t *buff=malloc(CD_FRAMESIZE_RAW);
int16_t *buff=malloc(CDIO_CD_FRAMESIZE_RAW);
int audioflag=0;
cdmessage(d,"Verifying drive can read CDDA...\n");
@@ -226,7 +221,7 @@ cooked_init_drive (cdrom_drive_t *d){
} else {
char buffer[256];
sprintf(buffer,"\tSetting read block size at %d sectors (%ld bytes).\n",
d->nsectors,(long)d->nsectors*CD_FRAMESIZE_RAW);
d->nsectors,(long)d->nsectors*CDIO_CD_FRAMESIZE_RAW);
cdmessage(d,buffer);
break;
}
@@ -253,7 +248,7 @@ cooked_init_drive (cdrom_drive_t *d){
char buffer[256];
d->nsectors = 8;
sprintf(buffer,"\tSetting read block size at %d sectors (%ld bytes).\n",
d->nsectors,(long)d->nsectors*CD_FRAMESIZE_RAW);
d->nsectors,(long)d->nsectors*CDIO_CD_FRAMESIZE_RAW);
cdmessage(d,buffer);
}

View File

@@ -117,8 +117,8 @@ long cdda_read(cdrom_drive_t *d, void *buffer, lsn_t beginsector, long sectors)
if(d->bigendianp!=bigendianp()){
int i;
u_int16_t *p=(u_int16_t *)buffer;
long els=sectors*CD_FRAMESIZE_RAW/2;
uint16_t *p=(uint16_t *)buffer;
long els=sectors*CDIO_CD_FRAMESIZE_RAW/2;
for(i=0;i<els;i++)
p[i]=UINT16_SWAP_LE_BE_C(p[i]);

View File

@@ -1,5 +1,5 @@
/*
$Id: low_interface.h,v 1.3 2005/01/05 22:28:53 rocky Exp $
$Id: low_interface.h,v 1.4 2005/01/06 03:09:11 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1998 Monty xiphmont@mit.edu
@@ -63,11 +63,13 @@
#define CDROMAUDIOBUFSIZ 0x5382 /* set the audio buffer size */
#endif
#include <scsi/sg.h>
#include <scsi/scsi.h>
#ifdef HAVE_LINUX_CDROM_H
#include <linux/cdrom.h>
#endif
#ifdef HAVE_LINUX_MAJOR_H
#include <linux/major.h>
#endif
#define MAX_RETRIES 8
#define MAX_BIG_BUFF_SIZE 65536