summaryrefslogtreecommitdiff
path: root/include/cdio
diff options
context:
space:
mode:
Diffstat (limited to 'include/cdio')
-rw-r--r--include/cdio/Makefile.am62
-rw-r--r--include/cdio/audio.h148
-rw-r--r--include/cdio/bytesex.h220
-rw-r--r--include/cdio/bytesex_asm.h130
-rw-r--r--include/cdio/cd_types.h175
-rw-r--r--include/cdio/cdda.h411
-rw-r--r--include/cdio/cdio.h84
-rw-r--r--include/cdio/cdio_config.h258
-rw-r--r--include/cdio/cdtext.h125
-rw-r--r--include/cdio/device.h995
-rw-r--r--include/cdio/disc.h108
-rw-r--r--include/cdio/ds.h98
-rw-r--r--include/cdio/dvd.h112
-rw-r--r--include/cdio/ecma_167.h1006
-rw-r--r--include/cdio/iso9660.h1116
-rw-r--r--include/cdio/logging.h136
-rw-r--r--include/cdio/mmc.h907
-rw-r--r--include/cdio/paranoia.h202
-rw-r--r--include/cdio/posix.h43
-rw-r--r--include/cdio/read.h235
-rw-r--r--include/cdio/rock.h396
-rw-r--r--include/cdio/sector.h286
-rw-r--r--include/cdio/track.h269
-rw-r--r--include/cdio/types.h327
-rw-r--r--include/cdio/udf.h171
-rw-r--r--include/cdio/udf_file.h117
-rw-r--r--include/cdio/udf_time.h80
-rw-r--r--include/cdio/utf8.h92
-rw-r--r--include/cdio/util.h117
-rw-r--r--include/cdio/version.h12
-rw-r--r--include/cdio/version.h.in12
-rw-r--r--include/cdio/xa.h179
32 files changed, 8629 insertions, 0 deletions
diff --git a/include/cdio/Makefile.am b/include/cdio/Makefile.am
new file mode 100644
index 00000000..ea695618
--- /dev/null
+++ b/include/cdio/Makefile.am
@@ -0,0 +1,62 @@
+# $Id: Makefile.am,v 1.34 2008/03/20 19:02:37 karl Exp $
+#
+# Copyright (C) 2003, 2004, 2006, 2008 Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+
+########################################################
+# Things to make the install (public) libcdio headers
+########################################################
+#
+
+if BUILD_CD_PARANOIA
+paranoiaheaders = cdda.h cdtext.h
+endif
+
+libcdioincludedir=$(includedir)/cdio
+libcdioinclude_HEADERS = \
+ audio.h \
+ bytesex.h \
+ bytesex_asm.h \
+ cdio.h \
+ cdio_config.h \
+ cd_types.h \
+ device.h \
+ disc.h \
+ ds.h \
+ dvd.h \
+ ecma_167.h \
+ iso9660.h \
+ logging.h \
+ mmc.h \
+ paranoia.h \
+ posix.h \
+ read.h \
+ rock.h \
+ sector.h \
+ track.h \
+ types.h \
+ udf.h \
+ udf_file.h \
+ udf_time.h \
+ utf8.h \
+ util.h \
+ version.h \
+ xa.h \
+ $(paranoiaheaders)
+
+EXTRA_DIST = version.h.in
+BUILT_SOURCES = version.h
+
+DISTCLEANFILES = cdio_config.h
diff --git a/include/cdio/audio.h b/include/cdio/audio.h
new file mode 100644
index 00000000..880cd541
--- /dev/null
+++ b/include/cdio/audio.h
@@ -0,0 +1,148 @@
+/* -*- c -*-
+ $Id: audio.h,v 1.12 2008/03/25 15:59:08 karl Exp $
+
+ Copyright (C) 2005, 2007, 2008 Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file audio.h
+ *
+ * \brief The top-level header for CD audio-related libcdio
+ * calls. These control playing of the CD-ROM through its
+ * line-out jack.
+ */
+#ifndef __CDIO_AUDIO_H__
+#define __CDIO_AUDIO_H__
+
+#include <cdio/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /*! This struct is used by the cdio_audio_read_subchannel */
+ typedef struct cdio_subchannel_s
+ {
+ uint8_t format;
+ uint8_t audio_status;
+ uint8_t address: 4;
+ uint8_t control: 4;
+ uint8_t track;
+ uint8_t index;
+ msf_t abs_addr;
+ msf_t rel_addr;
+ } cdio_subchannel_t;
+
+ /*! This struct is used by cdio_audio_get_volume and cdio_audio_set_volume */
+ typedef struct cdio_audio_volume_s
+ {
+ uint8_t level[4];
+ } cdio_audio_volume_t;
+
+
+ /*! This struct is used by the CDROMPLAYTRKIND ioctl */
+ typedef struct cdio_track_index_s
+ {
+ uint8_t i_start_track; /**< start track */
+ uint8_t i_start_index; /**< start index */
+ uint8_t i_end_track; /**< end track */
+ uint8_t i_end_index; /**< end index */
+ } cdio_track_index_t;
+
+ /*!
+ Get volume of an audio CD.
+
+ @param p_cdio the CD object to be acted upon.
+ @param p_volume place to put the list of volume outputs levels
+
+ p_volume can be NULL in which case we return only whether the driver
+ has the ability to get the volume or not.
+
+ */
+ driver_return_code_t cdio_audio_get_volume (CdIo_t *p_cdio, /*out*/
+ cdio_audio_volume_t *p_volume);
+
+ /*!
+ Return the number of seconds (discarding frame portion) of an MSF
+ */
+ uint32_t cdio_audio_get_msf_seconds(msf_t *p_msf);
+
+ /*!
+ Pause playing CD through analog output
+
+ @param p_cdio the CD object to be acted upon.
+ */
+ driver_return_code_t cdio_audio_pause (CdIo_t *p_cdio);
+
+ /*!
+ Playing CD through analog output at the given MSF.
+
+ @param p_cdio the CD object to be acted upon.
+ @param p_start_msf pointer to staring MSF
+ @param p_end_msf pointer to ending MSF
+ */
+ driver_return_code_t cdio_audio_play_msf (CdIo_t *p_cdio,
+ /*in*/msf_t *p_start_msf,
+ /*in*/ msf_t *p_end_msf);
+
+ /*!
+ Playing CD through analog output at the desired track and index
+
+ @param p_cdio the CD object to be acted upon.
+ @param p_track_index location to start/end.
+ */
+ driver_return_code_t cdio_audio_play_track_index
+ ( CdIo_t *p_cdio, cdio_track_index_t *p_track_index);
+
+ /*!
+ Get subchannel information.
+
+ @param p_cdio the CD object to be acted upon.
+ @param p_subchannel place for returned subchannel information
+ */
+ driver_return_code_t cdio_audio_read_subchannel (CdIo_t *p_cdio,
+ /*out*/ cdio_subchannel_t *p_subchannel);
+
+ /*!
+ Resume playing an audio CD.
+
+ @param p_cdio the CD object to be acted upon.
+
+ */
+ driver_return_code_t cdio_audio_resume (CdIo_t *p_cdio);
+
+ /*!
+ Set volume of an audio CD.
+
+ @param p_cdio the CD object to be acted upon.
+ @param p_volume place for returned volume-level information
+
+ */
+ driver_return_code_t cdio_audio_set_volume (CdIo_t *p_cdio, /*out*/
+ cdio_audio_volume_t *p_volume);
+
+ /*!
+ Stop playing an audio CD.
+
+ @param p_cdio the CD object to be acted upon.
+
+ */
+ driver_return_code_t cdio_audio_stop (CdIo_t *p_cdio);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CDIO_AUDIO_H__ */
diff --git a/include/cdio/bytesex.h b/include/cdio/bytesex.h
new file mode 100644
index 00000000..e1be483e
--- /dev/null
+++ b/include/cdio/bytesex.h
@@ -0,0 +1,220 @@
+/*
+ $Id: bytesex.h,v 1.5 2008/03/25 15:59:08 karl Exp $
+
+ Copyright (C) 2000, 2004 Herbert Valerio Riedel <hvr@gnu.org>
+ Copyright (C) 2005, 2008 Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file bytesex.h
+ * \brief Generic Byte-swapping routines.
+ *
+ * Note: this header will is slated to get removed and libcdio will
+ * use glib.h routines instead.
+*/
+
+#ifndef __CDIO_BYTESEX_H__
+#define __CDIO_BYTESEX_H__
+
+#include <cdio/types.h>
+#include <cdio/bytesex_asm.h>
+#include <cdio/logging.h>
+
+/** 16-bit big-endian to little-endian */
+#define UINT16_SWAP_LE_BE_C(val) ((uint16_t) ( \
+ (((uint16_t) (val) & (uint16_t) 0x00ffU) << 8) | \
+ (((uint16_t) (val) & (uint16_t) 0xff00U) >> 8)))
+
+/** 32-bit big-endian to little-endian */
+#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)))
+
+/** 64-bit big-endian to little-endian */
+#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 field conversion routines */
+
+/** Convert from uint8_t to ISO 9660 7.1.1 format */
+#define to_711(i) uint8_to_le(i)
+
+/** Convert from ISO 9660 7.1.1 format to uint8_t */
+#define from_711(i) uint8_from_le(i)
+
+/** Convert from uint16_t to ISO 9669 7.2.1 format */
+#define to_721(i) uint16_to_le(i)
+
+/** Convert from ISO 9660 7.2.1 format to uint16_t */
+#define from_721(i) uint16_from_le(i)
+
+/** Convert from uint16_t to ISO 9669 7.2.2 format */
+#define to_722(i) uint16_to_be(i)
+
+/** Convert from ISO 9660 7.2.2 format to uint16_t */
+#define from_722(i) uint16_from_be(i)
+
+/** Convert from uint16_t to ISO 9669 7.2.3 format */
+static inline uint32_t
+to_723(uint16_t i)
+{
+ return uint32_swap_le_be(i) | i;
+}
+
+/** Convert from ISO 9660 7.2.3 format to uint16_t */
+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);
+}
+
+/** Convert from uint16_t to ISO 9669 7.3.1 format */
+#define to_731(i) uint32_to_le(i)
+
+/** Convert from ISO 9660 7.3.1 format to uint32_t */
+#define from_731(i) uint32_from_le(i)
+
+/** Convert from uint32_t to ISO 9669 7.3.2 format */
+#define to_732(i) uint32_to_be(i)
+
+/** Convert from ISO 9660 7.3.2 format to uint32_t */
+#define from_732(i) uint32_from_be(i)
+
+/** Convert from uint16_t to ISO 9669 7.3.3 format */
+static inline uint64_t
+to_733(uint32_t i)
+{
+ return uint64_swap_le_be(i) | i;
+}
+
+/** Convert from ISO 9660 7.3.3 format to uint32_t */
+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:
+ */
diff --git a/include/cdio/bytesex_asm.h b/include/cdio/bytesex_asm.h
new file mode 100644
index 00000000..7f1f131a
--- /dev/null
+++ b/include/cdio/bytesex_asm.h
@@ -0,0 +1,130 @@
+/*
+ $Id: bytesex_asm.h,v 1.3 2008/03/25 15:59:08 karl Exp $
+
+ Copyright (C) 2008 Rocky Bernstein <rocky@gnu.org>
+ 2001, 2004, 2005 Herbert Valerio Riedel <hvr@gnu.org>
+ 2001 Sven Ottemann <ac-logic@freenet.de>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file bytesex_asm.h
+ * \brief Assembly code to handle byte-swapping.
+
+ Note: this header will is slated to get removed and libcdio will use
+ glib.h routines instead.
+*/
+
+#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:
+ */
diff --git a/include/cdio/cd_types.h b/include/cdio/cd_types.h
new file mode 100644
index 00000000..bc1f16c0
--- /dev/null
+++ b/include/cdio/cd_types.h
@@ -0,0 +1,175 @@
+/*
+ $Id: cd_types.h,v 1.18 2008/03/25 15:59:08 karl Exp $
+
+ Copyright (C) 2003, 2006, 2008 Rocky Bernstein <rocky@cpan.org>
+ Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org>
+ and Heiko Eißfeldt <heiko@hexco.de>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file cd_types.h
+ * \brief Header for routines which automatically determine the Compact Disc
+ * format and possibly filesystem on the CD.
+ *
+ */
+
+#ifndef __CDIO_CD_TYPES_H__
+#define __CDIO_CD_TYPES_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * Filesystem types we understand. The highest-numbered fs type should
+ * be less than CDIO_FS_MASK defined below.
+ */
+ typedef enum {
+ CDIO_FS_AUDIO = 1, /**< audio only - not really a
+ filesystem */
+ CDIO_FS_HIGH_SIERRA = 2, /**< High-Sierra Filesystem */
+ CDIO_FS_ISO_9660 = 3, /**< ISO 9660 filesystem */
+ CDIO_FS_INTERACTIVE = 4,
+ CDIO_FS_HFS = 5, /**< file system used on the Macintosh
+ system in MacOS 6 through MacOS 9
+ and deprecated in OSX. */
+ CDIO_FS_UFS = 6, /**< Generic Unix file system derived
+ from the Berkeley fast file
+ system. */
+
+ /**<
+ * EXT2 was the GNU/Linux native filesystem for early kernels. Newer
+ * GNU/Linux OS's may use EXT3 which is EXT2 with a journal.
+ */
+ CDIO_FS_EXT2 = 7,
+
+ CDIO_FS_ISO_HFS = 8, /**< both HFS & ISO-9660 filesystem */
+ CDIO_FS_ISO_9660_INTERACTIVE = 9, /**< both CD-RTOS and ISO filesystem */
+
+
+ /**<
+ * The 3DO is, technically, a set of specifications created by the 3DO
+ * company. These specs are for making a 3DO Interactive Multiplayer
+ * which uses a CD-player. Panasonic in the early 90's was the first
+ * company to manufacture and market a 3DO player.
+ */
+ CDIO_FS_3DO = 10,
+
+
+ /**<
+ Microsoft X-BOX CD.
+ */
+ CDIO_FS_XISO = 11,
+ CDIO_FS_UDFX = 12,
+ CDIO_FS_UDF = 13,
+ CDIO_FS_ISO_UDF = 14
+ } cdio_fs_t;
+
+
+/**
+ * Macro to extract just the FS type portion defined above
+*/
+#define CDIO_FSTYPE(fs) (fs & CDIO_FS_MASK)
+
+/**
+ * Bit masks for the classes of CD-images. These are generally
+ * higher-level than the fs-type information above and may be determined
+ * based of the fs type information. This
+ */
+ typedef enum {
+ CDIO_FS_MASK = 0x000f, /**< Note: this should be 2**n-1 and
+ and greater than the highest
+ CDIO_FS number above */
+ CDIO_FS_ANAL_XA = 0x00010, /**< eXtended Architecture format */
+ CDIO_FS_ANAL_MULTISESSION = 0x00020, /**< CD has multisesion */
+ CDIO_FS_ANAL_PHOTO_CD = 0x00040, /**< Is a Kodak Photo CD */
+ CDIO_FS_ANAL_HIDDEN_TRACK = 0x00080, /**< Hidden track at the
+ beginning of the CD */
+ CDIO_FS_ANAL_CDTV = 0x00100,
+ CDIO_FS_ANAL_BOOTABLE = 0x00200, /**< CD is bootable */
+ CDIO_FS_ANAL_VIDEOCD = 0x00400, /**< VCD 1.1 */
+ CDIO_FS_ANAL_ROCKRIDGE = 0x00800, /**< Has Rock Ridge Extensions to
+ ISO 9660, */
+ CDIO_FS_ANAL_JOLIET = 0x01000, /**< Microsoft Joliet extensions
+ to ISO 9660, */
+ CDIO_FS_ANAL_SVCD = 0x02000, /**< Super VCD or Choiji Video CD */
+ CDIO_FS_ANAL_CVD = 0x04000, /**< Choiji Video CD */
+ CDIO_FS_ANAL_XISO = 0x08000, /**< XBOX CD */
+ CDIO_FS_ANAL_ISO9660_ANY = 0x10000, /**< Any sort fo ISO9660 FS */
+ CDIO_FS_ANAL_VCD_ANY = (CDIO_FS_ANAL_VIDEOCD|CDIO_FS_ANAL_SVCD|
+ CDIO_FS_ANAL_CVD),
+ CDIO_FS_MATCH_ALL = ~CDIO_FS_MASK /**< bitmask which can
+ be used by
+ cdio_get_devices to
+ specify matching any
+ sort of CD. */
+ } cdio_fs_cap_t;
+
+
+#define CDIO_FS_UNKNOWN CDIO_FS_MASK
+
+/**
+ *
+ */
+#define CDIO_FS_MATCH_ALL (cdio_fs_anal_t) (~CDIO_FS_MASK)
+
+
+/*!
+ \brief The type used to return analysis information from
+ cdio_guess_cd_type.
+
+ These fields make sense only for when an ISO-9660 filesystem is used.
+ */
+typedef struct
+{
+ unsigned int joliet_level; /**< If has Joliet extensions, this is the
+ associated level number (i.e. 1, 2, or 3). */
+ char iso_label[33]; /**< This is 32 + 1 for null byte at the end in
+ formatting the string */
+ unsigned int isofs_size;
+ uint8_t UDFVerMinor; /**< For UDF filesystems only */
+ uint8_t UDFVerMajor; /**< For UDF filesystems only */
+} cdio_iso_analysis_t;
+
+/**
+ * Try to determine what kind of CD-image and/or filesystem we
+ * have at track track_num. Return information about the CD image
+ * is returned in iso_analysis and the return value.
+ */
+cdio_fs_anal_t cdio_guess_cd_type(const CdIo_t *cdio, int start_session,
+ track_t track_num,
+ /*out*/ cdio_iso_analysis_t *iso_analysis);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/** The below variables are trickery to force the above enum symbol
+ values to be recorded in debug symbol tables. They are used to
+ allow one to refer to the enumeration value names in the typedefs
+ above in a debugger and debugger expressions.
+*/
+extern cdio_fs_cap_t debug_cdio_fs_cap;
+extern cdio_fs_t debug_cdio_fs;
+
+#endif /* __CDIO_CD_TYPES_H__ */
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/cdio/cdda.h b/include/cdio/cdda.h
new file mode 100644
index 00000000..c30e129d
--- /dev/null
+++ b/include/cdio/cdda.h
@@ -0,0 +1,411 @@
+/*
+ $Id: cdda.h,v 1.30 2008/03/25 15:59:08 karl Exp $
+
+ Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 2001 Xiph.org and Heiko Eissfeldt heiko@escape.colossus.de
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file cdda.h
+ *
+ * \brief The top-level interface header for libcdio_cdda.
+ * Applications include this for paranoia access.
+ *
+ ******************************************************************/
+
+#ifndef _CDDA_INTERFACE_H_
+#define _CDDA_INTERFACE_H_
+
+#include <cdio/cdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /** cdrom_paranoia is an opaque structure which is used in all of the
+ library operations.
+ */
+ typedef struct cdrom_paranoia_s cdrom_paranoia_t;
+ typedef struct cdrom_drive_s cdrom_drive_t;
+
+ /** For compatibility. cdrom_drive_t is deprecated, use cdrom_drive_t
+ instead. */
+
+ /**
+ Flags for simulating jitter used in testing.
+
+ The enumeration type one probably wouldn't really use in a program.
+ It is here instead of defines to give symbolic names that can be
+ helpful in debuggers where wants just to say refer to
+ CDDA_TEST_JITTER_SMALL and get the correct value.
+ */
+ typedef enum {
+ CDDA_MESSAGE_FORGETIT = 0,
+ CDDA_MESSAGE_PRINTIT = 1,
+ CDDA_MESSAGE_LOGIT = 2,
+ CD_FRAMESAMPLES = CDIO_CD_FRAMESIZE_RAW / 4,
+ MAXTRK = (CDIO_CD_MAX_TRACKS+1)
+ } paranoia_cdda_enums_t;
+
+
+#include <signal.h>
+
+/** We keep MAXTRK since this header is exposed publicly and other
+ programs may have used this.
+*/
+#define MAXTRK (CDIO_CD_MAX_TRACKS+1)
+
+/** \brief Structure for cdparanoia's CD Table of Contents */
+typedef struct TOC_s {
+ unsigned char bTrack;
+ int32_t dwStartSector;
+} TOC_t;
+
+/** For compatibility. TOC is deprecated, use TOC_t instead. */
+#define TOC TOC_t
+
+/** \brief Structure for cdparanoia's CD-ROM access */
+struct cdrom_drive_s {
+
+ CdIo_t *p_cdio;
+ int opened; /**< This struct may just represent a candidate for opening */
+
+ char *cdda_device_name;
+
+ char *drive_model;
+ int drive_type;
+ int bigendianp; /**< Whether data returned on the CDDA is bigendian or
+ not. 1 if big endian, 0 if little endian and -1 if
+ we don't know.
+ */
+ int nsectors; /**< Number of sectors use in reading. Multiply by
+ CDIO_CD_FRAMESIZE_RAW to get number of bytes used in
+ the read buffer. */
+
+ int cd_extra; /**< -1 if we can't get multisession info, 0 if
+ there is one session only or the multi-session
+ LBA is less than or 100 (don't ask me why -- I
+ don't know), and 1 if the multi-session lba is
+ greater than 100. */
+
+ bool b_swap_bytes; /**< Swap bytes if Endian-ness of drive
+ mismatches the endian-ness of the
+ computer? */
+ track_t tracks;
+ TOC_t disc_toc[MAXTRK]; /**< info here starts origin 0 rather than the
+ first track number (usually 1). So to take
+ a track number and use it here, subtract
+ off cdio_get_first_track_num() beforehand.
+ */
+ lsn_t audio_first_sector;
+ lsn_t audio_last_sector;
+
+ int errordest;
+ int messagedest;
+ char *errorbuf;
+ char *messagebuf;
+
+ /* functions specific to particular drives/interfaces */
+
+ int (*enable_cdda) (cdrom_drive_t *d, int onoff);
+ int (*read_toc) (cdrom_drive_t *d);
+ long (*read_audio) (cdrom_drive_t *d, void *p, lsn_t begin,
+ long sectors);
+ int (*set_speed) (cdrom_drive_t *d, int speed);
+ int error_retry;
+ int report_all;
+
+ int is_atapi;
+ int is_mmc;
+
+ int i_test_flags; /**< Normally set 0. But if we are testing
+ paranoia operation this can be set to one of
+ the flag masks to simulate a particular kind of
+ failure. */
+
+};
+
+
+ /**
+ Flags for simulating jitter used in testing.
+
+ The enumeration type one probably wouldn't really use in a program.
+ It is here instead of defines to give symbolic names that can be
+ helpful in debuggers where wants just to say refer to
+ CDDA_TEST_JITTER_SMALL and get the correct value.
+ */
+ typedef enum {
+ CDDA_TEST_JITTER_SMALL = 1,
+ CDDA_TEST_JITTER_LARGE = 2,
+ CDDA_TEST_JITTER_MASSIVE = 3,
+ CDDA_TEST_FRAG_SMALL = (1<<3),
+ CDDA_TEST_FRAG_LARGE = (2<<3),
+ CDDA_TEST_FRAG_MASSIVE = (3<<3),
+ CDDA_TEST_UNDERRUN = 64
+ } paranoia_jitter_t;
+
+/** jitter testing. The first two bits are set to determine the
+ byte-distance we will jitter the data; 0 is no shifting.
+ */
+
+/**< jitter testing. Set the below bit to always cause jittering on reads.
+ The below bit only has any effect if the first two (above) bits are
+ nonzero. If the above bits are set, but the below bit isn't we'll
+ jitter 90% of the time.
+ */
+#define CDDA_TEST_ALWAYS_JITTER 4
+
+/** fragment testing */
+#define CDDA_TEST_FRAG_SMALL (1<<3)
+#define CDDA_TEST_FRAG_LARGE (2<<3)
+#define CDDA_TEST_FRAG_MASSIVE (3<<3)
+
+/**< under-run testing. The below bit is set for testing. */
+#define CDDA_TEST_UNDERRUN 64
+
+#if TESTING_IS_FINISHED
+
+ /** scratch testing */
+#define CDDA_TEST_SCRATCH 128
+#undef CDDA_TEST_BOGUS_BYTES 256
+#undef CDDA_TEST_DROPDUPE_BYTES 512
+#endif /* TESTING_IS_FINISHED */
+
+/** autosense functions */
+
+/** Get a CD-ROM drive with a CD-DA in it.
+ If mesagedest is 1, then any messages in the process will be stored
+ in message.
+*/
+extern cdrom_drive_t *cdio_cddap_find_a_cdrom(int messagedest,
+ char **ppsz_message);
+
+/** Returns a paranoia CD-ROM drive object with a CD-DA in it or NULL
+ if there was an error.
+ @see cdio_cddap_identify_cdio
+ */
+extern cdrom_drive_t *cdio_cddap_identify(const char *psz_device,
+ int messagedest,
+ char **ppsz_message);
+
+/** Returns a paranoia CD-ROM drive object with a CD-DA in it or NULL
+ if there was an error. In contrast to cdio_cddap_identify, we
+ start out with an initialized p_cdio object. For example you may
+ have used that for other purposes such as to get CDDB/CD-Text
+ information. @see cdio_cddap_identify
+ */
+cdrom_drive_t *cdio_cddap_identify_cdio(CdIo_t *p_cdio,
+ int messagedest, char **ppsz_messages);
+
+/** drive-oriented functions */
+
+extern int cdio_cddap_speed_set(cdrom_drive_t *d, int speed);
+extern void cdio_cddap_verbose_set(cdrom_drive_t *d, int err_action,
+ int mes_action);
+extern char *cdio_cddap_messages(cdrom_drive_t *d);
+extern char *cdio_cddap_errors(cdrom_drive_t *d);
+
+/*!
+ Closes d and releases all storage associated with it except
+ the internal p_cdio pointer.
+
+ @param d cdrom_drive_t object to be closed.
+ @return 0 if passed a null pointer and 1 if not in which case
+ some work was probably done.
+
+ @see cdio_cddap_close
+*/
+bool cdio_cddap_close_no_free_cdio(cdrom_drive_t *d);
+
+/*!
+ Closes d and releases all storage associated with it.
+ Doubles as "cdrom_drive_free()".
+
+ @param d cdrom_drive_t object to be closed.
+ @return 0 if passed a null pointer and 1 if not in which case
+ some work was probably done.
+
+ @see cdio_cddap_close_no_free_cdio
+*/
+extern int cdio_cddap_close(cdrom_drive_t *d);
+
+extern int cdio_cddap_open(cdrom_drive_t *d);
+
+extern long cdio_cddap_read(cdrom_drive_t *d, void *p_buffer,
+ lsn_t beginsector, long sectors);
+
+/*! Return the lsn for the start of track i_track */
+extern lsn_t cdio_cddap_track_firstsector(cdrom_drive_t *d,
+ track_t i_track);
+
+/*! Get last lsn of the track. This generally one less than the start
+ of the next track. -1 is returned on error. */
+extern lsn_t cdio_cddap_track_lastsector(cdrom_drive_t *d, track_t i_track);
+
+/*! Return the number of tracks on the CD. */
+extern track_t cdio_cddap_tracks(cdrom_drive_t *d);
+
+/*! Return the track containing the given LSN. If the LSN is before
+ the first track (in the pregap), 0 is returned. If there was an
+ error or the LSN after the LEADOUT (beyond the end of the CD), then
+ CDIO_INVALID_TRACK is returned.
+ */
+extern int cdio_cddap_sector_gettrack(cdrom_drive_t *d, lsn_t lsn);
+
+/*! Return the number of channels in track: 2 or 4; -2 if not
+ implemented or -1 for error.
+ Not meaningful if track is not an audio track.
+*/
+extern int cdio_cddap_track_channels(cdrom_drive_t *d, track_t i_track);
+
+/*! Return 1 is track is an audio track, 0 otherwise. */
+extern int cdio_cddap_track_audiop(cdrom_drive_t *d, track_t i_track);
+
+/*! Return 1 is track has copy permit set, 0 otherwise. */
+extern int cdio_cddap_track_copyp(cdrom_drive_t *d, track_t i_track);
+
+/*! Return 1 is audio track has linear preemphasis set, 0 otherwise.
+ Only makes sense for audio tracks.
+ */
+extern int cdio_cddap_track_preemp(cdrom_drive_t *d, track_t i_track);
+
+/*! Get first lsn of the first audio track. -1 is returned on error. */
+extern lsn_t cdio_cddap_disc_firstsector(cdrom_drive_t *d);
+
+/*! Get last lsn of the last audio track. The last lsn is generally one
+ less than the start of the next track after the audio track. -1 is
+ returned on error. */
+extern lsn_t cdio_cddap_disc_lastsector(cdrom_drive_t *d);
+
+/*! Determine Endian-ness of the CD-drive based on reading data from
+ it. Some drives return audio data Big Endian while some (most)
+ return data Little Endian. Drives known to return data bigendian are
+ SCSI drives from Kodak, Ricoh, HP, Philips, Plasmon, Grundig
+ CDR100IPW, and Mitsumi CD-R. ATAPI and MMC drives are little endian.
+
+ rocky: As someone who didn't write the code, I have to say this is
+ nothing less than brilliant. An FFT is done both ways and the the
+ transform is looked at to see which has data in the FFT (or audible)
+ portion. (Or so that's how I understand it.)
+
+ @return 1 if big-endian, 0 if little-endian, -1 if we couldn't
+ figure things out or some error.
+ */
+extern int data_bigendianp(cdrom_drive_t *d);
+
+/** transport errors: */
+
+typedef enum {
+ TR_OK = 0,
+ TR_EWRITE = 1 /**< Error writing packet command (transport) */,
+ TR_EREAD = 2 /**< Error reading packet data (transport) */,
+ TR_UNDERRUN = 3 /**< Read underrun */,
+ TR_OVERRUN = 4 /**< Read overrun */,
+ TR_ILLEGAL = 5 /**< Illegal/rejected request */,
+ TR_MEDIUM = 6 /**< Medium error */,
+ TR_BUSY = 7 /**< Device busy */,
+ TR_NOTREADY = 8 /**< Device not ready */,
+ TR_FAULT = 9 /**< Device failure */,
+ TR_UNKNOWN = 10 /**< Unspecified error */,
+ TR_STREAMING = 11 /**< loss of streaming */,
+} transport_error_t;
+
+
+#ifdef NEED_STRERROR_TR
+const char *strerror_tr[]={
+ "Success",
+ "Error writing packet command to device",
+ "Error reading command from device",
+ "SCSI packet data underrun (too little data)",
+ "SCSI packet data overrun (too much data)",
+ "Illegal SCSI request (rejected by target)",
+ "Medium reading data from medium",
+ "Device busy",
+ "Device not ready",
+ "Target hardware fault",
+ "Unspecified error",
+ "Drive lost streaming"
+};
+#endif /*NEED_STERROR_TR*/
+
+/** Errors returned by lib:
+
+\verbatim
+001: Unable to set CDROM to read audio mode
+002: Unable to read table of contents lead-out
+003: CDROM reporting illegal number of tracks
+004: Unable to read table of contents header
+005: Unable to read table of contents entry
+006: Could not read any data from drive
+007: Unknown, unrecoverable error reading data
+008: Unable to identify CDROM model
+009: CDROM reporting illegal table of contents
+010: Unaddressable sector
+
+100: Interface not supported
+101: Drive is neither a CDROM nor a WORM device
+102: Permision denied on cdrom (ioctl) device
+103: Permision denied on cdrom (data) device
+
+300: Kernel memory error
+
+400: Device not open
+401: Invalid track number
+402: Track not audio data
+403: No audio tracks on disc
+\endverbatim
+
+*/
+
+#ifndef DO_NOT_WANT_PARANOIA_COMPATIBILITY
+/** For compatibility with good ol' paranoia */
+#define cdda_find_a_cdrom cdio_cddap_find_a_cdrom
+#define cdda_identify cdio_cddap_identify
+#define cdda_speed_set cdio_cddap_speed_set
+#define cdda_verbose_set cdio_cddap_verbose_set
+#define cdda_messages cdio_cddap_messages
+#define cdda_errors cdio_cddap_errors
+#define cdda_close cdio_cddap_close
+#define cdda_open cdio_cddap_open
+#define cdda_read cdio_cddap_read
+#define cdda_track_firstsector cdio_cddap_track_firstsector
+#define cdda_track_lastsector cdio_cddap_track_lastsector
+#define cdda_tracks cdio_cddap_tracks
+#define cdda_sector_gettrack cdio_cddap_sector_gettrack
+#define cdda_track_channels cdio_cddap_track_channels
+#define cdda_track_audiop cdio_cddap_track_audiop
+#define cdda_track_copyp cdio_cddap_track_copyp
+#define cdda_track_preemp cdio_cddap_track_preemp
+#define cdda_disc_firstsector cdio_cddap_disc_firstsector
+#define cdda_disc_lastsector cdio_cddap_disc_lastsector
+#define cdrom_drive cdrom_drive_t
+
+#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/** The below variables are trickery to force the above enum symbol
+ values to be recorded in debug symbol tables. They are used to
+ allow one to refer to the enumeration value names in the typedefs
+ above in a debugger and debugger expressions
+*/
+
+extern paranoia_jitter_t debug_paranoia_jitter;
+extern paranoia_cdda_enums_t debug_paranoia_cdda_enums;
+
+#endif /*_CDDA_INTERFACE_H_*/
+
diff --git a/include/cdio/cdio.h b/include/cdio/cdio.h
new file mode 100644
index 00000000..84e54b10
--- /dev/null
+++ b/include/cdio/cdio.h
@@ -0,0 +1,84 @@
+/* -*- c -*-
+ $Id: cdio.h,v 1.82 2008/03/25 15:59:08 karl Exp $
+
+ Copyright (C) 2003, 2004, 2005, 2008 Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file cdio.h
+ *
+ * \brief The top-level header for libcdio: the CD Input and Control
+ * library. Applications include this for anything regarding libcdio.
+ */
+
+
+#ifndef __CDIO_H__
+#define __CDIO_H__
+
+/** Application Interface or Protocol version number. If the public
+ * interface changes, we increase this number.
+ */
+#define CDIO_API_VERSION 5
+
+#include <cdio/version.h>
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <cdio/types.h>
+#include <cdio/sector.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* For compatibility. */
+#define CdIo CdIo_t
+
+ /** This is an opaque structure for the CD object. */
+ typedef struct _CdIo CdIo_t;
+
+ /** This is an opaque structure for the CD-Text object. */
+ typedef struct cdtext cdtext_t;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/* Drive(r)/Device-related functions. Perhaps we should break out
+ Driver from device?
+*/
+#include <cdio/device.h>
+
+/* Disc-related functions. */
+#include <cdio/disc.h>
+
+/* Sector (frame, or block)-related functions. Uses driver_return_code_t
+ from <cdio/device.h> so it should come after that.
+*/
+#include <cdio/read.h>
+
+/* CD-Text-related functions. */
+#include <cdio/cdtext.h>
+
+/* Track-related functions. */
+#include <cdio/track.h>
+
+#endif /* __CDIO_H__ */
diff --git a/include/cdio/cdio_config.h b/include/cdio/cdio_config.h
new file mode 100644
index 00000000..2005b888
--- /dev/null
+++ b/include/cdio/cdio_config.h
@@ -0,0 +1,258 @@
+/** \file cdio_config.h
+ * \brief configuration-time settings useful in compilation; a run-time
+ version of config.h
+*/
+/* config.h. Generated from config.h.in by configure. */
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define if building universal (internal helper macro) */
+/* #undef AC_APPLE_UNIVERSAL_BUILD */
+
+/* Define 1 if you are compiling using cygwin */
+/* #undef CYGWIN */
+
+/* what to put between the brackets for empty arrays */
+#define EMPTY_ARRAY_SIZE
+
+/* Define 1 if you have BSDI-type CD-ROM support */
+/* #undef HAVE_BSDI_CDROM */
+
+/* Define to 1 if you have the `bzero' function. */
+#define HAVE_BZERO 1
+
+/* Define this if you have libcddb installed */
+#define HAVE_CDDB /**/
+
+/* Define to 1 if you have the <CoreFoundation/CFBase.h> header file. */
+/* #undef HAVE_COREFOUNDATION_CFBASE_H */
+
+/* Define to 1 if you have the <curses.h> header file. */
+/* #undef HAVE_CURSES_H */
+
+/* Define 1 if you have Darwin OS X-type CD-ROM support */
+/* #undef HAVE_DARWIN_CDROM */
+
+/* Define if time.h defines extern long timezone and int daylight vars. */
+#define HAVE_DAYLIGHT 1
+
+/* Define to 1 if you have the Apple DiskArbitration framework */
+/* #undef HAVE_DISKARBITRATION */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you have the `drand48' function. */
+#define HAVE_DRAND48 1
+
+/* Define to 1 if you have the <dvd.h> header file. */
+/* #undef HAVE_DVD_H */
+
+/* Define to 1 if you have the <errno.h> header file. */
+#define HAVE_ERRNO_H 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define 1 if you have FreeBSD CD-ROM support */
+/* #undef HAVE_FREEBSD_CDROM */
+
+/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
+/* #undef HAVE_FSEEKO */
+
+/* Define to 1 if you have the `ftruncate' function. */
+#define HAVE_FTRUNCATE 1
+
+/* Define to 1 if you have the `geteuid' function. */
+#define HAVE_GETEUID 1
+
+/* Define to 1 if you have the `getgid' function. */
+#define HAVE_GETGID 1
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#define HAVE_GETOPT_H 1
+
+/* Define to 1 if you have the `getpwuid' function. */
+#define HAVE_GETPWUID 1
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#define HAVE_GETTIMEOFDAY 1
+
+/* Define to 1 if you have the `getuid' function. */
+#define HAVE_GETUID 1
+
+/* Define to 1 if you have the <glob.h> header file. */
+#define HAVE_GLOB_H 1
+
+/* Define to 1 if you have the `gmtime_r' function. */
+#define HAVE_GMTIME_R 1
+
+/* Define if you have the iconv() function and it works. */
+#define HAVE_ICONV 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <IOKit/IOKitLib.h> header file. */
+/* #undef HAVE_IOKIT_IOKITLIB_H */
+
+/* Supports ISO _Pragma() macro */
+#define HAVE_ISOC99_PRAGMA /**/
+
+/* Define 1 if you want ISO-9660 Joliet extension support. You must have also
+ libiconv installed to get Joliet extension support. */
+#define HAVE_JOLIET 1
+
+/* Define this if your libcurses has keypad */
+#define HAVE_KEYPAD /**/
+
+/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
+#define HAVE_LANGINFO_CODESET 1
+
+/* Define to 1 if you have the `nsl' library (-lnsl). */
+/* #undef HAVE_LIBNSL */
+
+/* Define to 1 if you have the `socket' library (-lsocket). */
+/* #undef HAVE_LIBSOCKET */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define 1 if you have Linux-type CD-ROM support */
+#define HAVE_LINUX_CDROM 1
+
+/* Define to 1 if you have the <linux/cdrom.h> header file. */
+#define HAVE_LINUX_CDROM_H 1
+
+/* Define 1 if timeout is in cdrom_generic_command struct */
+/* #undef HAVE_LINUX_CDROM_TIMEOUT */
+
+/* Define to 1 if you have the <linux/major.h> header file. */
+#define HAVE_LINUX_MAJOR_H 1
+
+/* Define to 1 if you have the <linux/version.h> header file. */
+#define HAVE_LINUX_VERSION_H 1
+
+/* Define to 1 if you have the `localtime_r' function. */
+#define HAVE_LOCALTIME_R 1
+
+/* Define to 1 if you have the `lstat' function. */
+#define HAVE_LSTAT 1
+
+/* Define to 1 if you have the `memcpy' function. */
+#define HAVE_MEMCPY 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if you have the <ncurses.h> header file. */
+#define HAVE_NCURSES_H 1
+
+/* Define 1 if you have NetBSD CD-ROM support */
+/* #undef HAVE_NETBSD_CDROM */
+
+/* Define 1 if you have OS/2 CD-ROM support */
+/* #undef HAVE_OS2_CDROM */
+
+/* Define to 1 if you have the <pwd.h> header file. */
+#define HAVE_PWD_H 1
+
+/* Define to 1 if you have the `rand' function. */
+#define HAVE_RAND 1
+
+/* Define to 1 if you have the `readlink' function. */
+#define HAVE_READLINK 1
+
+/* Define 1 if you want ISO-9660 Rock-Ridge extension support. */
+#define HAVE_ROCK 1
+
+/* Define to 1 if you have the `setegid' function. */
+#define HAVE_SETEGID 1
+
+/* Define to 1 if you have the `setenv' function. */
+#define HAVE_SETENV 1
+
+/* Define to 1 if you have the `seteuid' function. */
+#define HAVE_SETEUID 1
+
+/* Define to 1 if you have the `sleep' function. */
+#define HAVE_SLEEP 1
+
+/* Define to 1 if you have the `snprintf' function. */
+#define HAVE_SNPRINTF 1
+
+/* Define 1 if you have Solaris CD-ROM support */
+/* #undef HAVE_SOLARIS_CDROM */
+
+/* Define to 1 if you have the <stdarg.h> header file. */
+#define HAVE_STDARG_H 1
+
+/* Define to 1 if you have the <stdbool.h> header file. */
+#define HAVE_STDBOOL_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define this if you have struct timespec */
+#define HAVE_STRUCT_TIMESPEC /**/
+
+/* Define to 1 if you have the <sys/cdio.h> header file. */
+/* #undef HAVE_SYS_CDIO_H */
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#define HAVE_SYS_PARAM_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/timeb.h> header file. */
+#define HAVE_SYS_TIMEB_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/utsname.h> header file. */
+#define HAVE_SYS_UTSNAME_H 1
+
+/* Define this <sys/stat.h> defines S_ISLNK() */
+#define HAVE_S_ISLNK /**/
+
+/* Define this <sys/stat.h> defines S_ISSOCK() */
+#define HAVE_S_ISSOCK /**/
+
+/* Define to 1 if timegm is available */
+#define HAVE_TIMEGM 1
+
+/* Define if you have an extern long timenzone variable. */
+#define HAVE_TIMEZONE_VAR 1
+
+/* Define if struct tm has the tm_gmtoff member. */
+#define HAVE_TM_GMTOFF 1
+
+/* Define if time.h defines extern extern char *tzname[2] variable */
+#define HAVE_TZNAME 1
+
+/* Define to 1 if you have the `tzset' function. */
+#define HAVE_TZSET 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `unsetenv' function. */
diff --git a/include/cdio/cdtext.h b/include/cdio/cdtext.h
new file mode 100644
index 00000000..daac733f
--- /dev/null
+++ b/include/cdio/cdtext.h
@@ -0,0 +1,125 @@
+/*
+ $Id: cdtext.h,v 1.14 2008/03/25 15:59:08 karl Exp $
+
+ Copyright (C) 2004, 2005, 2008 Rocky Bernstein <rocky@gnu.org>
+ adapted from cuetools
+ Copyright (C) 2003 Svend Sanjay Sorensen <ssorensen@fastmail.fm>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+/*!
+ * \file cdtext.h
+ *
+ * \brief The top-level header for CD-Text information. Applications
+ * include this for CD-Text access.
+*/
+
+
+#ifndef __CDIO_CDTEXT_H__
+#define __CDIO_CDTEXT_H__
+
+#include <cdio/cdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define MAX_CDTEXT_FIELDS 13
+#define MIN_CDTEXT_FIELD 0
+
+ /*! \brief structure for holding CD-Text information
+
+ @see cdtext_init, cdtext_destroy, cdtext_get, and cdtext_set.
+ */
+ struct cdtext {
+ char *field[MAX_CDTEXT_FIELDS];
+ };
+
+ /*! \brief A list of all of the CD-Text fields. Because
+ the interval has no gaps, we can use ++ to iterate over fields.
+ */
+ typedef enum {
+ CDTEXT_ARRANGER = 0, /**< name(s) of the arranger(s) */
+ CDTEXT_COMPOSER = 1, /**< name(s) of the composer(s) */
+ CDTEXT_DISCID = 2, /**< disc identification information */
+ CDTEXT_GENRE = 3, /**< genre identification and genre information */
+ CDTEXT_MESSAGE = 4, /**< ISRC code of each track */
+ CDTEXT_ISRC = 5, /**< message(s) from the content provider or artist */
+ CDTEXT_PERFORMER = 6, /**< name(s) of the performer(s) */
+ CDTEXT_SIZE_INFO = 7, /**< size information of the block */
+ CDTEXT_SONGWRITER = 8, /**< name(s) of the songwriter(s) */
+ CDTEXT_TITLE = 9, /**< title of album name or track titles */
+ CDTEXT_TOC_INFO = 10, /**< table of contents information */
+ CDTEXT_TOC_INFO2 = 11, /**< second table of contents information */
+ CDTEXT_UPC_EAN = 12,
+ CDTEXT_INVALID = MAX_CDTEXT_FIELDS
+ } cdtext_field_t;
+
+ /*! Return string representation of the enum values above */
+ const char *cdtext_field2str (cdtext_field_t i);
+
+ /*! Initialize a new cdtext structure.
+ When the structure is no longer needed, release the
+ resources using cdtext_delete.
+ */
+ void cdtext_init (cdtext_t *cdtext);
+
+ /*! Free memory assocated with cdtext*/
+ void cdtext_destroy (cdtext_t *cdtext);
+
+ /*! returns an allocated string associated with the given field. NULL is
+ returned if key is CDTEXT_INVALID or the field is not set.
+
+ The user needs to free the string when done with it.
+
+ @see cdio_get_const to retrieve a constant string that doesn't
+ have to be freed.
+ */
+ char *cdtext_get (cdtext_field_t key, const cdtext_t *cdtext);
+
+ /*! returns a const string associated with the given field. NULL is
+ returned if key is CDTEXT_INVALID or the field is not set.
+
+ Don't use the string when the cdtext object (i.e. the CdIo_t object
+ you got it from) is no longer valid.
+
+ @see cdio_get to retrieve an allocated string that persists past
+ the cdtext object.
+ */
+ const char *cdtext_get_const (cdtext_field_t key, const cdtext_t *cdtext);
+
+ /*!
+ returns enum of keyword if key is a CD-Text keyword,
+ returns MAX_CDTEXT_FIELDS non-zero otherwise.
+ */
+ cdtext_field_t cdtext_is_keyword (const char *key);
+
+ /*!
+ sets cdtext's keyword entry to field
+ */
+ void cdtext_set (cdtext_field_t key, const char *value, cdtext_t *cdtext);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CDIO_CDTEXT_H__ */
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/cdio/device.h b/include/cdio/device.h
new file mode 100644
index 00000000..cc84e79a
--- /dev/null
+++ b/include/cdio/device.h
@@ -0,0 +1,995 @@
+/* -*- c -*-
+ $Id: device.h,v 1.39 2008/03/28 01:28:50 rocky Exp $
+
+ Copyright (C) 2005, 2006, 2008, 2009 Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file device.h
+ *
+ * \brief C header for driver- or device-related libcdio
+ * calls. ("device" includes CD-image reading devices).
+ */
+#ifndef __CDIO_DEVICE_H__
+#define __CDIO_DEVICE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /*! The type of an drive capability bit mask. See below for values*/
+ typedef uint32_t cdio_drive_read_cap_t;
+ typedef uint32_t cdio_drive_write_cap_t;
+ typedef uint32_t cdio_drive_misc_cap_t;
+
+ /*!
+ \brief Drive capability bits returned by cdio_get_drive_cap()
+ NOTE: Setting a bit here means the presence of a capability.
+ */
+
+ /** Miscellaneous capabilities. */
+ typedef enum {
+ CDIO_DRIVE_CAP_ERROR = 0x40000, /**< Error */
+ CDIO_DRIVE_CAP_UNKNOWN = 0x80000, /**< Dunno. It can be on if we
+ have only partial information
+ or are not completely certain
+ */
+ CDIO_DRIVE_CAP_MISC_CLOSE_TRAY = 0x00001, /**< caddy systems can't
+ close... */
+ CDIO_DRIVE_CAP_MISC_EJECT = 0x00002, /**< but can eject. */
+ CDIO_DRIVE_CAP_MISC_LOCK = 0x00004, /**< disable manual eject */
+ CDIO_DRIVE_CAP_MISC_SELECT_SPEED = 0x00008, /**< programmable speed */
+ CDIO_DRIVE_CAP_MISC_SELECT_DISC = 0x00010, /**< select disc from
+ juke-box */
+ CDIO_DRIVE_CAP_MISC_MULTI_SESSION= 0x00020, /**< read sessions>1 */
+ CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED= 0x00080, /**< media changed */
+ CDIO_DRIVE_CAP_MISC_RESET = 0x00100, /**< hard reset device */
+ CDIO_DRIVE_CAP_MISC_FILE = 0x20000 /**< drive is really a file,
+ i.e a CD file image */
+ } cdio_drive_cap_misc_t;
+
+ /*! Reading masks.. */
+ typedef enum {
+ CDIO_DRIVE_CAP_READ_AUDIO = 0x00001, /**< drive can play CD audio */
+ CDIO_DRIVE_CAP_READ_CD_DA = 0x00002, /**< drive can read CD-DA */
+ CDIO_DRIVE_CAP_READ_CD_G = 0x00004, /**< drive can read CD+G */
+ CDIO_DRIVE_CAP_READ_CD_R = 0x00008, /**< drive can read CD-R */
+ CDIO_DRIVE_CAP_READ_CD_RW = 0x00010, /**< drive can read CD-RW */
+ CDIO_DRIVE_CAP_READ_DVD_R = 0x00020, /**< drive can read DVD-R */
+ CDIO_DRIVE_CAP_READ_DVD_PR = 0x00040, /**< drive can read DVD+R */
+ CDIO_DRIVE_CAP_READ_DVD_RAM = 0x00080, /**< drive can read DVD-RAM */
+ CDIO_DRIVE_CAP_READ_DVD_ROM = 0x00100, /**< drive can read DVD-ROM */
+ CDIO_DRIVE_CAP_READ_DVD_RW = 0x00200, /**< drive can read DVD-RW */
+ CDIO_DRIVE_CAP_READ_DVD_RPW = 0x00400, /**< drive can read DVD+RW */
+ CDIO_DRIVE_CAP_READ_C2_ERRS = 0x00800, /**< has C2 error correction */
+ CDIO_DRIVE_CAP_READ_MODE2_FORM1 = 0x01000, /**< can read mode 2 form 1 */
+ CDIO_DRIVE_CAP_READ_MODE2_FORM2 = 0x02000, /**< can read mode 2 form 2 */
+ CDIO_DRIVE_CAP_READ_MCN = 0x04000, /**< can read MCN */
+ CDIO_DRIVE_CAP_READ_ISRC = 0x08000 /**< can read ISRC */
+ } cdio_drive_cap_read_t;
+
+ /*! Writing masks.. */
+ typedef enum {
+ CDIO_DRIVE_CAP_WRITE_CD_R = 0x00001, /**< drive can write CD-R */
+ CDIO_DRIVE_CAP_WRITE_CD_RW = 0x00002, /**< drive can write CD-RW */
+ CDIO_DRIVE_CAP_WRITE_DVD_R = 0x00004, /**< drive can write DVD-R */
+ CDIO_DRIVE_CAP_WRITE_DVD_PR = 0x00008, /**< drive can write DVD+R */
+ CDIO_DRIVE_CAP_WRITE_DVD_RAM = 0x00010, /**< drive can write DVD-RAM */
+ CDIO_DRIVE_CAP_WRITE_DVD_RW = 0x00020, /**< drive can write DVD-RW */
+ CDIO_DRIVE_CAP_WRITE_DVD_RPW = 0x00040, /**< drive can write DVD+RW */
+ CDIO_DRIVE_CAP_WRITE_MT_RAINIER = 0x00080, /**< Mount Rainier */
+ CDIO_DRIVE_CAP_WRITE_BURN_PROOF = 0x00100, /**< burn proof */
+ CDIO_DRIVE_CAP_WRITE_CD =
+ (CDIO_DRIVE_CAP_WRITE_CD_R | CDIO_DRIVE_CAP_WRITE_CD_RW),
+ /**< Has some sort of CD writer ability */
+
+ CDIO_DRIVE_CAP_WRITE_DVD =
+ (CDIO_DRIVE_CAP_WRITE_DVD_R | CDIO_DRIVE_CAP_WRITE_DVD_PR
+ | CDIO_DRIVE_CAP_WRITE_DVD_RAM | CDIO_DRIVE_CAP_WRITE_DVD_RW
+ | CDIO_DRIVE_CAP_WRITE_DVD_RPW ),
+ /**< Has some sort of DVD writer ability */
+
+ CDIO_DRIVE_CAP_WRITE =
+ (CDIO_DRIVE_CAP_WRITE_CD | CDIO_DRIVE_CAP_WRITE_DVD)
+ /**< Has some sort of DVD or CD writing ability */
+ } cdio_drive_cap_write_t;
+
+/*! Size of fields returned by an INQUIRY command */
+ typedef enum {
+ CDIO_MMC_HW_VENDOR_LEN = 8, /**< length of vendor field */
+ CDIO_MMC_HW_MODEL_LEN = 16, /**< length of model field */
+ CDIO_MMC_HW_REVISION_LEN = 4 /**< length of revision field */
+ } cdio_mmc_hw_len_t;
+
+
+ /*! \brief Structure to return CD vendor, model, and revision-level
+ strings obtained via the INQUIRY command */
+ typedef struct cdio_hwinfo
+ {
+ char psz_vendor [CDIO_MMC_HW_VENDOR_LEN+1];
+ char psz_model [CDIO_MMC_HW_MODEL_LEN+1];
+ char psz_revision[CDIO_MMC_HW_REVISION_LEN+1];
+ } cdio_hwinfo_t;
+
+
+ /** Flags specifying the category of device to open or is opened. */
+ typedef enum {
+ CDIO_SRC_IS_DISK_IMAGE_MASK = 0x0001, /**< Read source is a CD image. */
+ CDIO_SRC_IS_DEVICE_MASK = 0x0002, /**< Read source is a CD device. */
+ CDIO_SRC_IS_SCSI_MASK = 0x0004, /**< Read source SCSI device. */
+ CDIO_SRC_IS_NATIVE_MASK = 0x0008
+ } cdio_src_category_mask_t;
+
+
+ /** The driver_id_t enumerations may be used to tag a specific driver
+ * that is opened or is desired to be opened. Note that this is
+ * different than what is available on a given host.
+ *
+ * Order should not be changed lightly because it breaks the ABI.
+ * One is not supposed to iterate over the values, but iterate over the
+ * cdio_drivers and cdio_device_drivers arrays.
+ *
+ * NOTE: IF YOU MODIFY ENUM MAKE SURE INITIALIZATION IN CDIO.C AGREES.
+ *
+ */
+ typedef enum {
+ DRIVER_UNKNOWN, /**< Used as input when we don't care what kind
+ of driver to use. */
+ DRIVER_AIX, /**< AIX driver */
+ DRIVER_BSDI, /**< BSDI driver */
+ DRIVER_FREEBSD, /**< FreeBSD driver - includes CAM and ioctl access */
+ DRIVER_NETBSD, /**< NetBSD Driver. */
+ DRIVER_LINUX, /**< GNU/Linux Driver */
+ DRIVER_SOLARIS, /**< Sun Solaris Driver */
+ DRIVER_OS2, /**< IBM OS/2 Driver */
+ DRIVER_OSX, /**< Apple OSX Driver */
+ DRIVER_WIN32, /**< Microsoft Windows Driver. Includes ASPI and
+ ioctl access. */
+ DRIVER_CDRDAO, /**< cdrdao format CD image. This is listed
+ before BIN/CUE, to make the code prefer cdrdao
+ over BIN/CUE when both exist. */
+ DRIVER_BINCUE, /**< CDRWIN BIN/CUE format CD image. This is
+ listed before NRG, to make the code prefer
+ BIN/CUE over NRG when both exist. */
+ DRIVER_NRG, /**< Nero NRG format CD image. */
+ DRIVER_DEVICE /**< Is really a set of the above; should come last */
+ } driver_id_t;
+
+ /** A null-terminated (that is DRIVER_UNKNOWN-terminated) ordered (in
+ order of preference) array of drivers.
+ */
+ extern const driver_id_t cdio_drivers[];
+ /** A null-terminated (that is DRIVER_UNKNOWN-terminated) ordered (in
+ order of preference) array of device drivers.
+ */
+ extern const driver_id_t cdio_device_drivers[];
+
+ /** There will generally be only one hardware for a given
+ build/platform from the list above. You can use the variable
+ below to determine which you've got. If the build doesn't make an
+ hardware driver, then the value will be DRIVER_UNKNOWN.
+ */
+ extern const driver_id_t cdio_os_driver;
+
+
+/** Those are deprecated; use cdio_drivers or cdio_device_drivers to
+ iterate over all drivers or only the device drivers.
+ Make sure what's listed for CDIO_MIN_DRIVER is the last
+ enumeration in driver_id_t. Since we have a bogus (but useful) 0th
+ entry above we don't have to add one.
+*/
+#define CDIO_MIN_DRIVER DRIVER_AIX
+#define CDIO_MIN_DEVICE_DRIVER CDIO_MIN_DRIVER
+#define CDIO_MAX_DRIVER DRIVER_NRG
+#define CDIO_MAX_DEVICE_DRIVER DRIVER_WIN32
+
+ /** The following are status codes for completion of a given cdio
+ operation. By design 0 is successful completion and -1 is error
+ completion. This is compatable with ioctl so those routines that
+ call ioctl can just pass the value the get back (cast as this
+ enum). Also, by using negative numbers for errors, the
+ enumeration values below can be used in places where a positive
+ value is expected when things complete successfully. For example,
+ get_blocksize returns the blocksize, but on error uses the error
+ codes below. So note that this enumeration is often cast to an
+ integer. C seems to tolerate this.
+ */
+ typedef enum {
+ DRIVER_OP_SUCCESS = 0, /**< in cases where an int is returned,
+ like cdio_set_speed, more the negative
+ return codes are for errors and the
+ positive ones for success. */
+ DRIVER_OP_ERROR = -1, /**< operation returned an error */
+ DRIVER_OP_UNSUPPORTED = -2, /**< returned when a particular driver
+ doesn't support a particular operation.
+ For example an image driver which doesn't
+ really "eject" a CD.
+ */
+ DRIVER_OP_UNINIT = -3, /**< returned when a particular driver
+ hasn't been initialized or a null
+ pointer has been passed.
+ */
+ DRIVER_OP_NOT_PERMITTED = -4, /**< Operation not permitted.
+ For example might be a permission
+ problem.
+ */
+ DRIVER_OP_BAD_PARAMETER = -5, /**< Bad parameter passed */
+ DRIVER_OP_BAD_POINTER = -6, /**< Bad pointer to memory area */
+ DRIVER_OP_NO_DRIVER = -7, /**< Operaton called on a driver
+ not available on this OS */
+ } driver_return_code_t;
+
+ /*!
+ Close media tray in CD drive if there is a routine to do so.
+
+ @param psz_drive the name of CD-ROM to be closed. If NULL, we will
+ use the default device.
+ @param p_driver_id is the driver to be used or that got used if
+ it was DRIVER_UNKNOWN or DRIVER_DEVICE; If this is NULL, we won't
+ report back the driver used.
+ */
+ driver_return_code_t cdio_close_tray (const char *psz_drive,
+ /*in/out*/ driver_id_t *p_driver_id);
+
+ /*!
+ @param drc the return code you want interpreted.
+ @return the string information about drc
+ */
+ const char *cdio_driver_errmsg(driver_return_code_t drc);
+
+ /*!
+ Eject media in CD drive if there is a routine to do so.
+
+ @param p_cdio the CD object to be acted upon.
+ If the CD is ejected *p_cdio is free'd and p_cdio set to NULL.
+ */
+ driver_return_code_t cdio_eject_media (CdIo_t **p_cdio);
+
+ /*!
+ Eject media in CD drive if there is a routine to do so.
+
+ @param psz_drive the name of the device to be acted upon.
+ If NULL is given as the drive, we'll use the default driver device.
+ */
+ driver_return_code_t cdio_eject_media_drive (const char *psz_drive);
+
+ /*!
+ Free device list returned by cdio_get_devices or
+ cdio_get_devices_with_cap.
+
+ @param device_list list returned by cdio_get_devices or
+ cdio_get_devices_with_cap
+
+ @see cdio_get_devices, cdio_get_devices_with_cap
+
+ */
+ void cdio_free_device_list (char * device_list[]);
+
+ /*!
+ Get the default CD device.
+ if p_cdio is NULL (we haven't initialized a specific device driver),
+ then find a suitable one and return the default device for that.
+
+ @param p_cdio the CD object queried
+ @return a string containing the default CD device or NULL is
+ if we couldn't get a default device.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+ */
+ char * cdio_get_default_device (const CdIo_t *p_cdio);
+
+ /*!
+ Return a string containing the default CD device if none is specified.
+ if p_driver_id is DRIVER_UNKNOWN or DRIVER_DEVICE
+ then find a suitable one set the default device for that.
+
+ NULL is returned if we couldn't get a default device.
+ */
+ char * cdio_get_default_device_driver (/*in/out*/ driver_id_t *p_driver_id);
+
+ /*! Return an array of device names. If you want a specific
+ devices for a driver, give that device. If you want hardware
+ devices, give DRIVER_DEVICE and if you want all possible devices,
+ image drivers and hardware drivers give DRIVER_UNKNOWN.
+
+ NULL is returned if we couldn't return a list of devices.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+ */
+ char ** cdio_get_devices (driver_id_t driver_id);
+
+ /*!
+ Get an array of device names in search_devices that have at least
+ the capabilities listed by the capabities parameter. If
+ search_devices is NULL, then we'll search all possible CD drives.
+
+ Capabilities have two parts to them, a "filesystem" part and an
+ "analysis" part.
+
+ The filesystem part is mutually exclusive. For example either the
+ filesystem is at most one of the High-Sierra, UFS, or HFS, ISO9660,
+ fileystems. Valid combinations of say HFS and ISO9660 are
+ specified as a separate "filesystem".
+
+ Capabilities on the other hand are not mutually exclusive. For example
+ a filesystem may have none, either, or both of the XA or Rock-Ridge
+ extension properties.
+
+ If "b_any" is set false then every capability listed in the
+ analysis portion of capabilities (i.e. not the basic filesystem)
+ must be satisified. If no analysis capabilities are specified,
+ that's a match.
+
+ If "b_any" is set true, then if any of the analysis capabilities
+ matches, we call that a success.
+
+ In either case, in the filesystem portion different filesystem
+ either specify 0 to match any filesystem or the specific
+ filesystem type.
+
+ To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
+
+ @return the array of device names or NULL if we couldn't get a
+ default device. It is also possible to return a non NULL but
+ after dereferencing the the value is NULL. This also means nothing
+ was found.
+ */
+ char ** cdio_get_devices_with_cap (/*in*/ char *ppsz_search_devices[],
+ cdio_fs_anal_t capabilities, bool b_any);
+
+ /*!
+ Like cdio_get_devices_with_cap but we return the driver we found
+ as well. This is because often one wants to search for kind of drive
+ and then *open* it afterwards. Giving the driver back facilitates this,
+ and speeds things up for libcdio as well.
+ */
+ char ** cdio_get_devices_with_cap_ret (/*in*/ char* ppsz_search_devices[],
+ cdio_fs_anal_t capabilities,
+ bool b_any,
+ /*out*/ driver_id_t *p_driver_id);
+
+ /*! Like cdio_get_devices, but we may change the p_driver_id if we
+ were given DRIVER_DEVICE or DRIVER_UNKNOWN. This is because
+ often one wants to get a drive name and then *open* it
+ afterwards. Giving the driver back facilitates this, and speeds
+ things up for libcdio as well.
+ */
+
+ char ** cdio_get_devices_ret (/*in/out*/ driver_id_t *p_driver_id);
+
+ /*!
+ Get the what kind of device we've got.
+
+ @param p_cdio the CD object queried
+ @param p_read_cap pointer to return read capabilities
+ @param p_write_cap pointer to return write capabilities
+ @param p_misc_cap pointer to return miscellaneous other capabilities
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it. In this situation capabilities will show up as
+ NULL even though there isa hardware CD-ROM.
+ */
+ void cdio_get_drive_cap (const CdIo_t *p_cdio,
+ cdio_drive_read_cap_t *p_read_cap,
+ cdio_drive_write_cap_t *p_write_cap,
+ cdio_drive_misc_cap_t *p_misc_cap);
+
+ /*!
+ Get the drive capabilities for a specified device.
+
+ Return a list of device capabilities.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it. In this situation capabilities will show up as
+ NULL even though there isa hardware CD-ROM.
+ */
+ void cdio_get_drive_cap_dev (const char *device,
+ cdio_drive_read_cap_t *p_read_cap,
+ cdio_drive_write_cap_t *p_write_cap,
+ cdio_drive_misc_cap_t *p_misc_cap);
+
+ /*!
+ Get a string containing the name of the driver in use.
+
+ @return a string with driver name or NULL if CdIo_t is NULL (we
+ haven't initialized a specific device.
+ */
+ const char * cdio_get_driver_name (const CdIo_t *p_cdio);
+
+ /*!
+ Get the driver id.
+ if CdIo_t is NULL (we haven't initialized a specific device driver),
+ then return DRIVER_UNKNOWN.
+
+ @return the driver id..
+ */
+ driver_id_t cdio_get_driver_id (const CdIo_t *p_cdio);
+
+ /*!
+ Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
+ False is returned if we had an error getting the information.
+ */
+ bool cdio_get_hwinfo ( const CdIo_t *p_cdio,
+ /*out*/ cdio_hwinfo_t *p_hw_info );
+
+
+ /*! Get the LSN of the first track of the last session of
+ on the CD.
+
+ @param p_cdio the CD object to be acted upon.
+ @param i_last_session pointer to the session number to be returned.
+ */
+ driver_return_code_t cdio_get_last_session (CdIo_t *p_cdio,
+ /*out*/ lsn_t *i_last_session);
+
+ /*!
+ Find out if media has changed since the last call.
+ @param p_cdio the CD object to be acted upon.
+ @return 1 if media has changed since last call, 0 if not. Error
+ return codes are the same as driver_return_code_t
+ */
+ int cdio_get_media_changed(CdIo_t *p_cdio);
+
+ /*! True if CD-ROM understand ATAPI commands. */
+ bool_3way_t cdio_have_atapi (CdIo_t *p_cdio);
+
+ /*! Like cdio_have_xxx but uses an enumeration instead. */
+ bool cdio_have_driver (driver_id_t driver_id);
+
+ /*
+ Free any resources associated with p_cdio. Call this when done using p_cdio
+ and using CD reading/control operations.
+
+ @param p_cdio the CD object to eliminated.
+ */
+ void cdio_destroy (CdIo_t *p_cdio);
+
+ /*!
+ Get a string decribing driver_id.
+
+ @param driver_id the driver you want the description for
+ @return a string of driver description
+ */
+ const char *cdio_driver_describe (driver_id_t driver_id);
+
+ /*! Sets up to read from place specified by psz_source and
+ driver_id. This or cdio_open_* should be called before using any
+ other routine, except cdio_init or any routine that accesses the
+ CD-ROM drive by name. cdio_open will call cdio_init, if that hasn't
+ been done previously.
+
+ @return the cdio object or NULL on error or no device. If NULL
+ is given as the source, we'll use the default driver device.
+ */
+ CdIo_t * cdio_open (const char *psz_source, driver_id_t driver_id);
+
+ /*! Sets up to read from place specified by psz_source, driver_id
+ and access mode. This or cdio_open* should be called before using
+ any other routine, except cdio_init or any routine that accesses
+ the CD-ROM drive by name. This will call cdio_init, if that
+ hasn't been done previously.
+
+ If NULL is given as the source, we'll use the default driver device.
+
+ @return the cdio object or NULL on error or no device.
+ */
+ CdIo_t * cdio_open_am (const char *psz_source,
+ driver_id_t driver_id, const char *psz_access_mode);
+
+ /*! Set up BIN/CUE CD disk-image for reading. Source is the .bin or
+ .cue file
+
+ @return the cdio object or NULL on error or no device.
+ */
+ CdIo_t * cdio_open_bincue (const char *psz_cue_name);
+
+ /*! Set up BIN/CUE CD disk-image for reading. Source is the .bin or
+ .cue file
+
+ @return the cdio object or NULL on error or no device..
+ */
+ CdIo_t * cdio_open_am_bincue (const char *psz_cue_name,
+ const char *psz_access_mode);
+
+ /*! Set up cdrdao CD disk-image for reading. Source is the .toc file
+
+ @return the cdio object or NULL on error or no device.
+ */
+ CdIo_t * cdio_open_cdrdao (const char *psz_toc_name);
+
+ /*! Set up cdrdao CD disk-image for reading. Source is the .toc file
+
+ @return the cdio object or NULL on error or no device..
+ */
+ CdIo_t * cdio_open_am_cdrdao (const char *psz_toc_name,
+ const char *psz_access_mode);
+
+ /*! Return a string containing the default CUE file that would
+ be used when none is specified.
+
+ @return the cdio object or NULL on error or no device.
+ */
+ char * cdio_get_default_device_bincue(void);
+
+ char **cdio_get_devices_bincue(void);
+
+ /*! @return string containing the default CUE file that would be
+ used when none is specified. NULL is returned on error or there
+ is no device.
+ */
+ char * cdio_get_default_device_cdrdao(void);
+
+ char **cdio_get_devices_cdrdao(void);
+
+ /*! Set up CD-ROM for reading. The device_name is
+ the some sort of device name.
+
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no driver for a some sort of hardware CD-ROM.
+ */
+ CdIo_t * cdio_open_cd (const char *device_name);
+
+ /*! Set up CD-ROM for reading. The device_name is
+ the some sort of device name.
+
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no driver for a some sort of hardware CD-ROM.
+ */
+ CdIo_t * cdio_open_am_cd (const char *psz_device,
+ const char *psz_access_mode);
+
+ /*! CDRWIN BIN/CUE CD disc-image routines. Source is the .cue file
+
+ @return the cdio object for subsequent operations.
+ NULL on error.
+ */
+ CdIo_t * cdio_open_cue (const char *cue_name);
+
+ /*! Set up CD-ROM for reading using the AIX driver. The device_name is
+ the some sort of device name.
+
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no AIX driver.
+
+ @see cdio_open
+ */
+ CdIo_t * cdio_open_am_aix (const char *psz_source,
+ const char *psz_access_mode);
+
+ /*! Set up CD-ROM for reading using the AIX driver. The device_name is
+ the some sort of device name.
+
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no AIX driver.
+
+ @see cdio_open
+ */
+ CdIo_t * cdio_open_aix (const char *psz_source);
+
+ /*! Return a string containing the default device name that the
+ AIX driver would use when none is specified.
+
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no AIX driver.
+
+ @see cdio_open_cd, cdio_open
+ */
+ char * cdio_get_default_device_aix(void);
+
+ /*! Return a list of all of the CD-ROM devices that the AIX driver
+ can find.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+ */
+ char **cdio_get_devices_aix(void);
+
+ /*! Set up CD-ROM for reading using the BSDI driver. The device_name is
+ the some sort of device name.
+
+ @param psz_source the name of the device to open
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no BSDI driver.
+
+ @see cdio_open
+ */
+ CdIo_t * cdio_open_bsdi (const char *psz_source);
+
+ /*! Set up CD-ROM for reading using the BSDI driver. The device_name is
+ the some sort of device name.
+
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no BSDI driver.
+
+ @see cdio_open
+ */
+ CdIo_t * cdio_open_am_bsdi (const char *psz_source,
+ const char *psz_access_mode);
+
+ /*! Return a string containing the default device name that the
+ BSDI driver would use when none is specified.
+
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no BSDI driver.
+
+ @see cdio_open_cd, cdio_open
+ */
+ char * cdio_get_default_device_bsdi(void);
+
+ /*! Return a list of all of the CD-ROM devices that the BSDI driver
+ can find.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+ */
+ char **cdio_get_devices_bsdi(void);
+
+ /*! Set up CD-ROM for reading using the FreeBSD driver. The device_name is
+ the some sort of device name.
+
+ NULL is returned on error or there is no FreeBSD driver.
+
+ @see cdio_open_cd, cdio_open
+ */
+ CdIo_t * cdio_open_freebsd (const char *paz_psz_source);
+
+ /*! Set up CD-ROM for reading using the FreeBSD driver. The device_name is
+ the some sort of device name.
+
+ NULL is returned on error or there is no FreeBSD driver.
+
+ @see cdio_open_cd, cdio_open
+ */
+ CdIo_t * cdio_open_am_freebsd (const char *psz_source,
+ const char *psz_access_mode);
+
+ /*! Return a string containing the default device name that the
+ FreeBSD driver would use when none is specified.
+
+ NULL is returned on error or there is no CD-ROM device.
+ */
+ char * cdio_get_default_device_freebsd(void);
+
+ /*! Return a list of all of the CD-ROM devices that the FreeBSD driver
+ can find.
+ */
+ char **cdio_get_devices_freebsd(void);
+
+ /*! Set up CD-ROM for reading using the GNU/Linux driver. The device_name is
+ the some sort of device name.
+
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no GNU/Linux driver.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+ */
+ CdIo_t * cdio_open_linux (const char *psz_source);
+
+ /*! Set up CD-ROM for reading using the GNU/Linux driver. The
+ device_name is the some sort of device name.
+
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no GNU/Linux driver.
+ */
+ CdIo_t * cdio_open_am_linux (const char *psz_source,
+ const char *access_mode);
+
+ /*! Return a string containing the default device name that the
+ GNU/Linux driver would use when none is specified. A scan is made
+ for CD-ROM drives with CDs in them.
+
+ NULL is returned on error or there is no CD-ROM device.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+
+ @see cdio_open_cd, cdio_open
+ */
+ char * cdio_get_default_device_linux(void);
+
+ /*! Return a list of all of the CD-ROM devices that the GNU/Linux driver
+ can find.
+ */
+ char **cdio_get_devices_linux(void);
+
+ /*! Set up CD-ROM for reading using the Sun Solaris driver. The
+ device_name is the some sort of device name.
+
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no Solaris driver.
+ */
+ CdIo_t * cdio_open_solaris (const char *psz_source);
+
+ /*! Set up CD-ROM for reading using the Sun Solaris driver. The
+ device_name is the some sort of device name.
+
+ @return the cdio object for subsequent operations.
+ NULL on error or there is no Solaris driver.
+ */
+ CdIo_t * cdio_open_am_solaris (const char *psz_source,
+ const char *psz_access_mode);
+
+ /*! Return a string containing the default device name that the
+ Solaris driver would use when none is specified. A scan is made
+ for CD-ROM drives with CDs in them.
+
+ NULL is returned on error or there is no CD-ROM device.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+
+ @see cdio_open_cd, cdio_open
+ */
+ char * cdio_get_default_device_solaris(void);
+
+ /*! Return a list of all of the CD-ROM devices that the Solaris driver
+ can find.
+ */
+ char **cdio_get_devices_solaris(void);
+
+ /*! Set up CD-ROM for reading using the Apple OSX driver. The
+ device_name is the some sort of device name.
+
+ NULL is returned on error or there is no OSX driver.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+
+ @see cdio_open_cd, cdio_open
+ */
+ CdIo_t * cdio_open_osx (const char *psz_source);
+
+ /*! Set up CD-ROM for reading using the Apple OSX driver. The
+ device_name is the some sort of device name.
+
+ NULL is returned on error or there is no OSX driver.
+
+ @see cdio_open_cd, cdio_open
+ */
+ CdIo_t * cdio_open_am_osx (const char *psz_source,
+ const char *psz_access_mode);
+
+ /*! Return a string containing the default device name that the
+ OSX driver would use when none is specified. A scan is made
+ for CD-ROM drives with CDs in them.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+ */
+ char * cdio_get_default_device_osx(void);
+
+ /*! Return a list of all of the CD-ROM devices that the OSX driver
+ can find.
+ */
+ char **cdio_get_devices_osx(void);
+
+ /*! Set up CD-ROM for reading using the Microsoft Windows driver. The
+ device_name is the some sort of device name.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+ */
+ CdIo_t * cdio_open_win32 (const char *psz_source);
+
+ /*! Set up CD-ROM for reading using the Microsoft Windows driver. The
+ device_name is the some sort of device name.
+
+ NULL is returned on error or there is no Microsof Windows driver.
+ */
+ CdIo_t * cdio_open_am_win32 (const char *psz_source,
+ const char *psz_access_mode);
+
+ /*! Return a string containing the default device name that the
+ Win32 driver would use when none is specified. A scan is made
+ for CD-ROM drives with CDs in them.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+
+ @see cdio_open_cd, cdio_open
+ */
+ char * cdio_get_default_device_win32(void);
+
+ char **cdio_get_devices_win32(void);
+
+ /*! Set up CD-ROM for reading using the IBM OS/2 driver. The
+ device_name is the some sort of device name.
+
+ NULL is returned on error or there is no OS/2 driver.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+
+ @see cdio_open_cd, cdio_open
+ */
+ CdIo_t * cdio_open_os2 (const char *psz_source);
+
+ /*! Set up CD-ROM for reading using the IBM OS/2 driver. The
+ device_name is the some sort of device name.
+
+ NULL is returned on error or there is no OS/2 driver.
+
+ @see cdio_open_cd, cdio_open
+ */
+ CdIo_t * cdio_open_am_os2 (const char *psz_source,
+ const char *psz_access_mode);
+
+ /*! Return a string containing the default device name that the
+ OS/2 driver would use when none is specified. A scan is made
+ for CD-ROM drives with CDs in them.
+
+ In some situations of drivers or OS's we can't find a CD device if
+ there is no media in it and it is possible for this routine to return
+ NULL even though there may be a hardware CD-ROM.
+ */
+ char * cdio_get_default_device_os2(void);
+
+ /*! Return a list of all of the CD-ROM devices that the OS/2 driver
+ can find.
+ */
+ char **cdio_get_devices_os2(void);
+
+ /*! Set up CD-ROM for reading using the Nero driver. The
+ device_name is the some sort of device name.
+
+ @return true on success; NULL on error or there is no Nero driver.
+ */
+ CdIo_t * cdio_open_nrg (const char *psz_source);
+
+ /*! Set up CD-ROM for reading using the Nero driver. The
+ device_name is the some sort of device name.
+
+ @return true on success; NULL on error or there is no Nero driver.
+ */
+ CdIo_t * cdio_open_am_nrg (const char *psz_source,
+ const char *psz_access_mode);
+
+ /*! Get a string containing the default device name that the NRG
+ driver would use when none is specified. A scan is made for NRG
+ disk images in the current directory.
+
+ @return string containing the default device. NULL on error or
+ there is no CD-ROM device.
+ */
+ char * cdio_get_default_device_nrg(void);
+
+ char **cdio_get_devices_nrg(void);
+
+ /*!
+
+ Determine if bin_name is the bin file part of a CDRWIN CD disk image.
+
+ @param bin_name location of presumed CDRWIN bin image file.
+ @return the corresponding CUE file if bin_name is a BIN file or
+ NULL if not a BIN file.
+ */
+ char *cdio_is_binfile(const char *bin_name);
+
+ /*!
+ Determine if cue_name is the cue sheet for a CDRWIN CD disk image.
+
+ @return corresponding BIN file if cue_name is a CDRWIN cue file or
+ NULL if not a CUE file.
+ */
+ char *cdio_is_cuefile(const char *cue_name);
+
+ /*!
+ Determine if psg_nrg is a Nero CD disc image.
+
+ @param psz_nrg location of presumed NRG image file.
+ @return true if psz_nrg is a Nero NRG image or false
+ if not a NRG image.
+ */
+ bool cdio_is_nrg(const char *psz_nrg);
+
+ /*!
+ Determine if psz_toc is a TOC file for a cdrdao CD disc image.
+
+ @param psz_toc location of presumed TOC image file.
+ @return true if toc_name is a cdrdao TOC file or false
+ if not a TOC file.
+ */
+ bool cdio_is_tocfile(const char *psz_toc);
+
+ /*!
+ Determine if psz_source refers to a real hardware CD-ROM.
+
+ @param psz_source location name of object
+ @param driver_id driver for reading object. Use DRIVER_UNKNOWN if you
+ don't know what driver to use.
+ @return true if psz_source is a device; If false is returned we
+ could have a CD disk image.
+ */
+ bool cdio_is_device(const char *psz_source, driver_id_t driver_id);
+
+ /*!
+ Set the blocksize for subsequent reads.
+ */
+ driver_return_code_t cdio_set_blocksize ( const CdIo_t *p_cdio,
+ int i_blocksize );
+
+ /*!
+ Set the drive speed.
+
+ @param p_cdio CD structure set by cdio_open().
+ @param i_drive_speed speed in CD-ROM speed units. Note this
+ not Kbs as would be used in the MMC spec or
+ in mmc_set_speed(). To convert CD-ROM speed units
+ to Kbs, multiply the number by 176 (for raw data)
+ and by 150 (for filesystem data). On many CD-ROM
+ drives, specifying a value too large will result
+ in using the fastest speed.
+
+ @see mmc_set_speed and mmc_set_drive_speed
+ */
+ driver_return_code_t cdio_set_speed ( const CdIo_t *p_cdio,
+ int i_drive_speed );
+
+ /*!
+ Get the value associatied with key.
+
+ @param p_cdio the CD object queried
+ @param key the key to retrieve
+ @return the value associatd with "key" or NULL if p_cdio is NULL
+ or "key" does not exist.
+ */
+ const char * cdio_get_arg (const CdIo_t *p_cdio, const char key[]);
+
+ /*!
+ Set the arg "key" with "value" in "p_cdio".
+
+ @param p_cdio the CD object to set
+ @param key the key to set
+ @param value the value to assocaiate with key
+ */
+ driver_return_code_t cdio_set_arg (CdIo_t *p_cdio, const char key[],
+ const char value[]);
+
+ /*!
+ Initialize CD Reading and control routines. Should be called first.
+ */
+ bool cdio_init(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/** The below variables are trickery to force the above enum symbol
+ values to be recorded in debug symbol tables. They are used to
+ allow one to refer to the enumeration value names in the typedefs
+ above in a debugger and debugger expressions.
+*/
+extern cdio_drive_cap_misc_t debug_cdio_drive_cap_misc;
+extern cdio_drive_cap_read_t debug_cdio_drive_cap_read_t;
+extern cdio_drive_cap_write_t debug_drive_cap_write_t;
+extern cdio_mmc_hw_len_t debug_cdio_mmc_hw_len;
+extern cdio_src_category_mask_t debug_cdio_src_category_mask;
+
+#endif /* __CDIO_DEVICE_H__ */
diff --git a/include/cdio/disc.h b/include/cdio/disc.h
new file mode 100644
index 00000000..b5ae3c49
--- /dev/null
+++ b/include/cdio/disc.h
@@ -0,0 +1,108 @@
+/* -*- c -*-
+ $Id: disc.h,v 1.9 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file disc.h
+ * \brief The top-level header for disc-related libcdio calls.
+ */
+#ifndef __CDIO_DISC_H__
+#define __CDIO_DISC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /*! disc modes. The first combined from MMC-3 5.29.2.8 (Send CUESHEET)
+ and GNU/Linux /usr/include/linux/cdrom.h and we've added DVD.
+ */
+ typedef enum {
+ CDIO_DISC_MODE_CD_DA, /**< CD-DA */
+ CDIO_DISC_MODE_CD_DATA, /**< CD-ROM form 1 */
+ CDIO_DISC_MODE_CD_XA, /**< CD-ROM XA form2 */
+ CDIO_DISC_MODE_CD_MIXED, /**< Some combo of above. */
+ CDIO_DISC_MODE_DVD_ROM, /**< DVD ROM (e.g. movies) */
+ CDIO_DISC_MODE_DVD_RAM, /**< DVD-RAM */
+ CDIO_DISC_MODE_DVD_R, /**< DVD-R */
+ CDIO_DISC_MODE_DVD_RW, /**< DVD-RW */
+ CDIO_DISC_MODE_DVD_PR, /**< DVD+R */
+ CDIO_DISC_MODE_DVD_PRW, /**< DVD+RW */
+ CDIO_DISC_MODE_DVD_OTHER, /**< Unknown/unclassified DVD type */
+ CDIO_DISC_MODE_NO_INFO,
+ CDIO_DISC_MODE_ERROR,
+ CDIO_DISC_MODE_CD_I /**< CD-i. */
+ } discmode_t;
+
+ extern const char *discmode2str[];
+
+ /*!
+ Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc.
+ that we've got. The notion of "CD" is extended a little to include
+ DVD's.
+ */
+ discmode_t cdio_get_discmode (CdIo_t *p_cdio);
+
+ /*!
+ Get the lsn of the end of the CD
+
+ @return the lsn. On error 0 or CDIO_INVALD_LSN.
+ */
+ lsn_t cdio_get_disc_last_lsn(const CdIo_t *p_cdio);
+
+ /*!
+ Return the Joliet level recognized for p_cdio.
+ */
+ uint8_t cdio_get_joliet_level(const CdIo_t *p_cdio);
+
+ /*!
+ Get the media catalog number (MCN) from the CD.
+
+ @return the media catalog number or NULL if there is none or we
+ don't have the ability to get it.
+
+ Note: string is malloc'd so caller has to free() the returned
+ string when done with it.
+
+ */
+ char * cdio_get_mcn (const CdIo_t *p_cdio);
+
+ /*!
+ Get the number of tracks on the CD.
+
+ @return the number of tracks, or CDIO_INVALID_TRACK if there is
+ an error.
+ */
+ track_t cdio_get_num_tracks (const CdIo_t *p_cdio);
+
+ /*!
+ Return true if discmode is some sort of CD.
+ */
+ bool cdio_is_discmode_cdrom (discmode_t discmode);
+
+ /*!
+ Return true if discmode is some sort of DVD.
+ */
+ bool cdio_is_discmode_dvd (discmode_t discmode);
+
+ /*! cdio_stat_size is deprecated. @see cdio_get_disc_last_lsn */
+#define cdio_stat_size cdio_get_disc_last_lsn
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CDIO_DISC_H__ */
diff --git a/include/cdio/ds.h b/include/cdio/ds.h
new file mode 100644
index 00000000..447e30df
--- /dev/null
+++ b/include/cdio/ds.h
@@ -0,0 +1,98 @@
+/*
+ $Id: ds.h,v 1.5 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2005, 2008 Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 2000, 2004 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file ds.h
+ * \brief The top-level header for list-related data structures.
+
+ Note: this header will is slated to get removed and libcdio will use
+ glib.h routines instead.
+*/
+
+
+#ifndef __CDIO_DS_H__
+#define __CDIO_DS_H__
+
+#include <cdio/types.h>
+
+/** opaque types... */
+typedef struct _CdioList CdioList_t;
+typedef struct _CdioListNode CdioListNode_t;
+
+typedef int (*_cdio_list_cmp_func_t) (void *p_data1, void *p_data2);
+typedef int (*_cdio_list_iterfunc_t) (void *p_data, void *p_user_data);
+
+/** The below are given compatibility with old code. Please use
+ the above type names, not these. */
+#define CdioList CdioList_t
+#define CdioListNode CdioListNode_t
+#define _cdio_list_cmp_func _cdio_list_cmp_func_t
+#define _cdio_list_iterfunc _cdio_list_iterfunc_t
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** methods */
+CdioList_t *_cdio_list_new (void);
+
+void _cdio_list_free (CdioList_t *p_list, int free_data);
+
+unsigned _cdio_list_length (const CdioList_t *list);
+
+void _cdio_list_prepend (CdioList_t *p_list, void *p_data);
+
+void _cdio_list_append (CdioList_t *p_list, void *p_data);
+
+void _cdio_list_foreach (CdioList_t *p_list, _cdio_list_iterfunc_t func,
+ void *p_user_data);
+
+CdioListNode_t *_cdio_list_find (CdioList_t *p_list,
+ _cdio_list_iterfunc_t cmp_func,
+ void *p_user_data);
+
+#define _CDIO_LIST_FOREACH(node, list) \
+ for (node = _cdio_list_begin (list); node; node = _cdio_list_node_next (node))
+
+/** node operations */
+
+CdioListNode_t *_cdio_list_begin (const CdioList_t *p_list);
+
+CdioListNode_t *_cdio_list_end (CdioList_t *p_list);
+
+CdioListNode_t *_cdio_list_node_next (CdioListNode_t *p_node);
+
+void _cdio_list_node_free (CdioListNode_t *p_node, int i_free_data);
+
+void *_cdio_list_node_data (CdioListNode_t *p_node);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CDIO_DS_H__ */
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
+
diff --git a/include/cdio/dvd.h b/include/cdio/dvd.h
new file mode 100644
index 00000000..8be8317b
--- /dev/null
+++ b/include/cdio/dvd.h
@@ -0,0 +1,112 @@
+/*
+ $Id: dvd.h,v 1.5 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2004 Rocky Bernstein <rocky@gnu.org>
+ Modeled after GNU/Linux definitions in linux/cdrom.h
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/*!
+ \file dvd.h
+ \brief Definitions for DVD access.
+*/
+
+#ifndef __CDIO_DVD_H__
+#define __CDIO_DVD_H__
+
+#include <cdio/types.h>
+
+/*! Values used in a READ DVD STRUCTURE */
+
+#define CDIO_DVD_STRUCT_PHYSICAL 0x00
+#define CDIO_DVD_STRUCT_COPYRIGHT 0x01
+#define CDIO_DVD_STRUCT_DISCKEY 0x02
+#define CDIO_DVD_STRUCT_BCA 0x03
+#define CDIO_DVD_STRUCT_MANUFACT 0x04
+
+/*! Media definitions for "Book Type" */
+#define CDIO_DVD_BOOK_DVD_ROM 0
+#define CDIO_DVD_BOOK_DVD_RAM 1
+#define CDIO_DVD_BOOK_DVD_R 2 /**< DVD-R */
+#define CDIO_DVD_BOOK_DVD_RW 3 /**< DVD-RW */
+#define CDIO_DVD_BOOK_DVD_PR 8 /**< DVD+R */
+#define CDIO_DVD_BOOK_DVD_PRW 9 /**< DVD+RW */
+
+typedef struct cdio_dvd_layer {
+ uint8_t book_version : 4;
+ uint8_t book_type : 4;
+ uint8_t min_rate : 4;
+ uint8_t disc_size : 4;
+ uint8_t layer_type : 4;
+ uint8_t track_path : 1;
+ uint8_t nlayers : 2;
+ uint8_t track_density : 4;
+ uint8_t linear_density: 4;
+ uint8_t bca : 1;
+ uint32_t start_sector;
+ uint32_t end_sector;
+ uint32_t end_sector_l0;
+} cdio_dvd_layer_t;
+
+/*! Maximum number of layers in a DVD. */
+#define CDIO_DVD_MAX_LAYERS 4
+
+typedef struct cdio_dvd_physical {
+ uint8_t type;
+ uint8_t layer_num;
+ cdio_dvd_layer_t layer[CDIO_DVD_MAX_LAYERS];
+} cdio_dvd_physical_t;
+
+typedef struct cdio_dvd_copyright {
+ uint8_t type;
+
+ uint8_t layer_num;
+ uint8_t cpst;
+ uint8_t rmi;
+} cdio_dvd_copyright_t;
+
+typedef struct cdio_dvd_disckey {
+ uint8_t type;
+
+ unsigned agid : 2;
+ uint8_t value[2048];
+} cdio_dvd_disckey_t;
+
+typedef struct cdio_dvd_bca {
+ uint8_t type;
+
+ int len;
+ uint8_t value[188];
+} cdio_dvd_bca_t;
+
+typedef struct cdio_dvd_manufact {
+ uint8_t type;
+
+ uint8_t layer_num;
+ int len;
+ uint8_t value[2048];
+} cdio_dvd_manufact_t;
+
+typedef union {
+ uint8_t type;
+
+ cdio_dvd_physical_t physical;
+ cdio_dvd_copyright_t copyright;
+ cdio_dvd_disckey_t disckey;
+ cdio_dvd_bca_t bca;
+ cdio_dvd_manufact_t manufact;
+} cdio_dvd_struct_t;
+
+#endif /* __SCSI_MMC_H__ */
diff --git a/include/cdio/ecma_167.h b/include/cdio/ecma_167.h
new file mode 100644
index 00000000..78da7ae0
--- /dev/null
+++ b/include/cdio/ecma_167.h
@@ -0,0 +1,1006 @@
+/*
+ Copyright (c) 2005, 2006, 2008 Rocky Bernstein <rocky@cpan.org>
+ Copyright (c) 2001-2002 Ben Fennema <bfennema@falcon.csc.calpoly.edu>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * Some portions taken from FreeBSD ecma167-udf.h which states:
+ * Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*!
+ * \file ecma_167.h
+ *
+ * \brief Definitions based on ECMA-167 3rd edition (June 1997)
+ * See http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-167.pdf
+*/
+
+#ifndef _ECMA_167_H
+#define _ECMA_167_H 1
+
+#include <cdio/types.h>
+
+/**
+ Imagine the below enum values as \#define'd values rather than
+ distinct values of an enum.
+*/
+typedef enum {
+ VSD_STD_ID_SIZE = 5, /** Volume Structure Descriptor (ECMA 167r3
+ 2/9.1) */
+ UDF_REGID_ID_SIZE = 23, /**< See identifier (ECMA 167r3 1/7.4) */
+ UDF_VOLID_SIZE = 32,
+ UDF_FID_SIZE = 38,
+ UDF_VOLSET_ID_SIZE = 128
+} ecma_167_enum1_t ;
+
+/** Tag Identifier (ECMA 167r3 3/7.2.1) */
+
+typedef enum {
+ TAGID_PRI_VOL = 0x0001,
+ TAGID_ANCHOR = 0x0002,
+ TAGID_VOL = 0x0003,
+ TAGID_IMP_VOL = 0x0004,
+ TAGID_PARTITION = 0x0005,
+ TAGID_LOGVOL = 0x0006,
+ TAGID_UNALLOC_SPACE = 0x0007,
+ TAGID_TERM = 0x0008,
+ TAGID_LOGVOL_INTEGRITY = 0x0009,
+ TAGID_FSD = 0x0100,
+ TAGID_FID = 0x0101,
+ TAGID_AED = 0x0102,
+ TAGID_IE = 0x0103,
+ TAGID_TE = 0x0104,
+ TAGID_FILE_ENTRY = 0x0105,
+ TAGID_EAHD = 0x0106,
+ TAGID_USE = 0x0107,
+ TAGID_SBD = 0x0108,
+ TAGID_PIE = 0x0109,
+ TAGID_EFE = 0x010A,
+} tag_id_t ;
+
+/** Character Set Type (ECMA 167r3 1/7.2.1.1) */
+typedef enum {
+ CHARSPEC_TYPE_CS0 = 0x00, /**< Section 1/7.2.2 */
+ CHARSPEC_TYPE_CS1 = 0x01, /**< Section 1/7.2.3 */
+ CHARSPEC_TYPE_CS2 = 0x02, /**< Section 1/7.2.4 */
+ CHARSPEC_TYPE_CS3 = 0x03, /**< Section 1/7.2.5 */
+ CHARSPEC_TYPE_CS4 = 0x04, /**< Section 1/7.2.6 */
+ CHARSPEC_TYPE_CS5 = 0x05, /**< Section 1/7.2.7 */
+ CHARSPEC_TYPE_CS6 = 0x06, /**< Section 1/7.2.8 */
+ CHARSPEC_TYPE_CS7 = 0x07, /**< Section 1/7.2.9 */
+
+ CHARSPEC_TYPE_CS8 = 0x08, /**< Section 1/7.2.10 */
+} udf_charspec_enum_t;
+
+typedef uint8_t udf_Uint8_t; /*! Section 1/7/1.1 */
+typedef uint16_t udf_Uint16_t; /*! Section 1/7.1.3 */
+typedef uint32_t udf_Uint32_t; /*! Section 1/7.1.5 */
+typedef uint64_t udf_Uint64_t; /*! Section 1/7.1.7 */
+typedef char udf_dstring; /*! Section 1/7.1.12 */
+
+#define UDF_LENGTH_MASK 0x3fffffff
+
+PRAGMA_BEGIN_PACKED
+
+/** Character set specification (ECMA 167r3 1/7.2.1) */
+struct udf_charspec_s
+{
+ udf_Uint8_t charset_type;
+ udf_Uint8_t charset_info[63];
+} GNUC_PACKED;
+
+typedef struct udf_charspec_s udf_charspec_t;
+
+/** Timestamp (ECMA 167r3 1/7.3) */
+struct udf_timestamp_s
+{
+ udf_Uint16_t type_tz;
+ udf_Uint16_t year;
+ udf_Uint8_t month;
+ udf_Uint8_t day;
+ udf_Uint8_t hour;
+ udf_Uint8_t minute;
+ udf_Uint8_t second;
+ udf_Uint8_t centiseconds;
+ udf_Uint8_t hundreds_of_microseconds;
+ udf_Uint8_t microseconds;
+} GNUC_PACKED;
+
+typedef struct udf_timestamp_s udf_timestamp_t;
+
+/** Type and Time Zone (ECMA 167r3 1/7.3.1)
+
+ Imagine the below enum values as \#define'd values rather than
+ distinct values of an enum.
+*/
+typedef enum {
+ TIMESTAMP_TYPE_CUT = 0x0000,
+ TIMESTAMP_TYPE_LOCAL = 0x1000,
+ TIMESTAMP_TYPE_AGREEMENT = 0x2000,
+ TIMESTAMP_TYPE_MASK = 0xF000,
+ TIMESTAMP_TIMEZONE_MASK = 0x0FFF,
+} ecma_167_timezone_enum_t ;
+
+
+#define TIMESTAMP_TYPE_MASK 0xF000
+#define TIMESTAMP_TYPE_CUT 0x0000
+#define TIMESTAMP_TYPE_LOCAL 0x1000
+#define TIMESTAMP_TYPE_AGREEMENT 0x2000
+#define TIMESTAMP_TIMEZONE_MASK 0x0FFF
+
+struct udf_id_suffix_s
+{
+ udf_Uint16_t udf_revision;
+ udf_Uint8_t os_class;
+ udf_Uint8_t os_identifier;
+ udf_Uint8_t reserved[4];
+} GNUC_PACKED;
+
+typedef struct udf_id_suffix_s udf_id_suffix_t;
+
+/** Entity identifier (ECMA 167r3 1/7.4) */
+struct udf_regid_s
+{
+ udf_Uint8_t flags;
+ udf_Uint8_t id[UDF_REGID_ID_SIZE];
+ udf_id_suffix_t id_suffix;
+} GNUC_PACKED;
+
+typedef struct udf_regid_s udf_regid_t;
+
+/** Flags (ECMA 167r3 1/7.4.1) */
+#define ENTITYID_FLAGS_DIRTY 0x00
+#define ENTITYID_FLAGS_PROTECTED 0x01
+
+/** Volume Structure Descriptor (ECMA 167r3 2/9.1) */
+struct vol_struct_desc_s
+{
+ udf_Uint8_t struct_type;
+ udf_Uint8_t std_id[VSD_STD_ID_SIZE];
+ udf_Uint8_t struct_version;
+ udf_Uint8_t struct_data[2041];
+} GNUC_PACKED;
+
+/** Standard Identifier (EMCA 167r2 2/9.1.2) */
+#define VSD_STD_ID_NSR02 "NSR02" /* (3/9.1) */
+
+/** Standard Identifier (ECMA 167r3 2/9.1.2) */
+
+/* The below const definitions are to faciltate debugging of the
+ values #define'd below. */
+extern const char VSD_STD_ID_BEA01[sizeof("BEA01")-1];
+extern const char VSD_STD_ID_BOOT2[sizeof("BOOT2")-1];
+extern const char VSD_STD_ID_CD001[sizeof("CD001")-1];
+extern const char VSD_STD_ID_CDW01[sizeof("CDW02")-1];
+extern const char VSD_STD_ID_NSR03[sizeof("NSR03")-1];
+extern const char VSD_STD_ID_TEA01[sizeof("TEA01")-1];
+
+#define VSD_STD_ID_BEA01 "BEA01" /**< ECMA-167 2/9.2 */
+#define VSD_STD_ID_BOOT2 "BOOT2" /**< ECMA-167 2/9.4 */
+#define VSD_STD_ID_CD001 "CD001" /**< ECMA-119 */
+#define VSD_STD_ID_CDW02 "CDW02" /**< ECMA-168 */
+#define VSD_STD_ID_NSR02 "NSR02" /**< ECMA-167, 3/9.1
+ NOTE: ECMA-167, 2nd edition */
+#define VSD_STD_ID_NSR03 "NSR03" /**< ECMA-167 3/9.1 */
+#define VSD_STD_ID_TEA01 "TEA01" /**< ECMA-168 2/9.3 */
+
+/** Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */
+struct beginning_extended_area_desc_s
+{
+ udf_Uint8_t struct_type;
+ udf_Uint8_t std_id[VSD_STD_ID_SIZE];
+ udf_Uint8_t struct_version;
+ udf_Uint8_t struct_data[2041];
+} GNUC_PACKED;
+
+/** Terminating Extended Area Descriptor (ECMA 167r3 2/9.3) */
+struct terminating_extended_area_desc_s
+{
+ udf_Uint8_t struct_type;
+ udf_Uint8_t std_id[VSD_STD_ID_SIZE];
+ udf_Uint8_t struct_version;
+ udf_Uint8_t struct_data[2041];
+} GNUC_PACKED;
+
+/** Boot Descriptor (ECMA 167r3 2/9.4) */
+struct boot_desc_s
+{
+ udf_Uint8_t struct_type;
+ udf_Uint8_t std_ident[VSD_STD_ID_SIZE];
+ udf_Uint8_t struct_version;
+ udf_Uint8_t reserved1;
+ udf_regid_t arch_type;
+ udf_regid_t boot_ident;
+ udf_Uint32_t bool_ext_location;
+ udf_Uint32_t bool_ext_length;
+ udf_Uint64_t load_address;
+ udf_Uint64_t start_address;
+ udf_timestamp_t desc_creation_time;
+ udf_Uint16_t flags;
+ udf_Uint8_t reserved2[32];
+ udf_Uint8_t boot_use[1906];
+} GNUC_PACKED;
+
+/** Flags (ECMA 167r3 2/9.4.12) */
+#define BOOT_FLAGS_ERASE 0x01
+
+/** Extent Descriptor (ECMA 167r3 3/7.1) */
+struct udf_extent_ad_s
+{
+ udf_Uint32_t len;
+ udf_Uint32_t loc;
+} GNUC_PACKED;
+
+typedef struct udf_extent_ad_s udf_extent_ad_t;
+
+/** Descriptor Tag (ECMA 167r3 3/7.2) */
+struct udf_tag_s
+{
+ udf_Uint16_t id;
+ udf_Uint16_t desc_version;
+ udf_Uint8_t cksum;
+ udf_Uint8_t reserved;
+ udf_Uint16_t i_serial;
+ udf_Uint16_t desc_CRC;
+ udf_Uint16_t desc_CRC_len;
+ udf_Uint32_t loc;
+} GNUC_PACKED;
+
+typedef struct udf_tag_s udf_tag_t;
+
+/** NSR Descriptor (ECMA 167r3 3/9.1) */
+struct NSR_desc_s
+{
+ udf_Uint8_t struct_type;
+ udf_Uint8_t std_id[VSD_STD_ID_SIZE];
+ udf_Uint8_t struct_version;
+ udf_Uint8_t reserved;
+ udf_Uint8_t struct_data[2040];
+} GNUC_PACKED;
+
+/** Primary Volume Descriptor (ECMA 167r3 3/10.1) */
+struct udf_pvd_s
+{
+ udf_tag_t tag;
+ udf_Uint32_t vol_desc_seq_num;
+ udf_Uint32_t primary_vol_desc_num;
+ udf_dstring vol_ident[UDF_VOLID_SIZE];
+ udf_Uint16_t vol_seq_num;
+ udf_Uint16_t max_vol_seqnum;
+ udf_Uint16_t interchange_lvl;
+ udf_Uint16_t max_interchange_lvl;
+ udf_Uint32_t charset_list;
+ udf_Uint32_t max_charset_list;
+ udf_dstring volset_id[UDF_VOLSET_ID_SIZE];
+ udf_charspec_t desc_charset;
+ udf_charspec_t explanatory_charset;
+ udf_extent_ad_t vol_abstract;
+ udf_extent_ad_t vol_copyright;
+ udf_regid_t app_ident;
+ udf_timestamp_t recording_time;
+ udf_regid_t imp_ident;
+ udf_Uint8_t imp_use[64];
+ udf_Uint32_t predecessor_vol_desc_seq_location;
+ udf_Uint16_t flags;
+ udf_Uint8_t reserved[22];
+} GNUC_PACKED;
+
+typedef struct udf_pvd_s udf_pvd_t;
+
+/** Flags (ECMA 167r3 3/10.1.21) */
+#define PVD_FLAGS_VSID_COMMON 0x0001
+
+/** Anchor Volume Descriptor Pointer (ECMA 167r3 3/10.2) */
+struct anchor_vol_desc_ptr_s
+{
+ udf_tag_t tag;
+ udf_extent_ad_t main_vol_desc_seq_ext;
+ udf_extent_ad_t reserve_vol_desc_seq_ext;
+ udf_Uint8_t reserved[480];
+} GNUC_PACKED;
+
+typedef struct anchor_vol_desc_ptr_s anchor_vol_desc_ptr_t;
+
+/** Volume Descriptor Pointer (ECMA 167r3 3/10.3) */
+struct vol_desc_ptr_s
+{
+ udf_tag_t tag;
+ udf_Uint32_t vol_desc_seq_num;
+ udf_extent_ad_t next_vol_desc_set_ext;
+ udf_Uint8_t reserved[484];
+} GNUC_PACKED;
+
+/** Implementation Use Volume Descriptor (ECMA 167r3 3/10.4) */
+struct imp_use_vol_desc_s
+{
+ udf_tag_t tag;
+ udf_Uint32_t vol_desc_seq_num;
+ udf_regid_t imp_id;
+ udf_Uint8_t imp_use[460];
+} GNUC_PACKED;
+
+/** Partition Descriptor (ECMA 167r3 3/10.5) */
+struct partition_desc_s
+{
+ udf_tag_t tag;
+ udf_Uint32_t vol_desc_seq_num;
+ udf_Uint16_t flags;
+ udf_Uint16_t number; /**< Partition number */
+ udf_regid_t contents;
+ udf_Uint8_t contents_use[128];
+ udf_Uint32_t access_type;
+ udf_Uint32_t start_loc;
+ udf_Uint32_t part_len;
+ udf_regid_t imp_id;
+ udf_Uint8_t imp_use[128];
+ udf_Uint8_t reserved[156];
+} GNUC_PACKED;
+
+typedef struct partition_desc_s partition_desc_t;
+
+/** Partition Flags (ECMA 167r3 3/10.5.3) */
+#define PD_PARTITION_FLAGS_ALLOC 0x0001
+
+/** Partition Contents (ECMA 167r2 3/10.5.3) */
+#define PD_PARTITION_CONTENTS_NSR02 "+NSR02"
+
+/** Partition Contents (ECMA 167r3 3/10.5.5) */
+#define PD_PARTITION_CONTENTS_FDC01 "+FDC01"
+#define PD_PARTITION_CONTENTS_CD001 "+CD001"
+#define PD_PARTITION_CONTENTS_CDW02 "+CDW02"
+#define PD_PARTITION_CONTENTS_NSR03 "+NSR03"
+
+/** Access Type (ECMA 167r3 3/10.5.7) */
+#define PD_ACCESS_TYPE_NONE 0x00000000
+#define PD_ACCESS_TYPE_READ_ONLY 0x00000001
+#define PD_ACCESS_TYPE_WRITE_ONCE 0x00000002
+#define PD_ACCESS_TYPE_REWRITABLE 0x00000003
+#define PD_ACCESS_TYPE_OVERWRITABLE 0x00000004
+
+/** Recorded Address (ECMA 167r3 4/7.1) */
+struct udf_lb_addr_s
+{
+ udf_Uint32_t lba;
+ udf_Uint16_t partitionReferenceNum;
+} GNUC_PACKED;
+
+typedef struct udf_lb_addr_s udf_lb_addr_t;
+
+/** Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
+struct udf_short_ad_s
+{
+ udf_Uint32_t len;
+ udf_Uint32_t pos;
+} GNUC_PACKED;
+
+typedef struct udf_short_ad_s udf_short_ad_t;
+
+/** Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */
+struct udf_long_ad_s
+{
+ udf_Uint32_t len;
+ udf_lb_addr_t loc;
+ udf_Uint8_t imp_use[6];
+} GNUC_PACKED;
+
+typedef struct udf_long_ad_s udf_long_ad_t;
+
+/** Logical Volume Descriptor (ECMA 167r3 3/10.6) */
+struct logical_vol_desc_s
+{
+ udf_tag_t tag;
+ udf_Uint32_t seq_num;
+ udf_charspec_t desc_charset;
+ udf_dstring logvol_id[128];
+ udf_Uint32_t logical_blocksize;
+ udf_regid_t domain_id;
+ union {
+ udf_long_ad_t fsd_loc;
+ udf_Uint8_t logvol_content_use[16];
+ } lvd_use;
+ udf_Uint8_t logvol_contents_use[16];
+ udf_Uint32_t maptable_len;
+ udf_Uint32_t i_partition_maps;
+ udf_regid_t imp_id;
+ udf_Uint8_t imp_use[128];
+ udf_extent_ad_t integrity_seq_ext;
+ udf_Uint8_t partition_maps[0];
+} GNUC_PACKED;
+
+typedef struct logical_vol_desc_s logical_vol_desc_t;
+
+/** Generic Partition Map (ECMA 167r3 3/10.7.1) */
+struct generic_partition_map
+{
+ udf_Uint8_t partition_map_type;
+ udf_Uint8_t partition_map_length;
+ udf_Uint8_t partition_mapping[0];
+} GNUC_PACKED;
+
+/** Partition Map Type (ECMA 167r3 3/10.7.1.1) */
+#define GP_PARTITION_MAP_TYPE_UNDEF 0x00
+#define GP_PARTIITON_MAP_TYPE_1 0x01
+#define GP_PARTITION_MAP_TYPE_2 0x02
+
+/** Type 1 Partition Map (ECMA 167r3 3/10.7.2) */
+struct generic_partition_map1
+{
+ udf_Uint8_t partition_map_type;
+ udf_Uint8_t partition_map_length;
+ udf_Uint16_t vol_seq_num;
+ udf_Uint16_t i_partition;
+} GNUC_PACKED;
+
+/** Type 2 Partition Map (ECMA 167r3 3/10.7.3) */
+struct generic_partition_map2
+{
+ udf_Uint8_t partition_map_type;
+ udf_Uint8_t partition_map_length;
+ udf_Uint8_t partition_id[62];
+} GNUC_PACKED;
+
+/** Unallocated Space Descriptor (ECMA 167r3 3/10.8) */
+struct unalloc_space_desc_s
+{
+ udf_tag_t tag;
+ udf_Uint32_t vol_desc_seq_num;
+ udf_Uint32_t i_alloc_descs;
+ udf_extent_ad_t allocDescs[0];
+} GNUC_PACKED;
+
+/** Terminating Descriptor (ECMA 167r3 3/10.9) */
+struct terminating_desc_s
+{
+ udf_tag_t tag;
+ udf_Uint8_t reserved[496];
+} GNUC_PACKED;
+
+/** Logical Volume Integrity Descriptor (ECMA 167r3 3/10.10) */
+struct logvol_integrity_desc_s
+{
+ udf_tag_t tag;
+ udf_timestamp_t recording_time;
+ udf_Uint32_t integrity_type;
+ udf_extent_ad_t next_integrity_ext;
+ udf_Uint8_t logvol_contents_use[32];
+ udf_Uint32_t i_partitions;
+ udf_Uint32_t imp_use_len;
+ udf_Uint32_t freespace_table[0];
+ udf_Uint32_t size_table[0];
+ udf_Uint8_t imp_use[0];
+} GNUC_PACKED;
+
+/** Integrity Type (ECMA 167r3 3/10.10.3) */
+#define LVID_INTEGRITY_TYPE_OPEN 0x00000000
+#define LVID_INTEGRITY_TYPE_CLOSE 0x00000001
+
+/** Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
+struct udf_ext_ad_s
+{
+ udf_Uint32_t len;
+ udf_Uint32_t recorded_len;
+ udf_Uint32_t information_len;
+ udf_lb_addr_t ext_loc;
+} GNUC_PACKED;
+
+typedef struct udf_ext_ad_s udf_ext_ad_t;
+
+/** Descriptor Tag (ECMA 167r3 4/7.2 - See 3/7.2) */
+
+/** Tag Identifier (ECMA 167r3 4/7.2.1) */
+
+/** File Set Descriptor (ECMA 167r3 4/14.1) */
+struct udf_fsd_s
+{
+ udf_tag_t tag;
+ udf_timestamp_t recording_time;
+ udf_Uint16_t interchange_lvl;
+ udf_Uint16_t maxInterchange_lvl;
+ udf_Uint32_t charset_list;
+ udf_Uint32_t max_charset_list;
+ udf_Uint32_t fileset_num;
+ udf_Uint32_t udf_fsd_num;
+ udf_charspec_t logical_vol_id_charset;
+ udf_dstring logical_vol_id[128];
+ udf_charspec_t fileset_charset;
+ udf_dstring fileSet_id[32];
+ udf_dstring copyright_file_id[32];
+ udf_dstring abstract_file_id[32];
+ udf_long_ad_t root_icb;
+ udf_regid_t domain_id;
+ udf_long_ad_t next_ext;
+ udf_long_ad_t stream_directory_ICB;
+ udf_Uint8_t reserved[32];
+} GNUC_PACKED;
+
+typedef struct udf_fsd_s udf_fsd_t;
+
+/** Partition Header Descriptor (ECMA 167r3 4/14.3) */
+struct partition_header_desc_s
+{
+ udf_short_ad_t unalloc_space_table;
+ udf_short_ad_t unalloc_space_bitmap;
+ udf_short_ad_t partition_integrity_table;
+ udf_short_ad_t freed_space_table;
+ udf_short_ad_t freed_space_bitmap;
+ udf_Uint8_t reserved[88];
+} GNUC_PACKED;
+
+typedef struct partition_header_desc_s partition_header_desc_t;
+
+/** File Identifier Descriptor (ECMA 167r3 4/14.4) */
+struct udf_fileid_desc_s
+{
+ udf_tag_t tag;
+ udf_Uint16_t file_version_num;
+ udf_Uint8_t file_characteristics;
+ udf_Uint8_t i_file_id;
+ udf_long_ad_t icb;
+ udf_Uint16_t i_imp_use;
+ udf_Uint8_t imp_use[0];
+ udf_Uint8_t file_id[0];
+ udf_Uint8_t padding[0];
+} GNUC_PACKED;
+
+typedef struct udf_fileid_desc_s udf_fileid_desc_t;
+
+/** File Characteristics (ECMA 167r3 4/14.4.3)
+
+ Imagine the below enumeration values are \#defines to be used in a
+ bitmask rather than distinct values of an enum.
+*/
+typedef enum {
+ UDF_FILE_HIDDEN = (1 << 0),
+ UDF_FILE_DIRECTORY = (1 << 1),
+ UDF_FILE_DELETED = (1 << 2),
+ UDF_FILE_PARENT = (1 << 3),
+ UDF_FILE_METADATA = (1 << 4)
+} file_characteristics_t;
+
+/** Allocation Ext Descriptor (ECMA 167r3 4/14.5) */
+struct allocExtDesc
+{
+ udf_tag_t tag;
+ udf_Uint32_t previous_alloc_ext_loc;
+ udf_Uint32_t i_alloc_descs;
+} GNUC_PACKED;
+
+/** ICB Tag (ECMA 167r3 4/14.6) */
+struct udf_icbtag_s
+{
+ udf_Uint32_t prev_num_dirs;
+ udf_Uint16_t strat_type;
+ udf_Uint16_t strat_param;
+ udf_Uint16_t max_num_entries;
+ udf_Uint8_t reserved;
+ udf_Uint8_t file_type;
+ udf_lb_addr_t parent_ICB;
+ udf_Uint16_t flags;
+} GNUC_PACKED;
+
+typedef struct udf_icbtag_s udf_icbtag_t;
+
+#define UDF_ICB_TAG_FLAGS_SETUID 0x40
+#define UDF_ICB_TAG_FLAGS_SETGID 0x80
+#define UDF_ICB_TAG_FLAGS_STICKY 0x100
+
+/** Strategy Type (ECMA 167r3 4/14.6.2) which helpfully points
+ largely to 4/A.x */
+#define ICBTAG_STRATEGY_TYPE_UNDEF 0x0000
+#define ICBTAG_STRATEGY_TYPE_1 0x0001 /**< 4/A.2 Direct entries Uint16 */
+#define ICBTAG_STRATEGY_TYPE_2 0x0002 /**< 4/A.3 List of ICB direct entries */
+#define ICBTAG_STRATEGY_TYPE_3 0x0003 /**< 4/A.4 */
+#define ICBTAG_STRATEGY_TYPE_4 0x0004 /**< 4/A.5 Hierarchy having one
+ single ICB with one direct entry.
+ This is what's most often used.
+ */
+
+/** File Type (ECMA 167r3 4/14.6.6)
+
+ Imagine the below enum values as \#define'd values rather than
+ distinct values of an enum.
+*/
+typedef enum {
+ ICBTAG_FILE_TYPE_UNDEF = 0x00,
+ ICBTAG_FILE_TYPE_USE = 0x01,
+ ICBTAG_FILE_TYPE_PIE = 0x02,
+ ICBTAG_FILE_TYPE_IE = 0x03,
+ ICBTAG_FILE_TYPE_DIRECTORY = 0x04,
+ ICBTAG_FILE_TYPE_REGULAR = 0x05,
+ ICBTAG_FILE_TYPE_BLOCK = 0x06,
+ ICBTAG_FILE_TYPE_CHAR = 0x07,
+ ICBTAG_FILE_TYPE_EA = 0x08,
+ ICBTAG_FILE_TYPE_FIFO = 0x09,
+ ICBTAG_FILE_TYPE_SOCKET = 0x0A,
+ ICBTAG_FILE_TYPE_TE = 0x0B,
+ ICBTAG_FILE_TYPE_SYMLINK = 0x0C,
+ ICBTAG_FILE_TYPE_STREAMDIR = 0x0D
+} icbtag_file_type_enum_t;
+
+/** Flags (ECMA 167r3 4/14.6.8) */
+typedef enum {
+ ICBTAG_FLAG_AD_MASK = 0x0007, /**< "&" this to get below address
+ flags */
+ ICBTAG_FLAG_AD_SHORT = 0x0000, /**< The allocation descriptor
+ field is filled with
+ short_ad's. If the
+ offset is beyond the
+ current extent, look for
+ the next extent. */
+ ICBTAG_FLAG_AD_LONG = 0x0001, /**< The allocation descriptor
+ field is filled with
+ long_ad's If the offset
+ is beyond the current
+ extent, look for the next
+ extent. */
+ ICBTAG_FLAG_AD_EXTENDED = 0x0002,
+ ICBTAG_FLAG_AD_IN_ICB = 0x0003, /**< This type means that the
+ file *data* is stored in
+ the allocation descriptor
+ field of the file entry. */
+ ICBTAG_FLAG_SORTED = 0x0008,
+ ICBTAG_FLAG_NONRELOCATABLE = 0x0010,
+ ICBTAG_FLAG_ARCHIVE = 0x0020,
+ ICBTAG_FLAG_SETUID = 0x0040,
+ ICBTAG_FLAG_SETGID = 0x0080,
+ ICBTAG_FLAG_STICKY = 0x0100,
+ ICBTAG_FLAG_CONTIGUOUS = 0x0200,
+ ICBTAG_FLAG_SYSTEM = 0x0400,
+ ICBTAG_FLAG_TRANSFORMED = 0x0800,
+ ICBTAG_FLAG_MULTIVERSIONS = 0x1000,
+ ICBTAG_FLAG_STREAM = 0x2000
+} icbtag_flag_enum_t;
+
+/** Indirect Entry (ECMA 167r3 4/14.7) */
+struct indirect_entry_s
+{
+ udf_tag_t tag;
+ udf_icbtag_t icb_tag;
+ udf_long_ad_t indirect_ICB;
+} GNUC_PACKED;
+
+/** Terminal Entry (ECMA 167r3 4/14.8) */
+struct terminal_entry_s
+{
+ udf_tag_t tag;
+ udf_icbtag_t icb_tag;
+} GNUC_PACKED;
+
+/** File Entry (ECMA 167r3 4/14.9) */
+struct udf_file_entry_s
+{
+ udf_tag_t tag;
+ udf_icbtag_t icb_tag; /**< 4/14.9.2 */
+ udf_Uint32_t uid; /**< 4/14.9.3 */
+ udf_Uint32_t gid; /**< 4/14.9.4 */
+ udf_Uint32_t permissions; /**< 4/14.9.5 */
+ udf_Uint16_t link_count; /**< 4/14.9.6 */
+ udf_Uint8_t rec_format; /**< 4/14.9.7 */
+ udf_Uint8_t rec_disp_attr; /**< 4/14.9.8 */
+ udf_Uint32_t rec_len; /**< 4/14.9.9 */
+ udf_Uint64_t info_len; /**< 4/14.9.10 */
+ udf_Uint64_t logblks_recorded; /**< 4/14.9.11 */
+ udf_timestamp_t access_time; /**< 4/14.9.12 - last access to
+ any stream of file prior to
+ recording file entry */
+ udf_timestamp_t modification_time; /**< 4/14.9.13 - last access to
+ modification to any stream of
+ file */
+ udf_timestamp_t attribute_time;
+ udf_Uint32_t checkpoint;
+ udf_long_ad_t ext_attr_ICB;
+ udf_regid_t imp_id;
+ udf_Uint64_t unique_ID;
+ udf_Uint32_t i_extended_attr;
+ udf_Uint32_t i_alloc_descs;
+ udf_Uint8_t ext_attr[0];
+ udf_Uint8_t alloc_descs[0];
+} GNUC_PACKED;
+
+typedef struct udf_file_entry_s udf_file_entry_t;
+
+#define UDF_FENTRY_SIZE 176
+#define UDF_FENTRY_PERM_USER_MASK 0x07
+#define UDF_FENTRY_PERM_GRP_MASK 0xE0
+#define UDF_FENTRY_PERM_OWNER_MASK 0x1C00
+
+/** Permissions (ECMA 167r3 4/14.9.5) */
+#define FE_PERM_O_EXEC 0x00000001U
+#define FE_PERM_O_WRITE 0x00000002U
+#define FE_PERM_O_READ 0x00000004U
+#define FE_PERM_O_CHATTR 0x00000008U
+#define FE_PERM_O_DELETE 0x00000010U
+#define FE_PERM_G_EXEC 0x00000020U
+#define FE_PERM_G_WRITE 0x00000040U
+#define FE_PERM_G_READ 0x00000080U
+#define FE_PERM_G_CHATTR 0x00000100U
+#define FE_PERM_G_DELETE 0x00000200U
+#define FE_PERM_U_EXEC 0x00000400U
+#define FE_PERM_U_WRITE 0x00000800U
+#define FE_PERM_U_READ 0x00001000U
+#define FE_PERM_U_CHATTR 0x00002000U
+#define FE_PERM_U_DELETE 0x00004000U
+
+/** Record Format (ECMA 167r3 4/14.9.7) */
+#define FE_RECORD_FMT_UNDEF 0x00
+#define FE_RECORD_FMT_FIXED_PAD 0x01
+#define FE_RECORD_FMT_FIXED 0x02
+#define FE_RECORD_FMT_VARIABLE8 0x03
+#define FE_RECORD_FMT_VARIABLE16 0x04
+#define FE_RECORD_FMT_VARIABLE16_MSB 0x05
+#define FE_RECORD_FMT_VARIABLE32 0x06
+#define FE_RECORD_FMT_PRINT 0x07
+#define FE_RECORD_FMT_LF 0x08
+#define FE_RECORD_FMT_CR 0x09
+#define FE_RECORD_FMT_CRLF 0x0A
+#define FE_RECORD_FMT_LFCR 0x0B
+
+/** Record Display Attributes (ECMA 167r3 4/14.9.8) */
+#define FE_RECORD_DISPLAY_ATTR_UNDEF 0x00
+#define FE_RECORD_DISPLAY_ATTR_1 0x01
+#define FE_RECORD_DISPLAY_ATTR_2 0x02
+#define FE_RECORD_DISPLAY_ATTR_3 0x03
+
+/** Extended Attribute Header Descriptor (ECMA 167r3 4/14.10.1) */
+struct extended_attr_header_desc_s
+{
+ udf_tag_t tag;
+ udf_Uint32_t imp_attr_location;
+ udf_Uint32_t app_attr_location;
+} GNUC_PACKED;
+
+/** Generic Format (ECMA 167r3 4/14.10.2) */
+struct generic_format_s
+{
+ udf_Uint32_t attr_type;
+ udf_Uint8_t attr_subtype;
+ udf_Uint8_t reserved[3];
+ udf_Uint32_t attrLength;
+ udf_Uint8_t attrData[0];
+} GNUC_PACKED;
+
+/** Character Set Information (ECMA 167r3 4/14.10.3) */
+struct charSet_info_s
+{
+ udf_Uint32_t attr_type;
+ udf_Uint8_t attr_subtype;
+ udf_Uint8_t reserved[3];
+ udf_Uint32_t attrLength;
+ udf_Uint32_t escapeSeqLength;
+ udf_Uint8_t charSetType;
+ udf_Uint8_t escapeSeq[0];
+} GNUC_PACKED;
+
+/* Alternate Permissions (ECMA 167r3 4/14.10.4) */
+struct alt_perms_s
+{
+ udf_Uint32_t attr_type;
+ udf_Uint8_t attr_subtype;
+ udf_Uint8_t reserved[3];
+ udf_Uint32_t attrLength;
+ udf_Uint16_t owner_id;
+ udf_Uint16_t group_id;
+ udf_Uint16_t permission;
+} GNUC_PACKED;
+
+/** File Times Extended Attribute (ECMA 167r3 4/14.10.5) */
+struct filetimes_ext_attr_s
+{
+ udf_Uint32_t attr_type;
+ udf_Uint8_t attr_subtype;
+ udf_Uint8_t reserved[3];
+ udf_Uint32_t attrLength;
+ udf_Uint32_t dataLength;
+ udf_Uint32_t fileTimeExistence;
+ udf_Uint8_t fileTimes;
+} GNUC_PACKED;
+
+/** FileTimeExistence (ECMA 167r3 4/14.10.5.6) */
+#define FTE_CREATION 0x00000001
+#define FTE_DELETION 0x00000004
+#define FTE_EFFECTIVE 0x00000008
+#define FTE_BACKUP 0x00000002
+
+/** Information Times Extended Attribute (ECMA 167r3 4/14.10.6) */
+struct infoTimesExtAttr
+{
+ udf_Uint32_t attr_type;
+ udf_Uint8_t attr_subtype;
+ udf_Uint8_t reserved[3];
+ udf_Uint32_t attrLength;
+ udf_Uint32_t dataLength;
+ udf_Uint32_t infoTimeExistence;
+ udf_Uint8_t infoTimes[0];
+} GNUC_PACKED;
+
+/** Device Specification (ECMA 167r3 4/14.10.7) */
+struct deviceSpec
+{
+ udf_Uint32_t attr_type;
+ udf_Uint8_t attr_subtype;
+ udf_Uint8_t reserved[3];
+ udf_Uint32_t attrLength;
+ udf_Uint32_t imp_useLength;
+ udf_Uint32_t majorDevice_id;
+ udf_Uint32_t minorDevice_id;
+ udf_Uint8_t imp_use[0];
+} GNUC_PACKED;
+
+/** Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */
+struct impUseExtAttr
+{
+ udf_Uint32_t attr_type;
+ udf_Uint8_t attr_subtype;
+ udf_Uint8_t reserved[3];
+ udf_Uint32_t attrLength;
+ udf_Uint32_t imp_useLength;
+ udf_regid_t imp_id;
+ udf_Uint8_t imp_use[0];
+} GNUC_PACKED;
+
+/** Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */
+struct appUseExtAttr
+{
+ udf_Uint32_t attr_type;
+ udf_Uint8_t attr_subtype;
+ udf_Uint8_t reserved[3];
+ udf_Uint32_t attrLength;
+ udf_Uint32_t appUseLength;
+ udf_regid_t app_id;
+ udf_Uint8_t appUse[0];
+} GNUC_PACKED;
+
+#define EXTATTR_CHAR_SET 1
+#define EXTATTR_ALT_PERMS 3
+#define EXTATTR_FILE_TIMES 5
+#define EXTATTR_INFO_TIMES 6
+#define EXTATTR_DEV_SPEC 12
+#define EXTATTR_IMP_USE 2048
+#define EXTATTR_APP_USE 65536
+
+
+/** Unallocated Space Entry (ECMA 167r3 4/14.11) */
+struct unallocSpaceEntry
+{
+ udf_tag_t tag;
+ udf_icbtag_t icb_tag;
+ udf_Uint32_t lengthAllocDescs;
+ udf_Uint8_t allocDescs[0];
+} GNUC_PACKED;
+
+/** Space Bitmap Descriptor (ECMA 167r3 4/14.12) */
+struct spaceBitmapDesc
+{
+ udf_tag_t tag;
+ udf_Uint32_t i_bits;
+ udf_Uint32_t i_bytes;
+ udf_Uint8_t bitmap[0];
+} GNUC_PACKED;
+
+/** Partition Integrity Entry (ECMA 167r3 4/14.13) */
+struct partitionIntegrityEntry
+{
+ udf_tag_t tag;
+ udf_icbtag_t icb_tag;
+ udf_timestamp_t recording_time;
+ udf_Uint8_t integrityType;
+ udf_Uint8_t reserved[175];
+ udf_regid_t imp_id;
+ udf_Uint8_t imp_use[256];
+} GNUC_PACKED;
+
+/** Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
+
+/** Extent Length (ECMA 167r3 4/14.14.1.1) */
+#define EXT_RECORDED_ALLOCATED 0x00000000
+#define EXT_NOT_RECORDED_ALLOCATED 0x40000000
+#define EXT_NOT_RECORDED_NOT_ALLOCATED 0x80000000
+#define EXT_NEXT_EXTENT_ALLOCDECS 0xC0000000
+
+/** Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */
+
+/** Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
+
+/** Logical Volume Header Descriptor (ECMA 167r3 4/14.15) */
+struct logical_vol_header_desc_s
+{
+ udf_Uint64_t uniqueID;
+ udf_Uint8_t reserved[24];
+} GNUC_PACKED;
+
+typedef struct logical_vol_header_desc_s logical_vol_header_desc_t;
+
+/** Path Component (ECMA 167r3 4/14.16.1) */
+struct pathComponent
+{
+ udf_Uint8_t component_type;
+ udf_Uint8_t lengthComponent_id;
+ udf_Uint16_t componentFileVersionNum;
+ udf_dstring component_id[0];
+} GNUC_PACKED;
+
+/** File Entry (ECMA 167r3 4/14.17) */
+struct extended_file_entry
+{
+ udf_tag_t tag; /**< 4/14.17.1 - id = 266 */
+ udf_icbtag_t icb_tag; /**< 4/14.17.2 & 4/14.9.2 */
+ udf_Uint32_t uid; /**< 4/14.17.3 & 4/14.9.3 */
+ udf_Uint32_t gid; /**< 4/14.17.4 & 4/14.9.4 */
+ udf_Uint32_t permissions; /**< 4/14.17.5 & 4/14.9.5 */
+ udf_Uint16_t link_count; /**< 4/14.17.6 & 4/14.9.6 */
+ udf_Uint8_t rec_format; /**< 4/14.17.7 & 4/14.9.7 */
+ udf_Uint8_t rec_display_attr; /**< 4/14.17.8 & 4/14.9.8 */
+ udf_Uint32_t record_len; /**< 4/14.17.9 & 4/14.9.9 */
+ udf_Uint64_t info_len; /**< 4/14.17.10 & 4/14.9.10 */
+ udf_Uint64_t object_size; /**< 4/14.17.11 */
+ udf_Uint64_t logblks_recorded; /**< 4/14.17.12 & 4/14.9.11 */
+ udf_timestamp_t access_time; /**< 4/14.17.13 & 4/14.9.12 - last
+ access to any stream of file */
+ udf_timestamp_t modification_time; /**< 4/14.17.14 & 4/14.9.13 - last
+ modification to any stream of
+ file*/
+ udf_timestamp_t create_time; /**< 4/14.17.15 */
+ udf_timestamp_t attribute_time; /**< 4/14.17.16 & 4/14.9.14 -
+ most recent create or modify
+ time */
+ udf_Uint32_t checkpoint;
+ udf_Uint32_t reserved; /**< #00 bytes */
+ udf_long_ad_t ext_attr_ICB;
+ udf_long_ad_t stream_directory_ICB;
+ udf_regid_t imp_id;
+ udf_Uint64_t unique_ID;
+ udf_Uint32_t length_extended_attr;
+ udf_Uint32_t length_alloc_descs;
+ udf_Uint8_t ext_attr[0];
+ udf_Uint8_t alloc_descs[0];
+} GNUC_PACKED;
+
+PRAGMA_END_PACKED
+
+/** The below variables are trickery to force the above enum symbol
+ values to be recorded in debug symbol tables. They are used to
+ allow one refer to the enumeration value names in the typedefs
+ above in a debugger and in debugger expressions.
+*/
+extern tag_id_t debug_tagid;
+extern file_characteristics_t debug_file_characteristics;
+extern icbtag_file_type_enum_t debug_icbtag_file_type_enum;
+extern icbtag_flag_enum_t debug_flag_enum;
+extern ecma_167_enum1_t debug_ecma_167_enum1;
+extern ecma_167_timezone_enum_t debug_ecma_167_timezone_enum;
+
+#endif /* _ECMA_167_H */
diff --git a/include/cdio/iso9660.h b/include/cdio/iso9660.h
new file mode 100644
index 00000000..a5311c8f
--- /dev/null
+++ b/include/cdio/iso9660.h
@@ -0,0 +1,1116 @@
+/*
+ $Id: iso9660.h,v 1.102 2008/07/16 00:28:54 rocky Exp $
+
+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
+ Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
+
+ See also iso9660.h by Eric Youngdale (1993).
+
+ Copyright 1993 Yggdrasil Computing, Incorporated
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+/*!
+ * \file iso9660.h
+ *
+ * \brief The top-level interface header for libiso9660: the ISO-9660
+ * filesystem library; applications include this.
+ *
+ * See also the ISO-9660 specification. The freely available European
+ * equivalant standard is called ECMA-119.
+*/
+
+
+#ifndef __CDIO_ISO9660_H__
+#define __CDIO_ISO9660_H__
+
+#include <time.h>
+
+#include <cdio/cdio.h>
+#include <cdio/ds.h>
+#include <cdio/posix.h>
+
+/** \brief ISO 9660 Integer and Character types
+
+These are described in the section 7 of the ISO 9660 (or ECMA 119)
+specification.
+*/
+
+typedef uint8_t iso711_t; /*! See section 7.1.1 */
+typedef int8_t iso712_t; /*! See section 7.1.2 */
+typedef uint16_t iso721_t; /*! See section 7.2.1 */
+typedef uint16_t iso722_t; /*! See section 7.2.2 */
+typedef uint32_t iso723_t; /*! See section 7.2.3 */
+typedef uint32_t iso731_t; /*! See section 7.3.1 */
+typedef uint32_t iso732_t; /*! See section 7.3.2 */
+typedef uint64_t iso733_t; /*! See section 7.3.3 */
+
+typedef char achar_t; /*! See section 7.4.1 */
+typedef char dchar_t; /*! See section 7.4.1 */
+
+#ifndef EMPTY_ARRAY_SIZE
+#define EMPTY_ARRAY_SIZE 0
+#endif
+
+#include <cdio/types.h>
+#include <cdio/xa.h>
+
+#ifdef ISODCL
+#undef ISODCL
+#endif
+/* This part borrowed from the bsd386 isofs */
+#define ISODCL(from, to) ((to) - (from) + 1)
+
+#define MIN_TRACK_SIZE 4*75
+#define MIN_ISO_SIZE MIN_TRACK_SIZE
+
+/*! The below isn't really an enumeration one would really use in a
+ program; things are done this way so that in a debugger one can to
+ refer to the enumeration value names such as in a debugger
+ expression and get something. With the more common a \#define
+ mechanism, the name/value assocation is lost at run time.
+ */
+extern enum iso_enum1_s {
+ ISO_PVD_SECTOR = 16, /**< Sector of Primary Volume Descriptor. */
+ ISO_EVD_SECTOR = 17, /**< Sector of End Volume Descriptor. */
+ LEN_ISONAME = 31, /**< Size in bytes of the filename
+ portion + null byte. */
+ ISO_MAX_SYSTEM_ID = 32, /**< Maximum number of characters in a system
+ id. */
+ MAX_ISONAME = 37, /**< Size in bytes of the filename
+ portion + null byte. */
+ ISO_MAX_PREPARER_ID = 128, /**< Maximum number of characters in a
+ preparer id. */
+ MAX_ISOPATHNAME = 255, /**< Maximum number of characters in the
+ entire ISO 9660 filename. */
+ ISO_BLOCKSIZE = 2048 /**< Number of bytes in an ISO 9660 block. */
+
+} iso_enums1;
+
+/*! An enumeration for some of the ISO_* \#defines below. This isn't
+ really an enumeration one would really use in a program it is here
+ to be helpful in debuggers where wants just to refer to the
+ ISO_*_ names and get something.
+ */
+
+/*! ISO 9660 directory flags. */
+extern enum iso_flag_enum_s {
+ ISO_FILE = 0, /**< Not really a flag... */
+ ISO_EXISTENCE = 1, /**< Do not make existence known (hidden) */
+ ISO_DIRECTORY = 2, /**< This file is a directory */
+ ISO_ASSOCIATED = 4, /**< This file is an associated file */
+ ISO_RECORD = 8, /**< Record format in extended attr. != 0 */
+ ISO_PROTECTION = 16, /**< No read/execute perm. in ext. attr. */
+ ISO_DRESERVED1 = 32, /**<, Reserved bit 5 */
+ ISO_DRESERVED2 = 64, /**<, Reserved bit 6 */
+ ISO_MULTIEXTENT = 128, /**< Not final entry of a mult. ext. file */
+} iso_flag_enums;
+
+/*! Volume descriptor types */
+extern enum iso_vd_enum_s {
+ ISO_VD_BOOT_RECORD = 0, /**< CD is bootable */
+ ISO_VD_PRIMARY = 1, /**< Is in any ISO-9660 */
+ ISO_VD_SUPPLEMENTARY = 2, /**< Used by Joliet, for example */
+ ISO_VD_PARITION = 3, /**< Indicates a partition of a CD */
+ ISO_VD_END = 255
+} iso_vd_enums;
+
+
+/*!
+ An ISO filename is:
+ <em>abcd</em>.<em>eee</em> ->
+ <em>filename</em>.<em>ext</em>;<em>version#</em>
+
+ For ISO-9660 Level 1, the maximum needed string length is:
+
+@code
+ 30 chars (filename + ext)
+ + 2 chars ('.' + ';')
+ + 5 chars (strlen("32767"))
+ + 1 null byte
+ ================================
+ = 38 chars
+@endcode
+
+*/
+
+/*! \brief Maximum number of characters in a publisher id. */
+#define ISO_MAX_PUBLISHER_ID 128
+
+/*! \brief Maximum number of characters in an application id. */
+#define ISO_MAX_APPLICATION_ID 128
+
+/*! \brief Maximum number of characters in a volume id. */
+#define ISO_MAX_VOLUME_ID 32
+
+/*! \brief Maximum number of characters in a volume-set id. */
+#define ISO_MAX_VOLUMESET_ID 128
+
+/*! String inside frame which identifies an ISO 9660 filesystem. This
+ string is the "id" field of an iso9660_pvd_t or an iso9660_svd_t.
+*/
+extern const char ISO_STANDARD_ID[sizeof("CD001")-1];
+
+#define ISO_STANDARD_ID "CD001"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+typedef enum strncpy_pad_check {
+ ISO9660_NOCHECK = 0,
+ ISO9660_7BIT,
+ ISO9660_ACHARS,
+ ISO9660_DCHARS
+} strncpy_pad_check_t;
+
+PRAGMA_BEGIN_PACKED
+
+/*!
+ \brief ISO-9660 shorter-format time structure. See ECMA 9.1.5.
+
+ @see iso9660_dtime
+ */
+struct iso9660_dtime_s {
+ iso711_t dt_year; /**< Number of years since 1900 */
+ iso711_t dt_month; /**< Has value in range 1..12. Note starts
+ at 1, not 0 like a tm struct. */
+ iso711_t dt_day; /**< Day of the month from 1 to 31 */
+ iso711_t dt_hour; /**< Hour of the day from 0 to 23 */
+ iso711_t dt_minute; /**< Minute of the hour from 0 to 59 */
+ iso711_t dt_second; /**< Second of the minute from 0 to 59 */
+ iso712_t dt_gmtoff; /**< GMT values -48 .. + 52 in 15 minute
+ intervals */
+} GNUC_PACKED;
+
+typedef struct iso9660_dtime_s iso9660_dtime_t;
+
+/*!
+ \brief ISO-9660 longer-format time structure.
+
+ Section 8.4.26.1 of ECMA 119. All values are encoded as character
+ arrays, eg. '1', '9', '5', '5' for the year 1955 (no null terminated
+ byte).
+
+ @see iso9660_ltime
+ */
+struct iso9660_ltime_s {
+ char lt_year [ISODCL( 1, 4)]; /**< Add 1900 to value
+ for the Julian
+ year */
+ char lt_month [ISODCL( 5, 6)]; /**< Has value in range
+ 1..12. Note starts
+ at 1, not 0 like a
+ tm struct. */
+ char lt_day [ISODCL( 7, 8)]; /**< Day of month: 1..31 */
+ char lt_hour [ISODCL( 9, 10)]; /**< hour: 0..23 */
+ char lt_minute [ISODCL( 11, 12)]; /**< minute: 0..59 */
+ char lt_second [ISODCL( 13, 14)]; /**< second: 0..59 */
+ char lt_hsecond [ISODCL( 15, 16)]; /**< The value is in
+ units of 1/100's of
+ a second */
+ iso712_t lt_gmtoff; /**< Offset from Greenwich Mean Time in number
+ of 15 min intervals from -48 (West) to +52
+ (East) recorded according to 7.1.2 numerical
+ value */
+} GNUC_PACKED;
+
+typedef struct iso9660_ltime_s iso9660_ltime_t;
+typedef struct iso9660_dir_s iso9660_dir_t;
+typedef struct iso9660_stat_s iso9660_stat_t;
+
+#include <cdio/rock.h>
+
+/*! \brief Format of an ISO-9660 directory record
+
+ Section 9.1 of ECMA 119.
+
+ This structure may have an odd length depending on how many
+ characters there are in the filename! Some compilers (e.g. on
+ Sun3/mc68020) pad the structures to an even length. For this reason,
+ we cannot use sizeof (struct iso_path_table) or sizeof (struct
+ iso_directory_record) to compute on disk sizes. Instead, we use
+ offsetof(..., name) and add the name size. See mkisofs.h of the
+ cdrtools package.
+
+ @see iso9660_stat
+*/
+struct iso9660_dir_s {
+ iso711_t length; /*! Length of Directory record (9.1.1) */
+ iso711_t xa_length; /*! XA length if XA is used. Otherwise
+ zero. (9.1.2) */
+ iso733_t extent; /*! LBA of first local block allocated
+ to the extent */
+ iso733_t size; /*! data length of File Section. This
+ does not include the length of
+ any XA Records. (9.1.2) */
+ iso9660_dtime_t recording_time; /*! Recording date and time (9.1.3) */
+ uint8_t file_flags; /*! If no XA then zero. If a directory,
+ then bits 2,3 and 7 are zero.
+ (9.1.6) */
+ iso711_t file_unit_size; /*! File Unit size for the File
+ Section if the File Section
+ is recorded in interleaved
+ mode. Otherwise zero. (9.1.7) */
+ iso711_t interleave_gap; /*! Interleave Gap size for the
+ File Section if the File
+ Section is interleaved. Otherwise
+ zero. (9.1.8) */
+ iso723_t volume_sequence_number; /*! Ordinal number of the volume
+ in the Volume Set on which
+ the Extent described by this
+ Directory Record is
+ recorded. (9.1.9) */
+ iso711_t filename_len; /*! number of bytes in filename field */
+ char filename[EMPTY_ARRAY_SIZE];
+} GNUC_PACKED;
+
+/*!
+ \brief ISO-9660 Primary Volume Descriptor.
+ */
+struct iso9660_pvd_s {
+ iso711_t type; /**< ISO_VD_PRIMARY - 1 */
+ char id[5]; /**< ISO_STANDARD_ID "CD001"
+ */
+ iso711_t version; /**< value 1 for ECMA 119 */
+ char unused1[1]; /**< unused - value 0 */
+ achar_t system_id[ISO_MAX_SYSTEM_ID]; /**< each char is an achar */
+ dchar_t volume_id[ISO_MAX_VOLUME_ID]; /**< each char is a dchar */
+ uint8_t unused2[8]; /**< unused - value 0 */
+ iso733_t volume_space_size; /**< total number of
+ sectors */
+ uint8_t unused3[32]; /**< unused - value 0 */
+ iso723_t volume_set_size; /**< often 1 */
+ iso723_t volume_sequence_number; /**< often 1 */
+ iso723_t logical_block_size; /**< sector size, e.g. 2048 */
+ iso733_t path_table_size; /**< bytes in path table */
+ iso731_t type_l_path_table; /**< first sector of L Path
+ Table */
+ iso731_t opt_type_l_path_table; /**< first sector of optional
+ L Path Table */
+ iso732_t type_m_path_table; /**< first sector of M Path
+ table */
+ iso732_t opt_type_m_path_table; /**< first sector of optional
+ M Path table */
+ iso9660_dir_t root_directory_record; /**< See 8.4.18 and
+ section 9.1 of
+ ISO 9660 spec. */
+ char root_directory_filename; /**< Is '\\0' or root
+ directory. Also pads previous
+ field to 34 bytes */
+ dchar_t volume_set_id[ISO_MAX_VOLUMESET_ID]; /**< Volume Set of
+ which the volume is
+ a member. See
+ section 8.4.19 */
+ achar_t publisher_id[ISO_MAX_PUBLISHER_ID]; /**< Publisher of
+ volume. If the first
+ character is '_' 0x5F,
+ the remaining bytes
+ specify a file
+ containing the user.
+ If all bytes are " "
+ (0x20) no publisher
+ is specified. See
+ section 8.4.20 of
+ ECMA 119 */
+ achar_t preparer_id[ISO_MAX_PREPARER_ID]; /**< preparer of
+ volume. If the first
+ character is '_' 0x5F,
+ the remaining bytes
+ specify a file
+ containing the user.
+ If all bytes are " "
+ (0x20) no preparer
+ is specified.
+ See section 8.4.21
+ of ECMA 119 */
+ achar_t application_id[ISO_MAX_APPLICATION_ID]; /**< application
+ use to create the
+ volume. If the first
+ character is '_' 0x5F,
+ the remaining bytes
+ specify a file
+ containing the user.
+ If all bytes are " "
+ (0x20) no application
+ is specified.
+ See section of 8.4.22
+ of ECMA 119 */
+ dchar_t copyright_file_id[37]; /**< Name of file for
+ copyright info. If
+ all bytes are " "
+ (0x20), then no file
+ is identified. See
+ section 8.4.23 of ECMA 119
+ 9660 spec. */
+ dchar_t abstract_file_id[37]; /**< See section 8.4.24 of
+ ECMA 119. */
+ dchar_t bibliographic_file_id[37]; /**< See section 7.5 of
+ ISO 9660 spec. */
+ iso9660_ltime_t creation_date; /**< date and time of volume
+ creation. See section 8.4.26.1
+ of the ISO 9660 spec. */
+ iso9660_ltime_t modification_date; /**< date and time of the most
+ recent modification.
+ See section 8.4.27 of the
+ ISO 9660 spec. */
+ iso9660_ltime_t expiration_date; /**< date and time when volume
+ expires. See section 8.4.28
+ of the ISO 9660 spec. */
+ iso9660_ltime_t effective_date; /**< date and time when volume
+ is effective. See section
+ 8.4.29 of the ISO 9660
+ spec. */
+ iso711_t file_structure_version; /**< value 1 for ECMA 119 */
+ uint8_t unused4[1]; /**< unused - value 0 */
+ char application_data[512]; /**< Application can put
+ whatever it wants here. */
+ uint8_t unused5[653]; /**< Unused - value 0 */
+} GNUC_PACKED;
+
+typedef struct iso9660_pvd_s iso9660_pvd_t;
+
+/*!
+ \brief ISO-9660 Supplementary Volume Descriptor.
+
+ This is used for Joliet Extentions and is almost the same as the
+ the primary descriptor but two unused fields, "unused1" and "unused3
+ become "flags and "escape_sequences" respectively.
+*/
+struct iso9660_svd_s {
+ iso711_t type; /**< ISO_VD_SUPPLEMENTARY - 2
+ */
+ char id[5]; /**< ISO_STANDARD_ID "CD001"
+ */
+ iso711_t version; /**< value 1 */
+ char flags; /**< Section 8.5.3 */
+ achar_t system_id[ISO_MAX_SYSTEM_ID]; /**< Section 8.5.4; each char
+ is an achar */
+ dchar_t volume_id[ISO_MAX_VOLUME_ID]; /**< Section 8.5.5; each char
+ is a dchar */
+ char unused2[8];
+ iso733_t volume_space_size; /**< total number of
+ sectors */
+ char escape_sequences[32]; /**< Section 8.5.6 */
+ iso723_t volume_set_size; /**< often 1 */
+ iso723_t volume_sequence_number; /**< often 1 */
+ iso723_t logical_block_size; /**< sector size, e.g. 2048 */
+ iso733_t path_table_size; /**< 8.5.7; bytes in path
+ table */
+ iso731_t type_l_path_table; /**< 8.5.8; first sector of
+ little-endian path table */
+ iso731_t opt_type_l_path_table; /**< 8.5.9; first sector of
+ optional little-endian
+ path table */
+ iso732_t type_m_path_table; /**< 8.5.10; first sector of
+ big-endian path table */
+ iso732_t opt_type_m_path_table; /**< 8.5.11; first sector of
+ optional big-endian path
+ table */
+ iso9660_dir_t root_directory_record; /**< See section 8.5.12 and
+ 9.1 of ISO 9660 spec. */
+ char root_directory_filename; /**< Is '\\0' or root
+ directory. Also pads previous
+ field to 34 bytes */
+ dchar_t volume_set_id[ISO_MAX_VOLUMESET_ID]; /**< 8.5.13;
+ dchars */
+ achar_t publisher_id[ISO_MAX_PUBLISHER_ID]; /**<
+ Publisher of volume.
+ If the first char-
+ aracter is '_' 0x5F,
+ the remaining bytes
+ specify a file
+ containing the user.
+ If all bytes are " "
+ (0x20) no publisher
+ is specified. See
+ section 8.5.14 of
+ ECMA 119 */
+ achar_t preparer_id[ISO_MAX_PREPARER_ID]; /**<
+ Data preparer of
+ volume. If the first
+ character is '_' 0x5F,
+ the remaining bytes
+ specify a file
+ containing the user.
+ If all bytes are " "
+ (0x20) no preparer
+ is specified.
+ See section 8.5.15
+ of ECMA 119 */
+ achar_t application_id[ISO_MAX_APPLICATION_ID]; /**< application
+ use to create the
+ volume. If the first
+ character is '_' 0x5F,
+ the remaining bytes
+ specify a file
+ containing the user.
+ If all bytes are " "
+ (0x20) no application
+ is specified.
+ See section of 8.5.16
+ of ECMA 119 */
+ dchar_t copyright_file_id[37]; /**< Name of file for
+ copyright info. If
+ all bytes are " "
+ (0x20), then no file
+ is identified. See
+ section 8.5.17 of ECMA 119
+ 9660 spec. */
+ dchar_t abstract_file_id[37]; /**< See section 8.5.18 of
+ ECMA 119. */
+ dchar_t bibliographic_file_id[37]; /**< See section 8.5.19 of
+ ECMA 119. */
+ iso9660_ltime_t creation_date; /**< date and time of volume
+ creation. See section 8.4.26.1
+ of the ECMA 119 spec. */
+ iso9660_ltime_t modification_date; /**< date and time of the most
+ recent modification.
+ See section 8.4.27 of the
+ ECMA 119 spec. */
+ iso9660_ltime_t expiration_date; /**< date and time when volume
+ expires. See section 8.4.28
+ of the ECMA 119 spec. */
+ iso9660_ltime_t effective_date; /**< date and time when volume
+ is effective. See section
+ 8.4.29 of the ECMA 119
+ spec. */
+ iso711_t file_structure_version; /**< value 1 for ECMA 119 */
+ uint8_t unused4[1]; /**< unused - value 0 */
+ char application_data[512]; /**< 8.5.20 Application can put
+ whatever it wants here. */
+ uint8_t unused5[653]; /**< Unused - value 0 */
+} GNUC_PACKED;
+
+typedef struct iso9660_svd_s iso9660_svd_t;
+
+PRAGMA_END_PACKED
+
+/*! \brief Unix stat-like version of iso9660_dir
+
+ The iso9660_stat structure is not part of the ISO-9660
+ specification. We use it for our to communicate information
+ in a C-library friendly way, e.g struct tm time structures and
+ a C-style filename string.
+
+ @see iso9660_dir
+*/
+struct iso9660_stat_s { /* big endian!! */
+
+ iso_rock_statbuf_t rr; /**< Rock Ridge-specific fields */
+
+ struct tm tm; /**< time on entry - FIXME merge with
+ one of entries above, like ctime? */
+ lsn_t lsn; /**< start logical sector number */
+ uint32_t size; /**< total size in bytes */
+ uint32_t secsize; /**< number of sectors allocated */
+ iso9660_xa_t xa; /**< XA attributes */
+ enum { _STAT_FILE = 1, _STAT_DIR = 2 } type;
+ bool b_xa;
+ char filename[EMPTY_ARRAY_SIZE]; /**< filename */
+};
+
+/** A mask used in iso9660_ifs_read_vd which allows what kinds
+ of extensions we allow, eg. Joliet, Rock Ridge, etc. */
+typedef uint8_t iso_extension_mask_t;
+
+/*! An enumeration for some of the ISO_EXTENSION_* \#defines below. This isn't
+ really an enumeration one would really use in a program it is here
+ to be helpful in debuggers where wants just to refer to the
+ ISO_EXTENSION_*_ names and get something.
+ */
+extern enum iso_extension_enum_s {
+ ISO_EXTENSION_JOLIET_LEVEL1 = 0x01,
+ ISO_EXTENSION_JOLIET_LEVEL2 = 0x02,
+ ISO_EXTENSION_JOLIET_LEVEL3 = 0x04,
+ ISO_EXTENSION_ROCK_RIDGE = 0x08,
+ ISO_EXTENSION_HIGH_SIERRA = 0x10
+} iso_extension_enums;
+
+
+#define ISO_EXTENSION_ALL 0xFF
+#define ISO_EXTENSION_NONE 0x00
+#define ISO_EXTENSION_JOLIET \
+ (ISO_EXTENSION_JOLIET_LEVEL1 | \
+ ISO_EXTENSION_JOLIET_LEVEL2 | \
+ ISO_EXTENSION_JOLIET_LEVEL3 )
+
+
+/** This is an opaque structure. */
+typedef struct _iso9660_s iso9660_t;
+
+ /*! Close previously opened ISO 9660 image and free resources
+ associated with the image. Call this when done using using an ISO
+ 9660 image.
+
+ @return true is unconditionally returned. If there was an error
+ false would be returned.
+ */
+ bool iso9660_close (iso9660_t * p_iso);
+
+
+ /*!
+ Open an ISO 9660 image for reading. Maybe in the future we will have
+ a mode. NULL is returned on error.
+ */
+ iso9660_t *iso9660_open (const char *psz_path /*flags, mode */);
+
+ /*!
+ Open an ISO 9660 image for reading allowing various ISO 9660
+ extensions. Maybe in the future we will have a mode. NULL is
+ returned on error.
+
+ @see iso9660_open_fuzzy
+ */
+ iso9660_t *iso9660_open_ext (const char *psz_path,
+ iso_extension_mask_t iso_extension_mask);
+
+ /*! Open an ISO 9660 image for "fuzzy" reading. This means that we
+ will try to guess various internal offset based on internal
+ checks. This may be useful when trying to read an ISO 9660 image
+ contained in a file format that libiso9660 doesn't know natively
+ (or knows imperfectly.)
+
+ Some tolerence allowed for positioning the ISO 9660 image. We scan
+ for STANDARD_ID and use that to set the eventual offset to adjust
+ by (as long as that is <= i_fuzz).
+
+ Maybe in the future we will have a mode. NULL is returned on error.
+
+ @see iso9660_open, @see iso9660_fuzzy_ext
+ */
+ iso9660_t *iso9660_open_fuzzy (const char *psz_path /*flags, mode */,
+ uint16_t i_fuzz);
+
+ /*!
+ Open an ISO 9660 image for reading with some tolerence for positioning
+ of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set
+ the eventual offset to adjust by (as long as that is <= i_fuzz).
+
+ Maybe in the future we will have a mode. NULL is returned on error.
+
+ @see iso9660_open_ext @see iso9660_open_fuzzy
+ */
+ iso9660_t *iso9660_open_fuzzy_ext (const char *psz_path,
+ iso_extension_mask_t iso_extension_mask,
+ uint16_t i_fuzz
+ /*flags, mode */);
+
+ /*!
+ Read the Super block of an ISO 9660 image but determine framesize
+ and datastart and a possible additional offset. Generally here we are
+ not reading an ISO 9660 image but a CD-Image which contains an ISO 9660
+ filesystem.
+ */
+ bool iso9660_ifs_fuzzy_read_superblock (iso9660_t *p_iso,
+ iso_extension_mask_t iso_extension_mask,
+ uint16_t i_fuzz);
+
+ /*!
+ Seek to a position and then read i_size blocks.
+
+ @param p_iso the ISO-9660 file image to get data from
+
+ @param ptr place to put returned data. It should be able to store
+ a least i_size bytes
+
+ @param start location to start reading from
+
+ @param i_size number of blocks to read. Each block is ISO_BLOCKSIZE bytes
+ long.
+
+ @return number of bytes (not blocks) read
+
+ */
+ long int iso9660_iso_seek_read (const iso9660_t *p_iso, /*out*/ void *ptr,
+ lsn_t start, long int i_size);
+
+ /*!
+ Read the Primary Volume Descriptor for a CD.
+ True is returned if read, and false if there was an error.
+ */
+ bool iso9660_fs_read_pvd ( const CdIo_t *p_cdio,
+ /*out*/ iso9660_pvd_t *p_pvd );
+
+ /*!
+ Read the Primary Volume Descriptor for an ISO 9660 image.
+ True is returned if read, and false if there was an error.
+ */
+ bool iso9660_ifs_read_pvd (const iso9660_t *p_iso,
+ /*out*/ iso9660_pvd_t *p_pvd);
+
+/*!
+ Read the Super block of an ISO 9660 image. This is the
+ Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
+ Descriptor if (Joliet) extensions are acceptable.
+*/
+ bool iso9660_fs_read_superblock (CdIo_t *p_cdio,
+ iso_extension_mask_t iso_extension_mask);
+
+ /*!
+ Read the Super block of an ISO 9660 image. This is the
+ Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
+ Descriptor if (Joliet) extensions are acceptable.
+ */
+ bool iso9660_ifs_read_superblock (iso9660_t *p_iso,
+ iso_extension_mask_t iso_extension_mask);
+
+
+/*====================================================
+ Time conversion
+ ====================================================*/
+/*!
+ Set time in format used in ISO 9660 directory index record
+ from a Unix time structure. */
+ void iso9660_set_dtime (const struct tm *tm,
+ /*out*/ iso9660_dtime_t *idr_date);
+
+
+ /*!
+ Set "long" time in format used in ISO 9660 primary volume descriptor
+ from a Unix time structure. */
+ void iso9660_set_ltime (const struct tm *_tm,
+ /*out*/ iso9660_ltime_t *p_pvd_date);
+
+ /*!
+ Get Unix time structure from format use in an ISO 9660 directory index
+ record. Even though tm_wday and tm_yday fields are not explicitly in
+ idr_date, they are calculated from the other fields.
+
+ If tm is to reflect the localtime, set "b_localtime" true, otherwise
+ tm will reported in GMT.
+ */
+ bool iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool b_localtime,
+ /*out*/ struct tm *tm);
+
+
+ /*!
+ Get "long" time in format used in ISO 9660 primary volume descriptor
+ from a Unix time structure.
+ */
+ bool iso9660_get_ltime (const iso9660_ltime_t *p_ldate,
+ /*out*/ struct tm *p_tm);
+
+ /*====================================================
+ Character Classification and String Manipulation
+ ====================================================*/
+ /*!
+ Return true if c is a DCHAR - a character that can appear in an an
+ ISO-9600 level 1 directory name. These are the ASCII capital
+ letters A-Z, the digits 0-9 and an underscore.
+ */
+ bool iso9660_is_dchar (int c);
+
+ /*!
+ Return true if c is an ACHAR -
+ These are the DCHAR's plus some ASCII symbols including the space
+ symbol.
+ */
+ bool iso9660_is_achar (int c);
+
+ /*!
+ Convert an ISO-9660 file name which is in the format usually stored
+ in a ISO 9660 directory entry into what's usually listed as the
+ file name in a listing. Lowercase name, and remove trailing ;1's
+ or .;1's and turn the other ;'s into version numbers.
+
+ @param psz_oldname the ISO-9660 filename to be translated.
+ @param psz_newname returned string. The caller allocates this and
+ it should be at least the size of psz_oldname.
+ @return length of the translated string is returned.
+ */
+ int iso9660_name_translate(const char *psz_oldname,
+ /*out*/ char *psz_newname);
+
+ /*!
+ Convert an ISO-9660 file name which is in the format usually stored
+ in a ISO 9660 directory entry into what's usually listed as the
+ file name in a listing. Lowercase name if no Joliet Extension
+ interpretation. Remove trailing ;1's or .;1's and turn the other
+ ;'s into version numbers.
+
+ @param psz_oldname the ISO-9660 filename to be translated.
+ @param psz_newname returned string. The caller allocates this and
+ it should be at least the size of psz_oldname.
+ @param i_joliet_level 0 if not using Joliet Extension. Otherwise the
+ Joliet level.
+ @return length of the translated string is returned. It will be no greater
+ than the length of psz_oldname.
+ */
+ int iso9660_name_translate_ext(const char *psz_oldname, char *psz_newname,
+ uint8_t i_joliet_level);
+
+ /*!
+ Pad string src with spaces to size len and copy this to dst. If
+ len is less than the length of src, dst will be truncated to the
+ first len characters of src.
+
+ src can also be scanned to see if it contains only ACHARs, DCHARs,
+ 7-bit ASCII chars depending on the enumeration _check.
+
+ In addition to getting changed, dst is the return value.
+ Note: this string might not be NULL terminated.
+ */
+ char *iso9660_strncpy_pad(char dst[], const char src[], size_t len,
+ enum strncpy_pad_check _check);
+
+ /*=====================================================================
+ File and Directory Names
+ ======================================================================*/
+
+ /*!
+ Check that psz_path is a valid ISO-9660 directory name.
+
+ A valid directory name should not start out with a slash (/),
+ dot (.) or null byte, should be less than 37 characters long,
+ have no more than 8 characters in a directory component
+ which is separated by a /, and consist of only DCHARs.
+
+ True is returned if psz_path is valid.
+ */
+ bool iso9660_dirname_valid_p (const char psz_path[]);
+
+ /*!
+ Take psz_path and a version number and turn that into a ISO-9660
+ pathname. (That's just the pathname followd by ";" and the version
+ number. For example, mydir/file.ext -> MYDIR/FILE.EXT;1 for version
+ 1. The resulting ISO-9660 pathname is returned.
+ */
+ char *iso9660_pathname_isofy (const char psz_path[], uint16_t i_version);
+
+ /*!
+ Check that psz_path is a valid ISO-9660 pathname.
+
+ A valid pathname contains a valid directory name, if one appears and
+ the filename portion should be no more than 8 characters for the
+ file prefix and 3 characters in the extension (or portion after a
+ dot). There should be exactly one dot somewhere in the filename
+ portion and the filename should be composed of only DCHARs.
+
+ True is returned if psz_path is valid.
+ */
+ bool iso9660_pathname_valid_p (const char psz_path[]);
+
+/*=====================================================================
+ directory tree
+======================================================================*/
+
+void
+iso9660_dir_init_new (void *dir, uint32_t self, uint32_t ssize,
+ uint32_t parent, uint32_t psize,
+ const time_t *dir_time);
+
+void
+iso9660_dir_init_new_su (void *dir, uint32_t self, uint32_t ssize,
+ const void *ssu_data, unsigned int ssu_size,
+ uint32_t parent, uint32_t psize,
+ const void *psu_data, unsigned int psu_size,
+ const time_t *dir_time);
+
+void
+iso9660_dir_add_entry_su (void *dir, const char filename[], uint32_t extent,
+ uint32_t size, uint8_t file_flags,
+ const void *su_data,
+ unsigned int su_size, const time_t *entry_time);
+
+unsigned int
+iso9660_dir_calc_record_size (unsigned int namelen, unsigned int su_len);
+
+/*!
+ Given a directory pointer, find the filesystem entry that contains
+ lsn and return information about it.
+
+ @return stat_t of entry if we found lsn, or NULL otherwise.
+ Caller must free return value.
+ */
+#define iso9660_fs_find_lsn iso9660_find_fs_lsn
+iso9660_stat_t *iso9660_fs_find_lsn(CdIo_t *p_cdio, lsn_t i_lsn);
+
+
+/*!
+ Given a directory pointer, find the filesystem entry that contains
+ lsn and return information about it.
+
+ @return stat_t of entry if we found lsn, or NULL otherwise.
+ Caller must free return value.
+ */
+iso9660_stat_t *iso9660_fs_find_lsn_with_path(CdIo_t *p_cdio, lsn_t i_lsn,
+ /*out*/ char **ppsz_path);
+
+/*!
+ Given a directory pointer, find the filesystem entry that contains
+ lsn and return information about it.
+
+ @return stat_t of entry if we found lsn, or NULL otherwise.
+ Caller must free return value.
+ */
+iso9660_stat_t *iso9660_ifs_find_lsn(iso9660_t *p_iso, lsn_t i_lsn);
+
+
+/*!
+ Given a directory pointer, find the filesystem entry that contains
+ lsn and return information about it.
+
+ @param p_iso pointer to iso_t
+ @param i_lsn LSN to find
+ @param ppsz_path full path of lsn filename. On entry *ppsz_path should be
+ NULL. On return it will be allocated an point to the full path of the
+ file at lsn or NULL if the lsn is not found. You should deallocate
+ *ppsz_path when you are done using it.
+
+ @return stat_t of entry if we found lsn, or NULL otherwise.
+ Caller must free return value.
+ */
+iso9660_stat_t *iso9660_ifs_find_lsn_with_path(iso9660_t *p_iso,
+ lsn_t i_lsn,
+ /*out*/ char **ppsz_path);
+
+
+/*!
+ Return file status for psz_path. NULL is returned on error.
+
+ @param p_cdio the CD object to read from
+
+ @param psz_path filename path to look up and get information about
+
+ @return ISO 9660 file information
+
+ Important note:
+
+ You make get different results looking up "/" versus "/." and the
+ latter may give more complete information. "/" will take information
+ from the PVD only, whereas "/." will force a directory read of "/" and
+ find "." and in that Rock-Ridge information might be found which fills
+ in more stat information. Ideally iso9660_fs_stat should be fixed.
+ Patches anyone?
+ */
+iso9660_stat_t *iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[]);
+
+
+/*!
+ Return file status for path name psz_path. NULL is returned on error.
+ pathname version numbers in the ISO 9660 name are dropped, i.e. ;1
+ is removed and if level 1 ISO-9660 names are lowercased.
+
+ b_mode2 is historical. It is not used.
+ */
+iso9660_stat_t *iso9660_fs_stat_translate (CdIo_t *p_cdio,
+ const char psz_path[],
+ bool b_mode2);
+
+/*!
+ Return file status for pathname. NULL is returned on error.
+ */
+iso9660_stat_t *iso9660_ifs_stat (iso9660_t *p_iso, const char psz_path[]);
+
+
+/*! Return file status for path name psz_path. NULL is returned on
+ error. pathname version numbers in the ISO 9660 name are dropped,
+ i.e. ;1 is removed and if level 1 ISO-9660 names are lowercased.
+ */
+iso9660_stat_t *iso9660_ifs_stat_translate (iso9660_t *p_iso,
+ const char psz_path[]);
+
+/*! Read psz_path (a directory) and return a list of iso9660_stat_t
+ pointers for the files inside that directory. The caller must free the
+ returned result.
+
+ b_mode2 is historical. It is not used.
+*/
+CdioList_t * iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[],
+ bool b_mode2);
+
+/*! Read psz_path (a directory) and return a list of iso9660_stat_t
+ pointers for the files inside that directory. The caller must free
+ the returned result.
+*/
+CdioList_t * iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[]);
+
+/*!
+ Return the PVD's application ID.
+ NULL is returned if there is some problem in getting this.
+*/
+char * iso9660_get_application_id(iso9660_pvd_t *p_pvd);
+
+/*!
+ Get the application ID. psz_app_id is set to NULL if there
+ is some problem in getting this and false is returned.
+*/
+bool iso9660_ifs_get_application_id(iso9660_t *p_iso,
+ /*out*/ cdio_utf8_t **p_psz_app_id);
+
+/*!
+ Return the Joliet level recognized for p_iso.
+*/
+uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso);
+
+uint8_t iso9660_get_dir_len(const iso9660_dir_t *p_idr);
+
+#if FIXME
+uint8_t iso9660_get_dir_size(const iso9660_dir_t *p_idr);
+
+lsn_t iso9660_get_dir_extent(const iso9660_dir_t *p_idr);
+#endif
+
+ /*!
+ Return the directory name stored in the iso9660_dir_t
+
+ A string is allocated: the caller must deallocate. This routine
+ can return NULL if memory allocation fails.
+ */
+ char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir);
+
+ /*!
+ Returns a POSIX mode for a given p_iso_dirent.
+ */
+ mode_t iso9660_get_posix_filemode(const iso9660_stat_t *p_iso_dirent);
+
+ /*!
+ Return a string containing the preparer id with trailing
+ blanks removed.
+ */
+ char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd);
+
+ /*!
+ Get the preparer ID. psz_preparer_id is set to NULL if there
+ is some problem in getting this and false is returned.
+ */
+ bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso,
+ /*out*/ cdio_utf8_t **p_psz_preparer_id);
+
+ /*!
+ Return a string containing the PVD's publisher id with trailing
+ blanks removed.
+ */
+ char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd);
+
+ /*!
+ Get the publisher ID. psz_publisher_id is set to NULL if there
+ is some problem in getting this and false is returned.
+ */
+ bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso,
+ /*out*/ cdio_utf8_t **p_psz_publisher_id);
+
+ uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd);
+
+ const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd);
+
+ int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd);
+
+ int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ;
+
+ /*! Return the primary volume id version number (of pvd).
+ If there is an error 0 is returned.
+ */
+ int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ;
+
+ /*!
+ Return a string containing the PVD's system id with trailing
+ blanks removed.
+ */
+ char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd);
+
+ /*!
+ Get the system ID. psz_system_id is set to NULL if there
+ is some problem in getting this and false is returned.
+ */
+ bool iso9660_ifs_get_system_id(iso9660_t *p_iso,
+ /*out*/ cdio_utf8_t **p_psz_system_id);
+
+
+ /*! Return the LSN of the root directory for pvd.
+ If there is an error CDIO_INVALID_LSN is returned.
+ */
+ lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd);
+
+ /*!
+ Get the volume ID in the PVD. psz_volume_id is set to NULL if there
+ is some problem in getting this and false is returned.
+ */
+ char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd);
+
+ /*!
+ Get the volume ID in the PVD. psz_volume_id is set to NULL if there
+ is some problem in getting this and false is returned.
+ */
+ bool iso9660_ifs_get_volume_id(iso9660_t *p_iso,
+ /*out*/ cdio_utf8_t **p_psz_volume_id);
+
+ /*!
+ Return the volumeset ID in the PVD.
+ NULL is returned if there is some problem in getting this.
+ */
+ char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd);
+
+ /*!
+ Get the volumeset ID. psz_systemset_id is set to NULL if there
+ is some problem in getting this and false is returned.
+ */
+ bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso,
+ /*out*/ cdio_utf8_t **p_psz_volumeset_id);
+
+ /* pathtable */
+
+ /*! Zero's out pathable. Do this first. */
+ void iso9660_pathtable_init (void *pt);
+
+ unsigned int iso9660_pathtable_get_size (const void *pt);
+
+ uint16_t iso9660_pathtable_l_add_entry (void *pt, const char name[],
+ uint32_t extent, uint16_t parent);
+
+ uint16_t iso9660_pathtable_m_add_entry (void *pt, const char name[],
+ uint32_t extent, uint16_t parent);
+
+ /**=====================================================================
+ Volume Descriptors
+ ======================================================================*/
+
+ void iso9660_set_pvd (void *pd, const char volume_id[],
+ const char application_id[],
+ const char publisher_id[], const char preparer_id[],
+ uint32_t iso_size, const void *root_dir,
+ uint32_t path_table_l_extent,
+ uint32_t path_table_m_extent,
+ uint32_t path_table_size, const time_t *pvd_time);
+
+ 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);
+
+
+#ifndef DO_NOT_WANT_COMPATIBILITY
+/** For compatibility with < 0.77 */
+#define iso9660_isdchar iso9660_is_dchar
+#define iso9660_isachar iso9660_is_achar
+#endif /*DO_NOT_WANT_COMPATIBILITY*/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#undef ISODCL
+#endif /* __CDIO_ISO9660_H__ */
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/cdio/logging.h b/include/cdio/logging.h
new file mode 100644
index 00000000..988d11c5
--- /dev/null
+++ b/include/cdio/logging.h
@@ -0,0 +1,136 @@
+/*
+ $Id: logging.h,v 1.11 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2003, 2004, 2008 Rocky Bernstein <rocky@gnu.org>
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file logging.h
+ * \brief Header to control logging and level of detail of output.
+ *
+ */
+
+#ifndef __LOGGING_H__
+#define __LOGGING_H__
+
+#include <cdio/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * The different log levels supported.
+ */
+typedef enum {
+ CDIO_LOG_DEBUG = 1, /**< Debug-level messages - helps debug what's up. */
+ CDIO_LOG_INFO, /**< Informational - indicates perhaps something of
+ interest. */
+ CDIO_LOG_WARN, /**< Warning conditions - something that looks funny. */
+ CDIO_LOG_ERROR, /**< Error conditions - may terminate program. */
+ CDIO_LOG_ASSERT /**< Critical conditions - may abort program. */
+} cdio_log_level_t;
+
+/**
+ * The place to save the preference concerning how much verbosity
+ * is desired. This is used by the internal default log handler, but
+ * it could be use by applications which provide their own log handler.
+ */
+extern cdio_log_level_t cdio_loglevel_default;
+
+/**
+ * This type defines the signature of a log handler. For every
+ * message being logged, the handler will receive the log level and
+ * the message string.
+ *
+ * @see cdio_log_set_handler
+ * @see cdio_log_level_t
+ *
+ * @param level The log level.
+ * @param message The log message.
+ */
+typedef void (*cdio_log_handler_t) (cdio_log_level_t level,
+ const char message[]);
+
+/**
+ * Set a custom log handler for libcdio. The return value is the log
+ * handler being replaced. If the provided parameter is NULL, then
+ * the handler will be reset to the default handler.
+ *
+ * @see cdio_log_handler_t
+ *
+ * @param new_handler The new log handler.
+ * @return The previous log handler.
+ */
+cdio_log_handler_t cdio_log_set_handler (cdio_log_handler_t new_handler);
+
+/**
+ * Handle an message with the given log level.
+ *
+ * @see cdio_debug
+ * @see cdio_info
+ * @see cdio_warn
+ * @see cdio_error
+
+ * @param level The log level.
+ * @param format printf-style format string
+ * @param ... remaining arguments needed by format string
+ */
+void cdio_log (cdio_log_level_t level,
+ const char format[], ...) GNUC_PRINTF(2, 3);
+
+/**
+ * Handle a debugging message.
+ *
+ * @see cdio_log for a more generic routine
+ */
+void cdio_debug (const char format[], ...) GNUC_PRINTF(1,2);
+
+/**
+ * Handle an informative message.
+ *
+ * @see cdio_log for a more generic routine
+ */
+void cdio_info (const char format[], ...) GNUC_PRINTF(1,2);
+
+/**
+ * Handle a warning message.
+ *
+ * @see cdio_log for a more generic routine
+ */
+void cdio_warn (const char format[], ...) GNUC_PRINTF(1,2);
+
+/**
+ * Handle an error message. Execution is terminated.
+ *
+ * @see cdio_log for a more generic routine.
+ */
+void cdio_error (const char format[], ...) GNUC_PRINTF(1,2);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LOGGING_H__ */
+
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/cdio/mmc.h b/include/cdio/mmc.h
new file mode 100644
index 00000000..c7a4eeaf
--- /dev/null
+++ b/include/cdio/mmc.h
@@ -0,0 +1,907 @@
+/*
+ $Id: mmc.h,v 1.32 2008/05/09 06:13:32 edsdead Exp $
+
+ Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
+ Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * \file mmc.h
+ *
+ * \brief Common definitions for MMC (Multimedia Commands). Applications
+ * include this for direct MMC access.
+*/
+
+#ifndef __CDIO_MMC_H__
+#define __CDIO_MMC_H__
+
+#include <cdio/cdio.h>
+#include <cdio/types.h>
+#include <cdio/dvd.h>
+#include <cdio/audio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /** Set this to the maximum value in milliseconds that we will
+ wait on an MMC command. */
+ extern uint32_t mmc_timeout_ms;
+
+ /** The default timeout (non-read) is 6 seconds. */
+#define MMC_TIMEOUT_DEFAULT 6000
+
+ /** Set this to the maximum value in milliseconds that we will
+ wait on an MMC read command. */
+ extern uint32_t mmc_read_timeout_ms;
+
+ /** The default read timeout is 3 minutes. */
+#define MMC_READ_TIMEOUT_DEFAULT 3*60*1000
+
+
+ /** \brief The opcode-portion (generic packet commands) of an MMC command.
+
+ In general, those opcodes that end in 6 take a 6-byte command
+ descriptor, those that end in 10 take a 10-byte
+ descriptor and those that in in 12 take a 12-byte descriptor.
+
+ (Not that you need to know that, but it seems to be a
+ big deal in the MMC specification.)
+
+ */
+ typedef enum {
+ CDIO_MMC_GPCMD_INQUIRY = 0x12, /**< Request drive
+ information. */
+ CDIO_MMC_GPCMD_MODE_SELECT_6 = 0x15, /**< Select medium
+ (6 bytes). */
+ CDIO_MMC_GPCMD_MODE_SENSE_6 = 0x1a, /**< Get medium or device
+ information. Should be issued
+ before MODE SELECT to get
+ mode support or save current
+ settings. (6 bytes). */
+ CDIO_MMC_GPCMD_START_STOP = 0x1b, /**< Enable/disable Disc
+ operations. (6 bytes). */
+ CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL = 0x1e, /**< Enable/disable Disc
+ removal. (6 bytes). */
+
+ /** Group 2 Commands (CDB's here are 10-bytes)
+ */
+ CDIO_MMC_GPCMD_READ_10 = 0x28, /**< Read data from drive
+ (10 bytes). */
+ CDIO_MMC_GPCMD_READ_SUBCHANNEL = 0x42, /**< Read Sub-Channel data.
+ (10 bytes). */
+ CDIO_MMC_GPCMD_READ_TOC = 0x43, /**< READ TOC/PMA/ATIP.
+ (10 bytes). */
+ CDIO_MMC_GPCMD_READ_HEADER = 0x44,
+ CDIO_MMC_GPCMD_PLAY_AUDIO_10 = 0x45, /**< Begin audio playing at
+ current position
+ (10 bytes). */
+ CDIO_MMC_GPCMD_GET_CONFIGURATION = 0x46, /**< Get drive Capabilities
+ (10 bytes) */
+ CDIO_MMC_GPCMD_PLAY_AUDIO_MSF = 0x47, /**< Begin audio playing at
+ specified MSF (10
+ bytes). */
+ CDIO_MMC_GPCMD_PLAY_AUDIO_TI = 0x48,
+ CDIO_MMC_GPCMD_PLAY_TRACK_REL_10 = 0x49, /**< Play audio at the track
+ relative LBA. (10 bytes).
+ Doesn't seem to be part
+ of MMC standards but is
+ handled by Plextor drives.
+ */
+
+ CDIO_MMC_GPCMD_GET_EVENT_STATUS = 0x4a, /**< Report events and
+ Status. */
+ CDIO_MMC_GPCMD_PAUSE_RESUME = 0x4b, /**< Stop or restart audio
+ playback. (10 bytes).
+ Used with a PLAY command. */
+
+ CDIO_MMC_GPCMD_READ_DISC_INFO = 0x51, /**< Get CD information.
+ (10 bytes). */
+ CDIO_MMC_GPCMD_MODE_SELECT_10 = 0x55, /**< Select medium
+ (10-bytes). */
+ CDIO_MMC_GPCMD_MODE_SENSE_10 = 0x5a, /**< Get medium or device
+ information. Should be issued
+ before MODE SELECT to get
+ mode support or save current
+ settings. (6 bytes). */
+
+ /** Group 5 Commands (CDB's here are 12-bytes)
+ */
+ CDIO_MMC_GPCMD_PLAY_AUDIO_12 = 0xa5, /**< Begin audio playing at
+ current position
+ (12 bytes) */
+ CDIO_MMC_GPCMD_LOAD_UNLOAD = 0xa6, /**< Load/unload a Disc
+ (12 bytes) */
+ CDIO_MMC_GPCMD_READ_12 = 0xa8, /**< Read data from drive
+ (12 bytes). */
+ CDIO_MMC_GPCMD_PLAY_TRACK_REL_12 = 0xa9, /**< Play audio at the track
+ relative LBA. (12 bytes).
+ Doesn't seem to be part
+ of MMC standards but is
+ handled by Plextor drives.
+ */
+ CDIO_MMC_GPCMD_READ_DVD_STRUCTURE = 0xad, /**< Get DVD structure info
+ from media (12 bytes). */
+ CDIO_MMC_GPCMD_READ_MSF = 0xb9, /**< Read almost any field
+ of a CD sector at specified
+ MSF. (12 bytes). */
+ CDIO_MMC_GPCMD_SET_SPEED = 0xbb, /**< Set drive speed
+ (12 bytes). This is listed
+ as optional in ATAPI 2.6,
+ but is (curiously)
+ missing from Mt. Fuji,
+ Table 57. It is mentioned
+ in Mt. Fuji Table 377 as an
+ MMC command for SCSI
+ devices though... Most
+ ATAPI drives support it. */
+ CDIO_MMC_GPCMD_READ_CD = 0xbe, /**< Read almost any field
+ of a CD sector at current
+ location. (12 bytes). */
+ /** Vendor-unique Commands
+ */
+ CDIO_MMC_GPCMD_CD_PLAYBACK_STATUS = 0xc4 /**< SONY unique = command */,
+ CDIO_MMC_GPCMD_PLAYBACK_CONTROL = 0xc9 /**< SONY unique = command */,
+ CDIO_MMC_GPCMD_READ_CDDA = 0xd8 /**< Vendor unique = command */,
+ CDIO_MMC_GPCMD_READ_CDXA = 0xdb /**< Vendor unique = command */,
+ CDIO_MMC_GPCMD_READ_ALL_SUBCODES = 0xdf /**< Vendor unique = command */
+ } cdio_mmc_gpcmd_t;
+
+
+ /** Read Subchannel states */
+ typedef enum {
+ CDIO_MMC_READ_SUB_ST_INVALID = 0x00, /**< audio status not supported */
+ CDIO_MMC_READ_SUB_ST_PLAY = 0x11, /**< audio play operation in
+ progress */
+ CDIO_MMC_READ_SUB_ST_PAUSED = 0x12, /**< audio play operation paused */
+ CDIO_MMC_READ_SUB_ST_COMPLETED = 0x13, /**< audio play successfully
+ completed */
+ CDIO_MMC_READ_SUB_ST_ERROR = 0x14, /**< audio play stopped due to
+ error */
+ CDIO_MMC_READ_SUB_ST_NO_STATUS = 0x15, /**< no current audio status to
+ return */
+ } cdio_mmc_read_sub_state_t;
+
+ /** Level values that can go into READ_CD */
+ typedef enum {
+ CDIO_MMC_READ_TYPE_ANY = 0, /**< All types */
+ CDIO_MMC_READ_TYPE_CDDA = 1, /**< Only CD-DA sectors */
+ CDIO_MMC_READ_TYPE_MODE1 = 2, /**< mode1 sectors (user data = 2048) */
+ CDIO_MMC_READ_TYPE_MODE2 = 3, /**< mode2 sectors form1 or form2 */
+ CDIO_MMC_READ_TYPE_M2F1 = 4, /**< mode2 sectors form1 */
+ CDIO_MMC_READ_TYPE_M2F2 = 5 /**< mode2 sectors form2 */
+ } cdio_mmc_read_cd_type_t;
+
+ /** Format values for READ_TOC */
+ typedef enum {
+ CDIO_MMC_READTOC_FMT_TOC = 0,
+ CDIO_MMC_READTOC_FMT_SESSION = 1,
+ CDIO_MMC_READTOC_FMT_FULTOC = 2,
+ CDIO_MMC_READTOC_FMT_PMA = 3, /**< Q subcode data */
+ CDIO_MMC_READTOC_FMT_ATIP = 4, /**< includes media type */
+ CDIO_MMC_READTOC_FMT_CDTEXT = 5 /**< CD-TEXT info */
+ } cdio_mmc_readtoc_t;
+
+/** Page codes for MODE SENSE and MODE SET. */
+ typedef enum {
+ CDIO_MMC_R_W_ERROR_PAGE = 0x01,
+ CDIO_MMC_WRITE_PARMS_PAGE = 0x05,
+ CDIO_MMC_CDR_PARMS_PAGE = 0x0d,
+ CDIO_MMC_AUDIO_CTL_PAGE = 0x0e,
+ CDIO_MMC_POWER_PAGE = 0x1a,
+ CDIO_MMC_FAULT_FAIL_PAGE = 0x1c,
+ CDIO_MMC_TO_PROTECT_PAGE = 0x1d,
+ CDIO_MMC_CAPABILITIES_PAGE = 0x2a,
+ CDIO_MMC_ALL_PAGES = 0x3f,
+ } cdio_mmc_mode_page_t;
+
+
+PRAGMA_BEGIN_PACKED
+ struct mmc_audio_volume_entry_s
+ {
+ uint8_t selection; /* Only the lower 4 bits are used. */
+ uint8_t volume;
+ } GNUC_PACKED;
+
+ typedef struct mmc_audio_volume_entry_s mmc_audio_volume_entry_t;
+
+ /** This struct is used by cdio_audio_get_volume and cdio_audio_set_volume */
+ struct mmc_audio_volume_s
+ {
+ mmc_audio_volume_entry_t port[4];
+ } GNUC_PACKED;
+
+ typedef struct mmc_audio_volume_s mmc_audio_volume_t;
+
+PRAGMA_END_PACKED
+
+
+/** Return type codes for GET_CONFIGURATION. */
+typedef enum {
+ CDIO_MMC_GET_CONF_ALL_FEATURES = 0, /**< all features without regard
+ to currency. */
+ CDIO_MMC_GET_CONF_CURRENT_FEATURES = 1, /**< features which are currently
+ in effect (e.g. based on
+ medium inserted). */
+ CDIO_MMC_GET_CONF_NAMED_FEATURE = 2 /**< just the feature named in
+ the GET_CONFIGURATION cdb. */
+} cdio_mmc_get_conf_t;
+
+
+/** FEATURE codes used in GET CONFIGURATION. */
+
+typedef enum {
+ CDIO_MMC_FEATURE_PROFILE_LIST = 0x000, /**< Profile List Feature */
+ CDIO_MMC_FEATURE_CORE = 0x001,
+ CDIO_MMC_FEATURE_MORPHING = 0x002, /**< Report/prevent operational
+ changes */
+ CDIO_MMC_FEATURE_REMOVABLE_MEDIUM = 0x003, /**< Removable Medium Feature */
+ CDIO_MMC_FEATURE_WRITE_PROTECT = 0x004, /**< Write Protect Feature */
+ CDIO_MMC_FEATURE_RANDOM_READABLE = 0x010, /**< Random Readable Feature */
+ CDIO_MMC_FEATURE_MULTI_READ = 0x01D, /**< Multi-Read Feature */
+ CDIO_MMC_FEATURE_CD_READ = 0x01E, /**< CD Read Feature */
+ CDIO_MMC_FEATURE_DVD_READ = 0x01F, /**< DVD Read Feature */
+ CDIO_MMC_FEATURE_RANDOM_WRITABLE = 0x020, /**< Random Writable Feature */
+ CDIO_MMC_FEATURE_INCR_WRITE = 0x021, /**< Incremental Streaming
+ Writable Feature */
+ CDIO_MMC_FEATURE_SECTOR_ERASE = 0x022, /**< Sector Erasable Feature */
+ CDIO_MMC_FEATURE_FORMATABLE = 0x023, /**< Formattable Feature */
+ CDIO_MMC_FEATURE_DEFECT_MGMT = 0x024, /**< Management Ability of the
+ Logical Unit/media system to
+ provide an apparently
+ defect-free space.*/
+ CDIO_MMC_FEATURE_WRITE_ONCE = 0x025, /**< Write Once
+ Feature */
+ CDIO_MMC_FEATURE_RESTRICT_OVERW = 0x026, /**< Restricted Overwrite
+ Feature */
+ CDIO_MMC_FEATURE_CD_RW_CAV = 0x027, /**< CD-RW CAV Write Feature */
+ CDIO_MMC_FEATURE_MRW = 0x028, /**< MRW Feature */
+ CDIO_MMC_FEATURE_ENHANCED_DEFECT = 0x029, /**< Enhanced Defect Reporting */
+ CDIO_MMC_FEATURE_DVD_PRW = 0x02A, /**< DVD+RW Feature */
+ CDIO_MMC_FEATURE_DVD_PR = 0x02B, /**< DVD+R Feature */
+ CDIO_MMC_FEATURE_RIGID_RES_OVERW = 0x02C, /**< Rigid Restricted Overwrite */
+ CDIO_MMC_FEATURE_CD_TAO = 0x02D, /**< CD Track at Once */
+ CDIO_MMC_FEATURE_CD_SAO = 0x02E, /**< CD Mastering (Session at
+ Once) */
+ CDIO_MMC_FEATURE_DVD_R_RW_WRITE = 0x02F, /**< DVD-R/RW Write */
+ CDIO_MMC_FEATURE_CD_RW_MEDIA_WRITE= 0x037, /**< CD-RW Media Write Support */
+ CDIO_MMC_FEATURE_DVD_PR_2_LAYER = 0x03B, /**< DVD+R Double Layer */
+ CDIO_MMC_FEATURE_POWER_MGMT = 0x100, /**< Initiator and device directed
+ power management */
+ CDIO_MMC_FEATURE_CDDA_EXT_PLAY = 0x103, /**< Ability to play audio CDs
+ via the Logical Unit's own
+ analog output */
+ CDIO_MMC_FEATURE_MCODE_UPGRADE = 0x104, /* Ability for the device to
+ accept new microcode via
+ the interface */
+ CDIO_MMC_FEATURE_TIME_OUT = 0x105, /**< Ability to respond to all
+ commands within a specific
+ time */
+ CDIO_MMC_FEATURE_DVD_CSS = 0x106, /**< Ability to perform DVD
+ CSS/CPPM authentication and
+ RPC */
+ CDIO_MMC_FEATURE_RT_STREAMING = 0x107, /**< Ability to read and write
+ using Initiator requested
+ performance parameters */
+ CDIO_MMC_FEATURE_LU_SN = 0x108, /**< The Logical Unit has a unique
+ identifier. */
+ CDIO_MMC_FEATURE_FIRMWARE_DATE = 0x1FF, /**< Firmware creation date
+ report */
+} cdio_mmc_feature_t;
+
+/** Profile profile codes used in GET_CONFIGURATION - PROFILE LIST. */
+typedef enum {
+ CDIO_MMC_FEATURE_PROF_NON_REMOVABLE = 0x0001, /**< Re-writable disk, capable
+ of changing behavior */
+ CDIO_MMC_FEATURE_PROF_REMOVABLE = 0x0002, /**< disk Re-writable; with
+ removable media */
+ CDIO_MMC_FEATURE_PROF_MO_ERASABLE = 0x0003, /**< Erasable Magneto-Optical
+ disk with sector erase
+ capability */
+ CDIO_MMC_FEATURE_PROF_MO_WRITE_ONCE = 0x0004, /**< Write Once Magneto-Optical
+ write once */
+ CDIO_MMC_FEATURE_PROF_AS_MO = 0x0005, /**< Advance Storage
+ Magneto-Optical */
+ CDIO_MMC_FEATURE_PROF_CD_ROM = 0x0008, /**< Read only Compact Disc
+ capable */
+ CDIO_MMC_FEATURE_PROF_CD_R = 0x0009, /**< Write once Compact Disc
+ capable */
+ CDIO_MMC_FEATURE_PROF_CD_RW = 0x000A, /**< CD-RW Re-writable
+ Compact Disc capable */
+ CDIO_MMC_FEATURE_PROF_DVD_ROM = 0x0010, /**< Read only DVD */
+ CDIO_MMC_FEATURE_PROF_DVD_R_SEQ = 0x0011, /**< Re-recordable DVD using
+ Sequential recording */
+ CDIO_MMC_FEATURE_PROF_DVD_RAM = 0x0012, /**< Re-writable DVD */
+ CDIO_MMC_FEATURE_PROF_DVD_RW_RO = 0x0013, /**< Re-recordable DVD using
+ Restricted Overwrite */
+ CDIO_MMC_FEATURE_PROF_DVD_RW_SEQ = 0x0014, /**< Re-recordable DVD using
+ Sequential recording */
+ CDIO_MMC_FEATURE_PROF_DVD_PRW = 0x001A, /**< DVD+RW - DVD ReWritable */
+ CDIO_MMC_FEATURE_PROF_DVD_PR = 0x001B, /**< DVD+R - DVD Recordable */
+ CDIO_MMC_FEATURE_PROF_DDCD_ROM = 0x0020, /**< Read only DDCD */
+ CDIO_MMC_FEATURE_PROF_DDCD_R = 0x0021, /**< DDCD-R Write only DDCD */
+ CDIO_MMC_FEATURE_PROF_DDCD_RW = 0x0022, /**< Re-Write only DDCD */
+ CDIO_MMC_FEATURE_PROF_DVD_PR2 = 0x002B, /**< DVD+R - DVD Recordable
+ double layer */
+ CDIO_MMC_FEATURE_PROF_NON_CONFORM = 0xFFFF, /**< The Logical Unit does not
+ conform to any Profile. */
+} cdio_mmc_feature_profile_t;
+
+typedef enum {
+ CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED = 0,
+ CDIO_MMC_FEATURE_INTERFACE_SCSI = 1,
+ CDIO_MMC_FEATURE_INTERFACE_ATAPI = 2,
+ CDIO_MMC_FEATURE_INTERFACE_IEEE_1394 = 3,
+ CDIO_MMC_FEATURE_INTERFACE_IEEE_1394A = 4,
+ CDIO_MMC_FEATURE_INTERFACE_FIBRE_CH = 5
+} cdio_mmc_feature_interface_t;
+
+
+/** The largest Command Descriptor Block (CDB) size.
+ The possible sizes are 6, 10, and 12 bytes.
+ */
+#define MAX_CDB_LEN 12
+
+/** \brief A Command Descriptor Block (CDB) used in sending MMC
+ commands.
+ */
+typedef struct mmc_cdb_s {
+ uint8_t field[MAX_CDB_LEN];
+} mmc_cdb_t;
+
+ /** \brief Format of header block in data returned from an MMC
+ GET_CONFIGURATION command.
+ */
+ typedef struct mmc_feature_list_header_s {
+ unsigned char length_msb;
+ unsigned char length_1sb;
+ unsigned char length_2sb;
+ unsigned char length_lsb;
+ unsigned char reserved1;
+ unsigned char reserved2;
+ unsigned char profile_msb;
+ unsigned char profile_lsb;
+ } cdio_mmc_feature_list_header_t;
+
+ /** An enumeration indicating whether an MMC command is sending
+ data or getting data.
+ */
+ typedef enum mmc_direction_s {
+ SCSI_MMC_DATA_READ,
+ SCSI_MMC_DATA_WRITE
+ } cdio_mmc_direction_t;
+
+ typedef struct mmc_subchannel_s
+ {
+ uint8_t reserved;
+ uint8_t audio_status;
+ uint16_t data_length; /**< Really ISO 9660 7.2.2 */
+ uint8_t format;
+ uint8_t address: 4;
+ uint8_t control: 4;
+ uint8_t track;
+ uint8_t index;
+ uint8_t abs_addr[4];
+ uint8_t rel_addr[4];
+ } cdio_mmc_subchannel_t;
+
+#define CDIO_MMC_SET_COMMAND(cdb, command) \
+ cdb[0] = command
+
+#define CDIO_MMC_SET_READ_TYPE(cdb, sector_type) \
+ cdb[1] = (sector_type << 2)
+
+#define CDIO_MMC_GETPOS_LEN16(p, pos) \
+ (p[pos]<<8) + p[pos+1]
+
+#define CDIO_MMC_GET_LEN16(p) \
+ (p[0]<<8) + p[1]
+
+#define CDIO_MMC_GET_LEN32(p) \
+ (p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3];
+
+#define CDIO_MMC_SET_LEN16(cdb, pos, len) \
+ cdb[pos ] = (len >> 8) & 0xff; \
+ cdb[pos+1] = (len ) & 0xff
+
+#define CDIO_MMC_SET_READ_LBA(cdb, lba) \
+ cdb[2] = (lba >> 24) & 0xff; \
+ cdb[3] = (lba >> 16) & 0xff; \
+ cdb[4] = (lba >> 8) & 0xff; \
+ cdb[5] = (lba ) & 0xff
+
+#define CDIO_MMC_SET_START_TRACK(cdb, command) \
+ cdb[6] = command
+
+#define CDIO_MMC_SET_READ_LENGTH24(cdb, len) \
+ cdb[6] = (len >> 16) & 0xff; \
+ cdb[7] = (len >> 8) & 0xff; \
+ cdb[8] = (len ) & 0xff
+
+#define CDIO_MMC_SET_READ_LENGTH16(cdb, len) \
+ CDIO_MMC_SET_LEN16(cdb, 7, len)
+
+#define CDIO_MMC_SET_READ_LENGTH8(cdb, len) \
+ cdb[8] = (len ) & 0xff
+
+#define CDIO_MMC_MCSB_ALL_HEADERS 0xf
+
+#define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(cdb, val) \
+ cdb[9] = val << 3;
+
+/**
+ Read Audio Subchannel information
+
+ @param p_cdio the CD object to be acted upon.
+ @param p_subchannel place for returned subchannel information
+*/
+driver_return_code_t
+mmc_audio_read_subchannel (CdIo_t *p_cdio,
+ /*out*/ cdio_subchannel_t *p_subchannel);
+
+ /**
+ Return a string containing the name of the audio state as returned from
+ the Q_SUBCHANNEL.
+ */
+ const char *mmc_audio_state2str( uint8_t i_audio_state );
+
+ /**
+ Eject using MMC commands. If CD-ROM is "locked" we'll unlock it.
+ Command is not "immediate" -- we'll wait for the command to complete.
+ For a more general (and lower-level) routine, @see mmc_start_stop_media.
+ */
+ driver_return_code_t mmc_eject_media( const CdIo_t *p_cdio );
+
+ /**
+ Return a string containing the name of the given feature
+ */
+ const char *mmc_feature2str( int i_feature );
+
+ /**
+ Return a string containing the name of the given feature
+ */
+ const char *mmc_feature_profile2str( int i_feature_profile );
+
+ /**
+ Return the length in bytes of the Command Descriptor
+ Buffer (CDB) for a given MMC command. The length will be
+ either 6, 10, or 12.
+ */
+ uint8_t mmc_get_cmd_len(uint8_t mmc_cmd);
+
+ /**
+ Get the block size used in read requests, via MMC.
+ @return the blocksize if > 0; error if <= 0
+ */
+ int mmc_get_blocksize ( CdIo_t *p_cdio );
+
+ /**
+ * Close tray using a MMC START STOP command.
+ */
+ driver_return_code_t mmc_close_tray( CdIo_t *p_cdio );
+
+ /**
+ Get the lsn of the end of the CD
+
+ @return the lsn. On error return CDIO_INVALID_LSN.
+ */
+ lsn_t mmc_get_disc_last_lsn( const CdIo_t *p_cdio );
+
+ /**
+ Return the discmode as reported by the MMC Read (FULL) TOC
+ command.
+
+ Information was obtained from Section 5.1.13 (Read TOC/PMA/ATIP)
+ pages 56-62 from the MMC draft specification, revision 10a
+ at http://www.t10.org/ftp/t10/drafts/mmc/mmc-r10a.pdf See
+ especially tables 72, 73 and 75.
+ */
+ discmode_t mmc_get_discmode( const CdIo_t *p_cdio );
+
+
+ /**
+ Get drive capabilities for a device.
+ @return the drive capabilities.
+ */
+ void mmc_get_drive_cap ( CdIo_t *p_cdio,
+ /*out*/ cdio_drive_read_cap_t *p_read_cap,
+ /*out*/ cdio_drive_write_cap_t *p_write_cap,
+ /*out*/ cdio_drive_misc_cap_t *p_misc_cap);
+
+ typedef enum {
+ CDIO_MMC_LEVEL_WEIRD,
+ CDIO_MMC_LEVEL_1,
+ CDIO_MMC_LEVEL_2,
+ CDIO_MMC_LEVEL_3,
+ CDIO_MMC_LEVEL_NONE
+ } cdio_mmc_level_t;
+
+ /**
+ Get the MMC level supported by the device.
+ */
+ cdio_mmc_level_t mmc_get_drive_mmc_cap(CdIo_t *p_cdio);
+
+
+ /**
+ Get the DVD type associated with cd object.
+
+ @return the DVD discmode.
+ */
+ discmode_t mmc_get_dvd_struct_physical ( const CdIo_t *p_cdio,
+ cdio_dvd_struct_t *s);
+
+ /*!
+ Return results of media status
+ @param p_cdio the CD object to be acted upon.
+ @param out_buf media status code from operation
+ @return DRIVER_OP_SUCCESS (0) if we got the status.
+ return codes are the same as driver_return_code_t
+ */
+ int mmc_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2]);
+
+ /*!
+ Find out if media tray is open or closed.
+ @param p_cdio the CD object to be acted upon.
+ @return 1 if media is open, 0 if closed. Error
+ return codes are the same as driver_return_code_t
+ */
+ int mmc_get_tray_status ( const CdIo_t *p_cdio );
+
+ /**
+ Get the CD-ROM hardware info via an MMC INQUIRY command.
+
+ @return true if we were able to get hardware info, false if we had
+ an error.
+ */
+ bool mmc_get_hwinfo ( const CdIo_t *p_cdio,
+ /* out*/ cdio_hwinfo_t *p_hw_info );
+
+
+ /**
+ Find out if media has changed since the last call.
+ @param p_cdio the CD object to be acted upon.
+ @return 1 if media has changed since last call, 0 if not. Error
+ return codes are the same as driver_return_code_t
+ */
+ int mmc_get_media_changed(const CdIo_t *p_cdio);
+
+ /**
+ Get the media catalog number (MCN) from the CD via MMC.
+
+ @return the media catalog number r NULL if there is none or we
+ don't have the ability to get it.
+
+ Note: string is malloc'd so caller has to free() the returned
+ string when done with it.
+
+ */
+ char * mmc_get_mcn ( const CdIo_t *p_cdio );
+
+ /** Get the output port volumes and port selections used on AUDIO PLAY
+ commands via a MMC MODE SENSE command using the CD Audio Control
+ Page.
+ */
+ driver_return_code_t mmc_audio_get_volume (CdIo_t *p_cdio, /*out*/
+ mmc_audio_volume_t *p_volume);
+
+ /**
+ Report if CD-ROM has a praticular kind of interface (ATAPI, SCSCI, ...)
+ Is it possible for an interface to have serveral? If not this
+ routine could probably return the single mmc_feature_interface_t.
+ @return true if we have the interface and false if not.
+ */
+ bool_3way_t mmc_have_interface( CdIo_t *p_cdio,
+ cdio_mmc_feature_interface_t e_interface );
+
+ /** Run a MODE_SENSE command (6- or 10-byte version)
+ and put the results in p_buf
+ @return DRIVER_OP_SUCCESS if we ran the command ok.
+ */
+ int mmc_mode_sense( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
+ int page);
+
+
+ /** Run a MODE_SENSE command (10-byte version)
+ and put the results in p_buf
+ @return DRIVER_OP_SUCCESS if we ran the command ok.
+ */
+ int mmc_mode_sense_10( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
+ int page);
+
+ /** Run a MODE_SENSE command (6-byte version)
+ and put the results in p_buf
+ @return DRIVER_OP_SUCCESS if we ran the command ok.
+ */
+ int mmc_mode_sense_6( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
+ int page);
+
+ /** Issue a MMC READ_CD command.
+
+ @param p_cdio object to read from
+
+ @param p_buf Place to store data. The caller should ensure that
+ p_buf can hold at least i_blocksize * i_blocks bytes.
+
+ @param i_lsn sector to read
+
+ @param expected_sector_type restricts reading to a specific CD
+ sector type. Only 3 bits with values 1-5 are used:
+ 0 all sector types
+ 1 CD-DA sectors only
+ 2 Mode 1 sectors only
+ 3 Mode 2 formless sectors only. Note in contrast to all other
+ values an MMC CD-ROM is not required to support this mode.
+ 4 Mode 2 Form 1 sectors only
+ 5 Mode 2 Form 2 sectors only
+
+ @param b_digital_audio_play Control error concealment when the
+ data being read is CD-DA. If the data being read is not CD-DA,
+ this parameter is ignored. If the data being read is CD-DA and
+ DAP is false zero, then the user data returned should not be
+ modified by flaw obscuring mechanisms such as audio data mute and
+ interpolate. If the data being read is CD-DA and DAP is true,
+ then the user data returned should be modified by flaw obscuring
+ mechanisms such as audio data mute and interpolate.
+
+ b_sync_header return the sync header (which will probably have
+ the same value as CDIO_SECTOR_SYNC_HEADER of size
+ CDIO_CD_SYNC_SIZE).
+
+ @param header_codes Header Codes refer to the sector header and
+ the sub-header that is present in mode 2 formed sectors:
+
+ 0 No header information is returned.
+ 1 The 4-byte sector header of data sectors is be returned,
+ 2 The 8-byte sector sub-header of mode 2 formed sectors is
+ returned.
+ 3 Both sector header and sub-header (12 bytes) is returned.
+ The Header preceeds the rest of the bytes (e.g. user-data bytes)
+ that might get returned.
+
+ @param b_user_data Return user data if true.
+
+ For CD-DA, the User Data is CDIO_CD_FRAMESIZE_RAW bytes.
+
+ For Mode 1, The User Data is ISO_BLOCKSIZE bytes beginning at
+ offset CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE.
+
+ For Mode 2 formless, The User Data is M2RAW_SECTOR_SIZE bytes
+ beginning at offset CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE.
+
+ For data Mode 2, form 1, User Data is ISO_BLOCKSIZE bytes beginning at
+ offset CDIO_CD_XA_SYNC_HEADER.
+
+ For data Mode 2, form 2, User Data is 2 324 bytes beginning at
+ offset CDIO_CD_XA_SYNC_HEADER.
+
+ @param b_sync
+
+ @param b_edc_ecc true if we return EDC/ECC error detection/correction bits.
+
+ The presence and size of EDC redundancy or ECC parity is defined
+ according to sector type:
+
+ CD-DA sectors have neither EDC redundancy nor ECC parity.
+
+ Data Mode 1 sectors have 288 bytes of EDC redundancy, Pad, and
+ ECC parity beginning at offset 2064.
+
+ Data Mode 2 formless sectors have neither EDC redundancy nor ECC
+ parity
+
+ Data Mode 2 form 1 sectors have 280 bytes of EDC redundancy and
+ ECC parity beginning at offset 2072
+
+ Data Mode 2 form 2 sectors optionally have 4 bytes of EDC
+ redundancy beginning at offset 2348.
+
+
+ @param c2_error_information If true associate a bit with each
+ sector for C2 error The resulting bit field is ordered exactly as
+ the main channel bytes. Each 8-bit boundary defines a byte of
+ flag bits.
+
+ @param subchannel_selection subchannel-selection bits
+
+ 0 No Sub-channel data shall be returned. (0 bytes)
+ 1 RAW P-W Sub-channel data shall be returned. (96 byte)
+ 2 Formatted Q sub-channel data shall be transferred (16 bytes)
+ 3 Reserved
+ 4 Corrected and de-interleaved R-W sub-channel (96 bytes)
+ 5-7 Reserved
+
+ @param i_blocksize size of the a block expected to be returned
+
+ @param i_blocks number of blocks expected to be returned.
+
+ */
+ driver_return_code_t
+ mmc_read_cd ( const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn,
+ int expected_sector_type, bool b_digital_audio_play,
+ bool b_sync, uint8_t header_codes, bool b_user_data,
+ bool b_edc_ecc, uint8_t c2_error_information,
+ uint8_t subchannel_selection, uint16_t i_blocksize,
+ uint32_t i_blocks );
+
+ /** Read just the user data part of some sort of data sector (via
+ mmc_read_cd).
+
+ @param p_cdio object to read from
+
+ @param p_buf place to read data into. The caller should make sure
+ this location can store at least CDIO_CD_FRAMESIZE,
+ M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE depending on
+ the kind of sector getting read. If you don't know
+ whether you have a Mode 1/2, Form 1/ Form 2/Formless
+ sector best to reserve space for the maximum,
+ M2RAW_SECTOR_SIZE.
+
+ @param i_lsn sector to read
+ @param i_blocksize size of each block
+ @param i_blocks number of blocks to read
+
+ */
+ driver_return_code_t mmc_read_data_sectors ( CdIo_t *p_cdio, void *p_buf,
+ lsn_t i_lsn,
+ uint16_t i_blocksize,
+ uint32_t i_blocks );
+
+ /** Read sectors using SCSI-MMC GPCMD_READ_CD.
+ Can read only up to 25 blocks.
+ */
+ driver_return_code_t mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf,
+ lsn_t i_lsn, int read_sector_type,
+ uint32_t i_blocks);
+
+ /**
+ Run a Multimedia command (MMC).
+
+ @param p_cdio CD structure set by cdio_open().
+ @param i_timeout_ms time in milliseconds we will wait for the command
+ to complete.
+ @param p_cdb CDB bytes. All values that are needed should be set
+ on input. We'll figure out what the right CDB length
+ should be.
+ @param e_direction direction the transfer is to go.
+ @param i_buf Size of buffer
+ @param p_buf Buffer for data, both sending and receiving.
+
+ @return 0 if command completed successfully.
+ */
+ driver_return_code_t
+ mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
+ const mmc_cdb_t *p_cdb,
+ cdio_mmc_direction_t e_direction, unsigned int i_buf,
+ /*in/out*/ void *p_buf );
+
+ /**
+ Run a Multimedia command (MMC) specifying the CDB length.
+ The motivation here is for example ot use in is an undocumented
+ debug command for LG drives (namely E7), whose length is being
+ miscalculated by mmc_get_cmd_len(); it doesn't follow the usual
+ code number to length conventions. Patch supplied by SukkoPera.
+
+ @param p_cdio CD structure set by cdio_open().
+ @param i_timeout_ms time in milliseconds we will wait for the command
+ to complete.
+ @param p_cdb CDB bytes. All values that are needed should be set
+ on input.
+ @param i_cdb number of CDB bytes.
+ @param e_direction direction the transfer is to go.
+ @param i_buf Size of buffer
+ @param p_buf Buffer for data, both sending and receiving.
+
+ @return 0 if command completed successfully.
+ */
+ driver_return_code_t
+ mmc_run_cmd_len( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
+ const mmc_cdb_t *p_cdb, unsigned int i_cdb,
+ cdio_mmc_direction_t e_direction, unsigned int i_buf,
+ /*in/out*/ void *p_buf );
+
+ /**
+ Set the block size for subsequest read requests, via MMC.
+ */
+ driver_return_code_t mmc_set_blocksize ( const CdIo_t *p_cdio,
+ uint16_t i_blocksize);
+
+ /**
+ Set the drive speed in CD-ROM speed units.
+
+ @param p_cdio CD structure set by cdio_open().
+ @param i_drive_speed speed in CD-ROM speed units. Note this
+ not Kbs as would be used in the MMC spec or
+ in mmc_set_speed(). To convert CD-ROM speed units
+ to Kbs, multiply the number by 176 (for raw data)
+ and by 150 (for filesystem data). On many CD-ROM
+ drives, specifying a value too large will result
+ in using the fastest speed.
+
+ @return the drive speed if greater than 0. -1 if we had an error. is -2
+ returned if this is not implemented for the current driver.
+
+ @see cdio_set_speed and mmc_set_speed
+ */
+ driver_return_code_t mmc_set_drive_speed( const CdIo_t *p_cdio,
+ int i_drive_speed );
+
+ /**
+ Set the drive speed in K bytes per second.
+
+ @param p_cdio CD structure set by cdio_open().
+ @param i_Kbs_speed speed in K bytes per second. Note this is
+ not in standard CD-ROM speed units, e.g.
+ 1x, 4x, 16x as it is in cdio_set_speed.
+ To convert CD-ROM speed units to Kbs,
+ multiply the number by 176 (for raw data)
+ and by 150 (for filesystem data).
+ Also note that ATAPI specs say that a value
+ less than 176 will result in an error.
+ On many CD-ROM drives,
+ specifying a value too large will result in using
+ the fastest speed.
+
+ @return the drive speed if greater than 0. -1 if we had an error. is -2
+ returned if this is not implemented for the current driver.
+
+ @see cdio_set_speed and mmc_set_drive_speed
+ */
+ driver_return_code_t mmc_set_speed( const CdIo_t *p_cdio,
+ int i_Kbs_speed );
+
+ /**
+ Load or Unload media using a MMC START STOP command.
+
+ @param p_cdio the CD object to be acted upon.
+ @param b_eject eject if true and close tray if false
+ @param b_immediate wait or don't wait for operation to complete
+ @param power_condition Set CD-ROM to idle/standby/sleep. If nonzero
+ eject/load is ignored, so set to 0 if you want to eject or load.
+
+ @see mmc_eject_media or mmc_close_tray
+ */
+ driver_return_code_t
+ mmc_start_stop_media(const CdIo_t *p_cdio, bool b_eject, bool b_immediate,
+ uint8_t power_condition);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/** The below variables are trickery to force the above enum symbol
+ values to be recorded in debug symbol tables. They are used to
+ allow one to refer to the enumeration value names in the typedefs
+ above in a debugger and debugger expressions
+*/
+extern cdio_mmc_feature_t debug_cdio_mmc_feature;
+extern cdio_mmc_feature_interface_t debug_cdio_mmc_feature_interface;
+extern cdio_mmc_feature_profile_t debug_cdio_mmc_feature_profile;
+extern cdio_mmc_get_conf_t debug_cdio_mmc_get_conf;
+extern cdio_mmc_gpcmd_t debug_cdio_mmc_gpcmd;
+extern cdio_mmc_read_sub_state_t debug_cdio_mmc_read_sub_state;
+extern cdio_mmc_read_cd_type_t debug_cdio_mmc_read_cd_type;
+extern cdio_mmc_readtoc_t debug_cdio_mmc_readtoc;
+extern cdio_mmc_mode_page_t debug_cdio_mmc_mode_page;
+
+#endif /* __MMC_H__ */
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/cdio/paranoia.h b/include/cdio/paranoia.h
new file mode 100644
index 00000000..02b50002
--- /dev/null
+++ b/include/cdio/paranoia.h
@@ -0,0 +1,202 @@
+/*
+ $Id: paranoia.h,v 1.15 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2004, 2005, 2006, 2007, 2008 Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 1998 Monty xiphmont@mit.edu
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file paranoia.h
+ *
+ * \brief The top-level header for libcdda_paranoia: a device- and OS-
+ * independent library for reading CD-DA with error tolerance and
+ * repair. Applications include this for paranoia access.
+ */
+
+#ifndef _CDIO_PARANOIA_H_
+#define _CDIO_PARANOIA_H_
+
+#include <cdio/cdda.h>
+
+/*! Paranoia likes to work with 16-bit numbers rather than
+ (possibly byte-swapped) bytes. So there are this many
+ 16-bit numbers block (frame, or sector) read.
+*/
+#define CD_FRAMEWORDS (CDIO_CD_FRAMESIZE_RAW/2)
+
+/**
+ Flags used in paranoia_modeset.
+
+ The enumeration type one probably wouldn't really use in a program.
+ It is here instead of defines to give symbolic names that can be
+ helpful in debuggers where wants just to say refer to
+ PARANOIA_MODE_DISABLE and get the correct value.
+*/
+
+typedef enum {
+ PARANOIA_MODE_DISABLE = 0x00, /**< No fixups */
+ PARANOIA_MODE_VERIFY = 0x01, /**< Verify data integrety in overlap area*/
+ PARANOIA_MODE_FRAGMENT = 0x02, /**< unsupported */
+ PARANOIA_MODE_OVERLAP = 0x04, /**< Perform overlapped reads */
+ PARANOIA_MODE_SCRATCH = 0x08, /**< unsupported */
+ PARANOIA_MODE_REPAIR = 0x10, /**< unsupported */
+ PARANOIA_MODE_NEVERSKIP = 0x20, /**< Do not skip failed reads (retry
+ maxretries) */
+ PARANOIA_MODE_FULL = 0xff, /**< Maximum paranoia - all of the above
+ (except disable) */
+} paranoia_mode_t;
+
+
+/**
+ Flags set in a callback.
+
+ The enumeration type one probably wouldn't really use in a program.
+ It is here instead of defines to give symbolic names that can be
+ helpful in debuggers where wants just to say refer to
+ PARANOIA_CB_READ and get the correct value.
+*/
+typedef enum {
+ PARANOIA_CB_READ, /**< Read off adjust ??? */
+ PARANOIA_CB_VERIFY, /**< Verifying jitter */
+ PARANOIA_CB_FIXUP_EDGE, /**< Fixed edge jitter */
+ PARANOIA_CB_FIXUP_ATOM, /**< Fixed atom jitter */
+ PARANOIA_CB_SCRATCH, /**< Unsupported */
+ PARANOIA_CB_REPAIR, /**< Unsupported */
+ PARANOIA_CB_SKIP, /**< Skip exhausted retry */
+ PARANOIA_CB_DRIFT, /**< Skip exhausted retry */
+ PARANOIA_CB_BACKOFF, /**< Unsupported */
+ PARANOIA_CB_OVERLAP, /**< Dynamic overlap adjust */
+ PARANOIA_CB_FIXUP_DROPPED, /**< Fixed dropped bytes */
+ PARANOIA_CB_FIXUP_DUPED, /**< Fixed duplicate bytes */
+ PARANOIA_CB_READERR /**< Hard read error */
+} paranoia_cb_mode_t;
+
+ extern const char *paranoia_cb_mode2str[];
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /*!
+ Get and initialize a new cdrom_paranoia object from cdrom_drive.
+ Run this before calling any of the other paranoia routines below.
+
+ @return new cdrom_paranoia object Call paranoia_free() when you are
+ done with it
+ */
+ extern cdrom_paranoia_t *cdio_paranoia_init(cdrom_drive_t *d);
+
+ /*!
+ Free any resources associated with p.
+
+ @param p paranoia object to for which resources are to be freed.
+
+ @see paranoia_init.
+ */
+ extern void cdio_paranoia_free(cdrom_paranoia_t *p);
+
+ /*!
+ Set the kind of repair you want to on for reading.
+ The modes are listed above
+
+ @param p paranoia type
+ @param mode_flags paranoia mode flags built from values in
+ paranoia_mode_t, e.g.
+ PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP
+ */
+ extern void cdio_paranoia_modeset(cdrom_paranoia_t *p, int mode_flags);
+
+ /*!
+ reposition reading offset.
+
+ @param p paranoia type
+ @param seek byte offset to seek to
+ @param whence like corresponding parameter in libc's lseek, e.g.
+ SEEK_SET or SEEK_END.
+ */
+ extern lsn_t cdio_paranoia_seek(cdrom_paranoia_t *p, off_t seek, int whence);
+
+ /*!
+ Reads the next sector of audio data and returns a pointer to a full
+ sector of verified samples.
+
+ @param p paranoia object.
+
+ @param callback callback routine which gets called with the status
+ on each read.
+
+ @return the audio data read, CDIO_CD_FRAMESIZE_RAW (2352)
+ bytes. This data is not to be freed by the caller. It will persist
+ only until the next call to paranoia_read() for this p.
+ */
+ extern int16_t *cdio_paranoia_read(cdrom_paranoia_t *p,
+ void(*callback)(long int,
+ paranoia_cb_mode_t));
+
+ /*! The same as cdio_paranoia_read but the number of retries is set.
+ @param p paranoia object.
+
+ @param callback callback routine which gets called with the status
+ on each read.
+
+ @param max_retries number of times to try re-reading a block before
+ failing.
+
+ @return the block of CDIO_FRAMEIZE_RAW bytes (or
+ CDIO_FRAMESIZE_RAW / 2 16-bit integers). Unless byte-swapping has
+ been turned off the 16-bit integers Endian independent order.
+
+ @see cdio_paranoia_read.
+
+ */
+ extern int16_t *cdio_paranoia_read_limited(cdrom_paranoia_t *p,
+ void(*callback)(long int,
+ paranoia_cb_mode_t),
+ int max_retries);
+
+
+/*! a temporary hack */
+ extern void cdio_paranoia_overlapset(cdrom_paranoia_t *p,long overlap);
+
+ extern void cdio_paranoia_set_range(cdrom_paranoia_t *p, long int start,
+ long int end);
+
+#ifndef DO_NOT_WANT_PARANOIA_COMPATIBILITY
+/** For compatibility with good ol' paranoia */
+#define cdrom_paranoia cdrom_paranoia_t
+#define paranoia_init cdio_paranoia_init
+#define paranoia_free cdio_paranoia_free
+#define paranoia_modeset cdio_paranoia_modeset
+#define paranoia_seek cdio_paranoia_seek
+#define paranoia_read cdio_paranoia_read
+#define paranoia_read_limited cdio_paranoia_read_limited
+#define paranoia_overlapset cdio_paranoia_overlapset
+#define paranoia_set_range cdio_paranoia_set_range
+#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
+
+#ifdef __cplusplus
+}
+#endif
+
+/** The below variables are trickery to force the above enum symbol
+ values to be recorded in debug symbol tables. They are used to
+ allow one to refer to the enumeration value names in the typedefs
+ above in a debugger and debugger expressions
+*/
+
+extern paranoia_mode_t debug_paranoia_mode;
+extern paranoia_cb_mode_t debug_paranoia_cb_mode;
+
+#endif /*_CDIO_PARANOIA_H_*/
diff --git a/include/cdio/posix.h b/include/cdio/posix.h
new file mode 100644
index 00000000..89e0ad37
--- /dev/null
+++ b/include/cdio/posix.h
@@ -0,0 +1,43 @@
+/*
+ $Id: posix.h,v 1.2 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2005, 2008 Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+/*!
+ * \file posix.h
+ *
+ * \brief various POSIX definitions.
+*/
+
+#ifndef __CDIO_POSIX_H__
+#define __CDIO_POSIX_H__
+
+typedef uint32_t posix_mode_t;
+typedef uint32_t posix_nlink_t;
+typedef uint32_t posix_uid_t;
+typedef uint32_t posix_gid_t;
+typedef uint16_t unicode16_t;
+
+#endif /* __CDIO_POSIX_H__ */
+
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/cdio/read.h b/include/cdio/read.h
new file mode 100644
index 00000000..81e5148a
--- /dev/null
+++ b/include/cdio/read.h
@@ -0,0 +1,235 @@
+/*
+ $Id: read.h,v 1.15 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2005, 2006, 2007, 2008 Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file read.h
+ *
+ * \brief The top-level header for sector (block, frame)-related
+ * libcdio calls.
+ */
+
+#ifndef __CDIO_READ_H__
+#define __CDIO_READ_H__
+
+#ifndef EXTERNAL_LIBCDIO_CONFIG_H
+#define EXTERNAL_LIBCDIO_CONFIG_H
+/* Need for HAVE_SYS_TYPES_H */
+#include <cdio/cdio_config.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+/* Some systems need this for off_t and ssize. */
+#include <sys/types.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /** All the different ways a block/sector can be read. */
+ typedef enum {
+ CDIO_READ_MODE_AUDIO, /**< CD-DA, audio, Red Book */
+ CDIO_READ_MODE_M1F1, /**< Mode 1 Form 1 */
+ CDIO_READ_MODE_M1F2, /**< Mode 1 Form 2 */
+ CDIO_READ_MODE_M2F1, /**< Mode 2 Form 1 */
+ CDIO_READ_MODE_M2F2 /**< Mode 2 Form 2 */
+ } cdio_read_mode_t;
+
+ /*!
+ Reposition read offset
+ Similar to (if not the same as) libc's fseek()
+
+ @param p_cdio object which gets adjusted
+ @param offset amount to seek
+ @param whence like corresponding parameter in libc's fseek, e.g.
+ SEEK_SET or SEEK_END.
+ @return (off_t) -1 on error.
+ */
+
+ off_t cdio_lseek(const CdIo_t *p_cdio, off_t offset, int whence);
+
+ /*! Reads into buf the next size bytes. Similar to (if not the
+ same as) libc's read(). This is a "cooked" read, or one handled by
+ the OS. It probably won't work on audio data. For that use
+ cdio_read_audio_sector(s).
+
+ @param p_cdio object to read from
+ @param p_buf place to read data into. The caller should make sure
+ this location can store at least i_size bytes.
+ @param i_size number of bytes to read
+
+ @return (ssize_t) -1 on error.
+ */
+ ssize_t cdio_read(const CdIo_t *p_cdio, void *p_buf, size_t i_size);
+
+ /*!
+ Read an audio sector
+
+ @param p_cdio object to read from
+ @param p_buf place to read data into. The caller should make sure
+ this location can store at least CDIO_FRAMESIZE_RAW
+ bytes.
+ @param i_lsn sector to read
+ */
+ driver_return_code_t cdio_read_audio_sector (const CdIo_t *p_cdio,
+ void *p_buf, lsn_t i_lsn);
+
+ /*!
+ Reads audio sectors
+
+ @param p_cdio object to read from
+ @param p_buf place to read data into. The caller should make sure
+ this location can store at least CDIO_FRAMESIZE_RAW
+ * i_blocks bytes.
+ @param i_lsn sector to read
+ @param i_blocks number of sectors to read
+ */
+ driver_return_code_t cdio_read_audio_sectors (const CdIo_t *p_cdio,
+ void *p_buf, lsn_t i_lsn,
+ uint32_t i_blocks);
+
+ /*!
+ Read data sectors
+
+ @param p_cdio object to read from
+ @param p_buf place to read data into. The caller should make sure
+ this location can store at least ISO_BLOCKSIZE,
+ M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE depending
+ on the kind of sector getting read. If you don't
+ know whether you have a Mode 1/2, Form 1/ Form 2/Formless
+ sector best to reserve space for the maximum,
+ M2RAW_SECTOR_SIZE.
+ @param i_lsn sector to read
+ @param i_blocksize size of block. Should be either CDIO_CD_FRAMESIZE,
+ M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE. See comment above under p_buf.
+
+ @param i_blocks number of blocks to read
+ */
+ driver_return_code_t cdio_read_data_sectors ( const CdIo_t *p_cdio,
+ void *p_buf, lsn_t i_lsn,
+ uint16_t i_blocksize,
+ uint32_t i_blocks );
+ /*!
+ Reads a mode 1 sector
+
+ @param p_cdio object to read from
+ @param p_buf place to read data into.
+ @param i_lsn sector to read
+ @param b_form2 true for reading mode 1 form 2 sectors or false for
+ mode 1 form 1 sectors.
+ */
+ driver_return_code_t cdio_read_mode1_sector (const CdIo_t *p_cdio,
+ void *p_buf, lsn_t i_lsn,
+ bool b_form2);
+ /*!
+ Reads mode 1 sectors
+
+ @param p_cdio object to read from
+ @param p_buf place to read data into
+ @param i_lsn sector to read
+ @param b_form2 true for reading mode 1 form 2 sectors or false for
+ mode 1 form 1 sectors.
+ @param i_blocks number of sectors to read
+ */
+ driver_return_code_t cdio_read_mode1_sectors (const CdIo_t *p_cdio,
+ void *p_buf, lsn_t i_lsn,
+ bool b_form2,
+ uint32_t i_blocks);
+ /*!
+ Reads a mode 2 sector
+
+ @param p_cdio object to read from
+ @param p_buf place to read data into. The caller should make sure
+ this location can store at least
+ M2RAW_SECTOR_SIZE (for form 1) or CDIO_CD_FRAMESIZE (for
+ form 2) bytes.
+ @param i_lsn sector to read
+ @param b_form2 true for reading mode 2 form 2 sectors or false for
+ mode 2 form 1 sectors.
+
+ @return 0 if no error, nonzero otherwise.
+ */
+ driver_return_code_t cdio_read_mode2_sector (const CdIo_t *p_cdio,
+ void *p_buf, lsn_t i_lsn,
+ bool b_form2);
+
+ /** The special case of reading a single block is a common one so we
+ provide a routine for that as a convenience.
+ */
+ driver_return_code_t cdio_read_sector(const CdIo_t *p_cdio, void *p_buf,
+ lsn_t i_lsn,
+ cdio_read_mode_t read_mode);
+ /*!
+ Reads mode 2 sectors
+
+ @param p_cdio object to read from
+ @param p_buf place to read data into. The caller should make sure
+ this location can store at least
+ M2RAW_SECTOR_SIZE (for form 1) or CDIO_CD_FRAMESIZE (for
+ form 2) * i_blocks bytes.
+ @param i_lsn sector to read
+ @param b_form2 true for reading mode2 form 2 sectors or false for
+ mode 2 form 1 sectors.
+ @param i_blocks number of sectors to read
+
+ @return 0 if no error, nonzero otherwise.
+ */
+ driver_return_code_t cdio_read_mode2_sectors (const CdIo_t *p_cdio,
+ void *p_buf, lsn_t i_lsn,
+ bool b_form2,
+ uint32_t i_blocks);
+
+ /*!
+ Reads a number of sectors (AKA blocks).
+
+ @param p_cdio cdio object
+ @param p_buf place to read data into. The caller should make sure
+ this location is large enough. See below for size information.
+ @param read_mode the kind of "mode" to use in reading.
+ @param i_lsn sector to read
+ @param i_blocks number of sectors to read
+ @return DRIVER_OP_SUCCESS (0) if no error, other (negative) enumerations
+ are returned on error.
+
+ If read_mode is CDIO_MODE_AUDIO,
+ *p_buf should hold at least CDIO_FRAMESIZE_RAW * i_blocks bytes.
+
+ If read_mode is CDIO_MODE_DATA,
+ *p_buf should hold at least i_blocks times either ISO_BLOCKSIZE,
+ M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of
+ sector getting read. If you don't know whether you have a Mode 1/2,
+ Form 1/ Form 2/Formless sector best to reserve space for the maximum
+ which is M2RAW_SECTOR_SIZE.
+
+ If read_mode is CDIO_MODE_M2F1,
+ *p_buf should hold at least M2RAW_SECTOR_SIZE * i_blocks bytes.
+
+ If read_mode is CDIO_MODE_M2F2,
+ *p_buf should hold at least CDIO_CD_FRAMESIZE * i_blocks bytes.
+
+ */
+ driver_return_code_t cdio_read_sectors(const CdIo_t *p_cdio, void *p_buf,
+ lsn_t i_lsn,
+ cdio_read_mode_t read_mode,
+ uint32_t i_blocks);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CDIO_TRACK_H__ */
diff --git a/include/cdio/rock.h b/include/cdio/rock.h
new file mode 100644
index 00000000..57003276
--- /dev/null
+++ b/include/cdio/rock.h
@@ -0,0 +1,396 @@
+/*
+ $Id: rock.h,v 1.15 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2005, 2006 2008 Rocky Bernstein <rocky@panix.com>
+
+ See also rock.c by Eric Youngdale (1993) from GNU/Linux
+ This is Copyright 1993 Yggdrasil Computing, Incorporated
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+/*!
+ \file rock.h
+ \brief Things related to the Rock Ridge Interchange Protocol (RRIP)
+
+ Applications will probably not include this directly but via
+ the iso9660.h header.
+*/
+
+
+#ifndef __CDIO_ROCK_H__
+#define __CDIO_ROCK_H__
+
+#include <cdio/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* MSYS 1.0.10 with MinGW 3.4.2 (and perhaps others) don't have
+ S_ISSOCK() or S_ISLNK() macros, so we'll roll our own. */
+#if !defined(HAVE_S_ISSOCK) && !defined(S_ISSOCK)
+#define S_ISSOCK(st_mode) ((((st_mode)) & 0170000) == (0140000))
+#endif
+
+#if !defined(HAVE_S_ISLNK) && !defined(S_ISLNK)
+#define S_ISLNK(st_mode) ((((st_mode)) & 0170000) == (0010000))
+#endif
+
+/*! An enumeration for some of the ISO_ROCK_* \#defines below. This isn't
+ really an enumeration one would really use in a program it is to
+ be helpful in debuggers where wants just to refer to the ISO_ROCK_*
+ names and get something.
+*/
+extern enum iso_rock_enums {
+ ISO_ROCK_IRUSR = 000400, /**< read permission (owner) */
+ ISO_ROCK_IWUSR = 000200, /**< write permission (owner) */
+ ISO_ROCK_IXUSR = 000100, /**< execute permission (owner) */
+ ISO_ROCK_IRGRP = 000040, /**< read permission (group) */
+ ISO_ROCK_IWGRP = 000020, /**< write permission (group) */
+ ISO_ROCK_IXGRP = 000010, /**< execute permission (group) */
+ ISO_ROCK_IROTH = 000004, /**< read permission (other) */
+ ISO_ROCK_IWOTH = 000002, /**< write permission (other) */
+ ISO_ROCK_IXOTH = 000001, /**< execute permission (other) */
+
+ ISO_ROCK_ISUID = 004000, /**< set user ID on execution */
+ ISO_ROCK_ISGID = 002000, /**< set group ID on execution */
+ ISO_ROCK_ISVTX = 001000, /**< save swapped text even after use */
+
+ ISO_ROCK_ISSOCK = 0140000, /**< socket */
+ ISO_ROCK_ISLNK = 0120000, /**< symbolic link */
+ ISO_ROCK_ISREG = 0100000, /**< regular */
+ ISO_ROCK_ISBLK = 060000, /**< block special */
+ ISO_ROCK_ISCHR = 020000, /**< character special */
+ ISO_ROCK_ISDIR = 040000, /**< directory */
+ ISO_ROCK_ISFIFO = 010000 /**< pipe or FIFO */
+} iso_rock_enums;
+
+#define ISO_ROCK_IRUSR 000400 /** read permission (owner) */
+#define ISO_ROCK_IWUSR 000200 /** write permission (owner) */
+#define ISO_ROCK_IXUSR 000100 /** execute permission (owner) */
+#define ISO_ROCK_IRGRP 000040 /** read permission (group) */
+#define ISO_ROCK_IWGRP 000020 /** write permission (group) */
+#define ISO_ROCK_IXGRP 000010 /** execute permission (group) */
+#define ISO_ROCK_IROTH 000004 /** read permission (other) */
+#define ISO_ROCK_IWOTH 000002 /** write permission (other) */
+#define ISO_ROCK_IXOTH 000001 /** execute permission (other) */
+
+#define ISO_ROCK_ISUID 004000 /** set user ID on execution */
+#define ISO_ROCK_ISGID 002000 /** set group ID on execution */
+#define ISO_ROCK_ISVTX 001000 /** save swapped text even after use */
+
+#define ISO_ROCK_ISSOCK 0140000 /** socket */
+#define ISO_ROCK_ISLNK 0120000 /** symbolic link */
+#define ISO_ROCK_ISREG 0100000 /** regular */
+#define ISO_ROCK_ISBLK 060000 /** block special */
+#define ISO_ROCK_ISCHR 020000 /** character special */
+#define ISO_ROCK_ISDIR 040000 /** directory */
+#define ISO_ROCK_ISFIFO 010000 /** pipe or FIFO */
+
+/** Enforced file locking (shared w/set group ID) */
+#define ISO_ROCK_ENFMT ISO_ROCK_ISGID
+
+PRAGMA_BEGIN_PACKED
+
+/*! The next two structs are used by the system-use-sharing protocol
+ (SUSP), in which the Rock Ridge extensions are embedded. It is
+ quite possible that other extensions are present on the disk, and
+ this is fine as long as they all use SUSP. */
+
+/*! system-use-sharing protocol */
+typedef struct iso_su_sp_s{
+ unsigned char magic[2];
+ uint8_t skip;
+} GNUC_PACKED iso_su_sp_t;
+
+/*! system-use extension record */
+typedef struct iso_su_er_s {
+ iso711_t len_id; /**< Identifier length. Value 10?. */
+ unsigned char len_des;
+ unsigned char len_src;
+ iso711_t ext_ver; /**< Extension version. Value 1? */
+ char data[EMPTY_ARRAY_SIZE];
+} GNUC_PACKED iso_su_er_t;
+
+typedef struct iso_su_ce_s {
+ char extent[8];
+ char offset[8];
+ char size[8];
+} iso_su_ce_t;
+
+/*! POSIX file attributes, PX. See Rock Ridge Section 4.1.2 */
+typedef struct iso_rock_px_s {
+ iso733_t st_mode; /*! file mode permissions; same as st_mode
+ of POSIX:5.6.1 */
+ iso733_t st_nlinks; /*! number of links to file; same as st_nlinks
+ of POSIX:5.6.1 */
+ iso733_t st_uid; /*! user id owner of file; same as st_uid
+ of POSIX:5.6.1 */
+ iso733_t st_gid; /*! group id of file; same as st_gid of
+ of POSIX:5.6.1 */
+} GNUC_PACKED iso_rock_px_t ;
+
+/*! POSIX device number, PN. A PN is mandatory if the file type
+ recorded in the "PX" File Mode field for a Directory Record
+ indicates a character or block device (ISO_ROCK_ISCHR |
+ ISO_ROCK_ISBLK). This entry is ignored for other (non-Direcotry)
+ file types. No more than one "PN" is recorded in the System Use Area
+ of a Directory Record.
+
+ See Rock Ridge Section 4.1.2 */
+typedef struct iso_rock_pn_s {
+ iso733_t dev_high; /**< high-order 32 bits of the 64 bit device number.
+ 7.2.3 encoded */
+ iso733_t dev_low; /**< low-order 32 bits of the 64 bit device number.
+ 7.2.3 encoded */
+} GNUC_PACKED iso_rock_pn_t ;
+
+/*! These are the bits and their meanings for flags in the SL structure. */
+typedef enum {
+ ISO_ROCK_SL_CONTINUE = 1,
+ ISO_ROCK_SL_CURRENT = 2,
+ ISO_ROCK_SL_PARENT = 4,
+ ISO_ROCK_SL_ROOT = 8
+} iso_rock_sl_flag_t;
+
+#define ISO_ROCK_SL_CONTINUE 1
+#define ISO_ROCK_SL_CURRENT 2
+#define ISO_ROCK_SL_PARENT 4
+#define ISO_ROCK_SL_ROOT 8
+
+typedef struct iso_rock_sl_part_s {
+ uint8_t flags;
+ uint8_t len;
+ char text[EMPTY_ARRAY_SIZE];
+} GNUC_PACKED iso_rock_sl_part_t ;
+
+/*! Symbolic link. See Rock Ridge Section 4.1.3 */
+typedef struct iso_rock_sl_s {
+ unsigned char flags;
+ iso_rock_sl_part_t link;
+} GNUC_PACKED iso_rock_sl_t ;
+
+/*! Alternate name. See Rock Ridge Section 4.1.4 */
+
+/*! These are the bits and their meanings for flags in the NM structure. */
+typedef enum {
+ ISO_ROCK_NM_CONTINUE = 1,
+ ISO_ROCK_NM_CURRENT = 2,
+ ISO_ROCK_NM_PARENT = 4,
+} iso_rock_nm_flag_t;
+
+#define ISO_ROCK_NM_CONTINUE 1
+#define ISO_ROCK_NM_CURRENT 2
+#define ISO_ROCK_NM_PARENT 4
+
+
+typedef struct iso_rock_nm_s {
+ unsigned char flags;
+ char name[EMPTY_ARRAY_SIZE];
+} GNUC_PACKED iso_rock_nm_t ;
+
+/*! Child link. See Section 4.1.5.1 */
+typedef struct iso_rock_cl_s {
+ char location[1];
+} GNUC_PACKED iso_rock_cl_t ;
+
+/*! Parent link. See Section 4.1.5.2 */
+typedef struct iso_rock_pl_s {
+ char location[1];
+} GNUC_PACKED iso_rock_pl_t ;
+
+/*! These are the bits and their meanings for flags in the TF structure. */
+typedef enum {
+ ISO_ROCK_TF_CREATE = 1,
+ ISO_ROCK_TF_MODIFY = 2,
+ ISO_ROCK_TF_ACCESS = 4,
+ ISO_ROCK_TF_ATTRIBUTES = 8,
+ ISO_ROCK_TF_BACKUP = 16,
+ ISO_ROCK_TF_EXPIRATION = 32,
+ ISO_ROCK_TF_EFFECTIVE = 64,
+ ISO_ROCK_TF_LONG_FORM = 128
+} iso_rock_tf_flag_t;
+
+/* These are the bits and their meanings for flags in the TF structure. */
+#define ISO_ROCK_TF_CREATE 1
+#define ISO_ROCK_TF_MODIFY 2
+#define ISO_ROCK_TF_ACCESS 4
+#define ISO_ROCK_TF_ATTRIBUTES 8
+#define ISO_ROCK_TF_BACKUP 16
+#define ISO_ROCK_TF_EXPIRATION 32
+#define ISO_ROCK_TF_EFFECTIVE 64
+#define ISO_ROCK_TF_LONG_FORM 128
+
+/*! Time stamp(s) for a file. See Rock Ridge Section 4.1.6 */
+typedef struct iso_rock_tf_s {
+ uint8_t flags; /**< See ISO_ROCK_TF_* bits above. */
+ uint8_t time_bytes[EMPTY_ARRAY_SIZE]; /**< A homogenious array of
+ iso9660_ltime_t or
+ iso9660_dtime_t entries
+ depending on flags &
+ ISO_ROCK_TF_LONG_FORM. Lacking
+ a better method, we store
+ this as an array of bytes
+ and a cast to the
+ appropriate type will have
+ to be made before
+ extraction. */
+} GNUC_PACKED iso_rock_tf_t ;
+
+/*! File data in sparse format. See Rock Ridge Section 4.1.7 */
+typedef struct iso_rock_sf_s {
+ iso733_t virtual_size_high; /**< high-order 32 bits of virtual size */
+ iso733_t virtual_size_low; /**< low-order 32 bits of virtual size */
+ uint8_t table_depth;
+} GNUC_PACKED iso_rock_sf_t ;
+
+typedef struct iso_extension_record_s {
+ char signature[2]; /**< signature word; either 'SP', 'CE', 'ER', 'RR',
+ 'PX', 'PN', 'SL', 'NM', 'CL', 'PL', 'TF', or
+ 'ZF' */
+ iso711_t len; /**< length of system-user area - 44 for PX
+ 20 for PN, 5+strlen(text) for SL, 21 for
+ SF, etc. */
+ iso711_t version; /**< version number - value 1 */
+ union {
+ iso_su_sp_t SP; /**< system-use-sharing protocol - not
+ strictly part of Rock Ridge */
+ iso_su_er_t ER; /**< system-use extension packet - not
+ strictly part of Rock Ridge */
+ iso_su_ce_t CE; /**< system-use - strictly part of Rock Ridge */
+ iso_rock_px_t PX; /**< Rock Ridge POSIX file attributes */
+ iso_rock_pn_t PN; /**< Rock Ridge POSIX device number */
+ iso_rock_sl_t SL; /**< Rock Ridge symbolic link */
+ iso_rock_nm_t NM; /**< Rock Ridge alternate name */
+ iso_rock_cl_t CL; /**< Rock Ridge child link */
+ iso_rock_pl_t PL; /**< Rock Ridge parent link */
+ iso_rock_tf_t TF; /**< Rock Ridge timestamp(s) for a file */
+ } u;
+} GNUC_PACKED iso_extension_record_t;
+
+typedef struct iso_rock_time_s {
+ bool b_used; /**< If true, field has been set and is valid.
+ Otherwise remaning fields are meaningless. */
+ bool b_longdate; /**< If true date format is a iso9660_ltime_t.
+ Otherwise date is iso9660_dtime_t */
+ union
+ {
+ iso9660_ltime_t ltime;
+ iso9660_dtime_t dtime;
+ } t;
+} GNUC_PACKED iso_rock_time_t;
+
+typedef struct iso_rock_statbuf_s {
+ bool_3way_t b3_rock; /**< has Rock Ridge extension.
+ If "yep", then the fields
+ are used.
+ */
+ posix_mode_t st_mode; /**< protection */
+ posix_nlink_t st_nlinks; /**< number of hard links */
+ posix_uid_t st_uid; /**< user ID of owner */
+ posix_gid_t st_gid; /**< group ID of owner */
+ uint8_t s_rock_offset;
+ int i_symlink; /**< size of psz_symlink */
+ int i_symlink_max; /**< max allocated to psz_symlink */
+ char *psz_symlink; /**< if symbolic link, name
+ of pointed to file. */
+ iso_rock_time_t create; /**< create time See ISO 9660:9.5.4. */
+ iso_rock_time_t modify; /**< time of last modification
+ ISO 9660:9.5.5. st_mtime field of
+ POSIX:5.6.1. */
+ iso_rock_time_t access; /**< time of last file access st_atime
+ field of POSIX:5.6.1. */
+ iso_rock_time_t attributes; /**< time of last attribute change.
+ st_ctime field of POSIX:5.6.1. */
+ iso_rock_time_t backup; /**< time of last backup. */
+ iso_rock_time_t expiration; /**< time of expiration; See ISO
+ 9660:9.5.6. */
+ iso_rock_time_t effective; /**< Effective time; See ISO 9660:9.5.7.
+ */
+ uint32_t i_rdev; /**< the upper 16-bits is major device
+ number, the lower 16-bits is the
+ minor device number */
+
+} iso_rock_statbuf_t;
+
+PRAGMA_END_PACKED
+
+/*! return length of name field; 0: not found, -1: to be ignored */
+int get_rock_ridge_filename(iso9660_dir_t * de, /*out*/ char * retname,
+ /*out*/ iso9660_stat_t *p_stat);
+
+ int parse_rock_ridge_stat(iso9660_dir_t *de, /*out*/ iso9660_stat_t *p_stat);
+
+ /*!
+ Returns POSIX mode bitstring for a given file.
+ */
+ mode_t
+ iso9660_get_posix_filemode_from_rock(const iso_rock_statbuf_t *rr);
+
+/*!
+ Returns a string which interpreting the POSIX mode st_mode.
+ For example:
+ \verbatim
+ drwxrws---
+ -rw---Sr--
+ lrwxrwxrwx
+ \endverbatim
+
+ A description of the characters in the string follows
+ The 1st character is either "d" if the entry is a directory, "l" is
+ a symbolic link or "-" if neither.
+
+ The 2nd to 4th characters refer to permissions for a user while the
+ the 5th to 7th characters refer to permissions for a group while, and
+ the 8th to 10h characters refer to permissions for everyone.
+
+ In each of these triplets the first character (2, 5, 8) is "r" if
+ the entry is allowed to be read.
+
+ The second character of a triplet (3, 6, 9) is "w" if the entry is
+ allowed to be written.
+
+ The third character of a triplet (4, 7, 10) is "x" if the entry is
+ executable but not user (for character 4) or group (for characters
+ 6) settable and "s" if the item has the corresponding user/group set.
+
+ For a directory having an executable property on ("x" or "s") means
+ the directory is allowed to be listed or "searched". If the execute
+ property is not allowed for a group or user but the corresponding
+ group/user is set "S" indicates this. If none of these properties
+ holds the "-" indicates this.
+*/
+const char *iso9660_get_rock_attr_str(posix_mode_t st_mode);
+
+/** These variables are not used, but are defined to facilatate debugging
+ by letting us use enumerations values (which also correspond to
+ \#define's inside a debugged program.
+ */
+extern iso_rock_nm_flag_t iso_rock_nm_flag;
+extern iso_rock_sl_flag_t iso_rock_sl_flag;
+extern iso_rock_tf_flag_t iso_rock_tf_flag;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __ISO_ROCK_H__ */
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/cdio/sector.h b/include/cdio/sector.h
new file mode 100644
index 00000000..6e308338
--- /dev/null
+++ b/include/cdio/sector.h
@@ -0,0 +1,286 @@
+/*
+ $Id: sector.h,v 1.38 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2003, 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+/*!
+ \file sector.h
+ \brief Things related to CD-ROM layout: tracks, sector sizes, MSFs, LBAs.
+
+ A CD-ROM physical sector size is 2048, 2052, 2056, 2324, 2332, 2336,
+ 2340, or 2352 bytes long.
+
+ Sector types of the standard CD-ROM data formats:
+
+\verbatim
+ format sector type user data size (bytes)
+ -----------------------------------------------------------------------------
+ 1 (Red Book) CD-DA 2352 (CDIO_CD_FRAMESIZE_RAW)
+ 2 (Yellow Book) Mode1 Form1 2048 (CDIO_CD_FRAMESIZE)
+ 3 (Yellow Book) Mode1 Form2 2336 (M2RAW_SECTOR_SIZE)
+ 4 (Green Book) Mode2 Form1 2048 (CDIO_CD_FRAMESIZE)
+ 5 (Green Book) Mode2 Form2 2328 (2324+4 spare bytes)
+
+
+ The layout of the standard CD-ROM data formats:
+ -----------------------------------------------------------------------------
+ - audio (red): | audio_sample_bytes |
+ | 2352 |
+
+ - data (yellow, mode1): | sync - head - data - EDC - zero - ECC |
+ | 12 - 4 - 2048 - 4 - 8 - 276 |
+
+ - data (yellow, mode2): | sync - head - data |
+ | 12 - 4 - 2336 |
+
+ - XA data (green, mode2 form1): | sync - head - sub - data - EDC - ECC |
+ | 12 - 4 - 8 - 2048 - 4 - 276 |
+
+ - XA data (green, mode2 form2): | sync - head - sub - data - Spare |
+ | 12 - 4 - 8 - 2324 - 4 |
+\endverbatim
+
+
+*/
+
+#ifndef _CDIO_SECTOR_H_
+#define _CDIO_SECTOR_H_
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#include <cdio/types.h>
+
+ /*! Information that can be obtained through a Read Subchannel
+ command.
+ */
+#define CDIO_SUBCHANNEL_SUBQ_DATA 0
+#define CDIO_SUBCHANNEL_CURRENT_POSITION 1
+#define CDIO_SUBCHANNEL_MEDIA_CATALOG 2
+#define CDIO_SUBCHANNEL_TRACK_ISRC 3
+
+ /*! track flags
+ * Q Sub-channel Control Field (4.2.3.3)
+ */
+ typedef enum {
+ NONE = 0x00, /* no flags set */
+ PRE_EMPHASIS = 0x01, /* audio track recorded with pre-emphasis */
+ COPY_PERMITTED = 0x02, /* digital copy permitted */
+ DATA = 0x04, /* data track */
+ FOUR_CHANNEL_AUDIO = 0x08, /* 4 audio channels */
+ SCMS = 0x10 /* SCMS (5.29.2.7) */
+ } flag_t;
+
+#define CDIO_PREGAP_SECTORS 150
+#define CDIO_POSTGAP_SECTORS 150
+
+ /*! An enumeration for some of the CDIO_CD \#defines below. This isn't
+ really an enumeration one would really use in a program it is to
+ be helpful in debuggers where wants just to refer to the CDIO_CD_
+ names and get something.
+ */
+ extern enum cdio_cd_enums {
+ CDIO_CD_MINS = 74, /**< max. minutes per CD, not really
+ a limit */
+ CDIO_CD_SECS_PER_MIN = 60, /**< seconds per minute */
+ CDIO_CD_FRAMES_PER_SEC = 75, /**< frames per second */
+ CDIO_CD_SYNC_SIZE = 12, /**< 12 sync bytes per raw data
+ frame */
+ CDIO_CD_CHUNK_SIZE = 24, /**< lowest-level "data bytes
+ piece" */
+ CDIO_CD_NUM_OF_CHUNKS = 98, /**< chunks per frame */
+ CDIO_CD_FRAMESIZE_SUB = 96, /**< subchannel data "frame" size */
+ CDIO_CD_HEADER_SIZE = 4, /**< header (address) bytes per raw
+ frame */
+ CDIO_CD_SUBHEADER_SIZE = 8, /**< subheader bytes per raw XA data
+ frame */
+ CDIO_CD_ECC_SIZE = 276, /**< bytes ECC per most raw data
+ frame types */
+ CDIO_CD_FRAMESIZE = 2048, /**< bytes per frame, "cooked"
+ mode */
+ CDIO_CD_FRAMESIZE_RAW = 2352, /**< bytes per frame, "raw" mode */
+ CDIO_CD_FRAMESIZE_RAWER = 2646, /**< The maximum possible
+ returned */
+ CDIO_CD_FRAMESIZE_RAW1 = 2340,
+ CDIO_CD_FRAMESIZE_RAW0 = 2336,
+ CDIO_CD_MAX_SESSIONS = 99,
+ CDIO_CD_MIN_SESSION_NO = 1, /**<, Smallest CD session number */
+ CDIO_CD_MAX_LSN = 450150, /**< Largest LSN in a CD */
+ CDIO_CD_MIN_LSN = -450150, /**< Smallest LSN in a CD */
+ } cdio_cd_enums;
+
+ /*!
+ Some generally useful CD-ROM information -- mostly based on the above.
+ This is from linux.h - not to slight other OS's. This was the first
+ place I came across such useful stuff.
+ */
+#define CDIO_CD_MINS 74 /**< max. minutes per CD, not really
+ a limit */
+#define CDIO_CD_SECS_PER_MIN 60 /**< seconds per minute */
+#define CDIO_CD_FRAMES_PER_SEC 75 /**< frames per second */
+#define CDIO_CD_SYNC_SIZE 12 /**< 12 sync bytes per raw data frame */
+#define CDIO_CD_CHUNK_SIZE 24 /**< lowest-level "data bytes piece" */
+#define CDIO_CD_NUM_OF_CHUNKS 98 /**< chunks per frame */
+#define CDIO_CD_FRAMESIZE_SUB 96 /**< subchannel data "frame" size */
+#define CDIO_CD_HEADER_SIZE 4 /**< header (address) bytes per raw
+ data frame */
+#define CDIO_CD_SUBHEADER_SIZE 8 /**< subheader bytes per raw XA data
+ frame */
+#define CDIO_CD_EDC_SIZE 4 /**< bytes EDC per most raw data
+ frame types */
+#define CDIO_CD_M1F1_ZERO_SIZE 8 /**< bytes zero per yellow book mode
+ 1 frame */
+#define CDIO_CD_ECC_SIZE 276 /**< bytes ECC per most raw data frame
+ types */
+#define CDIO_CD_FRAMESIZE 2048 /**< bytes per frame, "cooked" mode */
+#define CDIO_CD_FRAMESIZE_RAW 2352 /**< bytes per frame, "raw" mode */
+#define CDIO_CD_FRAMESIZE_RAWER 2646 /**< The maximum possible returned
+ bytes */
+#define CDIO_CD_FRAMESIZE_RAW1 (CDIO_CD_CD_FRAMESIZE_RAW-CDIO_CD_SYNC_SIZE) /*2340*/
+#define CDIO_CD_FRAMESIZE_RAW0 (CDIO_CD_FRAMESIZE_RAW-CDIO_CD_SYNC_SIZE-CDIO_CD_HEADER_SIZE) /*2336*/
+
+ /*! "before data" part of raw XA (green, mode2) frame */
+#define CDIO_CD_XA_HEADER (CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE)
+
+ /*! "after data" part of raw XA (green, mode2 form1) frame */
+#define CDIO_CD_XA_TAIL (CDIO_CD_EDC_SIZE+CDIO_CD_ECC_SIZE)
+
+ /*! "before data" sync bytes + header of XA (green, mode2) frame */
+#define CDIO_CD_XA_SYNC_HEADER (CDIO_CD_SYNC_SIZE+CDIO_CD_XA_HEADER)
+
+ /*! String of bytes used to identify the beginning of a Mode 1 or
+ Mode 2 sector. */
+ extern const uint8_t CDIO_SECTOR_SYNC_HEADER[CDIO_CD_SYNC_SIZE];
+ /**<
+ {0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0};
+ */
+
+ /*! An enumeration for some of the M2*_SECTOR_SIZE \#defines
+ below. This isn't really an enumeration one would really use in a
+ program it is to be helpful in debuggers where wants just to refer
+ to the M2*_SECTOR_SIZE names and get something.
+ */
+ extern enum m2_sector_enums {
+ M2F2_SECTOR_SIZE = 2324,
+ M2SUB_SECTOR_SIZE = 2332,
+ M2RAW_SECTOR_SIZE = 2336
+ } m2_sector_enums;
+
+#define M2F2_SECTOR_SIZE 2324
+#define M2SUB_SECTOR_SIZE 2332
+#define M2RAW_SECTOR_SIZE 2336
+
+ /*! Largest CD session number */
+#define CDIO_CD_MAX_SESSIONS 99
+ /*! Smallest CD session number */
+#define CDIO_CD_MIN_SESSION_NO 1
+
+ /*! Largest LSN in a CD */
+#define CDIO_CD_MAX_LSN 450150
+ /*! Smallest LSN in a CD */
+#define CDIO_CD_MIN_LSN -450150
+
+
+#define CDIO_CD_FRAMES_PER_MIN \
+ (CDIO_CD_FRAMES_PER_SEC*CDIO_CD_SECS_PER_MIN)
+
+#define CDIO_CD_74MIN_SECTORS (UINT32_C(74)*CDIO_CD_FRAMES_PER_MIN)
+#define CDIO_CD_80MIN_SECTORS (UINT32_C(80)*CDIO_CD_FRAMES_PER_MIN)
+#define CDIO_CD_90MIN_SECTORS (UINT32_C(90)*CDIO_CD_FRAMES_PER_MIN)
+
+#define CDIO_CD_MAX_SECTORS \
+ (UINT32_C(100)*CDIO_CD_FRAMES_PER_MIN-CDIO_PREGAP_SECTORS)
+
+#define msf_t_SIZEOF 3
+
+ /*!
+ Convert an LBA into a string representation of the MSF.
+ \warning cdio_lba_to_msf_str returns new allocated string */
+ char *cdio_lba_to_msf_str (lba_t i_lba);
+
+ /*!
+ Convert an MSF into a string representation of the MSF.
+ \warning cdio_msf_to_msf_str returns new allocated string */
+ char *cdio_msf_to_str (const msf_t *p_msf);
+
+ /*!
+ Convert an LBA into the corresponding LSN.
+ */
+ lba_t cdio_lba_to_lsn (lba_t i_lba);
+
+ /*!
+ Convert an LBA into the corresponding MSF.
+ */
+ void cdio_lba_to_msf(lba_t i_lba, msf_t *p_msf);
+
+ /*!
+ Convert an LSN into the corresponding LBA.
+ CDIO_INVALID_LBA is returned if there is an error.
+ */
+ lba_t cdio_lsn_to_lba (lsn_t i_lsn);
+
+ /*!
+ Convert an LSN into the corresponding MSF.
+ */
+ void cdio_lsn_to_msf (lsn_t i_lsn, msf_t *p_msf);
+
+ /*!
+ Convert a MSF into the corresponding LBA.
+ CDIO_INVALID_LBA is returned if there is an error.
+ */
+ lba_t cdio_msf_to_lba (const msf_t *p_msf);
+
+ /*!
+ Convert a MSF into the corresponding LSN.
+ CDIO_INVALID_LSN is returned if there is an error.
+ */
+ lsn_t cdio_msf_to_lsn (const msf_t *p_msf);
+
+ /*!
+ Convert a MSF - broken out as 3 integer components into the
+ corresponding LBA.
+ CDIO_INVALID_LBA is returned if there is an error.
+ */
+ lba_t cdio_msf3_to_lba (unsigned int minutes, unsigned int seconds,
+ unsigned int frames);
+
+ /*!
+ Convert a string of the form MM:SS:FF into the corresponding LBA.
+ CDIO_INVALID_LBA is returned if there is an error.
+ */
+ lba_t cdio_mmssff_to_lba (const char *psz_mmssff);
+
+#ifdef __cplusplus
+ }
+#endif
+
+#ifndef DO_NOT_WANT_PARANOIA_COMPATIBILITY
+/** For compatibility with good ol' paranoia */
+#define CD_FRAMESIZE_RAW CDIO_CD_FRAMESIZE_RAW
+#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
+
+#endif /* _CDIO_SECTOR_H_ */
+
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/cdio/track.h b/include/cdio/track.h
new file mode 100644
index 00000000..9deb942b
--- /dev/null
+++ b/include/cdio/track.h
@@ -0,0 +1,269 @@
+/*
+ $Id: track.h,v 1.14 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file track.h
+ * \brief The top-level header for track-related libcdio calls.
+ */
+#ifndef __CDIO_TRACK_H__
+#define __CDIO_TRACK_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /*! Printable tags for track_format_t enumeration. */
+ extern const char *track_format2str[6];
+
+ typedef enum {
+ TRACK_FORMAT_AUDIO, /**< Audio track, e.g. CD-DA */
+ TRACK_FORMAT_CDI, /**< CD-i. How this is different from DATA below? */
+ TRACK_FORMAT_XA, /**< Mode2 of some sort */
+ TRACK_FORMAT_DATA, /**< Mode1 of some sort */
+ TRACK_FORMAT_PSX, /**< Playstation CD. Like audio but only 2336 bytes
+ * of user data.
+ */
+ TRACK_FORMAT_ERROR /**< Dunno what is, or some other error. */
+ } track_format_t;
+
+ typedef enum {
+ CDIO_TRACK_FLAG_FALSE,
+ CDIO_TRACK_FLAG_TRUE,
+ CDIO_TRACK_FLAG_ERROR,
+ CDIO_TRACK_FLAG_UNKNOWN
+ } track_flag_t;
+
+ /*! \brief Structure containing attributes associated with a track */
+ typedef struct {
+ track_flag_t preemphasis; /**< Linear preemphasis on an audio track */
+ track_flag_t copy_permit; /**< Whether copying is permitted */
+ int channels; /**< Number of audio channels, 2, 4. -2 if not
+ implemented or -1 for error.
+ */
+ } track_flags_t;
+
+ /*! The leadout track is always 0xAA, regardless of # of tracks on
+ disc, or what value may be used internally. For example although
+ OS X uses a different value for the lead-out track internally than
+ given below, programmers should use CDIO_CDROM_LEADOUT_TRACK and
+ not worry about this.
+ */
+
+ /*! An enumeration for some of the CDIO_CDROM_* \#defines below. This
+ isn't really an enumeration one would really use in a program; it
+ is to be helpful in debuggers where wants just to refer to the
+ CDIO_CDROM_* names and get something.
+ */
+ extern enum cdio_track_enums {
+ CDIO_CDROM_LBA = 0x01, /**< "logical block": first frame is #0 */
+ CDIO_CDROM_MSF = 0x02, /**< "minute-second-frame": binary, not
+ BCD here! */
+ CDIO_CDROM_DATA_TRACK = 0x04,
+ CDIO_CDROM_CDI_TRACK = 0x10,
+ CDIO_CDROM_XA_TRACK = 0x20,
+ CDIO_CD_MAX_TRACKS = 99, /**< Largest CD track number */
+ CDIO_CDROM_LEADOUT_TRACK = 0xAA, /**< Lead-out track number */
+ CDIO_INVALID_TRACK = 0xFF, /**< Constant for invalid track number */
+
+ } cdio_track_enums;
+
+#define CDIO_CD_MIN_TRACK_NO 1 /**< Smallest CD track number */
+
+ /*! track modes (Table 350)
+ reference: MMC-3 draft revsion - 10g
+ */
+ typedef enum {
+ AUDIO, /**< 2352 byte block length */
+ MODE1, /**< 2048 byte block length */
+ MODE1_RAW, /**< 2352 byte block length */
+ MODE2, /**< 2336 byte block length */
+ MODE2_FORM1, /**< 2048 byte block length */
+ MODE2_FORM2, /**< 2324 byte block length */
+ MODE2_FORM_MIX, /**< 2336 byte block length */
+ MODE2_RAW /**< 2352 byte block length */
+ } trackmode_t;
+
+ /*!
+ Get CD-Text information for a CdIo_t object.
+
+ @param p_cdio the CD object that may contain CD-Text information.
+ @param i_track track for which we are requesting CD-Text information.
+ @return the CD-Text object or NULL if obj is NULL
+ or CD-Text information does not exist.
+
+ If i_track is 0 or CDIO_CDROM_LEADOUT_TRACK the track returned
+ is the information assocated with the CD.
+ */
+ cdtext_t *cdio_get_cdtext (CdIo_t *p_cdio, track_t i_track);
+
+ /*!
+ Get the number of the first track.
+
+ @return the track number or CDIO_INVALID_TRACK
+ on error.
+ */
+ track_t cdio_get_first_track_num(const CdIo_t *p_cdio);
+
+ /*!
+ Return the last track number.
+ CDIO_INVALID_TRACK is returned on error.
+ */
+ track_t cdio_get_last_track_num (const CdIo_t *p_cdio);
+
+
+ /*! Find the track which contains lsn.
+ CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
+ if there was some error.
+
+ If the lsn is before the pregap of the first track 0 is returned.
+ Otherwise we return the track that spans the lsn.
+ */
+ track_t cdio_get_track(const CdIo_t *p_cdio, lsn_t lsn);
+
+ /*! Return number of channels in track: 2 or 4; -2 if not
+ implemented or -1 for error.
+ Not meaningful if track is not an audio track.
+ */
+ int cdio_get_track_channels(const CdIo_t *p_cdio, track_t i_track);
+
+ /*! Return copy protection status on a track. Is this meaningful
+ if not an audio track?
+ */
+ track_flag_t cdio_get_track_copy_permit(const CdIo_t *p_cdio,
+ track_t i_track);
+
+ /*!
+ Get the format (audio, mode2, mode1) of track.
+ */
+ track_format_t cdio_get_track_format(const CdIo_t *p_cdio, track_t i_track);
+
+ /*!
+ Return true if we have XA data (green, mode2 form1) or
+ XA data (green, mode2 form2). That is track begins:
+ sync - header - subheader
+ 12 4 - 8
+
+ FIXME: there's gotta be a better design for this and get_track_format?
+ */
+ bool cdio_get_track_green(const CdIo_t *p_cdio, track_t i_track);
+
+ /*!
+ Return the ending LSN for track number
+ i_track in cdio. CDIO_INVALID_LSN is returned on error.
+ */
+ lsn_t cdio_get_track_last_lsn(const CdIo_t *p_cdio, track_t i_track);
+
+ /*!
+ Get the starting LBA for track number
+ i_track in p_cdio. Track numbers usually start at something
+ greater than 0, usually 1.
+
+ The "leadout" track is specified either by
+ using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1.
+
+ @param p_cdio object to get information from
+ @param i_track the track number we want the LSN for
+ @return the starting LBA or CDIO_INVALID_LBA on error.
+ */
+ lba_t cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track);
+
+ /*!
+ Return the starting LSN for track number
+ i_track in p_cdio. Track numbers usually start at something
+ greater than 0, usually 1.
+
+ The "leadout" track is specified either by
+ using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1.
+
+ @param p_cdio object to get information from
+ @param i_track the track number we want the LSN for
+ @return the starting LSN or CDIO_INVALID_LSN on error.
+ */
+ lsn_t cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track);
+
+ /*!
+ Return the starting LBA for the pregap for track number
+ i_track in p_cdio. Track numbers usually start at something
+ greater than 0, usually 1.
+
+ @param p_cdio object to get information from
+ @param i_track the track number we want the LBA for
+ @return the starting LBA or CDIO_INVALID_LBA on error.
+ */
+ lba_t cdio_get_track_pregap_lba(const CdIo_t *p_cdio, track_t i_track);
+
+ /*!
+ Return the starting LSN for the pregap for track number
+ i_track in p_cdio. Track numbers usually start at something
+ greater than 0, usually 1.
+
+ @param p_cdio object to get information from
+ @param i_track the track number we want the LSN for
+ @return the starting LSN or CDIO_INVALID_LSN on error.
+ */
+ lsn_t cdio_get_track_pregap_lsn(const CdIo_t *p_cdio, track_t i_track);
+
+ /*!
+ Get the International Standard Recording Code (ISRC) for track number
+ i_track in p_cdio. Track numbers usually start at something
+ greater than 0, usually 1.
+
+ @return the International Standard Recording Code (ISRC) or NULL
+ if there is none or we don't have the ability to get it.
+
+ Note: string is malloc'd so caller has to free() the returned
+ string when done with it.
+
+ */
+ char * cdio_get_track_isrc (const CdIo_t *p_cdio, track_t i_track);
+
+ /*!
+ Return the starting MSF (minutes/secs/frames) for track number
+ i_track in p_cdio. Track numbers usually start at something
+ greater than 0, usually 1.
+
+ The "leadout" track is specified either by
+ using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1.
+
+ @return true if things worked or false if there is no track entry.
+ */
+ bool cdio_get_track_msf(const CdIo_t *p_cdio, track_t i_track,
+ /*out*/ msf_t *msf);
+
+ /*! Get linear preemphasis status on an audio track
+ This is not meaningful if not an audio track?
+ */
+ track_flag_t cdio_get_track_preemphasis(const CdIo_t *p_cdio,
+ track_t i_track);
+
+ /*!
+ Get the number of sectors between this track an the next. This
+ includes any pregap sectors before the start of the next track.
+ Track numbers usually start at something
+ greater than 0, usually 1.
+
+ @return the number of sectors or 0 if there is an error.
+ */
+ unsigned int cdio_get_track_sec_count(const CdIo_t *p_cdio, track_t i_track);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CDIO_TRACK_H__ */
+
diff --git a/include/cdio/types.h b/include/cdio/types.h
new file mode 100644
index 00000000..347bf5a7
--- /dev/null
+++ b/include/cdio/types.h
@@ -0,0 +1,327 @@
+/*
+ $Id: types.h,v 1.37 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008
+ Rocky Bernstein <rocky@gnu.org>
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/** \file types.h
+ * \brief Common type definitions used pervasively in libcdio.
+ */
+
+
+#ifndef __CDIO_TYPES_H__
+#define __CDIO_TYPES_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifndef EXTERNAL_LIBCDIO_CONFIG_H
+#define EXTERNAL_LIBCDIO_CONFIG_H
+#include <cdio/cdio_config.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+ /* provide some C99 definitions */
+
+#if defined(HAVE_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
+#if defined(HAVE_STDINT_H)
+# include <stdint.h>
+#elif defined(HAVE_INTTYPES_H)
+# include <inttypes.h>
+#elif defined(AMIGA) || defined(__linux__)
+ typedef u_int8_t uint8_t;
+ typedef u_int16_t uint16_t;
+ typedef u_int32_t uint32_t;
+ typedef u_int64_t uint64_t;
+#else
+ /* warning ISO/IEC 9899:1999 <stdint.h> was missing and even <inttypes.h> */
+ /* fixme */
+#endif /* HAVE_STDINT_H */
+
+typedef uint8_t ubyte;
+
+ /* default HP/UX macros are broken */
+#if defined(__hpux__)
+# undef UINT16_C
+# undef UINT32_C
+# undef UINT64_C
+# undef INT64_C
+#endif
+
+ /* if it's still not defined, take a good guess... should work for
+ most 32bit and 64bit archs */
+
+#ifndef UINT16_C
+# define UINT16_C(c) c ## U
+#endif
+
+#ifndef UINT32_C
+# if defined (SIZEOF_INT) && SIZEOF_INT == 4
+# define UINT32_C(c) c ## U
+# elif defined (SIZEOF_LONG) && SIZEOF_LONG == 4
+# define UINT32_C(c) c ## UL
+# else
+# define UINT32_C(c) c ## U
+# endif
+#endif
+
+#ifndef UINT64_C
+# if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
+# define UINT64_C(c) c ## UL
+# elif defined (SIZEOF_INT) && SIZEOF_INT == 8
+# define UINT64_C(c) c ## U
+# else
+# define UINT64_C(c) c ## ULL
+# endif
+#endif
+
+#ifndef INT64_C
+# if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
+# define INT64_C(c) c ## L
+# elif defined (SIZEOF_INT) && SIZEOF_INT == 8
+# define INT64_C(c) c
+# else
+# define INT64_C(c) c ## LL
+# endif
+#endif
+
+#ifndef __cplusplus
+# if defined(HAVE_STDBOOL_H)
+# include <stdbool.h>
+# else
+ /* ISO/IEC 9899:1999 <stdbool.h> missing -- enabling workaround */
+
+# define false 0
+# define true 1
+# define bool uint8_t
+# endif /*HAVE_STDBOOL_H*/
+#endif /*C++*/
+
+ /* some GCC optimizations -- gcc 2.5+ */
+
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#define GNUC_PRINTF( format_idx, arg_idx ) \
+ __attribute__((format (printf, format_idx, arg_idx)))
+#define GNUC_SCANF( format_idx, arg_idx ) \
+ __attribute__((format (scanf, format_idx, arg_idx)))
+#define GNUC_FORMAT( arg_idx ) \
+ __attribute__((format_arg (arg_idx)))
+#define GNUC_NORETURN \
+ __attribute__((noreturn))
+#define GNUC_CONST \
+ __attribute__((const))
+#define GNUC_UNUSED \
+ __attribute__((unused))
+#define GNUC_PACKED \
+ __attribute__((packed))
+#else /* !__GNUC__ */
+#define GNUC_PRINTF( format_idx, arg_idx )
+#define GNUC_SCANF( format_idx, arg_idx )
+#define GNUC_FORMAT( arg_idx )
+#define GNUC_NORETURN
+#define GNUC_CONST
+#define GNUC_UNUSED
+#define GNUC_PACKED
+#endif /* !__GNUC__ */
+
+#if defined(__GNUC__)
+ /* for GCC we try to use GNUC_PACKED */
+# define PRAGMA_BEGIN_PACKED
+# define PRAGMA_END_PACKED
+#elif defined(HAVE_ISOC99_PRAGMA)
+ /* should work with most EDG-frontend based compilers */
+# define PRAGMA_BEGIN_PACKED _Pragma("pack(1)")
+# define PRAGMA_END_PACKED _Pragma("pack()")
+#else /* neither gcc nor _Pragma() available... */
+ /* ...so let's be naive and hope the regression testsuite is run... */
+# define PRAGMA_BEGIN_PACKED
+# define PRAGMA_END_PACKED
+#endif
+
+ /*
+ * user directed static branch prediction gcc 2.96+
+ */
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
+# define GNUC_LIKELY(x) __builtin_expect((x),true)
+# define GNUC_UNLIKELY(x) __builtin_expect((x),false)
+#else
+# define GNUC_LIKELY(x) (x)
+# define GNUC_UNLIKELY(x) (x)
+#endif
+
+#ifndef NULL
+# define NULL ((void*) 0)
+#endif
+
+ /* our own offsetof()-like macro */
+#define __cd_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+
+ /*!
+ \brief MSF (minute/second/frame) structure
+
+ One CD-ROMs addressing scheme especially used in audio formats
+ (Red Book) is an address by minute, sector and frame which
+ BCD-encoded in three bytes. An alternative format is an lba_t.
+
+ Note: the fields in this structure are BCD encoded. Use
+ cdio_to_bcd8() or cdio_from_bcd8() to convert an integer into or
+ out of this format. The format specifier %x (not %d) can be used
+ if you need to format or print values in this structure.
+
+ @see lba_t
+ */
+ PRAGMA_BEGIN_PACKED
+ struct msf_s {
+ uint8_t m, s, f; /* BCD encoded! */
+ } GNUC_PACKED;
+ PRAGMA_END_PACKED
+
+ typedef struct msf_s msf_t;
+
+#define msf_t_SIZEOF 3
+
+ /*!
+ \brief UTF-8 char definition
+
+ Type to denote UTF-8 strings.
+ */
+
+ typedef char cdio_utf8_t;
+
+ typedef enum {
+ nope = 0,
+ yep = 1,
+ dunno = 2
+ } bool_3way_t;
+
+ /* type used for bit-fields in structs (1 <= bits <= 8) */
+#if defined(__GNUC__)
+ /* this is strict ISO C99 which allows only 'unsigned int', 'signed
+ int' and '_Bool' explicitly as bit-field type */
+ typedef unsigned int bitfield_t;
+#else
+ /* other compilers might increase alignment requirements to match the
+ 'unsigned int' type -- fixme: find out how unalignment accesses can
+ be pragma'ed on non-gcc compilers */
+ typedef uint8_t bitfield_t;
+#endif
+
+ /*! The type of a Logical Block Address. We allow for an lba to be
+ negative to be consistent with an lba, although I'm not sure this
+ this is possible.
+
+ */
+ typedef int32_t lba_t;
+
+ /*! The type of a Logical Sector Number. Note that an lba can be negative
+ and the MMC3 specs allow for a conversion of a negative lba.
+
+ @see msf_t
+ */
+ typedef int32_t lsn_t;
+
+ /* Address in either MSF or logical format */
+ union cdio_cdrom_addr
+ {
+ msf_t msf;
+ lba_t lba;
+ };
+
+ /*! The type of a track number 0..99. */
+ typedef uint8_t track_t;
+
+ /*! The type of a session number 0..99. */
+ typedef uint8_t session_t;
+
+ /*!
+ Constant for invalid session number
+ */
+#define CDIO_INVALID_SESSION 0xFF
+
+ /*!
+ Constant for invalid LBA. It is 151 less than the most negative
+ LBA -45150. This provide slack for the 150-frame offset in
+ LBA to LSN 150 conversions
+ */
+#define CDIO_INVALID_LBA -45301
+
+ /*!
+ Constant for invalid LSN
+ */
+#define CDIO_INVALID_LSN CDIO_INVALID_LBA
+
+ /*!
+ Number of ASCII bytes in a media catalog number (MCN).
+ */
+#define CDIO_MCN_SIZE 13
+
+ /*!
+ Type to hold ASCII bytes in a media catalog number (MCN).
+ We include an extra 0 byte so these can be used as C strings.
+ */
+ typedef char cdio_mcn_t[CDIO_MCN_SIZE+1];
+
+
+ /*!
+ Number of ASCII bytes in International Standard Recording Codes (ISRC)
+ */
+#define CDIO_ISRC_SIZE 12
+
+ /*!
+ Type to hold ASCII bytes in a media catalog number (MCN).
+ We include an extra 0 byte so these can be used as C strings.
+ */
+ typedef char cdio_isrc_t[CDIO_ISRC_SIZE+1];
+
+ typedef int cdio_fs_anal_t;
+
+ /*!
+ track flags
+ Q Sub-channel Control Field (4.2.3.3)
+ */
+ typedef enum {
+ CDIO_TRACK_FLAG_NONE = 0x00, /**< no flags set */
+ CDIO_TRACK_FLAG_PRE_EMPHASIS = 0x01, /**< audio track recorded with
+ pre-emphasis */
+ CDIO_TRACK_FLAG_COPY_PERMITTED = 0x02, /**< digital copy permitted */
+ CDIO_TRACK_FLAG_DATA = 0x04, /**< data track */
+ CDIO_TRACK_FLAG_FOUR_CHANNEL_AUDIO = 0x08, /**< 4 audio channels */
+ CDIO_TRACK_FLAG_SCMS = 0x10 /**< SCMS (5.29.2.7) */
+} cdio_track_flag;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CDIO_TYPES_H__ */
+
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/cdio/udf.h b/include/cdio/udf.h
new file mode 100644
index 00000000..e35d74d1
--- /dev/null
+++ b/include/cdio/udf.h
@@ -0,0 +1,171 @@
+/*
+ $Id: udf.h,v 1.22 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/*!
+ * \file udf.h
+ *
+ * \brief The top-level interface header for libudf: UDF filesystem
+ * library; applications include this.
+ *
+*/
+
+#ifndef UDF_H
+#define UDF_H
+
+#include <cdio/cdio.h>
+#include <cdio/ecma_167.h>
+#include <cdio/posix.h>
+
+typedef uint16_t partition_num_t;
+
+/** Opaque structures. */
+typedef struct udf_s udf_t;
+typedef struct udf_file_s udf_file_t;
+typedef struct udf_dirent_s udf_dirent_t;
+
+/**
+ Imagine the below a \#define'd value rather than distinct values of
+ an enum.
+*/
+typedef enum {
+ UDF_BLOCKSIZE = 2048
+} udf_enum1_t;
+
+/** This variable is trickery to force the above enum symbol value to
+ be recorded in debug symbol tables. It is used to allow one refer
+ to above enumeration values in a debugger and debugger
+ expressions */
+extern udf_enum1_t debug_udf_enum1;
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /*!
+ Close UDF and free resources associated with p_udf.
+ */
+ bool udf_close (udf_t *p_udf);
+
+ /*!
+ Seek to a position i_start and then read i_blocks. Number of
+ blocks read is returned. One normally expects the return to be
+ equal to i_blocks.
+ */
+
+ driver_return_code_t udf_read_sectors (const udf_t *p_udf, void *ptr,
+ lsn_t i_start, long int i_blocks);
+
+ /*!
+ Open an UDF for reading. Maybe in the future we will have
+ a mode. NULL is returned on error.
+
+ Caller must free result - use udf_close for that.
+ */
+ udf_t *udf_open (const char *psz_path);
+
+ /*!
+ Return the partition number of the the opened udf handle. -1
+ Is returned if we have an error.
+ */
+ int16_t udf_get_part_number(const udf_t *p_udf);
+
+ /*!
+ Get the root in p_udf. If b_any_partition is false then
+ the root must be in the given partition.
+ NULL is returned if the partition is not found or a root is not found or
+ there is on error.
+
+ Caller must free result - use udf_file_free for that.
+ */
+ udf_dirent_t *udf_get_root (udf_t *p_udf, bool b_any_partition,
+ partition_num_t i_partition);
+
+ /**
+ * Gets the Volume Identifier string, in 8bit unicode (latin-1)
+ * psz_volid, place to put the string
+ * i_volid_size, size of the buffer volid points to
+ * returns the size of buffer needed for all data
+ */
+ int udf_get_volume_id(udf_t *p_udf, /*out*/ char *psz_volid,
+ unsigned int i_volid);
+
+ /**
+ * Gets the Volume Set Identifier, as a 128-byte dstring (not decoded)
+ * WARNING This is not a null terminated string
+ * volsetid, place to put the data
+ * volsetid_size, size of the buffer volsetid points to
+ * the buffer should be >=128 bytes to store the whole volumesetidentifier
+ * returns the size of the available volsetid information (128)
+ * or 0 on error
+ */
+ int udf_get_volumeset_id(udf_t *p_udf, /*out*/ uint8_t *volsetid,
+ unsigned int i_volsetid);
+
+ /*!
+ Return a file pointer matching pzz_name.
+ */
+ udf_dirent_t *udf_fopen(udf_dirent_t *p_udf_root, const char *psz_name);
+
+ /*! udf_mode_string - fill in string PSZ_STR with an ls-style ASCII
+ representation of the i_mode. PSZ_STR is returned.
+
+ 10 characters are stored in PSZ_STR; a terminating null byte is added.
+ The characters stored in PSZ_STR are:
+
+ 0 File type. 'd' for directory, 'c' for character
+ special, 'b' for block special, 'm' for multiplex,
+ 'l' for symbolic link, 's' for socket, 'p' for fifo,
+ '-' for regular, '?' for any other file type
+
+ 1 'r' if the owner may read, '-' otherwise.
+
+ 2 'w' if the owner may write, '-' otherwise.
+
+ 3 'x' if the owner may execute, 's' if the file is
+ set-user-id, '-' otherwise.
+ 'S' if the file is set-user-id, but the execute
+ bit isn't set.
+
+ 4 'r' if group members may read, '-' otherwise.
+
+ 5 'w' if group members may write, '-' otherwise.
+
+ 6 'x' if group members may execute, 's' if the file is
+ set-group-id, '-' otherwise.
+ 'S' if it is set-group-id but not executable.
+
+ 7 'r' if any user may read, '-' otherwise.
+
+ 8 'w' if any user may write, '-' otherwise.
+
+ 9 'x' if any user may execute, 't' if the file is "sticky"
+ (will be retained in swap space after execution), '-'
+ otherwise.
+ 'T' if the file is sticky but not executable. */
+
+ char *udf_mode_string (mode_t i_mode, char *psz_str);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#include <cdio/udf_time.h>
+#include <cdio/udf_file.h>
+
+#endif /*UDF_H*/
diff --git a/include/cdio/udf_file.h b/include/cdio/udf_file.h
new file mode 100644
index 00000000..0b8fe99e
--- /dev/null
+++ b/include/cdio/udf_file.h
@@ -0,0 +1,117 @@
+/*
+ $Id: udf_file.h,v 1.12 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * \file udf_file.h
+ *
+ * \brief Routines involving UDF file operations
+ *
+*/
+
+#ifndef UDF_FILE_H
+#define UDF_FILE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /**
+ Return the file id descriptor of the given file.
+ */
+ bool udf_get_fileid_descriptor(const udf_dirent_t *p_udf_dirent,
+ /*out*/ udf_fileid_desc_t *p_udf_fid);
+
+ /**
+ Return the name of the file
+ */
+ const char *udf_get_filename(const udf_dirent_t *p_udf_dirent);
+
+ /**
+ Return the name of the file
+ */
+ bool udf_get_file_entry(const udf_dirent_t *p_udf_dirent,
+ /*out*/ udf_file_entry_t *p_udf_fe);
+
+ /**
+ Return the number of hard links of the file. Return 0 if error.
+ */
+ uint16_t udf_get_link_count(const udf_dirent_t *p_udf_dirent);
+
+ /**
+ Return the file length the file. Return 2147483647L if error.
+ */
+ uint64_t udf_get_file_length(const udf_dirent_t *p_udf_dirent);
+
+ /**
+ Returns a POSIX mode for a given p_udf_dirent.
+ */
+ mode_t udf_get_posix_filemode(const udf_dirent_t *p_udf_dirent);
+
+ /**
+ Return the next subdirectory.
+ */
+ udf_dirent_t *udf_opendir(const udf_dirent_t *p_udf_dirent);
+
+ /**
+ Attempts to read up to count bytes from UDF directory entry
+ p_udf_dirent into the buffer starting at buf. buf should be a
+ multiple of UDF_BLOCKSIZE bytes. Reading continues after the
+ point at which we last read or from the beginning the first time.
+
+ If count is zero, read() returns zero and has no other results. If
+ count is greater than SSIZE_MAX, the result is unspecified.
+
+ If there is an error, cast the result to driver_return_code_t for
+ the specific error code.
+ */
+ /**
+ Attempts to read up to count bytes from file descriptor fd into
+ the buffer starting at buf.
+
+ If count is zero, read() returns zero and has no other results. If
+ count is greater than SSIZE_MAX, the result is unspecified.
+ */
+ ssize_t udf_read_block(const udf_dirent_t *p_udf_dirent,
+ void * buf, size_t count);
+
+ /**
+ Advances p_udf_direct to the the next directory entry in the
+ pointed to by p_udf_dir. It also returns this as the value. NULL
+ is returned on reaching the end-of-file or if an error. Also
+ p_udf_dirent is free'd. If the end of is not reached the caller
+ must call udf_dirent_free() with p_udf_dirent when done with it to
+ release resources.
+ */
+ udf_dirent_t *udf_readdir(udf_dirent_t *p_udf_dirent);
+
+ /**
+ free free resources associated with p_udf_dirent.
+ */
+ bool udf_dirent_free(udf_dirent_t *p_udf_dirent);
+
+ /**
+ Return true if the file is a directory.
+ */
+ bool udf_is_dir(const udf_dirent_t *p_udf_dirent);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /*UDF_FILE_H*/
diff --git a/include/cdio/udf_time.h b/include/cdio/udf_time.h
new file mode 100644
index 00000000..791fcdd9
--- /dev/null
+++ b/include/cdio/udf_time.h
@@ -0,0 +1,80 @@
+/*
+ $Id: udf_time.h,v 1.5 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2005, 2008 Rocky Bernstein <rocky@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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+/*!
+ * \file udf_time.h
+ *
+ * \brief UDF time conversion and access files.
+ *
+*/
+
+#ifndef UDF_TIME_H
+#define UDF_TIME_H
+
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /*!
+ Return the access time of the file.
+ */
+ time_t udf_get_access_time(const udf_dirent_t *p_udf_dirent);
+
+ /*!
+ Return the attribute (most recent create or access) time of the file
+ */
+ time_t udf_get_attribute_time(const udf_dirent_t *p_udf_dirent);
+
+ /*!
+ Return the modification time of the file.
+ */
+ time_t udf_get_modification_time(const udf_dirent_t *p_udf_dirent);
+
+ /*!
+ Return the access timestamp of the file
+ */
+ udf_timestamp_t *udf_get_access_timestamp(const udf_dirent_t *p_udf_dirent);
+
+ /*!
+ Return the modification timestamp of the file
+ */
+ udf_timestamp_t *udf_get_modification_timestamp(const udf_dirent_t
+ *p_udf_dirent);
+
+ /*!
+ Return the attr timestamp of the file
+ */
+ udf_timestamp_t *udf_get_attr_timestamp(const udf_dirent_t *p_udf_dirent);
+
+ /*!
+ Convert a UDF timestamp to a time_t. If microseconds are desired,
+ use dest_usec. The return value is the same as dest. */
+ time_t *udf_stamp_to_time(time_t *dest, long int *dest_usec,
+ const udf_timestamp_t src);
+
+ udf_timestamp_t *udf_timespec_to_stamp(const struct timespec ts,
+ udf_timestamp_t *dest);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /*UDF_TIME_H*/
diff --git a/include/cdio/utf8.h b/include/cdio/utf8.h
new file mode 100644
index 00000000..236105e9
--- /dev/null
+++ b/include/cdio/utf8.h
@@ -0,0 +1,92 @@
+/*
+ $Id: utf8.h,v 1.2 2008/03/25 15:59:09 karl Exp $
+
+ Copyright (C) 2008 Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 2006 Burkhard Plaum <plaum@ipf.uni-stuttgart.de>
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+/* UTF-8 support */
+
+
+#include <cdio/types.h>
+
+/** \brief Opaque characterset converter
+ */
+
+typedef struct cdio_charset_coverter_s cdio_charset_coverter_t;
+
+/** \brief Create a charset converter
+ * \param src_charset Source charset
+ * \param dst_charset Destination charset
+ * \returns A newly allocated charset converter
+ */
+
+cdio_charset_coverter_t *
+cdio_charset_converter_create(const char * src_charset,
+ const char * dst_charset);
+
+/** \brief Destroy a characterset converter
+ * \param cnv A characterset converter
+ */
+
+void cdio_charset_converter_destroy(cdio_charset_coverter_t*cnv);
+
+/** \brief Convert a string from one character set to another
+ * \param cnv A charset converter
+ * \param src Source string
+ * \param src_len Length of source string
+ * \param dst Returns destination string
+ * \param dst_len If non NULL, returns the length of the destination string
+ * \returns true if conversion was sucessful, false else.
+ *
+ * The destination string must be freed by the caller with free().
+ * If you pass -1 for src_len, strlen() will be used.
+ */
+
+bool cdio_charset_convert(cdio_charset_coverter_t*cnv,
+ char * src, int src_len,
+ char ** dst, int * dst_len);
+
+/** \brief Convert a string from UTF-8 to another charset
+ * \param src Source string (0 terminated)
+ * \param dst Returns destination string
+ * \param dst_len If non NULL, returns the length of the destination string
+ * \param dst_charset The characterset to convert to
+ * \returns true if conversion was sucessful, false else.
+ *
+ * This is a convenience function, which creates a charset converter,
+ * converts one string and destroys the charset converter.
+ */
+
+
+bool cdio_charset_from_utf8(cdio_utf8_t * src, char ** dst,
+ int * dst_len, const char * dst_charset);
+
+/** \brief Convert a string from another charset to UTF-8
+ * \param src Source string
+ * \param src_len Length of the source string
+ * \param dst Returns destination string (0 terminated)
+ * \param src_charset The characterset to convert from
+ * \returns true if conversion was sucessful, false else.
+ *
+ * This is a convenience function, which creates a charset converter,
+ * converts one string and destroys the charset converter. If you pass -1
+ * for src_len, strlen() will be used.
+ */
+
+
+bool cdio_charset_to_utf8(char *src, size_t src_len, cdio_utf8_t **dst,
+ const char * src_charset);
+
diff --git a/include/cdio/util.h b/include/cdio/util.h
new file mode 100644
index 00000000..81557dc7
--- /dev/null
+++ b/include/cdio/util.h
@@ -0,0 +1,117 @@
+/*
+ $Id: util.h,v 1.12 2008/03/25 15:59:10 karl Exp $
+
+ Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __CDIO_UTIL_H__
+#define __CDIO_UTIL_H__
+
+/*!
+ \file util.h
+ \brief Miscellaneous utility functions.
+
+ Warning: this will probably get removed/replaced by using glib.h
+*/
+#include <stdlib.h>
+
+#undef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+
+#undef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+
+#undef IN
+#define IN(x, low, high) ((x) >= (low) && (x) <= (high))
+
+#undef CLAMP
+#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
+
+static inline uint32_t
+_cdio_len2blocks (uint32_t i_len, uint16_t i_blocksize)
+{
+ uint32_t i_blocks;
+
+ i_blocks = i_len / (uint32_t) i_blocksize;
+ if (i_len % i_blocksize)
+ i_blocks++;
+
+ return i_blocks;
+}
+
+/* round up to next block boundary */
+static inline unsigned
+_cdio_ceil2block (unsigned offset, uint16_t i_blocksize)
+{
+ return _cdio_len2blocks (offset, i_blocksize) * i_blocksize;
+}
+
+static inline unsigned int
+_cdio_ofs_add (unsigned offset, unsigned length, uint16_t i_blocksize)
+{
+ if (i_blocksize - (offset % i_blocksize) < length)
+ offset = _cdio_ceil2block (offset, i_blocksize);
+
+ offset += length;
+
+ return offset;
+}
+
+static inline const char *
+_cdio_bool_str (bool b)
+{
+ return b ? "yes" : "no";
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void *
+_cdio_memdup (const void *mem, size_t count);
+
+char *
+_cdio_strdup_upper (const char str[]);
+
+void
+_cdio_strfreev(char **strv);
+
+size_t
+_cdio_strlenv(char **str_array);
+
+char **
+_cdio_strsplit(const char str[], char delim);
+
+uint8_t cdio_to_bcd8(uint8_t n);
+uint8_t cdio_from_bcd8(uint8_t p);
+
+void cdio_follow_symlink (const char * src, char * dst);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CDIO_UTIL_H__ */
+
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/include/cdio/version.h b/include/cdio/version.h
new file mode 100644
index 00000000..8eb564dc
--- /dev/null
+++ b/include/cdio/version.h
@@ -0,0 +1,12 @@
+/* $Id: version.h.in,v 1.6 2005/01/29 20:54:20 rocky Exp $ */
+/** \file version.h
+ *
+ * \brief A file containing the libcdio package version
+ * number (82) and OS build name.
+ */
+
+/*! CDIO_VERSION can as a string in programs to show what version is used. */
+#define CDIO_VERSION "0.82 i686-pc-linux-gnu"
+
+/*! LIBCDIO_VERSION_NUM can be used for testing in the C preprocessor */
+#define LIBCDIO_VERSION_NUM 82
diff --git a/include/cdio/version.h.in b/include/cdio/version.h.in
new file mode 100644
index 00000000..17d199e7
--- /dev/null
+++ b/include/cdio/version.h.in
@@ -0,0 +1,12 @@
+/* $Id: version.h.in,v 1.6 2005/01/29 20:54:20 rocky Exp $ */
+/** \file version.h
+ *
+ * \brief A file containing the libcdio package version
+ * number (@LIBCDIO_VERSION_NUM@) and OS build name.
+ */
+
+/*! CDIO_VERSION can as a string in programs to show what version is used. */
+#define CDIO_VERSION "@VERSION@ @build@"
+
+/*! LIBCDIO_VERSION_NUM can be used for testing in the C preprocessor */
+#define LIBCDIO_VERSION_NUM @LIBCDIO_VERSION_NUM@
diff --git a/include/cdio/xa.h b/include/cdio/xa.h
new file mode 100644
index 00000000..13b21c8f
--- /dev/null
+++ b/include/cdio/xa.h
@@ -0,0 +1,179 @@
+/*
+ $Id: xa.h,v 1.19 2008/03/25 15:59:10 karl Exp $
+
+ Copyright (C) 2003, 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
+
+ See also iso9660.h by Eric Youngdale (1993) and in cdrtools. These are
+
+ Copyright 1993 Yggdrasil Computing, Incorporated
+ Copyright (c) 1999,2000 J. Schilling
+
+ 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 3 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, see <http://www.gnu.org/licenses/>.
+*/
+/*!
+ \file xa.h
+ \brief Things related to the ISO-9660 XA (Extended Attributes) format
+
+ Applications will probably not include this directly but via
+ the iso9660.h header.
+*/
+
+
+#ifndef __CDIO_XA_H__
+#define __CDIO_XA_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+ /*! An enumeration for some of the XA_* \#defines below. This isn't
+ really an enumeration one would really use in a program it is to
+ be helpful in debuggers where wants just to refer to the XA_*
+ names and get something.
+ */
+ typedef enum {
+ ISO_XA_MARKER_OFFSET = 1024,
+ XA_PERM_RSYS = 0x0001, /**< System Group Read */
+ XA_PERM_XSYS = 0x0004, /**< System Group Execute */
+
+ XA_PERM_RUSR = 0x0010, /**< User (owner) Read */
+ XA_PERM_XUSR = 0x0040, /**< User (owner) Execute */
+
+ XA_PERM_RGRP = 0x0100, /**< Group Read */
+ XA_PERM_XGRP = 0x0400, /**< Group Execute */
+
+ XA_PERM_ROTH = 0x1000, /**< Other (world) Read */
+ XA_PERM_XOTH = 0x4000, /**< Other (world) Execute */
+
+ XA_ATTR_MODE2FORM1 = (1 << 11),
+ XA_ATTR_MODE2FORM2 = (1 << 12),
+ XA_ATTR_INTERLEAVED = (1 << 13),
+ XA_ATTR_CDDA = (1 << 14),
+ XA_ATTR_DIRECTORY = (1 << 15),
+
+ XA_PERM_ALL_READ = (XA_PERM_RUSR | XA_PERM_RSYS | XA_PERM_RGRP),
+ XA_PERM_ALL_EXEC = (XA_PERM_XUSR | XA_PERM_XSYS | XA_PERM_XGRP),
+ XA_PERM_ALL_ALL = (XA_PERM_ALL_READ | XA_PERM_ALL_EXEC),
+
+ XA_FORM1_DIR = (XA_ATTR_DIRECTORY | XA_ATTR_MODE2FORM1 | XA_PERM_ALL_ALL),
+ XA_FORM1_FILE = (XA_ATTR_MODE2FORM1 | XA_PERM_ALL_ALL),
+ XA_FORM2_FILE = (XA_ATTR_MODE2FORM2 | XA_PERM_ALL_ALL)
+ } xa_misc_enum_t;
+
+extern const char ISO_XA_MARKER_STRING[sizeof("CD-XA001")-1];
+
+#define ISO_XA_MARKER_STRING "CD-XA001"
+
+/*! \brief "Extended Architecture" according to the Philips Yellow Book.
+
+CD-ROM EXtended Architecture is a modification to the CD-ROM
+specification that defines two new types of sectors. CD-ROM XA was
+developed jointly by Sony, Philips, and Microsoft, and announced in
+August 1988. Its specifications were published in an extension to the
+Yellow Book. CD-i, Photo CD, Video CD and CD-EXTRA have all
+subsequently been based on CD-ROM XA.
+
+CD-XA defines another way of formatting sectors on a CD-ROM, including
+headers in the sectors that describe the type (audio, video, data) and
+some additional info (markers, resolution in case of a video or audio
+sector, file numbers, etc).
+
+The data written on a CD-XA is consistent with and can be in ISO-9660
+file system format and therefore be readable by ISO-9660 file system
+translators. But also a CD-I player can also read CD-XA discs even if
+its own `Green Book' file system only resembles ISO 9660 and isn't
+fully compatible.
+
+ Note structure is big-endian.
+*/
+typedef struct iso9660_xa_s
+{
+ uint16_t group_id; /**< 0 */
+ uint16_t user_id; /**< 0 */
+ uint16_t attributes; /**< XA_ATTR_ */
+ char signature[2]; /**< { 'X', 'A' } */
+ uint8_t filenum; /**< file number, see also XA subheader */
+ uint8_t reserved[5]; /**< zero */
+} GNUC_PACKED iso9660_xa_t;
+
+
+ /*!
+ Returns POSIX mode bitstring for a given file.
+ */
+ posix_mode_t iso9660_get_posix_filemode_from_xa(uint16_t i_perms);
+
+/*!
+ Returns a string interpreting the extended attribute xa_attr.
+ For example:
+ \verbatim
+ d---1xrxrxr
+ ---2--r-r-r
+ -a--1xrxrxr
+ \endverbatim
+
+ A description of the characters in the string follows.
+ The 1st character is either "d" if the entry is a directory, or "-" if not
+ The 2nd character is either "a" if the entry is CDDA (audio), or "-" if not
+ The 3rd character is either "i" if the entry is interleaved, or "-" if not
+ The 4th character is either "2" if the entry is mode2 form2 or "-" if not
+ The 5th character is either "1" if the entry is mode2 form1 or "-" if not
+ Note that an entry will either be in mode2 form1 or mode form2. That
+ is you will either see "2-" or "-1" in the 4th & 5th positions.
+
+ The 6th and 7th characters refer to permissions for a user while the
+ the 8th and 9th characters refer to permissions for a group while, and
+ the 10th and 11th characters refer to permissions for everyone.
+
+ In each of these pairs the first character (6, 8, 10) is "x" if the
+ entry is executable. For a directory this means the directory is
+ allowed to be listed or "searched".
+ The second character of a pair (7, 9, 11) is "r" if the entry is allowed
+ to be read.
+*/
+const char *
+iso9660_get_xa_attr_str (uint16_t xa_attr);
+
+/*!
+ Allocates and initalizes a new iso9600_xa_t variable and returns
+ it. The caller should free the returned result.
+
+ @see iso9660_xa
+*/
+iso9660_xa_t *
+iso9660_xa_init (iso9660_xa_t *_xa, uint16_t uid, uint16_t gid, uint16_t attr,
+ uint8_t filenum);
+
+#ifdef __cplusplus
+}
+
+/** The below variables are trickery to force the above enum symbol
+ values to be recorded in debug symbol tables. They are used to
+ allow one to refer to the enumeration value names in the typedefs
+ above in a debugger and debugger expressions.
+*/
+extern xa_misc_enum_t debugger_xa_misc_enum;
+
+
+#endif /* __cplusplus */
+
+#endif /* __CDIO_XA_H__ */
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */