Add type for holding MCN and ISRC. Add type for session

Replace magic constant 100 with CDIO_MAX_TRACK+1 where appropriate.

_cdio_osx: save session number and presumably some tighter coding.
nrg.c: make sure we add zero byte to end of MCN.
This commit is contained in:
rocky
2004-06-27 15:29:20 +00:00
parent 1e59a360a2
commit 79ea450a56
12 changed files with 216 additions and 85 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: freebsd.h,v 1.12 2004/06/19 16:34:45 rocky Exp $
$Id: freebsd.h,v 1.13 2004/06/27 15:29:22 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -140,7 +140,9 @@ typedef struct {
/* Track information */
bool toc_init; /* if true, info below is valid. */
struct ioc_toc_header tochdr;
struct ioc_read_toc_single_entry tocent[100]; /* entry info for each track */
/* Entry info for each track. Add 1 for leadout. */
struct ioc_read_toc_single_entry tocent[CDIO_CD_MAX_TRACKS+1;
} _img_private_t;

View File

@@ -1,5 +1,5 @@
/*
$Id: aspi32.c,v 1.9 2004/06/25 01:47:06 rocky Exp $
$Id: aspi32.c,v 1.10 2004/06/27 15:29:22 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: aspi32.c,v 1.9 2004/06/25 01:47:06 rocky Exp $";
static const char _rcsid[] = "$Id: aspi32.c,v 1.10 2004/06/27 15:29:22 rocky Exp $";
#include <cdio/cdio.h>
#include <cdio/sector.h>
@@ -53,6 +53,75 @@ static const char _rcsid[] = "$Id: aspi32.c,v 1.9 2004/06/25 01:47:06 rocky Exp
#include <sys/types.h>
#include "aspi32.h"
const char *aspierror(int nErrorCode)
{
switch (nErrorCode)
{
case SS_PENDING:
return "SRB being processed";
break;
case SS_COMP:
return "SRB completed without error";
break;
case SS_ABORTED:
return "SRB aborted";
break;
case SS_ABORT_FAIL:
return "Unable to abort SRB";
break;
case SS_ERR:
return "SRB completed with error";
break;
case SS_INVALID_CMD:
return "Invalid ASPI command";
break;
case SS_INVALID_HA:
return "Invalid host adapter number";
break;
case SS_NO_DEVICE:
return "SCSI device not installed";
break;
case SS_INVALID_SRB:
return "Invalid parameter set in SRB";
break;
case SS_OLD_MANAGER:
return "ASPI manager doesn't support";
break;
case SS_ILLEGAL_MODE:
return "Unsupported Windows mode";
break;
case SS_NO_ASPI:
return "No ASPI managers";
break;
case SS_FAILED_INIT:
return "ASPI for windows failed init";
break;
case SS_ASPI_IS_BUSY:
return "No resources available to execute command";
break;
case SS_BUFFER_TOO_BIG:
return "Buffer size too big to handle";
break;
case SS_MISMATCHED_COMPONENTS:
return "The DLLs/EXEs of ASPI don't version check";
break;
case SS_NO_ADAPTERS:
return "No host adapters found";
break;
case SS_INSUFFICIENT_RESOURCES:
return "Couldn't allocate resources needed to init";
break;
case SS_ASPI_IS_SHUTDOWN:
return "Call came to ASPI after PROCESS_DETACH";
break;
case SS_BAD_INSTALL:
return "The DLL or other components are installed wrong";
break;
default:
return "Unknow ASPI error");
}
}
/* General ioctl() CD-ROM command function */
static bool
mciSendCommand_aspi(int id, UINT msg, DWORD flags, void *arg)
@@ -111,6 +180,7 @@ is_cdrom_aspi(const char drive_letter)
DWORD dwSupportInfo;
int i_adapter, i_hostadapters;
char c_drive;
int i_rc;
if ( !have_aspi(&hASPI, &lpGetSupport, &lpSendCommand) )
return NULL;
@@ -118,15 +188,11 @@ is_cdrom_aspi(const char drive_letter)
/* 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");
i_rc = HIBYTE( LOWORD ( dwSupportInfo ) );
if( SS_COMP != rc ) {
cdio_debug("ASPI: %s", aspierror(i_rc));
FreeLibrary( hASPI );
return NULL;
}
@@ -205,6 +271,7 @@ init_aspi (_img_private_t *env)
DWORD dwSupportInfo;
int i_adapter, i_hostadapters;
char c_drive;
int i_rc;
if (2 == strlen(env->gen.source_name) && isalpha(env->gen.source_name[0]) )
{
@@ -221,14 +288,10 @@ init_aspi (_img_private_t *env)
dwSupportInfo = lpGetSupport();
if( HIBYTE( LOWORD ( dwSupportInfo ) ) == SS_NO_ADAPTERS ) {
cdio_debug("no host adapters found (ASPI)");
FreeLibrary( hASPI );
return false;
}
if( HIBYTE( LOWORD ( dwSupportInfo ) ) != SS_COMP ) {
cdio_debug("unable to initalize ASPI layer");
i_rc = HIBYTE( LOWORD ( dwSupportInfo ) );
if( SS_COMP != rc ) {
cdio_info("ASPI: %s", aspierror(i_rc));
FreeLibrary( hASPI );
return false;
}
@@ -402,6 +465,7 @@ mmc_read_sectors_aspi (const _img_private_t *env, void *data, lsn_t lsn,
/* check that the transfer went as planned */
if( ssc.SRB_Status != SS_COMP ) {
cdio_info("ASPI: %s", aspierror(ssc.SRB_Status));
return 1;
}
@@ -502,6 +566,7 @@ read_toc_aspi (_img_private_t *env)
/* check that the transfer went as planned */
if( ssc.SRB_Status != SS_COMP ) {
cdio_info("ASPI: %s", aspierror(ssc.SRB_Status));
CloseHandle( hEvent );
return false;
}
@@ -540,10 +605,10 @@ read_toc_aspi (_img_private_t *env)
WaitForSingleObject( hEvent, INFINITE );
/* check that the transfer went as planned */
#if 0
if( ssc.SRB_Status != SS_COMP )
if( ssc.SRB_Status != SS_COMP ) {
cdio_info("ASPI: %s", aspierror(ssc.SRB_Status));
env->total_tracks = 0;
#endif
}
for( i = 0 ; i <= env->total_tracks ; i++ ) {
int i_index = 8 + 8 * i;
@@ -664,6 +729,7 @@ get_drive_cap_aspi (const _img_private_t *env)
/* check that the transfer went as planned */
if( ssc.SRB_Status != SS_COMP ) {
cdio_info("ASPI: %s", aspierror(ssc.SRB_Status));
return i_drivetype;
} else {
BYTE *p;

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_linux.c,v 1.57 2004/06/26 00:39:00 rocky Exp $
$Id: _cdio_linux.c,v 1.58 2004/06/27 15:29:21 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.57 2004/06/26 00:39:00 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.58 2004/06/27 15:29:21 rocky Exp $";
#include <string.h>
@@ -819,7 +819,7 @@ _get_first_track_num_linux(void *user_data)
string when done with it.
*/
static char *
static cdio_mcn_t
_get_mcn_linux (const void *env) {
struct cdrom_mcn mcn;

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_osx.c,v 1.47 2004/06/26 01:20:41 rocky Exp $
$Id: _cdio_osx.c,v 1.48 2004/06/27 15:29:22 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
from vcdimager code:
@@ -34,7 +34,7 @@
#include "config.h"
#endif
static const char _rcsid[] = "$Id: _cdio_osx.c,v 1.47 2004/06/26 01:20:41 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_osx.c,v 1.48 2004/06/27 15:29:22 rocky Exp $";
#include <cdio/sector.h>
#include <cdio/util.h>
@@ -95,6 +95,8 @@ typedef struct {
int i_descriptors;
track_t i_last_track; /* highest track number */
track_t i_first_track; /* first track */
track_t i_last_session; /* highest session number */
track_t i_first_session; /* first session number */
lsn_t *pp_lba;
} _img_private_t;
@@ -383,7 +385,6 @@ _cdio_read_toc (_img_private_t *env)
int i, i_leadout = -1;
CDTOCDescriptor *pTrackDescriptors;
track_t i_track;
env->pp_lba = malloc( env->i_descriptors * sizeof(int) );
if( env->pp_lba == NULL )
@@ -395,24 +396,27 @@ _cdio_read_toc (_img_private_t *env)
pTrackDescriptors = env->pTOC->descriptors;
env->i_first_track = CDIO_CD_MAX_TRACKS+1;
env->i_last_track = CDIO_CD_MIN_TRACK_NO-1;
env->i_first_track = CDIO_CD_MAX_TRACKS+1;
env->i_last_track = CDIO_CD_MIN_TRACK_NO;
env->i_first_session = CDIO_CD_MAX_TRACKS+1;
env->i_last_session = CDIO_CD_MIN_TRACK_NO;
for( i = 0; i <= env->i_descriptors; i++ )
{
i_track = pTrackDescriptors[i].point;
track_t i_track = pTrackDescriptors[i].point;
session_t i_session = pTrackDescriptors[i].session;
cdio_debug( "point: %d, tno: %d, session: %d, adr: %d, control:%d, "
"address: %d:%d:%d, p: %d:%d:%d",
pTrackDescriptors[i].point,
pTrackDescriptors[i].tno, pTrackDescriptors[i].session,
pTrackDescriptors[i].adr, pTrackDescriptors[i].control,
pTrackDescriptors[i].address.minute,
pTrackDescriptors[i].address.second,
pTrackDescriptors[i].address.frame,
pTrackDescriptors[i].p.minute,
pTrackDescriptors[i].p.second,
pTrackDescriptors[i].p.frame );
"address: %d:%d:%d, p: %d:%d:%d",
i_track,
pTrackDescriptors[i].tno, i_session
pTrackDescriptors[i].adr, pTrackDescriptors[i].control,
pTrackDescriptors[i].address.minute,
pTrackDescriptors[i].address.second,
pTrackDescriptors[i].address.frame,
pTrackDescriptors[i].p.minute,
pTrackDescriptors[i].p.second,
pTrackDescriptors[i].p.frame );
/* track information has adr = 1 */
if ( 0x01 != pTrackDescriptors[i].adr )
@@ -430,6 +434,11 @@ _cdio_read_toc (_img_private_t *env)
if (env->i_last_track < i_track)
env->i_last_track = i_track;
if (env->i_first_session > i_session)
env->i_first_track = i_session;
if (env->i_last_session < i_session)
env->i_last_track = i_session;
}
/* Now that we know what the first track number is, we can make sure

View File

@@ -1,5 +1,5 @@
/*
$Id: bincue.c,v 1.22 2004/06/19 19:15:15 rocky Exp $
$Id: bincue.c,v 1.23 2004/06/27 15:29:22 rocky Exp $
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
@@ -24,7 +24,7 @@
(*.cue).
*/
static const char _rcsid[] = "$Id: bincue.c,v 1.22 2004/06/19 19:15:15 rocky Exp $";
static const char _rcsid[] = "$Id: bincue.c,v 1.23 2004/06/27 15:29:22 rocky Exp $";
#include "cdio_assert.h"
#include "cdio_private.h"
@@ -94,8 +94,9 @@ typedef struct {
bool sector_2336; /* Playstation (PSX) uses 2336-byte sectors */
char *cue_name;
char *mcn; /* Media catalog number. */
track_info_t tocent[100]; /* entry info for each track */
char *mcn; /* Media Catalog Number. */
track_info_t tocent[CDIO_CD_MAX_TRACKS+1]; /* entry info for each track
add 1 for leadout. */
track_t i_tracks; /* number of tracks in image */
track_t i_first_track; /* track number of first track */
bool have_cue;

View File

@@ -1,5 +1,5 @@
/*
$Id: cdrdao.c,v 1.9 2004/06/01 11:15:58 rocky Exp $
$Id: cdrdao.c,v 1.10 2004/06/27 15:29:22 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
toc reading routine adapted from cuetools
@@ -25,7 +25,7 @@
(*.cue).
*/
static const char _rcsid[] = "$Id: cdrdao.c,v 1.9 2004/06/01 11:15:58 rocky Exp $";
static const char _rcsid[] = "$Id: cdrdao.c,v 1.10 2004/06/27 15:29:22 rocky Exp $";
#include "cdio_assert.h"
#include "cdio_private.h"
@@ -106,7 +106,8 @@ typedef struct {
char *toc_name;
char *mcn; /* Media Catalog Number (5.22.3)
exactly 13 bytes */
track_info_t tocent[100]; /* entry info for each track */
track_info_t tocent[CDIO_CD_MAX_TRACKS+1]; /* entry info for each track
add 1 for leadout. */
track_t i_tracks; /* number of tracks in image */
track_t i_first_track; /* track number of first track */
track_format_t mode;

View File

@@ -1,5 +1,5 @@
/*
$Id: nrg.c,v 1.23 2004/06/18 22:55:24 rocky Exp $
$Id: nrg.c,v 1.24 2004/06/27 15:29:22 rocky Exp $
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2001, 2003 Herbert Valerio Riedel <hvr@gnu.org>
@@ -49,7 +49,7 @@
#include "_cdio_stdio.h"
#include "nrg.h"
static const char _rcsid[] = "$Id: nrg.c,v 1.23 2004/06/18 22:55:24 rocky Exp $";
static const char _rcsid[] = "$Id: nrg.c,v 1.24 2004/06/27 15:29:22 rocky Exp $";
/* reader */
@@ -99,8 +99,9 @@ typedef struct {
/* This is a hack because I don't really understnad NERO better. */
bool is_cues;
char *mcn; /* Media catalog number. */
track_info_t tocent[100]; /* entry info for each track */
char *mcn; /* Media Catalog Number (5.22.3) */
track_info_t tocent[CDIO_CD_MAX_TRACKS+1]; /* entry info for each track
add 1 for leadout. */
track_t i_tracks; /* number of tracks in image */
track_t i_first_track; /* track number of first track */
CdioList *mapping; /* List of track information */
@@ -384,18 +385,21 @@ parse_nrg (_img_private_t *env, const char *psz_nrg_name)
track_format_t track_format;
int form2;
env->mcn = _cdio_malloc (CDIO_MCN_SIZE);
/* We include an extra 0 byte so these can be used as C strings.*/
env->mcn = _cdio_malloc (CDIO_MCN_SIZE+1);
if (DAOX_ID == opcode) {
_daox_array_t *_entries = (void *) chunk->data;
form2 = _entries->_unknown[1];
env->dtyp = _entries->_unknown[19];
memcpy(env->mcn, &(_entries->mcn), CDIO_MCN_SIZE);
env->mcn[CDIO_MCN_SIZE] = '\0';
} else {
_daoi_array_t *_entries = (void *) chunk->data;
form2 = _entries->_unknown[1];
env->dtyp = _entries->_unknown[19];
memcpy(env->mcn, &(_entries->mcn), CDIO_MCN_SIZE);
env->mcn[CDIO_MCN_SIZE] = '\0';
}
env->is_dao = true;