More integration/cleanup. Now uses cdio bytesex.h's BE/LE routines.
copystring -> strdup. Some int's changed to track_t. But I need to be careful *not* to change cdda_interface.h.
This commit is contained in:
@@ -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 <rocky@panix.com>
|
||||
Copyright (C) 1998, 2002 Monty monty@xiph.org
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <math.h>
|
||||
#include "common_interface.h"
|
||||
#include <cdio/bytesex.h>
|
||||
#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;j<tracks;j++){
|
||||
for(j=0;j<i_tracks;j++){
|
||||
if(d->disc_toc[j].dwStartSector<0){
|
||||
cdmessage(d,"\n\tTOC entry claims a negative start offset: massaging"
|
||||
".\n");
|
||||
d->disc_toc[j].dwStartSector=0;
|
||||
}
|
||||
if(j<tracks-1 && d->disc_toc[j].dwStartSector>
|
||||
if(j<i_tracks-1 && d->disc_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;j<tracks;j++){
|
||||
for(j=1;j<i_tracks;j++){
|
||||
if(d->disc_toc[j].dwStartSector<last){
|
||||
cdmessage(d,"\n\tTOC entries claim non-increasing offsets: massaging"
|
||||
".\n");
|
||||
@@ -245,7 +255,7 @@ FixupTOC(cdrom_drive_t *d,int tracks)
|
||||
|
||||
/* believe the multisession offset :-) */
|
||||
/* adjust end of last audio track to be in the first session */
|
||||
for (j = tracks-1; j >= 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))
|
||||
|
||||
@@ -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 <rocky@panix.com>
|
||||
Copyright (C) 1998 Monty xiphmont@mit.edu
|
||||
@@ -23,12 +23,13 @@
|
||||
#define _CDDA_COMMON_INTERFACE_H_
|
||||
|
||||
#include "low_interface.h"
|
||||
#include <cdio/types.h>
|
||||
|
||||
/* 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_*/
|
||||
|
||||
@@ -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 <rocky@panix.com>
|
||||
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 */
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "low_interface.h"
|
||||
#include "common_interface.h"
|
||||
#include "utils.h"
|
||||
#include <cdio/bytesex.h>
|
||||
|
||||
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;i<d->tracks;i++)
|
||||
for(i=0; i<d->tracks; 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<els;i++)p[i]=UINT16_SWAP_LE_BE_C(p[i]);
|
||||
for(i=0;i<els;i++)
|
||||
p[i]=UINT16_SWAP_LE_BE_C(p[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: scan_devices.c,v 1.1 2004/12/18 17:29:32 rocky Exp $
|
||||
$Id: scan_devices.c,v 1.2 2004/12/19 01:43:38 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
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);
|
||||
|
||||
@@ -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 <rocky@panix.com>
|
||||
Original interface.c Copyright (C) 1994-1997
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "common_interface.h"
|
||||
#include "utils.h"
|
||||
#include <cdio/scsi_mmc.h>
|
||||
#include <cdio/bytesex.h>
|
||||
|
||||
/* 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);
|
||||
|
||||
@@ -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 <rocky@panix.com>
|
||||
Copyright (C) 1998 Monty xiphmont@mit.edu
|
||||
@@ -19,89 +19,22 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <endian.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <cdio/types.h>
|
||||
#include <cdio/bytesex.h>
|
||||
|
||||
/* 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);
|
||||
|
||||
Reference in New Issue
Block a user