Move a set_speed and set_blocksize (via MMC)from driver-specific

places to generic.

Add _t to yet another type.
This commit is contained in:
rocky
2005-01-20 01:00:52 +00:00
parent f7ebed2287
commit bd333bc73f
13 changed files with 99 additions and 104 deletions

View File

@@ -1,7 +1,7 @@
/*
$Id: freebsd.c,v 1.4 2005/01/18 04:03:06 rocky Exp $
$Id: freebsd.c,v 1.5 2005/01/20 01:00:52 rocky Exp $
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
@@ -27,7 +27,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: freebsd.c,v 1.4 2005/01/18 04:03:06 rocky Exp $";
static const char _rcsid[] = "$Id: freebsd.c,v 1.5 2005/01/20 01:00:52 rocky Exp $";
#include "freebsd.h"

View File

@@ -1,5 +1,5 @@
/*
$Id: win32.c,v 1.6 2005/01/18 05:41:58 rocky Exp $
$Id: win32.c,v 1.7 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -26,7 +26,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: win32.c,v 1.6 2005/01/18 05:41:58 rocky Exp $";
static const char _rcsid[] = "$Id: win32.c,v 1.7 2005/01/20 01:00:52 rocky Exp $";
#include <cdio/cdio.h>
#include <cdio/sector.h>
@@ -494,20 +494,6 @@ _get_arg_win32 (void *user_data, const char key[])
return NULL;
}
static int
set_speed_win32 (void *p_user_data, int i_speed) {
const _img_private_t *p_env = p_user_data;
if (!p_env) return -1;
return scsi_mmc_set_speed( p_env->gen.cdio, i_speed );
}
static int
set_blocksize_win32 (void *p_user_data, int i_blocksize) {
const _img_private_t *p_env = p_user_data;
if (!p_env) return -1;
return scsi_mmc_set_blocksize( p_env->gen.cdio, i_blocksize );
}
/*!
Return the media catalog number MCN.
@@ -773,8 +759,8 @@ cdio_open_am_win32 (const char *psz_orig_source, const char *psz_access_mode)
_funcs.read_toc = &read_toc_win32;
_funcs.run_scsi_mmc_cmd = &run_scsi_cmd_win32;
_funcs.set_arg = set_arg_win32;
_funcs.set_blocksize = set_blocksize_win32;
_funcs.set_speed = set_speed_win32;
_funcs.set_blocksize = set_blocksize_generic;
_funcs.set_speed = set_speed_generic;
_funcs.stat_size = stat_size_win32;
_data = _cdio_malloc (sizeof (_img_private_t));

View File

@@ -1,7 +1,7 @@
/*
$Id: _cdio_generic.c,v 1.7 2005/01/19 09:23:24 rocky Exp $
$Id: _cdio_generic.c,v 1.8 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
Copyright (C) 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
@@ -25,7 +25,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.7 2005/01/19 09:23:24 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.8 2005/01/20 01:00:52 rocky Exp $";
#include <stdio.h>
#include <stdlib.h>
@@ -170,9 +170,9 @@ cdio_generic_read (void *user_data, void *buf, size_t size)
Release and free resources associated with stream or disk image.
*/
void
cdio_generic_stdio_free (void *user_data)
cdio_generic_stdio_free (void *p_user_data)
{
generic_img_private_t *p_env = user_data;
generic_img_private_t *p_env = p_user_data;
if (NULL == p_env) return;
if (NULL != p_env->source_name)
@@ -488,6 +488,24 @@ set_track_flags(track_flags_t *p_track_flag, uint8_t i_flag)
? 4 : 2;
}
/* Set read blocksize (via MMC) */
driver_return_code_t
set_blocksize_generic (void *p_user_data, int i_blocksize)
{
generic_img_private_t *p_env = p_user_data;
if (!p_env) return DRIVER_OP_UNINIT;
return scsi_mmc_set_blocksize(p_env->cdio, i_blocksize);
}
/* Set CD-ROM drive speed (via MMC) */
driver_return_code_t
set_speed_generic (void *p_user_data, int i_speed)
{
generic_img_private_t *p_env = p_user_data;
if (!p_env) return DRIVER_OP_UNINIT;
return scsi_mmc_set_speed( p_env->cdio, i_speed );
}
/*

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_linux.c,v 1.12 2005/01/20 00:36:38 rocky Exp $
$Id: _cdio_linux.c,v 1.13 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h"
#endif
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.12 2005/01/20 00:36:38 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.13 2005/01/20 01:00:52 rocky Exp $";
#include <string.h>
@@ -982,14 +982,6 @@ static char checklist2[][40] = {
{"?a hd?"}, {"?0 scd?"}, {"?0 sr?"}, {""}
};
/* Set read blocksize */
static driver_return_code_t
set_blocksize_linux (void *p_user_data, int i_blocksize)
{
const _img_private_t *p_env = p_user_data;
return scsi_mmc_set_blocksize(p_env->gen.cdio, i_blocksize);
}
/* Set CD-ROM drive speed */
static driver_return_code_t
set_speed_linux (void *p_user_data, int i_speed)
@@ -1174,7 +1166,7 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode)
.read_toc = read_toc_linux,
.run_scsi_mmc_cmd = run_scsi_cmd_linux,
.set_arg = set_arg_linux,
.set_blocksize = set_blocksize_linux,
.set_blocksize = set_blocksize_generic,
.set_speed = set_speed_linux,
.stat_size = stat_size_linux
};

View File

@@ -1,8 +1,8 @@
/*
$Id: _cdio_stdio.c,v 1.1 2004/12/18 17:29:32 rocky Exp $
$Id: _cdio_stdio.c,v 1.2 2005/01/20 01:00:52 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
@@ -39,7 +39,7 @@
#include "_cdio_stream.h"
#include "_cdio_stdio.h"
static const char _rcsid[] = "$Id: _cdio_stdio.c,v 1.1 2004/12/18 17:29:32 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_stdio.c,v 1.2 2005/01/20 01:00:52 rocky Exp $";
#define CDIO_STDIO_BUFSIZE (128*1024)
@@ -179,15 +179,15 @@ _stdio_read(void *user_data, void *buf, long int count)
Deallocate resources assocaited with obj. After this obj is unusable.
*/
void
cdio_stdio_destroy(CdioDataSource *obj)
cdio_stdio_destroy(CdioDataSource_t *p_obj)
{
cdio_stream_destroy(obj);
cdio_stream_destroy(p_obj);
}
CdioDataSource*
CdioDataSource_t *
cdio_stdio_new(const char pathname[])
{
CdioDataSource *new_obj = NULL;
CdioDataSource_t *new_obj = NULL;
cdio_stream_io_functions funcs = { 0, };
_UserData *ud = NULL;
struct stat statbuf;

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_stdio.h,v 1.1 2004/12/18 17:29:32 rocky Exp $
$Id: _cdio_stdio.h,v 1.2 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
@@ -32,12 +32,12 @@
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[]);
CdioDataSource_t * cdio_stdio_new(const char psz_path[]);
/*!
Deallocate resources assocaited with obj. After this obj is unusable.
*/
void cdio_stdio_destroy(CdioDataSource *obj);
void cdio_stdio_destroy(CdioDataSource_t *p_obj);
#endif /* __CDIO_STREAM_STDIO_H__ */

View File

@@ -1,7 +1,7 @@
/*
$Id: _cdio_stream.c,v 1.1 2004/12/18 17:29:32 rocky Exp $
$Id: _cdio_stream.c,v 1.2 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2000, 2004 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2000, 2004, 2005 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 2004/12/18 17:29:32 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_stream.c,v 1.2 2005/01/20 01:00:52 rocky Exp $";
/*
* DataSource implementations
@@ -52,7 +52,7 @@ struct _CdioDataSource {
Return false if we hit an error. Errno should be set for that error.
*/
static bool
_cdio_stream_open_if_necessary(CdioDataSource *p_obj)
_cdio_stream_open_if_necessary(CdioDataSource_t *p_obj)
{
cdio_assert (p_obj != NULL);
@@ -87,7 +87,7 @@ _cdio_stream_open_if_necessary(CdioDataSource *p_obj)
cate the error.
*/
long
cdio_stream_seek(CdioDataSource* p_obj, long int offset, int whence)
cdio_stream_seek(CdioDataSource_t* p_obj, long int offset, int whence)
{
cdio_assert (p_obj != NULL);
@@ -106,12 +106,12 @@ cdio_stream_seek(CdioDataSource* p_obj, long int offset, int whence)
return 0;
}
CdioDataSource*
CdioDataSource_t *
cdio_stream_new(void *user_data, const cdio_stream_io_functions *funcs)
{
CdioDataSource *new_obj;
CdioDataSource_t *new_obj;
new_obj = _cdio_malloc (sizeof (CdioDataSource));
new_obj = _cdio_malloc (sizeof (CdioDataSource_t));
new_obj->user_data = user_data;
memcpy(&(new_obj->op), funcs, sizeof(cdio_stream_io_functions));
@@ -137,16 +137,16 @@ cdio_stream_new(void *user_data, const cdio_stream_io_functions *funcs)
must use feof(3) and ferror(3) to determine which occurred.
*/
long
cdio_stream_read(CdioDataSource* obj, void *ptr, long size, long nmemb)
cdio_stream_read(CdioDataSource_t* p_obj, void *ptr, long size, long nmemb)
{
long read_bytes;
cdio_assert (obj != NULL);
cdio_assert (p_obj != NULL);
if (!_cdio_stream_open_if_necessary(obj)) return 0;
if (!_cdio_stream_open_if_necessary(p_obj)) return 0;
read_bytes = obj->op.read(obj->user_data, ptr, size*nmemb);
obj->position += read_bytes;
read_bytes = p_obj->op.read(p_obj->user_data, ptr, size*nmemb);
p_obj->position += read_bytes;
return read_bytes;
}
@@ -156,38 +156,38 @@ cdio_stream_read(CdioDataSource* obj, void *ptr, long size, long nmemb)
On error return -1;
*/
long int
cdio_stream_stat(CdioDataSource* obj)
cdio_stream_stat(CdioDataSource_t *p_obj)
{
cdio_assert (obj != NULL);
cdio_assert (p_obj != NULL);
if (!_cdio_stream_open_if_necessary(obj)) return -1;
if (!_cdio_stream_open_if_necessary(p_obj)) return -1;
return obj->op.stat(obj->user_data);
return p_obj->op.stat(p_obj->user_data);
}
void
cdio_stream_close(CdioDataSource* obj)
cdio_stream_close(CdioDataSource_t *p_obj)
{
cdio_assert (obj != NULL);
cdio_assert (p_obj != NULL);
if (obj->is_open) {
if (p_obj->is_open) {
cdio_debug ("closed source...");
obj->op.close(obj->user_data);
obj->is_open = 0;
obj->position = 0;
p_obj->op.close(p_obj->user_data);
p_obj->is_open = 0;
p_obj->position = 0;
}
}
void
cdio_stream_destroy(CdioDataSource* obj)
cdio_stream_destroy(CdioDataSource_t *p_obj)
{
cdio_assert (obj != NULL);
cdio_assert (p_obj != NULL);
cdio_stream_close(obj);
cdio_stream_close(p_obj);
obj->op.free(obj->user_data);
p_obj->op.free(p_obj->user_data);
free(obj);
free(p_obj);
}

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_stream.h,v 1.1 2004/12/18 17:29:32 rocky Exp $
$Id: _cdio_stream.h,v 1.2 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -56,7 +56,7 @@ extern "C" {
cdio_data_free_t free;
} cdio_stream_io_functions;
CdioDataSource*
CdioDataSource_t *
cdio_stream_new(void *user_data, const cdio_stream_io_functions *funcs);
/*!
@@ -76,8 +76,8 @@ 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* obj, void *ptr, long size, long nmemb);
long cdio_stream_read(CdioDataSource_t* p_obj, void *ptr, long size,
long nmemb);
/*!
Like fseek(3) and in fact may be the same.
@@ -96,20 +96,20 @@ extern "C" {
Otherwise, -1 is returned and the global variable errno is set to indi-
cate the error.
*/
long int cdio_stream_seek(CdioDataSource* obj, long offset, int whence);
long int cdio_stream_seek(CdioDataSource_t *p_obj, long offset, int whence);
/*!
Return whatever size of stream reports, I guess unit size is bytes.
On error return -1;
*/
long int cdio_stream_stat(CdioDataSource* obj);
long int cdio_stream_stat(CdioDataSource_t *p_obj);
/*!
Deallocate resources assocaited with obj. After this obj is unusable.
Deallocate resources assocaited with p_obj. After this p_obj is unusable.
*/
void cdio_stream_destroy(CdioDataSource* obj);
void cdio_stream_destroy(CdioDataSource_t *p_obj);
void cdio_stream_close(CdioDataSource* obj);
void cdio_stream_close(CdioDataSource_t *p_obj);
#ifdef __cplusplus
}

View File

@@ -1,5 +1,5 @@
/*
$Id: _cdio_sunos.c,v 1.9 2005/01/20 00:36:38 rocky Exp $
$Id: _cdio_sunos.c,v 1.10 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -38,7 +38,7 @@
#ifdef HAVE_SOLARIS_CDROM
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.9 2005/01/20 00:36:38 rocky Exp $";
static const char _rcsid[] = "$Id: _cdio_sunos.c,v 1.10 2005/01/20 01:00:52 rocky Exp $";
#ifdef HAVE_GLOB_H
#include <glob.h>
@@ -766,14 +766,6 @@ _cdio_get_track_msf(void *p_user_data, track_t i_track, msf_t *msf)
}
}
/* Set read blocksize */
static driver_return_code_t
set_blocksize_solaris (void *p_user_data, int i_blocksize)
{
const _img_private_t *p_env = p_user_data;
return scsi_mmc_set_blocksize(p_env->gen.cdio, i_blocksize);
}
/* Set CD-ROM drive speed */
static driver_return_code_t
set_speed_solaris (void *p_user_data, int i_speed)
@@ -901,7 +893,7 @@ cdio_open_am_solaris (const char *psz_orig_source, const char *access_mode)
_funcs.run_scsi_mmc_cmd = run_scsi_cmd_solaris;
_funcs.stat_size = _cdio_stat_size;
_funcs.set_arg = _set_arg_solaris;
_funcs.set_blocksize = set_blocksize_solaris;
_funcs.set_blocksize = set_blocksize_generic;
_funcs.set_speed = set_speed_solaris;
_funcs.stat_size = _cdio_stat_size;

View File

@@ -1,5 +1,5 @@
/*
$Id: cdio_private.h,v 1.6 2005/01/18 00:57:20 rocky Exp $
$Id: cdio_private.h,v 1.7 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -37,7 +37,7 @@ extern "C" {
#endif /* __cplusplus */
/* Opaque type */
typedef struct _CdioDataSource CdioDataSource;
typedef struct _CdioDataSource CdioDataSource_t;
#ifdef __cplusplus
}

View File

@@ -1,5 +1,5 @@
/*
$Id: generic.h,v 1.7 2005/01/19 09:23:24 rocky Exp $
$Id: generic.h,v 1.8 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -55,7 +55,7 @@ extern "C" {
devices and the data_source for stream reading (bincue, nrg, toc,
network).
*/
CdioDataSource *data_source;
CdioDataSource_t *data_source;
int fd; /**< File descriptor of device */
track_t i_first_track; /**< The starting track number. */
track_t i_tracks; /**< The number of tracks. */
@@ -198,6 +198,13 @@ extern "C" {
track_flag_t get_track_preemphasis_generic(const void *p_user_data,
track_t i_track);
/* Set read blocksize (via MMC) */
driver_return_code_t set_blocksize_generic (void *p_user_data,
int i_blocksize);
/* Set CD-ROM drive speed (via MMC) */
driver_return_code_t set_speed_generic (void *p_user_data, int i_speed);
void set_cdtext_field_generic(void *user_data, track_t i_track,
track_t i_first_track,
cdtext_field_t e_field, const char *psz_value);

View File

@@ -1,5 +1,5 @@
/*
$Id: image.h,v 1.3 2005/01/16 04:25:16 rocky Exp $
$Id: image.h,v 1.4 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -56,7 +56,7 @@ typedef struct {
flag_t flags; /**< "[NO] COPY", "4CH", "[NO] PREMPAHSIS" */
char *isrc; /**< IRSC Code (5.22.4) exactly 12 bytes */
char *filename;
CdioDataSource *data_source;
CdioDataSource_t *data_source;
track_format_t track_format;
bool track_green;
cdtext_t cdtext; /**< CD-TEXT */

View File

@@ -1,5 +1,5 @@
/*
$Id: iso9660_fs.c,v 1.3 2005/01/12 11:34:52 rocky Exp $
$Id: iso9660_fs.c,v 1.4 2005/01/20 01:00:52 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
@@ -51,11 +51,11 @@
#include <stdio.h>
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.3 2005/01/12 11:34:52 rocky Exp $";
static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.4 2005/01/20 01:00:52 rocky Exp $";
/* Implementation of iso9660_t type */
struct _iso9660 {
CdioDataSource *stream; /* Stream pointer */
CdioDataSource_t *stream; /* Stream pointer */
bool b_xa; /* true if has XA attributes. */
uint8_t i_joliet_level;/* 0 = no Joliet extensions.
1-3: Joliet level. */