diff options
Diffstat (limited to 'src/input/vcd/libcdio/cdio')
-rw-r--r-- | src/input/vcd/libcdio/cdio/Makefile.am | 12 | ||||
-rw-r--r-- | src/input/vcd/libcdio/cdio/cd_types.h | 114 | ||||
-rw-r--r-- | src/input/vcd/libcdio/cdio/cdio.h | 445 | ||||
-rw-r--r-- | src/input/vcd/libcdio/cdio/iso9660.h | 428 | ||||
-rw-r--r-- | src/input/vcd/libcdio/cdio/logging.h | 66 | ||||
-rw-r--r-- | src/input/vcd/libcdio/cdio/sector.h | 162 | ||||
-rw-r--r-- | src/input/vcd/libcdio/cdio/types.h | 236 | ||||
-rw-r--r-- | src/input/vcd/libcdio/cdio/util.h | 109 | ||||
-rw-r--r-- | src/input/vcd/libcdio/cdio/version.h | 1 | ||||
-rw-r--r-- | src/input/vcd/libcdio/cdio/xa.h | 121 |
10 files changed, 1694 insertions, 0 deletions
diff --git a/src/input/vcd/libcdio/cdio/Makefile.am b/src/input/vcd/libcdio/cdio/Makefile.am new file mode 100644 index 000000000..e2564e9bd --- /dev/null +++ b/src/input/vcd/libcdio/cdio/Makefile.am @@ -0,0 +1,12 @@ +noinst_HEADERS = cdio.h cd_types.h iso9660.h logging.h sector.h types.h util.h version.h xa.h + +debug: +install-debug: install + +mostlyclean-generic: + -rm -f *~ \#* .*~ .\#* + +maintainer-clean-generic: + -@echo "This command is intended for maintainers to use;" + -@echo "it deletes files that may require special tools to rebuild." + -rm -f Makefile.in diff --git a/src/input/vcd/libcdio/cdio/cd_types.h b/src/input/vcd/libcdio/cdio/cd_types.h new file mode 100644 index 000000000..91b36453c --- /dev/null +++ b/src/input/vcd/libcdio/cdio/cd_types.h @@ -0,0 +1,114 @@ +/* + $Id: cd_types.h,v 1.1 2003/10/13 11:47:12 f1rmb 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 +*/ + +/* + Filesystem types we understand. The highest-numbered fs type should + be less than CDIO_FS_MASK defined below. +*/ + +#ifndef __CDIO_CD_TYPES_H__ +#define __CDIO_CD_TYPES_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define CDIO_FS_AUDIO 1 /* audio only - not really a fs */ +#define CDIO_FS_HIGH_SIERRA 2 +#define CDIO_FS_ISO_9660 3 +#define CDIO_FS_INTERACTIVE 4 +#define CDIO_FS_HFS 5 +#define CDIO_FS_UFS 6 + +/* 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 & isofs filesystem */ +#define CDIO_FS_ISO_9660_INTERACTIVE 9 /* both CD-RTOS and isofs 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 + +#define CDIO_FS_MASK 15 /* Should be 2*n-1 and > 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 16 +#define CDIO_FS_ANAL_MULTISESSION 32 +#define CDIO_FS_ANAL_PHOTO_CD 64 +#define CDIO_FS_ANAL_HIDDEN_TRACK 128 +#define CDIO_FS_ANAL_CDTV 256 +#define CDIO_FS_ANAL_BOOTABLE 512 +#define CDIO_FS_ANAL_VIDEOCD 1024 /* VCD 1.1 */ +#define CDIO_FS_ANAL_ROCKRIDGE 2048 +#define CDIO_FS_ANAL_JOLIET 4096 +#define CDIO_FS_ANAL_SVCD 8192 /* Super VCD or Choiji Video CD */ +#define CDIO_FS_ANAL_CVD 16384 /* Choiji Video 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) + + +typedef struct +{ + unsigned int joliet_level; + char iso_label[33]; /* 32 + 1 for null byte at the end in + formatting the string */ + unsigned int isofs_size; +} cdio_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 cdio_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_analysis_t *cdio_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/src/input/vcd/libcdio/cdio/cdio.h b/src/input/vcd/libcdio/cdio/cdio.h new file mode 100644 index 000000000..d0b304b38 --- /dev/null +++ b/src/input/vcd/libcdio/cdio/cdio.h @@ -0,0 +1,445 @@ +/* -*- c -*- + $Id: cdio.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + + Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> + Copyright (C) 2003 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 +*/ + +/* Public CD Input and Control Interface . */ + + +#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 1 + +#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 +#define CDIO_SRC_IS_DEVICE_MASK 0x0002 +#define CDIO_SRC_IS_SCSI_MASK 0x0004 +#define CDIO_SRC_IS_NATIVE_MASK 0x0008 + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + /* opaque structure */ + typedef struct _CdIo CdIo; + + /* The below 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 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, + DRIVER_BSDI, + DRIVER_FREEBSD, + DRIVER_LINUX, + DRIVER_SOLARIS, + DRIVER_OSX, + DRIVER_WIN32, + DRIVER_BINCUE, /* Prefer bincue over nrg when both exist */ + DRIVER_NRG, + DRIVER_DEVICE /* Is really a set of the above; should come last */ + } driver_id_t; + + /* Make sure what's listed below is the last one above. Since we have + a bogus (but useful) 0th entry above we don't have to add one below. + */ +#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; + + /* Printable tags for above enumeration. */ + extern const char *track_format2str[6]; + + /*! + Eject media in CD drive if there is a routine to do so. + Return 0 if success and 1 for failure, and 2 if no routine. + If the CD is ejected *obj is freed and obj set to NULL. + */ + int cdio_eject_media (CdIo **obj); + + /*! + Free any resources associated with obj. + */ + void cdio_destroy (CdIo *obj); + + /*! + Free device list returned by cdio_get_devices or + cdio_get_devices_with_cap. + */ + void cdio_free_device_list (char * device_list[]); + + /*! + Return the value associatied with key. NULL is returned if obj is NULL + or "key" does not exist. + */ + const char * cdio_get_arg (const CdIo *obj, const char key[]); + + /*! + Return an array of device names in search_devices that have at + least the capabilities listed by cap. If search_devices is NULL, + then we'll search all possible CD drives. + + If "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. + + NULL is returned if we couldn't get a default device. + */ + char ** cdio_get_devices_with_cap (char* search_devices[], + cdio_fs_anal_t capabilities, bool any); + + /*!Return an array of device names. If you want a specific + devices, dor 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. + */ + char ** cdio_get_devices (driver_id_t driver); + + /*! + Return a string containing the default CD device. + if obj is NULL (we haven't initialized a specific device driver), + then find a suitable one and return the default device for that. + + NULL is returned if we couldn't get a default device. + */ + char * cdio_get_default_device (const CdIo *obj); + + /*! + Return the media catalog number (MCN) from the CD or NULL if there + is none or we don't have the ability to get it. + + Note: string is malloc'd so caller has to free() the returned + string when done with it. + */ + char *cdio_get_mcn (const CdIo *obj); + + /*! + Return a string containing the name of the driver in use. + if CdIo is NULL (we haven't initialized a specific device driver), + then return NULL. + */ + const char * cdio_get_driver_name (const CdIo *obj); + + /*! + Return the number of the first track. + CDIO_INVALID_TRACK is returned on error. + */ + track_t cdio_get_first_track_num(const CdIo *obj); + + /*! + Return a string containing the default CD device if none is specified. + */ + track_t cdio_get_num_tracks (const CdIo *obj); + + /*! + Get format of track. + */ + track_format_t cdio_get_track_format(const CdIo *obj, track_t track_num); + + /*! + 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 *obj, track_t track_num); + + /*! + Return the starting LBA for track number + track_num in obj. Tracks numbers start at 1. + The "leadout" track is specified either by + using track_num LEADOUT_TRACK or the total tracks+1. + CDIO_INVALID_LBA is returned on error. + */ + lba_t cdio_get_track_lba(const CdIo *obj, track_t track_num); + + /*! + Return the starting LSN for track number + track_num in obj. Tracks numbers start at 1. + The "leadout" track is specified either by + using track_num LEADOUT_TRACK or the total tracks+1. + CDIO_INVALID_LBA is returned on error. + */ + lsn_t cdio_get_track_lsn(const CdIo *obj, track_t track_num); + + /*! + Return the starting MSF (minutes/secs/frames) for track number + track_num in obj. Track numbers start at 1. + The "leadout" track is specified either by + using track_num LEADOUT_TRACK or the total tracks+1. + False is returned if there is no track entry. + */ + bool cdio_get_track_msf(const CdIo *obj, track_t track_num, + /*out*/ msf_t *msf); + + /*! + Return the number of sectors between this track an the next. This + includes any pregap sectors before the start of the next track. + Tracks start at 1. + 0 is returned if there is an error. + */ + unsigned int cdio_get_track_sec_count(const CdIo *obj, track_t track_num); + + /*! + lseek - reposition read/write file offset + Returns (off_t) -1 on error. + Similar to (if not the same as) libc's lseek() + */ + off_t cdio_lseek(const CdIo *obj, off_t offset, int whence); + + /*! + Reads into buf the next size bytes. + Returns -1 on error. + Similar to (if not the same as) libc's read() + */ + ssize_t cdio_read(const CdIo *obj, void *buf, size_t size); + + /*! + Reads a audio sector from cd device into data starting + from lsn. Returns 0 if no error. + */ + int cdio_read_audio_sector (const CdIo *obj, void *buf, lsn_t lsn); + + /*! + Reads a audio sector from cd device into data starting + from lsn. Returns 0 if no error. + */ + int cdio_read_audio_sectors (const CdIo *obj, void *buf, lsn_t lsn, + unsigned int nblocks); + + /*! + Reads a single mode1 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ + int cdio_read_mode1_sector (const CdIo *obj, void *buf, lsn_t lsn, + bool is_form2); + + /*! + Reads nblocks of mode1 sectors from cd device into data starting + from lsn. Returns 0 if no error. + */ + int cdio_read_mode1_sectors (const CdIo *obj, void *buf, lsn_t lsn, + bool is_form2, unsigned int num_sectors); + + /*! + Reads a single mode2 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ + int cdio_read_mode2_sector (const CdIo *obj, void *buf, lsn_t lsn, + bool is_form2); + + /*! + Reads nblocks of mode2 sectors from cd device into data starting + from lsn. + Returns 0 if no error. + */ + int cdio_read_mode2_sectors (const CdIo *obj, void *buf, lsn_t lsn, + bool is_form2, unsigned int num_sectors); + + /*! + Set the arg "key" with "value" in the source device. + 0 is returned if no error was found, and nonzero if there as an error. + */ + int cdio_set_arg (CdIo *obj, const char key[], const char value[]); + + /*! + Return the size of the CD in logical block address (LBA) units. + */ + uint32_t cdio_stat_size (const CdIo *obj); + + /*! + 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, ... + */ + bool cdio_have_bsdi (void); + bool cdio_have_freebsd (void); + bool cdio_have_linux (void); + bool cdio_have_solaris (void); + bool cdio_have_osx (void); + bool cdio_have_win32 (void); + bool cdio_have_nrg (void); + bool cdio_have_bincue (void); + + /* Like above but uses the enumeration instead. */ + bool cdio_have_driver (driver_id_t driver_id); + + /* Return a string decribing driver_id. */ + const char *cdio_driver_describe (driver_id_t driver_id); + + /*! Sets up to read from place specified by source_name and + driver_id This 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 routines below. + + NULL is returned on error. + */ + CdIo * cdio_open (const char *source_name, driver_id_t driver_id); + + /*! cdrao BIN/CUE CD disk-image routines. Source is the .bin file + + NULL is returned on error. + */ + CdIo * cdio_open_bincue (const char *bin_name); + + char * cdio_get_default_device_bincue(void); + + char **cdio_get_devices_bincue(void); + + /*! CD routines. Source is the some sort of device. + + NULL is returned on error. + */ + CdIo * cdio_open_cd (const char *device_name); + + /*! cdrao BIN/CUE CD disk-image routines. Source is the .cue file + + NULL is returned on error. + */ + CdIo * cdio_open_cue (const char *cue_name); + + /*! BSDI CD-reading routines. + NULL is returned on error. + */ + CdIo * cdio_open_bsdi (const char *source_name); + + char * cdio_get_default_device_bsdi(void); + + char **cdio_get_devices_bsdi(void); + + /*! BSDI CD-reading routines. + NULL is returned on error. + */ + CdIo * cdio_open_freebsd (const char *source_name); + + char * cdio_get_default_device_freebsd(void); + + char **cdio_get_devices_freebsd(void); + + /*! Linux CD-reading routines. + NULL is returned on error. + */ + CdIo * cdio_open_linux (const char *source_name); + + char * cdio_get_default_device_linux(void); + + char **cdio_get_devices_linux(void); + + /*! Solaris CD-reading routines. + NULL is returned on error. + */ + CdIo * cdio_open_solaris (const char *source_name); + + char * cdio_get_default_device_solaris(void); + + char **cdio_get_devices_solaris(void); + + /*! Darwin OS X CD-reading routines. + NULL is returned on error. + */ + CdIo * cdio_open_osx (const char *source_name); + + char * cdio_get_default_device_osx(void); + + char **cdio_get_devices_osx(void); + + /*! Win32 CD-reading routines. + NULL is returned on error. + */ + CdIo * cdio_open_win32 (const char *source_name); + + char * cdio_get_default_device_win32(void); + + char **cdio_get_devices_win32(void); + + /*! Nero CD disk-image routines. + NULL is returned on error. + */ + CdIo * cdio_open_nrg (const char *source_name); + + char * cdio_get_default_device_nrg(void); + + char **cdio_get_devices_nrg(void); + + /*! Return corresponding BIN file if cue_name is a cue file or NULL + if not a CUE file. + */ + char *cdio_is_cuefile(const char *cue_name); + + /*! Return corresponding CUE file if bin_name is a fin file or NULL + if not a BIN file. NOTE: when we handle TOC something will have to + change here.... + */ + char *cdio_is_binfile(const char *bin_name); + + /*! Return true if source name is a device. + */ + bool cdio_is_device(const char *source_name, driver_id_t driver_id); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __CDIO_H__ */ diff --git a/src/input/vcd/libcdio/cdio/iso9660.h b/src/input/vcd/libcdio/cdio/iso9660.h new file mode 100644 index 000000000..c2cabe5fc --- /dev/null +++ b/src/input/vcd/libcdio/cdio/iso9660.h @@ -0,0 +1,428 @@ +/* + $Id: iso9660.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + + Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> + Copyright (C) 2003 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 +*/ +/* + * Header file iso9660.h - assorted structure definitions and typecasts. + specific to iso9660 filesystem. +*/ + + +#ifndef __CDIO_ISO9660_H__ +#define __CDIO_ISO9660_H__ + +#include <cdio/cdio.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 + +/* + A ISO filename is: "abcde.eee;1" -> <filename> '.' <ext> ';' <version #> + + The maximum needed string length is: + 30 chars (filename + ext) + + 2 chars ('.' + ';') + + strlen("32767") + + null byte + ================================ + = 38 chars +*/ +#define LEN_ISONAME 31 +#define MAX_ISONAME 37 + +#define MAX_ISOPATHNAME 255 + +/* + * 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 assiciated 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 + +#define ISO_PVD_SECTOR 16 +#define ISO_EVD_SECTOR 17 + +#define ISO_STANDARD_ID "CD001" +#define ISO_BLOCKSIZE 2048 + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +enum strncpy_pad_check { + ISO9660_NOCHECK = 0, + ISO9660_7BIT, + ISO9660_ACHARS, + ISO9660_DCHARS +}; + +PRAGMA_BEGIN_PACKED + +struct iso9660_dtime { + uint8_t dt_year; + uint8_t dt_month; /* 1..12. Note 1 origin 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 min intervals */ +} GNUC_PACKED; + +typedef struct iso9660_dtime iso9660_dtime_t; + +struct iso9660_ltime { + char lt_year [_delta( 1, 4)]; /* Add 1900 for Julian year */ + char lt_month [_delta( 5, 6)]; /* 1..12. Note starts at 1. */ + 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)]; /* 1/100's of a second */ + int8_t lt_gmtoff [_delta( 17, 17)]; +} GNUC_PACKED; + +typedef struct iso9660_ltime iso9660_ltime_t; + +/* ISO-9660 Primary Volume Descriptor. + */ +struct iso9660_pvd { + uint8_t type; /* 711 */ + char id[5]; + uint8_t version; /* 711 */ + char unused1[1]; + char system_id[32]; /* achars */ + char volume_id[32]; /* dchars */ + char unused2[8]; + uint64_t volume_space_size; /* 733 */ + char escape_sequences[32]; + uint32_t volume_set_size; /* 723 */ + uint32_t volume_sequence_number; /* 723 */ + uint32_t logical_block_size; /* 723 */ + uint64_t path_table_size; /* 733 */ + uint32_t type_l_path_table; /* 731 */ + uint32_t opt_type_l_path_table; /* 731 */ + uint32_t type_m_path_table; /* 732 */ + uint32_t opt_type_m_path_table; /* 732 */ + char root_directory_record[34]; /* 9.1 */ + char volume_set_id[128]; /* dchars */ + char publisher_id[128]; /* achars */ + char preparer_id[128]; /* achars */ + char application_id[128]; /* achars */ + char copyright_file_id[37]; /* 7.5 dchars */ + char abstract_file_id[37]; /* 7.5 dchars */ + char bibliographic_file_id[37]; /* 7.5 dchars */ + iso9660_ltime_t creation_date; /* 8.4.26.1 */ + iso9660_ltime_t modification_date; /* 8.4.26.1 */ + iso9660_ltime_t expiration_date; /* 8.4.26.1 */ + iso9660_ltime_t effective_date; /* 8.4.26.1 */ + uint8_t file_structure_version; /* 711 */ + char unused4[1]; + char application_data[512]; + char unused5[653]; +} GNUC_PACKED; + +typedef struct iso9660_dir iso9660_dir_t; +typedef struct iso9660_pvd iso9660_pvd_t; +typedef struct iso9660_stat iso9660_stat_t; + +#ifndef EMPTY_ARRAY_SIZE +#define EMPTY_ARRAY_SIZE 0 +#endif + +/* + * XXX JS: The next structure may have an odd length! + * Some compilers (e.g. on Sun3/mc68020) padd the structures to 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 + */ + +/* Format of an ISO-9660 directory record */ +struct iso9660_dir { + uint8_t length; /* 711 */ + uint8_t xa_length; /* 711 */ + uint64_t extent; /* 733 */ + uint64_t size; /* 733 */ + iso9660_dtime_t recording_time; /* 7 by 711 */ + uint8_t file_flags; + uint8_t file_unit_size; /* 711 */ + uint8_t interleave_gap; /* 711 */ + uint32_t volume_sequence_number; /* 723 */ + uint8_t filename_len; /* 711 */ + char filename[EMPTY_ARRAY_SIZE]; +} GNUC_PACKED; + + +/* The following structure is not part of ISO 9660. We just use it + for our own purposes for communicating info back that's pulled out. +*/ +struct iso9660_stat { /* big endian!! */ + enum { _STAT_FILE = 1, _STAT_DIR = 2 } type; + 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 */ + struct tm tm; /* time on entry */ +} ; + +PRAGMA_END_PACKED + +/*==================================== + Character file/dirname's +=====================================*/ + +/*! + 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 drop deal with trailing ;1's or .;1's or + ; version numbers. + + The length of the translated string is returned. +*/ +int iso9660_name_translate(const char *old, char *new); + +/*! + 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); + +/*! + 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 *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); + + +/*===================================================================== + 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 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 in stat. + + Returns true if we found an entry with the lsn and false if not. + */ +bool iso9660_find_fs_lsn(const CdIo *cdio, lsn_t lsn, + /*out*/ iso9660_stat_t *stat); + +/*! + Get file status for pathname into stat. As with libc's stat, 0 is returned + if no error and -1 on error. + */ +int iso9660_fs_stat (const CdIo *obj, const char pathname[], + /*out*/ iso9660_stat_t *stat, bool is_mode2); + +void * /* list of char* -- caller must free it */ +iso9660_fs_readdir (const CdIo *obj, const char pathname[], bool mode2); + +uint8_t +iso9660_get_dir_len(const iso9660_dir_t *idr); + +#if FIXME +uint8_t +iso9660_get_dir_size(const iso9660_dir_t *idr); + +lsn_t +iso9660_get_dir_extent(const iso9660_dir_t *idr); +#endif + +uint8_t +iso9660_get_pvd_type(const iso9660_pvd_t *pvd); + +const char * +iso9660_get_pvd_id(const iso9660_pvd_t *pvd); + +int +iso9660_get_pvd_space_size(const iso9660_pvd_t *pvd); + +int +iso9660_get_pvd_block_size(const iso9660_pvd_t *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 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 *pvd); + +/* 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); + +#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/src/input/vcd/libcdio/cdio/logging.h b/src/input/vcd/libcdio/cdio/logging.h new file mode 100644 index 000000000..9a600b437 --- /dev/null +++ b/src/input/vcd/libcdio/cdio/logging.h @@ -0,0 +1,66 @@ +/* + $Id: logging.h,v 1.1 2003/10/13 11:47:12 f1rmb 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 __LOGGING_H__ +#define __LOGGING_H__ + +#include <cdio/types.h> + +typedef enum { + CDIO_LOG_DEBUG = 1, + CDIO_LOG_INFO, + CDIO_LOG_WARN, + CDIO_LOG_ERROR, + CDIO_LOG_ASSERT +} cdio_log_level_t; + +extern int cdio_loglevel_default; + +void +cdio_log (cdio_log_level_t level, const char format[], ...) GNUC_PRINTF(2, 3); + +typedef void (*cdio_log_handler_t) (cdio_log_level_t level, + const char message[]); + +cdio_log_handler_t +cdio_log_set_handler (cdio_log_handler_t new_handler); + +void +cdio_debug (const char format[], ...) GNUC_PRINTF(1,2); + +void +cdio_info (const char format[], ...) GNUC_PRINTF(1,2); + +void +cdio_warn (const char format[], ...) GNUC_PRINTF(1,2); + +void +cdio_error (const char format[], ...) GNUC_PRINTF(1,2); + +#endif /* __LOGGING_H__ */ + + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/src/input/vcd/libcdio/cdio/sector.h b/src/input/vcd/libcdio/cdio/sector.h new file mode 100644 index 000000000..39dd0fefb --- /dev/null +++ b/src/input/vcd/libcdio/cdio/sector.h @@ -0,0 +1,162 @@ +/* + $Id: sector.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + + Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> + Copyright (C) 2003 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 +*/ +/* + Things related to CDROM layout. Sector sizes, MSFs, LBAs, +*/ + +#ifndef _CDIO_SECTOR_H_ +#define _CDIO_SECTOR_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#include <cdio/types.h> + +#define CDIO_PREGAP_SECTORS 150 +#define CDIO_POSTGAP_SECTORS 150 + +/* + * 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: + * + * 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 | + * + */ + +/* + 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 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/ +#define CDIO_CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-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 (Linux 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! */ + +#define CDIO_CDROM_DATA_TRACK 0x04 + +/* The leadout track is always 0xAA, regardless of # of tracks on disc */ +#define CDIO_CDROM_LEADOUT_TRACK 0xAA + +#define M2F2_SECTOR_SIZE 2324 +#define M2SUB_SECTOR_SIZE 2332 +#define M2RAW_SECTOR_SIZE 2336 + +#define CDIO_CD_MAX_TRACKS 99 +#define CDIO_CD_MIN_TRACK_NO 1 + +#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 + +/* warning, returns new allocated string */ +char *cdio_lba_to_msf_str (lba_t lba); + +lba_t cdio_lba_to_lsn (lba_t lba); + +void cdio_lba_to_msf(lba_t lba, msf_t *msf); + +lba_t cdio_lsn_to_lba (lsn_t lsn); + +void cdio_lsn_to_msf (lsn_t lsn, msf_t *msf); + +lba_t +cdio_msf_to_lba (const msf_t *msf); + +lsn_t +cdio_msf_to_lsn (const msf_t *msf); + +#ifdef __cplusplus + } +#endif + +#endif /* _CDIO_SECTOR_H_ */ + + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/src/input/vcd/libcdio/cdio/types.h b/src/input/vcd/libcdio/cdio/types.h new file mode 100644 index 000000000..e3c3ff3e5 --- /dev/null +++ b/src/input/vcd/libcdio/cdio/types.h @@ -0,0 +1,236 @@ +/* + $Id: types.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + + Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> + Copyright (C) 2002,2003 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_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 defined (MINGW32) + typedef int ssize_t; +#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 + } _Bool; + +# define false false +# define true true +# define bool _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) + + /* In many structures on the disk a sector address is stored as a + BCD-encoded mmssff in three bytes. */ + PRAGMA_BEGIN_PACKED + typedef struct { + uint8_t m, s, f; + } GNUC_PACKED msf_t; + PRAGMA_END_PACKED + +#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. */ + typedef uint32_t lba_t; + + /* The type of an Logical Sector Number. */ + typedef uint32_t lsn_t; + + /* The type of an track number 0..99. */ + typedef uint8_t track_t; + + /*! + Constant for invalid track number + */ +#define CDIO_INVALID_TRACK 0xFF + + /*! + Constant for invalid LBA + */ +#define CDIO_INVALID_LBA 0xFFFFFFFF + + /*! + Constant for invalid LSN + */ +#define CDIO_INVALID_LSN 0xFFFFFFFF + +typedef int cdio_fs_anal_t; + +#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/src/input/vcd/libcdio/cdio/util.h b/src/input/vcd/libcdio/cdio/util.h new file mode 100644 index 000000000..147a32365 --- /dev/null +++ b/src/input/vcd/libcdio/cdio/util.h @@ -0,0 +1,109 @@ +/* + $Id: util.h,v 1.1 2003/10/13 11:47:12 f1rmb 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_UTIL_H__ +#define __CDIO_UTIL_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; +} + +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); + +static inline const char * +_cdio_bool_str (bool b) +{ + return b ? "yes" : "no"; +} + +/* BCD */ + +uint8_t to_bcd8(uint8_t n); +uint8_t from_bcd8(uint8_t p); + +#endif /* __CDIO_UTIL_H__ */ + + +/* + * Local variables: + * c-file-style: "gnu" + * tab-width: 8 + * indent-tabs-mode: nil + * End: + */ diff --git a/src/input/vcd/libcdio/cdio/version.h b/src/input/vcd/libcdio/cdio/version.h new file mode 100644 index 000000000..c8bbce698 --- /dev/null +++ b/src/input/vcd/libcdio/cdio/version.h @@ -0,0 +1 @@ +#define CDIO_VERSION "0.64-cvs" diff --git a/src/input/vcd/libcdio/cdio/xa.h b/src/input/vcd/libcdio/cdio/xa.h new file mode 100644 index 000000000..06e5df250 --- /dev/null +++ b/src/input/vcd/libcdio/cdio/xa.h @@ -0,0 +1,121 @@ +/* + $Id: xa.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + + Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> + Copyright (C) 2003 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 +*/ + +#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) + +/* + * Extended Attributes record according to Yellow Book. + */ +typedef struct iso9660_xa /* big endian!! */ +{ + 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 */ +} iso9660_xa_t GNUC_PACKED; + + +/*! + 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); + +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: + */ |