From d8826d36a2ea170e1ae207b864de3b70d74d99c7 Mon Sep 17 00:00:00 2001 From: rocky Date: Tue, 20 Sep 2005 00:42:14 +0000 Subject: [PATCH] Add --with-versioned-libs for libcdio_paranioa and libcdio_cdda Remove use of "new" even in private C parts. Changes and patch from Nicholas Boullis. --- NEWS | 8 +-- example/.cvsignore | 1 + example/C++/.cvsignore | 3 ++ lib/cdda_interface/Makefile.am | 80 +++++++++++++++++++++++++-- lib/cdda_interface/libcdio_cdda.sym | 22 ++++++++ lib/iso9660/Makefile.am | 7 +-- lib/iso9660/iso9660.c | 23 ++++---- lib/paranoia/Makefile.am | 84 +++++++++++++++++++++++++++-- lib/paranoia/libcdio_paranoia.sym | 9 ++++ lib/paranoia/p_block.c | 24 ++++----- lib/paranoia/p_block.h | 34 +++++++----- 11 files changed, 245 insertions(+), 50 deletions(-) create mode 100644 lib/cdda_interface/libcdio_cdda.sym create mode 100644 lib/paranoia/libcdio_paranoia.sym diff --git a/NEWS b/NEWS index aa9ed2e5..a1523300 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,8 @@ -$Id: NEWS,v 1.81 2005/09/18 21:14:46 rocky Exp $ +$Id: NEWS,v 1.82 2005/09/20 00:42:14 rocky Exp $ version 0.76 ===================================== -2005-??-?? +2005-09-19 - Better compatibility with C++ @@ -10,7 +10,7 @@ version 0.76 - Fix bug in not specifying a device name in libcio_cdda -- Add IS_ISSOCK() or S_ISLNK() macros for Rock-Ridge when environment +- Add S_ISSOCK() or S_ISLNK() macros for Rock-Ridge when environment doesn't have it, e.g. MSYS 1.0.10 with MinGW 3.4.2. - Allow building cd-paranoia if Perl is not installed. @@ -282,4 +282,4 @@ version 0.1 Routines split off from VCDImager. -$Id: NEWS,v 1.81 2005/09/18 21:14:46 rocky Exp $ +$Id: NEWS,v 1.82 2005/09/20 00:42:14 rocky Exp $ diff --git a/example/.cvsignore b/example/.cvsignore index f0a71262..476ca79a 100644 --- a/example/.cvsignore +++ b/example/.cvsignore @@ -3,6 +3,7 @@ .libs Makefile Makefile.in +audio cdtext copying device diff --git a/example/C++/.cvsignore b/example/C++/.cvsignore index fbd9d92d..2da0fcbe 100644 --- a/example/C++/.cvsignore +++ b/example/C++/.cvsignore @@ -9,3 +9,6 @@ iso2 iso3 mmc1 mmc2 +paranoia +paranoia2 + diff --git a/lib/cdda_interface/Makefile.am b/lib/cdda_interface/Makefile.am index 2afde4ae..b2048b03 100644 --- a/lib/cdda_interface/Makefile.am +++ b/lib/cdda_interface/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.5 2005/09/17 20:57:19 rocky Exp $ +# $Id: Makefile.am,v 1.6 2005/09/20 00:42:14 rocky Exp $ # # Copyright (C) 2004, 2005 Rocky Bernstein # @@ -58,8 +58,6 @@ lib_LTLIBRARIES = libcdio_cdda.la libcdio_cdda_la_SOURCES = $(libcdio_cdda_sources) libcdio_cdda_la_ldflags = -version-info $(libcdio_cdda_la_CURRENT):$(libcdio_cdda_la_REVISION):$(libcdio_cdda_la_AGE) -libcdio_cdda_la_LDFLAGS = $(libcdio_cdda_la_ldflags) - INCLUDES = $(LIBCDIO_CFLAGS) FLAGS=@LIBCDIO_CFLAGS@ @UCDROM_H@ @TYPESIZES@ @CFLAGS@ @@ -73,3 +71,79 @@ DEBUG=$(FLAGS) -DCDDA_TEST ## $(LD) $(DEBUG) test_interface.o $(LDFLAGS) -o cdda_test $(LIBS) libcdio_cdda.a LIBS = $(LIBCDIO_LIBS) + + +######################################################## +# Things to version the symbols in the libraries +######################################################## + +# An explanation of the versioning problem from Nicolas Boullis and +# the versioned symbol solution he uses below... +# +# Currently, libvcdinfo uses the cdio_open function from libcdio. +# Let's imagine a program foobar that uses both the vcdinfo_open +# function from libvcdinfo and the cdio_open function from libcdio. + +# Currently, libcdio has SONAME libcdio.so.0, libvcdinfo has SONAME +# libvcdinfo.so.0 and requires libcdio.so.0, and foobar requires both +# libvcdinfo.so.0 and libcdio.so.0. Everything looks fine. +# +# Now, for some reason, you decide to change the cdio_open function. +# That's your right, but you have to bump the CURRENT version and (if I +# understand it correctly, athough this is not that clear in libtool's +# documentation) set the AGE to 0. Anyway, this bumps the SONAME, which is +# sane since the interface changes incompatibly. + +# Now, you have a new libcdio with SONAME libcdio.so.1. But libvcdinfo and +# foobar still require libcdio.so.0. Everything is still fine. + +# Now, after some minor changes, the author of foobar recompiles foobar. +# Then, foobar now requires libvcdinfo.so.0 and libcdio.so.1. And foobar +# now segfaults... + +# What is happening? When you run foobar, if brings both libvcdinfo.so.0 +# and libcdio.so.1, but libvcdinfo.so.0 also brings libcdio.so.0. So you +# have both libcdio.so.0 and libcdio.so.1 that bring their symbols to the +# global namespace. Hence, you have to incompatible versions of the +# cdio_open function in the name space. When foobar calls cdio_open, it +# may choose the wrong function, and segfaults... + +# With versioned symbols, the cdio_open function from libcdio.so.0 may be +# known as (something that looks like) cdio_open@@CDIO_0. An the cdio_open +# function from libcdio.so.1 as cdio_open@@CDIO_1. Both versions of +# libcdio would still be brought in by the most recent foobar, but foobar +# (and libvcdinfo) know which versioned function to use and then use the +# good one. + + +# This is some simple versioning where every symbol is versioned with +# something that looks like the SONAME of the library. More complex (and +# better) versioning is possible; it is for example what is used by glibc. +# But good complex versioning is something that requires much more +# work... + + +# The below is a impliments symbol versioning. First of all, I +# compute MAJOR as CURENT - AGE; that is what is used within libtool +# (at least on GNU/Linux systems) for the number in the SONAME. The +# nm command gives the list of symbols known in each of the object +# files that will be part of the shared library. And the sed command +# extracts from this list those symbols that will be shared. (This sed +# command comes from libtool.) + +libcdio_cdda_la_MAJOR := $(shell expr $(libcdio_cdda_la_CURRENT) - $(libcdio_cdda_la_AGE)) +if BUILD_VERSIONED_LIBS +libcdio_cdda_la_LDFLAGS = $(libcdio_cdda_la_ldflags) -Wl,--version-script=libcdio_cdda.la.ver +libcdio_cdda_la_DEPENDENCIES = libcdio_cdda.la.ver + +libcdio_cdda.la.ver: $(libcdio_cdda_la_OBJECTS) $(srcdir)/libcdio_cdda.sym + echo 'CDIO_CDDA_$(libcdio_cdda_la_MAJOR) { ' > $@ + objs=`for obj in $(libcdio_cdda_la_OBJECTS); do sed -ne "s/^pic_object='\(.*\)'$$/\1/p" $$obj; done`; \ + nm $${objs} | sed -n -e 's/^.*[ ][ABCDGIRSTW][ABCDGIRSTW]*[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$$/\1/p' | sort -u | { first=true; while read symbol; do if grep -q "^$${symbol}\$$" $(srcdir)/libcdio_cdda.sym; then if test $$first = true; then echo " global:"; first=false; fi; echo " $${symbol};"; fi; done; } >> $@; \ + nm $${objs} | sed -n -e 's/^.*[ ][ABCDGIRSTW][ABCDGIRSTW]*[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$$/\1/p' | sort -u | { first=true; while read symbol; do if grep -q "^$${symbol}\$$" $(srcdir)/libcdio_cdda.sym; then :; else if test $$first = true; then echo " local:"; first=false; fi; echo " $${symbol};"; fi; done; } >> $@ + echo '};' >> $@ +else +libcdio_cdda_la_LDFLAGS = $(libcdio_cdda_la_ldflags) +endif + +MOSTLYCLEANFILES = libcdio_cdda.la.ver diff --git a/lib/cdda_interface/libcdio_cdda.sym b/lib/cdda_interface/libcdio_cdda.sym new file mode 100644 index 00000000..a0801b62 --- /dev/null +++ b/lib/cdda_interface/libcdio_cdda.sym @@ -0,0 +1,22 @@ +cdio_cddap_find_a_cdrom +cdio_cddap_identify +cdio_cddap_identify_cdio +cdio_cddap_speed_set +cdio_cddap_verbose_set +cdio_cddap_messages +cdio_cddap_errors +cdio_cddap_close_no_free_cdio +cdio_cddap_close +cdio_cddap_open +cdio_cddap_read +cdio_cddap_track_firstsector +cdio_cddap_track_lastsector +cdio_cddap_tracks +cdio_cddap_sector_gettrack +cdio_cddap_track_channels +cdio_cddap_track_audiop +cdio_cddap_track_copyp +cdio_cddap_track_preemp +cdio_cddap_disc_firstsector +cdio_cddap_disc_lastsector +data_bigendianp diff --git a/lib/iso9660/Makefile.am b/lib/iso9660/Makefile.am index 2d111576..e611aaf0 100644 --- a/lib/iso9660/Makefile.am +++ b/lib/iso9660/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.8 2005/09/17 20:57:19 rocky Exp $ +# $Id: Makefile.am,v 1.9 2005/09/20 00:42:14 rocky Exp $ # # Copyright (C) 2003, 2004, 2005 Rocky Bernstein # @@ -136,8 +136,9 @@ libiso9660_la_DEPENDENCIES = $(libcdio9660_la_dependencies) libiso9660.la.ver libiso9660.la.ver: $(libiso9660_la_OBJECTS) $(srcdir)/libiso9660.sym echo 'ISO9660_$(libiso9660_la_MAJOR) {' > $@ - nm $(patsubst %.lo,%.o,$(libiso9660_la_OBJECTS)) | sed -n -e 's/^.*[ ][ABCDGIRSTW][ABCDGIRSTW]*[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$$/\1/p' | sort -u | { first=true; while read symbol; do if grep -q "^$${symbol}\$$" $(srcdir)/libiso9660.sym; then if test $$first = true; then echo " global:"; first=false; fi; echo " $${symbol};"; fi; done; } >> $@ - nm $(patsubst %.lo,%.o,$(libiso9660_la_OBJECTS)) | sed -n -e 's/^.*[ ][ABCDGIRSTW][ABCDGIRSTW]*[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$$/\1/p' | sort -u | { first=true; while read symbol; do if grep -q "^$${symbol}\$$" $(srcdir)/libiso9660.sym; then :; else if test $$first = true; then echo " local:"; first=false; fi; echo " $${symbol};"; fi; done; } >> $@ + objs=`for obj in $(libiso9660_la_OBJECTS); do sed -ne "s/^pic_object='\(.*\)'$$/\1/p" $$obj; done`; \ + nm $${objs} | sed -n -e 's/^.*[ ][ABCDGIRSTW][ABCDGIRSTW]*[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$$/\1/p' | sort -u | { first=true; while read symbol; do if grep -q "^$${symbol}\$$" $(srcdir)/libiso9660.sym; then if test $$first = true; then echo " global:"; first=false; fi; echo " $${symbol};"; fi; done; } >> $@; \ + nm $${objs} | sed -n -e 's/^.*[ ][ABCDGIRSTW][ABCDGIRSTW]*[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$$/\1/p' | sort -u | { first=true; while read symbol; do if grep -q "^$${symbol}\$$" $(srcdir)/libiso9660.sym; then :; else if test $$first = true; then echo " local:"; first=false; fi; echo " $${symbol};"; fi; done; } >> $@ echo '};' >> $@ MOSTLYCLEANFILES = libiso9660.la.ver diff --git a/lib/iso9660/iso9660.c b/lib/iso9660/iso9660.c index 3b9f900a..7ac93a3f 100644 --- a/lib/iso9660/iso9660.c +++ b/lib/iso9660/iso9660.c @@ -1,5 +1,5 @@ /* - $Id: iso9660.c,v 1.13 2005/03/03 10:32:01 rocky Exp $ + $Id: iso9660.c,v 1.14 2005/09/20 00:42:14 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -48,7 +48,7 @@ const char ISO_STANDARD_ID[] = {'C', 'D', '0', '0', '1'}; #include #endif -static const char _rcsid[] = "$Id: iso9660.c,v 1.13 2005/03/03 10:32:01 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660.c,v 1.14 2005/09/20 00:42:14 rocky Exp $"; /* Variables to hold debugger-helping enumerations */ enum iso_enum1_s iso_enums1; @@ -301,14 +301,15 @@ iso9660_name_translate(const char *psz_old, char *psz_new) The length of the translated string is returned. */ int -iso9660_name_translate_ext(const char *old, char *new, uint8_t i_joliet_level) +iso9660_name_translate_ext(const char *psz_oldname, char *psz_newname, + uint8_t i_joliet_level) { - int len = strlen(old); + int len = strlen(psz_oldname); int i; if (0 == len) return 0; for (i = 0; i < len; i++) { - unsigned char c = old[i]; + unsigned char c = psz_oldname[i]; if (!c) break; @@ -316,20 +317,21 @@ iso9660_name_translate_ext(const char *old, char *new, uint8_t i_joliet_level) if (!i_joliet_level && isupper(c)) c = tolower(c); /* Drop trailing '.;1' (ISO 9660:1988 7.5.1 requires period) */ - if (c == '.' && i == len - 3 && old[i + 1] == ';' && old[i + 2] == '1') + if (c == '.' && i == len - 3 + && psz_oldname[i + 1] == ';' && psz_oldname[i + 2] == '1') break; /* Drop trailing ';1' */ - if (c == ';' && i == len - 2 && old[i + 1] == '1') + if (c == ';' && i == len - 2 && psz_oldname[i + 1] == '1') break; /* Convert remaining ';' to '.' */ if (c == ';') c = '.'; - new[i] = c; + psz_newname[i] = c; } - new[i] = '\0'; + psz_newname[i] = '\0'; return i; } @@ -453,7 +455,8 @@ iso9660_set_evd(void *pd) memset(&ied, 0, sizeof(ied)); ied.type = to_711(ISO_VD_END); - iso9660_strncpy_pad (ied.id, ISO_STANDARD_ID, sizeof(ied.id), ISO9660_DCHARS); + iso9660_strncpy_pad (ied.id, ISO_STANDARD_ID, sizeof(ied.id), + ISO9660_DCHARS); ied.version = to_711(ISO_VERSION); memcpy(pd, &ied, sizeof(ied)); diff --git a/lib/paranoia/Makefile.am b/lib/paranoia/Makefile.am index e0b1f200..4fbfbbed 100644 --- a/lib/paranoia/Makefile.am +++ b/lib/paranoia/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.1 2004/12/18 17:29:32 rocky Exp $ +# $Id: Makefile.am,v 1.2 2005/09/20 00:42:14 rocky Exp $ # # Copyright (C) 2004 Rocky Bernstein # @@ -43,8 +43,10 @@ # public release, then set AGE to 0. A changed interface means an # incompatibility with previous versions. +EXTRA_DIST = libcdio_cdda.sym + libcdio_paranoia_la_CURRENT := 0 -libcdio_paranoia_la_REVISION := 0 +libcdio_paranoia_la_REVISION := 1 libcdio_paranoia_la_AGE := 0 noinst_HEADERS = gap.h isort.h overlap.h p_block.h @@ -57,8 +59,6 @@ lib_LTLIBRARIES = libcdio_paranoia.la libcdio_paranoia_la_SOURCES = $(libcdio_paranoia_sources) libcdio_paranoia_la_ldflags = -version-info $(libcdio_paranoia_la_CURRENT):$(libcdio_paranoia_la_REVISION):$(libcdio_paranoia_la_AGE) -libcdio_paranoia_la_LDFLAGS = $(libcdio_paranoia_la_ldflags) - INCLUDES = $(LIBCDIO_CFLAGS) FLAGS=@LIBCDIO_CFLAGS@ @TYPESIZES@ @CFLAGS@ -I.. -I../.. @@ -75,3 +75,79 @@ DEBUG=$(FLAGS) ## $(MAKE) libcdio_paranoia.a CFLAGS="$(DEBUG)" LIBS = $(LIBCDIO_LIBS) $(LIBCDIO_CDDA_LIBS) + + +######################################################## +# Things to version the symbols in the libraries +######################################################## + +# An explanation of the versioning problem from Nicolas Boullis and +# the versioned symbol solution he uses below... +# +# Currently, libvcdinfo uses the cdio_open function from libcdio. +# Let's imagine a program foobar that uses both the vcdinfo_open +# function from libvcdinfo and the cdio_open function from libcdio. + +# Currently, libcdio has SONAME libcdio.so.0, libvcdinfo has SONAME +# libvcdinfo.so.0 and requires libcdio.so.0, and foobar requires both +# libvcdinfo.so.0 and libcdio.so.0. Everything looks fine. +# +# Now, for some reason, you decide to change the cdio_open function. +# That's your right, but you have to bump the CURRENT version and (if I +# understand it correctly, athough this is not that clear in libtool's +# documentation) set the AGE to 0. Anyway, this bumps the SONAME, which is +# sane since the interface changes incompatibly. + +# Now, you have a new libcdio with SONAME libcdio.so.1. But libvcdinfo and +# foobar still require libcdio.so.0. Everything is still fine. + +# Now, after some minor changes, the author of foobar recompiles foobar. +# Then, foobar now requires libvcdinfo.so.0 and libcdio.so.1. And foobar +# now segfaults... + +# What is happening? When you run foobar, if brings both libvcdinfo.so.0 +# and libcdio.so.1, but libvcdinfo.so.0 also brings libcdio.so.0. So you +# have both libcdio.so.0 and libcdio.so.1 that bring their symbols to the +# global namespace. Hence, you have to incompatible versions of the +# cdio_open function in the name space. When foobar calls cdio_open, it +# may choose the wrong function, and segfaults... + +# With versioned symbols, the cdio_open function from libcdio.so.0 may be +# known as (something that looks like) cdio_open@@CDIO_0. An the cdio_open +# function from libcdio.so.1 as cdio_open@@CDIO_1. Both versions of +# libcdio would still be brought in by the most recent foobar, but foobar +# (and libvcdinfo) know which versioned function to use and then use the +# good one. + + +# This is some simple versioning where every symbol is versioned with +# something that looks like the SONAME of the library. More complex (and +# better) versioning is possible; it is for example what is used by glibc. +# But good complex versioning is something that requires much more +# work... + + +# The below is a impliments symbol versioning. First of all, I +# compute MAJOR as CURENT - AGE; that is what is used within libtool +# (at least on GNU/Linux systems) for the number in the SONAME. The +# nm command gives the list of symbols known in each of the object +# files that will be part of the shared library. And the sed command +# extracts from this list those symbols that will be shared. (This sed +# command comes from libtool.) + +libcdio_paranoia_la_MAJOR := $(shell expr $(libcdio_paranoia_la_CURRENT) - $(libcdio_paranoia_la_AGE)) +if BUILD_VERSIONED_LIBS +libcdio_paranoia_la_LDFLAGS = $(libcdio_paranoia_la_ldflags) -Wl,--version-script=libcdio_paranoia.la.ver +libcdio_paranoia_la_DEPENDENCIES = libcdio_paranoia.la.ver + +libcdio_paranoia.la.ver: $(libcdio_paranoia_la_OBJECTS) $(srcdir)/libcdio_paranoia.sym + echo 'CDIO_CDDA_$(libcdio_paranoia_la_MAJOR) { ' > $@ + objs=`for obj in $(libcdio_paranoia_la_OBJECTS); do sed -ne "s/^pic_object='\(.*\)'$$/\1/p" $$obj; done`; \ + nm $${objs} | sed -n -e 's/^.*[ ][ABCDGIRSTW][ABCDGIRSTW]*[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$$/\1/p' | sort -u | { first=true; while read symbol; do if grep -q "^$${symbol}\$$" $(srcdir)/libcdio_paranoia.sym; then if test $$first = true; then echo " global:"; first=false; fi; echo " $${symbol};"; fi; done; } >> $@; \ + nm $${objs} | sed -n -e 's/^.*[ ][ABCDGIRSTW][ABCDGIRSTW]*[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$$/\1/p' | sort -u | { first=true; while read symbol; do if grep -q "^$${symbol}\$$" $(srcdir)/libcdio_paranoia.sym; then :; else if test $$first = true; then echo " local:"; first=false; fi; echo " $${symbol};"; fi; done; } >> $@ + echo '};' >> $@ +else +libcdio_paranoia_la_LDFLAGS = $(libcdio_paranoia_la_ldflags) +endif + +MOSTLYCLEANFILES = libcdio_paranoia.la.ver diff --git a/lib/paranoia/libcdio_paranoia.sym b/lib/paranoia/libcdio_paranoia.sym new file mode 100644 index 00000000..20f8f1af --- /dev/null +++ b/lib/paranoia/libcdio_paranoia.sym @@ -0,0 +1,9 @@ +cdio_paranoia_init +cdio_paranoia_free +cdio_paranoia_modeset +cdio_paranoia_seek +cdio_paranoia_read +cdio_paranoia_read_limited +cdio_paranoia_overlapset +cdio_paranoia_set_range +paranoia_cb_mode2str diff --git a/lib/paranoia/p_block.c b/lib/paranoia/p_block.c index 71a5822f..59a9c562 100644 --- a/lib/paranoia/p_block.c +++ b/lib/paranoia/p_block.c @@ -1,5 +1,5 @@ /* - $Id: p_block.c,v 1.7 2005/02/06 15:09:10 rocky Exp $ + $Id: p_block.c,v 1.8 2005/09/20 00:42:14 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein Copyright (C) 1998 Monty xiphmont@mit.edu @@ -35,15 +35,15 @@ #include #include -linked_list *new_list(void *(*newp)(void),void (*freep)(void *)) +linked_list_t *new_list(void *(*newp)(void),void (*freep)(void *)) { - linked_list *ret=calloc(1,sizeof(linked_list)); + linked_list_t *ret=calloc(1,sizeof(linked_list_t)); ret->new_poly=newp; ret->free_poly=freep; return(ret); } -linked_element *add_elem(linked_list *l,void *elem) +linked_element *add_elem(linked_list_t *l,void *elem) { linked_element *ret=calloc(1,sizeof(linked_element)); @@ -64,16 +64,16 @@ linked_element *add_elem(linked_list *l,void *elem) } linked_element * -new_elem(linked_list *list) +new_elem(linked_list_t *p_list) { - void *new=list->new_poly(); - return(add_elem(list,new)); + void *p_new=p_list->new_poly(); + return(add_elem(p_list,p_new)); } void free_elem(linked_element *e,int free_ptr) { - linked_list *l=e->list; + linked_list_t *l=e->list; if(free_ptr)l->free_poly(e->ptr); if(e==l->head) @@ -91,7 +91,7 @@ free_elem(linked_element *e,int free_ptr) } void -free_list(linked_list *list,int free_ptr) +free_list(linked_list_t *list,int free_ptr) { while(list->head) free_elem(list->head,free_ptr); @@ -103,9 +103,9 @@ void *get_elem(linked_element *e) return(e->ptr); } -linked_list *copy_list(linked_list *list) +linked_list_t *copy_list(linked_list_t *list) { - linked_list *new=new_list(list->new_poly,list->free_poly); + linked_list_t *new=new_list(list->new_poly,list->free_poly); linked_element *i=list->tail; while(i){ @@ -264,7 +264,7 @@ v_prev(v_fragment_t *v) void recover_cache(cdrom_paranoia_t *p) { - linked_list *l=p->cache; + linked_list_t *l=p->cache; /* Are we at/over our allowed cache size? */ while(l->active>p->cache_limit) diff --git a/lib/paranoia/p_block.h b/lib/paranoia/p_block.h index 6ce0407a..e3285c6e 100644 --- a/lib/paranoia/p_block.h +++ b/lib/paranoia/p_block.h @@ -1,5 +1,5 @@ /* - $Id: p_block.h,v 1.4 2005/02/06 15:09:10 rocky Exp $ + $Id: p_block.h,v 1.5 2005/09/20 00:42:14 rocky Exp $ Copyright (C) 2004, 2005 Rocky Bernstein Copyright (C) by Monty (xiphmont@mit.edu) @@ -39,7 +39,7 @@ #include "isort.h" -typedef struct linked_list{ +typedef struct { /* linked list */ struct linked_element *head; struct linked_element *tail; @@ -49,25 +49,26 @@ typedef struct linked_list{ long current; long active; -} linked_list; +} linked_list_t; typedef struct linked_element{ void *ptr; struct linked_element *prev; struct linked_element *next; - struct linked_list *list; + linked_list_t *list; int stamp; } linked_element; -extern linked_list *new_list(void *(*new)(void),void (*free)(void *)); -extern linked_element *new_elem(linked_list *list); -extern linked_element *add_elem(linked_list *list,void *elem); -extern void free_list(linked_list *list,int free_ptr); /* unlink or free */ +extern linked_list_t *new_list(void *(*new_fn)(void),void (*free)(void *)); +extern linked_element *new_elem(linked_list_t *list); +extern linked_element *add_elem(linked_list_t *list,void *elem); +extern void free_list(linked_list_t *list,int free_ptr); /* unlink or free */ extern void free_elem(linked_element *e,int free_ptr); /* unlink or free */ extern void *get_elem(linked_element *e); -extern linked_list *copy_list(linked_list *list); /* shallow; doesn't copy - contained structures */ + +/* This is a shallow copy; it doesn't copy contained structures */ +extern linked_list_t *copy_list(linked_list_t *p_list); typedef struct c_block { /* The buffer */ @@ -153,13 +154,13 @@ typedef struct offsets{ struct cdrom_paranoia_s { cdrom_drive_t *d; - root_block root; /* verified/reconstructed cached data */ - linked_list *cache; /* our data as read from the cdrom */ + root_block root; /* verified/reconstructed cached data */ + linked_list_t *cache; /* our data as read from the cdrom */ long int cache_limit; - linked_list *fragments; /* fragments of blocks that have been 'verified' */ + linked_list_t *fragments; /* fragments of blocks that have been 'verified' */ sort_info_t *sortcache; - int readahead; /* sectors of readahead in each readop */ + int readahead; /* sectors of readahead in each readop */ int jitter; long lastread; @@ -203,6 +204,11 @@ extern void i_paranoia_firstlast(cdrom_paranoia_t *p); #define fs(f) (f->size) #define fv(f) (v_buffer(f)) +#ifndef DO_NOT_WANT_PARANOIA_COMPATIBILITY +/** For compatibility with good ol' paranoia */ +#define linked_list linked_list_t +#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/ + #define CDP_COMPILE #endif /*_P_BLOCK_H_*/