diff --git a/include/cdio/cdda_interface.h b/include/cdio/cdda_interface.h index 662d1ad4..f2283a53 100644 --- a/include/cdio/cdda_interface.h +++ b/include/cdio/cdda_interface.h @@ -1,5 +1,5 @@ /* - $Id: cdda_interface.h,v 1.1 2004/12/18 17:29:32 rocky Exp $ + $Id: cdda_interface.h,v 1.2 2004/12/19 01:43:38 rocky Exp $ Copyright (C) 2004 Rocky Bernstein Copyright (C) 2001 Xiph.org @@ -28,6 +28,7 @@ #define _CDDA_INTERFACE_H_ #include +#include #define CD_FRAMESAMPLES (CDIO_CD_FRAMESIZE_RAW / 4) diff --git a/lib/cdda_interface/common_interface.c b/lib/cdda_interface/common_interface.c index f42daa22..91cb56ea 100644 --- a/lib/cdda_interface/common_interface.c +++ b/lib/cdda_interface/common_interface.c @@ -1,5 +1,5 @@ /* - $Id: common_interface.c,v 1.1 2004/12/18 17:29:32 rocky Exp $ + $Id: common_interface.c,v 1.2 2004/12/19 01:43:38 rocky Exp $ Copyright (C) 2004 Rocky Bernstein Copyright (C) 1998, 2002 Monty monty@xiph.org @@ -28,6 +28,7 @@ #include #include "common_interface.h" +#include #include "utils.h" #include "smallft.h" @@ -57,11 +58,11 @@ char *atapi_drive_info(int fd){ if (!(ioctl(fd, HDIO_GET_IDENTITY, id))) { if(id->model==0 || id->model[0]==0) - ret=copystring("Generic Unidentifiable ATAPI CDROM"); + ret=strdup("Generic Unidentifiable ATAPI CDROM"); else - ret=copystring(id->model); + ret=strdup(id->model); }else - ret=copystring("Generic Unidentifiable CDROM"); + ret=strdup("Generic Unidentifiable CDROM"); free(id); return(ret); @@ -131,14 +132,23 @@ data_bigendianp(cdrom_drive_t *d) if(!zeroflag){ int j; - for(j=0;j<128;j++)a[j]=le16_to_cpu(buff[j*2+beginsec+460]); - for(j=0;j<128;j++)b[j]=le16_to_cpu(buff[j*2+beginsec+461]); + for(j=0;j<128;j++) + a[j]=UINT16_FROM_LE(buff[j*2+beginsec+460]); + for(j=0;j<128;j++) + b[j]=UINT16_FROM_LE(buff[j*2+beginsec+461]); + fft_forward(128,a,NULL,NULL); fft_forward(128,b,NULL,NULL); - for(j=0;j<128;j++)lsb_energy+=fabs(a[j])+fabs(b[j]); + + for(j=0;j<128;j++) + lsb_energy+=fabs(a[j])+fabs(b[j]); - for(j=0;j<128;j++)a[j]=be16_to_cpu(buff[j*2+beginsec+460]); - for(j=0;j<128;j++)b[j]=be16_to_cpu(buff[j*2+beginsec+461]); + for(j=0;j<128;j++) + a[j]=UINT16_FROM_BE(buff[j*2+beginsec+460]); + + for(j=0;j<128;j++) + b[j]=UINT16_FROM_BE(buff[j*2+beginsec+461]); + fft_forward(128,a,NULL,NULL); fft_forward(128,b,NULL,NULL); for(j=0;j<128;j++)msb_energy+=fabs(a[j])+fabs(b[j]); @@ -193,20 +203,20 @@ data_bigendianp(cdrom_drive_t *d) knows the leadoud/leadin size. */ int -FixupTOC(cdrom_drive_t *d,int tracks) +FixupTOC(cdrom_drive_t *d, track_t i_tracks) { struct cdrom_multisession ms_str; int j; /* First off, make sure the 'starting sector' is >=0 */ - for(j=0;jdisc_toc[j].dwStartSector<0){ cdmessage(d,"\n\tTOC entry claims a negative start offset: massaging" ".\n"); d->disc_toc[j].dwStartSector=0; } - if(jdisc_toc[j].dwStartSector> + if(jdisc_toc[j].dwStartSector> d->disc_toc[j+1].dwStartSector){ cdmessage(d,"\n\tTOC entry claims an overly large start offset: massaging" ".\n"); @@ -218,7 +228,7 @@ FixupTOC(cdrom_drive_t *d,int tracks) Flag things that are blatant/stupid/wrong */ { long last=d->disc_toc[0].dwStartSector; - for(j=1;jdisc_toc[j].dwStartSector= 0; j--) { + for (j = i_tracks-1; j >= 0; j--) { if (j > 0 && !IS_AUDIO(d,j) && IS_AUDIO(d,j-1)) { if ((d->disc_toc[j].dwStartSector > ms_str.addr.lba - 11400) && (ms_str.addr.lba - 11400 > d->disc_toc[j-1].dwStartSector)) diff --git a/lib/cdda_interface/common_interface.h b/lib/cdda_interface/common_interface.h index 50fc5e4d..5fcb97af 100644 --- a/lib/cdda_interface/common_interface.h +++ b/lib/cdda_interface/common_interface.h @@ -1,5 +1,5 @@ /* - $Id: common_interface.h,v 1.1 2004/12/18 17:29:32 rocky Exp $ + $Id: common_interface.h,v 1.2 2004/12/19 01:43:38 rocky Exp $ Copyright (C) 2004 Rocky Bernstein Copyright (C) 1998 Monty xiphmont@mit.edu @@ -23,12 +23,13 @@ #define _CDDA_COMMON_INTERFACE_H_ #include "low_interface.h" +#include -/* Test for presence of a cdrom by pinging with the 'CDROMVOLREAD' ioctl() */ +/** Test for presence of a cdrom by pinging with the 'CDROMVOLREAD' ioctl() */ extern int ioctl_ping_cdrom(int fd); extern char *atapi_drive_info(int fd); extern int data_bigendianp(cdrom_drive_t *d); -extern int FixupTOC(cdrom_drive_t *d,int tracks); +extern int FixupTOC(cdrom_drive_t *d, track_t tracks); #endif /*_CDDA_COMMON_INTERFACE_H_*/ diff --git a/lib/cdda_interface/cooked_interface.c b/lib/cdda_interface/cooked_interface.c index 2eb73353..59faa17d 100644 --- a/lib/cdda_interface/cooked_interface.c +++ b/lib/cdda_interface/cooked_interface.c @@ -1,5 +1,5 @@ /* - $Id: cooked_interface.c,v 1.1 2004/12/18 17:29:32 rocky Exp $ + $Id: cooked_interface.c,v 1.2 2004/12/19 01:43:38 rocky Exp $ Copyright (C) 2004 Rocky Bernstein Original interface.c Copyright (C) 1994-1997 @@ -35,7 +35,7 @@ static int cooked_readtoc (cdrom_drive_t *d) { int i; - int tracks; + track_t i_tracks; struct cdrom_tochdr hdr; struct cdrom_tocentry entry; @@ -74,9 +74,9 @@ cooked_readtoc (cdrom_drive_t *d) d->disc_toc[i].bTrack = entry.cdte_track; d->disc_toc[i].dwStartSector = entry.cdte_addr.lba; - tracks=hdr.cdth_trk1+1; - d->cd_extra=FixupTOC(d,tracks); - return(--tracks); /* without lead-out */ + i_tracks=hdr.cdth_trk1+1; + d->cd_extra=FixupTOC(d,i_tracks); + return(--i_tracks); /* without lead-out */ } diff --git a/lib/cdda_interface/interface.c b/lib/cdda_interface/interface.c index d63f9973..32314d9d 100644 --- a/lib/cdda_interface/interface.c +++ b/lib/cdda_interface/interface.c @@ -12,6 +12,7 @@ #include "low_interface.h" #include "common_interface.h" #include "utils.h" +#include static void _clean_messages(cdrom_drive_t *d) { @@ -76,7 +77,7 @@ cdda_open(cdrom_drive_t *d) /* Some drives happily return a TOC even if there is no disc... */ { int i; - for(i=0;itracks;i++) + for(i=0; itracks; i++) if(d->disc_toc[i].dwStartSector<0 || d->disc_toc[i+1].dwStartSector==0){ d->opened=0; @@ -115,7 +116,8 @@ long cdda_read(cdrom_drive_t *d, void *buffer, long beginsector, long sectors) u_int16_t *p=(u_int16_t *)buffer; long els=sectors*CD_FRAMESIZE_RAW/2; - for(i=0;i Copyright (C) 1998 Monty xiphmont@mit.edu @@ -86,7 +86,7 @@ cdda_find_a_cdrom(int messagedest, char **messages){ int j; /* try first eight of each device */ for(j=0;j<4;j++){ - char *buffer=copystring(cdrom_devices[i]); + char *buffer=strdup(cdrom_devices[i]); /* number, then letter */ @@ -227,11 +227,11 @@ cdda_identify_cooked(const char *dev, int messagedest, break; case CDU31A_CDROM_MAJOR: /* major indicates this is a cdrom; no ping necessary. */ - description=copystring("Sony CDU31A or compatible"); + description=strdup("Sony CDU31A or compatible"); break; case CDU535_CDROM_MAJOR: /* major indicates this is a cdrom; no ping necessary. */ - description=copystring("Sony CDU535 or compatible"); + description=strdup("Sony CDU535 or compatible"); break; case MATSUSHITA_CDROM_MAJOR: @@ -239,26 +239,26 @@ cdda_identify_cooked(const char *dev, int messagedest, case MATSUSHITA_CDROM3_MAJOR: case MATSUSHITA_CDROM4_MAJOR: /* major indicates this is a cdrom; no ping necessary. */ - description=copystring("non-ATAPI IDE-style Matsushita/Panasonic CR-5xx or compatible"); + description=strdup("non-ATAPI IDE-style Matsushita/Panasonic CR-5xx or compatible"); break; case SANYO_CDROM_MAJOR: - description=copystring("Sanyo proprietary or compatible: NOT CDDA CAPABLE"); + description=strdup("Sanyo proprietary or compatible: NOT CDDA CAPABLE"); break; case MITSUMI_CDROM_MAJOR: case MITSUMI_X_CDROM_MAJOR: - description=copystring("Mitsumi proprietary or compatible: NOT CDDA CAPABLE"); + description=strdup("Mitsumi proprietary or compatible: NOT CDDA CAPABLE"); break; case OPTICS_CDROM_MAJOR: - description=copystring("Optics Dolphin or compatible: NOT CDDA CAPABLE"); + description=strdup("Optics Dolphin or compatible: NOT CDDA CAPABLE"); break; case AZTECH_CDROM_MAJOR: - description=copystring("Aztech proprietary or compatible: NOT CDDA CAPABLE"); + description=strdup("Aztech proprietary or compatible: NOT CDDA CAPABLE"); break; case GOLDSTAR_CDROM_MAJOR: - description=copystring("Goldstar proprietary: NOT CDDA CAPABLE"); + description=strdup("Goldstar proprietary: NOT CDDA CAPABLE"); break; case CM206_CDROM_MAJOR: - description=copystring("Philips/LMS CM206 proprietary: NOT CDDA CAPABLE"); + description=strdup("Philips/LMS CM206 proprietary: NOT CDDA CAPABLE"); break; case SCSI_CDROM_MAJOR: @@ -286,7 +286,7 @@ cdda_identify_cooked(const char *dev, int messagedest, d=calloc(1,sizeof(cdrom_drive_t)); d->cdda_device_name=device; - d->ioctl_device_name=copystring(device); + d->ioctl_device_name=strdup(device); d->drive_model=description; d->drive_type=type; d->cdda_fd=fd; @@ -663,8 +663,8 @@ cdda_identify_scsi(const char *generic_device, d->drive_model=calloc(36,1); memcpy(d->inqbytes,p,4); - d->cdda_device_name=copystring(generic_device); - d->ioctl_device_name=copystring(ioctl_device); + d->cdda_device_name=strdup(generic_device); + d->ioctl_device_name=strdup(ioctl_device); d->drive_model=calloc(36,1); strscat(d->drive_model,p+8,8); @@ -716,15 +716,15 @@ cdrom_drive_t *cdda_identify_test(const char *filename, int messagedest, d=calloc(1,sizeof(cdrom_drive_t)); - d->cdda_device_name=copystring(filename); - d->ioctl_device_name=copystring(filename); + d->cdda_device_name=strdup(filename); + d->ioctl_device_name=strdup(filename); d->drive_type=-1; d->cdda_fd=fd; d->ioctl_fd=fd; d->interface=TEST_INTERFACE; d->bigendianp=-1; /* We don't know yet... */ d->nsectors=-1; - d->drive_model=copystring("File based test interface"); + d->drive_model=strdup("File based test interface"); idmessage(messagedest,messages,"\t\tCDROM sensed: %s\n",d->drive_model); return(d); diff --git a/lib/cdda_interface/scsi_interface.c b/lib/cdda_interface/scsi_interface.c index 0fb28ee4..247dee31 100644 --- a/lib/cdda_interface/scsi_interface.c +++ b/lib/cdda_interface/scsi_interface.c @@ -1,5 +1,5 @@ /* - $Id: scsi_interface.c,v 1.1 2004/12/18 17:29:32 rocky Exp $ + $Id: scsi_interface.c,v 1.2 2004/12/19 01:43:38 rocky Exp $ Copyright (C) 2004 Rocky Bernstein Original interface.c Copyright (C) 1994-1997 @@ -35,6 +35,7 @@ #include "common_interface.h" #include "utils.h" #include +#include /* hook */ static int @@ -504,7 +505,7 @@ static int scsi_read_toc (cdrom_drive_t *d) { int i,first,last; - unsigned tracks; + track_t i_tracks; /* READTOC, MSF format flag, res, res, res, res, Start track, len msb, len lsb, flags */ @@ -521,7 +522,7 @@ scsi_read_toc (cdrom_drive_t *d) first=d->sg_buffer[2]; last=d->sg_buffer[3]; - tracks=last-first+1; + i_tracks=last-first+1; if (last > MAXTRK || first > MAXTRK || last<0 || first<0) { cderror(d,"003: CDROM reporting illegal number of tracks\n"); @@ -572,8 +573,8 @@ scsi_read_toc (cdrom_drive_t *d) (toc->start_LSB)); } - d->cd_extra = FixupTOC(d,tracks+1); /* include lead-out */ - return(tracks); + d->cd_extra = FixupTOC(d,i_tracks+1); /* include lead-out */ + return(i_tracks); } /* a contribution from Boris for IMS cdd 522 */ @@ -584,7 +585,7 @@ scsi_read_toc2 (cdrom_drive_t *d) u_int32_t foo,bar; int i; - unsigned tracks; + track_t i_tracks; memcpy(d->sg_buffer, (char[]){ 0xe5, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 10); d->sg_buffer[5]=1; @@ -596,13 +597,13 @@ scsi_read_toc2 (cdrom_drive_t *d) } /* copy to our structure and convert start sector */ - tracks = d->sg_buffer[1]; - if (tracks > MAXTRK) { + i_tracks = d->sg_buffer[1]; + if (i_tracks > MAXTRK) { cderror(d,"003: CDROM reporting illegal number of tracks\n"); return(-3); } - for (i = 0; i < tracks; i++){ + for (i = 0; i < i_tracks; i++){ memcpy(d->sg_buffer, (char[]){ 0xe5, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 10); d->sg_buffer[5]=i+1; d->sg_buffer[8]=255; @@ -626,8 +627,8 @@ scsi_read_toc2 (cdrom_drive_t *d) d->disc_toc[i].bTrack = i + 1; memcpy (&foo, d->sg_buffer+2, 4); memcpy (&bar, d->sg_buffer+6, 4); - d->disc_toc[i].dwStartSector = d->adjust_ssize * (be32_to_cpu(foo) + - be32_to_cpu(bar)); + d->disc_toc[i].dwStartSector = + d->adjust_ssize * (UINT32_FROM_BE(foo) + UINT32_FROM_BE(bar)); d->disc_toc[i].dwStartSector= d->adjust_ssize * ((((signed char)(d->sg_buffer[2])<<24) | @@ -641,8 +642,8 @@ scsi_read_toc2 (cdrom_drive_t *d) (d->sg_buffer[9])))); - d->cd_extra = FixupTOC(d,tracks+1); - return(tracks); + d->cd_extra = FixupTOC(d,i_tracks+1); + return(i_tracks); } /* These do one 'extra' copy in the name of clean code */ @@ -835,7 +836,7 @@ i_read_mmc3 (cdrom_drive_t *d, void *p, long int begin, long int sectors) /* straight from the MMC3 spec */ static inline void -LBA_to_MSF(long int lba, unsigned char *M, unsigned char *S, unsigned char *F) +LBA_to_MSF(lba_t lba, unsigned char *M, unsigned char *S, unsigned char *F) { if (lba>=-CDIO_PREGAP_SECTORS){ *M = ( lba+CDIO_PREGAP_SECTORS)/(CDIO_CD_FRAMES_PER_MIN); diff --git a/lib/cdda_interface/utils.h b/lib/cdda_interface/utils.h index 32a5845a..88ac4fce 100644 --- a/lib/cdda_interface/utils.h +++ b/lib/cdda_interface/utils.h @@ -1,5 +1,5 @@ /* - $Id: utils.h,v 1.2 2004/12/19 00:02:09 rocky Exp $ + $Id: utils.h,v 1.3 2004/12/19 01:43:38 rocky Exp $ Copyright (C) 2004 Rocky Bernstein Copyright (C) 1998 Monty xiphmont@mit.edu @@ -19,89 +19,22 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include -#include -#include -#include -#include /* I wonder how many alignment issues this is gonna trip in the future... it shouldn't trip any... I guess we'll find out :) */ -static inline int bigendianp(void){ +static inline int +bigendianp(void) +{ int test=1; char *hack=(char *)(&test); if(hack[0])return(0); return(1); } -#if BYTE_ORDER == LITTLE_ENDIAN - -static inline int32_t be32_to_cpu(int32_t x){ - return(UINT32_SWAP_LE_BE_C(x)); -} - -static inline int16_t be16_to_cpu(int16_t x){ - return(UINT16_SWAP_LE_BE_C(x)); -} - -static inline int32_t le32_to_cpu(int32_t x){ - return(x); -} - -static inline int16_t le16_to_cpu(int16_t x){ - return(x); -} - -#else - -static inline int32_t be32_to_cpu(int32_t x){ - return(x); -} - -static inline int16_t be16_to_cpu(int16_t x){ - return(x); -} - -static inline int32_t le32_to_cpu(int32_t x){ - return(UINT32_SWAP_LE_BE_C(x)); -} - -static inline int16_t le16_to_cpu(int16_t x){ - return(UINT16_SWAP_LE_BE_C(x)); -} - - -#endif - -static inline int32_t cpu_to_be32(int32_t x){ - return(be32_to_cpu(x)); -} - -static inline int32_t cpu_to_le32(int32_t x){ - return(le32_to_cpu(x)); -} - -static inline int16_t cpu_to_be16(int16_t x){ - return(be16_to_cpu(x)); -} - -static inline int16_t cpu_to_le16(int16_t x){ - return(le16_to_cpu(x)); -} - -static inline char *copystring(const char *s){ - if(s){ - char *ret=malloc((strlen(s)+9)*sizeof(char)); /* +9 to get around a linux - libc 5 bug. below too */ - strcpy(ret,s); - return(ret); - } - return(NULL); -} - -static inline char *catstring(char *buff,const char *s){ +static inline char * +catstring(char *buff,const char *s){ if(s){ if(buff) buff=realloc(buff,strlen(buff)+strlen(s)+9); diff --git a/src/cd-paranoia/buffering_write.c b/src/cd-paranoia/buffering_write.c index 63c01164..2eef7ef3 100644 --- a/src/cd-paranoia/buffering_write.c +++ b/src/cd-paranoia/buffering_write.c @@ -1,3 +1,24 @@ +/* + $Id: buffering_write.c,v 1.2 2004/12/19 01:43:38 rocky Exp $ + + Copyright (C) 2004 Rocky Bernstein + Copyright (C) 1998, 1999 Monty + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + */ /* Eliminate teeny little writes. patch submitted by Rob Ross --Monty 19991008 */ @@ -18,56 +39,75 @@ static long bw_pos = 0; static char bw_outbuf[OUTBUFSZ]; -/* buffering_write() - buffers data to a specified size before writing. + +long int +blocking_write(int outf, char *buffer, long num){ + long int words=0,temp; + + while(words= 0 && bw_pos > 0) { - if (blocking_write(bw_fd, bw_outbuf, bw_pos)) { - perror("write (in buffering_write, flushing)"); - } - } - bw_fd = fd; - bw_pos = 0; - } - - if (bw_pos + num > OUTBUFSZ) { - /* fill our buffer first, then write, then modify buffer and num */ - memcpy(&bw_outbuf[bw_pos], buffer, OUTBUFSZ - bw_pos); - if (blocking_write(fd, bw_outbuf, OUTBUFSZ)) { - perror("write (in buffering_write, full buffer)"); - return(-1); - } - num -= (OUTBUFSZ - bw_pos); - buffer += (OUTBUFSZ - bw_pos); - bw_pos = 0; - } - /* save data */ - memcpy(&bw_outbuf[bw_pos], buffer, num); - bw_pos += num; - - return(0); + if (fd != bw_fd) { + /* clean up after buffering for some other file */ + if (bw_fd >= 0 && bw_pos > 0) { + if (blocking_write(bw_fd, bw_outbuf, bw_pos)) { + perror("write (in buffering_write, flushing)"); + } + } + bw_fd = fd; + bw_pos = 0; + } + + if (bw_pos + num > OUTBUFSZ) { + /* fill our buffer first, then write, then modify buffer and num */ + memcpy(&bw_outbuf[bw_pos], buffer, OUTBUFSZ - bw_pos); + if (blocking_write(fd, bw_outbuf, OUTBUFSZ)) { + perror("write (in buffering_write, full buffer)"); + return(-1); + } + num -= (OUTBUFSZ - bw_pos); + buffer += (OUTBUFSZ - bw_pos); + bw_pos = 0; + } + /* save data */ + memcpy(&bw_outbuf[bw_pos], buffer, num); + bw_pos += num; + + return(0); } -/* buffering_close() - writes out remaining buffered data before closing - * file. +/** buffering_close() - writes out remaining buffered data before + * closing file. * */ -int buffering_close(int fd) +int +buffering_close(int fd) { - if (fd == bw_fd && bw_pos > 0) { - /* write out remaining data and clean up */ - if (blocking_write(fd, bw_outbuf, bw_pos)) { - perror("write (in buffering_close)"); - } - bw_fd = -1; - bw_pos = 0; - } - return(close(fd)); + if (fd == bw_fd && bw_pos > 0) { + /* write out remaining data and clean up */ + if (blocking_write(fd, bw_outbuf, bw_pos)) { + perror("write (in buffering_close)"); + } + bw_fd = -1; + bw_pos = 0; + } + return(close(fd)); } diff --git a/src/cd-paranoia/buffering_write.h b/src/cd-paranoia/buffering_write.h index 55c9d8a9..ec81d97c 100644 --- a/src/cd-paranoia/buffering_write.h +++ b/src/cd-paranoia/buffering_write.h @@ -1,23 +1,39 @@ /* - * Copyright: GNU Public License 2 applies - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Copyright (C) 2004 Rocky Bernstein - * (C) 1998 Monty - * + $Id: buffering_write.h,v 1.2 2004/12/19 01:43:38 rocky Exp $ + + Copyright (C) 2004 Rocky Bernstein + Copyright (C) 1998 Monty + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ extern long blocking_write(int outf, char *buffer, long i_num); + +/** buffering_write() - buffers data to a specified size before writing. + * + * Restrictions: + * - MUST CALL BUFFERING_CLOSE() WHEN FINISHED!!! + * + */ +extern long buffering_write(int outf, char *buffer, long num); + +/** buffering_close() - writes out remaining buffered data before + * closing file. + * + */ +extern int buffering_close(int fd); + + diff --git a/src/cd-paranoia/cd-paranoia.c b/src/cd-paranoia/cd-paranoia.c index 612c6f5c..0680140f 100644 --- a/src/cd-paranoia/cd-paranoia.c +++ b/src/cd-paranoia/cd-paranoia.c @@ -1,5 +1,6 @@ /* - * Copyright: GNU Public License 2 applies + * Copyright (C) 2004 Rocky Bernstein + * (C) 1998 Monty * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,8 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * Copyright (C) 2004 Rocky Bernstein - * (C) 1998 Monty * * See ChangeLog for recent changes. * @@ -71,6 +70,17 @@ extern int verbose; extern int quiet; +/* I wonder how many alignment issues this is gonna trip in the + future... it shouldn't trip any... I guess we'll find out :) */ + +static int bigendianp(void) +{ + int test=1; + char *hack=(char *)(&test); + if(hack[0])return(0); + return(1); +} + static long parse_offset(cdrom_drive_t *d, char *offset, int begin){ long track=-1; long hours=-1; @@ -196,7 +206,7 @@ static long parse_offset(cdrom_drive_t *d, char *offset, int begin){ static void display_toc(cdrom_drive_t *d){ long audiolen=0; - int i; + track_t i; report("\nTable of contents (audio tracks only):\n" "track length begin copy pre ch\n" "==========================================================="); @@ -642,21 +652,6 @@ struct option options [] = { {NULL,0,NULL,0} }; -long blocking_write(int outf, char *buffer, long num){ - long words=0,temp; - - while(words Copyright (C) 1998 Monty xiphmont@mit.edu @@ -20,92 +20,12 @@ */ #include -#include #include -#include #include -#include -#include -extern long buffering_write(int outf, char *buffer, long num); -extern int buffering_close(int fd); - - -/* I wonder how many alignment issues this is gonna trip in the - future... it shouldn't trip any... I guess we'll find out :) */ - -static inline int bigendianp(void){ - int test=1; - char *hack=(char *)(&test); - if(hack[0])return(0); - return(1); -} - -#if BYTE_ORDER == LITTLE_ENDIAN - -static inline int32_t be32_to_cpu(int32_t x){ - return(UINT32_SWAP_LE_BE_C(x)); -} - -static inline int16_t be16_to_cpu(int16_t x){ - return(UINT16_SWAP_LE_BE_C(x)); -} - -static inline int32_t le32_to_cpu(int32_t x){ - return(x); -} - -static inline int16_t le16_to_cpu(int16_t x){ - return(x); -} - -#else - -static inline int32_t be32_to_cpu(int32_t x){ - return(x); -} - -static inline int16_t be16_to_cpu(int16_t x){ - return(x); -} - -static inline int32_t le32_to_cpu(int32_t x){ - return(UINT32_SWAP_LE_BE_C(x)); -} - -static inline int16_t le16_to_cpu(int16_t x){ - return(UINT16_SWAP_LE_BE_C(x)); -} - - -#endif - -static inline int32_t cpu_to_be32(int32_t x){ - return(be32_to_cpu(x)); -} - -static inline int32_t cpu_to_le32(int32_t x){ - return(le32_to_cpu(x)); -} - -static inline int16_t cpu_to_be16(int16_t x){ - return(be16_to_cpu(x)); -} - -static inline int16_t cpu_to_le16(int16_t x){ - return(le16_to_cpu(x)); -} - -static inline char *copystring(const char *s){ - if(s){ - char *ret=malloc((strlen(s)+1)*sizeof(char)); - strcpy(ret,s); - return(ret); - } - return(NULL); -} - -static inline char *catstring(char *buff,const char *s){ +static inline char * +catstring(char *buff, const char *s) +{ if(s){ if(buff) buff=realloc(buff,strlen(buff)+strlen(s)+1); diff --git a/test/Makefile.am b/test/Makefile.am index 7c6bd4db..dc789687 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.36 2004/12/19 00:02:09 rocky Exp $ +# $Id: Makefile.am,v 1.37 2004/12/19 01:43:38 rocky Exp $ # # Copyright (C) 2003, 2004 Rocky Bernstein # @@ -41,7 +41,10 @@ testbincue_LDADD = $(LIBCDIO_LIBS) testbincue_CFLAGS = -DTEST_DIR=\"$(srcdir)\" check_SCRIPTS = check_nrg.sh check_cue.sh check_cd_read.sh \ - check_iso.sh check_opts.sh check_paranoia.sh + check_iso.sh check_opts.sh +# If we beefed this up so it checked to see if a CD-DA was loaded +# it could be an automatic test. But for now, not so. +# check_paranoia.sh check_PROGRAMS = $(hack)