summaryrefslogtreecommitdiff
path: root/contrib/libcdio/cdio
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libcdio/cdio')
-rw-r--r--contrib/libcdio/cdio/Makefile.am19
-rw-r--r--contrib/libcdio/cdio/bytesex.h196
-rw-r--r--contrib/libcdio/cdio/bytesex_asm.h123
-rw-r--r--contrib/libcdio/cdio/cd_types.h155
-rw-r--r--contrib/libcdio/cdio/cdio.h980
-rw-r--r--contrib/libcdio/cdio/cdtext.h108
-rw-r--r--contrib/libcdio/cdio/ds.h73
-rw-r--r--contrib/libcdio/cdio/dvd.h113
-rw-r--r--contrib/libcdio/cdio/iso9660.h786
-rw-r--r--contrib/libcdio/cdio/logging.h137
-rw-r--r--contrib/libcdio/cdio/scsi_mmc.h415
-rw-r--r--contrib/libcdio/cdio/sector.h326
-rw-r--r--contrib/libcdio/cdio/types.h379
-rw-r--r--contrib/libcdio/cdio/util.h136
-rw-r--r--contrib/libcdio/cdio/version.h10
-rw-r--r--contrib/libcdio/cdio/xa.h151
16 files changed, 4107 insertions, 0 deletions
diff --git a/contrib/libcdio/cdio/Makefile.am b/contrib/libcdio/cdio/Makefile.am
new file mode 100644
index 000000000..0910d60e5
--- /dev/null
+++ b/contrib/libcdio/cdio/Makefile.am
@@ -0,0 +1,19 @@
+include $(top_srcdir)/misc/Makefile.common
+
+noinst_HEADERS = \
+ bytesex.h \
+ bytesex_asm.h \
+ cdio.h \
+ cdtext.h \
+ cdtext.h \
+ cd_types.h \
+ ds.h \
+ dvd.h \
+ iso9660.h \
+ logging.h \
+ sector.h \
+ scsi_mmc.h \
+ types.h \
+ util.h \
+ version.h \
+ xa.h
diff --git a/contrib/libcdio/cdio/bytesex.h b/contrib/libcdio/cdio/bytesex.h
new file mode 100644
index 000000000..c40e44729
--- /dev/null
+++ b/contrib/libcdio/cdio/bytesex.h
@@ -0,0 +1,196 @@
+/*
+ $Id: bytesex.h,v 1.1 2005/01/02 00:51:38 rockyb Exp $
+
+ 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 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef __CDIO_BYTESEX_H__
+#define __CDIO_BYTESEX_H__
+
+#include <cdio/types.h>
+#include <cdio/bytesex_asm.h>
+#include <cdio/logging.h>
+
+/* generic byteswap routines */
+
+#define UINT16_SWAP_LE_BE_C(val) ((uint16_t) ( \
+ (((uint16_t) (val) & (uint16_t) 0x00ffU) << 8) | \
+ (((uint16_t) (val) & (uint16_t) 0xff00U) >> 8)))
+
+#define UINT32_SWAP_LE_BE_C(val) ((uint32_t) ( \
+ (((uint32_t) (val) & (uint32_t) 0x000000ffU) << 24) | \
+ (((uint32_t) (val) & (uint32_t) 0x0000ff00U) << 8) | \
+ (((uint32_t) (val) & (uint32_t) 0x00ff0000U) >> 8) | \
+ (((uint32_t) (val) & (uint32_t) 0xff000000U) >> 24)))
+
+#define UINT64_SWAP_LE_BE_C(val) ((uint64_t) ( \
+ (((uint64_t) (val) & (uint64_t) UINT64_C(0x00000000000000ff)) << 56) | \
+ (((uint64_t) (val) & (uint64_t) UINT64_C(0x000000000000ff00)) << 40) | \
+ (((uint64_t) (val) & (uint64_t) UINT64_C(0x0000000000ff0000)) << 24) | \
+ (((uint64_t) (val) & (uint64_t) UINT64_C(0x00000000ff000000)) << 8) | \
+ (((uint64_t) (val) & (uint64_t) UINT64_C(0x000000ff00000000)) >> 8) | \
+ (((uint64_t) (val) & (uint64_t) UINT64_C(0x0000ff0000000000)) >> 24) | \
+ (((uint64_t) (val) & (uint64_t) UINT64_C(0x00ff000000000000)) >> 40) | \
+ (((uint64_t) (val) & (uint64_t) UINT64_C(0xff00000000000000)) >> 56)))
+
+#ifndef UINT16_SWAP_LE_BE
+# define UINT16_SWAP_LE_BE UINT16_SWAP_LE_BE_C
+#endif
+
+#ifndef UINT32_SWAP_LE_BE
+# define UINT32_SWAP_LE_BE UINT32_SWAP_LE_BE_C
+#endif
+
+#ifndef UINT64_SWAP_LE_BE
+# define UINT64_SWAP_LE_BE UINT64_SWAP_LE_BE_C
+#endif
+
+inline static
+uint16_t uint16_swap_le_be (const uint16_t val)
+{
+ return UINT16_SWAP_LE_BE (val);
+}
+
+inline static
+uint32_t uint32_swap_le_be (const uint32_t val)
+{
+ return UINT32_SWAP_LE_BE (val);
+}
+
+inline static
+uint64_t uint64_swap_le_be (const uint64_t val)
+{
+ return UINT64_SWAP_LE_BE (val);
+}
+
+# define UINT8_TO_BE(val) ((uint8_t) (val))
+# define UINT8_TO_LE(val) ((uint8_t) (val))
+#ifdef WORDS_BIGENDIAN
+# define UINT16_TO_BE(val) ((uint16_t) (val))
+# define UINT16_TO_LE(val) ((uint16_t) UINT16_SWAP_LE_BE(val))
+
+# define UINT32_TO_BE(val) ((uint32_t) (val))
+# define UINT32_TO_LE(val) ((uint32_t) UINT32_SWAP_LE_BE(val))
+
+# define UINT64_TO_BE(val) ((uint64_t) (val))
+# define UINT64_TO_LE(val) ((uint64_t) UINT64_SWAP_LE_BE(val))
+#else
+# define UINT16_TO_BE(val) ((uint16_t) UINT16_SWAP_LE_BE(val))
+# define UINT16_TO_LE(val) ((uint16_t) (val))
+
+# define UINT32_TO_BE(val) ((uint32_t) UINT32_SWAP_LE_BE(val))
+# define UINT32_TO_LE(val) ((uint32_t) (val))
+
+# define UINT64_TO_BE(val) ((uint64_t) UINT64_SWAP_LE_BE(val))
+# define UINT64_TO_LE(val) ((uint64_t) (val))
+#endif
+
+/* symmetric conversions */
+#define UINT8_FROM_BE(val) (UINT8_TO_BE (val))
+#define UINT8_FROM_LE(val) (UINT8_TO_LE (val))
+#define UINT16_FROM_BE(val) (UINT16_TO_BE (val))
+#define UINT16_FROM_LE(val) (UINT16_TO_LE (val))
+#define UINT32_FROM_BE(val) (UINT32_TO_BE (val))
+#define UINT32_FROM_LE(val) (UINT32_TO_LE (val))
+#define UINT64_FROM_BE(val) (UINT64_TO_BE (val))
+#define UINT64_FROM_LE(val) (UINT64_TO_LE (val))
+
+/* converter function template */
+#define CVT_TO_FUNC(bits) \
+ static inline uint ## bits ## _t \
+ uint ## bits ## _to_be (uint ## bits ## _t val) \
+ { return UINT ## bits ## _TO_BE (val); } \
+ static inline uint ## bits ## _t \
+ uint ## bits ## _to_le (uint ## bits ## _t val) \
+ { return UINT ## bits ## _TO_LE (val); } \
+
+CVT_TO_FUNC(8)
+CVT_TO_FUNC(16)
+CVT_TO_FUNC(32)
+CVT_TO_FUNC(64)
+
+#undef CVT_TO_FUNC
+
+#define uint8_from_be(val) (uint8_to_be (val))
+#define uint8_from_le(val) (uint8_to_le (val))
+#define uint16_from_be(val) (uint16_to_be (val))
+#define uint16_from_le(val) (uint16_to_le (val))
+#define uint32_from_be(val) (uint32_to_be (val))
+#define uint32_from_le(val) (uint32_to_le (val))
+#define uint64_from_be(val) (uint64_to_be (val))
+#define uint64_from_le(val) (uint64_to_le (val))
+
+/* ISO9660 related stuff */
+
+#define to_711(i) uint8_to_le(i)
+#define from_711(i) uint8_from_le(i)
+
+#define to_721(i) uint16_to_le(i)
+#define from_721(i) uint16_from_le(i)
+
+#define to_721(i) uint16_to_le(i)
+#define from_721(i) uint16_from_le(i)
+
+#define to_722(i) uint16_to_be(i)
+#define from_722(i) uint16_from_be(i)
+
+static inline uint32_t
+to_723(uint16_t i)
+{
+ return uint32_swap_le_be(i) | i;
+}
+
+static inline uint16_t
+from_723 (uint32_t p)
+{
+ if (uint32_swap_le_be (p) != p)
+ cdio_warn ("from_723: broken byte order");
+
+ return (0xFFFF & p);
+}
+
+#define to_731(i) uint32_to_le(i)
+#define from_731(i) uint32_from_le(i)
+
+#define to_732(i) uint32_to_be(i)
+#define from_732(i) uint32_from_be(i)
+
+static inline uint64_t
+to_733(uint32_t i)
+{
+ return uint64_swap_le_be(i) | i;
+}
+
+static inline uint32_t
+from_733 (uint64_t p)
+{
+ if (uint64_swap_le_be (p) != p)
+ cdio_warn ("from_733: broken byte order");
+
+ return (UINT32_C(0xFFFFFFFF) & p);
+}
+
+#endif /* __CDIO_BYTESEX_H__ */
+
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/contrib/libcdio/cdio/bytesex_asm.h b/contrib/libcdio/cdio/bytesex_asm.h
new file mode 100644
index 000000000..4291563ec
--- /dev/null
+++ b/contrib/libcdio/cdio/bytesex_asm.h
@@ -0,0 +1,123 @@
+/*
+ $Id: bytesex_asm.h,v 1.1 2005/01/02 00:51:38 rockyb Exp $
+
+ Copyright (C) 2001 Sven Ottemann <ac-logic@freenet.de>
+ 2001, 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 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef __CDIO_BYTESEX_ASM_H__
+#define __CDIO_BYTESEX_ASM_H__
+#if !defined(DISABLE_ASM_OPTIMIZE)
+
+#include <cdio/types.h>
+
+#if defined(__powerpc__) && defined(__GNUC__)
+
+inline static
+uint32_t uint32_swap_le_be_asm(const uint32_t a)
+{
+ uint32_t b;
+
+ __asm__ ("lwbrx %0,0,%1"
+ :"=r"(b)
+ :"r"(&a), "m"(a));
+
+ return b;
+}
+
+inline static
+uint16_t uint16_swap_le_be_asm(const uint16_t a)
+{
+ uint32_t b;
+
+ __asm__ ("lhbrx %0,0,%1"
+ :"=r"(b)
+ :"r"(&a), "m"(a));
+
+ return b;
+}
+
+#define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
+#define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
+
+#elif defined(__mc68000__) && defined(__STORMGCC__)
+
+inline static
+uint32_t uint32_swap_le_be_asm(uint32_t a __asm__("d0"))
+{
+ /* __asm__("rolw #8,%0; swap %0; rolw #8,%0" : "=d" (val) : "0" (val)); */
+
+ __asm__("move.l %1,d0;rol.w #8,d0;swap d0;rol.w #8,d0;move.l d0,%0"
+ :"=r"(a)
+ :"r"(a));
+
+ return(a);
+}
+
+inline static
+uint16_t uint16_swap_le_be_asm(uint16_t a __asm__("d0"))
+{
+ __asm__("move.l %1,d0;rol.w #8,d0;move.l d0,%0"
+ :"=r"(a)
+ :"r"(a));
+
+ return(a);
+}
+
+#define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
+#define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
+
+#elif 0 && defined(__i386__) && defined(__GNUC__)
+
+inline static
+uint32_t uint32_swap_le_be_asm(uint32_t a)
+{
+ __asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
+ "rorl $16,%0\n\t" /* swap words */
+ "xchgb %b0,%h0" /* swap higher bytes */
+ :"=q" (a)
+ : "0" (a));
+
+ return(a);
+}
+
+inline static
+uint16_t uint16_swap_le_be_asm(uint16_t a)
+{
+ __asm__("xchgb %b0,%h0" /* swap bytes */
+ : "=q" (a)
+ : "0" (a));
+
+ return(a);
+}
+
+#define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
+#define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
+
+#endif
+
+#endif /* !defined(DISABLE_ASM_OPTIMIZE) */
+#endif /* __CDIO_BYTESEX_ASM_H__ */
+
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/contrib/libcdio/cdio/cd_types.h b/contrib/libcdio/cdio/cd_types.h
new file mode 100644
index 000000000..9f4a73f67
--- /dev/null
+++ b/contrib/libcdio/cdio/cd_types.h
@@ -0,0 +1,155 @@
+/*
+ $Id: cd_types.h,v 1.3 2005/01/01 02:43:58 rockyb Exp $
+
+ Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
+ 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 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/** \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.
+ */
+#define CDIO_FS_AUDIO 1 /**< audio only - not really a
+ filesystem */
+#define CDIO_FS_HIGH_SIERRA 2
+#define CDIO_FS_ISO_9660 3 /**< ISO 9660 filesystem */
+#define CDIO_FS_INTERACTIVE 4
+#define CDIO_FS_HFS 5 /**< file system used on the Macintosh
+ system in MacOS 6 through MacOS 9
+ and depricated in OSX. */
+#define 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 EXT2 with a journal.
+ */
+#define CDIO_FS_EXT2 7
+
+#define CDIO_FS_ISO_HFS 8 /**< both HFS & ISO-9660 filesystem */
+#define 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.
+ */
+#define CDIO_FS_3DO 10
+
+/**
+ Microsoft X-BOX CD.
+ */
+#define CDIO_FS_XISO 11
+#define CDIO_FS_UDFX 12
+#define CDIO_FS_UDF 13
+#define CDIO_FS_ISO_UDF 14
+
+
+#define CDIO_FS_MASK 15 /**< Note: this should be 2**n-1 and
+ and greater than the highest
+ CDIO_FS number above */
+#define CDIO_FS_UNKNOWN CDIO_FS_MASK
+
+/**
+ * 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.
+ */
+#define CDIO_FS_ANAL_XA 0x0010 /**< eXtended Architecture format */
+#define CDIO_FS_ANAL_MULTISESSION 0x0020 /**< CD has multisesion */
+#define CDIO_FS_ANAL_PHOTO_CD 0x0040 /**< Is a Kodak Photo CD */
+#define CDIO_FS_ANAL_HIDDEN_TRACK 0x0080 /**< Hidden track at the
+ beginning of the CD */
+#define CDIO_FS_ANAL_CDTV 0x0100
+#define CDIO_FS_ANAL_BOOTABLE 0x0200 /**< CD is bootable */
+#define CDIO_FS_ANAL_VIDEOCD 0x0400 /**< VCD 1.1 */
+#define CDIO_FS_ANAL_ROCKRIDGE 0x0800 /**< Has Rock Ridge Extensions to
+ ISO 9660 */
+#define CDIO_FS_ANAL_JOLIET 0x1000 /**< Microsoft Joliet extensions
+ to ISO 9660 */
+#define CDIO_FS_ANAL_SVCD 0x2000 /**< Super VCD or Choiji Video CD */
+#define CDIO_FS_ANAL_CVD 0x4000 /**< Choiji Video CD */
+#define CDIO_FS_ANAL_XISO 0x8000 /**< XBOX CD */
+
+/**
+ * Pattern which can be used by cdio_get_devices to specify matching
+ * any sort of CD.
+ */
+#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 *cdio, int start_session,
+ track_t track_num,
+ /*out*/ cdio_iso_analysis_t *iso_analysis);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CDIO_CD_TYPES_H__ */
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/contrib/libcdio/cdio/cdio.h b/contrib/libcdio/cdio/cdio.h
new file mode 100644
index 000000000..f9e2a38e3
--- /dev/null
+++ b/contrib/libcdio/cdio/cdio.h
@@ -0,0 +1,980 @@
+/* -*- c -*-
+ $Id: cdio.h,v 1.4 2005/04/27 23:28:42 rockyb Exp $
+
+ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
+ Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/** \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 2
+
+#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>
+
+/**! Flags specifying the category of device to open or is opened. */
+
+#define CDIO_SRC_IS_DISK_IMAGE_MASK 0x0001 /**< Read source is a CD image. */
+#define CDIO_SRC_IS_DEVICE_MASK 0x0002 /**< Read source is a CD device. */
+#define CDIO_SRC_IS_SCSI_MASK 0x0004 /**< Read source SCSI device. */
+#define CDIO_SRC_IS_NATIVE_MASK 0x0008
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*! Size of fields returned by an INQUIRY command */
+#define CDIO_MMC_HW_VENDOR_LEN 8 /**< length of vendor field */
+#define CDIO_MMC_HW_MODEL_LEN 16 /**< length of model field */
+#define CDIO_MMC_HW_REVISION_LEN 4 /**< length of revision field */
+
+ /*! \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;
+
+/* For compatability. */
+#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;
+
+ /** 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 is a little significant since the order is used in scans.
+ * We have to start with DRIVER_UNKNOWN and devices should come before
+ * disk-image readers. By putting something towards the top (a lower
+ * enumeration number), in an iterative scan we prefer that to
+ * something with a higher enumeration number.
+ *
+ * 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_BSDI, /**< BSDI driver */
+ DRIVER_FREEBSD, /**< FreeBSD driver - includes CAM and ioctl access */
+ DRIVER_LINUX, /**< GNU/Linux Driver */
+ DRIVER_SOLARIS, /**< Sun Solaris Driver */
+ DRIVER_OSX, /**< Apple OSX Driver */
+ DRIVER_WIN32, /**< Microsoft Windows Driver. Includes ASPI and
+ ioctl acces. */
+ 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;
+
+ /** 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;
+
+
+/** 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_BSDI
+#define CDIO_MIN_DEVICE_DRIVER CDIO_MIN_DRIVER
+#define CDIO_MAX_DRIVER DRIVER_NRG
+#define CDIO_MAX_DEVICE_DRIVER DRIVER_WIN32
+
+ 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;
+
+ extern const char *discmode2str[];
+
+ /*! Printable tags for track_format_t enumeration. */
+ extern const char *track_format2str[6];
+
+ /*!
+ Eject media in CD drive if there is a routine to do so.
+
+ @param p_cdio the CD object to be acted upon.
+ @return 0 if success and 1 for failure, and 2 if no routine.
+ If the CD is ejected *p_cdio is freed and p_cdio set to NULL.
+ */
+ int cdio_eject_media (CdIo_t **p_cdio);
+
+ /*!
+ 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);
+
+ /*!
+ 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 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[]);
+
+ /*!
+ Get CD-Text information for a CdIo 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.
+ */
+ const cdtext_t *cdio_get_cdtext (CdIo_t *p_cdio, track_t i_track);
+
+ /*!
+ 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 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.
+
+ If "b_any" is set false then every capability listed in the
+ extended portion of capabilities (i.e. not the basic filesystem)
+ must be satisified. If "any" is set true, then if any of the
+ capabilities matches, we call that a success.
+
+ 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 (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 (/*out*/ 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 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 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 and it is possible for this routine to return
+ NULL even though there may be a 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 and it is possible for this routine to return
+ NULL even though there may be a 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 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 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 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);
+
+ /*!
+ 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 );
+
+
+ /*!
+ 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 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 * 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);
+
+ /*!
+ 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);
+
+ /*!
+ 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 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.
+
+ @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 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 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);
+
+ /*!
+ Reposition read offset
+ Similar to (if not the same as) libc's lseek()
+
+ @param p_cdio object to get information from
+ @param offset amount to seek
+ @param whence like corresponding parameter in libc's lseek, 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()
+
+ @return (ssize_t) -1 on error.
+ */
+ ssize_t cdio_read(const CdIo_t *p_cdio, void *buf, size_t size);
+
+ /*!
+ Read an audio sector
+
+ @param p_cdio object to read from
+ @param buf place to read data into
+ @param lsn sector to read
+
+ @return 0 if no error, nonzero otherwise.
+ */
+ int cdio_read_audio_sector (const CdIo_t *p_cdio, void *buf, lsn_t lsn);
+
+ /*!
+ Reads audio sectors
+
+ @param p_cdio object to read from
+ @param buf place to read data into
+ @param lsn sector to read
+ @param i_sectors number of sectors to read
+
+ @return 0 if no error, nonzero otherwise.
+ */
+ int cdio_read_audio_sectors (const CdIo_t *p_cdio, void *buf, lsn_t lsn,
+ unsigned int i_sectors);
+
+ /*!
+ Reads a mode1 sector
+
+ @param p_cdio object to read from
+ @param buf place to read data into
+ @param lsn sector to read
+ @param b_form2 true for reading mode1 form2 sectors or false for
+ mode1 form1 sectors.
+
+ @return 0 if no error, nonzero otherwise.
+ */
+ int cdio_read_mode1_sector (const CdIo_t *p_cdio, void *buf, lsn_t lsn,
+ bool b_form2);
+
+ /*!
+ Reads mode1 sectors
+
+ @param p_cdio object to read from
+ @param buf place to read data into
+ @param lsn sector to read
+ @param b_form2 true for reading mode1 form2 sectors or false for
+ mode1 form1 sectors.
+ @param i_sectors number of sectors to read
+
+ @return 0 if no error, nonzero otherwise.
+ */
+ int cdio_read_mode1_sectors (const CdIo_t *p_cdio, void *buf, lsn_t lsn,
+ bool b_form2, unsigned int i_sectors);
+
+ /*!
+ Reads a mode1 sector
+
+ @param p_cdio object to read from
+ @param buf place to read data into
+ @param lsn sector to read
+ @param b_form2 true for reading mode1 form2 sectors or false for
+ mode1 form1 sectors.
+
+ @return 0 if no error, nonzero otherwise.
+ */
+ int cdio_read_mode2_sector (const CdIo_t *p_cdio, void *buf, lsn_t lsn,
+ bool b_form2);
+
+ /*!
+ Reads mode2 sectors
+
+ @param p_cdio object to read from
+ @param buf place to read data into
+ @param lsn sector to read
+ @param b_form2 true for reading mode1 form2 sectors or false for
+ mode1 form1 sectors.
+ @param i_sectors number of sectors to read
+
+ @return 0 if no error, nonzero otherwise.
+ */
+ int cdio_read_mode2_sectors (const CdIo_t *p_cdio, void *buf, lsn_t lsn,
+ bool b_form2, unsigned int i_sectors);
+
+ /*!
+ Set the arg "key" with "value" in "obj".
+
+ @param p_cdio the CD object to set
+ @param key the key to set
+ @param value the value to assocaiate with key
+ @return 0 if no error was found, and nonzero otherwise.
+ */
+ int cdio_set_arg (CdIo_t *p_cdio, const char key[], const char value[]);
+
+ /*!
+ Get the size of the CD in logical block address (LBA) units.
+
+ @param p_cdio the CD object queried
+ @return the size
+ */
+ uint32_t cdio_stat_size (const CdIo_t *p_cdio);
+
+ /*!
+ Initialize CD Reading and control routines. Should be called first.
+ */
+ bool cdio_init(void);
+
+ /* True if xxx driver is available. where xxx=linux, solaris, nrg, ...
+ */
+
+ /*! True if BSDI driver is available. */
+ bool cdio_have_bsdi (void);
+
+ /*! True if FreeBSD driver is available. */
+ bool cdio_have_freebsd (void);
+
+ /*! True if GNU/Linux driver is available. */
+ bool cdio_have_linux (void);
+
+ /*! True if Sun Solaris driver is available. */
+ bool cdio_have_solaris (void);
+
+ /*! True if Apple OSX driver is available. */
+ bool cdio_have_osx (void);
+
+ /*! True if Microsoft Windows driver is available. */
+ bool cdio_have_win32 (void);
+
+ /*! True if Nero driver is available. */
+ bool cdio_have_nrg (void);
+
+ /*! True if BIN/CUE driver is available. */
+ bool cdio_have_bincue (void);
+
+ /*! True if cdrdao CDRDAO driver is available. */
+ bool cdio_have_cdrdao (void);
+
+ /*! Like cdio_have_xxx but uses an enumeration instead. */
+ bool cdio_have_driver (driver_id_t driver_id);
+
+ /*!
+ Get a string decribing driver_id.
+
+ @param driver_id the driver you want the description for
+ @return a sring of driver description
+ */
+ const char *cdio_driver_describe (driver_id_t driver_id);
+
+ /*! Sets up to read from place specified by source_name and
+ driver_id. This or cdio_open_* should be called before using any
+ other routine, except cdio_init. This will call cdio_init, if
+ that hasn't been done previously. to call one of the specific
+ cdio_open_xxx routines.
+
+ @return the cdio object or NULL on error or no device.
+ */
+ CdIo_t * cdio_open (const char *source_name, driver_id_t driver_id);
+
+ /*! Sets up to read from place specified by source_name, driver_id
+ and access mode. This or cdio_open should be called before using
+ any other routine, except cdio_init. This will call cdio_init, if
+ that hasn't been done previously. to call one of the specific
+ cdio_open_xxx routines.
+
+ @return the cdio object or NULL on error or no device.
+ */
+ CdIo_t * cdio_open_am (const char *psz_source_name,
+ 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 a 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 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_bsdi (const char *psz_source_name);
+
+ /*! 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_name,
+ 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_source_name);
+
+ /*! 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_name,
+ 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 *source_name);
+
+ /*! 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 *source_name,
+ 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 *source_name);
+
+ /*! 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_name,
+ 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_name);
+
+ /*! 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_name,
+ 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 *source_name);
+
+ /*! 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_name,
+ 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 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 *source_name);
+
+ /*! 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_name,
+ const char *psz_access_mode);
+
+ /*! Return 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..
+
+ NULL is returned 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 disk 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 psg_toc is a TOC file for a cdrdao CD disk 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 source_name refers to a real hardware CD-ROM.
+
+ @param source_name 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 source_name is a device; If false is returned we
+ could have a CD disk image.
+ */
+ bool cdio_is_device(const char *source_name, driver_id_t driver_id);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CDIO_H__ */
diff --git a/contrib/libcdio/cdio/cdtext.h b/contrib/libcdio/cdio/cdtext.h
new file mode 100644
index 000000000..4b397a3ff
--- /dev/null
+++ b/contrib/libcdio/cdio/cdtext.h
@@ -0,0 +1,108 @@
+/*
+ $Id: cdtext.h,v 1.1 2005/01/01 02:43:58 rockyb Exp $
+
+ Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
+ 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 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+/*!
+ * \file cdtext.h
+ * \brief Header CD-Text information
+*/
+
+
+#ifndef __CDIO_CDTEXT_H__
+#define __CDIO_CDTEXT_H__
+
+#include <cdio/cdio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#define MAX_CDTEXT_FIELDS 13
+
+ /*! \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 */
+ 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 the string associated with the given field. NULL is
+ returned if key is CDTEXT_INVALID or the field is not set.
+
+ @see cdio_get_cdtext to retrieve the cdtext structure used as
+ input here.
+ */
+ const char *cdtext_get (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/contrib/libcdio/cdio/ds.h b/contrib/libcdio/cdio/ds.h
new file mode 100644
index 000000000..c811cadd4
--- /dev/null
+++ b/contrib/libcdio/cdio/ds.h
@@ -0,0 +1,73 @@
+/*
+ $Id: ds.h,v 1.1 2005/01/01 02:43:58 rockyb Exp $
+
+ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef __CDIO_DS_H__
+#define __CDIO_DS_H__
+
+#include <cdio/types.h>
+
+/* opaque... */
+typedef struct _CdioList CdioList;
+typedef struct _CdioListNode CdioListNode;
+
+typedef int (*_cdio_list_cmp_func) (void *data1, void *data2);
+
+typedef int (*_cdio_list_iterfunc) (void *data, void *user_data);
+
+/* methods */
+CdioList *_cdio_list_new (void);
+
+void _cdio_list_free (CdioList *list, int free_data);
+
+unsigned _cdio_list_length (const CdioList *list);
+
+void _cdio_list_prepend (CdioList *list, void *data);
+
+void _cdio_list_append (CdioList *list, void *data);
+
+void _cdio_list_foreach (CdioList *list, _cdio_list_iterfunc func, void *user_data);
+
+CdioListNode *_cdio_list_find (CdioList *list, _cdio_list_iterfunc cmp_func, void *user_data);
+
+#define _CDIO_LIST_FOREACH(node, list) \
+ for (node = _cdio_list_begin (list); node; node = _cdio_list_node_next (node))
+
+/* node ops */
+
+CdioListNode *_cdio_list_begin (const CdioList *list);
+
+CdioListNode *_cdio_list_end (CdioList *list);
+
+CdioListNode *_cdio_list_node_next (CdioListNode *node);
+
+void _cdio_list_node_free (CdioListNode *node, int free_data);
+
+void *_cdio_list_node_data (CdioListNode *node);
+
+#endif /* __CDIO_DS_H__ */
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
+
diff --git a/contrib/libcdio/cdio/dvd.h b/contrib/libcdio/cdio/dvd.h
new file mode 100644
index 000000000..df58c4322
--- /dev/null
+++ b/contrib/libcdio/cdio/dvd.h
@@ -0,0 +1,113 @@
+/*
+ $Id: dvd.h,v 1.1 2005/01/01 02:43:58 rockyb Exp $
+
+ Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
+ 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 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/*!
+ \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/contrib/libcdio/cdio/iso9660.h b/contrib/libcdio/cdio/iso9660.h
new file mode 100644
index 000000000..104b6ba62
--- /dev/null
+++ b/contrib/libcdio/cdio/iso9660.h
@@ -0,0 +1,786 @@
+/*
+ $Id: iso9660.h,v 1.3 2005/01/01 02:43:58 rockyb Exp $
+
+ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
+ Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
+
+ See also iso9660.h by Eric Youngdale (1993).
+
+ 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 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+/*!
+ * \file iso9660.h
+ * \brief Header for libiso9660: the ISO-9660 filesystem library.
+*/
+
+
+#ifndef __CDIO_ISO9660_H__
+#define __CDIO_ISO9660_H__
+
+#include <cdio/cdio.h>
+#include <cdio/ds.h>
+#include <cdio/xa.h>
+
+#include <time.h>
+
+#define _delta(from, to) ((to) - (from) + 1)
+
+#define MIN_TRACK_SIZE 4*75
+#define MIN_ISO_SIZE MIN_TRACK_SIZE
+
+/*!
+ An ISO filename is: "abcde.eee;1" -> <filename> '.' <ext> ';' <version #>
+
+ For ISO-9660 Level 1, the maximum needed string length is:
+
+\verbatim
+ 30 chars (filename + ext)
+ + 2 chars ('.' + ';')
+ + 5 chars (strlen("32767"))
+ + 1 null byte
+ ================================
+ = 38 chars
+\endverbatim
+*/
+
+/*! size in bytes of the filename portion + null byte */
+#define LEN_ISONAME 31
+
+/*! Max # characters in the entire ISO 9660 filename. */
+#define MAX_ISONAME 37
+
+/*! Max # characters in the entire ISO 9660 filename. */
+#define MAX_ISOPATHNAME 255
+
+/*! Max # characters in an perparer id. */
+#define ISO_MAX_PREPARER_ID 128
+
+/*! Max # characters in an publisher id. */
+#define ISO_MAX_PUBLISHER_ID 128
+
+/*! Max # characters in an application id. */
+#define ISO_MAX_APPLICATION_ID 128
+
+/*! Max # characters in an system id. */
+#define ISO_MAX_SYSTEM_ID 32
+
+/*! Max # characters in an volume id. */
+#define ISO_MAX_VOLUME_ID 32
+
+/*! Max # characters in an volume-set id. */
+#define ISO_MAX_VOLUMESET_ID 128
+
+/**! ISO 9660 directory flags. */
+#define ISO_FILE 0 /**< Not really a flag... */
+#define ISO_EXISTENCE 1 /**< Do not make existence known (hidden) */
+#define ISO_DIRECTORY 2 /**< This file is a directory */
+#define ISO_ASSOCIATED 4 /**< This file is an associated file */
+#define ISO_RECORD 8 /**< Record format in extended attr. != 0 */
+#define ISO_PROTECTION 16 /**< No read/execute perm. in ext. attr. */
+#define ISO_DRESERVED1 32 /**< Reserved bit 5 */
+#define ISO_DRESERVED2 64 /**< Reserved bit 6 */
+#define ISO_MULTIEXTENT 128 /**< Not final entry of a mult. ext. file */
+
+/**! Volume descriptor types */
+#define ISO_VD_PRIMARY 1
+#define ISO_VD_SUPPLEMENTARY 2 /**< Used by Joliet */
+#define ISO_VD_END 255
+
+/*! Sector of Primary Volume Descriptor */
+#define ISO_PVD_SECTOR 16
+
+/*! Sector of End Volume Descriptor */
+#define ISO_EVD_SECTOR 17
+
+/*! String inside track identifying an ISO 9660 filesystem. */
+#define ISO_STANDARD_ID "CD001"
+
+
+/*! Number of bytes in an ISO 9660 block */
+#define ISO_BLOCKSIZE 2048
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+enum strncpy_pad_check {
+ ISO9660_NOCHECK = 0,
+ ISO9660_7BIT,
+ ISO9660_ACHARS,
+ ISO9660_DCHARS
+};
+
+#ifndef EMPTY_ARRAY_SIZE
+#define EMPTY_ARRAY_SIZE 0
+#endif
+
+PRAGMA_BEGIN_PACKED
+
+/*!
+ \brief ISO-9660 shorter-format time structure.
+
+ @see iso9660_dtime
+ */
+struct iso9660_dtime {
+ uint8_t dt_year;
+ uint8_t dt_month; /**< Has value in range 1..12. Note starts
+ at 1, not 0 like a tm struct. */
+ uint8_t dt_day;
+ uint8_t dt_hour;
+ uint8_t dt_minute;
+ uint8_t dt_second;
+ int8_t dt_gmtoff; /**< GMT values -48 .. + 52 in 15 minute
+ intervals */
+} GNUC_PACKED;
+
+typedef struct iso9660_dtime iso9660_dtime_t;
+
+/*!
+ \brief ISO-9660 longer-format time structure.
+
+ @see iso9660_ltime
+ */
+struct iso9660_ltime {
+ char lt_year [_delta( 1, 4)]; /**< Add 1900 to value
+ for the Julian
+ year */
+ char lt_month [_delta( 5, 6)]; /**< Has value in range
+ 1..12. Note starts
+ at 1, not 0 like a
+ tm struct. */
+ char lt_day [_delta( 7, 8)];
+ char lt_hour [_delta( 9, 10)];
+ char lt_minute [_delta( 11, 12)];
+ char lt_second [_delta( 13, 14)];
+ char lt_hsecond [_delta( 15, 16)]; /**<! The value is in
+ units of 1/100's of
+ a second */
+ int8_t lt_gmtoff [_delta( 17, 17)];
+} GNUC_PACKED;
+
+typedef struct iso9660_ltime iso9660_ltime_t;
+
+/*! \brief Format of an ISO-9660 directory record
+
+ 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 {
+ uint8_t length; /*! 711 encoded */
+ uint8_t xa_length; /*! 711 encoded */
+ uint64_t extent; /*! 733 encoded */
+ uint64_t size; /*! 733 encoded */
+ iso9660_dtime_t recording_time; /*! 7 711-encoded units */
+ uint8_t file_flags;
+ uint8_t file_unit_size; /*! 711 encoded */
+ uint8_t interleave_gap; /*! 711 encoded */
+ uint32_t volume_sequence_number; /*! 723 encoded */
+ uint8_t filename_len; /*! 711 encoded */
+ char filename[EMPTY_ARRAY_SIZE];
+} GNUC_PACKED;
+
+typedef struct iso9660_dir iso9660_dir_t;
+
+/*!
+ \brief ISO-9660 Primary Volume Descriptor.
+ */
+struct iso9660_pvd {
+ uint8_t type; /**< 711 encoded */
+ char id[5];
+ uint8_t version; /**< 711 encoded */
+ char unused1[1];
+ char system_id[ISO_MAX_SYSTEM_ID]; /**< each char is an achar */
+ char volume_id[ISO_MAX_VOLUME_ID]; /**< each char is a dchar */
+ char unused2[8];
+ uint64_t volume_space_size; /**< 733 encoded */
+ char unused3[32];
+ uint32_t volume_set_size; /**< 723 encoded */
+ uint32_t volume_sequence_number; /**< 723 encoded */
+ uint32_t logical_block_size; /**< 723 encoded */
+ uint64_t path_table_size; /**< 733 encoded */
+ uint32_t type_l_path_table; /**< 731 encoded */
+ uint32_t opt_type_l_path_table; /**< 731 encoded */
+ uint32_t type_m_path_table; /**< 732 encoded */
+ uint32_t opt_type_m_path_table; /**< 732 encoded */
+ iso9660_dir_t root_directory_record; /**< See section 9.1 of
+ ISO 9660 spec. */
+ char root_directory_filename; /**< Is \0 */
+ char volume_set_id[ISO_MAX_VOLUMESET_ID]; /**< dchars */
+ char publisher_id[ISO_MAX_PUBLISHER_ID]; /**< achars */
+ char preparer_id[ISO_MAX_PREPARER_ID]; /**< achars */
+ char application_id[ISO_MAX_APPLICATION_ID]; /**< achars */
+ char copyright_file_id[37]; /**< See section 7.5 of
+ ISO 9660 spec. Each char is
+ a dchar */
+ char abstract_file_id[37]; /**< See section 7.5 of
+ ISO 9660 spec. Each char is
+ a dchar */
+ char bibliographic_file_id[37]; /**< See section 7.5 of
+ ISO 9660 spec. Each char is
+ a dchar. */
+ iso9660_ltime_t creation_date; /**< See section 8.4.26.1 of
+ ISO 9660 spec. */
+ iso9660_ltime_t modification_date; /**< See section 8.4.26.1 of
+ ISO 9660 spec. */
+ iso9660_ltime_t expiration_date; /**< See section 8.4.26.1 of
+ ISO 9660 spec. */
+ iso9660_ltime_t effective_date; /**< See section 8.4.26.1 of
+ ISO 9660 spec. */
+ uint8_t file_structure_version; /**< 711 encoded */
+ char unused4[1];
+ char application_data[512];
+ char unused5[653];
+} GNUC_PACKED;
+
+typedef struct iso9660_pvd 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 {
+ uint8_t type; /**< 711 encoded */
+ char id[5];
+ uint8_t version; /**< 711 encoded */
+ char flags; /**< 853 */
+ char system_id[ISO_MAX_SYSTEM_ID]; /**< each char is an achar */
+ char volume_id[ISO_MAX_VOLUME_ID]; /**< each char is a dchar */
+ char unused2[8];
+ uint64_t volume_space_size; /**< 733 encoded */
+ char escape_sequences[32]; /**< 856 */
+ uint32_t volume_set_size; /**< 723 encoded */
+ uint32_t volume_sequence_number; /**< 723 encoded */
+ uint32_t logical_block_size; /**< 723 encoded */
+ uint64_t path_table_size; /**< 733 encoded */
+ uint32_t type_l_path_table; /**< 731 encoded */
+ uint32_t opt_type_l_path_table; /**< 731 encoded */
+ uint32_t type_m_path_table; /**< 732 encoded */
+ uint32_t opt_type_m_path_table; /**< 732 encoded */
+ iso9660_dir_t root_directory_record; /**< See section 9.1 of
+ ISO 9660 spec. */
+ char volume_set_id[ISO_MAX_VOLUMESET_ID]; /**< dchars */
+ char publisher_id[ISO_MAX_PUBLISHER_ID]; /**< achars */
+ char preparer_id[ISO_MAX_PREPARER_ID]; /**< achars */
+ char application_id[ISO_MAX_APPLICATION_ID]; /**< achars */
+ char copyright_file_id[37]; /**< See section 7.5 of
+ ISO 9660 spec. Each char is
+ a dchar */
+ char abstract_file_id[37]; /**< See section 7.5 of
+ ISO 9660 spec. Each char is
+ a dchar */
+ char bibliographic_file_id[37]; /**< See section 7.5 of
+ ISO 9660 spec. Each char is
+ a dchar. */
+ iso9660_ltime_t creation_date; /**< See section 8.4.26.1 of
+ ISO 9660 spec. */
+ iso9660_ltime_t modification_date; /**< See section 8.4.26.1 of
+ ISO 9660 spec. */
+ iso9660_ltime_t expiration_date; /**< See section 8.4.26.1 of
+ ISO 9660 spec. */
+ iso9660_ltime_t effective_date; /**< See section 8.4.26.1 of
+ ISO 9660 spec. */
+ uint8_t file_structure_version; /**< 711 encoded */
+ char unused4[1];
+ char application_data[512];
+ char unused5[653];
+} GNUC_PACKED;
+
+typedef struct iso9660_svd 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 { /* big endian!! */
+ struct tm tm; /**< time on entry */
+ 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;
+ char filename[EMPTY_ARRAY_SIZE]; /**< filename */
+};
+
+typedef struct iso9660_stat iso9660_stat_t;
+
+
+/** 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;
+
+#define ISO_EXTENSION_JOLIET_LEVEL1 0x01
+#define ISO_EXTENSION_JOLIET_LEVEL2 0x02
+#define ISO_EXTENSION_JOLIET_LEVEL3 0x04
+#define ISO_EXTENSION_ROCK_RIDGE 0x08
+#define ISO_EXTENSION_HIGH_SIERRA 0x10
+
+#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 iso9660_t;
+
+/*!
+ 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_pathname /*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.
+*/
+ iso9660_t *iso9660_open_ext (const char *psz_pathname,
+ iso_extension_mask_t iso_extension_mask);
+
+/*!
+ Close previously opened ISO 9660 image.
+ True is unconditionally returned. If there was an error false would
+ be returned.
+*/
+ bool iso9660_close (iso9660_t * p_iso);
+
+
+/*!
+ Seek to a position and then read n bytes. Size read is returned.
+*/
+ long int iso9660_iso_seek_read (const iso9660_t *p_iso, 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 *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 *p_cdio,
+ iso_extension_mask_t iso_extension_mask);
+
+/*!
+ Read the Supper 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 "use_localtime" true, otherwise
+ tm will reported in GMT.
+*/
+ void iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool use_localtime,
+ /*out*/ struct tm *tm);
+
+
+/*====================================================
+ Characters used in file and directory and 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_isdchar (int c);
+
+/*!
+ Return true if c is an ACHAR -
+ These are the DCHAR's plus some ASCII symbols including the space
+ symbol.
+*/
+bool iso9660_isachar (int c);
+
+/*!
+ Convert ISO-9660 file name that stored in a 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.
+
+ The length of the translated string is returned.
+*/
+int iso9660_name_translate(const char *psz_oldname, char *psz_newname);
+
+/*!
+ Convert ISO-9660 file name that stored in a directory entry into
+ what's usually listed as the file name in a listing. Lowercase
+ name if not using Joliet extension. Remove trailing ;1's or .;1's and
+ turn the other ;'s into version numbers.
+
+ The length of the translated string is returned.
+*/
+int iso9660_name_translate_ext(const char *old, char *new,
+ 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/dirname's
+======================================================================*/
+
+/*!
+ Check that pathname 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 pathname is valid.
+ */
+bool iso9660_dirname_valid_p (const char pathname[]);
+
+/*!
+ Take pathname 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 pathname[], uint16_t i_version);
+
+/*!
+ Check that pathname 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 pathname is valid.
+ */
+bool iso9660_pathname_valid_p (const char pathname[]);
+
+/*=====================================================================
+ 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.
+
+ Returns stat_t of entry if we found lsn, or NULL otherwise.
+ */
+iso9660_stat_t *iso9660_find_fs_lsn(CdIo *p_cdio, lsn_t i_lsn);
+
+
+/*!
+ Given a directory pointer, find the filesystem entry that contains
+ lsn and return information about it.
+
+ Returns stat_t of entry if we found lsn, or NULL otherwise.
+ */
+iso9660_stat_t *iso9660_find_ifs_lsn(const iso9660_t *p_iso, lsn_t i_lsn);
+
+
+/*!
+ Get file status for pathname into stat. NULL is returned on error.
+ */
+iso9660_stat_t *iso9660_fs_stat (CdIo *p_cdio, const char pathname[]);
+
+
+/*!
+ Get file status for pathname into stat. 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_fs_stat_translate (CdIo *p_cdio,
+ const char pathname[],
+ bool b_mode2);
+
+/*!
+ Get file status for pathname into stat. NULL is returned on error.
+ */
+iso9660_stat_t *iso9660_ifs_stat (iso9660_t *p_iso, const char pathname[]);
+
+
+/*!
+ Get file status for pathname into stat. 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 pathname[]);
+
+/*!
+ Read pathname (a directory) and return a list of iso9660_stat_t
+ of the files inside that. The caller must free the returned result.
+*/
+CdioList * iso9660_fs_readdir (CdIo *p_cdio, const char pathname[],
+ bool b_mode2);
+
+/*!
+ Read pathname (a directory) and return a list of iso9660_stat_t
+ of the files inside that. The caller must free the returned result.
+*/
+CdioList * iso9660_ifs_readdir (iso9660_t *p_iso, const char pathname[]);
+
+/*!
+ 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*/ char **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.
+*/
+char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir);
+
+/*!
+ 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*/ char **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*/ char **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*/ char **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);
+
+/*!
+ Return the PVD's volume ID.
+*/
+char *iso9660_get_volume_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_volume_id(iso9660_t *p_iso,
+ /*out*/ char **p_psz_volume_id);
+
+/*!
+ Return the PVD's volumeset ID.
+ NULL is returned if there is some problem in getting this.
+*/
+char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd);
+
+/*!
+ Get the systemset 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*/ char **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);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __CDIO_ISO9660_H__ */
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/contrib/libcdio/cdio/logging.h b/contrib/libcdio/cdio/logging.h
new file mode 100644
index 000000000..8c78259ea
--- /dev/null
+++ b/contrib/libcdio/cdio/logging.h
@@ -0,0 +1,137 @@
+/*
+ $Id: logging.h,v 1.3 2005/01/01 02:43:58 rockyb Exp $
+
+ Copyright (C) 2000, Herbert Valerio Riedel <hvr@gnu.org>
+ Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/** \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/contrib/libcdio/cdio/scsi_mmc.h b/contrib/libcdio/cdio/scsi_mmc.h
new file mode 100644
index 000000000..12860247e
--- /dev/null
+++ b/contrib/libcdio/cdio/scsi_mmc.h
@@ -0,0 +1,415 @@
+/*
+ $Id: scsi_mmc.h,v 1.1 2005/01/01 02:43:58 rockyb Exp $
+
+ Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/*!
+ \file scsi_mmc.h
+ \brief Common definitions for SCSI MMC (Multi-Media Commands).
+*/
+
+#ifndef __SCSI_MMC_H__
+#define __SCSI_MMC_H__
+
+#include <cdio/cdio.h>
+#include <cdio/types.h>
+#include <cdio/dvd.h>
+
+/*! The generic packet command opcodes for CD/DVD Logical Units. */
+
+#define CDIO_MMC_GPCMD_INQUIRY 0x12
+#define CDIO_MMC_GPCMD_MODE_SELECT_6 0x15
+#define CDIO_MMC_GPCMD_MODE_SENSE 0x1a
+#define CDIO_MMC_GPCMD_START_STOP 0x1b
+#define CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL 0x1e
+#define CDIO_MMC_GPCMD_READ_10 0x28
+
+/*!
+ Group 2 Commands
+ */
+#define CDIO_MMC_GPCMD_READ_SUBCHANNEL 0x42
+#define CDIO_MMC_GPCMD_READ_TOC 0x43
+#define CDIO_MMC_GPCMD_READ_HEADER 0x44
+#define CDIO_MMC_GPCMD_PLAY_AUDIO_10 0x45
+#define CDIO_MMC_GPCMD_GET_CONFIGURATION 0x46
+#define CDIO_MMC_GPCMD_PLAY_AUDIO_MSF 0x47
+#define CDIO_MMC_GPCMD_PLAY_AUDIO_TI 0x48
+#define CDIO_MMC_GPCMD_PLAY_TRACK_REL_10 0x49
+#define CDIO_MMC_GPCMD_PAUSE_RESUME 0x4b
+
+#define CDIO_MMC_GPCMD_READ_DISC_INFO 0x51
+#define CDIO_MMC_GPCMD_MODE_SELECT 0x55
+#define CDIO_MMC_GPCMD_MODE_SENSE_10 0x5a
+
+/*!
+ Group 5 Commands
+ */
+#define CDIO_MMC_GPCMD_PLAY_AUDIO_12 0xa5
+#define CDIO_MMC_GPCMD_READ_12 0xa8
+#define CDIO_MMC_GPCMD_PLAY_TRACK_REL_12 0xa9
+#define CDIO_MMC_GPCMD_READ_DVD_STRUCTURE 0xad
+#define CDIO_MMC_GPCMD_READ_CD 0xbe
+#define CDIO_MMC_GPCMD_READ_MSF 0xb9
+
+/*!
+ Group 6 Commands
+ */
+
+#define CDIO_MMC_GPCMD_CD_PLAYBACK_STATUS 0xc4 /**< SONY unique command */
+#define CDIO_MMC_GPCMD_PLAYBACK_CONTROL 0xc9 /**< SONY unique command */
+#define CDIO_MMC_GPCMD_READ_CDDA 0xd8 /**< Vendor unique command */
+#define CDIO_MMC_GPCMD_READ_CDXA 0xdb /**< Vendor unique command */
+#define CDIO_MMC_GPCMD_READ_ALL_SUBCODES 0xdf /**< Vendor unique command */
+
+
+
+/*! Level values that can go into READ_CD */
+#define CDIO_MMC_READ_TYPE_ANY 0 /**< All types */
+#define CDIO_MMC_READ_TYPE_CDDA 1 /**< Only CD-DA sectors */
+#define CDIO_MMC_READ_TYPE_MODE1 2 /**< mode1 sectors (user data = 2048) */
+#define CDIO_MMC_READ_TYPE_MODE2 3 /**< mode2 sectors form1 or form2 */
+#define CDIO_MMC_READ_TYPE_M2F1 4 /**< mode2 sectors form1 */
+#define CDIO_MMC_READ_TYPE_M2F2 5 /**< mode2 sectors form2 */
+
+/*! Format values for READ_TOC */
+#define CDIO_MMC_READTOC_FMT_TOC 0
+#define CDIO_MMC_READTOC_FMT_SESSION 1
+#define CDIO_MMC_READTOC_FMT_FULTOC 2
+#define CDIO_MMC_READTOC_FMT_PMA 3 /**< Q subcode data */
+#define CDIO_MMC_READTOC_FMT_ATIP 4 /**< includes media type */
+#define CDIO_MMC_READTOC_FMT_CDTEXT 5 /**< CD-TEXT info */
+
+/*! Page codes for MODE SENSE and MODE SET. */
+#define CDIO_MMC_R_W_ERROR_PAGE 0x01
+#define CDIO_MMC_WRITE_PARMS_PAGE 0x05
+#define CDIO_MMC_AUDIO_CTL_PAGE 0x0e
+#define CDIO_MMC_CDR_PARMS_PAGE 0x0d
+#define CDIO_MMC_POWER_PAGE 0x1a
+#define CDIO_MMC_FAULT_FAIL_PAGE 0x1c
+#define CDIO_MMC_TO_PROTECT_PAGE 0x1d
+#define CDIO_MMC_CAPABILITIES_PAGE 0x2a
+#define CDIO_MMC_ALL_PAGES 0x3f
+
+/*! Return type codes for GET_CONFIGURATION. */
+#define CDIO_MMC_GET_CONF_ALL_FEATURES 0 /**< all features without regard
+ to currency. */
+#define CDIO_MMC_GET_CONF_CURRENT_FEATURES 1 /**< features which are currently
+ in effect (e.g. based on
+ medium inserted). */
+#define CDIO_MMC_GET_CONF_NAMED_FEATURE 2 /**< just the feature named in
+ the GET_CONFIGURATION
+ cdb. */
+
+/*! FEATURE codes used in GET CONFIGURATION. */
+
+#define CDIO_MMC_FEATURE_PROFILE_LIST 0x000 /**< Profile List Feature */
+#define CDIO_MMC_FEATURE_CORE 0x001
+#define CDIO_MMC_FEATURE_REMOVABLE_MEDIUM 0x002 /**< Removable Medium
+ Feature */
+#define CDIO_MMC_FEATURE_WRITE_PROTECT 0x003 /**< Write Protect
+ Feature */
+#define CDIO_MMC_FEATURE_RANDOM_READABLE 0x010 /**< Random Readable
+ Feature */
+#define CDIO_MMC_FEATURE_MULTI_READ 0x01D /**< Multi-Read
+ Feature */
+#define CDIO_MMC_FEATURE_CD_READ 0x01E /**< CD Read
+ Feature */
+#define CDIO_MMC_FEATURE_DVD_READ 0x01F /**< DVD Read
+ Feature */
+#define CDIO_MMC_FEATURE_RANDOM_WRITABLE 0x020 /**< Random Writable
+ Feature */
+#define CDIO_MMC_FEATURE_INCR_WRITE 0x021 /**< Incremental
+ Streaming Writable
+ Feature */
+#define CDIO_MMC_FEATURE_SECTOR_ERASE 0x022 /**< Sector Erasable
+ Feature */
+#define CDIO_MMC_FEATURE_FORMATABLE 0x023 /**< Formattable
+ Feature */
+#define CDIO_MMC_FEATURE_DEFECT_MGMT 0x024 /**< Management
+ Ability of the
+ Logical Unit/media
+ system to provide
+ an apparently
+ defect-free
+ space.*/
+#define CDIO_MMC_FEATURE_WRITE_ONCE 0x025 /**< Write Once
+ Feature */
+#define CDIO_MMC_FEATURE_RESTRICT_OVERW 0x026 /**< Restricted
+ Overwrite
+ Feature */
+#define CDIO_MMC_FEATURE_CD_RW_CAV 0x027 /**< CD-RW CAV Write
+ Feature */
+#define CDIO_MMC_FEATURE_MRW 0x028 /**< MRW Feature */
+#define CDIO_MMC_FEATURE_DVD_PRW 0x02A /**< DVD+RW Feature */
+#define CDIO_MMC_FEATURE_DVD_PR 0x02B /**< DVD+R Feature */
+#define CDIO_MMC_FEATURE_CD_TAO 0x02D
+#define CDIO_MMC_FEATURE_CD_SAO 0x02E
+#define CDIO_MMC_FEATURE_POWER_MGMT 0x100 /**< Initiator and
+ device directed
+ power management */
+#define CDIO_MMC_FEATURE_CDDA_EXT_PLAY 0x103 /**< Ability to play
+ audio CDs via the
+ Logical Unit s own
+ analog output */
+#define CDIO_MMC_FEATURE_MCODE_UPGRADE 0x104 /* Ability for the
+ device to accept
+ new microcode via
+ the interface */
+#define CDIO_MMC_FEATURE_TIME_OUT 0x105 /**< Ability to
+ respond to all
+ commands within a
+ specific time */
+#define CDIO_MMC_FEATURE_DVD_CSS 0x106 /**< Ability to
+ perform DVD
+ CSS/CPPM
+ authentication and
+ RPC */
+#define CDIO_MMC_FEATURE_RT_STREAMING 0x107 /**< Ability to read
+ and write using
+ Initiator requested
+ performance
+ parameters
+ */
+#define CDIO_MMC_FEATURE_LU_SN 0x108 /**< The Logical Unit
+ has a unique
+ identifier. */
+#define CDIO_MMC_FEATURE_FIRMWARE_DATE 0x1FF /**< Firmware creation
+ date report */
+
+/*! Profile codes used in GET_CONFIGURATION - PROFILE LIST. */
+#define CDIO_MMC_FEATURE_PROF_NON_REMOVABLE 0x0001 /**< Re-writable
+ disk, capable of
+ changing
+ behavior */
+#define CDIO_MMC_FEATURE_PROF_REMOVABLE 0x0002 /**< disk
+ Re-writable;
+ with removable
+ media */
+#define CDIO_MMC_FEATURE_PROF_MO_ERASABLE 0x0003 /**< Erasable
+ Magneto-Optical
+ disk with sector
+ erase
+ capability */
+#define CDIO_MMC_FEATURE_PROF_MO_WRITE_ONCE 0x0004 /**< Write Once
+ Magneto-Optical
+ write once */
+#define CDIO_MMC_FEATURE_PROF_AS_MO 0x0005 /**< Advance
+ Storage
+ Magneto-Optical */
+#define CDIO_MMC_FEATURE_PROF_CD_ROM 0x0008 /**< Read only
+ Compact Disc
+ capable */
+#define CDIO_MMC_FEATURE_PROF_CD_R 0x0009 /**< Write once
+ Compact Disc
+ capable */
+#define CDIO_MMC_FEATURE_PROF_CD_RW 0x000A /**< CD-RW
+ Re-writable
+ Compact Disc
+ capable */
+#define CDIO_MMC_FEATURE_PROF_DVD_ROM 0x0010 /**< Read only
+ DVD */
+#define CDIO_MMC_FEATURE_PROF_DVD_R_SEQ 0x0011 /**< Re-recordable
+ DVD using
+ Sequential
+ recording */
+#define CDIO_MMC_FEATURE_PROF_DVD_RAM 0x0012 /**< Re-writable
+ DVD */
+#define CDIO_MMC_FEATURE_PROF_DVD_RW_RO 0x0013 /**< Re-recordable
+ DVD using
+ Restricted
+ Overwrite */
+#define CDIO_MMC_FEATURE_PROF_DVD_RW_SEQ 0x0014 /**< Re-recordable
+ DVD using
+ Sequential
+ recording */
+#define CDIO_MMC_FEATURE_PROF_DVD_PRW 0x001A /**< DVD+RW - DVD
+ ReWritable */
+#define CDIO_MMC_FEATURE_PROF_DVD_PR 0x001B /**< DVD+R - DVD
+ Recordable */
+#define CDIO_MMC_FEATURE_PROF_DDCD_ROM 0x0020 /**< Read only
+ DDCD */
+#define CDIO_MMC_FEATURE_PROF_DDCD_R 0x0021 /**< DDCD-R Write
+ only DDCD */
+#define CDIO_MMC_FEATURE_PROF_DDCD_RW 0x0022 /**< Re-Write only
+ DDCD */
+#define CDIO_MMC_FEATURE_PROF_NON_CONFORM 0xFFFF /**< The Logical
+ Unit does not
+ conform to any
+ Profile. */
+
+/*! 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. */
+#define CDIO_MMC_GPCMD_SET_SPEED 0xbb
+
+
+/*! The largest Command Descriptor Buffer (CDB) size.
+ The possible sizes are 6, 10, and 12 bytes.
+ */
+#define MAX_CDB_LEN 12
+
+/*! \brief A Command Descriptor Buffer (CDB) used in sending SCSI MMC
+ commands.
+ */
+typedef struct scsi_mmc_cdb {
+ uint8_t field[MAX_CDB_LEN];
+} scsi_mmc_cdb_t;
+
+/*! \brief Format of header block in data returned from a SCSI-MMC
+ GET_CONFIGURATION command.
+ */
+typedef struct scsi_mmc_feature_list_header {
+ 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;
+} scs_mmc_feature_list_header_t;
+
+/*! An enumeration indicating whether a SCSI MMC command is sending
+ data or getting data.
+ */
+typedef enum scsi_mmc_direction {
+ SCSI_MMC_DATA_READ,
+ SCSI_MMC_DATA_WRITE
+} scsi_mmc_direction_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_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 0x78
+
+#define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(cdb, val) \
+ cdb[9] = val;
+
+/*!
+ Return the number of length in bytes of the Command Descriptor
+ buffer (CDB) for a given SCSI MMC command. The length will be
+ either 6, 10, or 12.
+*/
+uint8_t scsi_mmc_get_cmd_len(uint8_t scsi_cmd);
+
+
+/*!
+ Run a SCSI MMC command.
+
+ cdio CD structure set by cdio_open().
+ i_timeout_ms time in milliseconds we will wait for the command
+ to complete.
+ 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.
+ e_direction direction the transfer is to go.
+ i_buf Size of buffer
+ p_buf Buffer for data, both sending and receiving.
+
+ Returns 0 if command completed successfully.
+ */
+int scsi_mmc_run_cmd( const CdIo *p_cdio, unsigned int i_timeout_ms,
+ const scsi_mmc_cdb_t *p_cdb,
+ scsi_mmc_direction_t e_direction, unsigned int i_buf,
+ /*in/out*/ void *p_buf );
+
+/*!
+ * Eject using SCSI MMC commands. Return 0 if successful.
+ */
+int scsi_mmc_eject_media( const CdIo *p_cdio);
+
+/*! Packet driver to read mode2 sectors.
+ Can read only up to 25 blocks.
+*/
+int scsi_mmc_read_sectors ( const CdIo *p_cdio, void *p_buf, lba_t lba,
+ int sector_type, unsigned int nblocks);
+
+/*!
+ Set the block size for subsequest read requests, via a SCSI MMC
+ MODE_SELECT 6 command.
+ */
+int scsi_mmc_set_blocksize ( const CdIo *p_cdio, unsigned int bsize);
+
+/*!
+ Return the the kind of drive capabilities of device.
+ */
+void scsi_mmc_get_drive_cap (const CdIo *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);
+
+/*!
+ Get the DVD type associated with cd object.
+*/
+discmode_t scsi_mmc_get_dvd_struct_physical ( const CdIo *p_cdio,
+ cdio_dvd_struct_t *s);
+
+/*!
+ Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
+ False is returned if we had an error getting the information.
+*/
+bool scsi_mmc_get_hwinfo ( const CdIo *p_cdio,
+ /* out*/ cdio_hwinfo_t *p_hw_info );
+
+
+/*!
+ 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 *scsi_mmc_get_mcn ( const CdIo *p_cdio );
+
+#endif /* __SCSI_MMC_H__ */
diff --git a/contrib/libcdio/cdio/sector.h b/contrib/libcdio/cdio/sector.h
new file mode 100644
index 000000000..826883aea
--- /dev/null
+++ b/contrib/libcdio/cdio/sector.h
@@ -0,0 +1,326 @@
+/*
+ $Id: sector.h,v 1.3 2005/01/01 02:43:58 rockyb Exp $
+
+ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
+ Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+/*!
+ \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>
+
+/*! 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;
+
+/*! 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
+} discmode_t;
+
+/*! 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
+
+/*
+ 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__HEAD_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)
+
+/*! CD-ROM address types (GNU/Linux e.g. cdrom_tocentry.cdte_format) */
+#define CDIO_CDROM_LBA 0x01 /**< "logical block": first frame is #0 */
+#define CDIO_CDROM_MSF 0x02 /**< "minute-second-frame": binary, not
+ BCD here! */
+
+/*! CD-ROM track format types (GNU/Linux cdte_ctrl) */
+#define CDIO_CDROM_DATA_TRACK 0x04
+#define CDIO_CDROM_CDI_TRACK 0x10
+#define CDIO_CDROM_XA_TRACK 0x20
+
+/*! 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.
+ */
+#define CDIO_CDROM_LEADOUT_TRACK 0xAA
+
+#define M2F2_SECTOR_SIZE 2324
+#define M2SUB_SECTOR_SIZE 2332
+#define M2RAW_SECTOR_SIZE 2336
+
+/*! Largest CD track number */
+#define CDIO_CD_MAX_TRACKS 99
+/*! Smallest CD track number */
+#define CDIO_CD_MIN_TRACK_NO 1
+
+/*! 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 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 *msf);
+
+/*!
+ Convert an LBA into the corresponding LSN.
+*/
+lba_t cdio_lba_to_lsn (lba_t lba);
+
+/*!
+ Convert an LBA into the corresponding MSF.
+*/
+void cdio_lba_to_msf(lba_t lba, msf_t *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 lsn);
+
+/*!
+ Convert an LSN into the corresponding MSF.
+*/
+void cdio_lsn_to_msf (lsn_t lsn, msf_t *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 *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 *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);
+
+/*!
+ 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);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+static inline bool discmode_is_cd(discmode_t discmode)
+{
+ switch (discmode) {
+ case CDIO_DISC_MODE_CD_DA:
+ case CDIO_DISC_MODE_CD_DATA:
+ case CDIO_DISC_MODE_CD_XA:
+ case CDIO_DISC_MODE_CD_MIXED:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static inline bool discmode_is_dvd(discmode_t discmode)
+{
+ switch (discmode) {
+ case CDIO_DISC_MODE_DVD_ROM:
+ case CDIO_DISC_MODE_DVD_RAM:
+ case CDIO_DISC_MODE_DVD_R:
+ case CDIO_DISC_MODE_DVD_RW:
+ case CDIO_DISC_MODE_DVD_PR:
+ case CDIO_DISC_MODE_DVD_PRW:
+ case CDIO_DISC_MODE_DVD_OTHER:
+ return true;
+ default:
+ return false;
+ }
+}
+
+
+#endif /* _CDIO_SECTOR_H_ */
+
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/contrib/libcdio/cdio/types.h b/contrib/libcdio/cdio/types.h
new file mode 100644
index 000000000..ec84a142b
--- /dev/null
+++ b/contrib/libcdio/cdio/types.h
@@ -0,0 +1,379 @@
+/*
+ $Id: types.h,v 1.3 2005/01/01 02:43:58 rockyb Exp $
+
+ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
+ Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/** \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 */
+
+ /* 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 */
+
+ /* 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
+
+#if defined(HAVE_STDBOOL_H)
+#include <stdbool.h>
+#else
+ /* ISO/IEC 9899:1999 <stdbool.h> missing -- enabling workaround */
+
+# ifndef __cplusplus
+ typedef enum
+ {
+ false = 0,
+ true = 1
+ } _cdio_Bool;
+
+# define false false
+# define true true
+# define bool _cdio_Bool
+# endif
+#endif
+
+ /* 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.
+
+ @see lba_t
+ */
+ PRAGMA_BEGIN_PACKED
+ struct msf_rec {
+ uint8_t m, s, f;
+ } GNUC_PACKED;
+ PRAGMA_END_PACKED
+
+ typedef struct msf_rec msf_t;
+
+#define msf_t_SIZEOF 3
+
+ /* 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 lsn be negative
+ and the MMC3 specs allow for a conversion of a negative lba
+
+ @see msf_t
+ */
+ typedef int32_t lsn_t;
+
+ /*! The type of a track number 0..99. */
+ typedef uint8_t track_t;
+
+ /*!
+ Constant for invalid track number
+ */
+#define CDIO_INVALID_TRACK 0xFF
+
+ /*! 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;
+
+ /*! 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 types returned by cdio_get_drive_cap()
+
+ NOTE: Setting a bit here means the presence of a capability.
+ */
+
+#define CDIO_DRIVE_CAP_ERROR 0x40000 /**< Error */
+#define CDIO_DRIVE_CAP_UNKNOWN 0x80000 /**< Dunno. It can be on if we
+ have only partial information
+ or are not completely certain
+ */
+
+#define CDIO_DRIVE_CAP_MISC_CLOSE_TRAY 0x00001 /**< caddy systems can't
+ close... */
+#define CDIO_DRIVE_CAP_MISC_EJECT 0x00002 /**< but can eject. */
+#define CDIO_DRIVE_CAP_MISC_LOCK 0x00004 /**< disable manual eject */
+#define CDIO_DRIVE_CAP_MISC_SELECT_SPEED 0x00008 /**< programmable speed */
+#define CDIO_DRIVE_CAP_MISC_SELECT_DISC 0x00010 /**< select disc from
+ juke-box */
+#define CDIO_DRIVE_CAP_MISC_MULTI_SESSION 0x00020 /**< read sessions>1 */
+#define CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED 0x00080 /**< media changed */
+#define CDIO_DRIVE_CAP_MISC_RESET 0x00100 /**< hard reset device */
+#define CDIO_DRIVE_CAP_MCN 0x00200 /**< can read MCN */
+#define CDIO_DRIVE_CAP_ISRC 0x00200 /**< can read ISRC */
+#define CDIO_DRIVE_CAP_MISC_FILE 0x20000 /**< drive is really a file,
+ i.e a CD file image */
+
+ /*! Reading masks.. */
+#define CDIO_DRIVE_CAP_READ_AUDIO 0x00001 /**< drive can play CD audio */
+#define CDIO_DRIVE_CAP_READ_CD_DA 0x00002 /**< drive can read CD-DA */
+#define CDIO_DRIVE_CAP_READ_CD_G 0x00004 /**< drive can read CD+G */
+#define CDIO_DRIVE_CAP_READ_CD_R 0x00008 /**< drive can read CD-R */
+#define CDIO_DRIVE_CAP_READ_CD_RW 0x00010 /**< drive can read CD-RW */
+#define CDIO_DRIVE_CAP_READ_DVD_R 0x00020 /**< drive can read DVD-R */
+#define CDIO_DRIVE_CAP_READ_DVD_PR 0x00040 /**< drive can read DVD+R */
+#define CDIO_DRIVE_CAP_READ_DVD_RAM 0x00080 /**< drive can read DVD-RAM */
+#define CDIO_DRIVE_CAP_READ_DVD_ROM 0x00100 /**< drive can read DVD-ROM */
+#define CDIO_DRIVE_CAP_READ_DVD_RW 0x00200 /**< drive can read DVD-RW */
+#define CDIO_DRIVE_CAP_READ_DVD_RPW 0x00400 /**< drive can read DVD+RW */
+#define CDIO_DRIVE_CAP_READ_C2_ERRS 0x00800 /**< has C2 error correction */
+
+ /*! Writing masks.. */
+#define CDIO_DRIVE_CAP_WRITE_CD_R 0x00001 /**< drive can write CD-R */
+#define CDIO_DRIVE_CAP_WRITE_CD_RW 0x00002 /**< drive can write CD-R */
+#define CDIO_DRIVE_CAP_WRITE_DVD_R 0x00004 /**< drive can write DVD-R */
+#define CDIO_DRIVE_CAP_WRITE_DVD_PR 0x00008 /**< drive can write DVD+R */
+#define CDIO_DRIVE_CAP_WRITE_DVD_RAM 0x00010 /**< drive can write DVD-RAM */
+#define CDIO_DRIVE_CAP_WRITE_DVD_RW 0x00020 /**< drive can write DVD-RW */
+#define CDIO_DRIVE_CAP_WRITE_DVD_RPW 0x00040 /**< drive can write DVD+RW */
+#define CDIO_DRIVE_CAP_WRITE_MT_RAINIER 0x00080 /**< Mount Rainier */
+#define CDIO_DRIVE_CAP_WRITE_BURN_PROOF 0x00100 /**< burn proof */
+
+/**< Masks derived from above... */
+#define CDIO_DRIVE_CAP_WRITE_CD ( \
+ CDIO_DRIVE_CAP_WRITE_CD_R \
+ | CDIO_DRIVE_CAP_WRITE_CD_RW \
+ )
+/**< Has some sort of CD writer ability */
+
+/**< Masks derived from above... */
+#define 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 */
+
+#define CDIO_DRIVE_CAP_WRITE \
+ (CDIO_DRIVE_CAP_WRITE_CD | CDIO_DRIVE_CAP_WRITE_DVD)
+/**< Has some sort of DVD or CD writing ability */
+
+ /*!
+ 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/contrib/libcdio/cdio/util.h b/contrib/libcdio/cdio/util.h
new file mode 100644
index 000000000..3cea313b4
--- /dev/null
+++ b/contrib/libcdio/cdio/util.h
@@ -0,0 +1,136 @@
+/*
+ $Id: util.h,v 1.3 2005/01/01 02:43:58 rockyb Exp $
+
+ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
+ Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef __CDIO_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 unsigned
+_cdio_len2blocks (unsigned len, int blocksize)
+{
+ unsigned blocks;
+
+ blocks = len / blocksize;
+ if (len % blocksize)
+ blocks++;
+
+ return blocks;
+}
+
+/* round up to next block boundary */
+static inline unsigned
+_cdio_ceil2block (unsigned offset, int blocksize)
+{
+ return _cdio_len2blocks (offset, blocksize) * blocksize;
+}
+
+static inline unsigned
+_cdio_ofs_add (unsigned offset, unsigned length, int blocksize)
+{
+ if (blocksize - (offset % blocksize) < length)
+ offset = _cdio_ceil2block (offset, 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_malloc (size_t size);
+
+void *
+_cdio_memdup (const void *mem, size_t count);
+
+char *
+_cdio_strdup_upper (const char str[]);
+
+void
+_cdio_strfreev(char **strv);
+
+char *
+_cdio_strjoin (char *strv[], unsigned count, const char delim[]);
+
+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);
+
+#if defined(__GNUC__) && __GNUC__ >= 3
+static inline __attribute__((deprecated))
+uint8_t to_bcd8(uint8_t n) {
+ return cdio_to_bcd8(n);
+}
+static inline __attribute__((deprecated))
+uint8_t from_bcd8(uint8_t p) {
+ return cdio_from_bcd8(p);
+}
+#else
+#define to_bcd8 cdio_to_bcd8
+#define from_bcd8 cdio_from_bcd8
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CDIO_UTIL_H__ */
+
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/contrib/libcdio/cdio/version.h b/contrib/libcdio/cdio/version.h
new file mode 100644
index 000000000..345924cab
--- /dev/null
+++ b/contrib/libcdio/cdio/version.h
@@ -0,0 +1,10 @@
+/* $Id: version.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ */
+/** \file version.h
+ * \brief A file simply containing the library version number.
+ */
+
+/*! CDIO_VERSION can as a string in programs to show what version is used. */
+#define CDIO_VERSION "0.68"
+
+/*! LIBCDIO_VERSION_NUM can be used for testing in the C preprocessor */
+#define LIBCDIO_VERSION_NUM 68
diff --git a/contrib/libcdio/cdio/xa.h b/contrib/libcdio/cdio/xa.h
new file mode 100644
index 000000000..3af27eab5
--- /dev/null
+++ b/contrib/libcdio/cdio/xa.h
@@ -0,0 +1,151 @@
+/*
+ $Id: xa.h,v 1.3 2005/01/01 02:43:58 rockyb Exp $
+
+ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
+ Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
+
+ 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 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+/*!
+ \file xa.h
+ \brief Things related to the ISO-9660 XA (Extended Attributes) format
+*/
+
+
+#ifndef __CDIO_XA_H__
+#define __CDIO_XA_H__
+
+#include <cdio/types.h>
+
+#define ISO_XA_MARKER_STRING "CD-XA001"
+#define ISO_XA_MARKER_OFFSET 1024
+
+/* XA attribute definitions */
+#define XA_PERM_RSYS 0x0001 /**< System Group Read */
+#define XA_PERM_XSYS 0x0004 /**< System Group Execute */
+
+#define XA_PERM_RUSR 0x0010 /**< User (owner) Read */
+#define XA_PERM_XUSR 0x0040 /**< User (owner) Execute */
+
+#define XA_PERM_RGRP 0x0100 /**< Group Read */
+#define XA_PERM_XGRP 0x0400 /**< Group Execute */
+
+#define XA_PERM_ROTH 0x1000 /**< Other (world) Read */
+#define XA_PERM_XOTH 0x4000 /**< Other (world) Execute */
+
+#define XA_ATTR_MODE2FORM1 (1 << 11)
+#define XA_ATTR_MODE2FORM2 (1 << 12)
+#define XA_ATTR_INTERLEAVED (1 << 13)
+#define XA_ATTR_CDDA (1 << 14)
+#define XA_ATTR_DIRECTORY (1 << 15)
+
+/* some aggregations */
+#define XA_PERM_ALL_READ (XA_PERM_RUSR | XA_PERM_RSYS | XA_PERM_RGRP)
+#define XA_PERM_ALL_EXEC (XA_PERM_XUSR | XA_PERM_XSYS | XA_PERM_XGRP)
+#define XA_PERM_ALL_ALL (XA_PERM_ALL_READ | XA_PERM_ALL_EXEC)
+
+#define XA_FORM1_DIR (XA_ATTR_DIRECTORY | XA_ATTR_MODE2FORM1 | XA_PERM_ALL_ALL)
+#define XA_FORM1_FILE (XA_ATTR_MODE2FORM1 | XA_PERM_ALL_ALL)
+#define XA_FORM2_FILE (XA_ATTR_MODE2FORM2 | XA_PERM_ALL_ALL)
+
+/*! \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
+{
+ uint16_t group_id; /**< 0 */
+ uint16_t user_id; /**< 0 */
+ uint16_t attributes; /**< XA_ATTR_ */
+ uint8_t signature[2]; /**< { 'X', 'A' } */
+ uint8_t filenum; /**< file number, see also XA subheader */
+ uint8_t reserved[5]; /**< zero */
+} GNUC_PACKED iso9660_xa_t;
+
+
+/*!
+ Returns a string which 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);
+
+#endif /* __CDIO_XA_H__ */
+
+/*
+ * Local variables:
+ * c-file-style: "gnu"
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ */