diff options
93 files changed, 6364 insertions, 2799 deletions
diff --git a/src/input/vcd/libcdio/MSWindows/aspi32.c b/src/input/vcd/libcdio/MSWindows/aspi32.c new file mode 100644 index 000000000..bb568fcc7 --- /dev/null +++ b/src/input/vcd/libcdio/MSWindows/aspi32.c @@ -0,0 +1,588 @@ +/* + $Id: aspi32.c,v 1.1 2004/04/11 12:20:31 miguelfreitas Exp $ + + 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 +*/ + +/* This file contains Win32-specific code and implements low-level + control of the CD drive via the ASPI API. + Inspired by vlc's cdrom.h code +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +static const char _rcsid[] = "$Id: aspi32.c,v 1.1 2004/04/11 12:20:31 miguelfreitas Exp $"; + +#include <cdio/cdio.h> +#include <cdio/sector.h> +#include <cdio/util.h> +#include "cdio_assert.h" +#include "scsi_mmc.h" + +#include <string.h> + +#ifdef HAVE_WIN32_CDROM + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> + +#include <windows.h> +#include "win32.h" + +#include <sys/stat.h> +#include <sys/types.h> +#include "aspi32.h" + +/* General ioctl() CD-ROM command function */ +static bool +wnaspi32_mciSendCommand(int id, UINT msg, DWORD flags, void *arg) +{ + MCIERROR mci_error; + + mci_error = mciSendCommand(id, msg, flags, (DWORD)arg); + if ( mci_error ) { + char error[256]; + + mciGetErrorString(mci_error, error, 256); + cdio_warn("mciSendCommand() error: %s", error); + } + return(mci_error == 0); +} + +const char * +wnaspi32_is_cdrom(const char drive_letter) +{ + static char psz_win32_drive[7]; + HMODULE hASPI = NULL; + long (*lpGetSupport)( void ) = NULL; + long (*lpSendCommand)( void* ) = NULL; + DWORD dwSupportInfo; + int i_adapter, i_num_adapters; + char c_drive; + + hASPI = LoadLibrary( "wnaspi32.dll" ); + if( hASPI != NULL ) { + (FARPROC) lpGetSupport = GetProcAddress( hASPI, + "GetASPI32SupportInfo" ); + (FARPROC) lpSendCommand = GetProcAddress( hASPI, + "SendASPI32Command" ); + } + + if( hASPI == NULL || lpGetSupport == NULL || lpSendCommand == NULL ) { + cdio_debug("Unable to load ASPI or get ASPI function pointers"); + if( hASPI ) FreeLibrary( hASPI ); + return NULL; + } + + /* ASPI support seems to be there */ + + dwSupportInfo = lpGetSupport(); + + if( HIBYTE( LOWORD ( dwSupportInfo ) ) == SS_NO_ADAPTERS ) { + cdio_debug("no host adapters found (ASPI)"); + FreeLibrary( hASPI ); + return NULL; + } + + if( HIBYTE( LOWORD ( dwSupportInfo ) ) != SS_COMP ) { + cdio_debug("Unable to initalize ASPI layer"); + FreeLibrary( hASPI ); + return NULL; + } + + i_num_adapters = LOBYTE( LOWORD( dwSupportInfo ) ); + if( i_num_adapters == 0 ) { + FreeLibrary( hASPI ); + return NULL; + } + + c_drive = toupper(drive_letter) - 'A'; + + for( i_adapter = 0; i_adapter < i_num_adapters; i_adapter++ ) { + struct SRB_GetDiskInfo srbDiskInfo; + int i_target; + SRB_HAInquiry srbInquiry; + + srbInquiry.SRB_Cmd = SC_HA_INQUIRY; + srbInquiry.SRB_HaId = i_adapter; + + lpSendCommand( (void*) &srbInquiry ); + + if( srbInquiry.SRB_Status != SS_COMP ) continue; + if( !srbInquiry.HA_Unique[3]) srbInquiry.HA_Unique[3]=8; + + for(i_target=0; i_target < srbInquiry.HA_Unique[3]; i_target++) + { + int i_lun; + for( i_lun=0; i_lun<8; i_lun++) + { + srbDiskInfo.SRB_Cmd = SC_GET_DISK_INFO; + srbDiskInfo.SRB_Flags = 0; + srbDiskInfo.SRB_Hdr_Rsvd = 0; + srbDiskInfo.SRB_HaId = i_adapter; + srbDiskInfo.SRB_Target = i_target; + srbDiskInfo.SRB_Lun = i_lun; + + lpSendCommand( (void*) &srbDiskInfo ); + + if( (srbDiskInfo.SRB_Status == SS_COMP) && + (srbDiskInfo.SRB_Int13HDriveInfo == c_drive) ) { + /* Make sure this is a cdrom device */ + struct SRB_GDEVBlock srbGDEVBlock; + + memset( &srbGDEVBlock, 0, sizeof(struct SRB_GDEVBlock) ); + srbGDEVBlock.SRB_Cmd = SC_GET_DEV_TYPE; + srbDiskInfo.SRB_HaId = i_adapter; + srbGDEVBlock.SRB_Target = i_target; + + lpSendCommand( (void*) &srbGDEVBlock ); + + if( ( srbGDEVBlock.SRB_Status == SS_COMP ) && + ( srbGDEVBlock.SRB_DeviceType == DTYPE_CDROM ) ) { + sprintf( psz_win32_drive, "%c:", drive_letter ); + FreeLibrary( hASPI ); + return(psz_win32_drive); + } + } + } + } + } + FreeLibrary( hASPI ); + return NULL; +} + +/*! + Initialize CD device. + */ +bool +wnaspi32_init_win32 (_img_private_t *env) +{ + HMODULE hASPI = NULL; + long (*lpGetSupport)( void ) = NULL; + long (*lpSendCommand)( void* ) = NULL; + DWORD dwSupportInfo; + int i, j, i_num_adapters; + char c_drive = env->gen.source_name[0]; + + hASPI = LoadLibrary( "wnaspi32.dll" ); + if( hASPI != NULL ) { + (FARPROC) lpGetSupport = GetProcAddress( hASPI, + "GetASPI32SupportInfo" ); + (FARPROC) lpSendCommand = GetProcAddress( hASPI, + "SendASPI32Command" ); + } + + if( hASPI == NULL || lpGetSupport == NULL || lpSendCommand == NULL ) { + cdio_debug("Unable to load ASPI or get ASPI function pointers"); + if( hASPI ) FreeLibrary( hASPI ); + return false; + } + + /* ASPI support seems to be there */ + + dwSupportInfo = lpGetSupport(); + + if( HIBYTE( LOWORD ( dwSupportInfo ) ) == SS_NO_ADAPTERS ) { + cdio_debug("no host adapters found (ASPI)"); + FreeLibrary( hASPI ); + return -1; + } + + if( HIBYTE( LOWORD ( dwSupportInfo ) ) != SS_COMP ) { + cdio_debug("unable to initalize ASPI layer"); + FreeLibrary( hASPI ); + return -1; + } + + i_num_adapters = LOBYTE( LOWORD( dwSupportInfo ) ); + if( i_num_adapters == 0 ) { + FreeLibrary( hASPI ); + return -1; + } + + c_drive = toupper(c_drive) - 'A'; + + for( i = 0; i < i_num_adapters; i++ ) { + for( j = 0; j < 15; j++ ) { + struct SRB_GetDiskInfo srbDiskInfo; + int lun; + + for (lun = 0; lun < 8; lun++ ) { + srbDiskInfo.SRB_Cmd = SC_GET_DISK_INFO; + srbDiskInfo.SRB_HaId = i; + srbDiskInfo.SRB_Flags = 0; + srbDiskInfo.SRB_Hdr_Rsvd = 0; + srbDiskInfo.SRB_Target = j; + srbDiskInfo.SRB_Lun = lun; + + lpSendCommand( (void*) &srbDiskInfo ); + + if( (srbDiskInfo.SRB_Status == SS_COMP) ) { + + if (srbDiskInfo.SRB_Int13HDriveInfo != c_drive) + { + continue; + } else { + /* Make sure this is a cdrom device */ + struct SRB_GDEVBlock srbGDEVBlock; + + memset( &srbGDEVBlock, 0, sizeof(struct SRB_GDEVBlock) ); + srbGDEVBlock.SRB_Cmd = SC_GET_DEV_TYPE; + srbGDEVBlock.SRB_HaId = i; + srbGDEVBlock.SRB_Target = j; + + lpSendCommand( (void*) &srbGDEVBlock ); + + if( ( srbGDEVBlock.SRB_Status == SS_COMP ) && + ( srbGDEVBlock.SRB_DeviceType == DTYPE_CDROM ) ) { + env->i_sid = MAKEWORD( i, j ); + env->hASPI = (long)hASPI; + env->lpSendCommand = lpSendCommand; + cdio_debug("Using ASPI layer"); + + return true; + } else { + FreeLibrary( hASPI ); + cdio_debug( "%c: is not a CD-ROM drive", + env->gen.source_name[0] ); + return false; + } + } + } + } + } + } + + FreeLibrary( hASPI ); + cdio_debug( "Unable to get HaId and target (ASPI)" ); + return false; +} + +/*! + Reads a single mode2 sector from cd device into data starting from lsn. + Returns 0 if no error. + */ +static int +wnaspi32_mmc_read_sectors (_img_private_t *env, void *data, lsn_t lsn, + int sector_type, unsigned int nblocks) +{ + unsigned char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, }; + HANDLE hEvent; + struct SRB_ExecSCSICmd ssc; + +#if 1 + sector_type = 0; /*all types */ + int sync = 0; + int header_code = 2; + int i_user_data = 1; + int edc_ecc = 0; + int error_field = 0; +#endif + + + /* Create the transfer completion event */ + hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); + if( hEvent == NULL ) { + return 1; + } + + /* Data selection */ + + memset( &ssc, 0, sizeof( ssc ) ); + + ssc.SRB_Cmd = SC_EXEC_SCSI_CMD; + ssc.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY; + ssc.SRB_HaId = LOBYTE( env->i_sid ); + ssc.SRB_Target = HIBYTE( env->i_sid ); + ssc.SRB_SenseLen = SENSE_LEN; + + ssc.SRB_PostProc = (LPVOID) hEvent; + ssc.SRB_CDBLen = 12; + + /* Operation code */ + ssc.CDBByte[ 0 ] = CDIO_MMC_GPCMD_READ_CD; + + CDIO_MMC_SET_READ_TYPE(ssc.CDBByte, sector_type); + CDIO_MMC_SET_READ_LBA(ssc.CDBByte, lsn); + CDIO_MMC_SET_READ_LENGTH(ssc.CDBByte, nblocks); + +#if 1 + ssc.CDBByte[ 9 ] = (sync << 7) | + (header_code << 5) | + (i_user_data << 4) | + (edc_ecc << 3) | + (error_field << 1); + /* ssc.CDBByte[ 9 ] = READ_CD_USERDATA_MODE2; */ +#else + CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(ssc.CDBByte, + CDIO_MMC_MCSB_ALL_HEADERS); +#endif + + /* Result buffer */ + ssc.SRB_BufPointer = buf; + ssc.SRB_BufLen = CDIO_CD_FRAMESIZE_RAW; + + /* Initiate transfer */ + ResetEvent( hEvent ); + env->lpSendCommand( (void*) &ssc ); + + /* If the command has still not been processed, wait until it's + * finished */ + if( ssc.SRB_Status == SS_PENDING ) { + WaitForSingleObject( hEvent, INFINITE ); + } + CloseHandle( hEvent ); + + /* check that the transfer went as planned */ + if( ssc.SRB_Status != SS_COMP ) { + return 1; + } + + /* FIXME! remove the 8 (SUBHEADER size) below... */ + memcpy (data, buf, CDIO_CD_FRAMESIZE_RAW); + + return 0; +} + +/*! + Reads an audio device into data starting from lsn. + Returns 0 if no error. + */ +int +wnaspi32_read_audio_sectors (_img_private_t *env, void *data, lsn_t lsn, + unsigned int nblocks) +{ + return wnaspi32_mmc_read_sectors( env, data, lsn, CDIO_MMC_READ_TYPE_CDDA, + nblocks ); +} + +/*! + Reads a single mode2 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ +int +wnaspi32_read_mode2_sector (_img_private_t *env, void *data, lsn_t lsn) +{ + return wnaspi32_mmc_read_sectors(env, data, lsn, CDIO_MMC_READ_TYPE_ANY, + 1); +} + +/*! + Read and cache the CD's Track Table of Contents and track info. + Return true if successful or false if an error. +*/ +bool +wnaspi32_read_toc (_img_private_t *env) +{ + HANDLE hEvent; + struct SRB_ExecSCSICmd ssc; + unsigned char p_tocheader[ 4 ]; + + /* Create the transfer completion event */ + hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); + if( hEvent == NULL ) { + return false; + } + + memset( &ssc, 0, sizeof( ssc ) ); + + ssc.SRB_Cmd = SC_EXEC_SCSI_CMD; + ssc.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY; + ssc.SRB_HaId = LOBYTE( env->i_sid ); + ssc.SRB_Target = HIBYTE( env->i_sid ); + ssc.SRB_SenseLen = SENSE_LEN; + + ssc.SRB_PostProc = (LPVOID) hEvent; + ssc.SRB_CDBLen = 10; + + /* Operation code */ + ssc.CDBByte[ 0 ] = READ_TOC; + + /* Format */ + ssc.CDBByte[ 2 ] = READ_TOC_FORMAT_TOC; + + /* Starting track */ + ssc.CDBByte[ 6 ] = 0; + + /* Allocation length and buffer */ + ssc.SRB_BufLen = sizeof( p_tocheader ); + ssc.SRB_BufPointer = p_tocheader; + ssc.CDBByte[ 7 ] = ( ssc.SRB_BufLen >> 8 ) & 0xff; + ssc.CDBByte[ 8 ] = ( ssc.SRB_BufLen ) & 0xff; + + /* Initiate transfer */ + ResetEvent( hEvent ); + env->lpSendCommand( (void*) &ssc ); + + /* If the command has still not been processed, wait until it's + * finished */ + if( ssc.SRB_Status == SS_PENDING ) + WaitForSingleObject( hEvent, INFINITE ); + + /* check that the transfer went as planned */ + if( ssc.SRB_Status != SS_COMP ) { + CloseHandle( hEvent ); + return false; + } + + env->first_track_num = p_tocheader[2]; + env->total_tracks = p_tocheader[3] - p_tocheader[2] + 1; + + { + int i, i_toclength; + unsigned char *p_fulltoc; + + i_toclength = 4 /* header */ + p_tocheader[0] + + ((unsigned int)p_tocheader[1] << 8); + + p_fulltoc = malloc( i_toclength ); + + if( p_fulltoc == NULL ) { + cdio_error( "out of memory" ); + CloseHandle( hEvent ); + return false; + } + + /* Allocation length and buffer */ + ssc.SRB_BufLen = i_toclength; + ssc.SRB_BufPointer = p_fulltoc; + ssc.CDBByte[ 7 ] = ( ssc.SRB_BufLen >> 8 ) & 0xff; + ssc.CDBByte[ 8 ] = ( ssc.SRB_BufLen ) & 0xff; + + /* Initiate transfer */ + ResetEvent( hEvent ); + env->lpSendCommand( (void*) &ssc ); + + /* If the command has still not been processed, wait until it's + * finished */ + if( ssc.SRB_Status == SS_PENDING ) + WaitForSingleObject( hEvent, INFINITE ); + + /* check that the transfer went as planned */ + if( ssc.SRB_Status != SS_COMP ) + env->total_tracks = 0; + + for( i = 0 ; i <= env->total_tracks ; i++ ) { + int i_index = 8 + 8 * i; + env->tocent[ i ].start_lsn = ((int)p_fulltoc[ i_index ] << 24) + + ((int)p_fulltoc[ i_index+1 ] << 16) + + ((int)p_fulltoc[ i_index+2 ] << 8) + + (int)p_fulltoc[ i_index+3 ]; + env->tocent[ i ].Control = (UCHAR)p_fulltoc[ 1 + 8 * i ]; + + cdio_debug( "p_sectors: %i %lu", + i, (unsigned long int) env->tocent[i].start_lsn ); + } + + free( p_fulltoc ); + } + + CloseHandle( hEvent ); + env->gen.toc_init = true; + return true; +} + +/* Eject media will eventually get removed from _cdio_win32.c */ +#if 0 +/*! + Eject media. Return 1 if successful, 0 otherwise. + */ +int +wnaspi32_eject_media (void *user_data) { + + _img_private_t *env = user_data; + + + MCI_OPEN_PARMS op; + MCI_STATUS_PARMS st; + DWORD i_flags; + char psz_drive[4]; + int ret; + + memset( &op, 0, sizeof(MCI_OPEN_PARMS) ); + op.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO; + strcpy( psz_drive, "X:" ); + psz_drive[0] = env->gen.source_name[0]; + op.lpstrElementName = psz_drive; + + /* Set the flags for the device type */ + i_flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | + MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE; + + if( wnaspi32_mciSendCommand( 0, MCI_OPEN, i_flags, &op ) ) { + st.dwItem = MCI_STATUS_READY; + /* Eject disc */ + ret = wnaspi32_mciSendCommand( op.wDeviceID, MCI_SET, + MCI_SET_DOOR_OPEN, 0 ) != 0; + /* Release access to the device */ + wnaspi32_mciSendCommand( op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0 ); + } else + ret = 0; + + return ret; +} +#endif + +/*! + Get format of track. +*/ +track_format_t +wnaspi32_get_track_format(_img_private_t *env, track_t track_num) +{ + MCI_OPEN_PARMS op; + MCI_STATUS_PARMS st; + DWORD i_flags; + int ret; + + memset( &op, 0, sizeof(MCI_OPEN_PARMS) ); + op.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO; + op.lpstrElementName = env->gen.source_name; + + /* Set the flags for the device type */ + i_flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | + MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE; + + if( wnaspi32_mciSendCommand( 0, MCI_OPEN, i_flags, &op ) ) { + st.dwItem = MCI_CDA_STATUS_TYPE_TRACK; + st.dwTrack = track_num; + i_flags = MCI_TRACK | MCI_STATUS_ITEM ; + ret = wnaspi32_mciSendCommand( op.wDeviceID, MCI_STATUS, i_flags, &st ); + + /* Release access to the device */ + wnaspi32_mciSendCommand( op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0 ); + + switch(st.dwReturn) { + case MCI_CDA_TRACK_AUDIO: + return TRACK_FORMAT_AUDIO; + case MCI_CDA_TRACK_OTHER: + return TRACK_FORMAT_DATA; + default: + return TRACK_FORMAT_XA; + } + } + return TRACK_FORMAT_ERROR; +} + +#endif /* HAVE_WIN32_CDROM */ + + diff --git a/src/input/vcd/libcdio/MSWindows/aspi32.h b/src/input/vcd/libcdio/MSWindows/aspi32.h new file mode 100644 index 000000000..381d6c154 --- /dev/null +++ b/src/input/vcd/libcdio/MSWindows/aspi32.h @@ -0,0 +1,146 @@ +/* Win32 aspi specific */ +/* + $Id: aspi32.h,v 1.1 2004/04/11 12:20:31 miguelfreitas 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 +*/ + +#define ASPI_HAID 0 +#define ASPI_TARGET 0 +#define DTYPE_CDROM 0x05 + +#define SENSE_LEN 0x0E +#define SC_HA_INQUIRY 0x00 +#define SC_GET_DEV_TYPE 0x01 +#define SC_EXEC_SCSI_CMD 0x02 +#define SC_GET_DISK_INFO 0x06 +#define SS_COMP 0x01 +#define SS_PENDING 0x00 +#define SS_NO_ADAPTERS 0xE8 +#define SRB_DIR_IN 0x08 +#define SRB_DIR_OUT 0x10 +#define SRB_EVENT_NOTIFY 0x40 + +#define SECTOR_TYPE_MODE2 0x14 +#define READ_CD_USERDATA_MODE2 0x10 + +#define READ_TOC 0x43 +#define READ_TOC_FORMAT_TOC 0x0 + +#pragma pack(1) + +struct SRB_GetDiskInfo +{ + unsigned char SRB_Cmd; + unsigned char SRB_Status; + unsigned char SRB_HaId; + unsigned char SRB_Flags; + unsigned long SRB_Hdr_Rsvd; + unsigned char SRB_Target; + unsigned char SRB_Lun; + unsigned char SRB_DriveFlags; + unsigned char SRB_Int13HDriveInfo; + unsigned char SRB_Heads; + unsigned char SRB_Sectors; + unsigned char SRB_Rsvd1[22]; +}; + +struct SRB_GDEVBlock +{ + unsigned char SRB_Cmd; + unsigned char SRB_Status; + unsigned char SRB_HaId; + unsigned char SRB_Flags; + unsigned long SRB_Hdr_Rsvd; + unsigned char SRB_Target; + unsigned char SRB_Lun; + unsigned char SRB_DeviceType; + unsigned char SRB_Rsvd1; +}; + +struct SRB_ExecSCSICmd +{ + unsigned char SRB_Cmd; + unsigned char SRB_Status; + unsigned char SRB_HaId; + unsigned char SRB_Flags; + unsigned long SRB_Hdr_Rsvd; + unsigned char SRB_Target; + unsigned char SRB_Lun; + unsigned short SRB_Rsvd1; + unsigned long SRB_BufLen; + unsigned char *SRB_BufPointer; + unsigned char SRB_SenseLen; + unsigned char SRB_CDBLen; + unsigned char SRB_HaStat; + unsigned char SRB_TargStat; + unsigned long *SRB_PostProc; + unsigned char SRB_Rsvd2[20]; + unsigned char CDBByte[16]; + unsigned char SenseArea[SENSE_LEN+2]; +}; + +/***************************************************************************** + %%% SRB - HOST ADAPTER INQUIRY - SC_HA_INQUIRY (0) %%% +*****************************************************************************/ + +typedef struct // Offset +{ // HX/DEC + BYTE SRB_Cmd; // 00/000 ASPI command code = SC_HA_INQUIRY + BYTE SRB_Status; // 01/001 ASPI command status byte + BYTE SRB_HaId; // 02/002 ASPI host adapter number + BYTE SRB_Flags; // 03/003 ASPI request flags + DWORD SRB_Hdr_Rsvd; // 04/004 Reserved, MUST = 0 + BYTE HA_Count; // 08/008 Number of host adapters present + BYTE HA_SCSI_ID; // 09/009 SCSI ID of host adapter + BYTE HA_ManagerId[16]; // 0A/010 String describing the manager + BYTE HA_Identifier[16]; // 1A/026 String describing the host adapter + BYTE HA_Unique[16]; // 2A/042 Host Adapter Unique parameters + WORD HA_Rsvd1; // 3A/058 Reserved, MUST = 0 +} +SRB_HAInquiry; + +const char * wnaspi32_is_cdrom(const char drive_letter); + +/*! + Initialize CD device. + */ +bool wnaspi32_init_win32 (_img_private_t *env); + +/*! + Reads an audio device into data starting from lsn. + Returns 0 if no error. + */ +int wnaspi32_read_audio_sectors (_img_private_t *env, void *data, lsn_t lsn, + unsigned int nblocks); +/*! + Reads a single mode2 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ +int wnaspi32_read_mode2_sector (_img_private_t *env, void *data, lsn_t lsn); + +/*! + Read and cache the CD's Track Table of Contents and track info. + Return true if successful or false if an error. +*/ +bool wnaspi32_read_toc (_img_private_t *env); + +/*! + Get format of track. +*/ +track_format_t wnaspi32_get_track_format(_img_private_t *env, + track_t track_num); diff --git a/src/input/vcd/libcdio/MSWindows/ioctl.c b/src/input/vcd/libcdio/MSWindows/ioctl.c new file mode 100644 index 000000000..1d2f99420 --- /dev/null +++ b/src/input/vcd/libcdio/MSWindows/ioctl.c @@ -0,0 +1,472 @@ +/*
+ $Id: ioctl.c,v 1.1 2004/04/11 12:20:31 miguelfreitas Exp $
+
+ 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
+*/
+
+/* This file contains Win32-specific code using the DeviceIoControl
+ access method.
+*/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+static const char _rcsid[] = "$Id: ioctl.c,v 1.1 2004/04/11 12:20:31 miguelfreitas Exp $";
+
+#include <cdio/cdio.h>
+#include <cdio/sector.h>
+#include "cdio_assert.h"
+
+#ifdef HAVE_WIN32_CDROM
+
+#include <windows.h>
+#include <winioctl.h>
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "scsi_mmc.h"
+
+/* Win32 DeviceIoControl specifics */
+/***** FIXME: #include ntddcdrm.h from Wine, but probably need to
+ modify it a little.
+*/
+
+#define SCSI_IOCTL_DATA_OUT 0 //Give data to SCSI device (e.g. for writing)
+#define SCSI_IOCTL_DATA_IN 1 //Get data from SCSI device (e.g. for reading)
+#define SCSI_IOCTL_DATA_UNSPECIFIED 2 //No data (e.g. for ejecting)
+
+#define IOCTL_SCSI_PASS_THROUGH 0x4D004
+typedef struct ScsiPassThrough {
+ unsigned short Length;
+ unsigned char ScsiStatus;
+ unsigned char PathId;
+ unsigned char TargetId;
+ unsigned char Lun;
+ unsigned char CdbLength;
+ unsigned char SenseInfoLength;
+ unsigned char DataIn;
+ unsigned int DataTransferLength;
+ unsigned int TimeOutValue;
+ unsigned int DataBufferOffset;
+ unsigned int SenseInfoOffset;
+ unsigned char Cdb[16];
+} SCSI_PASS_THROUGH;
+
+#define IOCTL_SCSI_PASS_THROUGH_DIRECT 0x4D014
+typedef struct _SCSI_PASS_THROUGH_DIRECT {
+ USHORT Length;
+ UCHAR ScsiStatus;
+ UCHAR PathId;
+ UCHAR TargetId;
+ UCHAR Lun;
+ UCHAR CdbLength;
+ UCHAR SenseInfoLength;
+ UCHAR DataIn;
+ ULONG DataTransferLength;
+ ULONG TimeOutValue;
+ PVOID DataBuffer;
+ ULONG SenseInfoOffset;
+ UCHAR Cdb[16];
+} SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
+
+#ifndef IOCTL_CDROM_BASE
+# define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
+#endif
+#ifndef IOCTL_CDROM_RAW_READ
+#define IOCTL_CDROM_RAW_READ CTL_CODE(IOCTL_CDROM_BASE, 0x000F, \
+ METHOD_OUT_DIRECT, FILE_READ_ACCESS)
+#endif
+
+#ifndef IOCTL_CDROM_BASE
+# define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
+#endif
+#ifndef IOCTL_CDROM_READ_TOC
+#define IOCTL_CDROM_READ_TOC \
+ CTL_CODE(IOCTL_CDROM_BASE, 0x0000, METHOD_BUFFERED, FILE_READ_ACCESS)
+#endif
+#ifndef IOCTL_CDROM_RAW_READ
+#define IOCTL_CDROM_RAW_READ \
+ CTL_CODE(IOCTL_CDROM_BASE, 0x000F, METHOD_OUT_DIRECT, FILE_READ_ACCESS)
+#endif
+
+#ifndef IOCTL_CDROM_READ_Q_CHANNEL
+#define IOCTL_CDROM_READ_Q_CHANNEL \
+ CTL_CODE(IOCTL_CDROM_BASE, 0x000B, METHOD_BUFFERED, FILE_READ_ACCESS)
+#endif
+
+typedef struct _TRACK_DATA {
+ UCHAR Format;
+ UCHAR Control : 4;
+ UCHAR Adr : 4;
+ UCHAR TrackNumber;
+ UCHAR Reserved1;
+ UCHAR Address[4];
+} TRACK_DATA, *PTRACK_DATA;
+
+typedef struct _CDROM_TOC {
+ UCHAR Length[2];
+ UCHAR FirstTrack;
+ UCHAR LastTrack;
+ TRACK_DATA TrackData[CDIO_CD_MAX_TRACKS+1];
+} CDROM_TOC, *PCDROM_TOC;
+
+#define IOCTL_CDROM_SUB_Q_CHANNEL 0x00
+#define IOCTL_CDROM_CURRENT_POSITION 0x01
+#define IOCTL_CDROM_MEDIA_CATALOG 0x02
+#define IOCTL_CDROM_TRACK_ISRC 0x03
+
+typedef enum _TRACK_MODE_TYPE {
+ YellowMode2,
+ XAForm2,
+ CDDA
+} TRACK_MODE_TYPE, *PTRACK_MODE_TYPE;
+
+typedef struct __RAW_READ_INFO {
+ LARGE_INTEGER DiskOffset;
+ ULONG SectorCount;
+ TRACK_MODE_TYPE TrackMode;
+} RAW_READ_INFO, *PRAW_READ_INFO;
+
+typedef struct _CDROM_SUB_Q_DATA_FORMAT {
+ UCHAR Format;
+ UCHAR Track;
+} CDROM_SUB_Q_DATA_FORMAT, *PCDROM_SUB_Q_DATA_FORMAT;
+
+typedef struct _SUB_Q_HEADER {
+ UCHAR Reserved;
+ UCHAR AudioStatus;
+ UCHAR DataLength[2];
+} SUB_Q_HEADER, *PSUB_Q_HEADER;
+
+typedef struct _SUB_Q_MEDIA_CATALOG_NUMBER {
+ SUB_Q_HEADER Header;
+ UCHAR FormatCode;
+ UCHAR Reserved[3];
+ UCHAR Reserved1 : 7;
+ UCHAR Mcval :1;
+ UCHAR MediaCatalog[15];
+} SUB_Q_MEDIA_CATALOG_NUMBER, *PSUB_Q_MEDIA_CATALOG_NUMBER;
+
+#include "win32.h"
+
+/*
+ Returns a string that can be used in a CreateFile call if
+ c_drive letter is a character. If not NULL is returned.
+ */
+
+const char *
+win32ioctl_is_cdrom(const char c_drive_letter)
+{
+
+ UINT uDriveType;
+ char sz_win32_drive[4];
+
+ sz_win32_drive[0]= c_drive_letter;
+ sz_win32_drive[1]=':';
+ sz_win32_drive[2]='\\';
+ sz_win32_drive[3]='\0';
+
+ uDriveType = GetDriveType(sz_win32_drive);
+
+ switch(uDriveType) {
+ case DRIVE_CDROM: {
+ char sz_win32_drive_full[] = "\\\\.\\X:";
+ sz_win32_drive_full[4] = c_drive_letter;
+ return strdup(sz_win32_drive_full);
+ }
+ default:
+ cdio_debug("Drive %c is not a CD-ROM", c_drive_letter);
+ return NULL;
+ }
+}
+
+/*!
+ Reads an audio device using the DeviceIoControl method into data
+ starting from lsn. Returns 0 if no error.
+ */
+int
+win32ioctl_read_audio_sectors (_img_private_t *env, void *data, lsn_t lsn,
+ unsigned int nblocks)
+{
+ DWORD dwBytesReturned;
+ RAW_READ_INFO cdrom_raw;
+
+ /* Initialize CDROM_RAW_READ structure */
+ cdrom_raw.DiskOffset.QuadPart = CDIO_CD_FRAMESIZE_RAW * lsn;
+ cdrom_raw.SectorCount = nblocks;
+ cdrom_raw.TrackMode = CDDA;
+
+ if( DeviceIoControl( env->h_device_handle,
+ IOCTL_CDROM_RAW_READ, &cdrom_raw,
+ sizeof(RAW_READ_INFO), data,
+ CDIO_CD_FRAMESIZE_RAW * nblocks,
+ &dwBytesReturned, NULL ) == 0 ) {
+ cdio_info("Error reading audio-mode %lu (%ld)\n",
+ (long unsigned int) lsn, GetLastError());
+ return 1;
+ }
+ return 0;
+}
+
+/*!
+ Reads a single raw sector using the DeviceIoControl method into
+ data starting from lsn. Returns 0 if no error.
+ */
+static int
+win32ioctl_read_raw_sector (_img_private_t *env, void *buf, lsn_t lsn)
+{
+ SCSI_PASS_THROUGH_DIRECT sptd;
+ BOOL success;
+ DWORD dwBytesReturned;
+
+ sptd.Length=sizeof(sptd);
+ sptd.PathId=0; /* SCSI card ID will be filled in automatically */
+ sptd.TargetId=0; /* SCSI target ID will also be filled in */
+ sptd.Lun=0; /* SCSI lun ID will also be filled in */
+ sptd.CdbLength=12; /* CDB size is 12 for ReadCD MMC1 command */
+ sptd.SenseInfoLength=0; /* Don't return any sense data */
+ sptd.DataIn=SCSI_IOCTL_DATA_IN; //There will be data from drive
+ sptd.DataTransferLength=CDIO_CD_FRAMESIZE_RAW;
+ sptd.TimeOutValue=60; /*SCSI timeout value (60 seconds -
+ maybe it should be longer) */
+ sptd.DataBuffer= (PVOID) buf;
+ sptd.SenseInfoOffset=0;
+
+ /* ReadCD CDB12 command. The values were taken from MMC1 draft paper. */
+ sptd.Cdb[0]=CDIO_MMC_GPCMD_READ_CD;
+ sptd.Cdb[1]=0;
+
+ CDIO_MMC_SET_READ_LBA(sptd.Cdb, lsn);
+
+ CDIO_MMC_SET_READ_LENGTH(sptd.Cdb, 1);
+
+ sptd.Cdb[9]=0xF8; /* Raw read, 2352 bytes per sector */
+ sptd.Cdb[10]=0;
+ sptd.Cdb[11]=0;
+ sptd.Cdb[12]=0;
+ sptd.Cdb[13]=0;
+ sptd.Cdb[14]=0;
+ sptd.Cdb[15]=0;
+
+ /* Send the command to drive */
+ success=DeviceIoControl(env->h_device_handle,
+ IOCTL_SCSI_PASS_THROUGH_DIRECT,
+ (PVOID)&sptd,
+ (DWORD)sizeof(SCSI_PASS_THROUGH_DIRECT),
+ NULL, 0,
+ &dwBytesReturned,
+ NULL);
+
+ if(! success) {
+ cdio_info("Error reading %lu (%ld)\n", (long unsigned) lsn,
+ GetLastError());
+ return 1;
+ }
+
+ return 0;
+}
+
+/*!
+ Reads a single mode2 sector using the DeviceIoControl method into
+ data starting from lsn. Returns 0 if no error.
+ */
+int
+win32ioctl_read_mode2_sector (_img_private_t *env, void *data, lsn_t lsn,
+ bool mode2_form2)
+{
+ char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
+ int ret = win32ioctl_read_raw_sector (env, buf, lsn);
+
+ if ( 0 != ret) return ret;
+
+ memcpy (data,
+ buf + CDIO_CD_SYNC_SIZE + CDIO_CD_XA_HEADER,
+ mode2_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE);
+
+ return 0;
+
+}
+
+/*!
+ Reads a single mode2 sector using the DeviceIoControl method into
+ data starting from lsn. Returns 0 if no error.
+ */
+int
+win32ioctl_read_mode1_sector (_img_private_t *env, void *data, lsn_t lsn,
+ bool mode2_form2)
+{
+ char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
+ int ret = win32ioctl_read_raw_sector (env, buf, lsn);
+
+ if ( 0 != ret) return ret;
+
+ memcpy (data,
+ buf + CDIO_CD_SYNC_SIZE+CDIO_CD_HEADER_SIZE,
+ mode2_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE);
+
+ return 0;
+
+}
+
+/*!
+ Initialize internal structures for CD device.
+ */
+bool
+win32ioctl_init_win32 (_img_private_t *env)
+{
+ char psz_win32_drive[7];
+ unsigned int len=strlen(env->gen.source_name);
+ OSVERSIONINFO ov;
+ DWORD dw_access_flags;
+
+ cdio_debug("using winNT/2K/XP ioctl layer");
+
+ memset(&ov,0,sizeof(OSVERSIONINFO));
+ ov.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
+ GetVersionEx(&ov);
+
+ if((ov.dwPlatformId==VER_PLATFORM_WIN32_NT) &&
+ (ov.dwMajorVersion>4))
+ dw_access_flags = GENERIC_READ|GENERIC_WRITE; /* add gen write on W2k/XP */
+ else dw_access_flags = GENERIC_READ;
+
+ if (cdio_is_device_win32(env->gen.source_name)) {
+ sprintf( psz_win32_drive, "\\\\.\\%c:", env->gen.source_name[len-2] );
+
+ env->h_device_handle = CreateFile( psz_win32_drive,
+ dw_access_flags,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL );
+ if( env->h_device_handle == INVALID_HANDLE_VALUE )
+ {
+ /* No good. try toggle write. */
+ dw_access_flags ^= GENERIC_WRITE;
+ env->h_device_handle = CreateFile( psz_win32_drive,
+ dw_access_flags,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL );
+ return (env->h_device_handle == NULL) ? false : true;
+ }
+ return true;
+ }
+ return false;
+}
+
+#define MSF_TO_LBA2(min, sec, frame) \
+ ((int) frame + CDIO_CD_FRAMES_PER_SEC * (CDIO_CD_SECS_PER_MIN*min + sec) \
+ - CDIO_PREGAP_SECTORS )
+
+/*!
+ Read and cache the CD's Track Table of Contents and track info.
+ Return true if successful or false if an error.
+*/
+bool
+win32ioctl_read_toc (_img_private_t *env)
+{
+
+ DWORD dwBytesReturned;
+ CDROM_TOC cdrom_toc;
+ int i;
+
+ if( DeviceIoControl( env->h_device_handle,
+ IOCTL_CDROM_READ_TOC,
+ NULL, 0, &cdrom_toc, sizeof(CDROM_TOC),
+ &dwBytesReturned, NULL ) == 0 ) {
+ cdio_warn( "could not read TOCHDR: %ld" , (long int) GetLastError());
+ return false;
+ }
+
+ env->first_track_num = cdrom_toc.FirstTrack;
+ env->total_tracks = cdrom_toc.LastTrack - cdrom_toc.FirstTrack + 1;
+
+
+ for( i = 0 ; i <= env->total_tracks ; i++ ) {
+ env->tocent[ i ].start_lsn = MSF_TO_LBA2(
+ cdrom_toc.TrackData[i].Address[1],
+ cdrom_toc.TrackData[i].Address[2],
+ cdrom_toc.TrackData[i].Address[3] );
+ env->tocent[ i ].Control = cdrom_toc.TrackData[i].Control;
+ env->tocent[ i ].Format = cdrom_toc.TrackData[i].Format;
+ cdio_debug("p_sectors: %i, %lu", i,
+ (unsigned long int) (env->tocent[i].start_lsn));
+ }
+ env->gen.toc_init = true;
+ return true;
+}
+
+/*!
+ Return the media catalog number MCN.
+
+ Note: string is malloc'd so caller should free() then returned
+ string when done with it.
+
+ */
+char *
+win32ioctl_get_mcn (_img_private_t *env) {
+
+ DWORD dwBytesReturned;
+ SUB_Q_MEDIA_CATALOG_NUMBER mcn;
+ CDROM_SUB_Q_DATA_FORMAT q_data_format;
+
+ memset( &mcn, 0, sizeof(mcn) );
+
+ q_data_format.Format = IOCTL_CDROM_MEDIA_CATALOG;
+
+ q_data_format.Track=1;
+
+ if( DeviceIoControl( env->h_device_handle,
+ IOCTL_CDROM_READ_Q_CHANNEL,
+ &q_data_format, sizeof(q_data_format),
+ &mcn, sizeof(mcn),
+ &dwBytesReturned, NULL ) == 0 ) {
+ cdio_warn( "could not read Q Channel at track %d", 1);
+ } else if (mcn.Mcval)
+ return strdup(mcn.MediaCatalog);
+ return NULL;
+}
+
+/*!
+ Get the format (XA, DATA, AUDIO) of a track.
+*/
+track_format_t
+win32ioctl_get_track_format(_img_private_t *env, track_t track_num)
+{
+ /* This is pretty much copied from the "badly broken" cdrom_count_tracks
+ in linux/cdrom.c.
+ */
+ if (env->tocent[track_num-1].Control & 0x04) {
+ if (env->tocent[track_num-1].Format == 0x10)
+ return TRACK_FORMAT_CDI;
+ else if (env->tocent[track_num-1].Format == 0x20)
+ return TRACK_FORMAT_XA;
+ else
+ return TRACK_FORMAT_DATA;
+ } else
+ return TRACK_FORMAT_AUDIO;
+}
+
+
+#endif /*HAVE_WIN32_CDROM*/
diff --git a/src/input/vcd/libcdio/MSWindows/win32.c b/src/input/vcd/libcdio/MSWindows/win32.c new file mode 100644 index 000000000..13ccb9131 --- /dev/null +++ b/src/input/vcd/libcdio/MSWindows/win32.c @@ -0,0 +1,672 @@ +/* + $Id: win32.c,v 1.1 2004/04/11 12:20:31 miguelfreitas 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 +*/ + +/* This file contains Win32-specific code and implements low-level + control of the CD drive. Inspired by vlc's cdrom.h code +*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +static const char _rcsid[] = "$Id: win32.c,v 1.1 2004/04/11 12:20:31 miguelfreitas Exp $"; + +#include <cdio/cdio.h> +#include <cdio/sector.h> +#include <cdio/util.h> +#include "cdio_assert.h" +#include "cdio_private.h" /* protoype for cdio_is_device_win32 */ +#include "scsi_mmc.h" + +#include <string.h> + +#ifdef HAVE_WIN32_CDROM + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> + +#include <windows.h> +#include <winioctl.h> +#include "win32.h" + +#include <sys/stat.h> +#include <sys/types.h> +#include "aspi32.h" + +#define WIN_NT ( GetVersion() < 0x80000000 ) + +/* General ioctl() CD-ROM command function */ +static bool +_cdio_mciSendCommand(int id, UINT msg, DWORD flags, void *arg) +{ + MCIERROR mci_error; + + mci_error = mciSendCommand(id, msg, flags, (DWORD)arg); + if ( mci_error ) { + char error[256]; + + mciGetErrorString(mci_error, error, 256); + cdio_warn("mciSendCommand() error: %s", error); + } + return(mci_error == 0); +} + +static const char * +cdio_is_cdrom(const char drive_letter) { + if ( WIN_NT ) { + return win32ioctl_is_cdrom(drive_letter); + } else { + return wnaspi32_is_cdrom(drive_letter); + } +} + +/*! + Initialize CD device. + */ +static bool +_cdio_init_win32 (void *user_data) +{ + _img_private_t *env = user_data; + if (env->gen.init) { + cdio_error ("init called more than once"); + return false; + } + + env->gen.init = true; + env->toc_init = false; + + + /* Initializations */ + env->h_device_handle = NULL; + env->i_sid = 0; + env->hASPI = 0; + env->lpSendCommand = 0; + + if ( WIN_NT ) { + return win32ioctl_init_win32(env); + } else { + return wnaspi32_init_win32(env); + } +} + +/*! + Release and free resources associated with cd. + */ +static void +_cdio_win32_free (void *user_data) +{ + _img_private_t *env = user_data; + + if (NULL == env) return; + free (env->gen.source_name); + + if( env->h_device_handle ) + CloseHandle( env->h_device_handle ); + if( env->hASPI ) + FreeLibrary( (HMODULE)env->hASPI ); + + free (env); +} + +/*! + Reads an audio device into data starting from lsn. + Returns 0 if no error. + */ +static int +_cdio_read_audio_sectors (void *user_data, void *data, lsn_t lsn, + unsigned int nblocks) +{ + _img_private_t *env = user_data; + if ( env->hASPI ) { + return wnaspi32_read_audio_sectors( env, data, lsn, nblocks ); + } else { + return win32ioctl_read_audio_sectors( env, data, lsn, nblocks ); + } +} + +/*! + Reads a single mode1 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ +static int +_cdio_read_mode1_sector (void *user_data, void *data, lsn_t lsn, + bool b_form2) +{ + _img_private_t *env = user_data; + + if (env->gen.ioctls_debugged == 75) + cdio_debug ("only displaying every 75th ioctl from now on"); + + if (env->gen.ioctls_debugged == 30 * 75) + cdio_debug ("only displaying every 30*75th ioctl from now on"); + + if (env->gen.ioctls_debugged < 75 + || (env->gen.ioctls_debugged < (30 * 75) + && env->gen.ioctls_debugged % 75 == 0) + || env->gen.ioctls_debugged % (30 * 75) == 0) + cdio_debug ("reading %lu", (unsigned long int) lsn); + + env->gen.ioctls_debugged++; + + if ( env->hASPI ) { + return 1; + } else { + return win32ioctl_read_mode1_sector( env, data, lsn, b_form2 ); + } +} + +/*! + Reads nblocks of mode1 sectors from cd device into data starting + from lsn. + Returns 0 if no error. + */ +static int +_cdio_read_mode1_sectors (void *user_data, void *data, lsn_t lsn, + bool b_form2, unsigned int nblocks) +{ + _img_private_t *env = user_data; + int i; + int retval; + + for (i = 0; i < nblocks; i++) { + if (b_form2) { + if ( (retval = _cdio_read_mode1_sector (env, + ((char *)data) + (M2RAW_SECTOR_SIZE * i), + lsn + i, true)) ) + return retval; + } else { + char buf[M2RAW_SECTOR_SIZE] = { 0, }; + if ( (retval = _cdio_read_mode1_sector (env, buf, lsn + i, false)) ) + return retval; + + memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i), + buf, CDIO_CD_FRAMESIZE); + } + } + return 0; +} + +/*! + Reads a single mode2 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ +static int +_cdio_read_mode2_sector (void *user_data, void *data, lsn_t lsn, + bool b_form2) +{ + char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, }; + _img_private_t *env = user_data; + + if (env->gen.ioctls_debugged == 75) + cdio_debug ("only displaying every 75th ioctl from now on"); + + if (env->gen.ioctls_debugged == 30 * 75) + cdio_debug ("only displaying every 30*75th ioctl from now on"); + + if (env->gen.ioctls_debugged < 75 + || (env->gen.ioctls_debugged < (30 * 75) + && env->gen.ioctls_debugged % 75 == 0) + || env->gen.ioctls_debugged % (30 * 75) == 0) + cdio_debug ("reading %lu", (unsigned long int) lsn); + + env->gen.ioctls_debugged++; + + if ( env->hASPI ) { + int ret; + ret = wnaspi32_read_mode2_sector(user_data, buf, lsn); + if( ret != 0 ) return ret; + if (b_form2) + memcpy (data, buf, M2RAW_SECTOR_SIZE); + else + memcpy (((char *)data), buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); + return 0; + } else { + return win32ioctl_read_mode2_sector( env, data, lsn, b_form2 ); + } +} + +/*! + Reads nblocks of mode2 sectors from cd device into data starting + from lsn. + Returns 0 if no error. + */ +static int +_cdio_read_mode2_sectors (void *user_data, void *data, lsn_t lsn, + bool b_form2, unsigned int nblocks) +{ + int i; + int retval; + unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE; + + for (i = 0; i < nblocks; i++) { + if ( (retval = _cdio_read_mode2_sector (user_data, + ((char *)data) + (blocksize * i), + lsn + i, b_form2)) ) + return retval; + } + return 0; +} + +/*! + Return the size of the CD in logical block address (LBA) units. + */ +static uint32_t +_cdio_stat_size (void *user_data) +{ + _img_private_t *env = user_data; + + return env->tocent[env->total_tracks].start_lsn; +} + +/*! + Set the key "arg" to "value" in source device. +*/ +static int +_cdio_set_arg (void *user_data, const char key[], const char value[]) +{ + _img_private_t *env = user_data; + + if (!strcmp (key, "source")) + { + if (!value) + return -2; + + free (env->gen.source_name); + + env->gen.source_name = strdup (value); + } + else + return -1; + + return 0; +} + +/*! + Read and cache the CD's Track Table of Contents and track info. + Return true if successful or false if an error. +*/ +static bool +_cdio_read_toc (_img_private_t *env) +{ + bool ret; + if( env->hASPI ) { + ret = wnaspi32_read_toc( env ); + } else { + ret =win32ioctl_read_toc(env); + } + if (ret) env->gen.toc_init = true ; + return true; +} + +/*! + Eject media. Return 1 if successful, 0 otherwise. + */ +static int +_cdio_eject_media (void *user_data) { + + _img_private_t *env = user_data; + + + MCI_OPEN_PARMS op; + MCI_STATUS_PARMS st; + DWORD i_flags; + char psz_drive[4]; + int ret; + + memset( &op, 0, sizeof(MCI_OPEN_PARMS) ); + op.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO; + strcpy( psz_drive, "X:" ); + psz_drive[0] = env->gen.source_name[0]; + op.lpstrElementName = psz_drive; + + /* Set the flags for the device type */ + i_flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | + MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE; + + if( _cdio_mciSendCommand( 0, MCI_OPEN, i_flags, &op ) ) { + st.dwItem = MCI_STATUS_READY; + /* Eject disc */ + ret = _cdio_mciSendCommand( op.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0 ) != 0; + /* Release access to the device */ + _cdio_mciSendCommand( op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0 ); + } else + ret = 0; + + return ret; +} + +/*! + Return the value associated with the key "arg". +*/ +static const char * +_cdio_get_arg (void *user_data, const char key[]) +{ + _img_private_t *env = user_data; + + if (!strcmp (key, "source")) { + return env->gen.source_name; + } else if (!strcmp (key, "access-mode")) { + if (env->hASPI) + return "ASPI"; + else if ( WIN_NT ) + return "winNT/2K/XP ioctl"; + else + return "undefined WIN32"; + } + return NULL; +} + +/*! + Return the number of of the first track. + CDIO_INVALID_TRACK is returned on error. +*/ +static track_t +_cdio_get_first_track_num(void *user_data) +{ + _img_private_t *env = user_data; + + if (!env->toc_init) _cdio_read_toc (env) ; + + return env->first_track_num; +} + +/*! + Return the media catalog number MCN. + + Note: string is malloc'd so caller should free() then returned + string when done with it. + + */ +static char * +_cdio_get_mcn (void *env) { + + _img_private_t *_env = env; + + if( ! _env->hASPI ) { + win32ioctl_get_mcn(_env); + } + return NULL; +} + +/*! + Return the number of tracks in the current medium. + CDIO_INVALID_TRACK is returned on error. +*/ +static track_t +_cdio_get_num_tracks(void *user_data) +{ + _img_private_t *env = user_data; + + if (!env->toc_init) _cdio_read_toc (env) ; + + return env->total_tracks; +} + +/*! + Get format of track. +*/ +static track_format_t +_cdio_get_track_format(void *obj, track_t track_num) +{ + _img_private_t *env = obj; + + if (!env->gen.toc_init) _cdio_read_toc (env) ; + + if (track_num > env->total_tracks || track_num == 0) + return TRACK_FORMAT_ERROR; + + if( env->hASPI ) { + return wnaspi32_get_track_format(env, track_num); + } else { + return win32ioctl_get_track_format(env, 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? +*/ +static bool +_cdio_get_track_green(void *obj, track_t track_num) +{ + _img_private_t *env = obj; + + if (!env->toc_init) _cdio_read_toc (env) ; + + if (track_num == CDIO_CDROM_LEADOUT_TRACK) track_num = env->total_tracks+1; + + if (track_num > env->total_tracks+1 || track_num == 0) + return false; + + switch (_cdio_get_track_format(env, track_num)) { + case TRACK_FORMAT_ERROR: + case TRACK_FORMAT_CDI: + case TRACK_FORMAT_AUDIO: + return false; + default: + break; + } + + /* FIXME: Dunno if this is the right way, but it's what + I was using in cd-info for a while. + */ + return ((env->tocent[track_num-1].Control & 2) != 0); +} + +/*! + 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. +*/ +static bool +_cdio_get_track_msf(void *env, track_t track_num, msf_t *msf) +{ + _img_private_t *_obj = env; + + if (NULL == msf) return false; + + if (!_obj->toc_init) _cdio_read_toc (_obj) ; + + if (track_num == CDIO_CDROM_LEADOUT_TRACK) track_num = _obj->total_tracks+1; + + if (track_num > _obj->total_tracks+1 || track_num == 0) { + return false; + } else { + cdio_lsn_to_msf(_obj->tocent[track_num-1].start_lsn, msf); + return true; + } +} + +#endif /* HAVE_WIN32_CDROM */ + +/*! + Return an array of strings giving possible CD devices. + */ +char ** +cdio_get_devices_win32 (void) +{ +#ifndef HAVE_WIN32_CDROM + return NULL; +#else + char **drives = NULL; + unsigned int num_drives=0; + char drive_letter; + + /* Scan the system for CD-ROM drives. + */ + +#if FINISHED + /* Now check the currently mounted CD drives */ + if (NULL != (ret_drive = cdio_check_mounts("/etc/mtab"))) { + cdio_add_device_list(&drives, drive, &num_drives); + } + + /* Finally check possible mountable drives in /etc/fstab */ + if (NULL != (ret_drive = cdio_check_mounts("/etc/fstab"))) { + cdio_add_device_list(&drives, drive, &num_drives); + } +#endif + + /* Scan the system for CD-ROM drives. + Not always 100% reliable, so use the USE_MNTENT code above first. + */ + for (drive_letter='A'; drive_letter <= 'Z'; drive_letter++) { + const char *drive_str=cdio_is_cdrom(drive_letter); + if (drive_str != NULL) { + cdio_add_device_list(&drives, drive_str, &num_drives); + } + } + cdio_add_device_list(&drives, NULL, &num_drives); + return drives; +#endif /*HAVE_WIN32_CDROM*/ +} + +/*! + Return a string containing the default CD device if none is specified. + if CdIo 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_win32(void) +{ + +#ifdef HAVE_WIN32_CDROM + char drive_letter; + + for (drive_letter='A'; drive_letter <= 'Z'; drive_letter++) { + const char *drive_str=cdio_is_cdrom(drive_letter); + if (drive_str != NULL) { + return strdup(drive_str); + } + } +#endif + return NULL; +} + +/*! + Return true if source_name could be a device containing a CD-ROM. +*/ +bool +cdio_is_device_win32(const char *source_name) +{ + unsigned int len; + len = strlen(source_name); + + if (NULL == source_name) return false; + +#ifdef HAVE_WIN32_CDROM + if ((len == 2) && isalpha(source_name[0]) + && (source_name[len-1] == ':')) + return true; + + if ( ! WIN_NT ) return false; + + /* Test to see if of form: \\.\x: */ + return ( (len == 6) + && source_name[0] == '\\' && source_name[1] == '\\' + && source_name[2] == '.' && source_name[3] == '\\' + && isalpha(source_name[len-2]) + && (source_name[len-1] == ':') ); +#else + return false; +#endif +} + +/*! + Initialization routine. This is the only thing that doesn't + get called via a function pointer. In fact *we* are the + ones to set that up. + */ +CdIo * +cdio_open_win32 (const char *source_name) +{ + +#ifdef HAVE_WIN32_CDROM + CdIo *ret; + _img_private_t *_data; + + cdio_funcs _funcs = { + .eject_media = _cdio_eject_media, + .free = _cdio_win32_free, + .get_arg = _cdio_get_arg, + .get_default_device = cdio_get_default_device_win32, + .get_devices = cdio_get_devices_win32, + .get_first_track_num= _cdio_get_first_track_num, + .get_mcn = _cdio_get_mcn, + .get_num_tracks = _cdio_get_num_tracks, + .get_track_format = _cdio_get_track_format, + .get_track_green = _cdio_get_track_green, + .get_track_lba = NULL, /* This could be implemented if need be. */ + .get_track_msf = _cdio_get_track_msf, + .lseek = NULL, + .read = NULL, + .read_audio_sectors = _cdio_read_audio_sectors, + .read_mode1_sector = _cdio_read_mode1_sector, + .read_mode1_sectors = _cdio_read_mode1_sectors, + .read_mode2_sector = _cdio_read_mode2_sector, + .read_mode2_sectors = _cdio_read_mode2_sectors, + .set_arg = _cdio_set_arg, + .stat_size = _cdio_stat_size + }; + + _data = _cdio_malloc (sizeof (_img_private_t)); + _data->gen.init = false; + _data->gen.fd = -1; + + _cdio_set_arg(_data, "source", (NULL == source_name) + ? cdio_get_default_device_win32(): source_name); + + ret = cdio_new (_data, &_funcs); + if (ret == NULL) return NULL; + + if (_cdio_init_win32(_data)) + return ret; + else { + _cdio_win32_free (_data); + return NULL; + } + +#else + return NULL; +#endif /* HAVE_WIN32_CDROM */ + +} + +bool +cdio_have_win32 (void) +{ +#ifdef HAVE_WIN32_CDROM + return true; +#else + return false; +#endif /* HAVE_WIN32_CDROM */ +} diff --git a/src/input/vcd/libcdio/MSWindows/win32.h b/src/input/vcd/libcdio/MSWindows/win32.h new file mode 100644 index 000000000..d70797c08 --- /dev/null +++ b/src/input/vcd/libcdio/MSWindows/win32.h @@ -0,0 +1,90 @@ +/*
+ $Id: win32.h,v 1.1 2004/04/11 12:20:31 miguelfreitas Exp $
+
+ 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
+*/
+
+#include "cdio_private.h"
+
+#pragma pack()
+
+typedef struct {
+ lsn_t start_lsn;
+ UCHAR Control : 4;
+ UCHAR Format;
+} track_info_t;
+
+typedef struct {
+ /* Things common to all drivers like this.
+ This must be first. */
+ generic_img_private_t gen;
+
+ HANDLE h_device_handle; /* device descriptor */
+ long hASPI;
+ short i_sid;
+ long (*lpSendCommand)( void* );
+
+ /* Track information */
+ bool toc_init; /* if true, info below is valid. */
+ track_info_t tocent[100]; /* entry info for each track */
+ track_t total_tracks; /* number of tracks in image */
+ track_t first_track_num; /* track number of first track */
+
+} _img_private_t;
+
+/*!
+ Reads an audio device using the DeviceIoControl method into data
+ starting from lsn. Returns 0 if no error.
+ */
+int win32ioctl_read_audio_sectors (_img_private_t *obj, void *data, lsn_t lsn,
+ unsigned int nblocks);
+/*!
+ Reads a single mode2 sector using the DeviceIoControl method into
+ data starting from lsn. Returns 0 if no error.
+ */
+int
+win32ioctl_read_mode2_sector (_img_private_t *env, void *data, lsn_t lsn,
+ bool mode2_form2);
+
+/*!
+ Reads a single mode1 sector using the DeviceIoControl method into
+ data starting from lsn. Returns 0 if no error.
+ */
+int
+win32ioctl_read_mode1_sector (_img_private_t *env, void *data, lsn_t lsn,
+ bool mode2_form2);
+
+const char *win32ioctl_is_cdrom(const char drive_letter);
+
+/*!
+ Initialize internal structures for CD device.
+ */
+bool win32ioctl_init_win32 (_img_private_t *env);
+
+/*!
+ Read and cache the CD's Track Table of Contents and track info.
+ Return true if successful or false if an error.
+*/
+bool win32ioctl_read_toc (_img_private_t *env);
+
+char *win32ioctl_get_mcn (_img_private_t *env);
+
+/*!
+ Get the format (XA, DATA, AUDIO) of a track.
+*/
+track_format_t win32ioctl_get_track_format(_img_private_t *env,
+ track_t track_num);
diff --git a/src/input/vcd/libcdio/Makefile.am b/src/input/vcd/libcdio/Makefile.am index 636c734f7..799d4585f 100644 --- a/src/input/vcd/libcdio/Makefile.am +++ b/src/input/vcd/libcdio/Makefile.am @@ -1,21 +1,25 @@ include $(top_srcdir)/misc/Makefile.common -SUBDIRS = cdio +SUBDIRS = cdio MSWindows image INCLUDES = $(LIBCDIO_CFLAGS) libcdio_SRCS = \ - _cdio_bincue.c \ + image/bincue.c \ + image/nrg.c \ + MSWindows/aspi32.c \ + MSWindows/aspi32.h \ + MSWindows/ioctl.c \ + MSWindows/win32.c \ + MSWindows/win32.h \ _cdio_bsdi.c \ _cdio_freebsd.c \ _cdio_generic.c \ _cdio_linux.c \ _cdio_osx.c \ - _cdio_nrg.c \ _cdio_stdio.c \ _cdio_stream.c \ _cdio_sunos.c \ - _cdio_win32.c \ cdio.c \ cd_types.c \ ds.c \ diff --git a/src/input/vcd/libcdio/_cdio_bsdi.c b/src/input/vcd/libcdio/_cdio_bsdi.c index c3770b592..7fd60a9d9 100644 --- a/src/input/vcd/libcdio/_cdio_bsdi.c +++ b/src/input/vcd/libcdio/_cdio_bsdi.c @@ -1,8 +1,8 @@ /* - $Id: _cdio_bsdi.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: _cdio_bsdi.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com> + 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 @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; +static const char _rcsid[] = "$Id: _cdio_bsdi.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; #include <cdio/sector.h> #include <cdio/util.h> @@ -196,12 +196,57 @@ _read_audio_sectors (void *env, void *data, lsn_t lsn, } /*! + Reads a single mode1 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ +static int +_cdio_read_mode1_sector (void *env, void *data, lsn_t lsn, + bool b_form2) +{ + + char buf[M2RAW_SECTOR_SIZE] = { 0, }; +#if FIXED + do something here. +#else + if (0 > cdio_generic_lseek(env, CDIO_CD_FRAMESIZE*lsn, SEEK_SET)) + return -1; + if (0 > cdio_generic_read(env, buf, CDIO_CD_FRAMESIZE)) + return -1; + memcpy (data, buf, b_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE); +#endif + return 0; +} + +/*! + Reads nblocks of mode2 sectors from cd device into data starting + from lsn. + Returns 0 if no error. + */ +static int +_cdio_read_mode1_sectors (void *env, void *data, lsn_t lsn, + bool b_form2, unsigned int nblocks) +{ + _img_private_t *_obj = env; + unsigned int i; + int retval; + unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE; + + for (i = 0; i < nblocks; i++) { + if ( (retval = _cdio_read_mode1_sector (_obj, + ((char *)data) + (blocksize * i), + lsn + i, b_form2)) ) + return retval; + } + return 0; +} + +/*! Reads a single mode2 sector from cd device into data starting from lsn. Returns 0 if no error. */ static int _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, - bool mode2_form2) + bool b_form2) { char buf[M2RAW_SECTOR_SIZE] = { 0, }; struct cdrom_msf *msf = (struct cdrom_msf *) &buf; @@ -246,7 +291,7 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, break; } - if (mode2_form2) + if (b_form2) memcpy (data, buf, M2RAW_SECTOR_SIZE); else memcpy (((char *)data), buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); @@ -261,14 +306,14 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, */ static int _cdio_read_mode2_sectors (void *env, void *data, lsn_t lsn, - bool mode2_form2, unsigned int nblocks) + bool b_form2, unsigned int nblocks) { _img_private_t *_obj = env; int i; int retval; for (i = 0; i < nblocks; i++) { - if (mode2_form2) { + if (b_form2) { if ( (retval = _cdio_read_mode2_sector (_obj, ((char *)data) + (M2RAW_SECTOR_SIZE * i), lsn + i, true)) ) @@ -667,8 +712,10 @@ cdio_open_bsdi (const char *source_name) .get_track_msf = _cdio_get_track_msf, .lseek = cdio_generic_lseek, .read = cdio_generic_read, - .read_mode2_sector = _cdio_read_mode2_sector, .read_audio_sectors = _read_audio_sectors, + .read_mode1_sector = _cdio_read_mode1_sector, + .read_mode1_sectors = _cdio_read_mode1_sectors, + .read_mode2_sector = _cdio_read_mode2_sector, .read_mode2_sectors = _cdio_read_mode2_sectors, .set_arg = _cdio_set_arg, .stat_size = _cdio_stat_size diff --git a/src/input/vcd/libcdio/_cdio_freebsd.c b/src/input/vcd/libcdio/_cdio_freebsd.c index 1eaf227ef..0aae6a6a8 100644 --- a/src/input/vcd/libcdio/_cdio_freebsd.c +++ b/src/input/vcd/libcdio/_cdio_freebsd.c @@ -1,5 +1,5 @@ /* - $Id: _cdio_freebsd.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: _cdio_freebsd.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_freebsd.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; +static const char _rcsid[] = "$Id: _cdio_freebsd.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; #include <cdio/sector.h> #include <cdio/util.h> diff --git a/src/input/vcd/libcdio/_cdio_generic.c b/src/input/vcd/libcdio/_cdio_generic.c index 180de1086..1328fb2a7 100644 --- a/src/input/vcd/libcdio/_cdio_generic.c +++ b/src/input/vcd/libcdio/_cdio_generic.c @@ -1,8 +1,8 @@ /* - $Id: _cdio_generic.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: _cdio_generic.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com> + 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 @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; +static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; #include <stdio.h> #include <stdlib.h> @@ -126,7 +126,7 @@ cdio_generic_read (void *user_data, void *buf, size_t size) Release and free resources associated with stream or disk image. */ void -cdio_generic_stream_free (void *user_data) +cdio_generic_stdio_free (void *user_data) { generic_img_private_t *_obj = user_data; @@ -134,9 +134,7 @@ cdio_generic_stream_free (void *user_data) free (_obj->source_name); if (_obj->data_source) - cdio_stream_destroy (_obj->data_source); - - free (_obj); + cdio_stdio_destroy (_obj->data_source); } @@ -177,17 +175,31 @@ cdio_add_device_list(char **device_list[], const char *drive, int *num_drives) { if (NULL != drive) { unsigned int j; + + /* Check if drive is already in list. */ for (j=0; j<*num_drives; j++) { if (strcmp((*device_list)[j], drive) == 0) break; } + if (j==*num_drives) { + /* Drive not in list. Add it. */ (*num_drives)++; - *device_list = realloc(*device_list, (*num_drives) * sizeof(char *)); + if (*device_list) { + *device_list = realloc(*device_list, (*num_drives) * sizeof(char *)); + } else { + /* num_drives should be 0. Add assert? */ + *device_list = malloc((*num_drives) * sizeof(char *)); + } + (*device_list)[*num_drives-1] = strdup(drive); } } else { (*num_drives)++; - *device_list = realloc(*device_list, (*num_drives) * sizeof(char *)); + if (*device_list) { + *device_list = realloc(*device_list, (*num_drives) * sizeof(char *)); + } else { + *device_list = malloc((*num_drives) * sizeof(char *)); + } (*device_list)[*num_drives-1] = NULL; } } diff --git a/src/input/vcd/libcdio/_cdio_linux.c b/src/input/vcd/libcdio/_cdio_linux.c index 51afb728e..e5dd47551 100644 --- a/src/input/vcd/libcdio/_cdio_linux.c +++ b/src/input/vcd/libcdio/_cdio_linux.c @@ -1,8 +1,8 @@ /* - $Id: _cdio_linux.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: _cdio_linux.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com> + 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 @@ -27,7 +27,7 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; +static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; #include <string.h> @@ -110,7 +110,7 @@ cdio_is_cdrom(char *drive, char *mnttype) } /* If it does exist, verify that it's an available CD-ROM */ - cdfd = open(drive, (O_RDONLY|O_EXCL|O_NONBLOCK), 0); + cdfd = open(drive, (O_RDONLY|O_NONBLOCK), 0); if ( cdfd >= 0 ) { if ( ioctl(cdfd, CDROMREADTOCHDR, &tochdr) != -1 ) { is_cd = true; @@ -177,10 +177,9 @@ cdio_check_mounts(const char *mtab) } if ( strcmp(mnt_type, "iso9660") == 0 ) { if (cdio_is_cdrom(mnt_dev, mnt_type) > 0) { - free(mnt_dev); free(mnt_type); endmntent(mntfp); - return strdup(mnt_dev); + return mnt_dev; } } free(mnt_dev); @@ -354,12 +353,109 @@ _read_packet_mode2_sectors (int fd, void *buf, lba_t lba, } /*! + Reads a single mode1 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ +static int +_cdio_read_mode1_sector (void *env, void *data, lsn_t lsn, + bool b_form2) +{ + + char buf[M2RAW_SECTOR_SIZE] = { 0, }; +#if FIXED + struct cdrom_msf *msf = (struct cdrom_msf *) &buf; + msf_t _msf; + + _img_private_t *_obj = env; + + cdio_lba_to_msf (cdio_lsn_to_lba(lsn), &_msf); + msf->cdmsf_min0 = from_bcd8(_msf.m); + msf->cdmsf_sec0 = from_bcd8(_msf.s); + msf->cdmsf_frame0 = from_bcd8(_msf.f); + + retry: + switch (_obj->access_mode) + { + case _AM_NONE: + cdio_error ("no way to read mode1"); + return 1; + break; + + case _AM_IOCTL: + if (ioctl (_obj->gen.fd, CDROMREADMODE1, &buf) == -1) + { + perror ("ioctl()"); + return 1; + /* exit (EXIT_FAILURE); */ + } + break; + + case _AM_READ_CD: + case _AM_READ_10: + if (_read_packet_mode2_sectors (_obj->gen.fd, buf, lsn, 1, + (_obj->access_mode == _AM_READ_10))) + { + perror ("ioctl()"); + if (_obj->access_mode == _AM_READ_CD) + { + cdio_info ("READ_CD failed; switching to READ_10 mode..."); + _obj->access_mode = _AM_READ_10; + goto retry; + } + else + { + cdio_info ("READ_10 failed; switching to ioctl(CDROMREADMODE2) mode..."); + _obj->access_mode = _AM_IOCTL; + goto retry; + } + return 1; + } + break; + } + + memcpy (data, buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE, + b_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE); + +#else + if (0 > cdio_generic_lseek(env, CDIO_CD_FRAMESIZE*lsn, SEEK_SET)) + return -1; + if (0 > cdio_generic_read(env, buf, CDIO_CD_FRAMESIZE)) + return -1; + memcpy (data, buf, b_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE); +#endif + return 0; +} + +/*! + Reads nblocks of mode2 sectors from cd device into data starting + from lsn. + Returns 0 if no error. + */ +static int +_cdio_read_mode1_sectors (void *env, void *data, lsn_t lsn, + bool b_form2, unsigned int nblocks) +{ + _img_private_t *_obj = env; + unsigned int i; + int retval; + unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE; + + for (i = 0; i < nblocks; i++) { + if ( (retval = _cdio_read_mode1_sector (_obj, + ((char *)data) + (blocksize * i), + lsn + i, b_form2)) ) + return retval; + } + return 0; +} + +/*! Reads a single mode2 sector from cd device into data starting from lsn. Returns 0 if no error. */ static int _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, - bool mode2_form2) + bool b_form2) { char buf[M2RAW_SECTOR_SIZE] = { 0, }; struct cdrom_msf *msf = (struct cdrom_msf *) &buf; @@ -412,7 +508,7 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, break; } - if (mode2_form2) + if (b_form2) memcpy (data, buf, M2RAW_SECTOR_SIZE); else memcpy (((char *)data), buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); @@ -427,27 +523,18 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, */ static int _cdio_read_mode2_sectors (void *env, void *data, lsn_t lsn, - bool mode2_form2, unsigned int nblocks) + bool b_form2, unsigned int nblocks) { _img_private_t *_obj = env; unsigned int i; int retval; + unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE; for (i = 0; i < nblocks; i++) { - if (mode2_form2) { - if ( (retval = _cdio_read_mode2_sector (_obj, - ((char *)data) - + (M2RAW_SECTOR_SIZE * i), - lsn + i, true)) ) - return retval; - } else { - char buf[M2RAW_SECTOR_SIZE] = { 0, }; - if ( (retval = _cdio_read_mode2_sector (_obj, buf, lsn + i, true)) ) - return retval; - - memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i), - buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); - } + if ( (retval = _cdio_read_mode2_sector (_obj, + ((char *)data) + (blocksize * i), + lsn + i, b_form2)) ) + return retval; } return 0; } @@ -727,6 +814,7 @@ _cdio_get_mcn (void *env) { struct cdrom_mcn mcn; _img_private_t *_obj = env; + memset(&mcn, 0, sizeof(mcn)); if (ioctl(_obj->gen.fd, CDROM_GET_MCN, &mcn) != 0) return NULL; return strdup(mcn.medium_catalog_number); @@ -866,12 +954,14 @@ cdio_get_devices_linux (void) /* Now check the currently mounted CD drives */ if (NULL != (ret_drive = cdio_check_mounts("/etc/mtab"))) { - cdio_add_device_list(&drives, drive, &num_drives); + cdio_add_device_list(&drives, ret_drive, &num_drives); + free(ret_drive); } /* Finally check possible mountable drives in /etc/fstab */ if (NULL != (ret_drive = cdio_check_mounts("/etc/fstab"))) { - cdio_add_device_list(&drives, drive, &num_drives); + cdio_add_device_list(&drives, ret_drive, &num_drives); + free(ret_drive); } /* Scan the system for CD-ROM drives. @@ -980,6 +1070,8 @@ cdio_open_linux (const char *orig_source_name) .lseek = cdio_generic_lseek, .read = cdio_generic_read, .read_audio_sectors = _cdio_read_audio_sectors, + .read_mode1_sector = _cdio_read_mode1_sector, + .read_mode1_sectors = _cdio_read_mode1_sectors, .read_mode2_sector = _cdio_read_mode2_sector, .read_mode2_sectors = _cdio_read_mode2_sectors, .set_arg = _cdio_set_arg, diff --git a/src/input/vcd/libcdio/_cdio_osx.c b/src/input/vcd/libcdio/_cdio_osx.c index b02151f30..887eb00bf 100644 --- a/src/input/vcd/libcdio/_cdio_osx.c +++ b/src/input/vcd/libcdio/_cdio_osx.c @@ -1,12 +1,14 @@ /* - $Id: _cdio_osx.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: _cdio_osx.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ - Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> from vcdimager code + Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> + from vcdimager code: Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> and VideoLAN code Copyright (C) 1998-2001 VideoLAN Authors: Johan Bilien <jobi@via.ecp.fr> Gildas Bazin <gbazin@netcourrier.com> Jon Lech Johansen <jon-vl@nanocrew.net> + Derk-Jan Hartman <hartman at videolan.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 @@ -31,16 +33,13 @@ # include "config.h" #endif -static const char _rcsid[] = "$Id: _cdio_osx.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; +static const char _rcsid[] = "$Id: _cdio_osx.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; #include <cdio/sector.h> #include <cdio/util.h> #include "cdio_assert.h" #include "cdio_private.h" -/* Is this the right default? */ -#define DEFAULT_CDIO_DEVICE "/dev/rdisk2" - #include <string.h> #ifdef HAVE_DARWIN_CDROM @@ -55,9 +54,14 @@ static const char _rcsid[] = "$Id: _cdio_osx.c,v 1.1 2003/10/13 11:47:11 f1rmb E #include <sys/types.h> #include <sys/ioctl.h> +#include <paths.h> #include <CoreFoundation/CFBase.h> +#include <CoreFoundation/CFString.h> +#include <CoreFoundation/CFNumber.h> #include <IOKit/IOKitLib.h> +#include <IOKit/IOBSD.h> #include <IOKit/storage/IOCDTypes.h> +#include <IOKit/storage/IOMedia.h> #include <IOKit/storage/IOCDMedia.h> #include <IOKit/storage/IOCDMediaBSDClient.h> @@ -124,61 +128,71 @@ _cdio_getNumberOfTracks( CDTOC *pTOC, int i_descriptors ) Returns 0 if no error. */ static int -_cdio_read_mode2_form2_sectors (int device_handle, void *data, lsn_t lsn, - bool mode2_form2, unsigned int nblocks) +_cdio_read_mode1_sectors (void *env, void *data, lsn_t lsn, + bool is_form2, unsigned int nblocks) { + _img_private_t *_obj = env; dk_cd_read_t cd_read; memset( &cd_read, 0, sizeof(cd_read) ); - cd_read.offset = lsn * CDIO_CD_FRAMESIZE_RAW; - cd_read.sectorArea = kCDSectorAreaSync | kCDSectorAreaHeader | - kCDSectorAreaSubHeader | kCDSectorAreaUser | - kCDSectorAreaAuxiliary; - cd_read.sectorType = kCDSectorTypeUnknown; + cd_read.sectorArea = kCDSectorAreaUser; + cd_read.buffer = data; + cd_read.sectorType = kCDSectorTypeMode1; - cd_read.buffer = data; - cd_read.bufferLength = CDIO_CD_FRAMESIZE_RAW * nblocks; + if (is_form2) { + cd_read.offset = lsn * kCDSectorSizeMode2; + cd_read.bufferLength = kCDSectorSizeMode2 * nblocks; + } else { + cd_read.offset = lsn * kCDSectorSizeMode1; + cd_read.bufferLength = kCDSectorSizeMode1 * nblocks; + } - if( ioctl( device_handle, DKIOCCDREAD, &cd_read ) == -1 ) - { - cdio_error( "could not read block %d", lsn ); - return -1; - } + if( ioctl( _obj->gen.fd, DKIOCCDREAD, &cd_read ) == -1 ) + { + cdio_error( "could not read block %d, %s", lsn, strerror(errno) ); + return -1; + } return 0; } /*! - Reads nblocks of mode2 sectors from cd device into data starting + Reads nblocks of mode2 form2 sectors from cd device into data starting from lsn. Returns 0 if no error. */ static int _cdio_read_mode2_sectors (void *env, void *data, lsn_t lsn, - bool mode2_form2, unsigned int nblocks) + bool is_form2, unsigned int nblocks) { _img_private_t *_obj = env; - int i; - int retval; - - if (mode2_form2) { - return _cdio_read_mode2_form2_sectors(_obj->gen.fd, data, lsn, - mode2_form2, nblocks); + dk_cd_read_t cd_read; + + memset( &cd_read, 0, sizeof(cd_read) ); + + cd_read.sectorArea = kCDSectorAreaUser; + cd_read.buffer = data; + + if (is_form2) { + cd_read.offset = lsn * kCDSectorSizeMode2Form2; + cd_read.sectorType = kCDSectorTypeMode2Form2; + cd_read.bufferLength = kCDSectorSizeMode2Form2 * nblocks; + } else { + cd_read.offset = lsn * kCDSectorSizeMode2Form1; + cd_read.sectorType = kCDSectorTypeMode2Form1; + cd_read.bufferLength = kCDSectorSizeMode2Form1 * nblocks; } - for (i = 0; i < nblocks; i++) { - char buf[M2RAW_SECTOR_SIZE] = { 0, }; - retval = _cdio_read_mode2_form2_sectors (_obj->gen.fd, buf, lsn + i, - mode2_form2, 1); - if ( retval ) return retval; - - memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i), - buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); + if( ioctl( _obj->gen.fd, DKIOCCDREAD, &cd_read ) == -1 ) + { + cdio_error( "could not read block %d, %s", lsn, strerror(errno) ); + return -1; } return 0; } + /*! Reads a single audio sector from CD device into data starting from lsn. Returns 0 if no error. @@ -187,7 +201,35 @@ static int _cdio_read_audio_sectors (void *env, void *data, lsn_t lsn, unsigned int nblocks) { - return _cdio_read_mode2_sectors(env, data, lsn, true, nblocks); + _img_private_t *_obj = env; + dk_cd_read_t cd_read; + + memset( &cd_read, 0, sizeof(cd_read) ); + + cd_read.offset = lsn * kCDSectorSizeCDDA; + cd_read.sectorArea = kCDSectorAreaUser; + cd_read.sectorType = kCDSectorTypeCDDA; + + cd_read.buffer = data; + cd_read.bufferLength = kCDSectorSizeCDDA * nblocks; + + if( ioctl( _obj->gen.fd, DKIOCCDREAD, &cd_read ) == -1 ) + { + cdio_error( "could not read block %d", lsn ); + return -1; + } + return 0; +} + +/*! + Reads a single mode2 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ +static int +_cdio_read_mode1_sector (void *env, void *data, lsn_t lsn, + bool is_form2) +{ + return _cdio_read_mode1_sectors(env, data, lsn, is_form2, 1); } /*! @@ -196,9 +238,9 @@ _cdio_read_audio_sectors (void *env, void *data, lsn_t lsn, */ static int _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, - bool mode2_form2) + bool is_form2) { - return _cdio_read_mode2_sectors(env, data, lsn, mode2_form2, 1); + return _cdio_read_mode2_sectors(env, data, lsn, is_form2, 1); } /*! @@ -534,23 +576,24 @@ _cdio_get_first_track_num(void *env) } /*! - Return the media catalog number MCN. - */ + Return the media catalog number MCN. + */ static char * _cdio_get_mcn (void *env) { - _img_private_t *_obj = env; - dk_cd_read_mcn_t cd_read; + _img_private_t *_obj = env; + dk_cd_read_mcn_t cd_read; - memset( &cd_read, 0, sizeof(cd_read) ); + memset( &cd_read, 0, sizeof(cd_read) ); - if( ioctl( _obj->gen.fd, DKIOCCDREADMCN, &cd_read ) < 0 ) - { - cdio_error( "could not read MCN, %s", strerror(errno) ); - return -1; - } - return strdup((char*)cd_read.mcn); + if( ioctl( _obj->gen.fd, DKIOCCDREADMCN, &cd_read ) < 0 ) + { + cdio_error( "could not read MCN, %s", strerror(errno) ); + return NULL; + } + return strdup((char*)cd_read.mcn); } + /*! Return the number of tracks in the current medium. CDIO_INVALID_TRACK is returned on error. @@ -572,27 +615,31 @@ static track_format_t _cdio_get_track_format(void *env, track_t track_num) { _img_private_t *_obj = env; + CDTrackInfo a_track; if (!_obj->toc_init) _cdio_read_toc (_obj) ; if (track_num > TOTAL_TRACKS || track_num == 0) return TRACK_FORMAT_ERROR; + + dk_cd_read_track_info_t cd_read; + memset( &cd_read, 0, sizeof(cd_read) ); -#if 0 - if (_obj->tocent[track_num-1].entry.control & CDROM_DATA_TRACK) { - if (_obj->tocent[track_num-1].cdte_format == 0x10) - return TRACK_FORMAT_CDI; - else if (_obj->tocent[track_num-1].cdte_format == 0x20) - return TRACK_FORMAT_XA; - else - return TRACK_FORMAT_DATA; - } else - return TRACK_FORMAT_AUDIO; -#else - /* FIXME! Figure out how to do. */ - return TRACK_FORMAT_DATA; -#endif + cd_read.address = track_num; + cd_read.addressType = kCDTrackInfoAddressTypeTrackNumber; + + cd_read.buffer = &a_track; + cd_read.bufferLength = sizeof(CDTrackInfo); + if( ioctl( _obj->gen.fd, DKIOCCDREADTRACKINFO, &cd_read ) == -1 ) + { + cdio_error( "could not read trackinfo for track %d", track_num ); + return -1; + } + + cdio_warn( "trackinfo trackMode: %x dataMode: %x", a_track.trackMode, a_track.dataMode ); + + return TRACK_FORMAT_AUDIO; } /*! @@ -798,12 +845,13 @@ cdio_get_default_device_osx(void) ones to set that up. */ CdIo * -cdio_open_osx (const char *source_name) +cdio_open_osx (const char *orig_source_name) { #ifdef HAVE_DARWIN_CDROM CdIo *ret; _img_private_t *_data; + char *source_name; cdio_funcs _funcs = { .eject_media = _cdio_eject_media, @@ -812,7 +860,7 @@ cdio_open_osx (const char *source_name) .get_default_device = cdio_get_default_device_osx, .get_devices = cdio_get_devices_osx, .get_first_track_num= _cdio_get_first_track_num, - .get_mcn = _cdio_get_mcn, + .get_mcn = _cdio_get_mcn, .get_num_tracks = _cdio_get_num_tracks, .get_track_format = _cdio_get_track_format, .get_track_green = _cdio_get_track_green, @@ -821,6 +869,8 @@ cdio_open_osx (const char *source_name) .lseek = cdio_generic_lseek, .read = cdio_generic_read, .read_audio_sectors = _cdio_read_audio_sectors, + .read_mode1_sector = _cdio_read_mode1_sector, + .read_mode1_sectors = _cdio_read_mode1_sectors, .read_mode2_sector = _cdio_read_mode2_sector, .read_mode2_sectors = _cdio_read_mode2_sectors, .set_arg = _cdio_set_arg, @@ -832,8 +882,13 @@ cdio_open_osx (const char *source_name) _data->gen.init = false; _data->gen.fd = -1; - _cdio_set_arg(_data, "source", (NULL == source_name) - ? DEFAULT_CDIO_DEVICE: source_name); + if (NULL == orig_source_name) { + source_name=cdio_get_default_device_linux(); + if (NULL == source_name) return NULL; + _cdio_set_arg(_data, "source", source_name); + free(source_name); + } else + _cdio_set_arg(_data, "source", orig_source_name); ret = cdio_new (_data, &_funcs); if (ret == NULL) return NULL; @@ -860,5 +915,3 @@ cdio_have_osx (void) return false; #endif /* HAVE_DARWIN_CDROM */ } - - diff --git a/src/input/vcd/libcdio/_cdio_stdio.c b/src/input/vcd/libcdio/_cdio_stdio.c index b8d8daa67..0083b2194 100644 --- a/src/input/vcd/libcdio/_cdio_stdio.c +++ b/src/input/vcd/libcdio/_cdio_stdio.c @@ -1,8 +1,8 @@ /* - $Id: _cdio_stdio.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: _cdio_stdio.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> + 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 @@ -35,7 +35,7 @@ #include "_cdio_stream.h" #include "_cdio_stdio.h" -static const char _rcsid[] = "$Id: _cdio_stdio.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; +static const char _rcsid[] = "$Id: _cdio_stdio.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; #define CDIO_STDIO_BUFSIZE (128*1024) @@ -145,7 +145,7 @@ _stdio_stat(void *user_data) must use feof(3) and ferror(3) to determine which occurred. */ static long -_stdio_read(void *user_data, void *buf, long count) +_stdio_read(void *user_data, void *buf, long int count) { _UserData *const ud = user_data; long read; @@ -171,6 +171,15 @@ _stdio_read(void *user_data, void *buf, long count) return read; } +/*! + Deallocate resources assocaited with obj. After this obj is unusable. +*/ +void +cdio_stdio_destroy(CdioDataSource *obj) +{ + cdio_stream_destroy(obj); +} + CdioDataSource* cdio_stdio_new(const char pathname[]) { @@ -181,7 +190,8 @@ cdio_stdio_new(const char pathname[]) if (stat (pathname, &statbuf) == -1) { - cdio_error ("could not stat() file `%s': %s", pathname, strerror (errno)); + cdio_warn ("could not retrieve file info for `%s': %s", + pathname, strerror (errno)); return NULL; } diff --git a/src/input/vcd/libcdio/_cdio_stdio.h b/src/input/vcd/libcdio/_cdio_stdio.h index 013dff58b..f5e79c41c 100644 --- a/src/input/vcd/libcdio/_cdio_stdio.h +++ b/src/input/vcd/libcdio/_cdio_stdio.h @@ -1,5 +1,5 @@ /* - $Id: _cdio_stdio.h,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: _cdio_stdio.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> @@ -25,8 +25,20 @@ #include "_cdio_stream.h" -CdioDataSource* -cdio_stdio_new(const char pathname[]); +/*! + Initialize a new stdio stream reading from pathname. + A pointer to the stream is returned or NULL if there was an error. + + cdio_stream_free should be called on the returned value when you + don't need the stream any more. No other finalization is needed. + */ +CdioDataSource* cdio_stdio_new(const char pathname[]); + +/*! + Deallocate resources assocaited with obj. After this obj is unusable. +*/ +void cdio_stdio_destroy(CdioDataSource *obj); + #endif /* __CDIO_STREAM_STDIO_H__ */ diff --git a/src/input/vcd/libcdio/_cdio_stream.c b/src/input/vcd/libcdio/_cdio_stream.c index ee2f2b086..fc1f7fce7 100644 --- a/src/input/vcd/libcdio/_cdio_stream.c +++ b/src/input/vcd/libcdio/_cdio_stream.c @@ -1,7 +1,7 @@ /* - $Id: _cdio_stream.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: _cdio_stream.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ - Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> + Copyright (C) 2000, 2004 Herbert Valerio Riedel <hvr@gnu.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ #include <cdio/util.h> #include "_cdio_stream.h" -static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; +static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; /* * DataSource implementations @@ -186,6 +186,8 @@ cdio_stream_destroy(CdioDataSource* obj) cdio_stream_close(obj); obj->op.free(obj->user_data); + + free(obj); } diff --git a/src/input/vcd/libcdio/_cdio_stream.h b/src/input/vcd/libcdio/_cdio_stream.h index 562c18bf8..ffbb4098e 100644 --- a/src/input/vcd/libcdio/_cdio_stream.h +++ b/src/input/vcd/libcdio/_cdio_stream.h @@ -1,8 +1,8 @@ /* - $Id: _cdio_stream.h,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: _cdio_stream.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> + 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 @@ -96,14 +96,17 @@ extern "C" { Otherwise, -1 is returned and the global variable errno is set to indi- cate the error. */ - long cdio_stream_seek(CdioDataSource* obj, long offset, int whence); + long int cdio_stream_seek(CdioDataSource* obj, long offset, int whence); /*! Return whatever size of stream reports, I guess unit size is bytes. On error return -1; */ - long cdio_stream_stat(CdioDataSource* obj); + long int cdio_stream_stat(CdioDataSource* obj); + /*! + Deallocate resources assocaited with obj. After this obj is unusable. + */ void cdio_stream_destroy(CdioDataSource* obj); void cdio_stream_close(CdioDataSource* obj); diff --git a/src/input/vcd/libcdio/_cdio_sunos.c b/src/input/vcd/libcdio/_cdio_sunos.c index e7faf57cd..795ba6184 100644 --- a/src/input/vcd/libcdio/_cdio_sunos.c +++ b/src/input/vcd/libcdio/_cdio_sunos.c @@ -1,8 +1,8 @@ /* - $Id: _cdio_sunos.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: _cdio_sunos.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com> + 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 @@ -30,7 +30,6 @@ #include <glob.h> #endif - #include <cdio/logging.h> #include <cdio/sector.h> #include <cdio/util.h> @@ -42,7 +41,7 @@ #ifdef HAVE_SOLARIS_CDROM -static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; +static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; #include <stdio.h> #include <stdlib.h> @@ -98,80 +97,35 @@ static bool _cdio_init (_img_private_t *_obj) { - struct dk_cinfo cinfo; - if (!cdio_generic_init(_obj)) return false; - /* - * CDROMCDXA/CDROMREADMODE2 are broken on IDE/ATAPI devices. - * Try to send MMC3 SCSI commands via the uscsi interface on - * ATAPI devices. - */ - if ( ioctl(_obj->gen.fd, DKIOCINFO, &cinfo) == 0 - && ((strcmp(cinfo.dki_cname, "ide") == 0) - || (strncmp(cinfo.dki_cname, "pci", 3) == 0)) ) { - _obj->access_mode = _AM_SUN_CTRL_ATAPI; - } else { - _obj->access_mode = _AM_SUN_CTRL_SCSI; - } + _obj->access_mode = _AM_SUN_CTRL_SCSI; return true; } -static int -_cdio_mmc_read_sectors (int fd, void *buf, lsn_t lsn, int sector_type, - unsigned int nblocks) -{ - struct uscsi_cmd sc; - union scsi_cdb cdb; - int sub_channel = 0; - - memset(&cdb, 0, sizeof(cdb)); - memset(&sc, 0, sizeof(sc)); - - cdb.scc_cmd = CDIO_MMC_GPCMD_READ_CD; - CDIO_MMC_SET_READ_TYPE(cdb.cdb_opaque, sector_type); - CDIO_MMC_SET_READ_LBA(cdb.cdb_opaque, lsn); - CDIO_MMC_SET_READ_LENGTH(cdb.cdb_opaque, nblocks); - CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(cdb.cdb_opaque, - CDIO_MMC_MCSB_ALL_HEADERS); - cdb.cdb_opaque[10] = sub_channel; - - sc.uscsi_cdb = (caddr_t)&cdb; - sc.uscsi_cdblen = 12; - sc.uscsi_bufaddr = (caddr_t) buf; - sc.uscsi_buflen = CDIO_CD_FRAMESIZE_RAW; - sc.uscsi_flags = USCSI_ISOLATE | USCSI_READ; - sc.uscsi_timeout = 20; - if (ioctl(fd, USCSICMD, &sc)) { - perror("USCSICMD: READ CD"); - return 1; - } - if (sc.uscsi_status) { - cdio_error("SCSI command failed with status %d\n", - sc.uscsi_status); - } - - return sc.uscsi_status; -} - /*! - Reads a single mode2 sector from cd device into data starting from lsn. + Reads audio sectors from CD device into data starting from lsn. Returns 0 if no error. - */ + + May have to check size of nblocks. There may be a limit that + can be read in one go, e.g. 25 blocks. +*/ + static int -_cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, - bool mode2_form2) +_cdio_read_audio_sectors (void *env, void *data, lsn_t lsn, + unsigned int nblocks) { - char buf[M2RAW_SECTOR_SIZE] = { 0, }; + char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, }; struct cdrom_msf *msf = (struct cdrom_msf *) &buf; msf_t _msf; + struct cdrom_cdda cdda; _img_private_t *_obj = env; cdio_lba_to_msf (cdio_lsn_to_lba(lsn), &_msf); - msf->cdmsf_min0 = from_bcd8(_msf.m); - msf->cdmsf_sec0 = from_bcd8(_msf.s); + msf->cdmsf_min0 = from_bcd8(_msf.m); + msf->cdmsf_sec0 = from_bcd8(_msf.s); msf->cdmsf_frame0 = from_bcd8(_msf.f); if (_obj->gen.ioctls_debugged == 75) @@ -184,58 +138,89 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, || (_obj->gen.ioctls_debugged < (30 * 75) && _obj->gen.ioctls_debugged % 75 == 0) || _obj->gen.ioctls_debugged % (30 * 75) == 0) - cdio_debug ("reading %2.2d:%2.2d:%2.2d", - msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0); + cdio_debug ("reading %d", lsn); _obj->gen.ioctls_debugged++; - switch (_obj->access_mode) - { - case _AM_NONE: - cdio_error ("No way to read CD mode2."); - return 1; - break; - - case _AM_SUN_CTRL_SCSI: - if (ioctl (_obj->gen.fd, CDROMREADMODE2, buf) == -1) { - perror ("ioctl(..,CDROMREADMODE2,..)"); + cdda.cdda_addr = lsn; + cdda.cdda_length = nblocks; + cdda.cdda_data = (caddr_t) data; + if (ioctl (_obj->gen.fd, CDROMCDDA, &cdda) == -1) { + perror ("ioctl(..,CDROMCDDA,..)"); return 1; /* exit (EXIT_FAILURE); */ - } - break; - - case _AM_SUN_CTRL_ATAPI: - { - if (_cdio_mmc_read_sectors(_obj->gen.fd, data, lsn, - CDIO_MMC_READ_TYPE_MODE2, 1)) { - return 1; - } - break; - } - } - - if (mode2_form2) - memcpy (data, buf, M2RAW_SECTOR_SIZE); - else - memcpy (((char *)data), buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); + } + memcpy (data, buf, CDIO_CD_FRAMESIZE_RAW); return 0; } /*! - Reads single audio sectors from CD device into data starting from lsn. + Reads a single mode1 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ +static int +_cdio_read_mode1_sector (void *env, void *data, lsn_t lsn, + bool b_form2) +{ + + char buf[M2RAW_SECTOR_SIZE] = { 0, }; +#if FIXED + do something here. +#else + if (0 > cdio_generic_lseek(env, CDIO_CD_FRAMESIZE*lsn, SEEK_SET)) + return -1; + if (0 > cdio_generic_read(env, buf, CDIO_CD_FRAMESIZE)) + return -1; + memcpy (data, buf, b_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE); +#endif + return 0; +} + +/*! + Reads nblocks of mode2 sectors from cd device into data starting + from lsn. Returns 0 if no error. + */ +static int +_cdio_read_mode1_sectors (void *env, void *data, lsn_t lsn, + bool b_form2, unsigned int nblocks) +{ + _img_private_t *_obj = env; + unsigned int i; + int retval; + unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE; - May have to check size of nblocks. There may be a limit that - can be read in one go, e.g. 25 blocks. -*/ + for (i = 0; i < nblocks; i++) { + if ( (retval = _cdio_read_mode1_sector (_obj, + ((char *)data) + (blocksize * i), + lsn + i, b_form2)) ) + return retval; + } + return 0; +} +/*! + Reads a single mode2 sector from cd device into data starting from lsn. + Returns 0 if no error. + */ static int -_cdio_read_audio_sectors (void *env, void *data, lsn_t lsn, - unsigned int nblocks) +_cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, + bool b_form2) { + char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, }; + struct cdrom_msf *msf = (struct cdrom_msf *) &buf; + msf_t _msf; + int offset = 0; + struct cdrom_cdxa cd_read; + _img_private_t *_obj = env; + cdio_lba_to_msf (cdio_lsn_to_lba(lsn), &_msf); + msf->cdmsf_min0 = from_bcd8(_msf.m); + msf->cdmsf_sec0 = from_bcd8(_msf.s); + msf->cdmsf_frame0 = from_bcd8(_msf.f); + if (_obj->gen.ioctls_debugged == 75) cdio_debug ("only displaying every 75th ioctl from now on"); @@ -246,40 +231,29 @@ _cdio_read_audio_sectors (void *env, void *data, lsn_t lsn, || (_obj->gen.ioctls_debugged < (30 * 75) && _obj->gen.ioctls_debugged % 75 == 0) || _obj->gen.ioctls_debugged % (30 * 75) == 0) - cdio_debug ("reading %d", lsn); + cdio_debug ("reading %2.2d:%2.2d:%2.2d", + msf->cdmsf_min0, msf->cdmsf_sec0, msf->cdmsf_frame0); _obj->gen.ioctls_debugged++; - switch (_obj->access_mode) - { - case _AM_NONE: - cdio_error ("No way to read CD audio"); - return 1; - break; - - case _AM_SUN_CTRL_SCSI: - { - struct cdrom_cdda cdda; - cdda.cdda_addr = lsn; - cdda.cdda_length = nblocks; - cdda.cdda_data = (caddr_t) data; - if (ioctl (_obj->gen.fd, CDROMCDDA, &cdda) == -1) { - perror ("ioctl(..,CDROMCDDA,..)"); - return 1; - /* exit (EXIT_FAILURE); */ - } - } - break; - - case _AM_SUN_CTRL_ATAPI: - { - if (_cdio_mmc_read_sectors(_obj->gen.fd, data, lsn, - CDIO_MMC_READ_TYPE_CDDA, nblocks)) { - return 1; - } - break; - } - } + /* Using CDROMXA ioctl will actually use the same uscsi command + * as ATAPI, except we don't need to be root + */ + offset = CDIO_CD_XA_SYNC_HEADER; + cd_read.cdxa_addr = lsn; + cd_read.cdxa_data = buf; + cd_read.cdxa_length = 1; + cd_read.cdxa_format = CDROM_XA_SECTOR_DATA; + if (ioctl (_obj->gen.fd, CDROMCDXA, &cd_read) == -1) { + perror ("ioctl(..,CDROMCDXA,..)"); + return 1; + /* exit (EXIT_FAILURE); */ + } + + if (b_form2) + memcpy (data, buf + (offset-CDIO_CD_SUBHEADER_SIZE), M2RAW_SECTOR_SIZE); + else + memcpy (((char *)data), buf + offset, CDIO_CD_FRAMESIZE); return 0; } @@ -290,31 +264,24 @@ _cdio_read_audio_sectors (void *env, void *data, lsn_t lsn, Returns 0 if no error. */ static int -_cdio_read_mode2_sectors (void *env, void *data, uint32_t lsn, - bool mode2_form2, unsigned int nblocks) +_cdio_read_mode2_sectors (void *env, void *data, lsn_t lsn, + bool b_form2, unsigned int nblocks) { _img_private_t *_obj = env; unsigned int i; int retval; + unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE; for (i = 0; i < nblocks; i++) { - if (mode2_form2) { - if ( (retval = _cdio_read_mode2_sector (_obj, - ((char *)data) + (M2RAW_SECTOR_SIZE * i), - lsn + i, true)) ) - return retval; - } else { - char buf[M2RAW_SECTOR_SIZE] = { 0, }; - if ( (retval = _cdio_read_mode2_sector (_obj, buf, lsn + i, true)) ) - return retval; - - memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i), - buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); - } + if ( (retval = _cdio_read_mode2_sector (_obj, + ((char *)data) + (blocksize * i), + lsn + i, b_form2)) ) + return retval; } return 0; } + /*! Return the size of the CD in logical block address (LBA) units. */ @@ -364,7 +331,7 @@ _cdio_set_arg (void *env, const char key[], const char value[]) else if (!strcmp (key, "access-mode")) { if (!strcmp(value, "ATAPI")) - _obj->access_mode = _AM_SUN_CTRL_ATAPI; + _obj->access_mode = _AM_SUN_CTRL_SCSI; /* force ATAPI to be SCSI */ else if (!strcmp(value, "SCSI")) _obj->access_mode = _AM_SUN_CTRL_SCSI; else @@ -686,6 +653,7 @@ cdio_open_solaris (const char *source_name) .get_devices = cdio_get_devices_solaris, .get_default_device = cdio_get_default_device_solaris, .get_first_track_num= _cdio_get_first_track_num, + .get_mcn = NULL, .get_num_tracks = _cdio_get_num_tracks, .get_track_format = _cdio_get_track_format, .get_track_green = _cdio_get_track_green, @@ -694,6 +662,8 @@ cdio_open_solaris (const char *source_name) .lseek = cdio_generic_lseek, .read = cdio_generic_read, .read_audio_sectors = _cdio_read_audio_sectors, + .read_mode1_sector = _cdio_read_mode1_sector, + .read_mode1_sectors = _cdio_read_mode1_sectors, .read_mode2_sector = _cdio_read_mode2_sector, .read_mode2_sectors = _cdio_read_mode2_sectors, .stat_size = _cdio_stat_size, diff --git a/src/input/vcd/libcdio/_cdio_win32.c b/src/input/vcd/libcdio/_cdio_win32.c deleted file mode 100644 index 418beb86c..000000000 --- a/src/input/vcd/libcdio/_cdio_win32.c +++ /dev/null @@ -1,1168 +0,0 @@ -/* - $Id: _cdio_win32.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ - - 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 -*/ - -/* This file contains Win32-specific code and implements low-level - control of the CD drive. Inspired by vlc's cdrom.h code -*/ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -static const char _rcsid[] = "$Id: _cdio_win32.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; - -#include <cdio/cdio.h> -#include <cdio/sector.h> -#include <cdio/util.h> -#include "cdio_assert.h" -#include "cdio_private.h" -#include "scsi_mmc.h" - -/* LBA = msf.frame + 75 * ( msf.second - 2 + 60 * msf.minute ) */ -#define MSF_TO_LBA2(min, sec, frame) ((int)frame + 75 * (sec -2 + 60 * min)) - -#include <string.h> - -#ifdef HAVE_WIN32_CDROM - -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> -#include <unistd.h> -#include <fcntl.h> - -#include <windows.h> -#include <winioctl.h> - -#include <sys/stat.h> -#include <sys/types.h> - -/* Win32 DeviceIoControl specifics */ -#ifndef MAXIMUM_NUMBER_TRACKS -# define MAXIMUM_NUMBER_TRACKS 100 -#endif -typedef struct _TRACK_DATA { - UCHAR Reserved; - UCHAR Control : 4; - UCHAR Adr : 4; - UCHAR TrackNumber; - UCHAR Reserved1; - UCHAR Address[4]; -} TRACK_DATA, *PTRACK_DATA; -typedef struct _CDROM_TOC { - UCHAR Length[2]; - UCHAR FirstTrack; - UCHAR LastTrack; - TRACK_DATA TrackData[MAXIMUM_NUMBER_TRACKS]; -} CDROM_TOC, *PCDROM_TOC; -typedef enum _TRACK_MODE_TYPE { - YellowMode2, - XAForm2, - CDDA -} TRACK_MODE_TYPE, *PTRACK_MODE_TYPE; -typedef struct __RAW_READ_INFO { - LARGE_INTEGER DiskOffset; - ULONG SectorCount; - TRACK_MODE_TYPE TrackMode; -} RAW_READ_INFO, *PRAW_READ_INFO; - -#ifndef IOCTL_CDROM_BASE -# define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM -#endif -#ifndef IOCTL_CDROM_READ_TOC -# define IOCTL_CDROM_READ_TOC CTL_CODE(IOCTL_CDROM_BASE, 0x0000, \ - METHOD_BUFFERED, FILE_READ_ACCESS) -#endif -#ifndef IOCTL_CDROM_RAW_READ -#define IOCTL_CDROM_RAW_READ CTL_CODE(IOCTL_CDROM_BASE, 0x000F, \ - METHOD_OUT_DIRECT, FILE_READ_ACCESS) -#endif - -/* Win32 aspi specific */ -#define WIN_NT ( GetVersion() < 0x80000000 ) -#define ASPI_HAID 0 -#define ASPI_TARGET 0 -#define DTYPE_CDROM 0x05 - -#define SENSE_LEN 0x0E -#define SC_GET_DEV_TYPE 0x01 -#define SC_EXEC_SCSI_CMD 0x02 -#define SC_GET_DISK_INFO 0x06 -#define SS_COMP 0x01 -#define SS_PENDING 0x00 -#define SS_NO_ADAPTERS 0xE8 -#define SRB_DIR_IN 0x08 -#define SRB_DIR_OUT 0x10 -#define SRB_EVENT_NOTIFY 0x40 - -#define SECTOR_TYPE_MODE2 0x14 -#define READ_CD_USERDATA_MODE2 0x10 - -#define READ_TOC 0x43 -#define READ_TOC_FORMAT_TOC 0x0 - -#pragma pack(1) - -struct SRB_GetDiskInfo -{ - unsigned char SRB_Cmd; - unsigned char SRB_Status; - unsigned char SRB_HaId; - unsigned char SRB_Flags; - unsigned long SRB_Hdr_Rsvd; - unsigned char SRB_Target; - unsigned char SRB_Lun; - unsigned char SRB_DriveFlags; - unsigned char SRB_Int13HDriveInfo; - unsigned char SRB_Heads; - unsigned char SRB_Sectors; - unsigned char SRB_Rsvd1[22]; -}; - -struct SRB_GDEVBlock -{ - unsigned char SRB_Cmd; - unsigned char SRB_Status; - unsigned char SRB_HaId; - unsigned char SRB_Flags; - unsigned long SRB_Hdr_Rsvd; - unsigned char SRB_Target; - unsigned char SRB_Lun; - unsigned char SRB_DeviceType; - unsigned char SRB_Rsvd1; -}; - -struct SRB_ExecSCSICmd -{ - unsigned char SRB_Cmd; - unsigned char SRB_Status; - unsigned char SRB_HaId; - unsigned char SRB_Flags; - unsigned long SRB_Hdr_Rsvd; - unsigned char SRB_Target; - unsigned char SRB_Lun; - unsigned short SRB_Rsvd1; - unsigned long SRB_BufLen; - unsigned char *SRB_BufPointer; - unsigned char SRB_SenseLen; - unsigned char SRB_CDBLen; - unsigned char SRB_HaStat; - unsigned char SRB_TargStat; - unsigned long *SRB_PostProc; - unsigned char SRB_Rsvd2[20]; - unsigned char CDBByte[16]; - unsigned char SenseArea[SENSE_LEN+2]; -}; - -#pragma pack() - -typedef struct { - lsn_t start_lsn; -} track_info_t; - -typedef struct { - /* Things common to all drivers like this. - This must be first. */ - generic_img_private_t gen; - - HANDLE h_device_handle; /* device descriptor */ - long hASPI; - short i_sid; - long (*lpSendCommand)( void* ); - - /* Track information */ - bool toc_init; /* if true, info below is valid. */ - track_info_t tocent[100]; /* entry info for each track */ - track_t total_tracks; /* number of tracks in image */ - track_t first_track_num; /* track number of first track */ - -} _img_private_t; - -/* General ioctl() CD-ROM command function */ -static bool -_cdio_mciSendCommand(int id, UINT msg, DWORD flags, void *arg) -{ - MCIERROR mci_error; - - mci_error = mciSendCommand(id, msg, flags, (DWORD)arg); - if ( mci_error ) { - char error[256]; - - mciGetErrorString(mci_error, error, 256); - cdio_error("mciSendCommand() error: %s", error); - } - return(mci_error == 0); -} - -static const char * -cdio_is_cdrom(const char drive_letter) { - static char psz_win32_drive[7]; - static char root_path_name[8]; - _img_private_t obj; - - /* Initializations */ - obj.h_device_handle = NULL; - obj.i_sid = 0; - obj.hASPI = 0; - obj.lpSendCommand = 0; - - if ( WIN_NT ) { - sprintf( psz_win32_drive, "\\\\.\\%c:", drive_letter ); - sprintf( root_path_name, "\\\\.\\%c:\\", drive_letter ); - - obj.h_device_handle = CreateFile( psz_win32_drive, GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, - FILE_FLAG_NO_BUFFERING | - FILE_FLAG_RANDOM_ACCESS, NULL ); - if (obj.h_device_handle != NULL - && (DRIVE_CDROM == GetDriveType(root_path_name))) { - CloseHandle(obj.h_device_handle); - return strdup(psz_win32_drive); - } else { - CloseHandle(obj.h_device_handle); - return NULL; - } - } else { - HMODULE hASPI = NULL; - long (*lpGetSupport)( void ) = NULL; - long (*lpSendCommand)( void* ) = NULL; - DWORD dwSupportInfo; - int j, i_hostadapters; - char c_drive; - - hASPI = LoadLibrary( "wnaspi32.dll" ); - if( hASPI != NULL ) { - (FARPROC) lpGetSupport = GetProcAddress( hASPI, - "GetASPI32SupportInfo" ); - (FARPROC) lpSendCommand = GetProcAddress( hASPI, - "SendASPI32Command" ); - } - - if( hASPI == NULL || lpGetSupport == NULL || lpSendCommand == NULL ) { - cdio_debug("Unable to load ASPI or get ASPI function pointers"); - if( hASPI ) FreeLibrary( hASPI ); - return NULL; - } - - /* ASPI support seems to be there */ - - dwSupportInfo = lpGetSupport(); - - if( HIBYTE( LOWORD ( dwSupportInfo ) ) == SS_NO_ADAPTERS ) { - cdio_debug("no host adapters found (ASPI)"); - FreeLibrary( hASPI ); - return NULL; - } - - if( HIBYTE( LOWORD ( dwSupportInfo ) ) != SS_COMP ) { - cdio_debug("Unable to initalize ASPI layer"); - FreeLibrary( hASPI ); - return NULL; - } - - i_hostadapters = LOBYTE( LOWORD( dwSupportInfo ) ); - if( i_hostadapters == 0 ) { - FreeLibrary( hASPI ); - return NULL; - } - - c_drive = toupper(drive_letter) - 'A'; - - for( j = 0; j < 15; j++ ) { - struct SRB_GetDiskInfo srbDiskInfo; - - srbDiskInfo.SRB_Cmd = SC_GET_DISK_INFO; - srbDiskInfo.SRB_HaId = 0; - srbDiskInfo.SRB_Flags = 0; - srbDiskInfo.SRB_Hdr_Rsvd = 0; - srbDiskInfo.SRB_Target = j; - srbDiskInfo.SRB_Lun = 0; - - lpSendCommand( (void*) &srbDiskInfo ); - - if( (srbDiskInfo.SRB_Status == SS_COMP) && - (srbDiskInfo.SRB_Int13HDriveInfo == c_drive) ) { - /* Make sure this is a cdrom device */ - struct SRB_GDEVBlock srbGDEVBlock; - - memset( &srbGDEVBlock, 0, sizeof(struct SRB_GDEVBlock) ); - srbGDEVBlock.SRB_Cmd = SC_GET_DEV_TYPE; - srbGDEVBlock.SRB_HaId = 0; - srbGDEVBlock.SRB_Target = j; - - lpSendCommand( (void*) &srbGDEVBlock ); - - if( ( srbGDEVBlock.SRB_Status == SS_COMP ) && - ( srbGDEVBlock.SRB_DeviceType == DTYPE_CDROM ) ) { - sprintf( psz_win32_drive, "%c:", drive_letter ); - FreeLibrary( hASPI ); - return(psz_win32_drive); - } - } - } - FreeLibrary( hASPI ); - } - return NULL; - -} - -/*! - Initialize CD device. - */ -static bool -_cdio_init_win32 (void *user_data) -{ - _img_private_t *_obj = user_data; - if (_obj->gen.init) { - cdio_error ("init called more than once"); - return false; - } - - _obj->gen.init = true; - _obj->toc_init = false; - - - /* Initializations */ - _obj->h_device_handle = NULL; - _obj->i_sid = 0; - _obj->hASPI = 0; - _obj->lpSendCommand = 0; - - if ( WIN_NT ) { - char psz_win32_drive[7]; - unsigned int len=strlen(_obj->gen.source_name); - - cdio_debug("using winNT/2K/XP ioctl layer"); - - if (cdio_is_device_win32(_obj->gen.source_name)) { - sprintf( psz_win32_drive, "\\\\.\\%c:", _obj->gen.source_name[len-2] ); - - _obj->h_device_handle = CreateFile( psz_win32_drive, GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, - FILE_FLAG_NO_BUFFERING | - FILE_FLAG_RANDOM_ACCESS, NULL ); - return (_obj->h_device_handle == NULL) ? false : true; - } else - return false; - } else { - HMODULE hASPI = NULL; - long (*lpGetSupport)( void ) = NULL; - long (*lpSendCommand)( void* ) = NULL; - DWORD dwSupportInfo; - int i, j, i_hostadapters; - char c_drive = _obj->gen.source_name[0]; - - hASPI = LoadLibrary( "wnaspi32.dll" ); - if( hASPI != NULL ) { - (FARPROC) lpGetSupport = GetProcAddress( hASPI, - "GetASPI32SupportInfo" ); - (FARPROC) lpSendCommand = GetProcAddress( hASPI, - "SendASPI32Command" ); - } - - if( hASPI == NULL || lpGetSupport == NULL || lpSendCommand == NULL ) { - cdio_debug("Unable to load ASPI or get ASPI function pointers"); - if( hASPI ) FreeLibrary( hASPI ); - return false; - } - - /* ASPI support seems to be there */ - - dwSupportInfo = lpGetSupport(); - - if( HIBYTE( LOWORD ( dwSupportInfo ) ) == SS_NO_ADAPTERS ) { - cdio_debug("no host adapters found (ASPI)"); - FreeLibrary( hASPI ); - return -1; - } - - if( HIBYTE( LOWORD ( dwSupportInfo ) ) != SS_COMP ) { - cdio_debug("unable to initalize ASPI layer"); - FreeLibrary( hASPI ); - return -1; - } - - i_hostadapters = LOBYTE( LOWORD( dwSupportInfo ) ); - if( i_hostadapters == 0 ) { - FreeLibrary( hASPI ); - return -1; - } - - c_drive = toupper(c_drive) - 'A'; - - for( i = 0; i < i_hostadapters; i++ ) { - for( j = 0; j < 15; j++ ) { - struct SRB_GetDiskInfo srbDiskInfo; - - srbDiskInfo.SRB_Cmd = SC_GET_DISK_INFO; - srbDiskInfo.SRB_HaId = i; - srbDiskInfo.SRB_Flags = 0; - srbDiskInfo.SRB_Hdr_Rsvd = 0; - srbDiskInfo.SRB_Target = j; - srbDiskInfo.SRB_Lun = 0; - - lpSendCommand( (void*) &srbDiskInfo ); - - if( (srbDiskInfo.SRB_Status == SS_COMP) && - (srbDiskInfo.SRB_Int13HDriveInfo == c_drive) ) { - /* Make sure this is a cdrom device */ - struct SRB_GDEVBlock srbGDEVBlock; - - memset( &srbGDEVBlock, 0, sizeof(struct SRB_GDEVBlock) ); - srbGDEVBlock.SRB_Cmd = SC_GET_DEV_TYPE; - srbGDEVBlock.SRB_HaId = i; - srbGDEVBlock.SRB_Target = j; - - lpSendCommand( (void*) &srbGDEVBlock ); - - if( ( srbGDEVBlock.SRB_Status == SS_COMP ) && - ( srbGDEVBlock.SRB_DeviceType == DTYPE_CDROM ) ) { - _obj->i_sid = MAKEWORD( i, j ); - _obj->hASPI = (long)hASPI; - _obj->lpSendCommand = lpSendCommand; - cdio_debug("Using ASPI layer"); - - return true; - } else { - FreeLibrary( hASPI ); - cdio_debug( "%c: is not a CD-ROM drive", - _obj->gen.source_name[0] ); - return false; - } - } - } - } - - FreeLibrary( hASPI ); - cdio_debug( "Unable to get HaId and target (ASPI)" ); - - } - - return false; -} - -/*! - Release and free resources associated with cd. - */ -static void -_cdio_win32_free (void *user_data) -{ - _img_private_t *_obj = user_data; - - if (NULL == _obj) return; - free (_obj->gen.source_name); - - if( _obj->h_device_handle ) - CloseHandle( _obj->h_device_handle ); - if( _obj->hASPI ) - FreeLibrary( (HMODULE)_obj->hASPI ); - - free (_obj); -} - -/*! - Reads a single mode2 sector from cd device into data starting from lsn. - Returns 0 if no error. - */ -static int -_cdio_mmc_read_sectors (void *user_data, void *data, lsn_t lsn, - int sector_type, unsigned int nblocks) -{ - _img_private_t *_obj = user_data; - unsigned char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, }; - - if( _obj->hASPI ) { - HANDLE hEvent; - struct SRB_ExecSCSICmd ssc; - - /* Create the transfer completion event */ - hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); - if( hEvent == NULL ) { - return 1; - } - - /* Data selection */ - - memset( &ssc, 0, sizeof( ssc ) ); - - ssc.SRB_Cmd = SC_EXEC_SCSI_CMD; - ssc.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY; - ssc.SRB_HaId = LOBYTE( _obj->i_sid ); - ssc.SRB_Target = HIBYTE( _obj->i_sid ); - ssc.SRB_SenseLen = SENSE_LEN; - - ssc.SRB_PostProc = (LPVOID) hEvent; - ssc.SRB_CDBLen = 12; - - /* Operation code */ - ssc.CDBByte[ 0 ] = CDIO_MMC_GPCMD_READ_CD; - - CDIO_MMC_SET_READ_TYPE(ssc.CDBByte, sector_type); - CDIO_MMC_SET_READ_LBA(ssc.CDBByte, lsn); - CDIO_MMC_SET_READ_LENGTH(ssc.CDBByte, nblocks); - CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(ssc.CDBByte, - CDIO_MMC_MCSB_ALL_HEADERS); - - /* Result buffer */ - ssc.SRB_BufPointer = buf; - ssc.SRB_BufLen = CDIO_CD_FRAMESIZE_RAW; - - /* Initiate transfer */ - ResetEvent( hEvent ); - _obj->lpSendCommand( (void*) &ssc ); - - /* If the command has still not been processed, wait until it's - * finished */ - if( ssc.SRB_Status == SS_PENDING ) { - WaitForSingleObject( hEvent, INFINITE ); - } - CloseHandle( hEvent ); - - /* check that the transfer went as planned */ - if( ssc.SRB_Status != SS_COMP ) { - return 1; - } - - } else { - DWORD dwBytesReturned; - RAW_READ_INFO cdrom_raw; - - /* Initialize CDROM_RAW_READ structure */ - cdrom_raw.DiskOffset.QuadPart = CDIO_CD_FRAMESIZE * lsn; - cdrom_raw.SectorCount = 1; - cdrom_raw.TrackMode = XAForm2; - - if( DeviceIoControl( _obj->h_device_handle, - IOCTL_CDROM_RAW_READ, &cdrom_raw, - sizeof(RAW_READ_INFO), buf, - sizeof(buf), &dwBytesReturned, NULL ) - == 0 ) { - return 1; - } - } - - /* FIXME! remove the 8 (SUBHEADER size) below... */ - memcpy (data, buf, CDIO_CD_FRAMESIZE_RAW); - - return 0; -} - -/*! - Reads an audio device into data starting from lsn. - Returns 0 if no error. - */ -static int -_cdio_read_audio_sectors (void *user_data, void *data, lsn_t lsn, - unsigned int nblocks) -{ - return _cdio_mmc_read_sectors( user_data, data, lsn, - CDIO_MMC_READ_TYPE_CDDA, nblocks ); -} - -/*! - Reads a single mode2 sector from cd device into data starting - from lsn. Returns 0 if no error. - */ -static int -_cdio_read_mode2_sector (void *user_data, void *data, lsn_t lsn, - bool mode2_form2) -{ - char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, }; - _img_private_t *_obj = user_data; - int ret; - - if (_obj->gen.ioctls_debugged == 75) - cdio_debug ("only displaying every 75th ioctl from now on"); - - if (_obj->gen.ioctls_debugged == 30 * 75) - cdio_debug ("only displaying every 30*75th ioctl from now on"); - - if (_obj->gen.ioctls_debugged < 75 - || (_obj->gen.ioctls_debugged < (30 * 75) - && _obj->gen.ioctls_debugged % 75 == 0) - || _obj->gen.ioctls_debugged % (30 * 75) == 0) - cdio_debug ("reading %lu", (unsigned long int) lsn); - - _obj->gen.ioctls_debugged++; - - ret = _cdio_mmc_read_sectors(user_data, buf, lsn, CDIO_MMC_READ_TYPE_ANY, 1); - - if( ret != 0 ) return ret; - - if (mode2_form2) - memcpy (data, buf, M2RAW_SECTOR_SIZE); - else - memcpy (((char *)data), buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); - - return 0; -} - -/*! - Reads nblocks of mode2 sectors from cd device into data starting - from lsn. - Returns 0 if no error. - */ -static int -_cdio_read_mode2_sectors (void *user_data, void *data, lsn_t lsn, - bool mode2_form2, unsigned int nblocks) -{ - _img_private_t *_obj = user_data; - int i; - int retval; - - for (i = 0; i < nblocks; i++) { - if (mode2_form2) { - if ( (retval = _cdio_read_mode2_sector (_obj, - ((char *)data) + (M2RAW_SECTOR_SIZE * i), - lsn + i, true)) ) - return retval; - } else { - char buf[M2RAW_SECTOR_SIZE] = { 0, }; - if ( (retval = _cdio_read_mode2_sector (_obj, buf, lsn + i, true)) ) - return retval; - - memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i), - buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); - } - } - return 0; -} - -/*! - Return the size of the CD in logical block address (LBA) units. - */ -static uint32_t -_cdio_stat_size (void *user_data) -{ - _img_private_t *_obj = user_data; - - return _obj->tocent[_obj->total_tracks].start_lsn; -} - -/*! - Set the key "arg" to "value" in source device. -*/ -static int -_cdio_set_arg (void *user_data, const char key[], const char value[]) -{ - _img_private_t *_obj = user_data; - - if (!strcmp (key, "source")) - { - if (!value) - return -2; - - free (_obj->gen.source_name); - - _obj->gen.source_name = strdup (value); - } - else - return -1; - - return 0; -} - -/*! - Read and cache the CD's Track Table of Contents and track info. - Return true if successful or false if an error. -*/ -static bool -_cdio_read_toc (_img_private_t *_obj) -{ - - if( _obj->hASPI ) { - HANDLE hEvent; - struct SRB_ExecSCSICmd ssc; - unsigned char p_tocheader[ 4 ]; - - /* Create the transfer completion event */ - hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); - if( hEvent == NULL ) { - return false; - } - - memset( &ssc, 0, sizeof( ssc ) ); - - ssc.SRB_Cmd = SC_EXEC_SCSI_CMD; - ssc.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY; - ssc.SRB_HaId = LOBYTE( _obj->i_sid ); - ssc.SRB_Target = HIBYTE( _obj->i_sid ); - ssc.SRB_SenseLen = SENSE_LEN; - - ssc.SRB_PostProc = (LPVOID) hEvent; - ssc.SRB_CDBLen = 10; - - /* Operation code */ - ssc.CDBByte[ 0 ] = READ_TOC; - - /* Format */ - ssc.CDBByte[ 2 ] = READ_TOC_FORMAT_TOC; - - /* Starting track */ - ssc.CDBByte[ 6 ] = 0; - - /* Allocation length and buffer */ - ssc.SRB_BufLen = sizeof( p_tocheader ); - ssc.SRB_BufPointer = p_tocheader; - ssc.CDBByte[ 7 ] = ( ssc.SRB_BufLen >> 8 ) & 0xff; - ssc.CDBByte[ 8 ] = ( ssc.SRB_BufLen ) & 0xff; - - /* Initiate transfer */ - ResetEvent( hEvent ); - _obj->lpSendCommand( (void*) &ssc ); - - /* If the command has still not been processed, wait until it's - * finished */ - if( ssc.SRB_Status == SS_PENDING ) - WaitForSingleObject( hEvent, INFINITE ); - - /* check that the transfer went as planned */ - if( ssc.SRB_Status != SS_COMP ) { - CloseHandle( hEvent ); - return false; - } - - _obj->first_track_num = p_tocheader[2]; - _obj->total_tracks = p_tocheader[3] - p_tocheader[2] + 1; - - { - int i, i_toclength; - unsigned char *p_fulltoc; - - i_toclength = 4 /* header */ + p_tocheader[0] + - ((unsigned int)p_tocheader[1] << 8); - - p_fulltoc = malloc( i_toclength ); - - if( p_fulltoc == NULL ) { - cdio_error( "out of memory" ); - CloseHandle( hEvent ); - return false; - } - - /* Allocation length and buffer */ - ssc.SRB_BufLen = i_toclength; - ssc.SRB_BufPointer = p_fulltoc; - ssc.CDBByte[ 7 ] = ( ssc.SRB_BufLen >> 8 ) & 0xff; - ssc.CDBByte[ 8 ] = ( ssc.SRB_BufLen ) & 0xff; - - /* Initiate transfer */ - ResetEvent( hEvent ); - _obj->lpSendCommand( (void*) &ssc ); - - /* If the command has still not been processed, wait until it's - * finished */ - if( ssc.SRB_Status == SS_PENDING ) - WaitForSingleObject( hEvent, INFINITE ); - - /* check that the transfer went as planned */ - if( ssc.SRB_Status != SS_COMP ) - _obj->total_tracks = 0; - - for( i = 0 ; i <= _obj->total_tracks ; i++ ) { - int i_index = 8 + 8 * i; - _obj->tocent[ i ].start_lsn = ((int)p_fulltoc[ i_index ] << 24) + - ((int)p_fulltoc[ i_index+1 ] << 16) + - ((int)p_fulltoc[ i_index+2 ] << 8) + - (int)p_fulltoc[ i_index+3 ]; - - cdio_debug( "p_sectors: %i %lu", - i, (unsigned long int) _obj->tocent[i].start_lsn ); - } - - free( p_fulltoc ); - } - - CloseHandle( hEvent ); - return true; - - } else { - DWORD dwBytesReturned; - CDROM_TOC cdrom_toc; - int i; - - if( DeviceIoControl( _obj->h_device_handle, - IOCTL_CDROM_READ_TOC, - NULL, 0, &cdrom_toc, sizeof(CDROM_TOC), - &dwBytesReturned, NULL ) == 0 ) { - cdio_debug( "could not read TOCHDR" ); - return false; - } - - _obj->first_track_num = cdrom_toc.FirstTrack; - _obj->total_tracks = cdrom_toc.LastTrack - cdrom_toc.FirstTrack + 1; - - - for( i = 0 ; i <= _obj->total_tracks ; i++ ) { - _obj->tocent[ i ].start_lsn = MSF_TO_LBA2( - cdrom_toc.TrackData[i].Address[1], - cdrom_toc.TrackData[i].Address[2], - cdrom_toc.TrackData[i].Address[3] ); - cdio_debug("p_sectors: %i, %lu", i, - (unsigned long int) (_obj->tocent[i].start_lsn)); - } - } - return true; -} - -/*! - Eject media. Return 1 if successful, 0 otherwise. - */ -static int -_cdio_eject_media (void *user_data) { - - _img_private_t *_obj = user_data; - - - MCI_OPEN_PARMS op; - MCI_STATUS_PARMS st; - DWORD i_flags; - char psz_drive[4]; - int ret; - - memset( &op, 0, sizeof(MCI_OPEN_PARMS) ); - op.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO; - strcpy( psz_drive, "X:" ); - psz_drive[0] = _obj->gen.source_name[0]; - op.lpstrElementName = psz_drive; - - /* Set the flags for the device type */ - i_flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | - MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE; - - if( !mciSendCommand( 0, MCI_OPEN, i_flags, (unsigned long)&op ) ) { - st.dwItem = MCI_STATUS_READY; - /* Eject disc */ - ret = mciSendCommand( op.wDeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0 ) != 0; - /* Release access to the device */ - mciSendCommand( op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0 ); - } else - ret = 0; - - return ret; -} - -/*! - Return the value associated with the key "arg". -*/ -static const char * -_cdio_get_arg (void *user_data, const char key[]) -{ - _img_private_t *_obj = user_data; - - if (!strcmp (key, "source")) { - return _obj->gen.source_name; - } else if (!strcmp (key, "access-mode")) { - if ( WIN_NT ) - return "winNT/2K/XP ioctl"; - else if (_obj->hASPI) - return "ASPI"; - else - return "undefined WIN32"; - } - return NULL; -} - -/*! - Return the number of of the first track. - CDIO_INVALID_TRACK is returned on error. -*/ -static track_t -_cdio_get_first_track_num(void *user_data) -{ - _img_private_t *_obj = user_data; - - if (!_obj->toc_init) _cdio_read_toc (_obj) ; - - return _obj->first_track_num; -} - -/*! - Return the number of tracks in the current medium. - CDIO_INVALID_TRACK is returned on error. -*/ -static track_t -_cdio_get_num_tracks(void *user_data) -{ - _img_private_t *_obj = user_data; - - if (!_obj->toc_init) _cdio_read_toc (_obj) ; - - return _obj->total_tracks; -} - -/*! - Get format of track. -*/ -static track_format_t -_cdio_get_track_format(void *user_data, track_t track_num) -{ - _img_private_t *_obj = user_data; - - MCI_OPEN_PARMS op; - MCI_STATUS_PARMS st; - DWORD i_flags; - int ret; - - memset( &op, 0, sizeof(MCI_OPEN_PARMS) ); - op.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_CD_AUDIO; - op.lpstrElementName = _obj->gen.source_name; - - /* Set the flags for the device type */ - i_flags = MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID | - MCI_OPEN_ELEMENT | MCI_OPEN_SHAREABLE; - - if( !mciSendCommand( 0, MCI_OPEN, i_flags, (unsigned long)&op ) ) { - st.dwItem = MCI_CDA_STATUS_TYPE_TRACK; - st.dwTrack = track_num; - i_flags = MCI_TRACK | MCI_STATUS_ITEM ; - ret = mciSendCommand( op.wDeviceID, MCI_STATUS, i_flags, - (unsigned long) &st ); - - /* Release access to the device */ - mciSendCommand( op.wDeviceID, MCI_CLOSE, MCI_WAIT, 0 ); - - switch(st.dwReturn) { - case MCI_CDA_TRACK_AUDIO: - return TRACK_FORMAT_AUDIO; - case MCI_CDA_TRACK_OTHER: - return TRACK_FORMAT_DATA; - default: - return TRACK_FORMAT_XA; - } - } - - return TRACK_FORMAT_ERROR; - -} - -/*! - 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? -*/ -static bool -_cdio_get_track_green(void *user_data, track_t track_num) -{ - _img_private_t *_obj = user_data; - - if (!_obj->toc_init) _cdio_read_toc (_obj) ; - - if (track_num == CDIO_CDROM_LEADOUT_TRACK) track_num = _obj->total_tracks+1; - - if (track_num > _obj->total_tracks+1 || track_num == 0) - return false; - - /* FIXME! */ - return true; -} - -/*! - 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. -*/ -static bool -_cdio_get_track_msf(void *user_data, track_t track_num, msf_t *msf) -{ - _img_private_t *_obj = user_data; - - if (NULL == msf) return false; - - if (!_obj->toc_init) _cdio_read_toc (_obj) ; - - if (track_num == CDIO_CDROM_LEADOUT_TRACK) track_num = _obj->total_tracks+1; - - if (track_num > _obj->total_tracks+1 || track_num == 0) { - return false; - } else { - cdio_lsn_to_msf(_obj->tocent[track_num-1].start_lsn, msf); - return true; - } -} - -#endif /* HAVE_WIN32_CDROM */ - -/*! - Return an array of strings giving possible CD devices. - */ -char ** -cdio_get_devices_win32 (void) -{ -#ifndef HAVE_WIN32_CDROM - return NULL; -#else - char **drives = NULL; - unsigned int num_drives=0; - char drive_letter; - - /* Scan the system for CD-ROM drives. - */ - -#if FINISHED - /* Now check the currently mounted CD drives */ - if (NULL != (ret_drive = cdio_check_mounts("/etc/mtab"))) { - cdio_add_device_list(&drives, drive, &num_drives); - } - - /* Finally check possible mountable drives in /etc/fstab */ - if (NULL != (ret_drive = cdio_check_mounts("/etc/fstab"))) { - cdio_add_device_list(&drives, drive, &num_drives); - } -#endif - - /* Scan the system for CD-ROM drives. - Not always 100% reliable, so use the USE_MNTENT code above first. - */ - for (drive_letter='A'; drive_letter <= 'Z'; drive_letter++) { - const char *drive_str=cdio_is_cdrom(drive_letter); - if (drive_str != NULL) { - cdio_add_device_list(&drives, drive_str, &num_drives); - } - } - cdio_add_device_list(&drives, NULL, &num_drives); - return drives; -#endif /*HAVE_WIN32_CDROM*/ -} - -/*! - Return a string containing the default CD device if none is specified. - if CdIo 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_win32(void) -{ - -#ifdef HAVE_WIN32_CDROM - char drive_letter; - - for (drive_letter='A'; drive_letter <= 'Z'; drive_letter++) { - const char *drive_str=cdio_is_cdrom(drive_letter); - if (drive_str != NULL) { - return strdup(drive_str); - } - } -#endif - return NULL; -} - -/*! - Return true if source_name could be a device containing a CD-ROM. -*/ -bool -cdio_is_device_win32(const char *source_name) -{ - unsigned int len; - len = strlen(source_name); - - if (NULL == source_name) return false; - -#ifdef HAVE_WIN32_CDROM - if ( WIN_NT ) - /* Really should test to see if of form: \\.\x: */ - return ((len == 6) && isalpha(source_name[len-2]) - && (source_name[len-1] == ':')); - else - /* See if is of form: x: */ - return ((len == 2) && isalpha(source_name[0]) - && (source_name[len-1] == ':')); -#else - return false; -#endif -} - -/*! - Initialization routine. This is the only thing that doesn't - get called via a function pointer. In fact *we* are the - ones to set that up. - */ -CdIo * -cdio_open_win32 (const char *source_name) -{ - -#ifdef HAVE_WIN32_CDROM - CdIo *ret; - _img_private_t *_data; - - cdio_funcs _funcs = { - .eject_media = _cdio_eject_media, - .free = _cdio_win32_free, - .get_arg = _cdio_get_arg, - .get_default_device = cdio_get_default_device_win32, - .get_devices = cdio_get_devices_win32, - .get_first_track_num= _cdio_get_first_track_num, - .get_mcn = NULL, - .get_num_tracks = _cdio_get_num_tracks, - .get_track_format = _cdio_get_track_format, - .get_track_green = _cdio_get_track_green, - .get_track_lba = NULL, /* This could be implemented if need be. */ - .get_track_msf = _cdio_get_track_msf, - .lseek = NULL, - .read = NULL, - .read_audio_sectors = _cdio_read_audio_sectors, - .read_mode2_sector = _cdio_read_mode2_sector, - .read_mode2_sectors = _cdio_read_mode2_sectors, - .set_arg = _cdio_set_arg, - .stat_size = _cdio_stat_size - }; - - _data = _cdio_malloc (sizeof (_img_private_t)); - _data->gen.init = false; - _data->gen.fd = -1; - - _cdio_set_arg(_data, "source", (NULL == source_name) - ? cdio_get_default_device_win32(): source_name); - - ret = cdio_new (_data, &_funcs); - if (ret == NULL) return NULL; - - if (_cdio_init_win32(_data)) - return ret; - else { - _cdio_win32_free (_data); - return NULL; - } - -#else - return NULL; -#endif /* HAVE_WIN32_CDROM */ - -} - -bool -cdio_have_win32 (void) -{ -#ifdef HAVE_WIN32_CDROM - return true; -#else - return false; -#endif /* HAVE_WIN32_CDROM */ -} diff --git a/src/input/vcd/libcdio/bytesex.h b/src/input/vcd/libcdio/bytesex.h index 431de9799..a94a8129e 100644 --- a/src/input/vcd/libcdio/bytesex.h +++ b/src/input/vcd/libcdio/bytesex.h @@ -1,5 +1,5 @@ /* - $Id: bytesex.h,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: bytesex.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libcdio/bytesex_asm.h b/src/input/vcd/libcdio/bytesex_asm.h index 34ef5e605..03cb3cd98 100644 --- a/src/input/vcd/libcdio/bytesex_asm.h +++ b/src/input/vcd/libcdio/bytesex_asm.h @@ -1,5 +1,5 @@ /* - $Id: bytesex_asm.h,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: bytesex_asm.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2001 Sven Ottemann <ac-logic@freenet.de> 2001 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libcdio/cd_types.c b/src/input/vcd/libcdio/cd_types.c index 0dd6c8410..047c8bb63 100644 --- a/src/input/vcd/libcdio/cd_types.c +++ b/src/input/vcd/libcdio/cd_types.c @@ -1,5 +1,5 @@ /* - $Id: cd_types.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: cd_types.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> @@ -208,7 +208,7 @@ _cdio_get_joliet_level( void ) */ cdio_fs_anal_t cdio_guess_cd_type(const CdIo *cdio, int start_session, track_t track_num, - /*out*/ cdio_analysis_t *cdio_analysis) + /*out*/ cdio_iso_analysis_t *iso_analysis) { int ret = 0; bool sector0_read_ok; @@ -239,8 +239,8 @@ cdio_guess_cd_type(const CdIo *cdio, int start_session, track_t track_num, ret = CDIO_FS_ISO_HFS; else ret = CDIO_FS_ISO_9660; - cdio_analysis->isofs_size = _cdio_get_iso9660_fs_sec_count(); - sprintf(cdio_analysis->iso_label, buffer[0]+40); + iso_analysis->isofs_size = _cdio_get_iso9660_fs_sec_count(); + sprintf(iso_analysis->iso_label, buffer[0]+40); #if 0 if (_cdio_is_rockridge()) @@ -251,7 +251,7 @@ cdio_guess_cd_type(const CdIo *cdio, int start_session, track_t track_num, return ret; if (_cdio_is_joliet()) { - cdio_analysis->joliet_level = _cdio_get_joliet_level(); + iso_analysis->joliet_level = _cdio_get_joliet_level(); ret |= CDIO_FS_ANAL_JOLIET; } if (_cdio_is_it(INDEX_BOOTABLE)) diff --git a/src/input/vcd/libcdio/cdio.c b/src/input/vcd/libcdio/cdio.c index 8d6c39bed..2a814141b 100644 --- a/src/input/vcd/libcdio/cdio.c +++ b/src/input/vcd/libcdio/cdio.c @@ -1,7 +1,7 @@ /* - $Id: cdio.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: cdio.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ - Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> + Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> This program is free software; you can redistribute it and/or modify @@ -37,7 +37,7 @@ #include <cdio/logging.h> #include "cdio_private.h" -static const char _rcsid[] = "$Id: cdio.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; +static const char _rcsid[] = "$Id: cdio.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; const char *track_format2str[6] = @@ -299,7 +299,9 @@ cdio_get_devices (driver_id_t driver_id) if (cdio == NULL) return NULL; if (cdio->op.get_devices) { - return cdio->op.get_devices (); + char **devices = cdio->op.get_devices (); + cdio_destroy(cdio); + return devices; } else { return NULL; } @@ -318,6 +320,8 @@ cdio_get_devices (driver_id_t driver_id) 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. + 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* search_devices[], @@ -332,23 +336,26 @@ cdio_get_devices_with_cap (char* search_devices[], if (capabilities == CDIO_FS_MATCH_ALL) { /* Duplicate drives into drives_ret. */ - for( ; *drives != NULL; drives++ ) { - cdio_add_device_list(&drives_ret, *drives, &num_drives); + char **d = drives; + + for( ; *d != NULL; d++ ) { + cdio_add_device_list(&drives_ret, *d, &num_drives); } } else { cdio_fs_anal_t got_fs=0; cdio_fs_anal_t need_fs = CDIO_FSTYPE(capabilities); cdio_fs_anal_t need_fs_ext; + char **d = drives; need_fs_ext = capabilities & ~CDIO_FS_MASK; - for( ; *drives != NULL; drives++ ) { - CdIo *cdio = cdio_open(*drives, DRIVER_UNKNOWN); + for( ; *d != NULL; d++ ) { + CdIo *cdio = cdio_open(*d, DRIVER_UNKNOWN); if (NULL != cdio) { track_t first_track = cdio_get_first_track_num(cdio); - cdio_analysis_t cdio_analysis; + cdio_iso_analysis_t cdio_iso_analysis; got_fs = cdio_guess_cd_type(cdio, 0, first_track, - &cdio_analysis); + &cdio_iso_analysis); /* Match on fs and add */ if ( (CDIO_FS_UNKNOWN == need_fs || CDIO_FSTYPE(got_fs) == need_fs) ) { @@ -362,8 +369,10 @@ cdio_get_devices_with_cap (char* search_devices[], cdio_destroy(cdio); } } - cdio_add_device_list(&drives_ret, NULL, &num_drives); } + cdio_add_device_list(&drives_ret, NULL, &num_drives); + cdio_free_device_list(drives); + free(drives); return drives_ret; } @@ -669,53 +678,48 @@ cdio_read_audio_sectors (const CdIo *cdio, void *buf, lsn_t lsn, return -1; } +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif + /*! Reads a single mode1 form1 or form2 sector from cd device into data starting from lsn. Returns 0 if no error. */ int -cdio_read_mode1_sector (const CdIo *cdio, void *data, lsn_t lsn, bool is_form2) +cdio_read_mode1_sector (const CdIo *cdio, void *data, lsn_t lsn, bool b_form2) { - uint32_t size = is_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE ; + uint32_t size = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE ; char buf[M2RAW_SECTOR_SIZE] = { 0, }; - int ret; cdio_assert (cdio != NULL); cdio_assert (data != NULL); - if (cdio->op.lseek && cdio->op.read) { + if (cdio->op.read_mode1_sector && cdio->op.read_mode1_sector) { + return cdio->op.read_mode1_sector(cdio->env, data, lsn, b_form2); + } else if (cdio->op.lseek && cdio->op.read) { if (0 > cdio_lseek(cdio, CDIO_CD_FRAMESIZE*lsn, SEEK_SET)) return -1; if (0 > cdio_read(cdio, buf, CDIO_CD_FRAMESIZE)) return -1; memcpy (data, buf, size); return 0; - } else { - ret = cdio_read_mode2_sector(cdio, data, lsn, is_form2); - if (ret == 0) - memcpy (data, buf+CDIO_CD_SUBHEADER_SIZE, size); - } - return ret; + } + + return 1; } int -cdio_read_mode1_sectors (const CdIo *cdio, void *data, lsn_t lsn, - bool is_form2, unsigned int num_sectors) +cdio_read_mode1_sectors (const CdIo *cdio, void *buf, lsn_t lsn, + bool b_form2, unsigned int num_sectors) { - uint32_t size = is_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE ; - int retval; - int i; - cdio_assert (cdio != NULL); + cdio_assert (buf != NULL); + cdio_assert (cdio->op.read_mode1_sectors != NULL); - for (i = 0; i < num_sectors; i++) { - if ( (retval = cdio_read_mode1_sector (cdio, - ((char *)data) + (size * i), - lsn + i, is_form2)) ) - return retval; - } - return 0; + return cdio->op.read_mode1_sectors (cdio->env, buf, lsn, b_form2, + num_sectors); } /*! @@ -724,7 +728,7 @@ cdio_read_mode1_sectors (const CdIo *cdio, void *data, lsn_t lsn, */ int cdio_read_mode2_sector (const CdIo *cdio, void *buf, lsn_t lsn, - bool is_form2) + bool b_form2) { cdio_assert (cdio != NULL); cdio_assert (buf != NULL); @@ -732,24 +736,24 @@ cdio_read_mode2_sector (const CdIo *cdio, void *buf, lsn_t lsn, || cdio->op.read_mode2_sectors != NULL); if (cdio->op.read_mode2_sector) - return cdio->op.read_mode2_sector (cdio->env, buf, lsn, is_form2); + return cdio->op.read_mode2_sector (cdio->env, buf, lsn, b_form2); /* fallback */ if (cdio->op.read_mode2_sectors != NULL) - return cdio_read_mode2_sectors (cdio, buf, lsn, is_form2, 1); + return cdio_read_mode2_sectors (cdio, buf, lsn, b_form2, 1); return 1; } int -cdio_read_mode2_sectors (const CdIo *cdio, void *buf, lsn_t lsn, bool mode2raw, - unsigned num_sectors) +cdio_read_mode2_sectors (const CdIo *cdio, void *buf, lsn_t lsn, + bool b_form2, unsigned int num_sectors) { cdio_assert (cdio != NULL); cdio_assert (buf != NULL); cdio_assert (cdio->op.read_mode2_sectors != NULL); return cdio->op.read_mode2_sectors (cdio->env, buf, lsn, - mode2raw, num_sectors); + b_form2, num_sectors); } uint32_t @@ -849,6 +853,7 @@ cdio_open (const char *orig_source_name, driver_id_t driver_id) if ((*CdIo_all_drivers[driver_id].have_driver)()) { CdIo *ret = (*CdIo_all_drivers[driver_id].driver_open)(source_name); if (ret) ret->driver_id = driver_id; + free(source_name); return ret; } } diff --git a/src/input/vcd/libcdio/cdio/cd_types.h b/src/input/vcd/libcdio/cdio/cd_types.h index 91b36453c..1117171ae 100644 --- a/src/input/vcd/libcdio/cdio/cd_types.h +++ b/src/input/vcd/libcdio/cdio/cd_types.h @@ -1,5 +1,5 @@ /* - $Id: cd_types.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: cd_types.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org> @@ -20,10 +20,11 @@ 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. -*/ +/** \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__ @@ -32,72 +33,100 @@ 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 +/** + * 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 -#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_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 & isofs filesystem */ -#define CDIO_FS_ISO_9660_INTERACTIVE 9 /* both CD-RTOS and isofs filesystem */ +#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. */ +/** + * 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_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 */ +/** + * 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. +/** + * 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_XA 16 /**< eXtended Architecture format */ +#define CDIO_FS_ANAL_MULTISESSION 32 /**< CD has multisesion */ +#define CDIO_FS_ANAL_PHOTO_CD 64 /**< Is a Kodak Photo CD */ +#define CDIO_FS_ANAL_HIDDEN_TRACK 128 /**< Hidden track at the + beginning of the CD */ #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_ANAL_BOOTABLE 512 /**< CD is bootable */ +#define CDIO_FS_ANAL_VIDEOCD 1024 /**< VCD 1.1 */ +#define CDIO_FS_ANAL_ROCKRIDGE 2048 /**< Has Rock Ridge Extensions to + ISO 9660 */ +#define CDIO_FS_ANAL_JOLIET 4096 /**< Microsoft Joliet extensions + to ISO 9660 */ +#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) +/*! + \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; - char iso_label[33]; /* 32 + 1 for null byte at the end in - formatting the string */ + 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; -} cdio_analysis_t; +} 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 cdio_analysis and the return value. -*/ +/** + * 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_analysis_t *cdio_analysis); + /*out*/ cdio_iso_analysis_t *iso_analysis); #ifdef __cplusplus } diff --git a/src/input/vcd/libcdio/cdio/cdio.h b/src/input/vcd/libcdio/cdio/cdio.h index d0b304b38..a9fa4b02e 100644 --- a/src/input/vcd/libcdio/cdio/cdio.h +++ b/src/input/vcd/libcdio/cdio/cdio.h @@ -1,8 +1,8 @@ /* -*- c -*- - $Id: cdio.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: cdio.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> + 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 @@ -19,14 +19,16 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Public CD Input and Control Interface . */ +/** \file cdio.h + * \brief The top-level header for libcdio: the CD Input and Control library. + */ #ifndef __CDIO_H__ #define __CDIO_H__ -/* Application Interface or Protocol version number. If the public - interface changes, we increase this number. +/** Application Interface or Protocol version number. If the public + * interface changes, we increase this number. */ #define CDIO_API_VERSION 1 @@ -43,64 +45,68 @@ #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_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 #define CDIO_SRC_IS_NATIVE_MASK 0x0008 #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ - /* opaque structure */ + /** This is an 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. - - */ + /** 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 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_BSDI, /**< BSDI driver */ + DRIVER_FREEBSD, /**< FreeBSD driver */ + DRIVER_LINUX, /**< GNU/Linux Driver */ + DRIVER_SOLARIS, /**< Sun Solaris Driver */ + DRIVER_OSX, /**< Apple OSX Driver */ + DRIVER_WIN32, /**< Microsoft Windows Driver */ + DRIVER_BINCUE, /**< BIN/CUE format CD image. This is listed before NRG, + to make the code prefer BINCUE 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; - /* 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. - */ +/** 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_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_ERROR /**< Dunno what is, or some other error. */ } track_format_t; - /* Printable tags for above enumeration. */ + /*! Printable tags for track_format_t enumeration. */ extern const char *track_format2str[6]; /*! @@ -140,12 +146,14 @@ extern "C" { 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. + 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* 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 + /*! 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. @@ -190,7 +198,7 @@ extern "C" { track_t cdio_get_num_tracks (const CdIo *obj); /*! - Get format of track. + Get the format (audio, mode2, mode1) of track. */ track_format_t cdio_get_track_format(const CdIo *obj, track_t track_num); @@ -255,46 +263,46 @@ extern "C" { 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. - */ + 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. - */ + 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); - + bool b_form2); + /*! - Reads nblocks of mode1 sectors from cd device into data starting - from lsn. Returns 0 if no error. - */ + 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); - + bool b_form2, unsigned int num_sectors); + /*! - Reads a single mode2 sector from cd device into data starting - from lsn. Returns 0 if no error. - */ + 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); - + bool b_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); + bool b_form2, unsigned int num_sectors); /*! Set the arg "key" with "value" in the source device. @@ -306,49 +314,73 @@ extern "C" { 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, ... */ + + /*! 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); - /* Like above but uses the enumeration instead. */ + /*! Like cdio_have_xxx but uses an enumeration instead. */ bool cdio_have_driver (driver_id_t driver_id); - /* Return a string decribing 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. + done previously. to call one of the specific cdio_open_xxx + routines. 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 + /*! Set up BIN/CUE CD disk-image for reading. Source is the .bin or + .cue file NULL is returned on error. */ CdIo * cdio_open_bincue (const char *bin_name); + /*! 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_bincue(void); char **cdio_get_devices_bincue(void); - /*! CD routines. Source is the some sort of device. + /*! Set up CD-ROM for reading. The device_name is + the some sort of device name. NULL is returned on error. */ @@ -360,65 +392,154 @@ extern "C" { */ CdIo * cdio_open_cue (const char *cue_name); - /*! BSDI CD-reading routines. - NULL is returned on error. - */ + /*! Set up CD-ROM for reading using the BSDI driver. The device_name is + the some sort of device name. + + NULL is returned on error or there is no BSDI driver. + + @see cdio_open + */ CdIo * cdio_open_bsdi (const char *source_name); + /*! Return a string containing the default device name that the + BSDI driver would use when none is specified. + + NULL is returned on error or there is no CD-ROM device. + + @see cdio_open_cd + @see 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. + */ char **cdio_get_devices_bsdi(void); - /*! BSDI CD-reading routines. - NULL is returned on error. - */ + /*! 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 + @see cdio_open + */ CdIo * cdio_open_freebsd (const char *source_name); + /*! 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); - /*! Linux CD-reading routines. - NULL is returned on error. + /*! Set up CD-ROM for reading using the GNU/Linux driver. The device_name is + the some sort of device name. + + NULL is returned on error or there is no GNU/Linux driver. */ CdIo * cdio_open_linux (const char *source_name); + /*! 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. + + @see cdio_open_cd + @see 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); - /*! Solaris CD-reading routines. - NULL is returned on error. + /*! Set up CD-ROM for reading using the Sun Solaris driver. The + device_name is the some sort of device name. + + NULL is returned on error or there is no Solaris driver. */ CdIo * cdio_open_solaris (const char *source_name); + /*! 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. + + @see cdio_open_cd + @see 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); - /*! Darwin OS X CD-reading routines. - NULL is returned on error. + /*! 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 + @see cdio_open */ CdIo * cdio_open_osx (const char *source_name); + /*! 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. + + NULL is returned on error or there is no CD-ROM device + */ 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); - /*! Win32 CD-reading routines. - NULL is returned on error. + /*! 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 * cdio_open_win32 (const char *source_name); + /*! 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. + + NULL is returned on error or there is no CD-ROM device. + + @see cdio_open_cd + @see cdio_open + */ char * cdio_get_default_device_win32(void); char **cdio_get_devices_win32(void); - /*! Nero CD disk-image routines. - NULL is returned on error. + /*! Set up CD-ROM for reading using the Nero driver. The + device_name is the some sort of device name. + + NULL is returned on error or there is no Nero driver. */ CdIo * cdio_open_nrg (const char *source_name); + /*! 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); diff --git a/src/input/vcd/libcdio/cdio/iso9660.h b/src/input/vcd/libcdio/cdio/iso9660.h index c2cabe5fc..78f78ef81 100644 --- a/src/input/vcd/libcdio/cdio/iso9660.h +++ b/src/input/vcd/libcdio/cdio/iso9660.h @@ -1,8 +1,8 @@ /* - $Id: iso9660.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: iso9660.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> + Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> See also iso9660.h by Eric Youngdale (1993). @@ -23,9 +23,9 @@ 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. +/*! + * \file iso9660.h + * \brief Header for libiso9660: the ISO-9660 filesystem library. */ @@ -42,16 +42,19 @@ #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: +/*! + 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 ('.' + ';') - + strlen("32767") - + null byte + + 5 chars (strlen("32767")) + + 1 null byte ================================ - = 38 chars + = 38 chars +\endverbatim */ #define LEN_ISONAME 31 #define MAX_ISONAME 37 @@ -61,26 +64,28 @@ /* * 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 */ +#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_SUPPLEMENTARY 2 /**< Used by Joliet */ #define ISO_VD_END 255 -#define ISO_PVD_SECTOR 16 -#define ISO_EVD_SECTOR 17 +#define ISO_PVD_SECTOR 16 /**< Sector of Primary Volume Descriptor */ +#define ISO_EVD_SECTOR 17 /**< Sector of End Volume Descriptor */ -#define ISO_STANDARD_ID "CD001" -#define ISO_BLOCKSIZE 2048 +#define ISO_STANDARD_ID "CD001" /**< String inside track identifying an + ISO 9660 filesystem. */ +#define ISO_BLOCKSIZE 2048 /**< Number of bytes in an ISO + 9660 block */ #ifdef __cplusplus extern "C" { @@ -95,64 +100,95 @@ enum strncpy_pad_check { PRAGMA_BEGIN_PACKED +/*! + \brief ISO-9660 shorter-format time structure. + + @see iso9660_dtime + */ 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_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 min intervals */ + 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 for Julian year */ - char lt_month [_delta( 5, 6)]; /* 1..12. Note starts at 1. */ + 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)]; /* 1/100's of a second */ + 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; -/* ISO-9660 Primary Volume Descriptor. +/*! + \brief ISO-9660 Primary Volume Descriptor. */ struct iso9660_pvd { - uint8_t type; /* 711 */ + uint8_t type; /**< 711 encoded */ char id[5]; - uint8_t version; /* 711 */ + uint8_t version; /**< 711 encoded */ char unused1[1]; - char system_id[32]; /* achars */ - char volume_id[32]; /* dchars */ + char system_id[32]; /**< each char is an achar */ + char volume_id[32]; /**< each char is a dchar */ char unused2[8]; - uint64_t volume_space_size; /* 733 */ + uint64_t volume_space_size; /**< 733 encoded */ 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 */ + 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 */ + char root_directory_record[34]; /**< See section 9.1 of + ISO 9660 spec. */ + 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]; /**< 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]; @@ -166,49 +202,110 @@ typedef struct iso9660_stat iso9660_stat_t; #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 */ +/*! \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 */ - uint8_t xa_length; /* 711 */ - uint64_t extent; /* 733 */ - uint64_t size; /* 733 */ - iso9660_dtime_t recording_time; /* 7 by 711 */ + 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 */ - uint8_t interleave_gap; /* 711 */ - uint32_t volume_sequence_number; /* 723 */ - uint8_t filename_len; /* 711 */ + 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; -/* 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. +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; - 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 */ -} ; + char filename[EMPTY_ARRAY_SIZE]; /**< filename */ +}; -PRAGMA_END_PACKED -/*==================================== - Character file/dirname's -=====================================*/ +/** This is an opaque structure. */ +typedef struct _iso9660 iso9660_t; + +/*! + Open an ISO 9660 image for reading. Maybe in the future we will have + flags and mode. NULL is returned on error. +*/ + iso9660_t *iso9660_open (const char *pathname /*flags, mode */); + +/*! + Close previously opened ISO 9660 image. + True is unconditionally returned. If there was an error false would + be returned. +*/ + bool iso9660_close (iso9660_t * iso); + + +/*! + Seek to a position and then read n bytes. Size read is returned. +*/ + long int iso9660_iso_seek_read (iso9660_t *iso, void *ptr, lsn_t start, + long int size); + +/*==================================================== + 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 *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 @@ -247,31 +344,6 @@ int iso9660_name_translate(const char *old, char *new); 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 ======================================================================*/ @@ -291,7 +363,7 @@ 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 + 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); @@ -336,45 +408,88 @@ 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. + lsn and return information about it. - Returns true if we found an entry with the lsn and false if not. + Returns stat_t of entry if we found lsn, or NULL otherwise. */ -bool iso9660_find_fs_lsn(const CdIo *cdio, lsn_t lsn, - /*out*/ iso9660_stat_t *stat); +iso9660_stat_t *iso9660_find_fs_lsn(const CdIo *cdio, lsn_t lsn); + /*! - Get file status for pathname into stat. As with libc's stat, 0 is returned - if no error and -1 on error. + 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 *iso, lsn_t lsn); + + +/*! + Get file status for pathname into stat. NULL is returned on error. + */ +iso9660_stat_t *iso9660_fs_stat (const CdIo *obj, const char pathname[], + bool is_mode2); + +/*! + 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. */ -int iso9660_fs_stat (const CdIo *obj, const char pathname[], - /*out*/ iso9660_stat_t *stat, bool is_mode2); +iso9660_stat_t *iso9660_fs_stat_translate (const CdIo *obj, + const char pathname[], + bool is_mode2); -void * /* list of char* -- caller must free it */ -iso9660_fs_readdir (const CdIo *obj, const char pathname[], bool mode2); +/*! + Get file status for pathname into stat. NULL is returned on error. + */ +void *iso9660_ifs_stat (iso9660_t *iso, const char pathname[]); -uint8_t -iso9660_get_dir_len(const iso9660_dir_t *idr); + +/*! + 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. + */ +void *iso9660_ifs_stat_translate (iso9660_t *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. +*/ +void * iso9660_fs_readdir (const CdIo *obj, const char pathname[], bool 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. +*/ +void * iso9660_ifs_readdir (iso9660_t *iso, const char pathname[]); + +uint8_t iso9660_get_dir_len(const iso9660_dir_t *idr); #if FIXME -uint8_t -iso9660_get_dir_size(const iso9660_dir_t *idr); +uint8_t iso9660_get_dir_size(const iso9660_dir_t *idr); -lsn_t -iso9660_get_dir_extent(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); +/*! + 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 *iso9660_dir); + +uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *pvd); -const char * -iso9660_get_pvd_id(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_space_size(const iso9660_pvd_t *pvd); -int -iso9660_get_pvd_block_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. @@ -401,7 +516,9 @@ uint16_t iso9660_pathtable_m_add_entry (void *pt, const char name[], uint32_t extent, uint16_t parent); -/* volume descriptors */ +/*===================================================================== + Volume Descriptors +======================================================================*/ void iso9660_set_pvd (void *pd, const char volume_id[], const char application_id[], diff --git a/src/input/vcd/libcdio/cdio/logging.h b/src/input/vcd/libcdio/cdio/logging.h index 9a600b437..aec981ad4 100644 --- a/src/input/vcd/libcdio/cdio/logging.h +++ b/src/input/vcd/libcdio/cdio/logging.h @@ -1,7 +1,8 @@ /* - $Id: logging.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: logging.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ - Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> + 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 @@ -17,42 +18,104 @@ 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> +/** + * The different log levels supported. + */ typedef enum { - CDIO_LOG_DEBUG = 1, - CDIO_LOG_INFO, - CDIO_LOG_WARN, - CDIO_LOG_ERROR, - CDIO_LOG_ASSERT + 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; -extern int cdio_loglevel_default; +/** + * 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; -void -cdio_log (cdio_log_level_t level, const char format[], ...) GNUC_PRINTF(2, 3); - +/** + * 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[]); -cdio_log_handler_t -cdio_log_set_handler (cdio_log_handler_t new_handler); +/** + * 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 -void -cdio_debug (const char format[], ...) GNUC_PRINTF(1,2); + * @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); -void -cdio_info (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); -void -cdio_warn (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); -void -cdio_error (const char format[], ...) GNUC_PRINTF(1,2); +/** + * Handle an error message. + * + * @see cdio_log for a more generic routine. + */ +void cdio_error (const char format[], ...) GNUC_PRINTF(1,2); #endif /* __LOGGING_H__ */ diff --git a/src/input/vcd/libcdio/cdio/sector.h b/src/input/vcd/libcdio/cdio/sector.h index 39dd0fefb..939515543 100644 --- a/src/input/vcd/libcdio/cdio/sector.h +++ b/src/input/vcd/libcdio/cdio/sector.h @@ -1,5 +1,5 @@ /* - $Id: sector.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: sector.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> @@ -18,8 +18,44 @@ 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, +/*! + \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_ @@ -34,80 +70,50 @@ #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_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 */ +/*! "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 */ +/*! "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_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 */ +/*! The leadout track is always 0xAA, regardless of # of tracks on disc */ #define CDIO_CDROM_LEADOUT_TRACK 0xAA #define M2F2_SECTOR_SIZE 2324 @@ -129,20 +135,40 @@ #define msf_t_SIZEOF 3 -/* warning, returns new allocated string */ +/*! + 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 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. +*/ 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. +*/ lba_t cdio_msf_to_lba (const msf_t *msf); +/*! + Convert a MSF into the corresponding LSN. +*/ lsn_t cdio_msf_to_lsn (const msf_t *msf); diff --git a/src/input/vcd/libcdio/cdio/types.h b/src/input/vcd/libcdio/cdio/types.h index e3c3ff3e5..c4b0b0934 100644 --- a/src/input/vcd/libcdio/cdio/types.h +++ b/src/input/vcd/libcdio/cdio/types.h @@ -1,8 +1,8 @@ /* - $Id: types.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: types.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com> + 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 @@ -18,6 +18,11 @@ 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__ @@ -54,10 +59,6 @@ extern "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 */ @@ -172,14 +173,23 @@ extern "C" { /* 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. */ + /*! + \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 - typedef struct { + struct msf_rec { uint8_t m, s, f; - } GNUC_PACKED msf_t; + } 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) */ @@ -194,13 +204,16 @@ extern "C" { typedef uint8_t bitfield_t; #endif - /* The type of a Logical Block Address. */ + /*! The type of a Logical Block Address. + + @see msf_t + */ typedef uint32_t lba_t; - /* The type of an Logical Sector Number. */ + /*! The type of an Logical Sector Number. */ typedef uint32_t lsn_t; - /* The type of an track number 0..99. */ + /*! The type of an track number 0..99. */ typedef uint8_t track_t; /*! diff --git a/src/input/vcd/libcdio/cdio/util.h b/src/input/vcd/libcdio/cdio/util.h index 147a32365..5142653ad 100644 --- a/src/input/vcd/libcdio/cdio/util.h +++ b/src/input/vcd/libcdio/cdio/util.h @@ -1,5 +1,5 @@ /* - $Id: util.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: util.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -21,6 +21,12 @@ #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 diff --git a/src/input/vcd/libcdio/cdio/version.h b/src/input/vcd/libcdio/cdio/version.h index c8bbce698..345924cab 100644 --- a/src/input/vcd/libcdio/cdio/version.h +++ b/src/input/vcd/libcdio/cdio/version.h @@ -1 +1,10 @@ -#define CDIO_VERSION "0.64-cvs" +/* $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/src/input/vcd/libcdio/cdio/xa.h b/src/input/vcd/libcdio/cdio/xa.h index 06e5df250..5ff7addd4 100644 --- a/src/input/vcd/libcdio/cdio/xa.h +++ b/src/input/vcd/libcdio/cdio/xa.h @@ -1,8 +1,8 @@ /* - $Id: xa.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: xa.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> + Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com> See also iso9660.h by Eric Youngdale (1993) and in cdrtools. These are @@ -24,6 +24,11 @@ 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__ @@ -34,17 +39,17 @@ #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_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_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_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_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) @@ -61,18 +66,37 @@ #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!! */ +/*! \brief "Extended Architecture according t 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 */ -} iso9660_xa_t GNUC_PACKED; + 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; /*! @@ -106,6 +130,12 @@ typedef struct iso9660_xa /* big endian!! */ 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); diff --git a/src/input/vcd/libcdio/cdio_assert.h b/src/input/vcd/libcdio/cdio_assert.h index 03ea16763..2433bf0c7 100644 --- a/src/input/vcd/libcdio/cdio_assert.h +++ b/src/input/vcd/libcdio/cdio_assert.h @@ -1,5 +1,5 @@ /* - $Id: cdio_assert.h,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: cdio_assert.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libcdio/cdio_private.h b/src/input/vcd/libcdio/cdio_private.h index 85c92946d..c1106e694 100644 --- a/src/input/vcd/libcdio/cdio_private.h +++ b/src/input/vcd/libcdio/cdio_private.h @@ -1,7 +1,7 @@ /* - $Id: cdio_private.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: cdio_private.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ - Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> + 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 @@ -146,7 +146,7 @@ extern "C" { from lsn. Returns 0 if no error. */ int (*read_mode2_sector) (void *env, void *buf, lsn_t lsn, - bool mode2raw); + bool mode2_form2); /*! Reads nblocks of mode2 sectors from cd device into data starting @@ -154,7 +154,22 @@ extern "C" { Returns 0 if no error. */ int (*read_mode2_sectors) (void *env, void *buf, lsn_t lsn, - bool mode2raw, unsigned int nblocks); + bool mode2_form2, unsigned int nblocks); + + /*! + Reads a single mode1 sector from cd device into buf starting + from lsn. Returns 0 if no error. + */ + int (*read_mode1_sector) (void *env, void *buf, lsn_t lsn, + bool mode1_form2); + + /*! + Reads nblocks of mode1 sectors from cd device into data starting + from lsn. + Returns 0 if no error. + */ + int (*read_mode1_sectors) (void *env, void *buf, lsn_t lsn, + bool mode1_form2, unsigned int nblocks); /*! Set the arg "key" with "value" in the source device. @@ -275,7 +290,7 @@ extern "C" { /*! Release and free resources associated with stream or disk image. */ - void cdio_generic_stream_free (void *env); + void cdio_generic_stdio_free (void *env); /*! Return true if source_name could be a device containing a CD-ROM on diff --git a/src/input/vcd/libcdio/ds.c b/src/input/vcd/libcdio/ds.c index 7cc62a8f9..bc015d79f 100644 --- a/src/input/vcd/libcdio/ds.c +++ b/src/input/vcd/libcdio/ds.c @@ -1,5 +1,5 @@ /* - $Id: ds.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: ds.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -30,7 +30,7 @@ #include <cdio/types.h> #include "cdio_assert.h" -static const char _rcsid[] = "$Id: ds.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: ds.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; struct _CdioList { diff --git a/src/input/vcd/libcdio/ds.h b/src/input/vcd/libcdio/ds.h index 046a5b0b0..24805840e 100644 --- a/src/input/vcd/libcdio/ds.h +++ b/src/input/vcd/libcdio/ds.h @@ -1,5 +1,5 @@ /* - $Id: ds.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: ds.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libcdio/_cdio_bincue.c b/src/input/vcd/libcdio/image/bincue.c index 04293c483..d0ca9b240 100644 --- a/src/input/vcd/libcdio/_cdio_bincue.c +++ b/src/input/vcd/libcdio/image/bincue.c @@ -1,8 +1,8 @@ /* - $Id: _cdio_bincue.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: bincue.c,v 1.1 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com> + 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 @@ -24,7 +24,7 @@ (*.cue). */ -static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; +static const char _rcsid[] = "$Id: bincue.c,v 1.1 2004/04/11 12:20:32 miguelfreitas Exp $"; #include "cdio_assert.h" #include "cdio_private.h" @@ -52,10 +52,10 @@ static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.1 2003/10/13 11:47:11 f1rm #include <ctype.h> /* FIXME: should put in a common definition somewhere. */ -#ifdef HAVE_BZERO -#define BZERO(ptr, size) bzero(ptr, size) -#elif HAVE_MEMSET +#ifdef HAVE_MEMSET #define BZERO(ptr, size) memset(ptr, 0, size) +#elif HAVE_BZERO +#define BZERO(ptr, size) bzero(ptr, size) #else Error -- you need either memset or bzero #endif @@ -116,7 +116,7 @@ _cdio_init (_img_private_t *_obj) return false; if (!(_obj->gen.data_source = cdio_stdio_new (_obj->gen.source_name))) { - cdio_error ("init failed"); + cdio_warn ("init failed"); return false; } @@ -371,8 +371,7 @@ _cdio_image_read_cue (_img_private_t *_obj) } } else if (2==sscanf(p, "TRACK %d MODE1/%d", &track_num, &blocksize)) { - track_info_t *this_track=&(_obj->tocent[_obj->total_tracks]); - this_track->blocksize = blocksize; + track_info_t *this_track=&(_obj->tocent[_obj->total_tracks]); this_track->blocksize = blocksize; switch(blocksize) { case 2048: @@ -502,7 +501,8 @@ _cdio_read_audio_sectors (void *env, void *data, lsn_t lsn, CDIO_CD_FRAMESIZE_RAW - 272, nblocks); } - return ret; + /* ret is number of bytes if okay, but we need to return 0 okay. */ + return ret == 0; } /*! @@ -510,12 +510,75 @@ _cdio_read_audio_sectors (void *env, void *data, lsn_t lsn, from lsn. Returns 0 if no error. */ static int +_cdio_read_mode1_sector (void *env, void *data, lsn_t lsn, + bool b_form2) +{ + _img_private_t *_obj = env; + int ret; + char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, }; + int blocksize = _obj->sector_2336 + ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE_RAW; + + _cdio_init (_obj); + + ret = cdio_stream_seek (_obj->gen.data_source, lsn * blocksize, SEEK_SET); + if (ret!=0) return ret; + + /* FIXME: Not completely sure the below is correct. */ + ret = cdio_stream_read (_obj->gen.data_source, + _obj->sector_2336 + ? (buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE) + : buf, + blocksize, 1); + if (ret==0) return ret; + + memcpy (data, buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE, + b_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE); + + return 0; +} + +/*! + Reads nblocks of mode1 sectors from cd device into data starting + from lsn. + Returns 0 if no error. + */ +static int +_cdio_read_mode1_sectors (void *env, void *data, uint32_t lsn, + bool b_form2, unsigned int nblocks) +{ + _img_private_t *_obj = env; + int i; + int retval; + unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE; + + for (i = 0; i < nblocks; i++) { + if ( (retval = _cdio_read_mode1_sector (_obj, + ((char *)data) + (blocksize * i), + lsn + i, b_form2)) ) + return retval; + } + return 0; +} + +/*! + Reads a single mode1 sector from cd device into data starting + from lsn. Returns 0 if no error. + */ +static int _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, - bool mode2_form2) + bool b_form2) { _img_private_t *_obj = env; int ret; char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, }; + + /* NOTE: The logic below seems a bit wrong and convoluted + to me, but passes the regression tests. (Perhaps it is why we get + valgrind errors in vcdxrip). Leave it the way it was for now. + Review this sector 2336 stuff later. + */ + int blocksize = _obj->sector_2336 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE_RAW; @@ -531,7 +594,9 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, blocksize, 1); if (ret==0) return ret; - if (mode2_form2) + + /* See NOTE above. */ + if (b_form2) memcpy (data, buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE, M2RAW_SECTOR_SIZE); else @@ -547,40 +612,35 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, */ static int _cdio_read_mode2_sectors (void *env, void *data, uint32_t lsn, - bool mode2_form2, unsigned int nblocks) + bool b_form2, unsigned int nblocks) { _img_private_t *_obj = env; int i; int retval; + unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE; for (i = 0; i < nblocks; i++) { - if (mode2_form2) { - if ( (retval = _cdio_read_mode2_sector (_obj, - ((char *)data) + (M2RAW_SECTOR_SIZE * i), - lsn + i, true)) ) - return retval; - } else { - char buf[M2RAW_SECTOR_SIZE] = { 0, }; - if ( (retval = _cdio_read_mode2_sector (_obj, buf, lsn + i, true)) ) - return retval; - - memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i), - buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); - } + if ( (retval = _cdio_read_mode2_sector (_obj, + ((char *)data) + (blocksize * i), + lsn + i, b_form2)) ) + return retval; } return 0; } #define free_if_notnull(obj) \ - if (NULL != obj) free(obj); + if (NULL != obj) { free(obj); obj=NULL; }; static void -_cdio_bincue_free (void *env) { - _img_private_t *_obj = env; +_cdio_bincue_destroy (void *obj) +{ + _img_private_t *env = obj; - if (NULL == _obj) return; - free_if_notnull(_obj->mcn); - cdio_generic_stream_free(_obj); + if (NULL == env) return; + free_if_notnull(env->mcn); + free_if_notnull(env->cue_name); + cdio_generic_stdio_free(env); + free(env); } /*! @@ -590,9 +650,6 @@ _cdio_bincue_free (void *env) { 0 is returned if no error was found, and nonzero if there as an error. */ -/*! - Set the device to use in I/O operations. -*/ static int _cdio_set_arg (void *env, const char key[], const char value[]) { @@ -879,12 +936,32 @@ cdio_is_binfile(const char *bin_name) return NULL; } -static CdIo * -cdio_open_common (_img_private_t **_data) +CdIo * +cdio_open_bincue (const char *source_name) { + char *bin_name = cdio_is_cuefile(source_name); + + if (NULL != bin_name) { + free(bin_name); + return cdio_open_cue(source_name); + } else { + char *cue_name = cdio_is_binfile(source_name); + CdIo *cdio = cdio_open_cue(cue_name); + free(cue_name); + return cdio; + } +} + +CdIo * +cdio_open_cue (const char *cue_name) +{ + CdIo *ret; + _img_private_t *_data; + char *bin_name; + cdio_funcs _funcs = { .eject_media = cdio_generic_bogus_eject_media, - .free = _cdio_bincue_free, + .free = _cdio_bincue_destroy, .get_arg = _cdio_get_arg, .get_default_device = cdio_get_default_device_bincue, .get_first_track_num= _cdio_get_first_track_num, @@ -897,44 +974,23 @@ cdio_open_common (_img_private_t **_data) .lseek = _cdio_lseek, .read = _cdio_read, .read_audio_sectors = _cdio_read_audio_sectors, + .read_mode1_sector = _cdio_read_mode1_sector, + .read_mode1_sectors = _cdio_read_mode1_sectors, .read_mode2_sector = _cdio_read_mode2_sector, .read_mode2_sectors = _cdio_read_mode2_sectors, .set_arg = _cdio_set_arg, .stat_size = _cdio_stat_size }; - *_data = _cdio_malloc (sizeof (_img_private_t)); - (*_data)->gen.init = false; - (*_data)->sector_2336 = false; - (*_data)->cue_name = NULL; - - return cdio_new (*_data, &_funcs); -} - -CdIo * -cdio_open_bincue (const char *source_name) -{ - char *bin_name = cdio_is_cuefile(source_name); + if (NULL == cue_name) return NULL; - if (NULL != bin_name) { - return cdio_open_cue(source_name); - } else { - char *cue_name = cdio_is_binfile(source_name); - CdIo *cdio = cdio_open_cue(cue_name); - free(cue_name); - return cdio; - } -} + _data = _cdio_malloc (sizeof (_img_private_t)); + (_data)->gen.init = false; + (_data)->sector_2336 = false; + (_data)->cue_name = NULL; -CdIo * -cdio_open_cue (const char *cue_name) -{ - CdIo *ret; - _img_private_t *_data; - char *bin_name; + ret = cdio_new (_data, &_funcs); - if (NULL == cue_name) return NULL; - ret = cdio_open_common(&_data); if (ret == NULL) return NULL; bin_name = cdio_is_cuefile(cue_name); @@ -950,7 +1006,8 @@ cdio_open_cue (const char *cue_name) if (_cdio_init(_data)) { return ret; } else { - cdio_generic_stream_free (_data); + _cdio_bincue_destroy(_data); + free(ret); return NULL; } } diff --git a/src/input/vcd/libcdio/_cdio_nrg.c b/src/input/vcd/libcdio/image/nrg.c index 4b92f105f..c4aa5e403 100644 --- a/src/input/vcd/libcdio/_cdio_nrg.c +++ b/src/input/vcd/libcdio/image/nrg.c @@ -1,7 +1,8 @@ /* - $Id: _cdio_nrg.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $ + $Id: nrg.c,v 1.1 2004/04/11 12:20:32 miguelfreitas Exp $ - Copyright (C) 2001,2003 Herbert Valerio Riedel <hvr@gnu.org> + Copyright (C) 2001, 2003 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 @@ -47,7 +48,7 @@ #include "cdio_private.h" #include "_cdio_stdio.h" -static const char _rcsid[] = "$Id: _cdio_nrg.c,v 1.1 2003/10/13 11:47:11 f1rmb Exp $"; +static const char _rcsid[] = "$Id: nrg.c,v 1.1 2004/04/11 12:20:32 miguelfreitas Exp $"; /* structures used */ @@ -59,8 +60,9 @@ PRAGMA_BEGIN_PACKED typedef struct { uint32_t start GNUC_PACKED; uint32_t length GNUC_PACKED; - uint32_t type GNUC_PACKED; /* only 0x3 seen so far... - -> MIXED_MODE2 2336 blocksize */ + uint32_t type GNUC_PACKED; /* 0x0 -> MODE1, 0x2 -> MODE2 form1, + 0x3 -> MIXED_MODE2 2336 blocksize + */ uint32_t start_lsn GNUC_PACKED; /* does not include any pre-gaps! */ uint32_t _unknown GNUC_PACKED; /* wtf is this for? -- always zero... */ } _etnf_array_t; @@ -69,7 +71,9 @@ typedef struct { typedef struct { uint64_t start GNUC_PACKED; uint64_t length GNUC_PACKED; - uint32_t type GNUC_PACKED; + uint32_t type GNUC_PACKED; /* 0x0 -> MODE1, 0x2 -> MODE2 form1, + 0x3 -> MIXED_MODE2 2336 blocksize + */ uint32_t start_lsn GNUC_PACKED; uint64_t _unknown GNUC_PACKED; /* wtf is this for? -- always zero... */ } _etn2_array_t; @@ -83,6 +87,10 @@ typedef struct { } _cuex_array_t; typedef struct { + uint8_t _unknown[64] GNUC_PACKED; +} _daox_array_t; + +typedef struct { uint32_t id GNUC_PACKED; uint32_t len GNUC_PACKED; char data[EMPTY_ARRAY_SIZE] GNUC_PACKED; @@ -100,7 +108,17 @@ PRAGMA_END_PACKED #define ETNF_ID 0x45544e46 #define NER5_ID 0x4e455235 #define NERO_ID 0x4e45524f -#define SINF_ID 0x53494e46 +#define SINF_ID 0x53494e46 /* Session information */ +#define MTYP_ID 0x4d545950 /* Disc Media type? */ + +#define MTYP_AUDIO_CD 1 /* This isn't correct. But I don't know the + the right thing is and it sometimes works (and + sometimes is wrong). */ + +/* Disk track type Values gleaned from DAOX */ +#define DTYP_MODE1 0 +#define DTYP_MODE2_XA 2 +#define DTYP_INVALID 255 /* reader */ @@ -131,6 +149,7 @@ typedef struct { uint32_t sec_count; /* Number of sectors in track. Does not include pregap before next entry. */ uint64_t img_offset; /* Bytes offset from beginning of disk image file.*/ + uint32_t blocksize; /* Number of bytes in a block */ } _mapping_t; @@ -139,16 +158,20 @@ typedef struct { This must be first. */ generic_img_private_t gen; internal_position_t pos; + bool is_dao; /* True if some of disk at once. False + if some sort of track at once. */ + uint32_t mtyp; /* Value of MTYP (media type?) tag */ + uint8_t dtyp; /* Value of DAOX media type tag */ /* This is a hack because I don't really understnad NERO better. */ bool is_cues; - bool sector_2336; - track_info_t tocent[100]; /* entry info for each track */ - track_t total_tracks; /* number of tracks in image */ - track_t first_track_num; /* track number of first track */ - CdioList *mapping; /* List of track information */ - uint32_t size; + char *mcn; /* Media catalog number. */ + track_info_t tocent[100]; /* entry info for each track */ + track_t total_tracks; /* number of tracks in image */ + track_t first_track_num; /* track number of first track */ + CdioList *mapping; /* List of track information */ + uint32_t size; } _img_private_t; static bool _cdio_parse_nero_footer (_img_private_t *_obj); @@ -159,20 +182,20 @@ static uint32_t _cdio_stat_size (void *env); */ static void _register_mapping (_img_private_t *_obj, lsn_t start_lsn, uint32_t sec_count, - uint64_t img_offset, uint32_t blocksize) + uint64_t img_offset, uint32_t blocksize, + track_format_t track_format, bool track_green) { const int track_num=_obj->total_tracks; track_info_t *this_track=&(_obj->tocent[_obj->total_tracks]); _mapping_t *_map = _cdio_malloc (sizeof (_mapping_t)); - if (!_obj->mapping) - _obj->mapping = _cdio_list_new (); - - _cdio_list_append (_obj->mapping, _map); _map->start_lsn = start_lsn; _map->sec_count = sec_count; - _map->img_offset = img_offset; + _map->blocksize = blocksize; + + if (!_obj->mapping) _obj->mapping = _cdio_list_new (); + _cdio_list_append (_obj->mapping, _map); _obj->size = MAX (_obj->size, (start_lsn + sec_count)); @@ -186,21 +209,67 @@ _register_mapping (_img_private_t *_obj, lsn_t start_lsn, uint32_t sec_count, this_track->track_num = track_num+1; this_track->blocksize = blocksize; if (_obj->is_cues) - this_track->datastart = img_offset + 8; + this_track->datastart = img_offset; else - this_track->datastart = 8; + this_track->datastart = 0; + + if (track_green) + this_track->datastart += CDIO_CD_SUBHEADER_SIZE; this_track->sec_count = sec_count; + this_track->track_format= track_format; + this_track->track_green = track_green; + + switch (this_track->track_format) { + case TRACK_FORMAT_AUDIO: + this_track->blocksize = CDIO_CD_FRAMESIZE_RAW; + this_track->datasize = CDIO_CD_FRAMESIZE_RAW; + /*this_track->datastart = 0;*/ + this_track->endsize = 0; + break; + case TRACK_FORMAT_CDI: + this_track->datasize=CDIO_CD_FRAMESIZE; + break; + case TRACK_FORMAT_XA: + if (track_green) { + this_track->blocksize = CDIO_CD_FRAMESIZE; + /*this_track->datastart = CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE;*/ + this_track->datasize = M2RAW_SECTOR_SIZE; + this_track->endsize = 0; + } else { + /*this_track->datastart = CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE + + CDIO_CD_SUBHEADER_SIZE;*/ + this_track->datasize = CDIO_CD_FRAMESIZE; + this_track->endsize = CDIO_CD_SYNC_SIZE + CDIO_CD_ECC_SIZE; + } + break; + case TRACK_FORMAT_DATA: + if (track_green) { + /*this_track->datastart = CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE;*/ + this_track->datasize = CDIO_CD_FRAMESIZE; + this_track->endsize = CDIO_CD_EDC_SIZE + CDIO_CD_M1F1_ZERO_SIZE + + CDIO_CD_ECC_SIZE; + } else { + /* Is the below correct? */ + /*this_track->datastart = 0;*/ + this_track->datasize = CDIO_CD_FRAMESIZE; + this_track->endsize = 0; + } + break; + default: + /*this_track->datasize=CDIO_CD_FRAMESIZE_RAW;*/ + cdio_warn ("track %d has unknown format %d", + _obj->total_tracks, this_track->track_format); + } + _obj->total_tracks++; - /* FIXME: These are probably not right. Probably we need to look at - "type." But this hasn't been reverse engineered yet. - */ - this_track->track_format= TRACK_FORMAT_XA; - this_track->track_green = true; - - /* cdio_debug ("map: %d +%d -> %ld", start_lsn, sec_count, img_offset); */ + cdio_debug ("start lsn: %lu sector count: %0lu -> %8ld (%08lx)", + (long unsigned int) start_lsn, + (long unsigned int) sec_count, + (long unsigned int) img_offset, + (long unsigned int) img_offset); } @@ -215,8 +284,7 @@ _cdio_parse_nero_footer (_img_private_t *_obj) long unsigned int size; char *footer_buf = NULL; - if (_obj->size) - return 0; + if (_obj->size) return true; size = cdio_stream_stat (_obj->gen.data_source); if (-1 == size) return false; @@ -254,7 +322,7 @@ PRAGMA_END_PACKED else { cdio_warn ("Image not recognized as either v50 or v55 type NRG"); - return -1; + return false; } cdio_debug ("nrg footer start = %ld, length = %ld", @@ -273,115 +341,152 @@ PRAGMA_END_PACKED while (pos < size - footer_start) { _chunk_t *chunk = (void *) (footer_buf + pos); + uint32_t opcode = UINT32_FROM_BE (chunk->id); bool break_out = false; - switch (UINT32_FROM_BE (chunk->id)) { - case CUES_ID: { /* "CUES" Seems to have sector size 2336 and 150 sector - pregap seems to be included at beginning of image. - */ - + switch (opcode) { - unsigned entries = UINT32_FROM_BE (chunk->len); - _cuex_array_t *_entries = (void *) chunk->data; - - cdio_assert (_obj->mapping == NULL); - - cdio_assert (sizeof (_cuex_array_t) == 8); - cdio_assert ( UINT32_FROM_BE(chunk->len) % sizeof(_cuex_array_t) - == 0 ); - - entries /= sizeof (_cuex_array_t); - - cdio_info ("CUES type image detected"); - + case CUES_ID: /* "CUES" Seems to have sector size 2336 and 150 sector + pregap seems to be included at beginning of image. + */ + case CUEX_ID: /* "CUEX" */ { - lsn_t lsn = UINT32_FROM_BE (_entries[0].lsn); - int idx; + unsigned entries = UINT32_FROM_BE (chunk->len); + _cuex_array_t *_entries = (void *) chunk->data; - /*cdio_assert (lsn == 0?);*/ - - _obj->is_cues = true; /* HACK alert. */ - _obj->sector_2336 = true; - _obj->total_tracks = 0; - _obj->first_track_num = 1; - for (idx = 1; idx < entries-1; idx += 2) { - lsn_t sec_count; - - cdio_assert (_entries[idx].index == 0); - cdio_assert (_entries[idx].track == _entries[idx + 1].track); - - /* lsn and sec_count*2 aren't correct, but it comes closer on the - single example I have: svcdgs.nrg - We are picking up the wrong fields and/or not interpreting - them correctly. - */ - - lsn = UINT32_FROM_BE (_entries[idx].lsn); - sec_count = UINT32_FROM_BE (_entries[idx + 1].lsn); - - _register_mapping (_obj, lsn, sec_count*2, - (lsn+CDIO_PREGAP_SECTORS) * M2RAW_SECTOR_SIZE, - M2RAW_SECTOR_SIZE); - } - } - break; - } - - case CUEX_ID: /* "CUEX" */ { - unsigned entries = UINT32_FROM_BE (chunk->len); - _cuex_array_t *_entries = (void *) chunk->data; - - cdio_assert (_obj->mapping == NULL); - - cdio_assert ( sizeof (_cuex_array_t) == 8 ); - cdio_assert ( UINT32_FROM_BE (chunk->len) % sizeof(_cuex_array_t) - == 0 ); - - entries /= sizeof (_cuex_array_t); - - cdio_info ("DAO type image detected"); - - { - uint32_t lsn = UINT32_FROM_BE (_entries[0].lsn); - int idx; + cdio_assert (_obj->mapping == NULL); - cdio_assert (lsn == 0xffffff6a); + cdio_assert ( sizeof (_cuex_array_t) == 8 ); + cdio_assert ( UINT32_FROM_BE (chunk->len) % sizeof(_cuex_array_t) + == 0 ); - for (idx = 2; idx < entries; idx += 2) { - lsn_t lsn2; - - cdio_assert (_entries[idx].index == 1); - cdio_assert (_entries[idx].track != _entries[idx + 1].track); + entries /= sizeof (_cuex_array_t); + + if (CUES_ID == opcode) { + lsn_t lsn = UINT32_FROM_BE (_entries[0].lsn); + int idx; + + cdio_info ("CUES type image detected" ); + /*cdio_assert (lsn == 0?);*/ - lsn = UINT32_FROM_BE (_entries[idx].lsn); - lsn2 = UINT32_FROM_BE (_entries[idx + 1].lsn); + _obj->is_cues = true; /* HACK alert. */ + _obj->total_tracks = 0; + _obj->first_track_num = 1; + for (idx = 1; idx < entries-1; idx += 2) { + lsn_t sec_count; + + cdio_assert (_entries[idx].index == 0); + cdio_assert (_entries[idx].track == _entries[idx + 1].track); + + /* lsn and sec_count*2 aren't correct, but it comes closer on the + single example I have: svcdgs.nrg + We are picking up the wrong fields and/or not interpreting + them correctly. + */ + + lsn = UINT32_FROM_BE (_entries[idx].lsn); + sec_count = UINT32_FROM_BE (_entries[idx + 1].lsn); + + _register_mapping (_obj, lsn, sec_count*2, + (lsn+CDIO_PREGAP_SECTORS) * M2RAW_SECTOR_SIZE, + M2RAW_SECTOR_SIZE, TRACK_FORMAT_XA, true); + } + } else { + lsn_t lsn = UINT32_FROM_BE (_entries[0].lsn); + int idx; - _register_mapping (_obj, lsn, lsn2 - lsn, - (lsn + CDIO_PREGAP_SECTORS)*M2RAW_SECTOR_SIZE, - M2RAW_SECTOR_SIZE); + cdio_info ("CUEX type image detected"); + cdio_assert (lsn == 0xffffff6a); + + for (idx = 2; idx < entries; idx += 2) { + lsn_t sec_count; + + cdio_assert (_entries[idx].index == 1); + cdio_assert (_entries[idx].track != _entries[idx + 1].track); + + lsn = UINT32_FROM_BE (_entries[idx].lsn); + sec_count = UINT32_FROM_BE (_entries[idx + 1].lsn); + + _register_mapping (_obj, lsn, sec_count - lsn, + (lsn + CDIO_PREGAP_SECTORS)*M2RAW_SECTOR_SIZE, + M2RAW_SECTOR_SIZE, TRACK_FORMAT_XA, true); + } } - } - break; - } + break; + } case DAOI_ID: /* "DAOI" */ - cdio_debug ("DAOI tag detected..."); - break; - case DAOX_ID: /* "DAOX" */ - cdio_debug ("DAOX tag detected..."); - break; - + case DAOX_ID: /* "DAOX" */ + { + _daox_array_t *_entries = (void *) chunk->data; + track_format_t track_format; + int form = _entries->_unknown[18]; + _obj->dtyp = _entries->_unknown[36]; + _obj->is_dao = true; + cdio_debug ("DAO%c tag detected, track format %d, form %x\n", + opcode==DAOX_ID ? 'X': 'I', _obj->dtyp, form); + switch (_obj->dtyp) { + case 0: + track_format = TRACK_FORMAT_DATA; + break; + case 0x6: + case 0x20: + track_format = TRACK_FORMAT_XA; + break; + case 0x7: + track_format = TRACK_FORMAT_AUDIO; + break; + default: + cdio_warn ("Unknown track format %x\n", + _obj->dtyp); + track_format = TRACK_FORMAT_AUDIO; + } + if (0 == form) { + int i; + for (i=0; i<_obj->total_tracks; i++) { + _obj->tocent[i].track_format= track_format; + _obj->tocent[i].datastart = 0; + _obj->tocent[i].track_green = false; + if (TRACK_FORMAT_AUDIO == track_format) { + _obj->tocent[i].blocksize = CDIO_CD_FRAMESIZE_RAW; + _obj->tocent[i].datasize = CDIO_CD_FRAMESIZE_RAW; + _obj->tocent[i].endsize = 0; + } else { + _obj->tocent[i].datasize = CDIO_CD_FRAMESIZE; + _obj->tocent[i].datastart = 0; + } + } + } else if (2 == form) { + int i; + for (i=0; i<_obj->total_tracks; i++) { + _obj->tocent[i].track_green = true; + _obj->tocent[i].track_format= track_format; + _obj->tocent[i].datasize = CDIO_CD_FRAMESIZE; + if (TRACK_FORMAT_XA == track_format) { + _obj->tocent[i].datastart = CDIO_CD_SYNC_SIZE + + CDIO_CD_HEADER_SIZE + CDIO_CD_SUBHEADER_SIZE; + _obj->tocent[i].endsize = CDIO_CD_SYNC_SIZE + + CDIO_CD_ECC_SIZE; + } else { + _obj->tocent[i].datastart = CDIO_CD_SYNC_SIZE + + CDIO_CD_HEADER_SIZE; + _obj->tocent[i].endsize = CDIO_CD_EDC_SIZE + + CDIO_CD_M1F1_ZERO_SIZE + CDIO_CD_ECC_SIZE; + + } + } + } + break; + } + case NERO_ID: /* "NER0" */ case NER5_ID: /* "NER5" */ - cdio_error ("unexpected nrg magic ID NER5 detected"); - return -1; + cdio_error ("unexpected nrg magic ID NER%c detected", + opcode==NERO_ID ? 'O': '5'); + free(footer_buf); + return false; break; - case NERO_ID: /* "NER0" */ - cdio_error ("unexpected nrg magic ID NER0 detected"); - return -1; - break; - case END1_ID: /* "END!" */ cdio_debug ("nrg end tag detected"); break_out = true; @@ -401,24 +506,54 @@ PRAGMA_END_PACKED cdio_info ("SAO type image (ETNF) detected"); - _obj->sector_2336 = true; - { int idx; for (idx = 0; idx < entries; idx++) { uint32_t _len = UINT32_FROM_BE (_entries[idx].length); uint32_t _start = UINT32_FROM_BE (_entries[idx].start_lsn); uint32_t _start2 = UINT32_FROM_BE (_entries[idx].start); + uint32_t track_mode= uint32_from_be (_entries[idx].type); + bool track_green = true; + track_format_t track_format = TRACK_FORMAT_XA; + uint16_t blocksize; + + switch (track_mode) { + case 0: + track_format = TRACK_FORMAT_DATA; + track_green = false; /* ?? */ + blocksize = CDIO_CD_FRAMESIZE; + break; + case 2: + track_format = TRACK_FORMAT_XA; + track_green = false; /* ?? */ + blocksize = CDIO_CD_FRAMESIZE; + break; + case 3: + track_format = TRACK_FORMAT_XA; + track_green = true; + blocksize = M2RAW_SECTOR_SIZE; + break; + case 7: + track_format = TRACK_FORMAT_AUDIO; + track_green = false; + blocksize = CDIO_CD_FRAMESIZE_RAW; + break; + default: + cdio_warn ("Don't know how to handle track mode (%lu)?", + (long unsigned int) track_mode); + free(footer_buf); + return false; + } - cdio_assert (UINT32_FROM_BE (_entries[idx].type) == 3); - cdio_assert (_len % M2RAW_SECTOR_SIZE == 0); + cdio_assert (_len % blocksize == 0); - _len /= M2RAW_SECTOR_SIZE; + _len /= blocksize; - cdio_assert (_start * M2RAW_SECTOR_SIZE == _start2); + cdio_assert (_start * blocksize == _start2); _start += idx * CDIO_PREGAP_SECTORS; - _register_mapping (_obj, _start, _len, _start2, M2RAW_SECTOR_SIZE); + _register_mapping (_obj, _start, _len, _start2, blocksize, + track_format, track_green); } } @@ -438,24 +573,84 @@ PRAGMA_END_PACKED cdio_info ("SAO type image (ETN2) detected"); - _obj->sector_2336 = true; - { int idx; for (idx = 0; idx < entries; idx++) { uint32_t _len = uint64_from_be (_entries[idx].length); uint32_t _start = uint32_from_be (_entries[idx].start_lsn); uint32_t _start2 = uint64_from_be (_entries[idx].start); + uint32_t track_mode= uint32_from_be (_entries[idx].type); + bool track_green = true; + track_format_t track_format = TRACK_FORMAT_XA; + uint16_t blocksize; + + + switch (track_mode) { + case 0: + track_format = TRACK_FORMAT_DATA; + track_green = false; /* ?? */ + blocksize = CDIO_CD_FRAMESIZE; + break; + case 2: + track_format = TRACK_FORMAT_XA; + track_green = false; /* ?? */ + blocksize = CDIO_CD_FRAMESIZE; + break; + case 3: + track_format = TRACK_FORMAT_XA; + track_green = true; + blocksize = M2RAW_SECTOR_SIZE; + break; + case 7: + track_format = TRACK_FORMAT_AUDIO; + track_green = false; + blocksize = CDIO_CD_FRAMESIZE_RAW; + break; + default: + cdio_warn ("Don't know how to handle track mode (%lu)?", + (long unsigned int) track_mode); + free(footer_buf); + return false; + } - cdio_assert (uint32_from_be (_entries[idx].type) == 3); - cdio_assert (_len % M2RAW_SECTOR_SIZE == 0); + if (_len % blocksize != 0) { + cdio_warn ("length is not a multiple of blocksize " + "len %lu, size %d, rem %lu", + (long unsigned int) _len, blocksize, + (long unsigned int) _len % blocksize); + if (0 == _len % CDIO_CD_FRAMESIZE) { + cdio_warn("Adjusting blocksize to %d", CDIO_CD_FRAMESIZE); + blocksize = CDIO_CD_FRAMESIZE; + } else if (0 == _len % M2RAW_SECTOR_SIZE) { + cdio_warn("Adjusting blocksize to %d", M2RAW_SECTOR_SIZE); + blocksize = M2RAW_SECTOR_SIZE; + } else if (0 == _len % CDIO_CD_FRAMESIZE_RAW) { + cdio_warn("Adjusting blocksize to %d", CDIO_CD_FRAMESIZE_RAW); + blocksize = CDIO_CD_FRAMESIZE_RAW; + } + } - _len /= M2RAW_SECTOR_SIZE; + _len /= blocksize; - cdio_assert (_start * M2RAW_SECTOR_SIZE == _start2); + if (_start * blocksize != _start2) { + cdio_warn ("%lu * %d != %lu", + (long unsigned int) _start, blocksize, + (long unsigned int) _start2); + if (_start * CDIO_CD_FRAMESIZE == _start2) { + cdio_warn("Adjusting blocksize to %d", CDIO_CD_FRAMESIZE); + blocksize = CDIO_CD_FRAMESIZE; + } else if (_start * M2RAW_SECTOR_SIZE == _start2) { + cdio_warn("Adjusting blocksize to %d", M2RAW_SECTOR_SIZE); + blocksize = M2RAW_SECTOR_SIZE; + } else if (0 == _start * CDIO_CD_FRAMESIZE_RAW == _start2) { + cdio_warn("Adjusting blocksize to %d", CDIO_CD_FRAMESIZE_RAW); + blocksize = CDIO_CD_FRAMESIZE_RAW; + } + } _start += idx * CDIO_PREGAP_SECTORS; - _register_mapping (_obj, _start, _len, _start2, M2RAW_SECTOR_SIZE); + _register_mapping (_obj, _start, _len, _start2, blocksize, + track_format, track_green); } } break; @@ -472,6 +667,22 @@ PRAGMA_END_PACKED } break; + case MTYP_ID: { /* "MTYP" */ + uint32_t *mtyp_p = (void *) chunk->data; + uint32_t mtyp = UINT32_FROM_BE (*mtyp_p); + + cdio_assert (UINT32_FROM_BE (chunk->len) == 4); + + cdio_debug ("MTYP: %lu", + (long unsigned int) UINT32_FROM_BE (*mtyp_p)); + + if (mtyp != MTYP_AUDIO_CD) { + cdio_warn ("Unknown MTYP value: %u", (unsigned int) mtyp); + } + _obj->mtyp = mtyp; + } + break; + default: cdio_warn ("unknown tag %8.8x seen", (unsigned int) UINT32_FROM_BE (chunk->id)); @@ -495,7 +706,8 @@ PRAGMA_END_PACKED _obj->tocent[_obj->total_tracks-1].sec_count = cdio_lsn_to_lba(_obj->size - _obj->tocent[_obj->total_tracks-1].start_lba); - return 0; + free(footer_buf); + return true; } /*! @@ -510,7 +722,7 @@ _cdio_init (_img_private_t *_obj) } if (!(_obj->gen.data_source = cdio_stdio_new (_obj->gen.source_name))) { - cdio_error ("init failed"); + cdio_warn ("init failed"); return false; } @@ -532,42 +744,27 @@ _cdio_lseek (void *env, off_t offset, int whence) _img_private_t *_obj = env; /* real_offset is the real byte offset inside the disk image - The number below was determined empirically. I'm guessing - the 1st 24 bytes of a bin file are used for something. + The number below was determined empirically. */ - off_t real_offset=0; + off_t real_offset= _obj->is_dao ? 0x4b000 : 0; unsigned int i; - unsigned int user_datasize; for (i=0; i<_obj->total_tracks; i++) { track_info_t *this_track=&(_obj->tocent[i]); - switch (this_track->track_format) { - case TRACK_FORMAT_AUDIO: - user_datasize=CDIO_CD_FRAMESIZE_RAW; - break; - case TRACK_FORMAT_CDI: - user_datasize=CDIO_CD_FRAMESIZE; - break; - case TRACK_FORMAT_XA: - user_datasize=CDIO_CD_FRAMESIZE; - break; - default: - user_datasize=CDIO_CD_FRAMESIZE_RAW; - cdio_warn ("track %d has unknown format %d", - i+1, this_track->track_format); - } - - if ( (this_track->sec_count*user_datasize) >= offset) { - int blocks = offset / user_datasize; - int rem = offset % user_datasize; - int block_offset = blocks * (M2RAW_SECTOR_SIZE); - real_offset += block_offset + rem; + _obj->pos.index = i; + if ( (this_track->sec_count*this_track->datasize) >= offset) { + int blocks = offset / this_track->datasize; + int rem = offset % this_track->datasize; + int block_offset = blocks * this_track->blocksize; + real_offset += block_offset + rem; + _obj->pos.buff_offset = rem; + _obj->pos.lba += blocks; break; } - real_offset += this_track->sec_count*(M2RAW_SECTOR_SIZE); - - offset -= this_track->sec_count*user_datasize; + real_offset += this_track->sec_count*this_track->blocksize; + offset -= this_track->sec_count*this_track->datasize; + _obj->pos.lba += this_track->sec_count; } if (i==_obj->total_tracks) { @@ -645,13 +842,83 @@ _cdio_read_audio_sectors (void *env, void *data, lsn_t lsn, } static int +_cdio_read_mode1_sector (void *env, void *data, lsn_t lsn, + bool b_form2) +{ + _img_private_t *_obj = env; + char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, }; + + CdioListNode *node; + + if (lsn >= _obj->size) + { + cdio_warn ("trying to read beyond image size (%lu >= %lu)", + (long unsigned int) lsn, (long unsigned int) _obj->size); + return -1; + } + + _CDIO_LIST_FOREACH (node, _obj->mapping) { + _mapping_t *_map = _cdio_list_node_data (node); + + if (IN (lsn, _map->start_lsn, (_map->start_lsn + _map->sec_count - 1))) { + int ret; + long int img_offset = _map->img_offset; + + img_offset += (lsn - _map->start_lsn) * _map->blocksize; + + ret = cdio_stream_seek (_obj->gen.data_source, img_offset, + SEEK_SET); + if (ret!=0) return ret; + + /* FIXME: Not completely sure the below is correct. */ + ret = cdio_stream_read (_obj->gen.data_source, + (M2RAW_SECTOR_SIZE == _map->blocksize) + ? (buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE) + : buf, + _map->blocksize, 1); + if (ret==0) return ret; + break; + } + } + + if (!node) + cdio_warn ("reading into pre gap (lsn %lu)", (long unsigned int) lsn); + + memcpy (data, buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE, + b_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE); + + return 0; +} + +/*! + Reads nblocks of mode2 sectors from cd device into data starting + from lsn. + Returns 0 if no error. + */ +static int +_cdio_read_mode1_sectors (void *env, void *data, uint32_t lsn, + bool b_form2, unsigned nblocks) +{ + _img_private_t *_obj = env; + int i; + int retval; + unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE; + + for (i = 0; i < nblocks; i++) { + if ( (retval = _cdio_read_mode1_sector (_obj, + ((char *)data) + (blocksize * i), + lsn + i, b_form2)) ) + return retval; + } + return 0; +} + +static int _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, - bool mode2_form2) + bool b_form2) { _img_private_t *_obj = env; char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, }; - int blocksize = _obj->sector_2336 - ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE_RAW; CdioListNode *node; @@ -669,15 +936,16 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, int ret; long int img_offset = _map->img_offset; - img_offset += (lsn - _map->start_lsn) * blocksize; + img_offset += (lsn - _map->start_lsn) * _map->blocksize; ret = cdio_stream_seek (_obj->gen.data_source, img_offset, SEEK_SET); if (ret!=0) return ret; - ret = cdio_stream_read (_obj->gen.data_source, _obj->sector_2336 + ret = cdio_stream_read (_obj->gen.data_source, + (M2RAW_SECTOR_SIZE == _map->blocksize) ? (buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE) : buf, - blocksize, 1); + _map->blocksize, 1); if (ret==0) return ret; break; } @@ -686,7 +954,7 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, if (!node) cdio_warn ("reading into pre gap (lsn %lu)", (long unsigned int) lsn); - if (mode2_form2) + if (b_form2) memcpy (data, buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE, M2RAW_SECTOR_SIZE); else @@ -702,31 +970,38 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn, */ static int _cdio_read_mode2_sectors (void *env, void *data, uint32_t lsn, - bool mode2_form2, unsigned nblocks) + bool b_form2, unsigned nblocks) { _img_private_t *_obj = env; int i; int retval; + unsigned int blocksize = b_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE; for (i = 0; i < nblocks; i++) { - if (mode2_form2) { - if ( (retval = _cdio_read_mode2_sector (_obj, - ((char *)data) + (M2RAW_SECTOR_SIZE * i), - lsn + i, true)) ) - return retval; - } else { - char buf[M2RAW_SECTOR_SIZE] = { 0, }; - if ( (retval = _cdio_read_mode2_sector (_obj, buf, lsn + i, true)) ) - return retval; - - memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i), - buf + CDIO_CD_SUBHEADER_SIZE, CDIO_CD_FRAMESIZE); - } + if ( (retval = _cdio_read_mode2_sector (_obj, + ((char *)data) + (blocksize * i), + lsn + i, b_form2)) ) + return retval; } return 0; } -/*! +/* + Free memory resources associated with NRG object. +*/ +static void +_cdio_nrg_destroy (void *obj) +{ + _img_private_t *env = obj; + + if (NULL == env) return; + if (NULL != env->mapping) + _cdio_list_free (env->mapping, true); + cdio_generic_stdio_free(env); + free(env); +} + +/* Set the device to use in I/O operations. */ static int @@ -835,6 +1110,17 @@ _cdio_get_track_format(void *env, track_t track_num) if (track_num > _obj->total_tracks || track_num == 0) return TRACK_FORMAT_ERROR; + if ( _obj->dtyp != DTYP_INVALID) { + switch (_obj->dtyp) { + case DTYP_MODE2_XA: + return TRACK_FORMAT_XA; + case DTYP_MODE1: + return TRACK_FORMAT_DATA; + default: ; + } + } + + /*if ( MTYP_AUDIO_CD == _obj->mtyp) return TRACK_FORMAT_AUDIO; */ return _obj->tocent[track_num-1].track_format; } @@ -854,6 +1140,7 @@ _cdio_get_track_green(void *env, track_t track_num) if (track_num > _obj->total_tracks || track_num == 0) return false; + if ( MTYP_AUDIO_CD == _obj->mtyp) return false; return _obj->tocent[track_num-1].track_green; } @@ -887,7 +1174,7 @@ cdio_open_nrg (const char *source_name) cdio_funcs _funcs = { .eject_media = cdio_generic_bogus_eject_media, - .free = cdio_generic_stream_free, + .free = _cdio_nrg_destroy, .get_arg = _cdio_get_arg, .get_devices = cdio_get_devices_nrg, .get_default_device = cdio_get_default_device_nrg, @@ -900,6 +1187,8 @@ cdio_open_nrg (const char *source_name) .lseek = _cdio_lseek, .read = _cdio_read, .read_audio_sectors = _cdio_read_audio_sectors, + .read_mode1_sector = _cdio_read_mode1_sector, + .read_mode1_sectors = _cdio_read_mode1_sectors, .read_mode2_sector = _cdio_read_mode2_sector, .read_mode2_sectors = _cdio_read_mode2_sectors, .set_arg = _cdio_set_arg, @@ -909,10 +1198,11 @@ cdio_open_nrg (const char *source_name) _data = _cdio_malloc (sizeof (_img_private_t)); _data->gen.init = false; - _data->total_tracks = 0; + _data->mtyp = 0; + _data->dtyp = DTYP_INVALID; _data->first_track_num= 1; - _data->sector_2336 = false; /* FIXME: remove sector_2336 */ + _data->is_dao = false; _data->is_cues = false; /* FIXME: remove is_cues. */ @@ -925,7 +1215,8 @@ cdio_open_nrg (const char *source_name) if (_cdio_init(_data)) return ret; else { - cdio_generic_stream_free (_data); + cdio_generic_stdio_free (_data); + free(_data); return NULL; } diff --git a/src/input/vcd/libcdio/iso9660.c b/src/input/vcd/libcdio/iso9660.c index c7d6f8a54..c9c9ccb5e 100644 --- a/src/input/vcd/libcdio/iso9660.c +++ b/src/input/vcd/libcdio/iso9660.c @@ -1,5 +1,5 @@ /* - $Id: iso9660.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: iso9660.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> @@ -37,7 +37,7 @@ #include <stdio.h> #endif -static const char _rcsid[] = "$Id: iso9660.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: iso9660.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; /* some parameters... */ #define SYSTEM_ID "CD-RTOS CD-BRIDGE" diff --git a/src/input/vcd/libcdio/iso9660_fs.c b/src/input/vcd/libcdio/iso9660_fs.c index b54cf2c0f..5841b7d87 100644 --- a/src/input/vcd/libcdio/iso9660_fs.c +++ b/src/input/vcd/libcdio/iso9660_fs.c @@ -1,8 +1,8 @@ /* - $Id: iso9660_fs.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: iso9660_fs.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> - Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> + 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 @@ -35,88 +35,173 @@ #include "cdio_assert.h" #include "bytesex.h" #include "ds.h" +#include "_cdio_stdio.h" +#include "cdio_private.h" #include <stdio.h> -static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; -static void -_idr2statbuf (const iso9660_dir_t *idr, iso9660_stat_t *stat, bool is_mode2) +/* Implementation of iso9660_t type */ +struct _iso9660 { + CdioDataSource *stream; /* Stream pointer */ + void *env; /* environment. */ +}; + +/*! + Open an ISO 9660 image for reading. Maybe in the future we will have + flags and mode. NULL is returned on error. +*/ +iso9660_t * +iso9660_open (const char *pathname /*flags, mode */) +{ + iso9660_t *iso = (iso9660_t *) _cdio_malloc(sizeof(struct _iso9660)) ; + + if (NULL == iso) return NULL; + + iso->stream = cdio_stdio_new( pathname ); + if (NULL == iso->stream) { + free(iso); + return NULL; + } + + return iso; +} + + + +/*! + Close previously opened ISO 9660 image. + True is unconditionally returned. If there was an error false would + be returned. +*/ +bool +iso9660_close (iso9660_t *iso) +{ + if (NULL != iso) { + cdio_stdio_destroy(iso->stream); + free(iso); + } + return true; +} + + + +/*! + Seek to a position and then read n blocks. Size read is returned. +*/ +long int +iso9660_iso_seek_read (iso9660_t *iso, void *ptr, lsn_t start, long int size) +{ + long int ret; + if (NULL == iso) return 0; + ret = cdio_stream_seek (iso->stream, start * ISO_BLOCKSIZE, SEEK_SET); + if (ret!=0) return 0; + return cdio_stream_read (iso->stream, ptr, ISO_BLOCKSIZE, size); +} + + +static iso9660_stat_t * +_iso9660_dir_to_statbuf (const iso9660_dir_t *iso9660_dir, bool is_mode2) { iso9660_xa_t *xa_data = NULL; - uint8_t dir_len= iso9660_get_dir_len(idr); + uint8_t dir_len= iso9660_get_dir_len(iso9660_dir); + unsigned int filename_len; + unsigned int stat_len; + iso9660_stat_t *stat; + + if (!dir_len) return NULL; - memset ((void *) stat, 0, sizeof (iso9660_stat_t)); + filename_len = from_711(iso9660_dir->filename_len); - if (!dir_len) return; + /* .. string in statbuf is one longer than in iso9660_dir's listing '\1' */ + stat_len = sizeof(iso9660_stat_t)+filename_len+2; - stat->type = (idr->file_flags & ISO_DIRECTORY) ? _STAT_DIR : _STAT_FILE; - stat->lsn = from_733 (idr->extent); - stat->size = from_733 (idr->size); + stat = _cdio_malloc(stat_len); + stat->type = (iso9660_dir->file_flags & ISO_DIRECTORY) + ? _STAT_DIR : _STAT_FILE; + stat->lsn = from_733 (iso9660_dir->extent); + stat->size = from_733 (iso9660_dir->size); stat->secsize = _cdio_len2blocks (stat->size, ISO_BLOCKSIZE); - iso9660_get_dtime(&(idr->recording_time), true, &(stat->tm)); + if (iso9660_dir->filename[0] == '\0') + strcpy (stat->filename, "."); + else if (iso9660_dir->filename[0] == '\1') + strcpy (stat->filename, ".."); + else + strncpy (stat->filename, iso9660_dir->filename, filename_len); + + iso9660_get_dtime(&(iso9660_dir->recording_time), true, &(stat->tm)); cdio_assert (dir_len >= sizeof (iso9660_dir_t)); if (is_mode2) { - int su_length = iso9660_get_dir_len(idr) - sizeof (iso9660_dir_t); - su_length -= idr->filename_len; + int su_length = iso9660_get_dir_len(iso9660_dir) - sizeof (iso9660_dir_t); + su_length -= filename_len; if (su_length % 2) su_length--; if (su_length < 0 || su_length < sizeof (iso9660_xa_t)) - return; + return stat; - xa_data = (void *) (((char *) idr) + (iso9660_get_dir_len(idr) - su_length)); + xa_data = (void *) (((char *) iso9660_dir) + + (iso9660_get_dir_len(iso9660_dir) - su_length)); if (xa_data->signature[0] != 'X' || xa_data->signature[1] != 'A') { cdio_warn ("XA signature not found in ISO9660's system use area;" " ignoring XA attributes for this file entry."); - cdio_debug ("%d %d %d, '%c%c' (%d, %d)", iso9660_get_dir_len(idr), - idr->filename_len, + cdio_debug ("%d %d %d, '%c%c' (%d, %d)", + iso9660_get_dir_len(iso9660_dir), + filename_len, su_length, xa_data->signature[0], xa_data->signature[1], xa_data->signature[0], xa_data->signature[1]); - return; + return stat; } stat->xa = *xa_data; } + return stat; } -static char * -_idr2name (const iso9660_dir_t *idr) +/*! + 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 *iso9660_dir) { char namebuf[256] = { 0, }; - uint8_t len=iso9660_get_dir_len(idr); + uint8_t len=iso9660_get_dir_len(iso9660_dir); if (!len) return NULL; cdio_assert (len >= sizeof (iso9660_dir_t)); - /* (idr->file_flags & ISO_DIRECTORY) */ + /* (iso9660_dir->file_flags & ISO_DIRECTORY) */ - if (idr->filename[0] == '\0') + if (iso9660_dir->filename[0] == '\0') strcpy (namebuf, "."); - else if (idr->filename[0] == '\1') + else if (iso9660_dir->filename[0] == '\1') strcpy (namebuf, ".."); else - strncpy (namebuf, idr->filename, idr->filename_len); + strncpy (namebuf, iso9660_dir->filename, iso9660_dir->filename_len); return strdup (namebuf); } -static void -_fs_stat_root (const CdIo *cdio, iso9660_stat_t *stat, bool is_mode2) +static iso9660_stat_t * +_fs_stat_root (const CdIo *cdio, bool is_mode2) { char block[ISO_BLOCKSIZE] = { 0, }; const iso9660_pvd_t *pvd = (void *) █ - const iso9660_dir_t *idr = (void *) pvd->root_directory_record; + const iso9660_dir_t *iso9660_dir = (void *) pvd->root_directory_record; + iso9660_stat_t *stat; if (is_mode2) { if (cdio_read_mode2_sector (cdio, &block, ISO_PVD_SECTOR, false)) @@ -126,25 +211,44 @@ _fs_stat_root (const CdIo *cdio, iso9660_stat_t *stat, bool is_mode2) cdio_assert_not_reached (); } - _idr2statbuf (idr, stat, is_mode2); + stat = _iso9660_dir_to_statbuf (iso9660_dir, is_mode2); + return stat; +} + +static iso9660_stat_t * +_fs_stat_iso_root (iso9660_t *iso) +{ + char block[ISO_BLOCKSIZE] = { 0, }; + const iso9660_pvd_t *pvd = (void *) █ + const iso9660_dir_t *iso9660_dir = (void *) pvd->root_directory_record; + iso9660_stat_t *stat; + int ret; + + ret = iso9660_iso_seek_read (iso, block, ISO_PVD_SECTOR, 1); + if (ret!=ISO_BLOCKSIZE) return NULL; + + stat = _iso9660_dir_to_statbuf (iso9660_dir, true); + return stat; } -static int +static iso9660_stat_t * _fs_stat_traverse (const CdIo *cdio, const iso9660_stat_t *_root, - char **splitpath, /*out*/ iso9660_stat_t *buf, - bool is_mode2) + char **splitpath, bool is_mode2, bool translate) { unsigned offset = 0; uint8_t *_dirbuf = NULL; + iso9660_stat_t *stat; if (!splitpath[0]) { - *buf = *_root; - return 0; + unsigned int len=sizeof(iso9660_stat_t) + strlen(_root->filename)+1; + stat = _cdio_malloc(len); + memcpy(stat, _root, len); + return stat; } if (_root->type == _STAT_FILE) - return -1; + return NULL; cdio_assert (_root->type == _STAT_DIR); @@ -160,137 +264,386 @@ _fs_stat_traverse (const CdIo *cdio, const iso9660_stat_t *_root, if (is_mode2) { if (cdio_read_mode2_sectors (cdio, _dirbuf, _root->lsn, false, _root->secsize)) - cdio_assert_not_reached (); + return NULL; } else { if (cdio_read_mode1_sectors (cdio, _dirbuf, _root->lsn, false, _root->secsize)) - cdio_assert_not_reached (); + return NULL; } while (offset < (_root->secsize * ISO_BLOCKSIZE)) { - const iso9660_dir_t *idr = (void *) &_dirbuf[offset]; - iso9660_stat_t stat; - char *name; + const iso9660_dir_t *iso9660_dir = (void *) &_dirbuf[offset]; + iso9660_stat_t *stat; + int cmp; - if (!iso9660_get_dir_len(idr)) + if (!iso9660_get_dir_len(iso9660_dir)) { offset++; continue; } - name = _idr2name (idr); - _idr2statbuf (idr, &stat, is_mode2); + stat = _iso9660_dir_to_statbuf (iso9660_dir, is_mode2); + + if (translate) { + char *trans_fname = malloc(strlen(stat->filename)); + int trans_len; + + if (trans_fname == NULL) { + cdio_warn("can't allocate %lu bytes", + (long unsigned int) strlen(stat->filename)); + return NULL; + } + trans_len = iso9660_name_translate(stat->filename, trans_fname); + cmp = strcmp(splitpath[0], trans_fname); + free(trans_fname); + } else { + cmp = strcmp(splitpath[0], stat->filename); + } + + if (!cmp) { + iso9660_stat_t *ret_stat + = _fs_stat_traverse (cdio, stat, &splitpath[1], is_mode2, + translate); + free(stat); + free (_dirbuf); + return ret_stat; + } + + free(stat); + + offset += iso9660_get_dir_len(iso9660_dir); + } + + cdio_assert (offset == (_root->secsize * ISO_BLOCKSIZE)); + + /* not found */ + free (_dirbuf); + return NULL; +} + +static iso9660_stat_t * +_fs_iso_stat_traverse (iso9660_t *iso, const iso9660_stat_t *_root, + char **splitpath, bool translate) +{ + unsigned offset = 0; + uint8_t *_dirbuf = NULL; + iso9660_stat_t *stat; + int ret; + + if (!splitpath[0]) + { + unsigned int len=sizeof(iso9660_stat_t) + strlen(_root->filename)+1; + stat = _cdio_malloc(len); + memcpy(stat, _root, len); + return stat; + } + + if (_root->type == _STAT_FILE) + return NULL; + + cdio_assert (_root->type == _STAT_DIR); + + if (_root->size != ISO_BLOCKSIZE * _root->secsize) + { + cdio_warn ("bad size for ISO9660 directory (%ud) should be (%lu)!", + (unsigned) _root->size, + (unsigned long int) ISO_BLOCKSIZE * _root->secsize); + } + + _dirbuf = _cdio_malloc (_root->secsize * ISO_BLOCKSIZE); + + ret = iso9660_iso_seek_read (iso, _dirbuf, _root->lsn, _root->secsize); + if (ret!=ISO_BLOCKSIZE*_root->secsize) return NULL; + + while (offset < (_root->secsize * ISO_BLOCKSIZE)) + { + const iso9660_dir_t *iso9660_dir = (void *) &_dirbuf[offset]; + iso9660_stat_t *stat; + int cmp; - if (!strcmp (splitpath[0], name)) + if (!iso9660_get_dir_len(iso9660_dir)) { - int retval = _fs_stat_traverse (cdio, &stat, &splitpath[1], buf, - is_mode2); - free (name); - free (_dirbuf); - return retval; + offset++; + continue; } + + stat = _iso9660_dir_to_statbuf (iso9660_dir, true); + + if (translate) { + char *trans_fname = malloc(strlen(stat->filename)+1); + int trans_len; + + if (trans_fname == NULL) { + cdio_warn("can't allocate %lu bytes", + (long unsigned int) strlen(stat->filename)); + return NULL; + } + trans_len = iso9660_name_translate(stat->filename, trans_fname); + cmp = strcmp(splitpath[0], trans_fname); + free(trans_fname); + } else { + cmp = strcmp(splitpath[0], stat->filename); + } + + if (!cmp) { + iso9660_stat_t *ret_stat + = _fs_iso_stat_traverse (iso, stat, &splitpath[1], translate); + free(stat); + free (_dirbuf); + return ret_stat; + } - free (name); - - offset += iso9660_get_dir_len(idr); + free(stat); + + offset += iso9660_get_dir_len(iso9660_dir); } cdio_assert (offset == (_root->secsize * ISO_BLOCKSIZE)); /* not found */ free (_dirbuf); - return -1; + return NULL; +} + +/*! + Get file status for pathname into stat. NULL is returned on error. + */ +iso9660_stat_t * +iso9660_fs_stat (const CdIo *cdio, const char pathname[], bool is_mode2) +{ + iso9660_stat_t *root; + char **splitpath; + iso9660_stat_t *stat; + + if (cdio == NULL) return NULL; + if (pathname == NULL) return NULL; + + root = _fs_stat_root (cdio, is_mode2); + if (NULL == root) return NULL; + + splitpath = _cdio_strsplit (pathname, '/'); + stat = _fs_stat_traverse (cdio, root, splitpath, is_mode2, false); + free(root); + _cdio_strfreev (splitpath); + + return stat; +} + +/*! + 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 (const CdIo *cdio, const char pathname[], + bool is_mode2) +{ + iso9660_stat_t *root; + char **splitpath; + iso9660_stat_t *stat; + + if (cdio == NULL) return NULL; + if (pathname == NULL) return NULL; + + root = _fs_stat_root (cdio, is_mode2); + if (NULL == root) return NULL; + + splitpath = _cdio_strsplit (pathname, '/'); + stat = _fs_stat_traverse (cdio, root, splitpath, is_mode2, true); + free(root); + _cdio_strfreev (splitpath); + + return stat; +} + +/*! + Get file status for pathname into stat. NULL is returned on error. + */ +void * +iso9660_ifs_stat (iso9660_t *iso, const char pathname[]) +{ + iso9660_stat_t *root; + char **splitpath; + iso9660_stat_t *stat; + + if (iso == NULL) return NULL; + if (pathname == NULL) return NULL; + + root = _fs_stat_iso_root (iso); + if (NULL == root) return NULL; + + splitpath = _cdio_strsplit (pathname, '/'); + stat = _fs_iso_stat_traverse (iso, root, splitpath, false); + free(root); + _cdio_strfreev (splitpath); + + return stat; } /*! - Get file status for pathname into stat. As with libc's stat, 0 is returned - if no error and -1 on error. + 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. */ -int -iso9660_fs_stat (const CdIo *cdio, const char pathname[], - /*out*/ iso9660_stat_t *stat, bool is_mode2) +void * +iso9660_ifs_stat_translate (iso9660_t *iso, const char pathname[]) { - iso9660_stat_t _root; - int retval; + iso9660_stat_t *root; char **splitpath; + iso9660_stat_t *stat; - cdio_assert (cdio != NULL); - cdio_assert (pathname != NULL); - cdio_assert (stat != NULL); + if (iso == NULL) return NULL; + if (pathname == NULL) return NULL; - _fs_stat_root (cdio, &_root, is_mode2); + root = _fs_stat_iso_root (iso); + if (NULL == root) return NULL; splitpath = _cdio_strsplit (pathname, '/'); - retval = _fs_stat_traverse (cdio, &_root, splitpath, stat, is_mode2); + stat = _fs_iso_stat_traverse (iso, root, splitpath, true); + free(root); _cdio_strfreev (splitpath); - return retval; + return stat; } -void * /* list of char* -- caller must free it */ +/*! + Read pathname (a directory) and return a list of iso9660_stat_t + of the files inside that. The caller must free the returned result. +*/ +void * iso9660_fs_readdir (const CdIo *cdio, const char pathname[], bool is_mode2) { - iso9660_stat_t stat; + iso9660_stat_t *stat; - cdio_assert (cdio != NULL); - cdio_assert (pathname != NULL); + if (NULL == cdio) return NULL; + if (NULL == pathname) return NULL; - if (iso9660_fs_stat (cdio, pathname, &stat, is_mode2)) + stat = iso9660_fs_stat (cdio, pathname, is_mode2); + if (NULL == stat) return NULL; - if (stat.type != _STAT_DIR) + if (stat->type != _STAT_DIR) { + free(stat); return NULL; + } { unsigned offset = 0; uint8_t *_dirbuf = NULL; CdioList *retval = _cdio_list_new (); - if (stat.size != ISO_BLOCKSIZE * stat.secsize) + if (stat->size != ISO_BLOCKSIZE * stat->secsize) { cdio_warn ("bad size for ISO9660 directory (%ud) should be (%lu)!", - (unsigned) stat.size, - (unsigned long int) ISO_BLOCKSIZE * stat.secsize); + (unsigned) stat->size, + (unsigned long int) ISO_BLOCKSIZE * stat->secsize); } - _dirbuf = _cdio_malloc (stat.secsize * ISO_BLOCKSIZE); + _dirbuf = _cdio_malloc (stat->secsize * ISO_BLOCKSIZE); if (is_mode2) { - if (cdio_read_mode2_sectors (cdio, _dirbuf, stat.lsn, false, - stat.secsize)) + if (cdio_read_mode2_sectors (cdio, _dirbuf, stat->lsn, false, + stat->secsize)) cdio_assert_not_reached (); } else { - if (cdio_read_mode1_sectors (cdio, _dirbuf, stat.lsn, false, - stat.secsize)) + if (cdio_read_mode1_sectors (cdio, _dirbuf, stat->lsn, false, + stat->secsize)) cdio_assert_not_reached (); } - while (offset < (stat.secsize * ISO_BLOCKSIZE)) + while (offset < (stat->secsize * ISO_BLOCKSIZE)) + { + const iso9660_dir_t *iso9660_dir = (void *) &_dirbuf[offset]; + iso9660_stat_t *iso9660_stat; + + if (!iso9660_get_dir_len(iso9660_dir)) + { + offset++; + continue; + } + + iso9660_stat = _iso9660_dir_to_statbuf(iso9660_dir, is_mode2); + _cdio_list_append (retval, iso9660_stat); + + offset += iso9660_get_dir_len(iso9660_dir); + } + + cdio_assert (offset == (stat->secsize * ISO_BLOCKSIZE)); + + free (_dirbuf); + free (stat); + return retval; + } +} + +/*! + Read pathname (a directory) and return a list of iso9660_stat_t + of the files inside that. The caller must free the returned result. +*/ +void * +iso9660_ifs_readdir (iso9660_t *iso, const char pathname[]) +{ + iso9660_stat_t *stat; + + if (NULL == iso) return NULL; + if (NULL == pathname) return NULL; + + stat = iso9660_ifs_stat (iso, pathname); + if (NULL == stat) return NULL; + + if (stat->type != _STAT_DIR) { + free(stat); + return NULL; + } + + { + long int ret; + unsigned offset = 0; + uint8_t *_dirbuf = NULL; + CdioList *retval = _cdio_list_new (); + + if (stat->size != ISO_BLOCKSIZE * stat->secsize) { - const iso9660_dir_t *idr = (void *) &_dirbuf[offset]; + cdio_warn ("bad size for ISO9660 directory (%ud) should be (%lu)!", + (unsigned) stat->size, + (unsigned long int) ISO_BLOCKSIZE * stat->secsize); + } + + _dirbuf = _cdio_malloc (stat->secsize * ISO_BLOCKSIZE); - if (!iso9660_get_dir_len(idr)) + ret = iso9660_iso_seek_read (iso, _dirbuf, stat->lsn, stat->secsize); + if (ret != ISO_BLOCKSIZE*stat->secsize) return NULL; + + while (offset < (stat->secsize * ISO_BLOCKSIZE)) + { + const iso9660_dir_t *iso9660_dir = (void *) &_dirbuf[offset]; + iso9660_stat_t *iso9660_stat; + + if (!iso9660_get_dir_len(iso9660_dir)) { offset++; continue; } - _cdio_list_append (retval, _idr2name (idr)); + iso9660_stat = _iso9660_dir_to_statbuf(iso9660_dir, true); + _cdio_list_append (retval, iso9660_stat); - offset += iso9660_get_dir_len(idr); + offset += iso9660_get_dir_len(iso9660_dir); } - cdio_assert (offset == (stat.secsize * ISO_BLOCKSIZE)); + cdio_assert (offset == (stat->secsize * ISO_BLOCKSIZE)); free (_dirbuf); + free (stat); return retval; } } -static bool -find_fs_lsn_recurse (const CdIo *cdio, const char pathname[], - /*out*/ iso9660_stat_t *statbuf, lsn_t lsn) +static iso9660_stat_t * +find_fs_lsn_recurse (const CdIo *cdio, const char pathname[], lsn_t lsn) { CdioList *entlist = iso9660_fs_readdir (cdio, pathname, true); CdioList *dirlist = _cdio_list_new (); @@ -302,25 +655,26 @@ find_fs_lsn_recurse (const CdIo *cdio, const char pathname[], _CDIO_LIST_FOREACH (entnode, entlist) { - char *name = _cdio_list_node_data (entnode); + iso9660_stat_t *statbuf = _cdio_list_node_data (entnode); char _fullname[4096] = { 0, }; + char *filename = (char *) statbuf->filename; - snprintf (_fullname, sizeof (_fullname), "%s%s", pathname, name); + snprintf (_fullname, sizeof (_fullname), "%s%s", pathname, filename); - if (iso9660_fs_stat (cdio, _fullname, statbuf, true)) - cdio_assert_not_reached (); - strncat (_fullname, "/", sizeof (_fullname)); if (statbuf->type == _STAT_DIR - && strcmp (name, ".") - && strcmp (name, "..")) + && strcmp ((char *) statbuf->filename, ".") + && strcmp ((char *) statbuf->filename, "..")) _cdio_list_append (dirlist, strdup (_fullname)); if (statbuf->lsn == lsn) { + unsigned int len=sizeof(iso9660_stat_t)+strlen(statbuf->filename)+1; + iso9660_stat_t *ret_stat = _cdio_malloc(len); + memcpy(ret_stat, statbuf, len); _cdio_list_free (entlist, true); _cdio_list_free (dirlist, true); - return true; + return ret_stat; } } @@ -332,26 +686,27 @@ find_fs_lsn_recurse (const CdIo *cdio, const char pathname[], _CDIO_LIST_FOREACH (entnode, dirlist) { char *_fullname = _cdio_list_node_data (entnode); + iso9660_stat_t *ret_stat = find_fs_lsn_recurse (cdio, _fullname, lsn); - if (find_fs_lsn_recurse (cdio, _fullname, statbuf, lsn)) { + if (NULL != ret_stat) { _cdio_list_free (dirlist, true); - return true; + return ret_stat; } } _cdio_list_free (dirlist, true); - return false; + return NULL; } /*! Given a directory pointer, find the filesystem entry that contains - lsn and return information about it in stat. + lsn and return information about it. - Returns true if we found an entry with the lsn and false if not. + Returns stat_t of entry if we found lsn, or NULL otherwise. */ -bool -iso9660_find_fs_lsn(const CdIo *cdio, lsn_t lsn, /*out*/ iso9660_stat_t *stat) +iso9660_stat_t * +iso9660_find_fs_lsn(const CdIo *cdio, lsn_t lsn) { - return find_fs_lsn_recurse (cdio, "/", stat, lsn); + return find_fs_lsn_recurse (cdio, "/", lsn); } diff --git a/src/input/vcd/libcdio/iso9660_private.h b/src/input/vcd/libcdio/iso9660_private.h index 411664c38..9a10950aa 100644 --- a/src/input/vcd/libcdio/iso9660_private.h +++ b/src/input/vcd/libcdio/iso9660_private.h @@ -1,5 +1,5 @@ /* - $Id: iso9660_private.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: iso9660_private.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> diff --git a/src/input/vcd/libcdio/logging.c b/src/input/vcd/libcdio/logging.c index 522d98d9a..8d561debe 100644 --- a/src/input/vcd/libcdio/logging.c +++ b/src/input/vcd/libcdio/logging.c @@ -1,7 +1,8 @@ /* - $Id: logging.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: logging.c,v 1.2 2004/04/11 12:20:31 miguelfreitas 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 @@ -29,10 +30,9 @@ #include <cdio/logging.h> #include "cdio_assert.h" +static const char _rcsid[] = "$Id: logging.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; -static const char _rcsid[] = "$Id: logging.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; - -int cdio_loglevel_default = CDIO_LOG_WARN; +cdio_log_level_t cdio_loglevel_default = CDIO_LOG_WARN; static void default_cdio_log_handler (cdio_log_level_t level, const char message[]) diff --git a/src/input/vcd/libcdio/scsi_mmc.h b/src/input/vcd/libcdio/scsi_mmc.h index a0c22a86f..b6ea05b7a 100644 --- a/src/input/vcd/libcdio/scsi_mmc.h +++ b/src/input/vcd/libcdio/scsi_mmc.h @@ -1,5 +1,5 @@ /* - $Id: scsi_mmc.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: scsi_mmc.h,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> diff --git a/src/input/vcd/libcdio/sector.c b/src/input/vcd/libcdio/sector.c index 24082bc2d..8ae28fc03 100644 --- a/src/input/vcd/libcdio/sector.c +++ b/src/input/vcd/libcdio/sector.c @@ -1,5 +1,5 @@ /* - $Id: sector.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: sector.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -32,7 +32,7 @@ #endif -static const char _rcsid[] = "$Id: sector.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: sector.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; lba_t cdio_lba_to_lsn (lba_t lba) diff --git a/src/input/vcd/libcdio/util.c b/src/input/vcd/libcdio/util.c index 3b5b832cc..55717a15f 100644 --- a/src/input/vcd/libcdio/util.c +++ b/src/input/vcd/libcdio/util.c @@ -1,5 +1,5 @@ /* - $Id: util.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: util.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> @@ -31,7 +31,7 @@ #include "cdio_assert.h" #include <cdio/util.h> -static const char _rcsid[] = "$Id: util.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: util.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $"; size_t _cdio_strlenv(char **str_array) diff --git a/src/input/vcd/libcdio/xa.c b/src/input/vcd/libcdio/xa.c index 31c5e110a..dbf8abd3c 100644 --- a/src/input/vcd/libcdio/xa.c +++ b/src/input/vcd/libcdio/xa.c @@ -1,5 +1,5 @@ /* - $Id: xa.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: xa.c,v 1.2 2004/04/11 12:20:31 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> diff --git a/src/input/vcd/libvcd/Makefile.am b/src/input/vcd/libvcd/Makefile.am index a4138bf8b..edd3d0e28 100644 --- a/src/input/vcd/libvcd/Makefile.am +++ b/src/input/vcd/libvcd/Makefile.am @@ -44,7 +44,7 @@ endif endif noinst_HEADERS = \ - assert.h \ + vcd_assert.h \ data_structures.h \ info_private.h \ pbc.h \ diff --git a/src/input/vcd/libvcd/bitvec.h b/src/input/vcd/libvcd/bitvec.h index ca0198ca2..f45059db0 100644 --- a/src/input/vcd/libvcd/bitvec.h +++ b/src/input/vcd/libvcd/bitvec.h @@ -1,5 +1,5 @@ /* - $Id: bitvec.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: bitvec.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -23,7 +23,7 @@ #include <libvcd/types.h> -#include "assert.h" +#include "vcd_assert.h" static inline bool _vcd_bit_set_p (const uint32_t n, const unsigned bit) diff --git a/src/input/vcd/libvcd/bytesex.h b/src/input/vcd/libvcd/bytesex.h index 7bfdee8c7..9a212693d 100644 --- a/src/input/vcd/libvcd/bytesex.h +++ b/src/input/vcd/libvcd/bytesex.h @@ -1,5 +1,5 @@ /* - $Id: bytesex.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: bytesex.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -128,64 +128,10 @@ 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) - vcd_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) - vcd_warn ("from_733: broken byte order"); - - return (UINT32_C(0xFFFFFFFF) & p); -} #endif /* __VCD_BYTESEX_H__ */ diff --git a/src/input/vcd/libvcd/bytesex_asm.h b/src/input/vcd/libvcd/bytesex_asm.h index 21c7402da..3265c592b 100644 --- a/src/input/vcd/libvcd/bytesex_asm.h +++ b/src/input/vcd/libvcd/bytesex_asm.h @@ -1,5 +1,5 @@ /* - $Id: bytesex_asm.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: bytesex_asm.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2001 Sven Ottemann <ac-logic@freenet.de> 2001 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/data_structures.c b/src/input/vcd/libvcd/data_structures.c index 5b3785b88..a269cc8f8 100644 --- a/src/input/vcd/libvcd/data_structures.c +++ b/src/input/vcd/libvcd/data_structures.c @@ -1,5 +1,5 @@ /* - $Id: data_structures.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: data_structures.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -31,11 +31,11 @@ #include <libvcd/types.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "data_structures.h" #include "util.h" -static const char _rcsid[] = "$Id: data_structures.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: data_structures.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; struct _VcdList { diff --git a/src/input/vcd/libvcd/data_structures.h b/src/input/vcd/libvcd/data_structures.h index 332f731d9..9ce996f01 100644 --- a/src/input/vcd/libvcd/data_structures.h +++ b/src/input/vcd/libvcd/data_structures.h @@ -1,5 +1,5 @@ /* - $Id: data_structures.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: data_structures.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/dict.h b/src/input/vcd/libvcd/dict.h index cade2a3d4..f7de3b1c9 100644 --- a/src/input/vcd/libvcd/dict.h +++ b/src/input/vcd/libvcd/dict.h @@ -1,5 +1,5 @@ /* - $Id: dict.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: dict.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -25,7 +25,7 @@ #include <libvcd/types.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "obj.h" #include "util.h" diff --git a/src/input/vcd/libvcd/directory.c b/src/input/vcd/libvcd/directory.c index 9df691f99..49cc8fe8a 100644 --- a/src/input/vcd/libvcd/directory.c +++ b/src/input/vcd/libvcd/directory.c @@ -1,5 +1,5 @@ /* - $Id: directory.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: directory.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -30,12 +30,12 @@ #include <libvcd/logging.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "bytesex.h" #include "directory.h" #include "util.h" -static const char _rcsid[] = "$Id: directory.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: directory.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; /* CD-ROM XA */ diff --git a/src/input/vcd/libvcd/directory.h b/src/input/vcd/libvcd/directory.h index 13e44da89..c4cba9efc 100644 --- a/src/input/vcd/libvcd/directory.h +++ b/src/input/vcd/libvcd/directory.h @@ -1,5 +1,5 @@ /* - $Id: directory.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: directory.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/files.c b/src/input/vcd/libvcd/files.c index e0757355d..47210da7f 100644 --- a/src/input/vcd/libvcd/files.c +++ b/src/input/vcd/libvcd/files.c @@ -1,5 +1,5 @@ /* - $Id: files.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: files.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -39,14 +39,14 @@ #include <libvcd/files_private.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "bytesex.h" #include "mpeg_stream.h" #include "obj.h" #include "pbc.h" #include "util.h" -static const char _rcsid[] = "$Id: files.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: files.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; inline static bool _pal_p (const struct vcd_mpeg_stream_vid_info *_info) diff --git a/src/input/vcd/libvcd/image.c b/src/input/vcd/libvcd/image.c index ae5b6aeb6..8824d3b79 100644 --- a/src/input/vcd/libvcd/image.c +++ b/src/input/vcd/libvcd/image.c @@ -1,5 +1,5 @@ /* - $Id: image.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: image.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> 2002 Rocky Bernstein <rocky@panix.com> @@ -30,11 +30,11 @@ #include <cdio/iso9660.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "image_sink.h" #include "util.h" -static const char _rcsid[] = "$Id: image.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: image.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; /* * VcdImageSink routines next. diff --git a/src/input/vcd/libvcd/image_bincue.c b/src/input/vcd/libvcd/image_bincue.c index b5e598a61..f8af4bbe0 100644 --- a/src/input/vcd/libvcd/image_bincue.c +++ b/src/input/vcd/libvcd/image_bincue.c @@ -1,5 +1,5 @@ /* - $Id: image_bincue.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: image_bincue.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> @@ -34,13 +34,13 @@ #include <libvcd/logging.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "bytesex.h" #include "image_sink.h" #include "stream_stdio.h" #include "util.h" -static const char _rcsid[] = "$Id: image_bincue.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: image_bincue.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; /* reader */ diff --git a/src/input/vcd/libvcd/image_cdrdao.c b/src/input/vcd/libvcd/image_cdrdao.c index 3754721c2..58543ff8e 100644 --- a/src/input/vcd/libvcd/image_cdrdao.c +++ b/src/input/vcd/libvcd/image_cdrdao.c @@ -1,5 +1,5 @@ /* - $Id: image_cdrdao.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: image_cdrdao.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> @@ -32,14 +32,14 @@ #include <libvcd/logging.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "bytesex.h" #include "image_sink.h" #include "stream_stdio.h" #include "util.h" #include "vcd.h" -static const char _rcsid[] = "$Id: image_cdrdao.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: image_cdrdao.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; /* reader */ diff --git a/src/input/vcd/libvcd/image_nrg.c b/src/input/vcd/libvcd/image_nrg.c index e94e62b4e..29798d724 100644 --- a/src/input/vcd/libvcd/image_nrg.c +++ b/src/input/vcd/libvcd/image_nrg.c @@ -1,5 +1,5 @@ /* - $Id: image_nrg.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: image_nrg.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2001,2003 Herbert Valerio Riedel <hvr@gnu.org> @@ -38,13 +38,13 @@ #include <libvcd/logging.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "bytesex.h" #include "image_sink.h" #include "stream_stdio.h" #include "util.h" -static const char _rcsid[] = "$Id: image_nrg.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: image_nrg.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; /* structures used */ diff --git a/src/input/vcd/libvcd/image_sink.h b/src/input/vcd/libvcd/image_sink.h index 40d0f4867..98bbc0eb5 100644 --- a/src/input/vcd/libvcd/image_sink.h +++ b/src/input/vcd/libvcd/image_sink.h @@ -1,5 +1,5 @@ /* - $Id: image_sink.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: image_sink.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/inf.c b/src/input/vcd/libvcd/inf.c index 699bc24ad..c483f76af 100644 --- a/src/input/vcd/libvcd/inf.c +++ b/src/input/vcd/libvcd/inf.c @@ -1,5 +1,5 @@ /* - $Id: inf.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: inf.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com> @@ -60,7 +60,7 @@ #include "info_private.h" #include "pbc.h" -static const char _rcsid[] = "$Id: inf.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: inf.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; #define BUF_COUNT 16 #define BUF_SIZE 80 diff --git a/src/input/vcd/libvcd/info.c b/src/input/vcd/libvcd/info.c index 6e13637c2..096cb0b84 100644 --- a/src/input/vcd/libvcd/info.c +++ b/src/input/vcd/libvcd/info.c @@ -1,5 +1,5 @@ /* - $Id: info.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: info.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com> @@ -26,7 +26,7 @@ /* Private headers */ #include "info_private.h" -#include "assert.h" +#include "vcd_assert.h" #include "bytesex.h" #include "pbc.h" #include "util.h" @@ -59,7 +59,7 @@ #include <stddef.h> #include <errno.h> -static const char _rcsid[] = "$Id: info.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: info.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; #define MIN_ENCODED_TRACK_NUM 100 #define MIN_ENCODED_SEGMENT_NUM 1000 @@ -100,31 +100,76 @@ _init_segments (vcdinfo_obj_t *obj) { InfoVcd *info = vcdinfo_get_infoVcd(obj); segnum_t num_segments = vcdinfo_get_num_segments(obj); + VcdListNode *entnode; + VcdList *entlist; int i; - iso9660_stat_t statbuf; + lsn_t last_lsn=0; obj->first_segment_lsn = cdio_msf_to_lsn(&info->first_seg_addr); - obj->seg_sizes = _vcd_malloc( num_segments * sizeof(uint32_t *)); - if (NULL == obj->seg_sizes) return; + if (NULL == obj->seg_sizes || 0 == num_segments) return; + + entlist = iso9660_fs_readdir(obj->img, "SEGMENT", true); + + i=0; + _VCD_LIST_FOREACH (entnode, entlist) { + iso9660_stat_t *statbuf = _vcd_list_node_data (entnode); + + if (statbuf->type == _STAT_DIR) continue; + + while(info->spi_contents[i].item_cont) { + obj->seg_sizes[i] = VCDINFO_SEGMENT_SECTOR_SIZE; + i++; + } + + /* Should have an entry in the ISO 9660 filesystem. Get and save + in statbuf.secsize this size. + */ + obj->seg_sizes[i] = statbuf->secsize; + + if (last_lsn >= statbuf->lsn) + vcd_warn ("Segments if ISO 9660 directory out of order lsn %ul >= %ul", + (unsigned int) last_lsn, (unsigned int) statbuf->lsn); + last_lsn = statbuf->lsn; + + i++; + } + + while(i < num_segments && info->spi_contents[i].item_cont) { + obj->seg_sizes[i] = VCDINFO_SEGMENT_SECTOR_SIZE; + i++; + } + + if (i != num_segments) + vcd_warn ("Number of segments found %d is not number of segments %d", + i, num_segments); + + _vcd_list_free (entlist, true); + + +#if 0 /* Figure all of the segment sector sizes */ for (i=0; i < num_segments; i++) { obj->seg_sizes[i] = VCDINFO_SEGMENT_SECTOR_SIZE; if ( !info->spi_contents[i].item_cont ) { - /* Should have an entry in the ISO 9660 filesytem. Get and save + /* Should have an entry in the ISO 9660 filesystem. Get and save in statbuf.secsize this size. */ lsn_t lsn = vcdinfo_get_seg_lsn(obj, i); - if (iso9660_find_fs_lsn(obj->img, lsn, &statbuf)) { - obj->seg_sizes[i] = statbuf.secsize; + iso9660_stat_t *statbuf =iso9660_find_fs_lsn(obj->img, lsn); + if (NULL != statbuf) { + obj->seg_sizes[i] = statbuf->secsize; + free(statbuf); } else { vcd_warn ("Trouble finding ISO 9660 size for segment %d.", i); } } } +#endif + } /*! @@ -365,6 +410,68 @@ vcdinfo_get_cd_image (const vcdinfo_obj_t *vcd_obj) } +/*! + \fn vcdinfo_selection_get_lid(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int selection); + + \brief Get offset of a selection for a given lid. + + Return the LID offset associated with a the selection number of the + passed-in LID parameter. + + \return VCDINFO_INVALID_LID is returned if obj on error or obj + is NULL. Otherwise the LID offset is returned. +*/ +lid_t vcdinfo_selection_get_lid(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int selection) +{ + unsigned int offset; + + if (NULL == obj) return VCDINFO_INVALID_LID; + + offset = vcdinfo_selection_get_offset(obj, lid, selection); + switch (offset) { + case VCDINFO_INVALID_OFFSET: + case PSD_OFS_MULTI_DEF: + case PSD_OFS_MULTI_DEF_NO_NUM: + return VCDINFO_INVALID_LID; + default: + { + vcdinfo_offset_t *ofs = vcdinfo_get_offset_t(obj, offset); + return ofs->lid; + } + } +} + +/*! + \fn vcdinfo_selection_get_offset(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int selection); + + \brief Get offset of a selection for a given lid. + + Return the LID offset associated with a the selection number of the + passed-in LID parameter. + + \return VCDINFO_INVALID_OFFSET is returned if obj on error or obj + is NULL. Otherwise the LID offset is returned. +*/ +uint16_t vcdinfo_selection_get_offset(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int selection) +{ + unsigned int bsn; + + PsdListDescriptor pxd; + vcdinfo_lid_get_pxd(obj, &pxd, lid); + bsn=vcdinf_get_bsn(pxd.psd); + + if ( (selection - bsn + 1) > 0) { + return vcdinfo_lid_get_offset(obj, lid, selection-bsn+1); + } else { + vcd_warn( "Selection number %u too small. bsn %u", selection, bsn ); + return VCDINFO_INVALID_OFFSET; + } +} + /** \fn vcdinfo_get_default_offset(const vcdinfo_obj_t *obj, unsinged int lid); \brief Get return offset for a given PLD selector descriptor. @@ -372,7 +479,7 @@ vcdinfo_get_cd_image (const vcdinfo_obj_t *vcd_obj) "return" entry or pld is NULL. Otherwise the LID offset is returned. */ uint16_t -vcdinfo_get_default_offset(const vcdinfo_obj_t *obj, unsigned int lid) +vcdinfo_get_default_offset(const vcdinfo_obj_t *obj, lid_t lid) { if (NULL != obj) { @@ -395,6 +502,83 @@ vcdinfo_get_default_offset(const vcdinfo_obj_t *obj, unsigned int lid) } /*! + \brief Get default or multi-default LID. + + Return the LID offset associated with a the "default" entry of the + passed-in LID parameter. Note "default" entries are associated + with PSDs that are (extended) selection lists. If the "default" + offset is a multi-default, we use entry_num to find the proper + "default" LID. Otherwise this routine is exactly like + vcdinfo_get_default_lid with the exception of requiring an + additional "entry_num" parameter. + + \return VCDINFO_INVALID_LID is returned on error, or if the LID + is not a selection list or no "default" entry. Otherwise the LID + offset is returned. +*/ +lid_t +vcdinfo_get_multi_default_lid(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int entry_num) +{ + unsigned int offset = vcdinfo_get_multi_default_offset(obj, lid, entry_num); + switch (offset) { + case VCDINFO_INVALID_OFFSET: + case PSD_OFS_MULTI_DEF: + case PSD_OFS_MULTI_DEF_NO_NUM: + return VCDINFO_INVALID_LID; + default: + { + vcdinfo_offset_t *ofs = vcdinfo_get_offset_t(obj, offset); + return ofs->lid; + } + } +} + +/*! + \brief Get default or multi-default LID offset. + + Return the LID offset associated with a the "default" entry of the + passed-in LID parameter. Note "default" entries are associated + with PSDs that are (extended) selection lists. If the "default" + offset is a multi-default, we use entry_num to find the proper + "default" offset. Otherwise this routine is exactly like + vcdinfo_get_default_offset with the exception of requiring an + additional "entry_num" parameter. + + \return VCDINFO_INVALID_OFFSET is returned on error, or if the LID + is not a selection list or no "default" entry. Otherwise the LID + offset is returned. +*/ +uint16_t +vcdinfo_get_multi_default_offset(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int entry_num) +{ + uint16_t offset=vcdinfo_get_default_offset(obj, lid); + + switch (offset) { + case PSD_OFS_MULTI_DEF: + case PSD_OFS_MULTI_DEF_NO_NUM: + { + /* Have some work todo... Figure the selection number. */ + unsigned int selection=0; + track_t track=vcdinfo_get_track(obj, entry_num); + track_t prev_track=VCDINFO_INVALID_TRACK; + for (selection=1; + track != VCDINFO_INVALID_TRACK + && track != prev_track + && entry_num > 0; + selection++) { + prev_track = track; + track=vcdinfo_get_track(obj, --entry_num); + } + return vcdinfo_selection_get_offset(obj, lid, selection); + } + default: + return offset; + } +} + +/*! Return a string containing the default VCD device if none is specified. Return NULL we can't get this information. */ @@ -449,12 +633,15 @@ vcdinfo_get_entry_sect_count (const vcdinfo_obj_t *obj, unsigned int entry_num) */ track_t track = vcdinfo_get_track(obj, entry_num); if (track != VCDINFO_INVALID_TRACK) { - iso9660_stat_t statbuf; + iso9660_stat_t *statbuf; const lsn_t lsn = vcdinfo_get_track_lsn(obj, track); /* Try to get the sector count from the ISO 9660 filesystem */ - if (iso9660_find_fs_lsn(obj->img, lsn, &statbuf)) { - next_lsn = lsn + statbuf.secsize; + statbuf = iso9660_find_fs_lsn(obj->img, lsn); + + if (NULL != statbuf) { + next_lsn = lsn + statbuf->secsize; + free(statbuf); } else { /* Failed on ISO 9660 filesystem. Use next track or LEADOUT track. */ @@ -653,7 +840,7 @@ vcdinfo_get_num_segments(const vcdinfo_obj_t *obj) } /*! - \fn vcdinfo_get_offset_from_lid(const vcdinfo_obj_t *obj, unsigned int entry_num); + \fn vcdinfo_get_offset_lid(const vcdinfo_obj_t *obj, unsigned int entry_num); \brief Get offset entry_num for a given LID. \return VCDINFO_INVALID_OFFSET is returned if obj on error or obj is NULL. Otherwise the LID offset is returned. @@ -1150,12 +1337,14 @@ vcdinfo_get_track_sect_count(const vcdinfo_obj_t *obj, const track_t track_num) return 0; { - iso9660_stat_t statbuf; + iso9660_stat_t *statbuf; const lsn_t lsn = vcdinfo_get_track_lsn(obj, track_num); /* Try to get the sector count from the ISO 9660 filesystem */ - if (obj->has_xa && iso9660_find_fs_lsn(obj->img, lsn, &statbuf)) { - return statbuf.secsize; + if (obj->has_xa && (statbuf = iso9660_find_fs_lsn(obj->img, lsn))) { + unsigned int secsize = statbuf->secsize; + free(statbuf); + return secsize; } else { const lsn_t next_lsn=vcdinfo_get_track_lsn(obj, track_num+1); /* Failed on ISO 9660 filesystem. Use track information. */ @@ -1185,7 +1374,7 @@ vcdinfo_get_track_size(const vcdinfo_obj_t *obj, track_t track_num) const lsn_t lsn = cdio_lba_to_lsn(vcdinfo_get_track_lba(obj, track_num)); /* Try to get the sector count from the ISO 9660 filesystem */ - if (obj->has_xa && iso9660_find_fs_lsn(obj->img, lsn, &statbuf)) { + if (obj->has_xa && iso9660_find_fs_lsn(obj->img, lsn)) { return statbuf.size; } #if 0 @@ -1357,7 +1546,7 @@ vcdinfo_msf2lsn (uint8_t min, uint8_t sec, int8_t frame) lba_t lba=75*(60*min + sec) + frame; if (lba < CDIO_PREGAP_SECTORS) { vcd_error ("lba (%u) less than pregap sector (%u)", - lba, CDIO_PREGAP_SECTORS); + (unsigned int) lba, CDIO_PREGAP_SECTORS); return lba; } return lba - CDIO_PREGAP_SECTORS; @@ -1373,7 +1562,7 @@ vcdinfo_ofs2str (const vcdinfo_obj_t *obj, unsigned int offset, bool ext) case PSD_OFS_DISABLED: return "disabled"; case PSD_OFS_MULTI_DEF: - return "multi_def"; + return "multi-default"; case PSD_OFS_MULTI_DEF_NO_NUM: return "multi_def_no_num"; default: ; @@ -1426,10 +1615,17 @@ vcdinfo_read_psd (vcdinfo_obj_t *obj) return true; } -void +/*! + Calls recursive routine to populate obj->offset_list or obj->offset_x_list + by going through LOT. + + Returns false if there was some error. +*/ +bool vcdinfo_visit_lot (vcdinfo_obj_t *obj, bool extended) { struct _vcdinf_pbc_ctx pbc_ctx; + bool ret; pbc_ctx.psd_size = vcdinfo_get_psd_size (obj); pbc_ctx.psd_x_size = obj->psd_x_size; @@ -1443,13 +1639,14 @@ vcdinfo_visit_lot (vcdinfo_obj_t *obj, bool extended) pbc_ctx.lot_x = obj->lot_x; pbc_ctx.extended = extended; - vcdinf_visit_lot(&pbc_ctx); + ret = vcdinf_visit_lot(&pbc_ctx); if (NULL != obj->offset_x_list) _vcd_list_free(obj->offset_x_list, true); obj->offset_x_list = pbc_ctx.offset_x_list; if (NULL != obj->offset_list) _vcd_list_free(obj->offset_list, true); obj->offset_list = pbc_ctx.offset_list; + return ret; } /*! @@ -1541,8 +1738,8 @@ vcdinfo_open(vcdinfo_obj_t **obj_p, char *source_name[], driver_id_t source_type, const char access_mode[]) { CdIo *img; - iso9660_stat_t statbuf; vcdinfo_obj_t *obj = _vcd_malloc(sizeof(vcdinfo_obj_t)); + iso9660_stat_t *statbuf; /* If we don't specify a driver_id or a source_name, scan the @@ -1571,8 +1768,10 @@ vcdinfo_open(vcdinfo_obj_t **obj_p, char *source_name[], if (access_mode != NULL) cdio_set_arg (img, "access-mode", access_mode); - if (NULL == *source_name) + if (NULL == *source_name) { *source_name = cdio_get_default_device(img); + if (NULL == *source_name) return VCDINFO_OPEN_ERROR; + } memset (obj, 0, sizeof (vcdinfo_obj_t)); obj->img = img; /* Note we do this after the above wipeout! */ @@ -1607,81 +1806,113 @@ vcdinfo_open(vcdinfo_obj_t **obj_p, char *source_name[], } if (obj->vcd_type == VCD_TYPE_SVCD || obj->vcd_type == VCD_TYPE_HQVCD) { - if (!iso9660_fs_stat (obj->img, "MPEGAV", &statbuf, true)) + statbuf = iso9660_fs_stat (obj->img, "MPEGAV", true); + + if (NULL != statbuf) { vcd_warn ("non compliant /MPEGAV folder detected!"); + free(statbuf); + } - if (!iso9660_fs_stat (obj->img, "SVCD/TRACKS.SVD;1", &statbuf, true)) - { - if (statbuf.size != ISO_BLOCKSIZE) - vcd_warn ("TRACKS.SVD filesize != %d!", ISO_BLOCKSIZE); - - obj->tracks_buf = _vcd_malloc (ISO_BLOCKSIZE); - - if (cdio_read_mode2_sector (obj->img, obj->tracks_buf, statbuf.lsn, - false)) - return VCDINFO_OPEN_ERROR; - } + + statbuf = iso9660_fs_stat (obj->img, "SVCD/TRACKS.SVD;1", true); + if (NULL != statbuf) { + lsn_t lsn = statbuf->lsn; + if (statbuf->size != ISO_BLOCKSIZE) + vcd_warn ("TRACKS.SVD filesize != %d!", ISO_BLOCKSIZE); + + obj->tracks_buf = _vcd_malloc (ISO_BLOCKSIZE); + + free(statbuf); + if (cdio_read_mode2_sector (obj->img, obj->tracks_buf, lsn, false)) + return VCDINFO_OPEN_ERROR; + } } _init_segments (obj); switch (obj->vcd_type) { case VCD_TYPE_VCD2: { - if (!iso9660_fs_stat (img, "EXT/PSD_X.VCD;1", &statbuf, true)) { - vcd_debug ("found /EXT/PSD_X.VCD at sector %lu", - (long unsigned int) statbuf.lsn); - - obj->psd_x = _vcd_malloc (ISO_BLOCKSIZE * statbuf.secsize); - obj->psd_x_size = statbuf.size; + /* FIXME: Can reduce CD reads by using + iso9660_fs_readdir(img, "EXT", true) and then scanning for + the files listed below. + */ + statbuf = iso9660_fs_stat (img, "EXT/PSD_X.VCD;1", true); + if (NULL != statbuf) { + lsn_t lsn = statbuf->lsn; + uint32_t secsize = statbuf->secsize; + + obj->psd_x = _vcd_malloc (ISO_BLOCKSIZE * secsize); + obj->psd_x_size = statbuf->size; - if (cdio_read_mode2_sectors (img, obj->psd_x, statbuf.lsn, - false, statbuf.secsize)) + vcd_debug ("found /EXT/PSD_X.VCD at sector %lu", + (long unsigned int) lsn); + + free(statbuf); + if (cdio_read_mode2_sectors (img, obj->psd_x, lsn, false, secsize)) return VCDINFO_OPEN_ERROR; } - if (!iso9660_fs_stat (img, "EXT/LOT_X.VCD;1", &statbuf, true)) { + statbuf = iso9660_fs_stat (img, "EXT/LOT_X.VCD;1", true); + if (NULL != statbuf) { + lsn_t lsn = statbuf->lsn; + uint32_t secsize = statbuf->secsize; + obj->lot_x = _vcd_malloc (ISO_BLOCKSIZE * secsize); + vcd_debug ("found /EXT/LOT_X.VCD at sector %lu", - (unsigned long int) statbuf.lsn); + (unsigned long int) lsn); - obj->lot_x = _vcd_malloc (ISO_BLOCKSIZE * statbuf.secsize); - - if (cdio_read_mode2_sectors (img, obj->lot_x, statbuf.lsn, false, - statbuf.secsize)) + if (statbuf->size != LOT_VCD_SIZE * ISO_BLOCKSIZE) + vcd_warn ("LOT_X.VCD size != 65535"); + + free(statbuf); + if (cdio_read_mode2_sectors (img, obj->lot_x, lsn, false, secsize)) return VCDINFO_OPEN_ERROR; - if (statbuf.size != LOT_VCD_SIZE * ISO_BLOCKSIZE) - vcd_warn ("LOT_X.VCD size != 65535"); } break; } case VCD_TYPE_SVCD: case VCD_TYPE_HQVCD: { - if (!iso9660_fs_stat (img, "MPEGAV", &statbuf, true)) + /* FIXME: Can reduce CD reads by using + iso9660_fs_readdir(img, "SVCD", true) and then scanning for + the files listed below. + */ + statbuf = iso9660_fs_stat (img, "MPEGAV", true); + if (NULL != statbuf) { vcd_warn ("non compliant /MPEGAV folder detected!"); + free(statbuf); + } - if (iso9660_fs_stat (img, "SVCD/TRACKS.SVD;1", &statbuf, true)) + statbuf = iso9660_fs_stat (img, "SVCD/TRACKS.SVD;1", true); + if (NULL == statbuf) vcd_warn ("mandatory /SVCD/TRACKS.SVD not found!"); - else + else { vcd_debug ("found TRACKS.SVD signature at sector %lu", - (unsigned long int) statbuf.lsn); + (unsigned long int) statbuf->lsn); + free(statbuf); + } - if (iso9660_fs_stat (img, "SVCD/SEARCH.DAT;1", &statbuf, true)) + statbuf = iso9660_fs_stat (img, "SVCD/SEARCH.DAT;1", true); + if (NULL == statbuf) vcd_warn ("mandatory /SVCD/SEARCH.DAT not found!"); else { + lsn_t lsn = statbuf->lsn; + uint32_t secsize = statbuf->secsize; + uint32_t stat_size = statbuf->size; uint32_t size; - vcd_debug ("found SEARCH.DAT at sector %lu", - (unsigned long int) statbuf.lsn); + + vcd_debug ("found SEARCH.DAT at sector %lu", (unsigned long int) lsn); - obj->search_buf = _vcd_malloc (ISO_BLOCKSIZE * statbuf.secsize); + obj->search_buf = _vcd_malloc (ISO_BLOCKSIZE * secsize); - if (cdio_read_mode2_sectors (img, obj->search_buf, statbuf.lsn, - false, statbuf.secsize)) + if (cdio_read_mode2_sectors (img, obj->search_buf, lsn, false, secsize)) return VCDINFO_OPEN_ERROR; size = (3 * uint16_from_be (((SearchDat *)obj->search_buf)->scan_points)) + sizeof (SearchDat); - - if (size > statbuf.size) { + + free(statbuf); + if (size > stat_size) { vcd_warn ("number of scanpoints leads to bigger size than " "file size of SEARCH.DAT! -- rereading"); @@ -1689,8 +1920,8 @@ vcdinfo_open(vcdinfo_obj_t **obj_p, char *source_name[], obj->search_buf = _vcd_malloc (ISO_BLOCKSIZE * _vcd_len2blocks(size, ISO_BLOCKSIZE)); - if (cdio_read_mode2_sectors (img, obj->search_buf,statbuf.lsn, - false, statbuf.secsize)) + if (cdio_read_mode2_sectors (img, obj->search_buf, lsn, false, + secsize)) return VCDINFO_OPEN_ERROR; } } @@ -1700,13 +1931,17 @@ vcdinfo_open(vcdinfo_obj_t **obj_p, char *source_name[], ; } - if (!iso9660_fs_stat (img, "EXT/SCANDATA.DAT;1", &statbuf, true)) { - vcd_debug ("found /EXT/SCANDATA.DAT at sector %d", statbuf.lsn); - - obj->scandata_buf = _vcd_malloc (ISO_BLOCKSIZE * statbuf.secsize); + statbuf = iso9660_fs_stat (img, "EXT/SCANDATA.DAT;1", true); + if (statbuf != NULL) { + lsn_t lsn = statbuf->lsn; + uint32_t secsize = statbuf->secsize; + + vcd_debug ("found /EXT/SCANDATA.DAT at sector %u", (unsigned int) lsn); - if (cdio_read_mode2_sectors (img, obj->scandata_buf, statbuf.lsn, - false, statbuf.secsize)) + obj->scandata_buf = _vcd_malloc (ISO_BLOCKSIZE * secsize); + + free(statbuf); + if (cdio_read_mode2_sectors (img, obj->scandata_buf, lsn, false, secsize)) return VCDINFO_OPEN_ERROR; } @@ -1731,6 +1966,8 @@ vcdinfo_close(vcdinfo_obj_t *obj) free(obj->seg_sizes); free(obj->lot); free(obj->lot_x); + if (obj->psd_x) free(obj->psd_x); + if (obj->scandata_buf) free(obj->scandata_buf); free(obj->tracks_buf); free(obj->search_buf); free(obj->source_name); diff --git a/src/input/vcd/libvcd/info_private.c b/src/input/vcd/libvcd/info_private.c index e0297d344..bf86d9b89 100644 --- a/src/input/vcd/libvcd/info_private.c +++ b/src/input/vcd/libvcd/info_private.c @@ -1,5 +1,5 @@ /* - $Id: info_private.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: info_private.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> @@ -55,13 +55,13 @@ #include <libvcd/info.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "bytesex.h" #include "data_structures.h" #include "info_private.h" #include "pbc.h" -static const char _rcsid[] = "$Id: info_private.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: info_private.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; /* This fills in unassigned LIDs in the offset table. Due to @@ -118,20 +118,23 @@ vcdinf_update_offset_list(struct _vcdinf_pbc_ctx *obj, bool extended) /*! Calls recursive routine to populate obj->offset_list or obj->offset_x_list by going through LOT. + + Returns false if there was some error. */ -void +bool vcdinf_visit_lot (struct _vcdinf_pbc_ctx *obj) { const LotVcd *lot = obj->extended ? obj->lot_x : obj->lot; unsigned int n, tmp; + bool ret=true; if (obj->extended) { - if (!obj->psd_x_size) return; - } else if (!obj->psd_size) return; + if (!obj->psd_x_size) return false; + } else if (!obj->psd_size) return false; for (n = 0; n < LOT_VCD_OFFSETS; n++) if ((tmp = vcdinf_get_lot_offset(lot, n)) != PSD_OFS_DISABLED) - vcdinf_visit_pbc (obj, n + 1, tmp, true); + ret &= vcdinf_visit_pbc (obj, n + 1, tmp, true); _vcd_list_sort (obj->extended ? obj->offset_x_list : obj->offset_list, (_vcd_list_cmp_func) vcdinf_lid_t_cmp); @@ -140,13 +143,16 @@ vcdinf_visit_lot (struct _vcdinf_pbc_ctx *obj) might obviate the need for vcdinf_visit_pbc() or some of it which is more complex. */ vcdinf_update_offset_list(obj, obj->extended); + return ret; } /*! Recursive routine to populate obj->offset_list or obj->offset_x_list by reading playback control entries referred to via lid. + + Returns false if there was some error. */ -void +bool vcdinf_visit_pbc (struct _vcdinf_pbc_ctx *obj, lid_t lid, unsigned int offset, bool in_lot) { @@ -156,6 +162,7 @@ vcdinf_visit_pbc (struct _vcdinf_pbc_ctx *obj, lid_t lid, unsigned int offset, const uint8_t *psd = obj->extended ? obj->psd_x : obj->psd; unsigned int _rofs = offset * obj->offset_mult; VcdList *offset_list; + bool ret=true; vcd_assert (psd_size % 8 == 0); @@ -164,7 +171,7 @@ vcdinf_visit_pbc (struct _vcdinf_pbc_ctx *obj, lid_t lid, unsigned int offset, case PSD_OFS_DISABLED: case PSD_OFS_MULTI_DEF: case PSD_OFS_MULTI_DEF_NO_NUM: - return; + return true; default: break; @@ -173,15 +180,13 @@ vcdinf_visit_pbc (struct _vcdinf_pbc_ctx *obj, lid_t lid, unsigned int offset, if (_rofs >= psd_size) { if (obj->extended) - vcd_error ("psd offset out of range in extended PSD" - " (try --no-ext-psd option)"); + vcd_warn ("psd offset out of range in extended PSD (%d >= %d)", + _rofs, psd_size); else vcd_warn ("psd offset out of range (%d >= %d)", _rofs, psd_size); - return; + return false; } - vcd_assert (_rofs < psd_size); - if (!obj->offset_list) obj->offset_list = _vcd_list_new (); @@ -212,7 +217,7 @@ vcdinf_visit_pbc (struct _vcdinf_pbc_ctx *obj, lid_t lid, unsigned int offset, ofs->ext = obj->extended; - return; /* already been there... */ + return true; /* already been there... */ } } @@ -239,9 +244,10 @@ vcdinf_visit_pbc (struct _vcdinf_pbc_ctx *obj, lid_t lid, unsigned int offset, vcd_warn ("LOT entry assigned LID %d, but descriptor has LID %d", ofs->lid, lid); - vcdinf_visit_pbc (obj, 0, vcdinf_pld_get_prev_offset(d), false); - vcdinf_visit_pbc (obj, 0, vcdinf_pld_get_next_offset(d), false); - vcdinf_visit_pbc (obj, 0, vcdinf_pld_get_return_offset(d), false); + ret &= vcdinf_visit_pbc (obj, 0, vcdinf_pld_get_prev_offset(d), false); + ret &= vcdinf_visit_pbc (obj, 0, vcdinf_pld_get_next_offset(d), false); + ret &= vcdinf_visit_pbc (obj, 0, vcdinf_pld_get_return_offset(d), + false); } break; @@ -261,15 +267,18 @@ vcdinf_visit_pbc (struct _vcdinf_pbc_ctx *obj, lid_t lid, unsigned int offset, vcd_warn ("LOT entry assigned LID %d, but descriptor has LID %d", ofs->lid, uint16_from_be (d->lid) & 0x7fff); - vcdinf_visit_pbc (obj, 0, vcdinf_psd_get_prev_offset(d), false); - vcdinf_visit_pbc (obj, 0, vcdinf_psd_get_next_offset(d), false); - vcdinf_visit_pbc (obj, 0, vcdinf_psd_get_return_offset(d), false); - vcdinf_visit_pbc (obj, 0, vcdinf_psd_get_default_offset(d), false); - vcdinf_visit_pbc (obj, 0, uint16_from_be (d->timeout_ofs), false); + ret &= vcdinf_visit_pbc (obj, 0, vcdinf_psd_get_prev_offset(d), false); + ret &= vcdinf_visit_pbc (obj, 0, vcdinf_psd_get_next_offset(d), false); + ret &= vcdinf_visit_pbc (obj, 0, vcdinf_psd_get_return_offset(d), + false); + ret &= vcdinf_visit_pbc (obj, 0, vcdinf_psd_get_default_offset(d), + false); + ret &= vcdinf_visit_pbc (obj, 0, uint16_from_be (d->timeout_ofs), + false); for (idx = 0; idx < vcdinf_get_num_selections(d); idx++) - vcdinf_visit_pbc (obj, 0, vcdinf_psd_get_offset(d, idx), - false); + ret &= vcdinf_visit_pbc (obj, 0, vcdinf_psd_get_offset(d, idx), + false); } break; @@ -280,9 +289,10 @@ vcdinf_visit_pbc (struct _vcdinf_pbc_ctx *obj, lid_t lid, unsigned int offset, default: vcd_warn ("corrupt PSD???????"); free (ofs); - return; + return false; break; } + return ret; } /*! Return the starting LBA (logical block address) for sequence diff --git a/src/input/vcd/libvcd/info_private.h b/src/input/vcd/libvcd/info_private.h index 14e947e14..a0152abae 100644 --- a/src/input/vcd/libvcd/info_private.h +++ b/src/input/vcd/libvcd/info_private.h @@ -96,14 +96,18 @@ extern "C" { /*! Calls recursive routine to populate obj->offset_list or obj->offset_x_list by going through LOT. + + Returns false if there was some error. */ - void vcdinf_visit_lot (struct _vcdinf_pbc_ctx *obj); + bool vcdinf_visit_lot (struct _vcdinf_pbc_ctx *obj); /*! Recursive routine to populate obj->offset_list or obj->offset_x_list by reading playback control entries referred to via lid. + + Returns false if there was some error. */ - void vcdinf_visit_pbc (struct _vcdinf_pbc_ctx *obj, lid_t lid, + bool vcdinf_visit_pbc (struct _vcdinf_pbc_ctx *obj, lid_t lid, unsigned int offset, bool in_lot); #ifdef __cplusplus diff --git a/src/input/vcd/libvcd/libvcd/files.h b/src/input/vcd/libvcd/libvcd/files.h index a3a8352db..91eeafad8 100644 --- a/src/input/vcd/libvcd/libvcd/files.h +++ b/src/input/vcd/libvcd/libvcd/files.h @@ -1,5 +1,5 @@ /* - $Id: files.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: files.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/libvcd/files_private.h b/src/input/vcd/libvcd/libvcd/files_private.h index b4c41b635..24e01173a 100644 --- a/src/input/vcd/libvcd/libvcd/files_private.h +++ b/src/input/vcd/libvcd/libvcd/files_private.h @@ -1,5 +1,5 @@ /* - $Id: files_private.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: files_private.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> (C) 2000 Jens B. Jorgensen <jbj1@ultraemail.net> diff --git a/src/input/vcd/libvcd/libvcd/info.h b/src/input/vcd/libvcd/libvcd/info.h index 93bc1d0e9..e90253bc7 100644 --- a/src/input/vcd/libvcd/libvcd/info.h +++ b/src/input/vcd/libvcd/libvcd/info.h @@ -168,7 +168,7 @@ extern "C" { VCDINFO_ITEM_TYPE_SEGMENT, VCDINFO_ITEM_TYPE_LID, VCDINFO_ITEM_TYPE_SPAREID2, - VCDINFO_ITEM_TYPE_NOTFOUND, + VCDINFO_ITEM_TYPE_NOTFOUND } vcdinfo_item_enum_t; typedef struct { @@ -179,7 +179,7 @@ extern "C" { typedef enum { VCDINFO_OPEN_ERROR, /* Error */ VCDINFO_OPEN_VCD, /* Is VCD of some sort */ - VCDINFO_OPEN_OTHER, /* Is not VCD but something else */ + VCDINFO_OPEN_OTHER /* Is not VCD but something else */ } vcdinfo_open_return_t; typedef struct @@ -268,11 +268,17 @@ extern "C" { /*! \brief Get default LID offset. - \return VCDINFO_INVALID_OFFSET is returned on error or if - no "return" entry. Otherwise the LID offset is returned. + + Return the LID offset associated with a the "default" entry of the + passed-in LID parameter. Note "default" entries are associated with + PSDs that are (extended) selection lists. + + \return VCDINFO_INVALID_OFFSET is returned on error, or if the LID + is not a selection list or no "default" entry. Otherwise the LID + offset is returned. */ uint16_t - vcdinfo_get_default_offset(const vcdinfo_obj_t *obj, unsigned int lid); + vcdinfo_get_default_offset(const vcdinfo_obj_t *obj, lid_t lid); /*! Return number of sector units in of an entry. 0 is returned if @@ -322,20 +328,51 @@ extern "C" { InfoVcd * vcdinfo_get_infoVcd (vcdinfo_obj_t *obj); - void * vcdinfo_get_tracksSVD (vcdinfo_obj_t *obj); - - void * vcdinfo_get_scandata (vcdinfo_obj_t *obj); + /*! + \brief Get default or multi-default LID. - void * vcdinfo_get_searchDat (vcdinfo_obj_t *obj); - - void * vcdinfo_get_pvd (vcdinfo_obj_t *obj); + Return the LID offset associated with a the "default" entry of the + passed-in LID parameter. Note "default" entries are associated + with PSDs that are (extended) selection lists. If the "default" + is a multi-default, we use entry_num to find the proper + "default" LID. Otherwise this routine is exactly like + vcdinfo_get_default_offset with the exception of requiring an + additional "entry_num" parameter. + + \return VCDINFO_INVALID_LID is returned on error, or if the LID + is not a selection list or no "default" entry. Otherwise the LID + offset is returned. + */ + lid_t + vcdinfo_get_multi_default_lid(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int selection); /*! - Get the item id for a given list ID. - VCDINFO_REJECTED_MASK is returned on error or if obj is NULL. + \brief Get default or multi-default LID offset. + + Return the LID offset associated with a the "default" entry of the + passed-in LID parameter. Note "default" entries are associated + with PSDs that are (extended) selection lists. If the "default" + is a multi-default, we use entry_num to find the proper + "default" offset. Otherwise this routine is exactly like + vcdinfo_get_default_offset with the exception of requiring an + additional "entry_num" parameter. + + \return VCDINFO_INVALID_OFFSET is returned on error, or if the LID + is not a selection list or no "default" entry. Otherwise the LID + offset is returned. */ uint16_t - vcdinfo_lid_get_itemid(const vcdinfo_obj_t *obj, lid_t lid); + vcdinfo_get_multi_default_offset(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int selection); + + void * vcdinfo_get_pvd (vcdinfo_obj_t *obj); + + void * vcdinfo_get_scandata (vcdinfo_obj_t *obj); + + void * vcdinfo_get_searchDat (vcdinfo_obj_t *obj); + + void * vcdinfo_get_tracksSVD (vcdinfo_obj_t *obj); /*! Get the LOT pointer. @@ -387,16 +424,6 @@ extern "C" { vcdinfo_get_num_tracks(const vcdinfo_obj_t *obj); /*! - \fn vcdinfo_lid_get_offset(const vcdinfo_obj_t *obj, - unsigned int entry_num); - \brief Get offset entry_num for a given LID. - \return VCDINFO_INVALID_OFFSET is returned if obj on error or obj - is NULL. Otherwise the LID offset is returned. - */ - uint16_t vcdinfo_lid_get_offset(const vcdinfo_obj_t *obj, lid_t lid, - unsigned int entry_num); - - /*! Get the VCD info list. */ VcdList *vcdinfo_get_offset_list(const vcdinfo_obj_t *obj); @@ -446,13 +473,6 @@ extern "C" { uint32_t vcdinfo_get_psd_x_size (const vcdinfo_obj_t *obj); /*! - Get the PSD Selection List Descriptor for a given lid. - False is returned if not found. - */ - bool vcdinfo_lid_get_pxd(const vcdinfo_obj_t *obj, PsdListDescriptor *pxd, - uint16_t lid); - - /*! Return a string containing the VCD publisher id with trailing blanks removed, or NULL if there is some problem in getting this. */ @@ -686,6 +706,30 @@ extern "C" { vcdinfo_lba2msf (lba_t lba, uint8_t *min, uint8_t *sec, uint8_t *frame); /*! + Get the item id for a given list ID. + VCDINFO_REJECTED_MASK is returned on error or if obj is NULL. + */ + uint16_t + vcdinfo_lid_get_itemid(const vcdinfo_obj_t *obj, lid_t lid); + + /*! + \fn vcdinfo_lid_get_offset(const vcdinfo_obj_t *obj, + unsigned int entry_num); + \brief Get offset entry_num for a given LID. + \return VCDINFO_INVALID_OFFSET is returned if obj on error or obj + is NULL. Otherwise the LID offset is returned. + */ + uint16_t vcdinfo_lid_get_offset(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int entry_num); + + /*! + Get the PSD Selection List Descriptor for a given lid. + False is returned if not found. + */ + bool vcdinfo_lid_get_pxd(const vcdinfo_obj_t *obj, PsdListDescriptor *pxd, + uint16_t lid); + + /*! Convert minutes, seconds and frame (MSF components) into a logical block address (or LBA). See also msf_to_lba which uses msf_t as its single parameter. @@ -701,11 +745,45 @@ extern "C" { const char * vcdinfo_ofs2str (const vcdinfo_obj_t *obj, unsigned int offset, bool ext); - void vcdinfo_visit_lot (vcdinfo_obj_t *obj, bool extended); + /*! + Calls recursive routine to populate obj->offset_list or obj->offset_x_list + by going through LOT. + + Returns false if there was some error. + */ + bool vcdinfo_visit_lot (vcdinfo_obj_t *obj, bool extended); bool vcdinfo_read_psd (vcdinfo_obj_t *obj); /*! + \fn vcdinfo_selection_get_lid(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int selection); + \brief Get the "default" lid of a selection for a given lid. + + Return the LID offset associated with a the selection number of the + passed-in LID parameter. + + \return VCDINFO_INVALID_LID is returned if obj on error or obj + is NULL. Otherwise the LID offset is returned. + */ + lid_t vcdinfo_selection_get_lid(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int selection); + + /*! + \fn vcdinfo_selection_get_offset(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int selection); + \brief Get offset of a selection for a given LID. + + Return the LID offset associated with a the selection number of the + passed-in LID parameter. + + \return VCDINFO_INVALID_OFFSET is returned if obj on error or obj + is NULL. Otherwise the LID offset is returned. + */ + uint16_t vcdinfo_selection_get_offset(const vcdinfo_obj_t *obj, lid_t lid, + unsigned int selection); + + /*! Change trailing blanks in str to nulls. Str has a maximum size of n characters. */ diff --git a/src/input/vcd/libvcd/libvcd/logging.h b/src/input/vcd/libvcd/libvcd/logging.h index 8c3158248..bc088ed1c 100644 --- a/src/input/vcd/libvcd/libvcd/logging.h +++ b/src/input/vcd/libvcd/libvcd/logging.h @@ -1,7 +1,8 @@ /* - $Id: logging.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: logging.h,v 1.2 2004/04/11 12:20:32 miguelfreitas 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 @@ -27,32 +28,96 @@ extern "C" { #endif /* __cplusplus */ +/** + * The different log levels supported. + */ typedef enum { - VCD_LOG_DEBUG = 1, - VCD_LOG_INFO, - VCD_LOG_WARN, - VCD_LOG_ERROR, - VCD_LOG_ASSERT + VCD_LOG_DEBUG = 1, /**< Debug-level messages - helps debug what's up. */ + VCD_LOG_INFO, /**< Informational - indicates perhaps something of + interest. */ + VCD_LOG_WARN, /**< Warning conditions - something that looks funny. */ + VCD_LOG_ERROR, /**< Error conditions - may terminate program. */ + VCD_LOG_ASSERT /**< Critical conditions - may abort program. */ } vcd_log_level_t; -void -vcd_log (vcd_log_level_t level, const char format[], ...) GNUC_PRINTF(2, 3); - +/** + * 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 vcd_log_level_t vcd_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 vcd_log_set_handler + * @see vcd_log_level_t + * + * @param level The log level. + * @param message The log message. + */ typedef void (*vcd_log_handler_t) (vcd_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 vcd_log_handler_t + * + * @param new_handler The new log handler. + * @return The previous log handler. + */ vcd_log_handler_t vcd_log_set_handler (vcd_log_handler_t new_handler); +/** + * Handle an message with the given log level + * + * @see vcd_debug + * @see vcd_info + * @see vcd_warn + * @see vcd_error + + * @param level The log level. + * @param format printf-style format string + * @param ... remaining arguments needed by format string + */ +void +vcd_log (vcd_log_level_t level, const char format[], ...) GNUC_PRINTF(2, 3); + +/** + * Handle a debugging message. + * + * @see vcd_log for a more generic routine + */ void vcd_debug (const char format[], ...) GNUC_PRINTF(1,2); +/** + * Handle an informative message. + * + * @see vcd_log for a more generic routine + */ void vcd_info (const char format[], ...) GNUC_PRINTF(1,2); +/** + * Handle a warning message. + * + * @see vcd_log for a more generic routine + */ void vcd_warn (const char format[], ...) GNUC_PRINTF(1,2); +/** + * Handle an error message. + * + * @see vcd_log for a more generic routine. + */ void vcd_error (const char format[], ...) GNUC_PRINTF(1,2); diff --git a/src/input/vcd/libvcd/libvcd/sector.h b/src/input/vcd/libvcd/libvcd/sector.h index c49f644b6..32c2cc89a 100644 --- a/src/input/vcd/libvcd/libvcd/sector.h +++ b/src/input/vcd/libvcd/libvcd/sector.h @@ -1,5 +1,5 @@ /* - $Id: sector.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: sector.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/libvcd/types.h b/src/input/vcd/libvcd/libvcd/types.h index 50d6903f7..bde56e3c7 100644 --- a/src/input/vcd/libvcd/libvcd/types.h +++ b/src/input/vcd/libvcd/libvcd/types.h @@ -1,5 +1,5 @@ /* - $Id: types.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: types.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/libvcd/version.h b/src/input/vcd/libvcd/libvcd/version.h index b8739cb8a..054519ece 100644 --- a/src/input/vcd/libvcd/libvcd/version.h +++ b/src/input/vcd/libvcd/libvcd/version.h @@ -1 +1 @@ -#define LIBVCD_VERSION "0.7.19-cdio" +#define LIBVCD_VERSION "0.7.20" diff --git a/src/input/vcd/libvcd/logging.c b/src/input/vcd/libvcd/logging.c index dce5b8668..652a8090b 100644 --- a/src/input/vcd/libvcd/logging.c +++ b/src/input/vcd/libvcd/logging.c @@ -1,7 +1,8 @@ /* - $Id: logging.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: logging.c,v 1.2 2004/04/11 12:20:32 miguelfreitas 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 @@ -30,9 +31,11 @@ #include <libvcd/logging.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" -static const char _rcsid[] = "$Id: logging.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: logging.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; + +vcd_log_level_t vcd_loglevel_default = VCD_LOG_WARN; static void default_vcd_log_handler (vcd_log_level_t level, const char message[]) @@ -40,22 +43,32 @@ default_vcd_log_handler (vcd_log_level_t level, const char message[]) switch (level) { case VCD_LOG_ERROR: - fprintf (stderr, "**ERROR: %s\n", message); - fflush (stderr); - exit (EXIT_FAILURE); + if (level >= vcd_loglevel_default) { + fprintf (stderr, "**ERROR: %s\n", message); + fflush (stderr); + exit (EXIT_FAILURE); + } break; case VCD_LOG_DEBUG: - fprintf (stdout, "--DEBUG: %s\n", message); + if (level >= vcd_loglevel_default) { + fprintf (stdout, "--DEBUG: %s\n", message); + } break; case VCD_LOG_WARN: - fprintf (stdout, "++ WARN: %s\n", message); + if (level >= vcd_loglevel_default) { + fprintf (stdout, "++ WARN: %s\n", message); + } break; case VCD_LOG_INFO: - fprintf (stdout, " INFO: %s\n", message); + if (level >= vcd_loglevel_default) { + fprintf (stdout, " INFO: %s\n", message); + } break; case VCD_LOG_ASSERT: - fprintf (stderr, "!ASSERT: %s\n", message); - fflush (stderr); + if (level >= vcd_loglevel_default) { + fprintf (stderr, "!ASSERT: %s\n", message); + fflush (stderr); + } abort (); break; default: diff --git a/src/input/vcd/libvcd/mpeg.c b/src/input/vcd/libvcd/mpeg.c index 9b453fb36..545a44fbc 100644 --- a/src/input/vcd/libvcd/mpeg.c +++ b/src/input/vcd/libvcd/mpeg.c @@ -1,5 +1,5 @@ /* - $Id: mpeg.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: mpeg.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -31,7 +31,7 @@ #include "mpeg.h" #include "util.h" -static const char _rcsid[] = "$Id: mpeg.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: mpeg.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; #define MPEG_START_CODE_PATTERN ((uint32_t) 0x00000100) #define MPEG_START_CODE_MASK ((uint32_t) 0xffffff00) @@ -1117,7 +1117,7 @@ vcd_mpeg_parse_packet (const void *_buf, unsigned buflen, bool parse_pes, break; default: - vcd_debug ("unexpected start code 0x%8.8x", code); + vcd_debug ("unexpected start code 0x%8.8x", (unsigned int) code); pos += 4; break; } diff --git a/src/input/vcd/libvcd/mpeg.h b/src/input/vcd/libvcd/mpeg.h index cfe8a294f..d57c1a36e 100644 --- a/src/input/vcd/libvcd/mpeg.h +++ b/src/input/vcd/libvcd/mpeg.h @@ -1,5 +1,5 @@ /* - $Id: mpeg.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: mpeg.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/mpeg_stream.c b/src/input/vcd/libvcd/mpeg_stream.c index 3cff87dc8..4fcc1fa8b 100644 --- a/src/input/vcd/libvcd/mpeg_stream.c +++ b/src/input/vcd/libvcd/mpeg_stream.c @@ -1,5 +1,5 @@ /* - $Id: mpeg_stream.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: mpeg_stream.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -31,14 +31,14 @@ #include <libvcd/logging.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "mpeg_stream.h" #include "bytesex.h" #include "data_structures.h" #include "mpeg.h" #include "util.h" -static const char _rcsid[] = "$Id: mpeg_stream.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: mpeg_stream.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; struct _VcdMpegSource { diff --git a/src/input/vcd/libvcd/mpeg_stream.h b/src/input/vcd/libvcd/mpeg_stream.h index 68c51cc55..14f73d928 100644 --- a/src/input/vcd/libvcd/mpeg_stream.h +++ b/src/input/vcd/libvcd/mpeg_stream.h @@ -1,5 +1,5 @@ /* - $Id: mpeg_stream.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: mpeg_stream.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/obj.h b/src/input/vcd/libvcd/obj.h index 3efa86833..55ed51462 100644 --- a/src/input/vcd/libvcd/obj.h +++ b/src/input/vcd/libvcd/obj.h @@ -1,5 +1,5 @@ /* - $Id: obj.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: obj.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/pbc.c b/src/input/vcd/libvcd/pbc.c index 4b30a34f2..b9172b41b 100644 --- a/src/input/vcd/libvcd/pbc.c +++ b/src/input/vcd/libvcd/pbc.c @@ -1,5 +1,5 @@ /* - $Id: pbc.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: pbc.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -37,13 +37,13 @@ #include <libvcd/files_private.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "bytesex.h" #include "obj.h" #include "pbc.h" #include "util.h" -static const char _rcsid[] = "$Id: pbc.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: pbc.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; static uint8_t _wtime (int seconds) diff --git a/src/input/vcd/libvcd/pbc.h b/src/input/vcd/libvcd/pbc.h index 29c6f5081..c58ea2091 100644 --- a/src/input/vcd/libvcd/pbc.h +++ b/src/input/vcd/libvcd/pbc.h @@ -1,5 +1,5 @@ /* - $Id: pbc.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: pbc.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/salloc.c b/src/input/vcd/libvcd/salloc.c index a7599ec58..d6fc41c68 100644 --- a/src/input/vcd/libvcd/salloc.c +++ b/src/input/vcd/libvcd/salloc.c @@ -1,5 +1,5 @@ /* - $Id: salloc.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: salloc.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -32,11 +32,11 @@ #include <libvcd/logging.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "salloc.h" #include "util.h" -static const char _rcsid[] = "$Id: salloc.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: salloc.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; #define VCD_SALLOC_CHUNK_SIZE 16 diff --git a/src/input/vcd/libvcd/salloc.h b/src/input/vcd/libvcd/salloc.h index 959e2f1bd..4676f9b45 100644 --- a/src/input/vcd/libvcd/salloc.h +++ b/src/input/vcd/libvcd/salloc.h @@ -1,5 +1,5 @@ /* - $Id: salloc.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: salloc.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/sector.c b/src/input/vcd/libvcd/sector.c index 19393e9cd..d072a4f17 100644 --- a/src/input/vcd/libvcd/sector.c +++ b/src/input/vcd/libvcd/sector.c @@ -1,5 +1,5 @@ /* - $Id: sector.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: sector.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> (C) 1998 Heiko Eissfeldt <heiko@colossus.escape.de> @@ -33,12 +33,12 @@ #include <libvcd/sector.h> /* Private includes */ -#include "assert.h" +#include "vcd_assert.h" #include "bytesex.h" #include "salloc.h" #include "sector_private.h" -static const char _rcsid[] = "$Id: sector.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: sector.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; static const uint8_t sync_pattern[12] = { 0x00, 0xff, 0xff, 0xff, @@ -70,116 +70,94 @@ build_address (void *buf, sectortype_t sectortype, uint32_t address) } } +/* From cdrtools-1.11a25 */ static uint32_t -build_edc (const void *in, unsigned from, unsigned upto) +build_edc(const uint8_t inout[], int from, int upto) { - const uint8_t *p = (uint8_t*)in+from; + const uint8_t *p = inout+from; uint32_t result = 0; - for (; from <= upto; from++) + upto -= from-1; + upto /= 4; + while (--upto >= 0) { result = EDC_crctable[(result ^ *p++) & 0xffL] ^ (result >> 8); - - return result; + result = EDC_crctable[(result ^ *p++) & 0xffL] ^ (result >> 8); + result = EDC_crctable[(result ^ *p++) & 0xffL] ^ (result >> 8); + result = EDC_crctable[(result ^ *p++) & 0xffL] ^ (result >> 8); + } + return (result); } +/* From cdrtools-1.11a40 */ static void -encode_L2_Q (uint8_t inout[4 + L2_RAW + 4 + 8 + L2_P + L2_Q]) +encode_L2_Q(uint8_t inout[4 + L2_RAW + 4 + 8 + L2_P + L2_Q]) { + uint8_t *dps; + uint8_t *dp; uint8_t *Q; - int i,j; - + int i, j; + Q = inout + 4 + L2_RAW + 4 + 8 + L2_P; - memset (Q, 0, L2_Q); + + dps = inout; for (j = 0; j < 26; j++) { - for (i = 0; i < 43; i++) { - uint8_t data; + uint16_t a, b; + a = b = 0; + dp = dps; + for (i = 0; i < 43; i++) { + /* LSB */ - data = inout[(j*43*2+i*2*44) % (4 + L2_RAW + 4 + 8 + L2_P)]; - if (data != 0) { - uint32_t base = rs_l12_log[data]; - - uint32_t sum = base + DQ[0][i]; - if (sum >= ((1 << RS_L12_BITS)-1)) - sum -= (1 << RS_L12_BITS)-1; - - Q[0] ^= rs_l12_alog[sum]; - - sum = base + DQ[1][i]; - if (sum >= ((1 << RS_L12_BITS)-1)) - sum -= (1 << RS_L12_BITS)-1; - - Q[26*2] ^= rs_l12_alog[sum]; - } + a ^= L2sq[i][*dp++]; + /* MSB */ - data = inout[(j*43*2+i*2*44+1) % (4 + L2_RAW + 4 + 8 + L2_P)]; - if (data != 0) { - uint32_t base = rs_l12_log[data]; - - uint32_t sum = base+DQ[0][i]; - if (sum >= ((1 << RS_L12_BITS)-1)) - sum -= (1 << RS_L12_BITS)-1; - - Q[1] ^= rs_l12_alog[sum]; - - sum = base + DQ[1][i]; - if (sum >= ((1 << RS_L12_BITS)-1)) - sum -= (1 << RS_L12_BITS)-1; - - Q[26*2+1] ^= rs_l12_alog[sum]; - } + b ^= L2sq[i][*dp]; + + dp += 2*44-1; + if (dp >= &inout[(4 + L2_RAW + 4 + 8 + L2_P)]) { + dp -= (4 + L2_RAW + 4 + 8 + L2_P); + } } + Q[0] = a >> 8; + Q[26*2] = a; + Q[1] = b >> 8; + Q[26*2+1] = b; + Q += 2; + dps += 2*43; } } static void encode_L2_P (uint8_t inout[4 + L2_RAW + 4 + 8 + L2_P]) { - uint8_t *P; - int i,j; - + uint8_t *dp; + unsigned char *P; + int i, j; + P = inout + 4 + L2_RAW + 4 + 8; - memset(P, 0, L2_P); + for (j = 0; j < 43; j++) { - for (i = 0; i < 24; i++) { - uint8_t data; - + uint16_t a; + uint16_t b; + + a = b = 0; + dp = inout; + for (i = 19; i < 43; i++) { + /* LSB */ - data = inout[i*2*43]; - if (data != 0) { - uint32_t base = rs_l12_log[data]; - - uint32_t sum = base + DP[0][i]; - if (sum >= ((1 << RS_L12_BITS)-1)) - sum -= (1 << RS_L12_BITS)-1; - - P[0] ^= rs_l12_alog[sum]; - - sum = base + DP[1][i]; - if (sum >= ((1 << RS_L12_BITS)-1)) - sum -= (1 << RS_L12_BITS)-1; - - P[43*2] ^= rs_l12_alog[sum]; - } + a ^= L2sq[i][*dp++]; + /* MSB */ - data = inout[i*2*43+1]; - if (data != 0) { - uint32_t base = rs_l12_log[data]; - - uint32_t sum = base + DP[0][i]; - if (sum >= ((1 << RS_L12_BITS)-1)) - sum -= (1 << RS_L12_BITS)-1; - - P[1] ^= rs_l12_alog[sum]; - - sum = base + DP[1][i]; - if (sum >= ((1 << RS_L12_BITS)-1)) - sum -= (1 << RS_L12_BITS)-1; - - P[43*2+1] ^= rs_l12_alog[sum]; - } + b ^= L2sq[i][*dp]; + + dp += 2*43 -1; } + P[0] = a >> 8; + P[43*2] = a; + P[1] = b >> 8; + P[43*2+1] = b; + P += 2; inout += 2; } diff --git a/src/input/vcd/libvcd/sector_private.h b/src/input/vcd/libvcd/sector_private.h index 8cdae270e..9411b5420 100644 --- a/src/input/vcd/libvcd/sector_private.h +++ b/src/input/vcd/libvcd/sector_private.h @@ -1,5 +1,5 @@ /* - $Id: sector_private.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: sector_private.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> (C) 1998 Heiko Eissfeldt <heiko@colossus.escape.de> @@ -83,165 +83,1257 @@ typedef struct { #define mode2_form2_sector_t_SIZEOF CDIO_CD_FRAMESIZE_RAW -static const uint32_t EDC_crctable[256] = { - 0x00000000l, 0x90910101l, 0x91210201l, 0x01b00300l, - 0x92410401l, 0x02d00500l, 0x03600600l, 0x93f10701l, - 0x94810801l, 0x04100900l, 0x05a00a00l, 0x95310b01l, - 0x06c00c00l, 0x96510d01l, 0x97e10e01l, 0x07700f00l, - 0x99011001l, 0x09901100l, 0x08201200l, 0x98b11301l, - 0x0b401400l, 0x9bd11501l, 0x9a611601l, 0x0af01700l, - 0x0d801800l, 0x9d111901l, 0x9ca11a01l, 0x0c301b00l, - 0x9fc11c01l, 0x0f501d00l, 0x0ee01e00l, 0x9e711f01l, - 0x82012001l, 0x12902100l, 0x13202200l, 0x83b12301l, - 0x10402400l, 0x80d12501l, 0x81612601l, 0x11f02700l, - 0x16802800l, 0x86112901l, 0x87a12a01l, 0x17302b00l, - 0x84c12c01l, 0x14502d00l, 0x15e02e00l, 0x85712f01l, - 0x1b003000l, 0x8b913101l, 0x8a213201l, 0x1ab03300l, - 0x89413401l, 0x19d03500l, 0x18603600l, 0x88f13701l, - 0x8f813801l, 0x1f103900l, 0x1ea03a00l, 0x8e313b01l, - 0x1dc03c00l, 0x8d513d01l, 0x8ce13e01l, 0x1c703f00l, - 0xb4014001l, 0x24904100l, 0x25204200l, 0xb5b14301l, - 0x26404400l, 0xb6d14501l, 0xb7614601l, 0x27f04700l, - 0x20804800l, 0xb0114901l, 0xb1a14a01l, 0x21304b00l, - 0xb2c14c01l, 0x22504d00l, 0x23e04e00l, 0xb3714f01l, - 0x2d005000l, 0xbd915101l, 0xbc215201l, 0x2cb05300l, - 0xbf415401l, 0x2fd05500l, 0x2e605600l, 0xbef15701l, - 0xb9815801l, 0x29105900l, 0x28a05a00l, 0xb8315b01l, - 0x2bc05c00l, 0xbb515d01l, 0xbae15e01l, 0x2a705f00l, - 0x36006000l, 0xa6916101l, 0xa7216201l, 0x37b06300l, - 0xa4416401l, 0x34d06500l, 0x35606600l, 0xa5f16701l, - 0xa2816801l, 0x32106900l, 0x33a06a00l, 0xa3316b01l, - 0x30c06c00l, 0xa0516d01l, 0xa1e16e01l, 0x31706f00l, - 0xaf017001l, 0x3f907100l, 0x3e207200l, 0xaeb17301l, - 0x3d407400l, 0xadd17501l, 0xac617601l, 0x3cf07700l, - 0x3b807800l, 0xab117901l, 0xaaa17a01l, 0x3a307b00l, - 0xa9c17c01l, 0x39507d00l, 0x38e07e00l, 0xa8717f01l, - 0xd8018001l, 0x48908100l, 0x49208200l, 0xd9b18301l, - 0x4a408400l, 0xdad18501l, 0xdb618601l, 0x4bf08700l, - 0x4c808800l, 0xdc118901l, 0xdda18a01l, 0x4d308b00l, - 0xdec18c01l, 0x4e508d00l, 0x4fe08e00l, 0xdf718f01l, - 0x41009000l, 0xd1919101l, 0xd0219201l, 0x40b09300l, - 0xd3419401l, 0x43d09500l, 0x42609600l, 0xd2f19701l, - 0xd5819801l, 0x45109900l, 0x44a09a00l, 0xd4319b01l, - 0x47c09c00l, 0xd7519d01l, 0xd6e19e01l, 0x46709f00l, - 0x5a00a000l, 0xca91a101l, 0xcb21a201l, 0x5bb0a300l, - 0xc841a401l, 0x58d0a500l, 0x5960a600l, 0xc9f1a701l, - 0xce81a801l, 0x5e10a900l, 0x5fa0aa00l, 0xcf31ab01l, - 0x5cc0ac00l, 0xcc51ad01l, 0xcde1ae01l, 0x5d70af00l, - 0xc301b001l, 0x5390b100l, 0x5220b200l, 0xc2b1b301l, - 0x5140b400l, 0xc1d1b501l, 0xc061b601l, 0x50f0b700l, - 0x5780b800l, 0xc711b901l, 0xc6a1ba01l, 0x5630bb00l, - 0xc5c1bc01l, 0x5550bd00l, 0x54e0be00l, 0xc471bf01l, - 0x6c00c000l, 0xfc91c101l, 0xfd21c201l, 0x6db0c300l, - 0xfe41c401l, 0x6ed0c500l, 0x6f60c600l, 0xfff1c701l, - 0xf881c801l, 0x6810c900l, 0x69a0ca00l, 0xf931cb01l, - 0x6ac0cc00l, 0xfa51cd01l, 0xfbe1ce01l, 0x6b70cf00l, - 0xf501d001l, 0x6590d100l, 0x6420d200l, 0xf4b1d301l, - 0x6740d400l, 0xf7d1d501l, 0xf661d601l, 0x66f0d700l, - 0x6180d800l, 0xf111d901l, 0xf0a1da01l, 0x6030db00l, - 0xf3c1dc01l, 0x6350dd00l, 0x62e0de00l, 0xf271df01l, - 0xee01e001l, 0x7e90e100l, 0x7f20e200l, 0xefb1e301l, - 0x7c40e400l, 0xecd1e501l, 0xed61e601l, 0x7df0e700l, - 0x7a80e800l, 0xea11e901l, 0xeba1ea01l, 0x7b30eb00l, - 0xe8c1ec01l, 0x7850ed00l, 0x79e0ee00l, 0xe971ef01l, - 0x7700f000l, 0xe791f101l, 0xe621f201l, 0x76b0f300l, - 0xe541f401l, 0x75d0f500l, 0x7460f600l, 0xe4f1f701l, - 0xe381f801l, 0x7310f900l, 0x72a0fa00l, 0xe231fb01l, - 0x71c0fc00l, 0xe151fd01l, 0xe0e1fe01l, 0x7070ff00l -}; - -static const uint8_t rs_l12_alog[255] = { - 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, - 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26, - 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, - 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, - 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, - 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23, - 0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, - 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1, - 0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, - 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0, - 0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, - 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2, - 0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, - 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce, - 0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, - 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc, - 0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, - 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54, - 0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, - 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73, - 0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, - 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff, - 0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, - 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41, - 0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, - 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6, - 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, - 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09, - 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, - 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16, - 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, - 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e -}; +/*****************************************************************/ +/* */ +/* CRC LOOKUP TABLE */ +/* ================ */ +/* The following CRC lookup table was generated automagically */ +/* by the Rocksoft^tm Model CRC Algorithm Table Generation */ +/* Program V1.0 using the following model parameters: */ +/* */ +/* Width : 4 bytes. */ +/* Poly : 0x8001801BL */ +/* Reverse : TRUE. */ +/* */ +/* For more information on the Rocksoft^tm Model CRC Algorithm, */ +/* see the document titled "A Painless Guide to CRC Error */ +/* Detection Algorithms" by Ross Williams */ +/* (ross@guest.adelaide.edu.au.). This document is likely to be */ +/* in the FTP archive "ftp.adelaide.edu.au/pub/rocksoft". */ +/* */ +/*****************************************************************/ -static const uint8_t rs_l12_log[256] = { - 0x00, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, - 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, - 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, - 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71, - 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, - 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45, - 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, - 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6, - 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, - 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88, - 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, - 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40, - 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, - 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d, - 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, - 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57, - 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, - 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18, - 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, - 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e, - 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, - 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61, - 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, - 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2, - 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, - 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6, - 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, - 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a, - 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, - 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7, - 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, - 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf +static const uint32_t EDC_crctable[256] = +{ + 0x00000000U, 0x90910101U, 0x91210201U, 0x01B00300U, + 0x92410401U, 0x02D00500U, 0x03600600U, 0x93F10701U, + 0x94810801U, 0x04100900U, 0x05A00A00U, 0x95310B01U, + 0x06C00C00U, 0x96510D01U, 0x97E10E01U, 0x07700F00U, + 0x99011001U, 0x09901100U, 0x08201200U, 0x98B11301U, + 0x0B401400U, 0x9BD11501U, 0x9A611601U, 0x0AF01700U, + 0x0D801800U, 0x9D111901U, 0x9CA11A01U, 0x0C301B00U, + 0x9FC11C01U, 0x0F501D00U, 0x0EE01E00U, 0x9E711F01U, + 0x82012001U, 0x12902100U, 0x13202200U, 0x83B12301U, + 0x10402400U, 0x80D12501U, 0x81612601U, 0x11F02700U, + 0x16802800U, 0x86112901U, 0x87A12A01U, 0x17302B00U, + 0x84C12C01U, 0x14502D00U, 0x15E02E00U, 0x85712F01U, + 0x1B003000U, 0x8B913101U, 0x8A213201U, 0x1AB03300U, + 0x89413401U, 0x19D03500U, 0x18603600U, 0x88F13701U, + 0x8F813801U, 0x1F103900U, 0x1EA03A00U, 0x8E313B01U, + 0x1DC03C00U, 0x8D513D01U, 0x8CE13E01U, 0x1C703F00U, + 0xB4014001U, 0x24904100U, 0x25204200U, 0xB5B14301U, + 0x26404400U, 0xB6D14501U, 0xB7614601U, 0x27F04700U, + 0x20804800U, 0xB0114901U, 0xB1A14A01U, 0x21304B00U, + 0xB2C14C01U, 0x22504D00U, 0x23E04E00U, 0xB3714F01U, + 0x2D005000U, 0xBD915101U, 0xBC215201U, 0x2CB05300U, + 0xBF415401U, 0x2FD05500U, 0x2E605600U, 0xBEF15701U, + 0xB9815801U, 0x29105900U, 0x28A05A00U, 0xB8315B01U, + 0x2BC05C00U, 0xBB515D01U, 0xBAE15E01U, 0x2A705F00U, + 0x36006000U, 0xA6916101U, 0xA7216201U, 0x37B06300U, + 0xA4416401U, 0x34D06500U, 0x35606600U, 0xA5F16701U, + 0xA2816801U, 0x32106900U, 0x33A06A00U, 0xA3316B01U, + 0x30C06C00U, 0xA0516D01U, 0xA1E16E01U, 0x31706F00U, + 0xAF017001U, 0x3F907100U, 0x3E207200U, 0xAEB17301U, + 0x3D407400U, 0xADD17501U, 0xAC617601U, 0x3CF07700U, + 0x3B807800U, 0xAB117901U, 0xAAA17A01U, 0x3A307B00U, + 0xA9C17C01U, 0x39507D00U, 0x38E07E00U, 0xA8717F01U, + 0xD8018001U, 0x48908100U, 0x49208200U, 0xD9B18301U, + 0x4A408400U, 0xDAD18501U, 0xDB618601U, 0x4BF08700U, + 0x4C808800U, 0xDC118901U, 0xDDA18A01U, 0x4D308B00U, + 0xDEC18C01U, 0x4E508D00U, 0x4FE08E00U, 0xDF718F01U, + 0x41009000U, 0xD1919101U, 0xD0219201U, 0x40B09300U, + 0xD3419401U, 0x43D09500U, 0x42609600U, 0xD2F19701U, + 0xD5819801U, 0x45109900U, 0x44A09A00U, 0xD4319B01U, + 0x47C09C00U, 0xD7519D01U, 0xD6E19E01U, 0x46709F00U, + 0x5A00A000U, 0xCA91A101U, 0xCB21A201U, 0x5BB0A300U, + 0xC841A401U, 0x58D0A500U, 0x5960A600U, 0xC9F1A701U, + 0xCE81A801U, 0x5E10A900U, 0x5FA0AA00U, 0xCF31AB01U, + 0x5CC0AC00U, 0xCC51AD01U, 0xCDE1AE01U, 0x5D70AF00U, + 0xC301B001U, 0x5390B100U, 0x5220B200U, 0xC2B1B301U, + 0x5140B400U, 0xC1D1B501U, 0xC061B601U, 0x50F0B700U, + 0x5780B800U, 0xC711B901U, 0xC6A1BA01U, 0x5630BB00U, + 0xC5C1BC01U, 0x5550BD00U, 0x54E0BE00U, 0xC471BF01U, + 0x6C00C000U, 0xFC91C101U, 0xFD21C201U, 0x6DB0C300U, + 0xFE41C401U, 0x6ED0C500U, 0x6F60C600U, 0xFFF1C701U, + 0xF881C801U, 0x6810C900U, 0x69A0CA00U, 0xF931CB01U, + 0x6AC0CC00U, 0xFA51CD01U, 0xFBE1CE01U, 0x6B70CF00U, + 0xF501D001U, 0x6590D100U, 0x6420D200U, 0xF4B1D301U, + 0x6740D400U, 0xF7D1D501U, 0xF661D601U, 0x66F0D700U, + 0x6180D800U, 0xF111D901U, 0xF0A1DA01U, 0x6030DB00U, + 0xF3C1DC01U, 0x6350DD00U, 0x62E0DE00U, 0xF271DF01U, + 0xEE01E001U, 0x7E90E100U, 0x7F20E200U, 0xEFB1E301U, + 0x7C40E400U, 0xECD1E501U, 0xED61E601U, 0x7DF0E700U, + 0x7A80E800U, 0xEA11E901U, 0xEBA1EA01U, 0x7B30EB00U, + 0xE8C1EC01U, 0x7850ED00U, 0x79E0EE00U, 0xE971EF01U, + 0x7700F000U, 0xE791F101U, 0xE621F201U, 0x76B0F300U, + 0xE541F401U, 0x75D0F500U, 0x7460F600U, 0xE4F1F701U, + 0xE381F801U, 0x7310F900U, 0x72A0FA00U, 0xE231FB01U, + 0x71C0FC00U, 0xE151FD01U, 0xE0E1FE01U, 0x7070FF00U, }; -static const uint8_t DQ[2][43] = { - { 0xbe, 0x60, 0xfa, 0x84, 0x3b, 0x51, 0x9f, 0x9a, - 0xc8, 0x07, 0x6f, 0xf5, 0x0a, 0x14, 0x29, 0x9c, - 0xa8, 0x4f, 0xad, 0xe7, 0xe5, 0xab, 0xd2, 0xf0, - 0x11, 0x43, 0xd7, 0x2b, 0x78, 0x08, 0xc7, 0x4a, - 0x66, 0xdc, 0xfb, 0x5f, 0xaf, 0x57, 0xa6, 0x71, - 0x4b, 0xc6, 0x19 }, - { 0x61, 0xfb, 0x85, 0x3c, 0x52, 0xa0, 0x9b, 0xc9, - 0x08, 0x70, 0xf6, 0x0b, 0x15, 0x2a, 0x9d, 0xa9, - 0x50, 0xae, 0xe8, 0xe6, 0xac, 0xd3, 0xf1, 0x12, - 0x44, 0xd8, 0x2c, 0x79, 0x09, 0xc8, 0x4b, 0x67, - 0xdd, 0xfc, 0x60, 0xb0, 0x58, 0xa7, 0x72, 0x4c, - 0xc7, 0x1a, 0x01 }, -}; -static const uint8_t DP[2][24] = { - { 0xe7, 0xe5, 0xab, 0xd2, 0xf0, 0x11, 0x43, 0xd7, - 0x2b, 0x78, 0x08, 0xc7, 0x4a, 0x66, 0xdc, 0xfb, - 0x5f, 0xaf, 0x57, 0xa6, 0x71, 0x4b, 0xc6, 0x19 }, - { 0xe6, 0xac, 0xd3, 0xf1, 0x12, 0x44, 0xd8, 0x2c, - 0x79, 0x09, 0xc8, 0x4b, 0x67, 0xdd, 0xfc, 0x60, - 0xb0, 0x58, 0xa7, 0x72, 0x4c, 0xc7, 0x1a, 0x01 }, +static const uint16_t L2sq[43][256] = { + { 0, 44719, 16707, 61420, 33414, 11305, 50117, 28010, 6417, 47038, + 22610, 63229, 39831, 13624, 56020, 29819, 12834, 40077, 29537, 56782, + 45220, 7691, 61927, 24392, 11059, 34204, 27248, 50399, 43445, 1818, + 59638, 18009, 25668, 51947, 9479, 35752, 59074, 18541, 42881, 2350, + 32085, 54266, 15382, 37561, 65491, 20860, 48784, 4159, 22118, 63689, + 5925, 47498, 54496, 31311, 38307, 15116, 20343, 57816, 3636, 41115, + 52721, 25438, 36018, 8733, 51336, 26151, 35275, 10084, 18958, 58529, + 2893, 42466, 53657, 32566, 37082, 15989, 21279, 64944, 4700, 48371, + 64170, 21509, 48105, 5446, 30764, 54915, 14703, 38848, 58299, 19732, + 41720, 3159, 24893, 53138, 8318, 36561, 44236, 611, 60815, 17184, + 11850, 32997, 28425, 49574, 46557, 7026, 62622, 23089, 14171, 39412, + 30232, 55479, 40686, 12353, 57261, 28930, 7272, 45767, 23851, 62340, + 34815, 10576, 50876, 26643, 1401, 43990, 17466, 60053, 36109, 9122, + 52302, 25313, 3979, 41252, 20168, 57447, 37916, 15027, 54623, 31728, + 5786, 47157, 22489, 63862, 48943, 4480, 65132, 20675, 15785, 37638, + 31978, 53829, 42558, 2193, 59261, 18898, 9400, 35351, 26107, 52052, + 59721, 18406, 43018, 1701, 27599, 50528, 10892, 33827, 61528, 24311, + 45339, 8116, 29406, 56433, 13213, 40242, 56171, 30148, 39464, 13447, + 23021, 63298, 6318, 46593, 49786, 27861, 33593, 11670, 16636, 61011, + 447, 44816, 17797, 60202, 1222, 43625, 50947, 27052, 34368, 10479, + 23700, 62011, 7639, 45944, 56850, 28861, 40785, 12798, 30631, 55560, + 14052, 38987, 62753, 23438, 46178, 6861, 28342, 49177, 12277, 33114, + 60464, 17055, 44403, 988, 8641, 36718, 24706, 52781, 41799, 3560, + 57860, 19627, 14544, 38527, 31123, 55100, 47702, 5369, 64277, 21946, + 5091, 48460, 21152, 64527, 37221, 16330, 53286, 32393, 2802, 42077, + 19377, 58654, 34932, 9947, 51511, 26520, + }, + { 0, 55768, 44973, 30325, 17223, 39583, 60650, 13618, 34446, 24406, + 10531, 61691, 50633, 7185, 27236, 46012, 4353, 51417, 48812, 26484, + 21062, 35742, 65003, 9267, 38799, 20055, 14370, 57850, 54472, 3344, + 31589, 41661, 8706, 64474, 36271, 21623, 24901, 47261, 52968, 5936, + 42124, 32084, 2849, 54009, 59339, 15891, 18534, 37310, 13059, 60123, + 40110, 17782, 28740, 43420, 57321, 1585, 46477, 27733, 6688, 50168, + 63178, 12050, 22887, 32959, 17412, 40412, 60329, 12913, 1859, 56987, + 43246, 28982, 49802, 6994, 27943, 46335, 33229, 22549, 11872, 63416, + 21765, 36061, 64168, 9072, 5698, 53146, 47599, 24631, 54155, 2643, + 31782, 42494, 37068, 18708, 16225, 59065, 26118, 49118, 51627, 4211, + 9537, 64665, 35564, 21300, 57480, 14672, 20261, 38653, 41935, 31255, + 3170, 54714, 30471, 44767, 55466, 370, 13376, 60824, 39917, 16949, + 61833, 10321, 24100, 34812, 45774, 27414, 7523, 50363, 34824, 20944, + 10149, 65149, 52047, 4759, 25826, 48442, 3718, 55134, 41259, 30963, + 19905, 37913, 57964, 15284, 39177, 16593, 13988, 61308, 55886, 918, + 30179, 44091, 8071, 50783, 45098, 27122, 23744, 34072, 62317, 10933, + 43530, 29650, 1447, 56447, 59725, 12437, 18144, 40760, 11396, 62812, + 33577, 23281, 28611, 46619, 49262, 6582, 47883, 25299, 5286, 52606, + 63564, 8596, 22497, 36409, 15749, 58461, 37416, 19440, 32450, 42778, + 53615, 2231, 52236, 5588, 25505, 47737, 36683, 22163, 8422, 63806, + 19074, 37722, 58671, 15607, 2501, 53277, 42600, 32688, 56589, 1237, + 29344, 43896, 40522, 18322, 12775, 59455, 23427, 33371, 62510, 11766, + 6340, 49436, 46953, 28337, 60942, 14294, 16803, 39035, 44361, 29841, + 740, 56124, 26752, 45400, 50989, 7925, 11207, 61983, 33898, 23986, + 65295, 9943, 20642, 35194, 48200, 26000, 5093, 51773, 31105, 41049, + 54828, 4084, 15046, 58142, 38251, 19635, + }, + { 0, 27757, 55514, 46263, 44457, 49604, 30067, 6430, 18255, 11042, + 40853, 62456, 60134, 34443, 12860, 24145, 36510, 58099, 22084, 14889, + 9015, 20314, 64493, 38784, 51665, 42428, 4363, 32102, 25720, 2069, + 48290, 53455, 289, 27980, 55803, 46486, 44168, 49381, 29778, 6207, + 18030, 10755, 40628, 62169, 60359, 34730, 13085, 24432, 36799, 58322, + 22373, 15112, 8726, 20091, 64204, 38561, 51440, 42141, 4138, 31815, + 25945, 2356, 48515, 53742, 578, 28207, 55960, 46837, 45035, 50054, + 30513, 7004, 17677, 10592, 40407, 61882, 59556, 33993, 12414, 23571, + 36060, 57521, 21510, 14443, 8565, 19736, 63919, 38338, 52115, 43006, + 4937, 32548, 26170, 2647, 48864, 53901, 867, 28430, 56249, 47060, + 44746, 49831, 30224, 6781, 17452, 10305, 40182, 61595, 59781, 34280, + 12639, 23858, 36349, 57744, 21799, 14666, 8276, 19513, 63630, 38115, + 51890, 42719, 4712, 32261, 26395, 2934, 49089, 54188, 1156, 26857, + 56414, 45107, 43309, 50496, 29175, 7578, 17355, 12198, 39697, 63356, + 61026, 33295, 14008, 23253, 35354, 58999, 21184, 16045, 10163, 19422, + 65385, 37636, 52565, 41272, 5519, 31202, 24828, 3217, 47142, 54347, + 1445, 27080, 56703, 45330, 43020, 50273, 28886, 7355, 17130, 11911, + 39472, 63069, 61251, 33582, 14233, 23540, 35643, 59222, 21473, 16268, + 9874, 19199, 65096, 37413, 52340, 40985, 5294, 30915, 25053, 3504, + 47367, 54634, 1734, 27307, 56860, 45681, 43887, 50946, 29621, 8152, + 16777, 11748, 39251, 62782, 60448, 32845, 13562, 22679, 34904, 58421, + 20610, 15599, 9713, 18844, 64811, 37190, 53015, 41850, 6093, 31648, + 25278, 3795, 47716, 54793, 2023, 27530, 57149, 45904, 43598, 50723, + 29332, 7929, 16552, 11461, 39026, 62495, 60673, 33132, 13787, 22966, + 35193, 58644, 20899, 15822, 9424, 18621, 64522, 36967, 52790, 41563, + 5868, 31361, 25503, 4082, 47941, 55080, + }, + { 0, 47289, 28015, 54742, 56030, 25191, 47025, 3848, 43425, 4376, + 50382, 31863, 29567, 52166, 7696, 42665, 20319, 63462, 8752, 39561, + 38273, 11576, 63726, 16471, 59134, 24135, 35729, 13096, 15392, 33945, + 20815, 59894, 40638, 9735, 62417, 19304, 17504, 64729, 10511, 37302, + 14111, 36774, 23152, 58057, 60865, 21880, 32942, 14359, 53729, 26968, + 48270, 1079, 2879, 45958, 26192, 57065, 30784, 49401, 5423, 44438, + 41630, 6695, 53233, 30536, 8545, 39384, 19470, 62647, 64447, 17158, + 38608, 11881, 35008, 12409, 58799, 23830, 21022, 60071, 16241, 34760, + 28222, 54919, 849, 48104, 46304, 3161, 55695, 24886, 51103, 32550, + 43760, 4681, 7489, 42488, 28718, 51351, 49119, 1894, 53936, 27145, + 25857, 56760, 2158, 45271, 5758, 44743, 31505, 50088, 52384, 29721, + 41423, 6518, 61568, 18489, 40431, 9558, 10846, 37607, 18225, 65416, + 22817, 57752, 13390, 36087, 33791, 15174, 61072, 22057, 17090, 64123, + 12205, 38676, 38940, 8357, 62835, 19914, 60259, 21466, 34316, 16053, + 12733, 35076, 23762, 58475, 3485, 46372, 24818, 55371, 55107, 28666, + 47660, 661, 42044, 7301, 51539, 29162, 32482, 50779, 5005, 43828, + 56444, 25797, 45331, 2474, 1698, 48667, 27597, 54132, 30173, 52580, + 6322, 40971, 44803, 6074, 49772, 31445, 37667, 11162, 65100, 18165, + 18941, 61764, 9362, 39979, 14978, 33339, 22509, 61268, 57436, 22757, + 36147, 13706, 25507, 56090, 3788, 46709, 47485, 452, 54290, 27819, + 51714, 29371, 42861, 8148, 4316, 43109, 32179, 50442, 11516, 37957, + 16787, 63786, 63010, 20123, 39757, 9204, 34141, 15844, 59442, 20619, + 24451, 59194, 13036, 35413, 64797, 17828, 36978, 10443, 10179, 40826, + 19116, 61973, 21692, 60421, 14803, 33130, 36450, 14043, 58125, 23476, + 45634, 2811, 57133, 26516, 26780, 53285, 1523, 48458, 7139, 41818, + 30348, 52789, 49469, 31108, 44114, 5355, + }, + { 0, 53971, 47547, 27496, 28523, 48568, 54992, 1027, 57046, 3077, + 26477, 46526, 45501, 25454, 2054, 56021, 41393, 29538, 6154, 51929, + 52954, 7177, 30561, 42418, 32615, 44468, 50908, 5135, 4108, 49887, + 43447, 31588, 24447, 36268, 59076, 13335, 12308, 58055, 35247, 23420, + 33193, 21370, 14354, 60097, 61122, 15377, 22393, 34218, 65230, 11293, + 18293, 38310, 37285, 17270, 10270, 64205, 8216, 62155, 39331, 19312, + 20339, 40352, 63176, 9243, 48894, 27693, 1861, 54678, 53653, 838, + 26670, 47869, 24616, 45819, 55699, 2880, 3907, 56720, 46840, 25643, + 8015, 52636, 42740, 29735, 28708, 41719, 51615, 6988, 49561, 4938, + 30754, 43761, 44786, 31777, 5961, 50586, 57729, 13138, 22586, 35561, + 36586, 23609, 14161, 58754, 16215, 60804, 34540, 21567, 20540, 33519, + 59783, 15188, 16432, 37603, 63883, 11096, 12123, 64904, 38624, 17459, + 40678, 19509, 10077, 62862, 61837, 9054, 18486, 39653, 25057, 45874, + 55386, 2697, 3722, 56409, 46897, 26082, 48951, 28132, 1676, 54367, + 53340, 655, 27111, 47924, 49232, 4739, 31211, 43832, 44859, 32232, + 5760, 50259, 7814, 52309, 42813, 30190, 29165, 41790, 51286, 6789, + 16030, 60493, 34597, 22006, 20981, 33574, 59470, 15005, 57416, 12955, + 23027, 35616, 36643, 24048, 13976, 58443, 40751, 19964, 9876, 62535, + 61508, 8855, 18943, 39724, 16889, 37674, 63554, 10897, 11922, 64577, + 38697, 17914, 57119, 3532, 26276, 46199, 45172, 25255, 2511, 56092, + 457, 54042, 47218, 27297, 28322, 48241, 55065, 1482, 32430, 44157, + 50965, 5574, 4549, 49942, 43134, 31405, 41080, 29355, 6595, 51984, + 53011, 7616, 30376, 42107, 32864, 21171, 14811, 60168, 61195, 15832, + 22192, 33891, 24246, 35941, 59149, 13790, 12765, 58126, 34918, 23221, + 8657, 62210, 39018, 19129, 20154, 40041, 63233, 9682, 65287, 11732, + 18108, 37999, 36972, 17087, 10711, 64260, + }, + { 0, 59366, 54225, 13367, 48063, 23641, 26734, 36744, 27491, 35973, + 47282, 24404, 53468, 14138, 781, 58603, 54982, 12576, 1303, 58097, + 28025, 35487, 48808, 22862, 48549, 23107, 28276, 35218, 1562, 57852, + 54731, 12845, 45457, 22135, 25152, 34214, 2606, 60872, 55807, 15897, + 56050, 15636, 2339, 61125, 24909, 34475, 45724, 21882, 26455, 32945, + 46214, 21344, 56552, 15118, 3897, 59615, 3124, 60370, 57317, 14339, + 46987, 20589, 25690, 33724, 32575, 39129, 44270, 19208, 50304, 9062, + 5969, 61623, 5212, 62394, 51085, 8299, 45027, 18437, 31794, 39892, + 43513, 19999, 31272, 40398, 4678, 62880, 49559, 9841, 49818, 9596, + 4427, 63149, 31013, 40643, 43764, 19730, 52910, 10568, 7551, 64153, + 29969, 37623, 42688, 16678, 42445, 16939, 30236, 37370, 7794, 63892, + 52643, 10821, 6248, 65422, 52153, 11359, 41943, 17457, 28678, 38880, + 29451, 38125, 41178, 18236, 51380, 12114, 7013, 64643, 65150, 6552, + 11695, 51785, 17857, 41511, 38416, 29174, 38173, 29435, 18124, 41258, + 11938, 51524, 64883, 6805, 10424, 53086, 64361, 7311, 37639, 29921, + 16598, 42800, 17371, 42045, 36874, 30700, 63588, 8066, 11189, 52307, + 20463, 43017, 39998, 31704, 62544, 5046, 10113, 49255, 9356, 50026, + 63325, 4283, 40755, 30933, 19682, 43780, 39209, 32463, 19192, 44318, + 8854, 50544, 61767, 5793, 62026, 5548, 8603, 50813, 18933, 44563, + 39460, 32194, 33089, 26279, 21136, 46454, 15102, 56600, 59695, 3785, + 59938, 3524, 14835, 56853, 20893, 46715, 33356, 26026, 22407, 45153, + 33878, 25520, 60472, 3038, 16361, 55311, 15588, 56066, 61237, 2259, + 34651, 24765, 21642, 45932, 12496, 55094, 58113, 1255, 35695, 27785, + 22718, 48984, 23475, 48213, 34914, 28548, 57356, 2026, 13277, 54331, + 58902, 496, 13767, 53793, 23977, 47695, 36472, 27038, 36213, 27283, + 24228, 47426, 14026, 53548, 58651, 765, + }, + { 0, 29554, 59108, 38294, 53717, 41639, 14129, 17475, 49079, 52421, + 22867, 10785, 28258, 7440, 34950, 64500, 25459, 4097, 34199, 63205, + 45734, 49620, 21570, 10032, 56516, 44982, 14880, 18770, 3345, 32355, + 60405, 39047, 50918, 46484, 8194, 21360, 5939, 25665, 61911, 33445, + 31057, 2595, 40885, 60615, 43140, 56310, 20064, 15634, 42389, 55015, + 17265, 12291, 29760, 1842, 37540, 57814, 6690, 26960, 64710, 36788, + 52215, 47237, 11539, 24161, 37329, 58019, 30517, 1095, 16388, 13174, + 42720, 54674, 11878, 23828, 51330, 48112, 65459, 36033, 6487, 27173, + 62114, 33232, 5190, 26420, 9079, 20485, 50579, 46817, 19733, 15975, + 44017, 55427, 40128, 61362, 31268, 2390, 22327, 9285, 45523, 49825, + 34530, 62864, 24582, 4980, 59520, 39922, 3684, 32022, 14677, 18983, + 57265, 44227, 13380, 18230, 53920, 41426, 58769, 38627, 885, 28679, + 35827, 63617, 27927, 7781, 23078, 10580, 48322, 53168, 16319, 19661, + 55643, 43561, 61034, 40216, 2190, 31740, 32776, 62330, 26348, 5534, + 20957, 8879, 46905, 50251, 23756, 12222, 47656, 51546, 36121, 65131, + 27645, 6287, 58235, 36873, 1439, 30445, 12974, 16860, 54346, 42808, + 63833, 35371, 8125, 27855, 10380, 23550, 52840, 48410, 18158, 13724, + 40970, 54136, 38715, 58441, 29151, 685, 39466, 59736, 31950, 4028, + 19455, 14477, 44315, 56937, 9629, 22255, 50041, 45067, 62536, 34618, + 4780, 25054, 44654, 56604, 18570, 15352, 32699, 3273, 39263, 59949, + 4569, 25259, 63293, 33871, 49164, 45950, 9960, 21914, 52509, 48751, + 11257, 22667, 7368, 28602, 64044, 35166, 29354, 472, 37966, 59196, + 41855, 53261, 17819, 14057, 26760, 7162, 36460, 64798, 47453, 51759, + 24505, 11467, 55103, 42061, 12763, 17065, 1770, 30104, 57358, 37756, + 3067, 30857, 60703, 40557, 55854, 43356, 15562, 20408, 46156, 51006, + 21160, 8666, 26009, 5867, 33661, 61455, + }, + { 0, 14648, 29296, 19272, 58592, 56792, 38544, 44968, 54749, 60645, + 42925, 40597, 12605, 2053, 17229, 31349, 47015, 36511, 50647, 64751, + 21319, 27263, 8503, 6159, 25210, 23362, 4106, 10546, 34458, 49058, + 62698, 52690, 29523, 19051, 291, 14363, 38835, 44683, 58819, 56571, + 42638, 40886, 54526, 60870, 17006, 31574, 12318, 2342, 50420, 64972, + 46724, 36796, 8212, 6444, 21092, 27484, 4393, 10257, 25433, 23137, + 62921, 52465, 34745, 48769, 59046, 57246, 38102, 44526, 582, 15230, + 28726, 18702, 13179, 2627, 16651, 30771, 55195, 61091, 42475, 40147, + 20737, 26681, 9073, 6729, 46561, 36057, 51089, 65193, 34012, 48612, + 63148, 53140, 24636, 22788, 4684, 11124, 38389, 44237, 59269, 57021, + 28949, 18477, 869, 14941, 16424, 30992, 12888, 2912, 42184, 40432, + 54968, 61312, 8786, 7018, 20514, 26906, 50866, 65418, 46274, 36346, + 63375, 52919, 34303, 48327, 4975, 10839, 24863, 22567, 53585, 59497, + 41761, 39449, 13745, 3209, 18369, 32505, 1164, 15796, 30460, 20420, + 57452, 55636, 37404, 43812, 26358, 24526, 5254, 11710, 33302, 47918, + 61542, 51550, 45867, 35347, 49499, 63587, 22475, 28403, 9659, 7299, + 41474, 39738, 53362, 59722, 18146, 32730, 13458, 3498, 30687, 20199, + 1455, 15511, 37695, 43527, 57679, 55415, 5541, 11421, 26581, 24301, + 61765, 51325, 33589, 47629, 49272, 63808, 45576, 35632, 9368, 7584, + 22248, 28624, 14327, 3791, 17799, 31935, 54039, 59951, 41319, 39007, + 57898, 56082, 36954, 43362, 1738, 16370, 29882, 19842, 32848, 47464, + 61984, 51992, 25776, 23944, 5824, 12280, 21901, 27829, 10237, 7877, + 45421, 34901, 49949, 64037, 17572, 32156, 14036, 4076, 41028, 39292, + 53812, 60172, 37241, 43073, 58121, 55857, 30105, 19617, 2025, 16081, + 62211, 51771, 33139, 47179, 6115, 11995, 26003, 23723, 9950, 8166, + 21678, 28054, 49726, 64262, 45134, 35190, + }, + { 0, 7197, 14394, 9255, 28788, 27753, 18510, 21587, 57576, 64757, + 55506, 50383, 37020, 35969, 43174, 46267, 56781, 49616, 58871, 63978, + 44473, 45476, 38275, 35230, 15653, 8504, 1311, 6402, 19793, 20812, + 30059, 26998, 42887, 48026, 40893, 33696, 55283, 52206, 61385, 62420, + 18287, 23410, 32597, 25416, 14107, 11014, 3873, 4924, 31306, 26199, + 17008, 24173, 2622, 5667, 12804, 11801, 39586, 34495, 41624, 48773, + 60118, 63179, 53996, 52977, 21267, 20238, 27433, 30516, 9063, 16250, + 7005, 1856, 46075, 45030, 35777, 38876, 50063, 57234, 64437, 59304, + 36574, 37571, 46820, 43769, 65194, 58039, 50832, 55949, 28214, 29227, + 22028, 18961, 7746, 607, 9848, 14949, 62612, 59529, 52398, 53427, + 34016, 39165, 48346, 41159, 5244, 2145, 11334, 12379, 25608, 30741, + 23602, 16431, 10585, 13636, 4451, 3454, 22829, 17712, 24855, 32010, + 51633, 54700, 61835, 60822, 47557, 42456, 33279, 40418, 42534, 47675, + 40476, 33281, 54866, 51791, 61032, 62069, 18126, 23251, 32500, 25321, + 14010, 10919, 3712, 4765, 31723, 26614, 17361, 24524, 2975, 6018, + 13221, 12216, 39683, 34590, 41785, 48932, 60279, 63338, 54093, 53072, + 417, 7612, 14747, 9606, 29141, 28104, 18927, 22002, 57673, 64852, + 55667, 50542, 37181, 36128, 43271, 46362, 56428, 49265, 58454, 63563, + 44056, 45061, 37922, 34879, 15492, 8345, 1214, 6307, 19696, 20717, + 29898, 26839, 62773, 59688, 52495, 53522, 34113, 39260, 48507, 41318, + 5597, 2496, 11751, 12794, 26025, 31156, 23955, 16782, 10488, 13541, + 4290, 3295, 22668, 17553, 24758, 31915, 51216, 54285, 61482, 60471, + 47204, 42105, 32862, 40003, 21170, 20143, 27272, 30357, 8902, 16091, + 6908, 1761, 45658, 44615, 35424, 38525, 49710, 56883, 64020, 58889, + 36735, 37730, 46917, 43864, 65291, 58134, 50993, 56108, 28567, 29578, + 22445, 19376, 8163, 1022, 10201, 15300, + }, + { 0, 32897, 7455, 40350, 14910, 47807, 10017, 42912, 29820, 62717, + 26979, 59874, 20034, 52931, 21341, 54236, 59640, 26745, 62951, 30054, + 53958, 21063, 53209, 20312, 40068, 7173, 33179, 282, 42682, 9787, + 48037, 15140, 52717, 19820, 53490, 20595, 63443, 30546, 60108, 27213, + 47505, 14608, 42126, 9231, 33711, 814, 40624, 7729, 9493, 42388, + 14346, 47243, 7979, 40874, 564, 33461, 20841, 53736, 19574, 52471, + 27479, 60374, 30280, 63177, 34759, 1862, 39640, 6745, 48633, 15736, + 41190, 8295, 62395, 29498, 61092, 28197, 51589, 18692, 54426, 21531, + 28479, 61374, 29216, 62113, 21761, 54656, 18462, 51359, 6979, 39874, + 1628, 34525, 8573, 41468, 15458, 48355, 18986, 51883, 22325, 55220, + 28692, 61589, 27915, 60810, 15958, 48855, 9033, 41928, 1128, 34025, + 6519, 39414, 41682, 8787, 49101, 16204, 39148, 6253, 34291, 1394, + 54958, 22063, 52145, 19248, 60560, 27665, 61839, 28942, 5011, 37650, + 3724, 36365, 10669, 43308, 13490, 46131, 26607, 59246, 31472, 64113, + 24017, 56656, 16590, 49231, 64363, 31722, 58996, 26357, 49493, 16852, + 56394, 23755, 36631, 3990, 37384, 4745, 46377, 13736, 43062, 10423, + 56958, 24319, 50017, 17376, 58432, 25793, 63839, 31198, 43522, 10883, + 46877, 14236, 36924, 4285, 36131, 3490, 13958, 46599, 11161, 43800, + 3256, 35897, 4519, 37158, 17146, 49787, 24549, 57188, 30916, 63557, + 26075, 58714, 37972, 5333, 35147, 2506, 44650, 12011, 45941, 13300, + 57384, 24745, 64823, 32182, 55830, 23191, 50953, 18312, 31916, 64557, + 25011, 57650, 18066, 50707, 23437, 56076, 2256, 34897, 5583, 38222, + 13038, 45679, 12273, 44912, 22969, 55608, 17574, 50215, 25479, 58118, + 32408, 65049, 11717, 44356, 12506, 45147, 6139, 38778, 2788, 35429, + 45377, 12736, 44126, 11487, 35711, 3070, 38496, 5857, 50493, 17852, + 55330, 22691, 65283, 32642, 57884, 25245, + }, + { 0, 52943, 33155, 20300, 7963, 53716, 40600, 20567, 15926, 61689, + 49077, 29050, 8493, 61410, 41134, 28257, 31852, 45731, 65007, 13088, + 25463, 44472, 58100, 11323, 16986, 35989, 50137, 3350, 23873, 37774, + 56514, 4621, 63704, 13847, 31067, 46996, 59331, 10508, 26176, 43151, + 50926, 2081, 18285, 35234, 55797, 5946, 22646, 38585, 33972, 19067, + 1335, 52216, 39855, 21856, 6700, 54499, 47746, 29773, 15105, 62926, + 42393, 27478, 9242, 60117, 60845, 9058, 27694, 41697, 62134, 15481, + 29493, 48634, 54171, 7508, 21016, 40151, 52352, 591, 19715, 33740, + 37313, 24334, 4162, 56973, 36570, 16405, 3929, 49558, 45047, 24888, + 11892, 57531, 45292, 32291, 12655, 65440, 5493, 56250, 38134, 23097, + 2670, 50337, 35821, 17698, 11075, 58764, 43712, 25615, 13400, 64151, + 46555, 31508, 26905, 42966, 59546, 9813, 30210, 47309, 63361, 14670, + 22319, 39392, 54956, 6243, 18484, 34555, 51639, 1912, 51015, 2440, + 18116, 34827, 55388, 5779, 23007, 38672, 63857, 14270, 30962, 46653, + 58986, 10405, 26601, 43302, 47915, 30180, 15016, 62567, 42032, 27391, + 9651, 60284, 34077, 19410, 1182, 51793, 39430, 21705, 7045, 54602, + 16287, 61776, 48668, 28883, 8324, 61003, 41223, 28616, 425, 53094, + 32810, 20197, 7858, 53373, 40753, 20990, 17395, 36156, 49776, 3263, + 23784, 37415, 56683, 5028, 32197, 45834, 64582, 12937, 25310, 44049, + 58205, 11666, 10986, 58405, 43881, 26022, 13809, 64318, 46194, 31421, + 5340, 55827, 38239, 23440, 3015, 50440, 35396, 17547, 22150, 38985, + 55045, 6602, 18845, 34642, 51230, 1745, 26800, 42623, 59699, 10236, + 30635, 47460, 63016, 14567, 53810, 7421, 21425, 40318, 52521, 998, + 19626, 33381, 60420, 8907, 28039, 41800, 62239, 15824, 29340, 48211, + 44638, 24721, 12253, 57618, 45381, 32650, 12486, 65033, 36968, 24231, + 4587, 57124, 36723, 16828, 3824, 49215, + }, + { 0, 59880, 53197, 9765, 33671, 27247, 19530, 42402, 6931, 62203, + 54494, 15670, 39060, 29052, 22361, 48817, 13862, 57294, 63979, 4099, + 46497, 23625, 31340, 37764, 11573, 50397, 58104, 2832, 44722, 18266, + 24959, 34967, 27724, 34212, 41857, 19049, 61387, 1571, 8198, 51694, + 30559, 40631, 47250, 20858, 62680, 7472, 15125, 54013, 23146, 45954, + 38311, 31823, 55789, 12293, 5664, 65480, 16761, 43153, 36532, 26460, + 49918, 11030, 3379, 58587, 55448, 12656, 5973, 65213, 23327, 45815, + 38098, 32058, 50059, 10851, 3142, 58798, 16396, 43492, 36801, 26153, + 61118, 1878, 8563, 51355, 27961, 34001, 41716, 19228, 62893, 7237, + 14944, 54152, 30250, 40898, 47591, 20495, 46292, 23868, 31513, 37617, + 14163, 57019, 63646, 4470, 44999, 17967, 24586, 35298, 11328, 50600, + 58253, 2661, 33522, 27418, 19775, 42199, 373, 59549, 52920, 10064, + 39393, 28681, 22060, 49092, 6758, 62350, 54699, 15427, 44333, 17605, + 25312, 35592, 11946, 51010, 57703, 2191, 46654, 24534, 31219, 36891, + 13753, 56401, 64116, 5020, 39691, 29411, 21702, 48430, 6284, 61796, + 55105, 16041, 32792, 27120, 20437, 42557, 927, 60023, 52306, 9658, + 49505, 10377, 3756, 59204, 17126, 43790, 36139, 25795, 55922, 13210, + 5567, 64599, 23029, 45085, 38456, 32720, 63303, 7855, 14474, 53602, + 29888, 40232, 47885, 21221, 60500, 1468, 9113, 51825, 28627, 34363, + 40990, 18934, 30133, 40029, 47736, 21392, 63026, 8154, 14847, 53271, + 28326, 34638, 41323, 18563, 60705, 1225, 8940, 51972, 17299, 43643, + 35934, 26038, 49172, 10748, 4057, 58929, 22656, 45416, 38733, 32421, + 56071, 13039, 5322, 64802, 6649, 61457, 54836, 16348, 39550, 29590, + 21939, 48219, 746, 60162, 52519, 9423, 33133, 26757, 20128, 42824, + 12255, 50743, 57362, 2554, 44120, 17840, 25493, 35453, 13516, 56612, + 64257, 4841, 46923, 24227, 30854, 37230, + }, + { 0, 29813, 59626, 40095, 52681, 47548, 9507, 20822, 34703, 62458, + 28517, 6928, 19014, 15923, 41644, 55001, 4867, 26486, 64489, 36764, + 57034, 43711, 13856, 16981, 38028, 57593, 31846, 2067, 22853, 11568, + 45487, 50650, 9734, 21107, 52972, 47769, 60367, 40890, 805, 30544, + 41353, 54780, 18787, 15638, 27712, 6197, 33962, 61663, 13573, 16752, + 56815, 43418, 63692, 36025, 4134, 25683, 45706, 50943, 23136, 11797, + 32579, 2870, 38825, 58332, 19468, 14457, 42214, 53395, 33221, 62896, + 26927, 7514, 52099, 49142, 9065, 22300, 1610, 29247, 61088, 39637, + 24335, 11130, 47077, 50064, 37574, 59059, 31276, 3673, 55424, 44277, + 12394, 17439, 5449, 24892, 64931, 35286, 27146, 7807, 33504, 63125, + 42947, 54198, 20265, 15196, 60805, 39408, 1391, 28954, 8268, 21561, + 51366, 48339, 30985, 3452, 37347, 58774, 46272, 49333, 23594, 10335, + 65158, 35571, 5740, 25113, 13135, 18234, 56229, 45008, 38936, 60525, + 28914, 1159, 21969, 8612, 48443, 51534, 8087, 27618, 63357, 33544, + 53854, 42539, 15028, 20161, 35611, 65390, 25585, 6020, 18130, 12967, + 44600, 55885, 3220, 30945, 58494, 36875, 49501, 46376, 10679, 24002, + 48670, 51819, 22260, 8833, 29655, 1954, 39741, 61256, 14737, 19940, + 53627, 42254, 62552, 32813, 7346, 26823, 44317, 55656, 17911, 12674, + 24788, 5281, 34878, 64587, 10898, 24295, 49784, 46605, 59227, 37678, + 4017, 31684, 54292, 41057, 15614, 18571, 6621, 28072, 61751, 34114, + 21403, 10222, 47985, 52996, 40530, 59943, 30392, 717, 50967, 45922, + 12285, 23432, 2782, 32427, 57908, 38465, 16536, 13549, 43122, 56327, + 36177, 63780, 26043, 4558, 61970, 34407, 6904, 28301, 16347, 19374, + 55089, 41796, 30109, 488, 40311, 59650, 47188, 52257, 20670, 9419, + 57617, 38244, 2555, 32142, 11480, 22701, 50226, 45127, 26270, 4843, + 36468, 64001, 43863, 57122, 17341, 14280, + }, + { 0, 46261, 30071, 49602, 60142, 24155, 40857, 11052, 51649, 32116, + 48310, 2051, 9007, 38810, 22104, 58093, 36767, 15146, 64232, 20061, + 25969, 53700, 4102, 42163, 18014, 62187, 13097, 34716, 44208, 6149, + 55751, 28018, 803, 46998, 30292, 49889, 59853, 23928, 40122, 10255, + 51938, 32343, 49045, 2848, 8204, 38073, 21883, 57806, 36028, 14345, + 63947, 19838, 26194, 53991, 4901, 42896, 17789, 61896, 12298, 33983, + 44947, 6950, 56036, 28241, 1606, 45811, 29489, 51076, 60584, 22557, + 39391, 11626, 53127, 31538, 47856, 3653, 9577, 37340, 20510, 58539, + 35289, 15724, 64686, 18459, 25399, 55170, 5696, 41717, 16408, 62637, + 13679, 33242, 43766, 7747, 57217, 27444, 1381, 45520, 28690, 50343, + 61323, 23358, 39676, 11849, 52388, 30737, 47571, 3430, 9802, 37631, + 21309, 59272, 35578, 15951, 65421, 19256, 24596, 54433, 5475, 41430, + 17211, 63374, 13900, 33529, 43477, 7520, 56482, 26647, 3212, 47161, + 31227, 52558, 58978, 21207, 37653, 10144, 50509, 29176, 45114, 1167, + 12195, 39702, 23252, 61025, 33555, 14246, 63076, 17105, 27133, 56648, + 7306, 43071, 19154, 65127, 16293, 35600, 41020, 5257, 54603, 25086, + 4015, 47898, 31448, 52845, 58689, 20980, 36918, 9347, 50798, 29403, + 45849, 1964, 11392, 38965, 23031, 60738, 32816, 13445, 62791, 16882, + 27358, 56939, 8105, 43804, 18929, 64836, 15494, 34867, 41759, 6058, + 54888, 25309, 2762, 48767, 32701, 51976, 57380, 21649, 38227, 8678, + 49931, 30654, 46716, 713, 10725, 40272, 23698, 59431, 34133, 12768, + 61474, 17559, 28603, 56078, 6860, 44665, 19604, 63521, 14819, 36182, + 42618, 4815, 54029, 26552, 2537, 48476, 31902, 51243, 58119, 22450, + 38512, 8901, 49192, 29853, 46431, 490, 10950, 40563, 24497, 60164, + 34422, 12995, 62209, 18356, 27800, 55341, 6639, 44378, 20407, 64258, + 15040, 36469, 42329, 4588, 53294, 25755, + }, + { 0, 54485, 46519, 24930, 30579, 41894, 49860, 5649, 61158, 14899, + 23377, 36740, 39317, 19776, 11298, 63735, 49617, 5380, 29798, 41139, + 46754, 25207, 789, 55232, 12087, 64482, 39552, 20053, 22596, 35985, + 60915, 14630, 40895, 19306, 10760, 65245, 59596, 15385, 23931, 35246, + 29017, 42380, 50414, 4155, 1578, 54015, 45981, 26440, 24174, 35515, + 60377, 16140, 10525, 64968, 40106, 18559, 45192, 25693, 1343, 53738, + 51195, 4910, 29260, 42649, 9059, 63414, 38612, 16897, 21520, 32965, + 57767, 13682, 52613, 6480, 30770, 44263, 47862, 28195, 3905, 56212, + 58034, 13927, 22277, 33744, 38337, 16660, 8310, 62627, 3156, 55425, + 47587, 27958, 31527, 45042, 52880, 6725, 48348, 26633, 2411, 56766, + 52143, 8058, 32280, 43725, 21050, 34543, 59277, 13144, 9545, 61852, + 37118, 17451, 32013, 43480, 51386, 7279, 2686, 57003, 49097, 27420, + 37867, 18238, 9820, 62089, 58520, 12365, 20783, 34298, 18118, 37395, + 62321, 10148, 12725, 58720, 33794, 20695, 43040, 31989, 7575, 51522, + 57171, 2950, 27364, 48689, 34583, 21442, 12960, 58997, 61540, 9393, + 17875, 37126, 27121, 48420, 56390, 2195, 7810, 51799, 43829, 32736, + 55673, 3500, 27854, 47131, 44554, 31455, 7101, 53096, 14239, 58186, + 33320, 22269, 16620, 37945, 62811, 8590, 6312, 52349, 44319, 31178, + 28635, 47886, 55916, 3769, 63054, 8859, 17401, 38700, 33085, 21992, + 13450, 57439, 26021, 45424, 53266, 1223, 4822, 50691, 42849, 29620, + 35651, 24470, 16116, 59937, 64560, 10469, 18823, 40274, 42100, 28833, + 4547, 50454, 54023, 2002, 26288, 45669, 19090, 40519, 65317, 11248, + 15841, 59700, 34902, 23683, 64026, 11983, 20397, 39800, 36201, 22972, + 14558, 60427, 5372, 49193, 41291, 30110, 25487, 46938, 54840, 749, + 15307, 61214, 36476, 23209, 19640, 39021, 63759, 11738, 54573, 504, + 24730, 46159, 41566, 30347, 6121, 49980, + }, + { 0, 58597, 54743, 12594, 47027, 21334, 25188, 34433, 29563, 38814, + 42668, 16969, 50376, 8237, 4383, 62970, 59126, 531, 13089, 55236, + 20805, 46496, 33938, 24695, 38285, 29032, 16474, 42175, 8766, 50907, + 63465, 4876, 53745, 13588, 1062, 57539, 26178, 33447, 45973, 22384, + 41610, 18031, 30557, 37816, 5433, 61916, 49390, 9227, 14087, 54242, + 58064, 1589, 32948, 25681, 21859, 45446, 17532, 41113, 37291, 30030, + 62415, 5930, 9752, 49917, 49151, 23322, 27176, 36557, 2124, 60585, + 56731, 14718, 52356, 10337, 6483, 64950, 31543, 40914, 44768, 18949, + 22793, 48620, 36062, 26683, 61114, 2655, 15213, 57224, 10866, 52887, + 65445, 6976, 40385, 31012, 18454, 44275, 28174, 35563, 48089, 24380, + 55741, 15704, 3178, 59535, 7541, 63888, 51362, 11335, 43718, 20003, + 32529, 39924, 35064, 27677, 23855, 47562, 16203, 56238, 60060, 3705, + 64387, 8038, 11860, 51889, 19504, 43221, 39399, 32002, 25571, 34566, + 46644, 21201, 54352, 12469, 391, 58722, 4248, 62589, 50511, 8618, + 42795, 17358, 29436, 38425, 34069, 25072, 20674, 46119, 12966, 54851, + 59249, 916, 63086, 4747, 9145, 51036, 16861, 42296, 37898, 28911, + 45586, 22263, 26565, 33568, 1441, 57668, 53366, 13459, 49513, 9612, + 5310, 61531, 30426, 37439, 41741, 18408, 21732, 45057, 33075, 26070, + 58199, 1970, 13952, 53861, 10143, 50042, 62024, 5805, 36908, 29897, + 17915, 41246, 56348, 14585, 2507, 60718, 27567, 36682, 48760, 23197, + 44903, 19330, 31408, 40533, 6356, 64561, 52483, 10726, 15082, 56847, + 61245, 3032, 36185, 27068, 22670, 48235, 18833, 44404, 40006, 30883, + 65058, 6855, 11253, 53008, 3565, 59656, 55354, 15583, 47710, 24251, + 28553, 35692, 32406, 39539, 43841, 20388, 51493, 11712, 7410, 63511, + 60187, 4094, 16076, 55849, 23720, 47181, 35199, 28058, 39008, 31877, + 19895, 43346, 12243, 52022, 64004, 7905, + }, + { 0, 64765, 58855, 6426, 55251, 11054, 12852, 52937, 46011, 20294, + 22108, 43681, 25704, 39061, 33167, 32114, 31595, 34710, 40588, 25201, + 44216, 20549, 18783, 46498, 51408, 13357, 11575, 53706, 7939, 58366, + 64228, 1561, 63190, 2603, 4913, 61388, 8453, 56824, 50402, 14367, + 17773, 47504, 41098, 23671, 37566, 28227, 30553, 35748, 36285, 28992, + 26714, 38055, 23150, 42643, 49033, 17268, 15878, 49915, 56289, 10012, + 59861, 5416, 3122, 61647, 61873, 3404, 5206, 59563, 9826, 55967, + 50053, 16248, 16906, 48887, 42989, 23312, 38361, 26916, 28734, 36035, + 35546, 30247, 28477, 37824, 23817, 41460, 47342, 17427, 14689, 50588, + 56454, 8315, 61106, 4687, 2901, 63400, 1895, 64410, 57984, 7805, + 53428, 11337, 13651, 51630, 46300, 18465, 20795, 44486, 25359, 40946, + 34536, 31253, 31756, 33009, 39403, 25878, 43999, 22306, 20024, 45765, + 53175, 13130, 10832, 54957, 6244, 58521, 64899, 382, 65407, 898, + 6808, 58981, 10412, 54353, 52555, 12726, 19652, 45113, 43299, 21982, + 39703, 26602, 32496, 33293, 33812, 30953, 25075, 40206, 21447, 44858, + 46624, 19165, 14255, 52050, 53832, 11957, 57468, 7297, 1435, 63846, + 2473, 62804, 60494, 4275, 56954, 8839, 15261, 51040, 47634, 18159, + 24565, 41736, 28097, 37180, 34854, 29915, 29378, 36415, 38693, 27608, + 42257, 23020, 16630, 48139, 49529, 15748, 9374, 55395, 5802, 59991, + 62285, 4016, 3790, 62003, 60201, 6100, 55581, 9696, 15610, 49159, + 48501, 16776, 22674, 42095, 27302, 38491, 36673, 29628, 30117, 35160, + 36930, 27839, 41590, 24203, 18321, 47980, 50718, 15075, 9209, 57092, + 4557, 60720, 62506, 2263, 63512, 1253, 7679, 57602, 12235, 54070, + 51756, 14033, 19363, 46942, 44612, 21177, 40048, 24717, 31127, 34154, + 33651, 32654, 26260, 39529, 21664, 43101, 45383, 19898, 12488, 52277, + 54575, 10706, 59163, 7142, 764, 65025, + }, + { 0, 61681, 65023, 3342, 59363, 5906, 6684, 60141, 54235, 9002, + 11812, 57045, 13368, 50377, 51655, 14646, 48043, 19290, 18004, 46757, + 23624, 44217, 41399, 20806, 26736, 39041, 38287, 25982, 36755, 32610, + 29292, 33437, 27467, 39866, 38580, 26181, 36008, 31833, 29015, 33190, + 47248, 18529, 17775, 46494, 24435, 44930, 41612, 21117, 53472, 8209, + 11551, 56814, 14083, 51186, 51964, 14861, 827, 62410, 65220, 3637, + 58584, 5161, 6439, 59862, 54934, 9831, 11113, 56216, 12661, 49540, + 52362, 15483, 1357, 62908, 63666, 2115, 58030, 4703, 8017, 61344, + 27965, 40396, 37058, 24627, 35550, 31279, 30497, 34768, 48870, 19991, + 17177, 46056, 22789, 43508, 42234, 21515, 48605, 19756, 16418, 45267, + 23102, 43727, 42945, 22320, 28166, 40695, 37881, 25352, 35301, 30996, + 29722, 34027, 1654, 63111, 64393, 2936, 57749, 4452, 7274, 60571, + 54701, 9564, 10322, 55459, 12878, 49855, 53169, 16192, 45361, 16832, + 19662, 48191, 22226, 42531, 43821, 23516, 25322, 37403, 40725, 28644, + 34057, 30200, 30966, 34823, 2714, 64107, 63333, 1940, 60793, 7560, + 4230, 57463, 55617, 10672, 9406, 54351, 16034, 52819, 50013, 13228, + 55930, 10891, 10117, 55156, 15769, 52584, 49254, 12439, 2465, 63824, + 62558, 1199, 60994, 7859, 5053, 58188, 25041, 37152, 39982, 27871, + 34354, 30403, 31693, 35644, 45578, 17147, 20469, 48900, 21993, 42264, + 43030, 22759, 26535, 38742, 39512, 27305, 32836, 28853, 32187, 36170, + 46204, 17549, 18819, 47474, 21407, 41838, 44640, 24209, 56332, 11517, + 8691, 53506, 15343, 51998, 50704, 14049, 4055, 65318, 61992, 729, + 59444, 6341, 5579, 58682, 3308, 64541, 61715, 482, 60175, 7166, + 5872, 58881, 57143, 12230, 8904, 53817, 14548, 51237, 50475, 13786, + 46919, 18358, 19128, 47689, 20644, 41045, 44379, 23978, 25756, 37997, + 39267, 27026, 33663, 29582, 32384, 36465, + }, + { 0, 63223, 61939, 1796, 65531, 2316, 3592, 63743, 58347, 5404, + 4632, 58607, 7184, 60135, 60899, 6932, 56267, 11580, 10808, 56527, + 9264, 53959, 54723, 9012, 14368, 52951, 51667, 16164, 51163, 12588, + 13864, 49375, 43915, 23932, 23160, 44175, 21616, 41607, 42371, 21364, + 18528, 48791, 47507, 20324, 47003, 16748, 18024, 45215, 28736, 34487, + 33203, 30532, 36795, 31052, 32328, 35007, 37803, 25948, 25176, 38063, + 27728, 39591, 40355, 27476, 19211, 48636, 47864, 19471, 46320, 16903, + 17667, 46068, 43232, 24087, 22803, 45028, 22299, 41452, 42728, 20511, + 37056, 26167, 24883, 38852, 28475, 39372, 40648, 26687, 29483, 34268, + 33496, 29743, 36048, 31271, 32035, 35796, 57472, 5751, 4467, 59268, + 8059, 59788, 61064, 6271, 875, 62876, 62104, 1135, 64656, 2663, + 3427, 64404, 15179, 52668, 51896, 15439, 50352, 12871, 13635, 50100, + 55456, 11863, 10579, 57252, 10075, 53676, 54952, 8287, 38422, 24801, + 26597, 37138, 27117, 40730, 38942, 28393, 30205, 33546, 33806, 29433, + 35334, 31985, 31733, 36098, 19933, 47914, 48174, 19161, 45606, 17617, + 17365, 46370, 44598, 22721, 24517, 43314, 20941, 42810, 41022, 22217, + 15773, 52074, 52334, 15001, 49766, 13457, 13205, 50530, 56950, 10369, + 12165, 55666, 8589, 55162, 53374, 9865, 58966, 4257, 6053, 57682, + 6573, 61274, 59486, 7849, 1469, 62282, 62542, 697, 64070, 3249, + 2997, 64834, 56605, 11242, 11502, 55833, 8934, 54289, 54037, 9698, + 16118, 51201, 52997, 14834, 49421, 14330, 12542, 50697, 1750, 61473, + 63269, 466, 63789, 4058, 2270, 65065, 58685, 5066, 5326, 57913, + 6854, 60465, 60213, 7618, 30358, 32865, 34661, 29074, 35181, 32666, + 30878, 36457, 38269, 25482, 25742, 37497, 27270, 40049, 39797, 28034, + 44381, 23466, 23726, 43609, 21158, 42065, 41813, 21922, 20150, 47169, + 48965, 18866, 45389, 18362, 16574, 46665, + }, + { 0, 62964, 63477, 513, 62455, 1539, 1026, 61942, 64499, 3591, + 3078, 63986, 2052, 65008, 65521, 2565, 60411, 7695, 7182, 59898, + 6156, 60920, 61433, 6669, 4104, 58876, 59389, 4617, 58367, 5643, + 5130, 57854, 52203, 15903, 15390, 51690, 14364, 52712, 53225, 14877, + 12312, 50668, 51181, 12825, 50159, 13851, 13338, 49646, 8208, 54756, + 55269, 8721, 54247, 9747, 9234, 53734, 56291, 11799, 11286, 55778, + 10260, 56800, 57313, 10773, 35787, 32319, 31806, 35274, 30780, 36296, + 36809, 31293, 28728, 34252, 34765, 29241, 33743, 30267, 29754, 33230, + 24624, 38340, 38853, 25137, 37831, 26163, 25650, 37318, 39875, 28215, + 27702, 39362, 26676, 40384, 40897, 27189, 16416, 46548, 47061, 16929, + 46039, 17955, 17442, 45526, 48083, 20007, 19494, 47570, 18468, 48592, + 49105, 18981, 43995, 24111, 23598, 43482, 22572, 44504, 45017, 23085, + 20520, 42460, 42973, 21033, 41951, 22059, 21546, 41438, 2955, 65151, + 64638, 2442, 63612, 3464, 3977, 64125, 61560, 1420, 1933, 62073, + 911, 63099, 62586, 398, 57456, 5508, 6021, 57969, 4999, 58995, + 58482, 4486, 7043, 61047, 60534, 6530, 59508, 7552, 8065, 60021, + 49248, 13716, 14229, 49761, 13207, 50787, 50274, 12694, 15251, 52839, + 52326, 14738, 51300, 15760, 16273, 51813, 11163, 56943, 56430, 10650, + 55404, 11672, 12185, 55917, 53352, 9628, 10141, 53865, 9119, 54891, + 54378, 8606, 32832, 30132, 30645, 33345, 29623, 34371, 33858, 29110, + 31667, 36423, 35910, 31154, 34884, 32176, 32689, 35397, 27579, 40527, + 40014, 27066, 38988, 28088, 28601, 39501, 36936, 26044, 26557, 37449, + 25535, 38475, 37962, 25022, 19371, 48735, 48222, 18858, 47196, 19880, + 20393, 47709, 45144, 17836, 18349, 45657, 17327, 46683, 46170, 16814, + 41040, 21924, 22437, 41553, 21415, 42579, 42066, 20902, 23459, 44631, + 44118, 22946, 43092, 23968, 24481, 43605, + }, + { 0, 31355, 62710, 36493, 62961, 36746, 263, 31612, 63487, 36228, + 777, 31090, 526, 30837, 63224, 35971, 62435, 35224, 1813, 32110, + 1554, 31849, 62180, 34975, 1052, 32359, 61674, 35473, 61933, 35734, + 1307, 32608, 64475, 33184, 3885, 30038, 3626, 29777, 64220, 32935, + 3108, 30303, 63698, 33449, 63957, 33710, 3363, 30552, 2104, 29251, + 64718, 34485, 64969, 34738, 2367, 29508, 65479, 34236, 2865, 29002, + 2614, 28749, 65216, 33979, 60331, 37328, 8029, 25894, 7770, 25633, + 60076, 37079, 7252, 26159, 59554, 37593, 59813, 37854, 7507, 26408, + 6216, 25139, 60606, 38597, 60857, 38850, 6479, 25396, 61367, 38348, + 6977, 24890, 6726, 24637, 61104, 38091, 4208, 27147, 58502, 40701, + 58753, 40954, 4471, 27404, 59279, 40436, 4985, 26882, 4734, 26629, + 59016, 40179, 58259, 39400, 5989, 27934, 5730, 27673, 58004, 39151, + 5228, 28183, 57498, 39649, 57757, 39910, 5483, 28432, 52043, 45360, + 16317, 17862, 16058, 17601, 51788, 45111, 15540, 18127, 51266, 45625, + 51525, 45886, 15795, 18376, 14504, 17107, 52318, 46629, 52569, 46882, + 14767, 17364, 53079, 46380, 15265, 16858, 15014, 16605, 52816, 46123, + 12432, 19179, 50278, 48669, 50529, 48922, 12695, 19436, 51055, 48404, + 13209, 18914, 12958, 18661, 50792, 48147, 50035, 47368, 14213, 19966, + 13954, 19705, 49780, 47119, 13452, 20215, 49274, 47617, 49533, 47878, + 13707, 20464, 8416, 23195, 54294, 44653, 54545, 44906, 8679, 23452, + 55071, 44388, 9193, 22930, 8942, 22677, 54808, 44131, 54019, 43384, + 10229, 23950, 9970, 23689, 53764, 43135, 9468, 24199, 53258, 43633, + 53517, 43894, 9723, 24448, 56123, 41280, 12237, 21942, 11978, 21681, + 55868, 41031, 11460, 22207, 55346, 41545, 55605, 41806, 11715, 22456, + 10456, 21155, 56366, 42581, 56617, 42834, 10719, 21412, 57127, 42332, + 11217, 20906, 10966, 20653, 56864, 42075, + }, + { 0, 46002, 31609, 51403, 63218, 17728, 36235, 15929, 61945, 16971, + 35456, 14642, 1803, 46265, 31858, 53184, 65519, 19549, 33942, 14116, + 2333, 47791, 29284, 49622, 3606, 48548, 30063, 50909, 63716, 19286, + 33693, 12335, 58307, 20593, 39098, 11016, 5425, 42627, 28232, 56826, + 4666, 41352, 26947, 56049, 58568, 22394, 40881, 11267, 7212, 44958, + 26453, 54503, 60126, 22892, 37287, 8725, 60885, 24167, 38572, 9502, + 6951, 43157, 24670, 54252, 56219, 26665, 41186, 4944, 11625, 40667, + 22032, 58786, 10850, 39376, 20763, 58025, 56464, 28450, 42985, 5211, + 9332, 38854, 24333, 60607, 53894, 24884, 43519, 6733, 54669, 26175, + 44788, 7494, 9087, 37069, 22534, 60340, 14424, 35818, 17185, 61587, + 52906, 32024, 46547, 1633, 51617, 31251, 45784, 362, 16211, 36065, + 17450, 63384, 51127, 29701, 48334, 3964, 12613, 33527, 19004, 63886, + 13902, 34300, 19767, 65157, 49340, 29454, 48069, 2167, 43819, 6297, + 53330, 25568, 24025, 61035, 9888, 38162, 23250, 59744, 8619, 37401, + 44064, 8082, 55129, 25835, 21700, 59254, 12221, 39951, 41526, 4484, + 55631, 27389, 42301, 5775, 56900, 28150, 21455, 57469, 10422, 39684, + 18664, 64346, 13201, 32803, 48666, 3496, 50531, 30417, 47377, 2723, + 49768, 29146, 20451, 64593, 13466, 34600, 46855, 1205, 52350, 32716, + 16885, 62023, 14988, 35134, 18174, 62796, 15751, 36405, 45068, 958, + 52085, 30919, 28848, 49922, 3017, 47227, 34370, 13808, 64827, 20105, + 33097, 13051, 64048, 18818, 30651, 50185, 3266, 49008, 36703, 15597, + 62502, 18324, 31149, 51743, 724, 45414, 32422, 52500, 1503, 46701, + 34900, 15334, 62253, 16543, 37747, 8385, 59402, 23480, 25985, 54835, + 7928, 44362, 25226, 53560, 6643, 43585, 38008, 10186, 61185, 23731, + 27804, 57134, 6117, 42071, 39534, 10716, 57623, 21157, 40293, 11991, + 58908, 21934, 27543, 55333, 4334, 41820, + }, + { 0, 22872, 45744, 60392, 31101, 8229, 52173, 37525, 62202, 43938, + 16458, 6418, 35719, 53983, 14647, 24687, 63977, 41137, 19289, 4609, + 32916, 55756, 12836, 27516, 2835, 21067, 47523, 57595, 29294, 11062, + 49374, 39302, 61391, 46743, 23935, 1063, 38578, 53226, 9218, 32090, + 7477, 17517, 44933, 63197, 25672, 15632, 55032, 36768, 5670, 20350, + 42134, 64974, 28507, 13827, 56811, 33971, 58588, 48516, 22124, 3892, + 40353, 50425, 12049, 30281, 50051, 39643, 28979, 10347, 47870, 58278, + 2126, 20758, 12665, 26657, 33737, 55953, 18436, 4444, 64180, 41964, + 14954, 25394, 35034, 53634, 17175, 6735, 61863, 43263, 51344, 37320, + 31264, 9080, 45549, 59573, 861, 23045, 11340, 29972, 40700, 51108, + 21809, 3177, 59265, 48857, 57014, 34798, 27654, 13662, 42955, 65171, + 5499, 19491, 54693, 36093, 26389, 15949, 44248, 62848, 7784, 18224, + 10079, 32263, 38383, 52407, 24098, 1914, 60562, 46538, 39707, 49731, + 10667, 28915, 57958, 47934, 20694, 2446, 27105, 12473, 56145, 33289, + 4252, 18884, 41516, 64372, 25330, 15274, 53314, 35098, 7055, 17111, + 43327, 61543, 36872, 51536, 8888, 31712, 59765, 45101, 23493, 669, + 29908, 11660, 50788, 40764, 3497, 21745, 48921, 58945, 34350, 57206, + 13470, 28102, 65363, 42507, 19939, 5307, 36157, 54373, 16269, 26325, + 62528, 44312, 18160, 8104, 32711, 9887, 52599, 37935, 1722, 24546, + 46090, 60754, 22680, 448, 59944, 45936, 8677, 30909, 37717, 51725, + 43618, 62266, 6354, 16778, 54047, 35399, 25007, 14583, 41329, 63529, + 5057, 19097, 55308, 33108, 27324, 13284, 21387, 2771, 57659, 47203, + 10998, 29614, 38982, 49438, 46935, 60943, 1511, 23743, 52778, 38770, + 31898, 9666, 17837, 7413, 63261, 44613, 15568, 25992, 36448, 55096, + 20158, 6118, 64526, 42326, 14275, 28315, 34163, 56363, 48196, 58652, + 3828, 22444, 50489, 40033, 30601, 11985, + }, + { 0, 11309, 22618, 29815, 45236, 40089, 59630, 50371, 32117, 20824, + 9519, 2306, 52673, 57836, 38299, 47542, 64234, 54983, 41648, 36509, + 19038, 26227, 4612, 15913, 34719, 43954, 57285, 62440, 14123, 6918, + 28529, 17244, 59849, 50660, 45459, 40382, 22909, 30032, 295, 11530, + 38076, 47249, 52454, 57547, 9224, 2085, 31826, 20607, 4899, 16142, + 19321, 26452, 41879, 36794, 64461, 55264, 28246, 17019, 13836, 6689, + 57058, 62159, 34488, 43669, 53135, 58274, 38869, 48120, 32571, 21270, + 10081, 2892, 45818, 40663, 60064, 50829, 590, 11875, 23060, 30265, + 13669, 6472, 27967, 16658, 34257, 43516, 56715, 61862, 18448, 25661, + 4170, 15463, 63652, 54409, 41214, 36051, 9798, 2667, 32284, 21041, + 38642, 47839, 52904, 57989, 23347, 30494, 873, 12100, 60295, 51114, + 46045, 40944, 56492, 61569, 34038, 43227, 27672, 16437, 13378, 6255, + 41433, 36340, 63875, 54702, 4461, 15680, 18743, 25882, 33539, 44846, + 56153, 63348, 13239, 8090, 27629, 18368, 65142, 53851, 42540, 35329, + 20162, 25327, 5784, 15029, 31209, 21956, 8627, 3486, 51549, 58736, + 37127, 48426, 1180, 10417, 23750, 28907, 46120, 38917, 60530, 49247, + 27338, 18151, 12944, 7869, 55934, 63059, 33316, 44553, 6079, 15250, + 20453, 25544, 42763, 35622, 65361, 54140, 36896, 48141, 51322, 58455, + 8340, 3257, 30926, 21731, 60757, 49528, 46351, 39202, 24033, 29132, + 1467, 10646, 19596, 24737, 5334, 14587, 64568, 53269, 42082, 34895, + 12793, 7636, 27043, 17806, 33101, 44384, 55575, 62778, 46694, 39499, + 60988, 49681, 1746, 11007, 24200, 29349, 51987, 59198, 37705, 48996, + 31655, 22410, 9213, 4048, 42309, 35176, 64799, 53554, 5617, 14812, + 19883, 24966, 55344, 62493, 32874, 44103, 26756, 17577, 12510, 7411, + 24495, 29570, 2037, 11224, 61211, 49974, 46913, 39788, 8922, 3831, + 31360, 22189, 37486, 48707, 51764, 58905, + }, + { 0, 39065, 11567, 46518, 23134, 49863, 30577, 61416, 46268, 11301, + 39315, 266, 61154, 30331, 50125, 23380, 30053, 60924, 22602, 49363, + 12091, 47010, 532, 39565, 49625, 22848, 60662, 29807, 39815, 798, + 46760, 11825, 60106, 29267, 51173, 24444, 45204, 10253, 40379, 1314, + 24182, 50927, 29529, 60352, 1064, 40113, 10503, 45470, 40879, 1846, + 45696, 10777, 50673, 23912, 59614, 28743, 11027, 45962, 1596, 40613, + 29005, 59860, 23650, 50427, 51593, 20752, 58534, 31807, 37847, 2894, + 48888, 9825, 32053, 58796, 20506, 51331, 10091, 49138, 2628, 37597, + 48364, 9333, 37315, 2394, 59058, 32299, 52125, 21252, 2128, 37065, + 9599, 48614, 21006, 51863, 32545, 59320, 9027, 48090, 3692, 38645, + 31005, 57732, 21554, 52395, 38911, 3942, 47824, 8777, 52641, 21816, + 57486, 30743, 22054, 52927, 31497, 58256, 3192, 38113, 8535, 47566, + 58010, 31235, 53173, 22316, 47300, 8285, 38379, 3442, 36623, 6038, + 41504, 15033, 54609, 19912, 63614, 24807, 15283, 41770, 5788, 36357, + 25069, 63860, 19650, 54363, 64106, 25331, 55109, 20444, 41012, 14509, + 36123, 5506, 20182, 54863, 25593, 64352, 5256, 35857, 14759, 41278, + 26053, 64860, 18666, 53363, 16283, 42754, 4788, 35373, 53625, 18912, + 64598, 25807, 35623, 5054, 42504, 16017, 4256, 34873, 15759, 42262, + 19198, 53863, 26577, 65352, 42012, 15493, 35123, 4522, 65090, 26331, + 54125, 19444, 18054, 56863, 27561, 62256, 7384, 33857, 12791, 43374, + 62010, 27299, 57109, 18316, 43108, 12541, 34123, 7634, 13283, 43898, + 7884, 34389, 27069, 61732, 17554, 56331, 34655, 8134, 43632, 13033, + 56577, 17816, 61486, 26807, 44108, 13525, 33123, 6650, 62994, 28299, + 56125, 17316, 6384, 32873, 13791, 44358, 17070, 55863, 28545, 63256, + 55593, 16816, 62470, 27807, 33655, 7150, 44632, 14017, 28053, 62732, + 16570, 55331, 14283, 44882, 6884, 33405, + }, + { 0, 49859, 39323, 23384, 12075, 60904, 46768, 29811, 24150, 40085, + 51149, 1294, 29053, 46014, 59622, 10789, 48300, 32367, 9527, 59380, + 37767, 20804, 2588, 51423, 58106, 8249, 31585, 47522, 52689, 3858, + 21578, 38537, 25925, 42886, 64734, 15901, 19054, 34989, 54261, 4406, + 15123, 63952, 41608, 24651, 5176, 55035, 36259, 20320, 55785, 6954, + 16498, 33457, 63170, 13313, 28505, 44442, 34751, 17788, 7716, 56551, + 43156, 27223, 12559, 62412, 51850, 2121, 21265, 37330, 58785, 10082, + 31802, 48889, 38108, 22047, 3399, 53124, 48119, 31028, 8812, 57519, + 30246, 46309, 61373, 11646, 22797, 39886, 49302, 597, 10352, 60083, + 45547, 29480, 1883, 50584, 40640, 23555, 45007, 27916, 13908, 62615, + 32996, 16935, 6527, 56252, 61849, 13146, 26626, 43713, 57010, 7281, + 18217, 34282, 4963, 53664, 35576, 18491, 15432, 65163, 42451, 26384, + 19765, 36854, 54446, 5741, 25118, 41181, 64389, 14662, 35081, 19402, + 4242, 53841, 42530, 25825, 16313, 64890, 55135, 5532, 20164, 35847, + 63604, 15031, 25071, 41772, 13733, 63334, 44094, 28413, 6798, 55373, + 33557, 16854, 27635, 43312, 62056, 12459, 17624, 34331, 56643, 8064, + 60492, 11919, 30167, 46868, 50023, 420, 23292, 38975, 45594, 28889, + 11137, 59714, 40241, 24562, 1194, 50793, 20704, 37411, 51579, 3000, + 32715, 48392, 58960, 9363, 3766, 52341, 38701, 21998, 8605, 58206, + 47110, 31429, 17283, 33088, 55832, 6363, 27816, 44651, 62771, 14320, + 7637, 57110, 33870, 18061, 13054, 61501, 43877, 27046, 65327, 15852, + 26292, 42103, 53252, 4807, 18847, 35676, 41337, 25530, 14562, 64033, + 36434, 19601, 6089, 54538, 9926, 58373, 48989, 32158, 2541, 52014, + 36982, 21173, 30864, 47699, 57611, 9160, 22459, 38264, 52768, 3299, + 39530, 22697, 1009, 49458, 46401, 30594, 11482, 60953, 50236, 1791, + 23975, 40804, 60183, 10708, 29324, 45135, + }, + { 0, 61422, 50113, 11311, 39839, 29809, 22622, 47024, 11043, 50381, + 59618, 1804, 45244, 24402, 29565, 40083, 22086, 47528, 38279, 31337, + 52697, 8759, 3608, 57846, 32101, 37515, 48804, 20810, 59130, 2324, + 9531, 51925, 44172, 17250, 28493, 32931, 14099, 55549, 62674, 6972, + 34735, 26689, 17518, 43904, 7216, 62430, 57329, 12319, 64202, 5412, + 14603, 55013, 24917, 36539, 41620, 19834, 53737, 15879, 4648, 64966, + 19062, 42392, 35255, 26201, 17669, 43755, 34500, 26922, 56986, 12660, + 7515, 62133, 28198, 33224, 44519, 16905, 62905, 6743, 13944, 55702, + 4931, 64685, 53378, 16236, 35036, 26418, 19229, 42227, 14432, 55182, + 64417, 5199, 41983, 19473, 24638, 36816, 59785, 1639, 10824, 50598, + 29206, 40440, 45527, 24121, 49834, 11588, 363, 61061, 22837, 46811, + 39668, 29978, 49103, 20513, 31758, 37856, 9296, 52158, 59281, 2175, + 38124, 31490, 22317, 47299, 3955, 57501, 52402, 9052, 35338, 26084, + 18891, 42533, 4501, 65147, 53844, 15802, 41257, 20167, 25320, 36102, + 15030, 54616, 63863, 5785, 56396, 13218, 8077, 61539, 18387, 43069, + 33810, 27644, 63343, 6273, 13486, 56128, 27888, 33566, 44849, 16607, + 9862, 51560, 58695, 2729, 48409, 21239, 32472, 37174, 3493, 57931, + 52836, 8586, 38458, 31188, 22011, 47637, 28864, 40750, 45825, 23791, + 60255, 1201, 10398, 51056, 23523, 46093, 38946, 30668, 49276, 12178, + 957, 60499, 53007, 8417, 3278, 58144, 21648, 47998, 38737, 30911, + 58412, 3010, 10221, 51203, 32691, 36957, 48242, 21404, 39241, 30375, + 23176, 46438, 726, 60728, 49431, 12025, 45674, 23940, 29099, 40517, + 10741, 50715, 59956, 1498, 25475, 35949, 41026, 20396, 63516, 6130, + 15325, 54323, 18592, 42830, 35681, 25743, 54079, 15569, 4350, 65296, + 13765, 55851, 62980, 6634, 44634, 16820, 28059, 33397, 7910, 61704, + 56615, 13001, 34169, 27287, 18104, 43350, + }, + { 0, 30582, 61164, 39322, 49605, 46771, 12073, 22623, 40855, 59617, + 29051, 1549, 24146, 10532, 45246, 51144, 9011, 21573, 52703, 47785, + 58102, 38272, 3098, 31596, 48292, 52178, 21064, 9534, 32097, 2583, + 37773, 58619, 18022, 12560, 43146, 57340, 34723, 61653, 26959, 7737, + 55793, 44679, 14109, 16491, 6196, 28482, 63192, 33198, 25941, 4643, + 35769, 64719, 42128, 54246, 19068, 15626, 64194, 36276, 5166, 25432, + 15111, 19569, 54763, 41629, 36044, 64442, 25120, 5462, 19721, 14975, + 41957, 54419, 4955, 25645, 64951, 35521, 53918, 42472, 15474, 19204, + 45055, 55433, 16659, 13925, 28218, 6476, 32982, 63392, 12392, 18206, + 56964, 43506, 61869, 34523, 8001, 26679, 51882, 48604, 9286, 21296, + 2927, 31769, 58755, 37621, 21821, 8779, 48081, 52391, 38136, 58254, + 31252, 3426, 59801, 40687, 1909, 28675, 10332, 24362, 50864, 45510, + 30222, 376, 39138, 61332, 47051, 49341, 22823, 11857, 1413, 29427, + 60265, 39967, 50240, 45878, 10924, 24026, 39442, 60772, 29950, 904, + 23511, 11425, 46395, 49741, 9910, 20928, 51290, 48940, 59251, 36869, + 2463, 32489, 47393, 52823, 22477, 8379, 30948, 3986, 38408, 57726, + 17379, 13461, 44303, 55929, 33318, 62800, 27850, 7100, 56436, 43778, + 12952, 17902, 7601, 27335, 62301, 33835, 24784, 6054, 36412, 63818, + 41237, 54883, 20473, 14479, 65351, 34865, 4523, 26333, 16002, 18932, + 53358, 42776, 35145, 65087, 26533, 4307, 18572, 16378, 42592, 53526, + 5854, 25000, 63538, 36676, 55067, 41069, 14839, 20097, 43642, 56588, + 17558, 13280, 27583, 7369, 34131, 61989, 13805, 17051, 56065, 44151, + 62504, 33630, 6852, 28082, 53039, 47193, 8643, 22197, 3818, 31132, + 57350, 38768, 20664, 10190, 48724, 51490, 37245, 58891, 32657, 2279, + 60444, 39786, 752, 30086, 11737, 23215, 49973, 46147, 29579, 1277, + 40295, 59921, 45646, 50488, 23714, 11220, + }, + { 0, 15162, 30324, 19790, 60648, 55250, 39580, 41382, 50637, 65271, + 46009, 34947, 10533, 4639, 24401, 25707, 38791, 44221, 57843, 56009, + 31599, 16469, 3355, 13857, 21066, 26992, 9278, 7940, 48802, 34200, + 51414, 62444, 13075, 2089, 17767, 32349, 57339, 58561, 43407, 37557, + 63198, 52708, 32938, 48016, 6710, 8460, 27714, 22392, 42132, 40878, + 53984, 59866, 18556, 29510, 15880, 1330, 24921, 23139, 5933, 11287, + 36273, 46731, 64453, 49407, 26150, 23836, 4178, 11112, 35534, 45556, + 64698, 51072, 41963, 39121, 54687, 61093, 20227, 29753, 14711, 589, + 61857, 51867, 34773, 48367, 7497, 9843, 27453, 20487, 13420, 3926, + 16920, 31010, 55428, 58302, 44784, 38346, 21813, 28175, 9025, 6267, + 47581, 33511, 53161, 62611, 37112, 43970, 59020, 56758, 31760, 18218, + 2660, 12638, 49842, 63880, 46278, 36860, 11866, 5472, 22574, 25364, + 1919, 15429, 28939, 18993, 60311, 53421, 40419, 42713, 52300, 63350, + 47672, 33026, 8356, 7070, 22224, 28138, 2433, 12987, 32757, 17615, + 58729, 56915, 37661, 43047, 23499, 24817, 11711, 5765, 46883, 35865, + 49495, 64109, 40454, 42300, 59506, 54088, 29422, 18900, 1178, 16288, + 65375, 50277, 35115, 45585, 5047, 10381, 26051, 24313, 14994, 424, + 19686, 30684, 54906, 60736, 40974, 39732, 26840, 21474, 7852, 9622, + 33840, 48906, 62020, 51582, 44309, 38447, 56161, 57435, 16893, 31431, + 14217, 3251, 43626, 37200, 56350, 59172, 18050, 32184, 12534, 3020, + 28583, 21661, 6611, 8937, 33615, 47221, 62779, 52737, 15853, 1751, + 19353, 28835, 53509, 59967, 42865, 40011, 63520, 49946, 36436, 46446, + 5320, 12274, 25276, 22918, 39289, 41539, 61197, 54327, 30097, 20139, + 997, 14559, 23732, 26510, 10944, 4602, 45148, 35686, 50728, 64786, + 3838, 13764, 30858, 17328, 57878, 55596, 37986, 44888, 52019, 61449, + 48455, 34429, 10203, 7393, 20911, 27285, + }, + { 0, 7452, 14904, 10020, 29808, 26988, 20040, 21332, 59616, 62972, + 53976, 53188, 40080, 33164, 42664, 48052, 52701, 53441, 63461, 60153, + 47533, 42161, 33685, 40585, 9533, 14369, 7941, 537, 20813, 19537, + 27509, 30313, 34727, 39611, 48543, 41091, 62423, 61131, 51695, 54515, + 28487, 29275, 21887, 18531, 6967, 1579, 8463, 15379, 19066, 22374, + 28738, 27998, 15882, 8982, 1074, 6446, 41626, 49030, 39074, 34238, + 55018, 52214, 60626, 61902, 4947, 3663, 10603, 13431, 26403, 31295, + 23835, 16391, 64435, 59055, 49547, 56471, 36803, 37599, 46587, 43239, + 56974, 50066, 58550, 63914, 43774, 47074, 37062, 36314, 13934, 11122, + 3158, 4426, 16926, 24322, 30758, 25914, 38132, 35304, 44748, 46032, + 57476, 64920, 55996, 51104, 31764, 24840, 17964, 23344, 2148, 5496, + 12892, 12096, 22825, 17461, 25361, 32269, 11609, 12357, 5985, 2685, + 45513, 44245, 35825, 38637, 50617, 55461, 65409, 58013, 9894, 15290, + 7326, 386, 21206, 20426, 26862, 30194, 52806, 54106, 62590, 59746, + 47670, 42794, 32782, 40210, 60283, 63079, 53571, 52319, 40715, 33303, + 42291, 47151, 923, 7815, 14755, 9407, 30699, 27383, 19923, 20687, + 41217, 48157, 39737, 34341, 54641, 51309, 61257, 62037, 18913, 21757, + 29657, 28357, 15761, 8333, 1961, 6837, 27868, 29120, 22244, 19448, + 6316, 1456, 8852, 16264, 33852, 39200, 48644, 41752, 61516, 60752, + 51828, 55144, 13813, 10473, 4045, 4817, 16773, 23705, 31677, 26273, + 56597, 49161, 59181, 64049, 43365, 46201, 37725, 36417, 63528, 58676, + 49680, 57100, 35928, 37188, 46688, 43900, 4296, 3540, 10992, 14316, + 25784, 31140, 24192, 17308, 45650, 44878, 34922, 38262, 50722, 56126, + 64538, 57606, 23218, 18350, 24714, 32150, 11970, 13278, 5370, 2534, + 32655, 25235, 17847, 22699, 3071, 5859, 12743, 11483, 38767, 35443, + 44375, 45131, 58143, 65027, 55591, 50235, + }, + { 0, 3599, 7198, 4625, 14396, 13875, 9250, 10797, 28792, 32375, + 27750, 25193, 18500, 17995, 21594, 23125, 57584, 61183, 64750, 62177, + 55500, 54979, 50386, 51933, 37000, 40583, 35990, 33433, 43188, 42683, + 46250, 47781, 56829, 54258, 49635, 53228, 58817, 60366, 63967, 63440, + 44421, 41866, 45467, 49044, 38329, 39862, 35239, 34728, 15629, 13058, + 8467, 12060, 1329, 2878, 6447, 5920, 19829, 17274, 20843, 24420, + 30025, 31558, 26967, 26456, 42983, 43496, 48121, 46582, 40923, 37332, + 33733, 36298, 55199, 55696, 52097, 50574, 61347, 57772, 62397, 64946, + 18199, 18712, 23305, 21766, 32555, 28964, 25397, 27962, 14191, 14688, + 11121, 9598, 3923, 348, 4941, 7490, 31258, 29717, 26116, 26635, + 16934, 19497, 24120, 20535, 2658, 1133, 5756, 6259, 12894, 15441, + 11840, 8271, 39658, 38117, 34548, 35067, 41686, 44249, 48840, 45255, + 60050, 58525, 63116, 63619, 53934, 56481, 52912, 49343, 21459, 24028, + 20429, 16834, 27631, 26080, 30705, 31230, 9131, 11684, 16309, 12730, + 7063, 5528, 1929, 2438, 45859, 48428, 44861, 41266, 35615, 34064, + 38657, 39182, 50011, 52564, 57157, 53578, 64359, 62824, 59257, 59766, + 36398, 32801, 37424, 39999, 46610, 47133, 43532, 41987, 65110, 61529, + 57928, 60487, 50794, 51301, 55924, 54395, 28382, 24785, 29376, 31951, + 22242, 22765, 19196, 17651, 7846, 4265, 696, 3255, 9882, 10389, + 14980, 13451, 62516, 64059, 59434, 58917, 52232, 49671, 53270, 56857, + 33868, 35395, 38994, 38493, 48240, 45695, 41070, 44641, 5316, 6859, + 2266, 1749, 11512, 8951, 12518, 16105, 25788, 27315, 30882, 30381, + 23680, 21135, 16542, 20113, 10697, 10182, 13783, 15320, 4597, 8186, + 3563, 996, 22961, 22462, 17839, 19360, 24973, 28546, 32147, 29596, + 51513, 50998, 54567, 56104, 61701, 65290, 60699, 58132, 47425, 46926, + 42335, 43856, 33149, 36722, 40291, 37740, + }, + { 0, 35208, 3853, 34437, 7706, 38802, 4375, 39071, 15412, 46524, + 13113, 47793, 8750, 43942, 11555, 42155, 30824, 61920, 30565, 65261, + 26226, 61434, 27007, 57591, 17500, 52692, 19281, 49881, 23110, 54222, + 21835, 56515, 61648, 31064, 65501, 30293, 61130, 26434, 57799, 26703, + 52452, 17772, 50153, 19041, 54014, 23414, 56819, 21627, 35000, 304, + 34741, 3645, 38562, 7978, 39343, 4135, 46220, 15620, 48001, 12809, + 43670, 8990, 42395, 11283, 64957, 29749, 62128, 31544, 58279, 27183, + 60586, 25890, 49545, 18433, 52868, 18188, 57235, 22043, 53406, 22806, + 34261, 3165, 35544, 848, 39887, 4679, 38082, 7498, 47585, 12393, + 46828, 16228, 43003, 11891, 43254, 8574, 3437, 34021, 608, 35816, + 4983, 39679, 7290, 38386, 12633, 47313, 15956, 47068, 12099, 42699, + 8270, 43462, 29957, 64653, 31240, 62336, 27423, 58007, 25618, 60826, + 18737, 49337, 17980, 53172, 22315, 56995, 22566, 53678, 59239, 28399, + 59498, 25058, 63869, 28917, 63088, 32760, 56147, 21211, 54366, 24022, + 50505, 19649, 51780, 17356, 40719, 5767, 36866, 6538, 33045, 2205, + 36376, 1936, 41787, 10931, 44086, 9662, 48417, 13481, 45612, 15268, + 6071, 40511, 6330, 37170, 2477, 32805, 1696, 36648, 11139, 41483, + 9358, 44294, 13721, 48145, 14996, 45852, 28639, 58967, 24786, 59738, + 29125, 63565, 32456, 63296, 21483, 55907, 23782, 54638, 19953, 50297, + 17148, 52084, 6874, 37714, 5591, 40031, 1216, 36168, 3021, 33349, + 9966, 44902, 10723, 41067, 14580, 45436, 14329, 48753, 25266, 60218, + 28095, 58423, 31912, 62752, 29605, 64045, 24198, 55054, 20875, 55299, + 16540, 51476, 20369, 50713, 59914, 25474, 58631, 27791, 62480, 32152, + 64285, 29333, 54846, 24502, 55603, 20667, 51236, 16812, 50985, 20129, + 37474, 7146, 40303, 5351, 35960, 1520, 33653, 2813, 44630, 10206, + 41307, 10451, 45132, 14788, 48961, 14025, + }, + { 0, 17477, 34954, 52431, 3337, 18764, 34179, 49606, 6674, 24151, + 37528, 55005, 5915, 21342, 40849, 56276, 13348, 28769, 48302, 63723, + 14637, 32104, 45479, 62946, 11830, 27251, 42684, 58105, 9023, 26490, + 43957, 61424, 26696, 11277, 57538, 42119, 25921, 8452, 60875, 43406, + 29274, 13855, 64208, 48789, 32595, 15126, 63449, 45980, 23660, 6185, + 54502, 37027, 20837, 5408, 55791, 40362, 18046, 571, 52980, 35505, + 19319, 3890, 50173, 34744, 53392, 38101, 22554, 7263, 56729, 39388, + 21779, 4438, 51842, 36551, 16904, 1613, 51083, 33742, 20225, 2884, + 58548, 41201, 27710, 10363, 59837, 44536, 24887, 9586, 65190, 47843, + 30252, 12905, 62383, 47082, 31525, 16224, 47320, 64669, 12370, 29719, + 46545, 61844, 15707, 31006, 41674, 59023, 10816, 28165, 44995, 60294, + 10057, 25356, 36092, 51385, 1142, 16435, 33269, 50608, 2431, 19770, + 38638, 53931, 7780, 23073, 39911, 57250, 4973, 22312, 48445, 63864, + 13751, 29170, 45108, 62577, 14526, 31995, 42799, 58218, 12197, 27616, + 43558, 61027, 8876, 26345, 35097, 52572, 403, 17878, 33808, 49237, + 3226, 18655, 37643, 55118, 7041, 24516, 40450, 55879, 5768, 21197, + 54645, 37168, 24063, 6586, 55420, 39993, 20726, 5299, 53095, 35618, + 18413, 936, 49774, 34347, 19172, 3745, 57681, 42260, 27099, 11678, + 60504, 43037, 25810, 8343, 64323, 48902, 29641, 14220, 63050, 45583, + 32448, 14981, 28077, 10728, 58663, 41314, 24740, 9441, 59438, 44139, + 30655, 13306, 65333, 47984, 31414, 16115, 62012, 46713, 22921, 7628, + 53507, 38214, 21632, 4293, 56330, 38991, 17307, 2014, 51985, 36692, + 20114, 2775, 50712, 33373, 1509, 16800, 36207, 51498, 2284, 19625, + 32870, 50211, 8183, 23474, 38781, 54072, 4862, 22203, 39540, 56881, + 12737, 30084, 47435, 64782, 15560, 30861, 46146, 61447, 11219, 28566, + 41817, 59164, 9946, 25247, 44624, 59925, + }, + { 0, 44205, 17735, 59882, 35470, 9763, 53193, 25444, 2305, 42412, + 19526, 57579, 33679, 12066, 50888, 27237, 4610, 48815, 22341, 64488, + 39052, 13345, 56779, 29030, 6915, 47022, 24132, 62185, 37261, 15648, + 54474, 30823, 9220, 34985, 24899, 52718, 44682, 551, 60365, 18272, + 11525, 33192, 26690, 50415, 42891, 2854, 58060, 20065, 13830, 39595, + 29505, 57324, 48264, 4133, 63951, 21858, 16135, 37802, 31296, 55021, + 46473, 6436, 61646, 23651, 18440, 58533, 3407, 41442, 49798, 28203, + 34753, 11116, 16649, 60836, 1102, 43235, 52103, 26410, 36544, 8813, + 23050, 63143, 8013, 46048, 53380, 31785, 38339, 14702, 21259, 65446, + 5708, 47841, 55685, 29992, 40130, 12399, 27660, 49313, 10571, 34278, + 59010, 18991, 41925, 3944, 25869, 51616, 8266, 36071, 61315, 17198, + 43716, 1641, 32270, 53923, 15177, 38884, 62592, 22573, 45511, 7530, + 30479, 56226, 12872, 40677, 64897, 20780, 47302, 5227, 36880, 15549, + 54615, 31226, 6814, 46643, 24537, 62324, 39185, 13756, 56406, 28923, + 5023, 48946, 22232, 64117, 33298, 11967, 51029, 27640, 2204, 42033, + 19931, 57718, 35603, 10174, 52820, 25337, 413, 44336, 17626, 59511, + 46100, 6329, 61779, 24062, 16026, 37431, 31709, 55152, 48405, 4536, + 63570, 21759, 14235, 39734, 29404, 56945, 42518, 2747, 58193, 20476, + 11416, 32821, 27103, 50546, 44823, 954, 59984, 18173, 9625, 35124, + 24798, 52339, 55320, 29877, 40287, 12786, 21142, 65083, 6097, 47996, + 53529, 32180, 37982, 14579, 23447, 63290, 7888, 45693, 51738, 26295, + 36701, 9200, 16532, 60473, 1491, 43390, 49947, 28598, 34396, 10993, + 18837, 58680, 3282, 41087, 64540, 20657, 47451, 5622, 30354, 55871, + 13269, 40824, 62749, 22960, 45146, 7415, 32659, 54078, 15060, 38521, + 60958, 17075, 43865, 2036, 25744, 51261, 8663, 36218, 59167, 19378, + 41560, 3829, 28049, 49468, 10454, 33915, + }, + { 0, 55513, 44463, 30070, 18243, 40858, 60140, 12853, 36486, 22111, + 9001, 64496, 51653, 4380, 25706, 48307, 273, 55752, 44222, 29799, + 18002, 40587, 60413, 13092, 36759, 22350, 8760, 64225, 51412, 4109, + 25979, 48546, 546, 56059, 44941, 30548, 17761, 40376, 59598, 12311, + 36004, 21629, 8459, 63954, 52199, 4926, 26184, 48785, 819, 56298, + 44700, 30277, 17520, 40105, 59871, 12550, 36277, 21868, 8218, 63683, + 51958, 4655, 26457, 49024, 1092, 56477, 43499, 28978, 17159, 39902, + 61096, 13937, 35522, 21019, 10093, 65460, 52609, 5464, 24622, 47351, + 1365, 56716, 43258, 28707, 16918, 39631, 61369, 14176, 35795, 21258, + 9852, 65189, 52368, 5193, 24895, 47590, 1638, 57023, 43977, 29456, + 16677, 39420, 60554, 13395, 35040, 20537, 9551, 64918, 53155, 6010, + 25100, 47829, 1911, 57262, 43736, 29185, 16436, 39149, 60827, 13634, + 35313, 20776, 9310, 64647, 52914, 5739, 25373, 48068, 2184, 53329, + 42279, 32254, 20427, 38674, 57956, 15037, 34318, 24279, 11169, 62328, + 49485, 6548, 27874, 46139, 2457, 53568, 42038, 31983, 20186, 38403, + 58229, 15276, 34591, 24518, 10928, 62057, 49244, 6277, 28147, 46378, + 2730, 53875, 42757, 32732, 19945, 38192, 57414, 14495, 33836, 23797, + 10627, 61786, 50031, 7094, 28352, 46617, 3003, 54114, 42516, 32461, + 19704, 37921, 57687, 14734, 34109, 24036, 10386, 61515, 49790, 6823, + 28625, 46856, 3276, 54293, 41315, 31162, 19343, 37718, 58912, 16121, + 33354, 23187, 12261, 63292, 50441, 7632, 26790, 45183, 3549, 54532, + 41074, 30891, 19102, 37447, 59185, 16360, 33627, 23426, 12020, 63021, + 50200, 7361, 27063, 45422, 3822, 54839, 41793, 31640, 18861, 37236, + 58370, 15579, 32872, 22705, 11719, 62750, 50987, 8178, 27268, 45661, + 4095, 55078, 41552, 31369, 18620, 36965, 58643, 15818, 33145, 22944, + 11478, 62479, 50746, 7907, 27541, 45900, + }, + { 0, 58083, 55771, 15160, 44971, 19784, 30320, 38035, 17227, 41384, + 39568, 30835, 60640, 3587, 13627, 55256, 34454, 25717, 24397, 48558, + 10557, 52190, 61670, 4613, 50653, 10046, 7174, 65253, 27254, 34965, + 45997, 20814, 4401, 62418, 51434, 10761, 48794, 23673, 26433, 34210, + 21114, 45209, 35745, 26946, 64977, 7986, 9226, 50921, 38823, 30020, + 20092, 44191, 14348, 56047, 57815, 820, 54508, 13839, 3383, 61396, + 31559, 39332, 41628, 16511, 8802, 49281, 64441, 6490, 36297, 28458, + 21522, 46833, 24873, 33738, 47346, 23057, 52866, 11361, 5977, 62906, + 42228, 17943, 32047, 40908, 2911, 59836, 53892, 12391, 59327, 1372, + 15972, 56455, 18452, 43767, 37327, 29484, 13139, 53680, 60040, 2155, + 40184, 32283, 17699, 42944, 28696, 37627, 43459, 19232, 57267, 15696, + 1640, 58507, 46533, 22310, 27678, 36605, 6766, 63629, 50101, 8534, + 63118, 5229, 12117, 52662, 22821, 48070, 33022, 25117, 17604, 42535, + 40223, 32764, 60271, 2444, 12980, 53335, 1935, 58732, 56916, 15543, + 43044, 19143, 29183, 37660, 49746, 8369, 7049, 63850, 28153, 36634, + 46114, 22209, 33049, 25594, 22722, 47649, 11954, 52305, 63337, 5514, + 22005, 46870, 35886, 28365, 64094, 6333, 9093, 49510, 5822, 62557, + 53093, 11654, 47381, 23542, 24782, 33325, 54115, 12672, 2744, 59483, + 31944, 40491, 42259, 18416, 36904, 29387, 18931, 43792, 16259, 56672, + 58968, 1211, 26278, 33861, 49021, 23966, 51469, 11246, 4310, 62005, + 9709, 50958, 64566, 7893, 35398, 26789, 21405, 45438, 57392, 723, + 14827, 56072, 20379, 44408, 38464, 29859, 41851, 16792, 31392, 38979, + 3280, 60979, 54539, 14312, 30615, 38260, 44620, 19631, 55356, 15071, + 487, 58116, 13532, 54847, 60679, 4068, 39799, 31124, 17068, 41039, + 61697, 5090, 10458, 51769, 24234, 48201, 34673, 26002, 45642, 20649, + 27537, 35186, 7649, 65282, 50234, 9945, + }, + { 0, 65534, 58337, 7199, 56287, 9249, 14398, 51136, 43939, 21597, + 18498, 47036, 28796, 36738, 37789, 27747, 19291, 46245, 43194, 22340, + 36996, 28538, 29541, 35995, 57592, 7942, 793, 64743, 15143, 50393, + 55494, 10040, 38582, 26952, 30039, 35497, 19817, 45719, 44680, 20854, + 15637, 49899, 57076, 8458, 59082, 6452, 1323, 64213, 56813, 8723, + 15884, 49650, 1586, 63948, 58835, 6701, 30286, 35248, 38319, 27217, + 44433, 21103, 20080, 45454, 12657, 52879, 53904, 11630, 60078, 5456, + 2383, 63153, 39634, 25900, 31027, 34509, 16653, 48883, 41708, 23826, + 31274, 34260, 39371, 26165, 41461, 24075, 16916, 48618, 53641, 11895, + 12904, 52630, 2646, 62888, 59831, 5705, 42951, 22585, 17446, 48088, + 31768, 33766, 40953, 24583, 3172, 62362, 61317, 4219, 55227, 10309, + 13402, 52132, 60572, 4962, 3965, 61571, 14147, 51389, 54434, 11100, + 18239, 47297, 42206, 23328, 40160, 25374, 32513, 33023, 25314, 40220, + 33027, 32509, 47421, 18115, 23260, 42274, 51521, 14015, 10912, 54622, + 4766, 60768, 61823, 3713, 10681, 54855, 51800, 13734, 62054, 3480, + 4487, 61049, 33306, 32228, 25083, 40453, 22981, 42555, 47652, 17882, + 62548, 2986, 6069, 59467, 12171, 53365, 52330, 13204, 24567, 40969, + 48150, 17384, 33832, 31702, 26569, 38967, 48911, 16625, 23790, 41744, + 25808, 39726, 34609, 30927, 5292, 60242, 63309, 2227, 53107, 12429, + 11410, 54124, 21395, 44141, 45170, 20364, 34892, 30642, 27565, 37971, + 63536, 1998, 7121, 58415, 9199, 56337, 49166, 16368, 6344, 59190, + 64297, 1239, 49943, 15593, 8438, 57096, 45931, 19605, 20618, 44916, + 26804, 38730, 35669, 29867, 50469, 15067, 9924, 55610, 7930, 57604, + 64795, 741, 28294, 37240, 36199, 29337, 46425, 19111, 22200, 43334, + 36478, 29056, 28063, 37473, 21921, 43615, 46656, 18878, 9693, 55843, + 50748, 14786, 65026, 508, 7651, 57885, + }, + { 0, 32638, 65276, 33154, 57829, 40603, 7961, 24679, 57303, 41129, + 8491, 24149, 15922, 16716, 49358, 49072, 41907, 56525, 23887, 8753, + 16982, 15656, 48298, 50132, 31844, 794, 33432, 64998, 40321, 58111, + 25469, 7171, 23419, 9221, 42375, 56057, 47774, 50656, 17506, 15132, + 33964, 64466, 31312, 1326, 25929, 6711, 39861, 58571, 63688, 34742, + 1588, 31050, 6445, 26195, 59345, 39087, 10015, 22625, 55779, 42653, + 50938, 47492, 14342, 18296, 46838, 51592, 18442, 14196, 22291, 10349, + 43503, 54929, 26913, 5727, 38877, 59555, 35012, 63418, 30264, 2374, + 5445, 27195, 60345, 38087, 62624, 35806, 2652, 29986, 51858, 46572, + 13422, 19216, 11127, 21513, 54667, 43765, 60813, 37619, 4977, 27663, + 3176, 29462, 62100, 36330, 12890, 19748, 52390, 46040, 54207, 44225, + 11587, 21053, 20030, 12608, 45250, 53180, 45019, 53413, 20775, 11865, + 37353, 61079, 28437, 4203, 28684, 3954, 36592, 61838, 29169, 3727, + 36621, 61555, 36884, 61290, 28392, 4502, 44582, 53592, 20698, 12196, + 20419, 12477, 45375, 52801, 53826, 44348, 11454, 21440, 13223, 19673, + 52571, 45605, 3477, 29419, 62313, 35863, 60528, 37646, 4748, 28146, + 10890, 22004, 54390, 43784, 52079, 46097, 13715, 19181, 62813, 35363, + 2977, 29919, 5304, 27590, 59972, 38202, 35129, 63047, 30661, 2235, + 26844, 6050, 38432, 59742, 22254, 10640, 43026, 55148, 46859, 51317, + 18935, 13961, 50951, 47225, 14843, 18053, 9954, 22940, 55326, 42848, + 6352, 26542, 58924, 39250, 63797, 34379, 1993, 30903, 25780, 7114, + 39496, 58678, 34129, 64047, 31661, 1235, 47971, 50205, 17823, 15073, + 23174, 9720, 42106, 56068, 40060, 58114, 25216, 7678, 32153, 743, + 33637, 64539, 17323, 15573, 48471, 49705, 41550, 56624, 23730, 9164, + 16335, 16561, 49459, 48717, 56874, 41300, 8406, 24488, 57368, 40806, + 7908, 24986, 509, 32387, 65281, 32895, + }, + { 0, 16190, 32380, 16706, 64760, 50118, 33412, 48570, 58861, 56019, + 39825, 42159, 6421, 9771, 26473, 22615, 55239, 59641, 43451, 38533, + 11071, 5121, 21827, 27261, 12842, 3348, 19542, 29544, 52946, 61932, + 45230, 36752, 45971, 36013, 52719, 62161, 20331, 28757, 12567, 3625, + 22142, 26944, 10242, 5948, 43654, 38328, 54522, 60356, 25684, 23402, + 6696, 9494, 39084, 42898, 59088, 55790, 33209, 48775, 65477, 49403, + 32065, 17023, 829, 15363, 31547, 17413, 1351, 14969, 34755, 47357, + 63935, 50817, 40662, 41448, 57514, 57236, 25134, 23824, 7250, 9068, + 44284, 37826, 53888, 60862, 20484, 28474, 11896, 4422, 18705, 30255, + 14189, 2131, 46569, 35543, 52117, 62635, 51368, 63382, 46804, 35306, + 13392, 2926, 18988, 29970, 11589, 4731, 21305, 27655, 53693, 61059, + 44993, 37119, 8047, 8273, 24851, 24109, 58263, 56489, 40427, 41685, + 64130, 50620, 34046, 48064, 1658, 14660, 30726, 18232, 63094, 51528, + 34826, 46900, 2702, 13744, 29938, 19404, 5019, 11429, 28135, 21209, + 61283, 53341, 37151, 44577, 8625, 7823, 24525, 24819, 56649, 57975, + 41781, 39947, 50268, 64354, 47648, 34078, 14500, 1946, 18136, 31206, + 17893, 31451, 15257, 1191, 47389, 34339, 51041, 63583, 40968, 40758, + 56948, 57674, 23792, 25550, 8844, 7602, 37410, 44316, 60510, 54112, + 28378, 20964, 4262, 12184, 30671, 18673, 2483, 13965, 35639, 46089, + 62795, 51829, 36173, 45683, 62257, 52239, 29109, 20107, 4041, 12535, + 26784, 22430, 5852, 10722, 37976, 43878, 59940, 54554, 23178, 26036, + 9462, 7112, 42610, 39244, 55310, 59184, 48999, 32857, 49435, 65061, + 17311, 31905, 15843, 733, 16094, 480, 16546, 32668, 49702, 64792, + 48218, 33636, 56115, 58381, 42319, 39537, 10187, 6389, 22967, 26249, + 59673, 54823, 38757, 43099, 5601, 10975, 27549, 21667, 3316, 13258, + 29320, 19894, 61452, 53042, 36464, 45390, + }, + { 0, 7966, 15932, 8482, 31864, 25446, 16964, 23898, 63728, 59374, + 50892, 55762, 33928, 39830, 47796, 42410, 60925, 62179, 54209, 52447, + 37253, 36507, 44985, 45223, 5389, 2579, 11057, 13359, 26997, 30315, + 22345, 18519, 51175, 55545, 63963, 59077, 48031, 42113, 34211, 39613, + 16151, 8201, 299, 7733, 17263, 23665, 32083, 25165, 10778, 13572, + 5158, 2872, 22114, 18812, 26718, 30528, 53994, 52724, 60630, 62408, + 44690, 45452, 37038, 36784, 37843, 36045, 44527, 45809, 61355, 61621, + 53655, 52873, 27427, 29757, 21791, 18945, 5979, 2117, 10599, 13945, + 32302, 24880, 16402, 24332, 598, 7496, 15466, 9076, 34526, 39360, + 47330, 43004, 64166, 58808, 50330, 56196, 21556, 19242, 27144, 29974, + 10316, 14162, 5744, 2414, 44228, 46042, 37624, 36326, 53436, 53154, + 61056, 61854, 47561, 42711, 34805, 39147, 50609, 55983, 64397, 58515, + 16697, 24103, 32517, 24603, 15681, 8799, 893, 7267, 15291, 9381, + 1415, 6809, 18371, 22749, 31231, 26337, 49995, 56405, 64887, 57961, + 48947, 41005, 33039, 40465, 54854, 51544, 59514, 63332, 43582, 46368, + 37890, 35612, 11958, 12712, 4234, 3988, 21198, 19920, 27890, 29676, + 64604, 58178, 49760, 56702, 32804, 40762, 48664, 41222, 1196, 7090, + 14992, 9614, 30932, 26570, 18152, 23030, 4513, 3775, 12189, 12419, + 28121, 29383, 21477, 19707, 59729, 63055, 55149, 51315, 38185, 35383, + 43797, 46091, 43112, 46966, 38484, 35146, 54288, 51982, 59948, 62770, + 20632, 20358, 28324, 29114, 11488, 13310, 4828, 3522, 17813, 23179, + 31657, 25783, 14829, 9971, 2001, 6351, 48485, 41595, 33625, 40007, + 49437, 56835, 65313, 57407, 28559, 28817, 20915, 20141, 5111, 3305, + 11723, 13013, 38783, 34913, 43331, 46685, 60167, 62489, 54587, 51749, + 33394, 40300, 48206, 41808, 65034, 57620, 49206, 57128, 31362, 26012, + 17598, 23456, 1786, 6628, 14534, 10200, + }, + { 0, 3854, 7708, 4370, 15416, 13110, 8740, 11562, 30832, 30590, + 26220, 26978, 17480, 19270, 23124, 21850, 61664, 65518, 61180, 57842, + 52440, 50134, 53956, 56778, 34960, 34718, 38540, 39298, 46248, 48038, + 43700, 42426, 64989, 62163, 58305, 60623, 49637, 52971, 57337, 53495, + 34221, 35491, 39857, 38079, 47509, 46747, 42889, 43143, 3389, 563, + 4897, 7215, 12549, 15883, 12057, 8215, 30029, 31299, 27473, 25695, + 18805, 18043, 22377, 22631, 59303, 59561, 63931, 63157, 56223, 54417, + 50563, 51853, 40919, 37081, 33227, 36549, 41967, 44257, 48627, 45821, + 5959, 6217, 2395, 1621, 11135, 9329, 13667, 14957, 28471, 24633, + 28971, 32293, 21263, 23553, 19731, 16925, 6778, 5492, 1126, 2920, + 9794, 10572, 14430, 14160, 25098, 27908, 31766, 29464, 24114, 20796, + 16430, 20256, 60058, 58772, 62598, 64392, 54946, 55724, 51390, 51120, + 37610, 40420, 36086, 33784, 44754, 41436, 45262, 49088, 54099, 56413, + 52559, 49729, 61291, 57445, 61815, 65145, 43811, 42029, 46399, 47665, + 38683, 38933, 35079, 34313, 9139, 11453, 15791, 12961, 8075, 4229, + 407, 3737, 23491, 21709, 17887, 19153, 26619, 26869, 31207, 30441, + 11918, 8576, 12434, 16284, 4790, 7608, 3242, 932, 22270, 23024, + 18658, 18412, 27334, 26056, 29914, 31700, 56942, 53600, 49266, 53116, + 57942, 60760, 64586, 62276, 42526, 43280, 47106, 46860, 39462, 38184, + 33850, 35636, 13556, 15354, 10984, 9702, 2252, 1986, 5840, 6622, + 19588, 17290, 21144, 23958, 28860, 32690, 28320, 25006, 50196, 51994, + 55816, 54534, 63532, 63266, 58928, 59710, 48228, 45930, 41592, 44406, + 32860, 36690, 40512, 37198, 51497, 50727, 55093, 55355, 62737, 64031, + 60173, 58371, 45401, 48727, 44869, 41035, 36193, 33391, 37757, 40051, + 14793, 14023, 10197, 10459, 1521, 2815, 7149, 5347, 16825, 20151, + 24485, 20651, 32129, 29327, 25501, 27795, + }, + { 0, 1798, 3596, 2314, 7192, 6942, 4628, 5394, 14384, 16182, + 13884, 12602, 9256, 9006, 10788, 11554, 28768, 30566, 32364, 31082, + 27768, 27518, 25204, 25970, 18512, 20310, 18012, 16730, 21576, 21326, + 23108, 23874, 57536, 59334, 61132, 59850, 64728, 64478, 62164, 62930, + 55536, 57334, 55036, 53754, 50408, 50158, 51940, 52706, 37024, 38822, + 40620, 39338, 36024, 35774, 33460, 34226, 43152, 44950, 42652, 41370, + 46216, 45966, 47748, 48514, 56733, 55963, 54161, 54423, 49541, 50819, + 53129, 51343, 58797, 58027, 60321, 60583, 63925, 65203, 63417, 61631, + 44541, 43771, 41969, 42231, 45541, 46819, 49129, 47343, 38349, 37579, + 39873, 40135, 35285, 36563, 34777, 32991, 15709, 14939, 13137, 13399, + 8517, 9795, 12105, 10319, 1389, 619, 2913, 3175, 6517, 7795, + 6009, 4223, 19773, 19003, 17201, 17463, 20773, 22051, 24361, 22575, + 29965, 29195, 31489, 31751, 26901, 28179, 26393, 24607, 42791, 40993, + 43307, 44589, 47935, 48185, 46387, 45621, 40727, 38929, 37147, 38429, + 33551, 33801, 36099, 35333, 55111, 53313, 55627, 56909, 52063, 52313, + 50515, 49749, 61303, 59505, 57723, 59005, 62319, 62569, 64867, 64101, + 18407, 16609, 18923, 20205, 23551, 23801, 22003, 21237, 32727, 30929, + 29147, 30429, 25551, 25801, 28099, 27333, 14215, 12417, 14731, 16013, + 11167, 11417, 9619, 8853, 4023, 2225, 443, 1725, 5039, 5289, + 7587, 6821, 31418, 32188, 29878, 29616, 26274, 24996, 26798, 28584, + 17034, 17804, 19590, 19328, 24210, 22932, 20638, 22424, 2778, 3548, + 1238, 976, 5826, 4548, 6350, 8136, 13034, 13804, 15590, 15328, + 12018, 10740, 8446, 10232, 39546, 40316, 38006, 37744, 34402, 33124, + 34926, 36712, 41546, 42316, 44102, 43840, 48722, 47444, 45150, 46936, + 59930, 60700, 58390, 58128, 62978, 61700, 63502, 65288, 53802, 54572, + 56358, 56096, 52786, 51508, 49214, 51000, + }, + { 0, 770, 1540, 1286, 3080, 3850, 2572, 2318, 6160, 6930, + 7700, 7446, 5144, 5914, 4636, 4382, 12320, 13090, 13860, 13606, + 15400, 16170, 14892, 14638, 10288, 11058, 11828, 11574, 9272, 10042, + 8764, 8510, 24640, 25410, 26180, 25926, 27720, 28490, 27212, 26958, + 30800, 31570, 32340, 32086, 29784, 30554, 29276, 29022, 20576, 21346, + 22116, 21862, 23656, 24426, 23148, 22894, 18544, 19314, 20084, 19830, + 17528, 18298, 17020, 16766, 49280, 50050, 50820, 50566, 52360, 53130, + 51852, 51598, 55440, 56210, 56980, 56726, 54424, 55194, 53916, 53662, + 61600, 62370, 63140, 62886, 64680, 65450, 64172, 63918, 59568, 60338, + 61108, 60854, 58552, 59322, 58044, 57790, 41152, 41922, 42692, 42438, + 44232, 45002, 43724, 43470, 47312, 48082, 48852, 48598, 46296, 47066, + 45788, 45534, 37088, 37858, 38628, 38374, 40168, 40938, 39660, 39406, + 35056, 35826, 36596, 36342, 34040, 34810, 33532, 33278, 40221, 40479, + 39705, 38939, 37141, 37399, 38673, 37907, 34061, 34319, 33545, 32779, + 35077, 35335, 36609, 35843, 44349, 44607, 43833, 43067, 41269, 41527, + 42801, 42035, 46381, 46639, 45865, 45099, 47397, 47655, 48929, 48163, + 64861, 65119, 64345, 63579, 61781, 62039, 63313, 62547, 58701, 58959, + 58185, 57419, 59717, 59975, 61249, 60483, 52605, 52863, 52089, 51323, + 49525, 49783, 51057, 50291, 54637, 54895, 54121, 53355, 55653, 55911, + 57185, 56419, 23965, 24223, 23449, 22683, 20885, 21143, 22417, 21651, + 17805, 18063, 17289, 16523, 18821, 19079, 20353, 19587, 28093, 28351, + 27577, 26811, 25013, 25271, 26545, 25779, 30125, 30383, 29609, 28843, + 31141, 31399, 32673, 31907, 15837, 16095, 15321, 14555, 12757, 13015, + 14289, 13523, 9677, 9935, 9161, 8395, 10693, 10951, 12225, 11459, + 3581, 3839, 3065, 2299, 501, 759, 2033, 1267, 5613, 5871, + 5097, 4331, 6629, 6887, 8161, 7395, + }, }; #endif /* __VCD_CD_SECTOR_PRIVATE_H__ */ diff --git a/src/input/vcd/libvcd/stream.c b/src/input/vcd/libvcd/stream.c index 7866a62c2..2840a05d6 100644 --- a/src/input/vcd/libvcd/stream.c +++ b/src/input/vcd/libvcd/stream.c @@ -1,5 +1,5 @@ /* - $Id: stream.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: stream.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -36,11 +36,11 @@ #include <libvcd/logging.h> /* Private headers */ -#include "assert.h" +#include "vcd_assert.h" #include "stream.h" #include "util.h" -static const char _rcsid[] = "$Id: stream.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: stream.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; /* * DataSource implementations diff --git a/src/input/vcd/libvcd/stream.h b/src/input/vcd/libvcd/stream.h index dcee55ac4..43b8c911a 100644 --- a/src/input/vcd/libvcd/stream.h +++ b/src/input/vcd/libvcd/stream.h @@ -1,5 +1,5 @@ /* - $Id: stream.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: stream.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/stream_stdio.c b/src/input/vcd/libvcd/stream_stdio.c index e3a79a494..4eac0f6b3 100644 --- a/src/input/vcd/libvcd/stream_stdio.c +++ b/src/input/vcd/libvcd/stream_stdio.c @@ -1,5 +1,5 @@ /* - $Id: stream_stdio.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: stream_stdio.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -37,7 +37,7 @@ #include "stream_stdio.h" #include "util.h" -static const char _rcsid[] = "$Id: stream_stdio.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: stream_stdio.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; #define VCD_STREAM_STDIO_BUFSIZE (128*1024) diff --git a/src/input/vcd/libvcd/stream_stdio.h b/src/input/vcd/libvcd/stream_stdio.h index 9141b370e..46bca3140 100644 --- a/src/input/vcd/libvcd/stream_stdio.h +++ b/src/input/vcd/libvcd/stream_stdio.h @@ -1,5 +1,5 @@ /* - $Id: stream_stdio.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: stream_stdio.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/util.c b/src/input/vcd/libvcd/util.c index 1607ca87d..a1e5c57d4 100644 --- a/src/input/vcd/libvcd/util.c +++ b/src/input/vcd/libvcd/util.c @@ -1,5 +1,5 @@ /* - $Id: util.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: util.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -28,11 +28,11 @@ #include <string.h> /* Private includes */ -#include "assert.h" +#include "vcd_assert.h" #include "bytesex.h" #include "util.h" -static const char _rcsid[] = "$Id: util.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: util.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; size_t _vcd_strlenv(char **str_array) diff --git a/src/input/vcd/libvcd/util.h b/src/input/vcd/libvcd/util.h index 02cd5de1d..c5a9ead7c 100644 --- a/src/input/vcd/libvcd/util.h +++ b/src/input/vcd/libvcd/util.h @@ -1,5 +1,5 @@ /* - $Id: util.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: util.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/vcd.c b/src/input/vcd/libvcd/vcd.c index b61cf0d27..baca9da91 100644 --- a/src/input/vcd/libvcd/vcd.c +++ b/src/input/vcd/libvcd/vcd.c @@ -1,5 +1,5 @@ /* - $Id: vcd.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: vcd.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> @@ -49,7 +49,7 @@ #include "util.h" #include "vcd.h" -static const char _rcsid[] = "$Id: vcd.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $"; +static const char _rcsid[] = "$Id: vcd.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $"; static const char zero[CDIO_CD_FRAMESIZE_RAW] = { 0, }; diff --git a/src/input/vcd/libvcd/vcd.h b/src/input/vcd/libvcd/vcd.h index b2899e1c3..7c001d282 100644 --- a/src/input/vcd/libvcd/vcd.h +++ b/src/input/vcd/libvcd/vcd.h @@ -1,5 +1,5 @@ /* - $Id: vcd.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: vcd.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/assert.h b/src/input/vcd/libvcd/vcd_assert.h index 6013c4c43..c096b3677 100644 --- a/src/input/vcd/libvcd/assert.h +++ b/src/input/vcd/libvcd/vcd_assert.h @@ -1,5 +1,5 @@ /* - $Id: assert.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: vcd_assert.h,v 1.1 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org> diff --git a/src/input/vcd/libvcd/vcd_read.c b/src/input/vcd/libvcd/vcd_read.c index 97db8899a..26e7d8cf7 100644 --- a/src/input/vcd/libvcd/vcd_read.c +++ b/src/input/vcd/libvcd/vcd_read.c @@ -1,5 +1,5 @@ /* - $Id: vcd_read.c,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: vcd_read.c,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2001,2003 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2003 Rocky Bernstein <rocky@gnu.org> @@ -21,7 +21,7 @@ #include "vcd_read.h" -#include "assert.h" +#include "vcd_assert.h" #include <libvcd/inf.h> #include <libvcd/files.h> #include <libvcd/logging.h> diff --git a/src/input/vcd/libvcd/vcd_read.h b/src/input/vcd/libvcd/vcd_read.h index 8731fd4f6..9dde195f4 100644 --- a/src/input/vcd/libvcd/vcd_read.h +++ b/src/input/vcd/libvcd/vcd_read.h @@ -1,5 +1,5 @@ /* - $Id: vcd_read.h,v 1.1 2003/10/13 11:47:12 f1rmb Exp $ + $Id: vcd_read.h,v 1.2 2004/04/11 12:20:32 miguelfreitas Exp $ Copyright (C) 2003 Rocky Bernstein <rocky@gnu.org> |