Various portability fixes mosty for MSVC which doesn't have drand and

doesn't allow dynamic local arrays.
v_fragment -> v_fragment_t
libcdio.sym: more external symbols defined
/lib/_cdio_linux.c: harmless type mismatch
example/sample2.c -> example/device.c
This commit is contained in:
rocky
2005-02-06 15:09:10 +00:00
parent 392478e776
commit 6618a05537
11 changed files with 69 additions and 58 deletions

View File

@@ -19,7 +19,7 @@ define(RELEASE_NUM, 73)
define(CDIO_VERSION_STR, 0.$1cvs) define(CDIO_VERSION_STR, 0.$1cvs)
AC_PREREQ(2.52) AC_PREREQ(2.52)
AC_REVISION([$Id: configure.ac,v 1.141 2005/02/05 23:16:34 rocky Exp $])dnl AC_REVISION([$Id: configure.ac,v 1.142 2005/02/06 15:09:10 rocky Exp $])dnl
AC_INIT(libcdio, CDIO_VERSION_STR(RELEASE_NUM)) AC_INIT(libcdio, CDIO_VERSION_STR(RELEASE_NUM))
AC_CONFIG_SRCDIR(src/cd-info.c) AC_CONFIG_SRCDIR(src/cd-info.c)
@@ -412,7 +412,7 @@ AC_DEFINE_UNQUOTED(LIBCDIO_SOURCE_PATH, "$LIBCDIO_SOURCE_PATH",
[Full path to libcdio top_sourcedir.]) [Full path to libcdio top_sourcedir.])
AC_SUBST(LIBCDIO_SOURCE_PATH) AC_SUBST(LIBCDIO_SOURCE_PATH)
AC_CHECK_FUNCS( [bzero ftruncate lstat memcpy memset snprintf \ AC_CHECK_FUNCS( [bzero drand48 rand ftruncate lstat memcpy memset snprintf \
tzset vsnprintf getpwuid geteuid] ) tzset vsnprintf getpwuid geteuid] )
AC_CHECK_MEMBER([struct tm.tm_gmtoff], AC_CHECK_MEMBER([struct tm.tm_gmtoff],

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.16 2005/02/04 23:12:16 rocky Exp $ # $Id: Makefile.am,v 1.17 2005/02/06 15:09:10 rocky Exp $
# #
# Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> # Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
# #
@@ -21,11 +21,11 @@
#################################################### ####################################################
# #
if DISABLE_CPP if DISABLE_CPP
noinst_PROGRAMS = cdtext drives iso1 iso2 iso3 iso4 mmc1 mmc2 \ noinst_PROGRAMS = cdtext device drives iso1 iso2 iso3 iso4 mmc1 mmc2 \
paranoia paranoia2 tracks sample2 sample3 sample4 paranoia paranoia2 tracks sample3 sample4
else else
noinst_PROGRAMS = cdtext drives iso1 iso2 iso3 iso4 mmc1 mmc2 \ noinst_PROGRAMS = cdtext device drives iso1 iso2 iso3 iso4 mmc1 mmc2 \
paranoia paranoia2 tracks sample2 sample3 sample4 \ paranoia paranoia2 tracks sample3 sample4 \
iso1cpp iso2cpp iso3cpp iso1cpp iso2cpp iso3cpp
endif endif
@@ -33,6 +33,8 @@ INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS)
cdtext_LDADD = $(LIBCDIO_LIBS) cdtext_LDADD = $(LIBCDIO_LIBS)
device_LDADD = $(LIBCDIO_LIBS)
drives_LDADD = $(LIBCDIO_LIBS) drives_LDADD = $(LIBCDIO_LIBS)
paranoia_LDADD = $(LIBCDIO_PARANOIA_LIBS) $(LIBCDIO_CDDA_LIBS) $(LIBCDIO_LIBS) paranoia_LDADD = $(LIBCDIO_PARANOIA_LIBS) $(LIBCDIO_CDDA_LIBS) $(LIBCDIO_LIBS)
@@ -55,7 +57,6 @@ endif
mmc1_LDADD = $(LIBCDIO_LIBS) mmc1_LDADD = $(LIBCDIO_LIBS)
mmc2_LDADD = $(LIBCDIO_LIBS) mmc2_LDADD = $(LIBCDIO_LIBS)
sample2_LDADD = $(LIBCDIO_LIBS)
sample3_LDADD = $(LIBCDIO_LIBS) sample3_LDADD = $(LIBCDIO_LIBS)
sample4_LDADD = $(LIBCDIO_LIBS) sample4_LDADD = $(LIBCDIO_LIBS)

View File

@@ -1,4 +1,4 @@
$Id: README,v 1.13 2005/02/04 23:14:54 rocky Exp $ $Id: README,v 1.14 2005/02/06 15:09:10 rocky Exp $
This directory contains some simple examples of the use of the libcdio This directory contains some simple examples of the use of the libcdio
library. library.
@@ -29,6 +29,8 @@ iso2.c: A program to show using libiso9660 to extract a file
iso3.c: A program to show using libiso9660 to extract a file from an iso3.c: A program to show using libiso9660 to extract a file from an
ISO-9660 image. ISO-9660 image.
iso4.c: A program showing fuzzy ISO-9660 detection/reading.
iso1cpp.cpp: iso1.c compiled via C++ iso1cpp.cpp: iso1.c compiled via C++
iso2cpp.cpp: iso2.c compiled via C++ iso2cpp.cpp: iso2.c compiled via C++
iso3cpp.cpp: iso3.c compiled via C++ iso3cpp.cpp: iso3.c compiled via C++

View File

@@ -1,5 +1,5 @@
/* /*
$Id: sample2.c,v 1.13 2005/01/04 04:40:22 rocky Exp $ $Id: device.c,v 1.1 2005/02/06 15:09:10 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_linux.c,v 1.21 2005/02/06 11:13:37 rocky Exp $ $Id: _cdio_linux.c,v 1.22 2005/02/06 15:09:10 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.21 2005/02/06 11:13:37 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.22 2005/02/06 15:09:10 rocky Exp $";
#include <string.h> #include <string.h>
@@ -294,7 +294,7 @@ get_drive_cap_linux (const void *p_user_data,
return codes are the same as driver_return_code_t return codes are the same as driver_return_code_t
*/ */
static int static int
get_media_changed_linux (void *p_user_data) { get_media_changed_linux (const void *p_user_data) {
const _img_private_t *p_env = p_user_data; const _img_private_t *p_env = p_user_data;
return ioctl(p_env->gen.fd, CDROM_MEDIA_CHANGED, 0); return ioctl(p_env->gen.fd, CDROM_MEDIA_CHANGED, 0);
} }

View File

@@ -85,6 +85,7 @@ cdio_is_binfile
cdio_is_cuefile cdio_is_cuefile
cdio_is_device cdio_is_device
cdio_is_discmode_cdrom cdio_is_discmode_cdrom
cdio_is_discmode_dvd
cdio_is_nrg cdio_is_nrg
cdio_is_tocfile cdio_is_tocfile
cdio_lba_to_lsn cdio_lba_to_lsn
@@ -122,6 +123,7 @@ cdio_open_nrg
cdio_open_osx cdio_open_osx
cdio_open_solaris cdio_open_solaris
cdio_open_win32 cdio_open_win32
cdio_os_driver
cdio_read cdio_read
cdio_read_audio_sector cdio_read_audio_sector
cdio_read_audio_sectors cdio_read_audio_sectors
@@ -148,3 +150,4 @@ discmode2str
mmc_get_hwinfo mmc_get_hwinfo
mmc_run_cmd mmc_run_cmd
track_format2str track_format2str
CDIO_SECTOR_SYNC_HEADER

View File

@@ -1,5 +1,5 @@
/* /*
$Id: portable.h,v 1.1 2004/12/18 17:29:32 rocky Exp $ $Id: portable.h,v 1.2 2005/02/06 15:09:10 rocky Exp $
Copyright (C) Rocky Bernstein <rocky@panix.com> Copyright (C) Rocky Bernstein <rocky@panix.com>
@@ -49,6 +49,10 @@
# endif # endif
#endif /*HAVE_SNPRINTF*/ #endif /*HAVE_SNPRINTF*/
#if !defined(HAVE_DRAND48) && defined(HAVE_RAND)
# define drand48() (rand() / (double)RAND_MAX)
#endif
#ifdef MSVC #ifdef MSVC
# include <io.h> # include <io.h>

View File

@@ -1,5 +1,5 @@
/* /*
$Id: overlap.c,v 1.3 2005/01/07 02:42:29 rocky Exp $ $Id: overlap.c,v 1.4 2005/02/06 15:09:10 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1998 Monty xiphmont@mit.edu Copyright (C) 1998 Monty xiphmont@mit.edu
@@ -46,7 +46,7 @@ void
paranoia_resetcache(cdrom_paranoia_t *p) paranoia_resetcache(cdrom_paranoia_t *p)
{ {
c_block_t *c=c_first(p); c_block_t *c=c_first(p);
v_fragment *v; v_fragment_t *v;
while(c){ while(c){
free_c_block(c); free_c_block(c);
@@ -140,7 +140,7 @@ offset_adjust_settings(cdrom_paranoia_t *p,
(potentially unstable) feedback loop */ (potentially unstable) feedback loop */
{ {
c_block_t *c=c_first(p); c_block_t *c=c_first(p);
v_fragment *v=v_first(p); v_fragment_t *v=v_first(p);
while(v && v->one){ while(v && v->one){
/* safeguard beginning bounds case with a hammer */ /* safeguard beginning bounds case with a hammer */

View File

@@ -1,5 +1,5 @@
/* /*
$Id: p_block.c,v 1.6 2005/01/23 05:31:03 rocky Exp $ $Id: p_block.c,v 1.7 2005/02/06 15:09:10 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1998 Monty xiphmont@mit.edu Copyright (C) 1998 Monty xiphmont@mit.edu
@@ -148,10 +148,10 @@ new_c_block(cdrom_paranoia_t *p)
void free_c_block(c_block_t *c) void free_c_block(c_block_t *c)
{ {
/* also rid ourselves of v_fragments that reference this block */ /* also rid ourselves of v_fragments that reference this block */
v_fragment *v=v_first(c->p); v_fragment_t *v=v_first(c->p);
while(v){ while(v){
v_fragment *next=v_next(v); v_fragment_t *next=v_next(v);
if(v->one==c)free_v_fragment(v); if(v->one==c)free_v_fragment(v);
v=next; v=next;
} }
@@ -159,25 +159,25 @@ void free_c_block(c_block_t *c)
free_elem(c->e,1); free_elem(c->e,1);
} }
static v_fragment * static v_fragment_t *
i_vfragment_constructor(void) i_vfragment_constructor(void)
{ {
v_fragment *ret=calloc(1,sizeof(v_fragment)); v_fragment_t *ret=calloc(1,sizeof(v_fragment_t));
return(ret); return(ret);
} }
static inline void static inline void
i_v_fragment_destructor(v_fragment *v) i_v_fragment_destructor(v_fragment_t *v)
{ {
free(v); free(v);
} }
v_fragment * v_fragment_t *
new_v_fragment(cdrom_paranoia_t *p, c_block_t *one, new_v_fragment(cdrom_paranoia_t *p, c_block_t *one,
long int begin, long int end, int last) long int begin, long int end, int last)
{ {
linked_element *e=new_elem(p->fragments); linked_element *e=new_elem(p->fragments);
v_fragment *b=e->ptr; v_fragment_t *b=e->ptr;
b->e=e; b->e=e;
b->p=p; b->p=p;
@@ -191,7 +191,7 @@ new_v_fragment(cdrom_paranoia_t *p, c_block_t *one,
return(b); return(b);
} }
void free_v_fragment(v_fragment *v) void free_v_fragment(v_fragment_t *v)
{ {
free_elem(v->e,1); free_elem(v->e,1);
} }
@@ -228,7 +228,7 @@ c_prev(c_block_t *c)
return(NULL); return(NULL);
} }
v_fragment * v_fragment_t *
v_first(cdrom_paranoia_t *p) v_first(cdrom_paranoia_t *p)
{ {
if(p->fragments->head){ if(p->fragments->head){
@@ -237,7 +237,7 @@ v_first(cdrom_paranoia_t *p)
return(NULL); return(NULL);
} }
v_fragment * v_fragment_t *
v_last(cdrom_paranoia_t *p) v_last(cdrom_paranoia_t *p)
{ {
if(p->fragments->tail) if(p->fragments->tail)
@@ -245,16 +245,16 @@ v_last(cdrom_paranoia_t *p)
return(NULL); return(NULL);
} }
v_fragment * v_fragment_t *
v_next(v_fragment *v) v_next(v_fragment_t *v)
{ {
if(v->e->next) if(v->e->next)
return(v->e->next->ptr); return(v->e->next->ptr);
return(NULL); return(NULL);
} }
v_fragment * v_fragment_t *
v_prev(v_fragment *v) v_prev(v_fragment_t *v)
{ {
if(v->e->prev) if(v->e->prev)
return(v->e->prev->ptr); return(v->e->prev->ptr);
@@ -274,7 +274,7 @@ recover_cache(cdrom_paranoia_t *p)
} }
int16_t * int16_t *
v_buffer(v_fragment *v) v_buffer(v_fragment_t *v)
{ {
if(!v->one)return(NULL); if(!v->one)return(NULL);
if(!cv(v->one))return(NULL); if(!cv(v->one))return(NULL);

View File

@@ -1,5 +1,5 @@
/* /*
$Id: p_block.h,v 1.3 2005/01/07 02:42:29 rocky Exp $ $Id: p_block.h,v 1.4 2005/02/06 15:09:10 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) by Monty (xiphmont@mit.edu) Copyright (C) by Monty (xiphmont@mit.edu)
@@ -97,7 +97,7 @@ extern void free_c_block(c_block_t *c);
extern void i_cblock_destructor(c_block_t *c); extern void i_cblock_destructor(c_block_t *c);
extern c_block_t *new_c_block(cdrom_paranoia_t *p); extern c_block_t *new_c_block(cdrom_paranoia_t *p);
typedef struct v_fragment{ typedef struct v_fragment_s {
c_block_t *one; c_block_t *one;
long begin; long begin;
@@ -111,23 +111,23 @@ typedef struct v_fragment{
cdrom_paranoia_t *p; cdrom_paranoia_t *p;
struct linked_element *e; struct linked_element *e;
} v_fragment; } v_fragment_t;
extern void free_v_fragment(v_fragment *c); extern void free_v_fragment(v_fragment_t *c);
extern v_fragment *new_v_fragment(cdrom_paranoia_t *p, c_block_t *one, extern v_fragment_t *new_v_fragment(cdrom_paranoia_t *p, c_block_t *one,
long int begin, long int end, long int begin, long int end,
int lastsector); int lastsector);
extern int16_t *v_buffer(v_fragment *v); extern int16_t *v_buffer(v_fragment_t *v);
extern c_block_t *c_first(cdrom_paranoia_t *p); extern c_block_t *c_first(cdrom_paranoia_t *p);
extern c_block_t *c_last(cdrom_paranoia_t *p); extern c_block_t *c_last(cdrom_paranoia_t *p);
extern c_block_t *c_next(c_block_t *c); extern c_block_t *c_next(c_block_t *c);
extern c_block_t *c_prev(c_block_t *c); extern c_block_t *c_prev(c_block_t *c);
extern v_fragment *v_first(cdrom_paranoia_t *p); extern v_fragment_t *v_first(cdrom_paranoia_t *p);
extern v_fragment *v_last(cdrom_paranoia_t *p); extern v_fragment_t *v_last(cdrom_paranoia_t *p);
extern v_fragment *v_next(v_fragment *v); extern v_fragment_t *v_next(v_fragment_t *v);
extern v_fragment *v_prev(v_fragment *v); extern v_fragment_t *v_prev(v_fragment_t *v);
typedef struct root_block{ typedef struct root_block{
long returnedlimit; long returnedlimit;

View File

@@ -1,5 +1,5 @@
/* /*
$Id: paranoia.c,v 1.9 2005/01/23 14:05:19 rocky Exp $ $Id: paranoia.c,v 1.10 2005/02/06 15:09:10 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1998 Monty xiphmont@mit.edu Copyright (C) 1998 Monty xiphmont@mit.edu
@@ -452,7 +452,7 @@ typedef struct sync_result {
/* do *not* match using zero posts */ /* do *not* match using zero posts */
static long int static long int
i_iterate_stage2(cdrom_paranoia_t *p, i_iterate_stage2(cdrom_paranoia_t *p,
v_fragment *v, v_fragment_t *v,
sync_result *r, sync_result *r,
void(*callback)(long int, paranoia_cb_mode_t)) void(*callback)(long int, paranoia_cb_mode_t))
{ {
@@ -528,7 +528,7 @@ i_silence_test(root_block *root)
also must be called with vectors in ascending begin order in case also must be called with vectors in ascending begin order in case
there are nonzero islands */ there are nonzero islands */
static long int static long int
i_silence_match(root_block *root, v_fragment *v, i_silence_match(root_block *root, v_fragment_t *v,
void(*callback)(long int, paranoia_cb_mode_t)) void(*callback)(long int, paranoia_cb_mode_t))
{ {
@@ -547,10 +547,10 @@ i_silence_match(root_block *root, v_fragment *v,
p->dynoverlap? */ p->dynoverlap? */
if(fb(v)>=re(root) && fb(v)-p->dynoverlap<re(root)){ if(fb(v)>=re(root) && fb(v)-p->dynoverlap<re(root)){
/* extend the zeroed area of root */ /* extend the zeroed area of root */
long addto=fb(v)+MIN_SILENCE_BOUNDARY-re(root); long addto = fb(v)+MIN_SILENCE_BOUNDARY-re(root);
int16_t vec[addto]; int16_t *vec = calloc(addto, sizeof(int16_t));
memset(vec,0,sizeof(vec)); c_append(rc(root), vec, addto);
c_append(rc(root),vec,addto); free(vec);
} }
/* do we have an 'effortless' overlap? */ /* do we have an 'effortless' overlap? */
@@ -595,7 +595,7 @@ i_silence_match(root_block *root, v_fragment *v,
} }
static long int static long int
i_stage2_each(root_block *root, v_fragment *v, i_stage2_each(root_block *root, v_fragment_t *v,
void(*callback)(long int, paranoia_cb_mode_t)) void(*callback)(long int, paranoia_cb_mode_t))
{ {
@@ -855,7 +855,7 @@ i_stage2_each(root_block *root, v_fragment *v,
} }
static int static int
i_init_root(root_block *root, v_fragment *v,long int begin, i_init_root(root_block *root, v_fragment_t *v,long int begin,
void(*callback)(long int, paranoia_cb_mode_t)) void(*callback)(long int, paranoia_cb_mode_t))
{ {
if(fb(v)<=begin && fe(v)>begin){ if(fb(v)<=begin && fe(v)>begin){
@@ -884,7 +884,7 @@ i_init_root(root_block *root, v_fragment *v,long int begin,
static int static int
vsort(const void *a,const void *b) vsort(const void *a,const void *b)
{ {
return((*(v_fragment **)a)->begin-(*(v_fragment **)b)->begin); return((*(v_fragment_t **)a)->begin-(*(v_fragment_t **)b)->begin);
} }
static int static int
@@ -904,14 +904,14 @@ i_stage2(cdrom_paranoia_t *p, long int beginword, long int endword,
matching in the event that there are still audio vectors with matching in the event that there are still audio vectors with
content to be sunk before the silence */ content to be sunk before the silence */
while(flag){ while (flag) {
/* loop through all the current fragments */ /* loop through all the current fragments */
v_fragment *first=v_first(p); v_fragment_t *first=v_first(p);
long active=p->fragments->active,count=0; long active=p->fragments->active,count=0;
v_fragment *list[active]; v_fragment_t **list = calloc(active, sizeof(v_fragment_t *));
while(first){ while(first){
v_fragment *next=v_next(first); v_fragment_t *next=v_next(first);
list[count++]=first; list[count++]=first;
first=next; first=next;
} }
@@ -919,7 +919,7 @@ i_stage2(cdrom_paranoia_t *p, long int beginword, long int endword,
flag=0; flag=0;
if(count){ if(count){
/* sorted in ascending order of beginning */ /* sorted in ascending order of beginning */
qsort(list,active,sizeof(v_fragment *),&vsort); qsort(list,active,sizeof(v_fragment_t *),&vsort);
/* we try a nonzero based match even if in silent mode in /* we try a nonzero based match even if in silent mode in
the case that there are still cached vectors to sink the case that there are still cached vectors to sink
@@ -958,6 +958,7 @@ i_stage2(cdrom_paranoia_t *p, long int beginword, long int endword,
} }
} }
} }
free(list);
} }
return(ret); return(ret);
} }