From b80d83f07b2fcd793f2bbd232a48c8b8ebc40b20 Mon Sep 17 00:00:00 2001 From: rocky Date: Fri, 22 Oct 2004 01:13:38 +0000 Subject: [PATCH] iso9660.h, iso9660_fs.c: Add iso9660_ifs_is_xa() a routine to determine if an iso image has XA attributes. bytesex.h and bytesex_asm.h are now public. (Down the line should use glib though.) Package has been revised to the move. iso-info.c: shows XA attributes what that it is available. --- include/cdio/Makefile.am | 6 ++-- {lib => include/cdio}/bytesex.h | 8 ++--- {lib => include/cdio}/bytesex_asm.h | 4 +-- include/cdio/iso9660.h | 8 ++++- lib/Makefile.am | 5 ++-- lib/image/nrg.c | 6 ++-- lib/iso9660.c | 6 ++-- lib/iso9660_fs.c | 46 +++++++++++++++++++++-------- lib/xa.c | 4 +-- src/cd-info.c | 4 +-- src/iso-info.c | 13 ++++---- 11 files changed, 70 insertions(+), 40 deletions(-) rename {lib => include/cdio}/bytesex.h (97%) rename {lib => include/cdio}/bytesex_asm.h (95%) diff --git a/include/cdio/Makefile.am b/include/cdio/Makefile.am index f5b3e5bc..4a5fe2a9 100644 --- a/include/cdio/Makefile.am +++ b/include/cdio/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.12 2004/10/09 03:20:28 rocky Exp $ +# $Id: Makefile.am,v 1.13 2004/10/22 01:13:38 rocky Exp $ # # Copyright (C) 2003, 2004 Rocky Bernstein # @@ -23,7 +23,9 @@ libcdioincludedir=$(includedir)/cdio libcdioinclude_HEADERS = \ - cdio.h \ + bytesex.h \ + bytesex_asm.h \ + cdtext.h \ cdtext.h \ cd_types.h \ ds.h \ diff --git a/lib/bytesex.h b/include/cdio/bytesex.h similarity index 97% rename from lib/bytesex.h rename to include/cdio/bytesex.h index 1e9155b5..e29ff61b 100644 --- a/lib/bytesex.h +++ b/include/cdio/bytesex.h @@ -1,7 +1,7 @@ /* - $Id: bytesex.h,v 1.3 2003/04/22 12:09:09 rocky Exp $ + $Id: bytesex.h,v 1.1 2004/10/22 01:13:38 rocky Exp $ - Copyright (C) 2000 Herbert Valerio Riedel + Copyright (C) 2000, 2004 Herbert Valerio Riedel 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 @@ -21,9 +21,9 @@ #ifndef __CDIO_BYTESEX_H__ #define __CDIO_BYTESEX_H__ -#include #include -#include "bytesex_asm.h" +#include +#include /* generic byteswap routines */ diff --git a/lib/bytesex_asm.h b/include/cdio/bytesex_asm.h similarity index 95% rename from lib/bytesex_asm.h rename to include/cdio/bytesex_asm.h index 2b56e382..8e3afa1c 100644 --- a/lib/bytesex_asm.h +++ b/include/cdio/bytesex_asm.h @@ -1,8 +1,8 @@ /* - $Id: bytesex_asm.h,v 1.3 2003/04/22 12:09:09 rocky Exp $ + $Id: bytesex_asm.h,v 1.1 2004/10/22 01:13:38 rocky Exp $ Copyright (C) 2001 Sven Ottemann - 2001 Herbert Valerio Riedel + 2001, 2004 Herbert Valerio Riedel 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 diff --git a/include/cdio/iso9660.h b/include/cdio/iso9660.h index cc2310b0..dd79149d 100644 --- a/include/cdio/iso9660.h +++ b/include/cdio/iso9660.h @@ -1,5 +1,5 @@ /* - $Id: iso9660.h,v 1.49 2004/10/10 20:36:10 rocky Exp $ + $Id: iso9660.h,v 1.50 2004/10/22 01:13:38 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -664,6 +664,12 @@ iso9660_set_pvd (void *pd, const char volume_id[], const char application_id[], void iso9660_set_evd (void *pd); +/*! + Return true if ISO 9660 image has extended attrributes (XA). +*/ +bool iso9660_ifs_is_xa (const iso9660_t * p_iso); + + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lib/Makefile.am b/lib/Makefile.am index 38d4e708..3fae5e6f 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.49 2004/10/09 03:20:28 rocky Exp $ +# $Id: Makefile.am,v 1.50 2004/10/22 01:13:38 rocky Exp $ # # Copyright (C) 2003, 2004 Rocky Bernstein # @@ -50,8 +50,7 @@ libiso9660_la_AGE := 0 EXTRA_DIST = image/Makefile FreeBSD/Makefile MSWindows/Makefile -noinst_HEADERS = cdio_assert.h bytesex.h bytesex_asm.h \ - cdio_private.h +noinst_HEADERS = cdio_assert.h cdio_private.h libcdio_sources = \ _cdio_bsdi.c \ diff --git a/lib/image/nrg.c b/lib/image/nrg.c index 2f4e65e9..e632b1ba 100644 --- a/lib/image/nrg.c +++ b/lib/image/nrg.c @@ -1,5 +1,5 @@ /* - $Id: nrg.c,v 1.41 2004/10/09 03:20:28 rocky Exp $ + $Id: nrg.c,v 1.42 2004/10/22 01:13:38 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein Copyright (C) 2001, 2003 Herbert Valerio Riedel @@ -37,16 +37,16 @@ #include #endif +#include #include #include #include #include #include "cdio_assert.h" -#include "bytesex.h" #include "_cdio_stdio.h" #include "nrg.h" -static const char _rcsid[] = "$Id: nrg.c,v 1.41 2004/10/09 03:20:28 rocky Exp $"; +static const char _rcsid[] = "$Id: nrg.c,v 1.42 2004/10/22 01:13:38 rocky Exp $"; /* reader */ diff --git a/lib/iso9660.c b/lib/iso9660.c index 75e3fbf8..7fab14b9 100644 --- a/lib/iso9660.c +++ b/lib/iso9660.c @@ -1,5 +1,5 @@ /* - $Id: iso9660.c,v 1.16 2004/06/18 23:00:06 rocky Exp $ + $Id: iso9660.c,v 1.17 2004/10/22 01:13:38 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003 Rocky Bernstein @@ -22,9 +22,9 @@ /* Private headers */ #include "iso9660_private.h" #include "cdio_assert.h" -#include "bytesex.h" /* Public headers */ +#include #include #include @@ -37,7 +37,7 @@ #include #endif -static const char _rcsid[] = "$Id: iso9660.c,v 1.16 2004/06/18 23:00:06 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660.c,v 1.17 2004/10/22 01:13:38 rocky Exp $"; /* some parameters... */ #define SYSTEM_ID "CD-RTOS CD-BRIDGE" diff --git a/lib/iso9660_fs.c b/lib/iso9660_fs.c index 72bd7f57..66683037 100644 --- a/lib/iso9660_fs.c +++ b/lib/iso9660_fs.c @@ -1,5 +1,5 @@ /* - $Id: iso9660_fs.c,v 1.25 2004/10/09 23:20:52 rocky Exp $ + $Id: iso9660_fs.c,v 1.26 2004/10/22 01:13:38 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003, 2004 Rocky Bernstein @@ -28,23 +28,23 @@ #endif #include +#include #include #include /* Private headers */ #include "cdio_assert.h" -#include "bytesex.h" #include "_cdio_stdio.h" #include "cdio_private.h" #include -static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.25 2004/10/09 23:20:52 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.26 2004/10/22 01:13:38 rocky Exp $"; /* Implementation of iso9660_t type */ struct _iso9660 { CdioDataSource *stream; /* Stream pointer */ - void *env; /* environment. */ + bool b_xa; /* true if has XA attributes. */ }; /*! @@ -54,17 +54,28 @@ struct _iso9660 { iso9660_t * iso9660_open (const char *pathname /*flags, mode */) { - iso9660_t *iso = (iso9660_t *) _cdio_malloc(sizeof(struct _iso9660)) ; + iso9660_t *p_iso = (iso9660_t *) _cdio_malloc(sizeof(struct _iso9660)) ; + iso9660_pvd_t pvd; - if (NULL == iso) return NULL; + if (NULL == p_iso) return NULL; - iso->stream = cdio_stdio_new( pathname ); - if (NULL == iso->stream) { - free(iso); - return NULL; - } + p_iso->stream = cdio_stdio_new( pathname ); + if (NULL == p_iso->stream) + goto error; - return iso; + if (!iso9660_ifs_read_pvd(p_iso, &pvd)) + goto error; + + /* Determine if image has XA attributes. */ + + p_iso->b_xa = !strncmp ((char *) &pvd + ISO_XA_MARKER_OFFSET, + ISO_XA_MARKER_STRING, + strlen (ISO_XA_MARKER_STRING)); + return p_iso; + + error: + free(p_iso); + return NULL; } @@ -761,3 +772,14 @@ iso9660_find_fs_lsn(const CdIo *cdio, lsn_t lsn) return find_fs_lsn_recurse (cdio, "/", lsn); } +/*! + Return true if ISO 9660 image has extended attrributes (XA). +*/ +bool +iso9660_ifs_is_xa (const iso9660_t * p_iso) +{ + if (!p_iso) return false; + return p_iso->b_xa; +} + + diff --git a/lib/xa.c b/lib/xa.c index 76d5d83f..3d19b628 100644 --- a/lib/xa.c +++ b/lib/xa.c @@ -1,5 +1,5 @@ /* - $Id: xa.c,v 1.4 2003/09/21 01:14:30 rocky Exp $ + $Id: xa.c,v 1.5 2004/10/22 01:13:38 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003 Rocky Bernstein @@ -31,10 +31,10 @@ /* Public headers */ #include #include +#include /* Private headers */ #include "cdio_assert.h" -#include "bytesex.h" #define BUF_COUNT 16 #define BUF_SIZE 80 diff --git a/src/cd-info.c b/src/cd-info.c index e8cf453a..f6602d3e 100644 --- a/src/cd-info.c +++ b/src/cd-info.c @@ -1,5 +1,5 @@ /* - $Id: cd-info.c,v 1.90 2004/10/09 03:20:28 rocky Exp $ + $Id: cd-info.c,v 1.91 2004/10/22 01:13:38 rocky Exp $ Copyright (C) 2003, 2004 Rocky Bernstein Copyright (C) 1996, 1997, 1998 Gerd Knorr @@ -37,6 +37,7 @@ #include #endif +#include #include #include #include @@ -45,7 +46,6 @@ #include #include "cdio_assert.h" -#include "bytesex.h" #include "iso9660_private.h" #include diff --git a/src/iso-info.c b/src/iso-info.c index 368696ce..e717c4f2 100644 --- a/src/iso-info.c +++ b/src/iso-info.c @@ -1,5 +1,5 @@ /* - $Id: iso-info.c,v 1.10 2004/10/09 03:20:28 rocky Exp $ + $Id: iso-info.c,v 1.11 2004/10/22 01:13:38 rocky Exp $ Copyright (C) 2004 Rocky Bernstein @@ -32,6 +32,7 @@ # include "config.h" #endif #include +#include #include #include #include @@ -151,13 +152,13 @@ _log_handler (cdio_log_level_t level, const char message[]) } static void -print_iso9660_recurse (iso9660_t *iso, const char pathname[]) +print_iso9660_recurse (iso9660_t *p_iso, const char pathname[]) { CdioList *entlist; CdioList *dirlist = _cdio_list_new (); CdioListNode *entnode; - entlist = iso9660_ifs_readdir (iso, pathname); + entlist = iso9660_ifs_readdir (p_iso, pathname); printf ("%s:\n", pathname); @@ -189,8 +190,8 @@ print_iso9660_recurse (iso9660_t *iso, const char pathname[]) && strcmp (iso_name, "..")) _cdio_list_append (dirlist, strdup (_fullname)); -#if FINISHED - if (fs & CDIO_FS_ANAL_XA) { +#if 1 + if (iso9660_ifs_is_xa(p_iso)) { printf ( " %c %s %d %d [fn %.2d] [LSN %6lu] ", (statbuf->type == _STAT_DIR) ? 'd' : '-', iso9660_get_xa_attr_str (statbuf->xa.attributes), @@ -222,7 +223,7 @@ print_iso9660_recurse (iso9660_t *iso, const char pathname[]) { char *_fullname = _cdio_list_node_data (entnode); - print_iso9660_recurse (iso, _fullname); + print_iso9660_recurse (p_iso, _fullname); } _cdio_list_free (dirlist, true);