First attempt at smart iso9660 reading in CD images.

_cdio_stream.*: return is now cdio_driver_return_t
This commit is contained in:
rocky
2005-02-05 04:25:14 +00:00
parent a35a0a61d3
commit d958f062ea
10 changed files with 334 additions and 112 deletions

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_stdio.c,v 1.3 2005/02/03 07:35:15 rocky Exp $
$Id: _cdio_stdio.c,v 1.4 2005/02/05 04:25:14 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -39,7 +39,7 @@
#include "_cdio_stream.h"
#include "_cdio_stdio.h"
static const char _rcsid[] = "$Id: _cdio_stdio.c,v 1.3 2005/02/03 07:35:15 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_stdio.c,v 1.4 2005/02/05 04:25:14 rocky Exp $";
#define CDIO_STDIO_BUFSIZE (128*1024)
@@ -106,27 +106,26 @@ _stdio_free(void *user_data)
of-file indicator for the stream and undoes any effects of the
ungetc(3) function on the same stream.
RETURN VALUE
Upon successful completion, return 0,
Otherwise, -1 is returned and the global variable errno is set to indi-
cate the error.
@return upon successful completion, DRIVER_OP_SUCCESS, else,
DRIVER_OP_ERROR is returned and the global variable errno is set to
indicate the error.
*/
static long
_stdio_seek(void *user_data, long offset, int whence)
static driver_return_code_t
_stdio_seek(void *p_user_data, long i_offset, int whence)
{
_UserData *const ud = user_data;
_UserData *const ud = p_user_data;
if ( (offset=fseek (ud->fd, offset, whence)) ) {
if ( (i_offset=fseek (ud->fd, i_offset, whence)) ) {
cdio_error ("fseek (): %s", strerror (errno));
}
return offset;
return i_offset;
}
static long int
_stdio_stat(void *user_data)
_stdio_stat(void *p_user_data)
{
const _UserData *const ud = user_data;
const _UserData *const ud = p_user_data;
return ud->st_size;
}

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_stream.c,v 1.5 2005/02/03 07:35:15 rocky Exp $
$Id: _cdio_stream.c,v 1.6 2005/02/05 04:25:14 rocky Exp $
Copyright (C) 2000, 2004, 2005 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -35,7 +35,7 @@
#include <cdio/util.h>
#include "_cdio_stream.h"
static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.5 2005/02/03 07:35:15 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.6 2005/02/05 04:25:14 rocky Exp $";
/*
* DataSource implementations
@@ -82,21 +82,20 @@ _cdio_stream_open_if_necessary(CdioDataSource_t *p_obj)
of-file indicator for the stream and undoes any effects of the
ungetc(3) function on the same stream.
RETURN VALUE
Upon successful completion, return 0,
Otherwise, -1 is returned and the global variable errno is set to indi-
cate the error.
@return unpon successful completion, DRIVER_OP_SUCCESS, else,
DRIVER_OP_ERROR is returned and the global variable errno is set to
indicate the error.
*/
long int
driver_return_code_t
cdio_stream_seek(CdioDataSource_t* p_obj, long int offset, int whence)
{
if (!p_obj) return -1;
if (!p_obj) return DRIVER_OP_UNINIT;
if (!_cdio_stream_open_if_necessary(p_obj))
/* errno is set by _cdio_stream_open_if necessary. */
return -1;
return DRIVER_OP_ERROR;
if (offset < 0) return -1;
if (offset < 0) return DRIVER_OP_ERROR;
if (p_obj->position != offset) {
#ifdef STREAM_DEBUG

View File

@@ -1,8 +1,8 @@
/*
$Id: _cdio_stream.h,v 1.2 2005/01/20 01:00:52 rocky Exp $
$Id: _cdio_stream.h,v 1.3 2005/02/05 04:25:14 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2003, 2004, 2005 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
@@ -36,7 +36,8 @@ extern "C" {
typedef long(*cdio_data_read_t)(void *user_data, void *buf, long count);
typedef long(*cdio_data_seek_t)(void *user_data, long offset, int whence);
typedef driver_return_code_t(*cdio_data_seek_t)(void *user_data, long offset,
int whence);
typedef long(*cdio_data_stat_t)(void *user_data);
@@ -76,7 +77,7 @@ extern "C" {
We do not distinguish between end-of-file and error, and callers
must use feof(3) and ferror(3) to determine which occurred.
*/
long cdio_stream_read(CdioDataSource_t* p_obj, void *ptr, long size,
long cdio_stream_read(CdioDataSource_t* p_obj, void *ptr, long i_size,
long nmemb);
/*!
@@ -91,12 +92,12 @@ extern "C" {
of-file indicator for the stream and undoes any effects of the
ungetc(3) function on the same stream.
RETURN VALUE
Upon successful completion, return 0,
Otherwise, -1 is returned and the global variable errno is set to indi-
cate the error.
@return upon successful completion, DRIVER_OP_SUCCESS, else,
DRIVER_OP_ERROR is returned and the global variable errno is set to
indicate the error.
*/
long int cdio_stream_seek(CdioDataSource_t *p_obj, long offset, int whence);
driver_return_code_t cdio_stream_seek(CdioDataSource_t *p_obj, long offset,
int whence);
/*!
Return whatever size of stream reports, I guess unit size is bytes.

View File

@@ -1,5 +1,5 @@
/*
$Id: read.c,v 1.3 2005/01/23 19:16:58 rocky Exp $
$Id: read.c,v 1.4 2005/02/05 04:25:14 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -104,7 +104,7 @@ cdio_read (const CdIo_t *p_cdio, void *p_buf, size_t size)
/*!
Reads an audio sector from cd device into data starting
from lsn. Returns 0 if no error.
from lsn. Returns DRIVER_OP_SUCCESS if no error.
*/
driver_return_code_t
cdio_read_audio_sector (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn)
@@ -117,7 +117,7 @@ cdio_read_audio_sector (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn)
/*!
Reads audio sectors from cd device into data starting
from lsn. Returns 0 if no error.
from lsn. Returns DRIVER_OP_SUCCESS if no error.
*/
driver_return_code_t
cdio_read_audio_sectors (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn,
@@ -135,7 +135,7 @@ cdio_read_audio_sectors (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn,
/*!
Reads a single mode1 form1 or form2 sector from cd device
into data starting from lsn. Returns 0 if no error.
into data starting from lsn. Returns DRIVER_OP_SUCCESS if no error.
*/
driver_return_code_t
cdio_read_mode1_sector (const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn,

View File

@@ -1,7 +1,7 @@
/*
$Id: sector.c,v 1.1 2004/12/18 17:29:32 rocky Exp $
$Id: sector.c,v 1.2 2005/02/05 04:25:14 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software; you can redistribute it and/or modify
@@ -35,8 +35,13 @@
#include <ctype.h>
static const char _rcsid[] = "$Id: sector.c,v 1.1 2004/12/18 17:29:32 rocky Exp $";
static const char _rcsid[] = "$Id: sector.c,v 1.2 2005/02/05 04:25:14 rocky Exp $";
/*! String of bytes used to identify the beginning of a Mode 1 or
Mode 2 sector. */
const uint8_t CDIO_SECTOR_SYNC_HEADER[CDIO_CD_SYNC_SIZE] =
{0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0};
lba_t
cdio_lba_to_lsn (lba_t lba)
{