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.
This commit is contained in:
rocky
2004-10-22 01:13:38 +00:00
parent 454497f058
commit b80d83f07b
11 changed files with 70 additions and 40 deletions

View File

@@ -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 <rocky@panix.com>
#
@@ -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 \

View File

@@ -1,196 +0,0 @@
/*
$Id: bytesex.h,v 1.3 2003/04/22 12:09:09 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __CDIO_BYTESEX_H__
#define __CDIO_BYTESEX_H__
#include <cdio/logging.h>
#include <cdio/types.h>
#include "bytesex_asm.h"
/* generic byteswap routines */
#define UINT16_SWAP_LE_BE_C(val) ((uint16_t) ( \
(((uint16_t) (val) & (uint16_t) 0x00ffU) << 8) | \
(((uint16_t) (val) & (uint16_t) 0xff00U) >> 8)))
#define UINT32_SWAP_LE_BE_C(val) ((uint32_t) ( \
(((uint32_t) (val) & (uint32_t) 0x000000ffU) << 24) | \
(((uint32_t) (val) & (uint32_t) 0x0000ff00U) << 8) | \
(((uint32_t) (val) & (uint32_t) 0x00ff0000U) >> 8) | \
(((uint32_t) (val) & (uint32_t) 0xff000000U) >> 24)))
#define UINT64_SWAP_LE_BE_C(val) ((uint64_t) ( \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x00000000000000ff)) << 56) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x000000000000ff00)) << 40) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x0000000000ff0000)) << 24) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x00000000ff000000)) << 8) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x000000ff00000000)) >> 8) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x0000ff0000000000)) >> 24) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x00ff000000000000)) >> 40) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0xff00000000000000)) >> 56)))
#ifndef UINT16_SWAP_LE_BE
# define UINT16_SWAP_LE_BE UINT16_SWAP_LE_BE_C
#endif
#ifndef UINT32_SWAP_LE_BE
# define UINT32_SWAP_LE_BE UINT32_SWAP_LE_BE_C
#endif
#ifndef UINT64_SWAP_LE_BE
# define UINT64_SWAP_LE_BE UINT64_SWAP_LE_BE_C
#endif
inline static
uint16_t uint16_swap_le_be (const uint16_t val)
{
return UINT16_SWAP_LE_BE (val);
}
inline static
uint32_t uint32_swap_le_be (const uint32_t val)
{
return UINT32_SWAP_LE_BE (val);
}
inline static
uint64_t uint64_swap_le_be (const uint64_t val)
{
return UINT64_SWAP_LE_BE (val);
}
# define UINT8_TO_BE(val) ((uint8_t) (val))
# define UINT8_TO_LE(val) ((uint8_t) (val))
#ifdef WORDS_BIGENDIAN
# define UINT16_TO_BE(val) ((uint16_t) (val))
# define UINT16_TO_LE(val) ((uint16_t) UINT16_SWAP_LE_BE(val))
# define UINT32_TO_BE(val) ((uint32_t) (val))
# define UINT32_TO_LE(val) ((uint32_t) UINT32_SWAP_LE_BE(val))
# define UINT64_TO_BE(val) ((uint64_t) (val))
# define UINT64_TO_LE(val) ((uint64_t) UINT64_SWAP_LE_BE(val))
#else
# define UINT16_TO_BE(val) ((uint16_t) UINT16_SWAP_LE_BE(val))
# define UINT16_TO_LE(val) ((uint16_t) (val))
# define UINT32_TO_BE(val) ((uint32_t) UINT32_SWAP_LE_BE(val))
# define UINT32_TO_LE(val) ((uint32_t) (val))
# define UINT64_TO_BE(val) ((uint64_t) UINT64_SWAP_LE_BE(val))
# define UINT64_TO_LE(val) ((uint64_t) (val))
#endif
/* symmetric conversions */
#define UINT8_FROM_BE(val) (UINT8_TO_BE (val))
#define UINT8_FROM_LE(val) (UINT8_TO_LE (val))
#define UINT16_FROM_BE(val) (UINT16_TO_BE (val))
#define UINT16_FROM_LE(val) (UINT16_TO_LE (val))
#define UINT32_FROM_BE(val) (UINT32_TO_BE (val))
#define UINT32_FROM_LE(val) (UINT32_TO_LE (val))
#define UINT64_FROM_BE(val) (UINT64_TO_BE (val))
#define UINT64_FROM_LE(val) (UINT64_TO_LE (val))
/* converter function template */
#define CVT_TO_FUNC(bits) \
static inline uint ## bits ## _t \
uint ## bits ## _to_be (uint ## bits ## _t val) \
{ return UINT ## bits ## _TO_BE (val); } \
static inline uint ## bits ## _t \
uint ## bits ## _to_le (uint ## bits ## _t val) \
{ return UINT ## bits ## _TO_LE (val); } \
CVT_TO_FUNC(8)
CVT_TO_FUNC(16)
CVT_TO_FUNC(32)
CVT_TO_FUNC(64)
#undef CVT_TO_FUNC
#define uint8_from_be(val) (uint8_to_be (val))
#define uint8_from_le(val) (uint8_to_le (val))
#define uint16_from_be(val) (uint16_to_be (val))
#define uint16_from_le(val) (uint16_to_le (val))
#define uint32_from_be(val) (uint32_to_be (val))
#define uint32_from_le(val) (uint32_to_le (val))
#define uint64_from_be(val) (uint64_to_be (val))
#define uint64_from_le(val) (uint64_to_le (val))
/* ISO9660 related stuff */
#define to_711(i) uint8_to_le(i)
#define from_711(i) uint8_from_le(i)
#define to_721(i) uint16_to_le(i)
#define from_721(i) uint16_from_le(i)
#define to_721(i) uint16_to_le(i)
#define from_721(i) uint16_from_le(i)
#define to_722(i) uint16_to_be(i)
#define from_722(i) uint16_from_be(i)
static inline uint32_t
to_723(uint16_t i)
{
return uint32_swap_le_be(i) | i;
}
static inline uint16_t
from_723 (uint32_t p)
{
if (uint32_swap_le_be (p) != p)
cdio_warn ("from_723: broken byte order");
return (0xFFFF & p);
}
#define to_731(i) uint32_to_le(i)
#define from_731(i) uint32_from_le(i)
#define to_732(i) uint32_to_be(i)
#define from_732(i) uint32_from_be(i)
static inline uint64_t
to_733(uint32_t i)
{
return uint64_swap_le_be(i) | i;
}
static inline uint32_t
from_733 (uint64_t p)
{
if (uint64_swap_le_be (p) != p)
cdio_warn ("from_733: broken byte order");
return (UINT32_C(0xFFFFFFFF) & p);
}
#endif /* __CDIO_BYTESEX_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

View File

@@ -1,123 +0,0 @@
/*
$Id: bytesex_asm.h,v 1.3 2003/04/22 12:09:09 rocky Exp $
Copyright (C) 2001 Sven Ottemann <ac-logic@freenet.de>
2001 Herbert Valerio Riedel <hvr@gnu.org>
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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __CDIO_BYTESEX_ASM_H__
#define __CDIO_BYTESEX_ASM_H__
#if !defined(DISABLE_ASM_OPTIMIZE)
#include <cdio/types.h>
#if defined(__powerpc__) && defined(__GNUC__)
inline static
uint32_t uint32_swap_le_be_asm(const uint32_t a)
{
uint32_t b;
__asm__ ("lwbrx %0,0,%1"
:"=r"(b)
:"r"(&a), "m"(a));
return b;
}
inline static
uint16_t uint16_swap_le_be_asm(const uint16_t a)
{
uint32_t b;
__asm__ ("lhbrx %0,0,%1"
:"=r"(b)
:"r"(&a), "m"(a));
return b;
}
#define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
#define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
#elif defined(__mc68000__) && defined(__STORMGCC__)
inline static
uint32_t uint32_swap_le_be_asm(uint32_t a __asm__("d0"))
{
/* __asm__("rolw #8,%0; swap %0; rolw #8,%0" : "=d" (val) : "0" (val)); */
__asm__("move.l %1,d0;rol.w #8,d0;swap d0;rol.w #8,d0;move.l d0,%0"
:"=r"(a)
:"r"(a));
return(a);
}
inline static
uint16_t uint16_swap_le_be_asm(uint16_t a __asm__("d0"))
{
__asm__("move.l %1,d0;rol.w #8,d0;move.l d0,%0"
:"=r"(a)
:"r"(a));
return(a);
}
#define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
#define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
#elif 0 && defined(__i386__) && defined(__GNUC__)
inline static
uint32_t uint32_swap_le_be_asm(uint32_t a)
{
__asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
"rorl $16,%0\n\t" /* swap words */
"xchgb %b0,%h0" /* swap higher bytes */
:"=q" (a)
: "0" (a));
return(a);
}
inline static
uint16_t uint16_swap_le_be_asm(uint16_t a)
{
__asm__("xchgb %b0,%h0" /* swap bytes */
: "=q" (a)
: "0" (a));
return(a);
}
#define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
#define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
#endif
#endif /* !defined(DISABLE_ASM_OPTIMIZE) */
#endif /* __CDIO_BYTESEX_ASM_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

View File

@@ -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 <rocky@panix.com>
Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org>
@@ -37,16 +37,16 @@
#include <glob.h>
#endif
#include <cdio/bytesex.h>
#include <cdio/ds.h>
#include <cdio/logging.h>
#include <cdio/util.h>
#include <cdio/version.h>
#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 */

View File

@@ -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 <hvr@gnu.org>
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
@@ -22,9 +22,9 @@
/* Private headers */
#include "iso9660_private.h"
#include "cdio_assert.h"
#include "bytesex.h"
/* Public headers */
#include <cdio/bytesex.h>
#include <cdio/iso9660.h>
#include <cdio/util.h>
@@ -37,7 +37,7 @@
#include <stdio.h>
#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"

View File

@@ -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 <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -28,23 +28,23 @@
#endif
#include <cdio/cdio.h>
#include <cdio/bytesex.h>
#include <cdio/iso9660.h>
#include <cdio/util.h>
/* Private headers */
#include "cdio_assert.h"
#include "bytesex.h"
#include "_cdio_stdio.h"
#include "cdio_private.h"
#include <stdio.h>
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;
}

View File

@@ -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 <hvr@gnu.org>
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
@@ -31,10 +31,10 @@
/* Public headers */
#include <cdio/iso9660.h>
#include <cdio/util.h>
#include <cdio/bytesex.h>
/* Private headers */
#include "cdio_assert.h"
#include "bytesex.h"
#define BUF_COUNT 16
#define BUF_SIZE 80