Try to regularize driver operation return codes via a new enumeation
return type. (I may regret this later as we return ioctl's int value in some cases). cdio.h: get/set_arg moved to device.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* -*- c -*-
|
||||
$Id: cdio.h,v 1.75 2005/01/09 16:07:46 rocky Exp $
|
||||
$Id: cdio.h,v 1.76 2005/01/19 09:23:24 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -57,31 +57,6 @@ extern "C" {
|
||||
/** This is an opaque structure for the CD-Text object. */
|
||||
typedef struct cdtext cdtext_t;
|
||||
|
||||
/*!
|
||||
Get the value associatied with key.
|
||||
|
||||
@param p_cdio the CD object queried
|
||||
@param key the key to retrieve
|
||||
@return the value associatd with "key" or NULL if p_cdio is NULL
|
||||
or "key" does not exist.
|
||||
*/
|
||||
const char * cdio_get_arg (const CdIo_t *p_cdio, const char key[]);
|
||||
|
||||
/*!
|
||||
Set the arg "key" with "value" in "p_cdio".
|
||||
|
||||
@param p_cdio the CD object to set
|
||||
@param key the key to set
|
||||
@param value the value to assocaiate with key
|
||||
@return 0 if no error was found, and nonzero otherwise.
|
||||
*/
|
||||
int cdio_set_arg (CdIo_t *p_cdio, const char key[], const char value[]);
|
||||
|
||||
/*!
|
||||
Initialize CD Reading and control routines. Should be called first.
|
||||
*/
|
||||
bool cdio_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* -*- c -*-
|
||||
$Id: device.h,v 1.4 2005/01/18 00:57:19 rocky Exp $
|
||||
$Id: device.h,v 1.5 2005/01/19 09:23:24 rocky Exp $
|
||||
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -102,14 +102,31 @@ extern "C" {
|
||||
#define CDIO_MAX_DRIVER DRIVER_NRG
|
||||
#define CDIO_MAX_DEVICE_DRIVER DRIVER_WIN32
|
||||
|
||||
/** There will generally be only one hardware for a given
|
||||
build/platform from the list above. You can use the variable
|
||||
below to determine which you've got. If the build doesn't make an
|
||||
hardware driver, then the value will be DRIVER_UNKNOWN.
|
||||
*/
|
||||
typedef enum {
|
||||
DRIVER_OP_UNSUPPORTED = -2, /**< returned when a particular driver
|
||||
doesn't support a particular operation.
|
||||
For example an image driver which doesn't
|
||||
really "eject" a CD.
|
||||
*/
|
||||
DRIVER_OP_ERROR = -1, /**< operation returned an error */
|
||||
DRIVER_OP_SUCCESS = 0, /**< in cases where an int is returned,
|
||||
like cdio_set_speed, more the negative
|
||||
return codes are for errors and the
|
||||
positive ones for success. */
|
||||
} driver_return_code_t;
|
||||
|
||||
/*!
|
||||
Eject media in CD drive if there is a routine to do so.
|
||||
|
||||
@param p_cdio the CD object to be acted upon.
|
||||
@return 0 if success and 1 for failure, and -2 if no routine.
|
||||
If the CD is ejected *p_cdio is freed and p_cdio set to NULL.
|
||||
*/
|
||||
int cdio_eject_media (CdIo_t **p_cdio);
|
||||
driver_return_code_t cdio_eject_media (CdIo_t **p_cdio);
|
||||
|
||||
/*!
|
||||
Free device list returned by cdio_get_devices or
|
||||
@@ -250,8 +267,9 @@ extern "C" {
|
||||
/*!
|
||||
Get the drive speed.
|
||||
|
||||
@return the drive speed if greater than 0. -1 if we had an error. is -2
|
||||
returned if this is not implemented for the current driver.
|
||||
@return the drive speed if greater than 0. DRIVER_OP_ERROR if we
|
||||
had an error, DRIVER_OP_UNSUPPORTED if this is not implemented for
|
||||
the current driver.
|
||||
|
||||
@see cdio_set_speed
|
||||
*/
|
||||
@@ -739,21 +757,41 @@ extern "C" {
|
||||
|
||||
/*!
|
||||
Set the blocksize for subsequent reads.
|
||||
|
||||
@return 0 if everything went okay, -1 if we had an error. is -2
|
||||
returned if this is not implemented for the current driver.
|
||||
*/
|
||||
int cdio_set_blocksize ( const CdIo_t *p_cdio, int i_blocksize );
|
||||
driver_return_code_t cdio_set_blocksize ( const CdIo_t *p_cdio,
|
||||
int i_blocksize );
|
||||
|
||||
/*!
|
||||
Set the drive speed.
|
||||
|
||||
@return 0 if everything went okay, -1 if we had an error. is -2
|
||||
returned if this is not implemented for the current driver.
|
||||
|
||||
@see cdio_get_speed
|
||||
*/
|
||||
int cdio_set_speed ( const CdIo_t *p_cdio, int i_speed );
|
||||
driver_return_code_t cdio_set_speed ( const CdIo_t *p_cdio, int i_speed );
|
||||
|
||||
/*!
|
||||
Get the value associatied with key.
|
||||
|
||||
@param p_cdio the CD object queried
|
||||
@param key the key to retrieve
|
||||
@return the value associatd with "key" or NULL if p_cdio is NULL
|
||||
or "key" does not exist.
|
||||
*/
|
||||
const char * cdio_get_arg (const CdIo_t *p_cdio, const char key[]);
|
||||
|
||||
/*!
|
||||
Set the arg "key" with "value" in "p_cdio".
|
||||
|
||||
@param p_cdio the CD object to set
|
||||
@param key the key to set
|
||||
@param value the value to assocaiate with key
|
||||
*/
|
||||
driver_return_code_t cdio_set_arg (CdIo_t *p_cdio, const char key[],
|
||||
const char value[]);
|
||||
|
||||
/*!
|
||||
Initialize CD Reading and control routines. Should be called first.
|
||||
*/
|
||||
bool cdio_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_generic.c,v 1.6 2005/01/18 00:57:20 rocky Exp $
|
||||
$Id: _cdio_generic.c,v 1.7 2005/01/19 09:23:24 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.6 2005/01/18 00:57:20 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.7 2005/01/19 09:23:24 rocky Exp $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -56,29 +56,25 @@ static const char _rcsid[] = "$Id: _cdio_generic.c,v 1.6 2005/01/18 00:57:20 roc
|
||||
int
|
||||
cdio_generic_unimplemented_eject_media (void *p_user_data) {
|
||||
/* Sort of a stub here. Perhaps log a message? */
|
||||
return -2;
|
||||
return DRIVER_OP_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the blocksize for subsequent reads.
|
||||
|
||||
@return -2 since it's not implemented.
|
||||
*/
|
||||
int
|
||||
cdio_generic_unimplemented_set_blocksize (void *p_user_data, int i_blocksize) {
|
||||
/* Sort of a stub here. Perhaps log a message? */
|
||||
return -2;
|
||||
return DRIVER_OP_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the drive speed.
|
||||
|
||||
@return -2 since it's not implemented.
|
||||
*/
|
||||
int
|
||||
cdio_generic_unimplemented_set_speed (void *p_user_data, int i_speed) {
|
||||
/* Sort of a stub here. Perhaps log a message? */
|
||||
return -2;
|
||||
return DRIVER_OP_UNSUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
$Id: _cdio_linux.c,v 1.9 2005/01/18 01:48:42 rocky Exp $
|
||||
$Id: _cdio_linux.c,v 1.10 2005/01/19 09:23:24 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 2002, 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: _cdio_linux.c,v 1.9 2005/01/18 01:48:42 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_linux.c,v 1.10 2005/01/19 09:23:24 rocky Exp $";
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -403,11 +403,11 @@ get_track_msf_linux(void *p_user_data, track_t i_track, msf_t *msf)
|
||||
Eject media in CD drive.
|
||||
Return 0 if success and 1 for failure, and 2 if no routine.
|
||||
*/
|
||||
static int
|
||||
static driver_return_code_t
|
||||
eject_media_linux (void *p_user_data) {
|
||||
|
||||
_img_private_t *p_env = p_user_data;
|
||||
int ret=2;
|
||||
int ret=DRIVER_OP_SUCCESS;
|
||||
int status;
|
||||
int fd;
|
||||
|
||||
@@ -417,7 +417,7 @@ eject_media_linux (void *p_user_data) {
|
||||
case CDS_TRAY_OPEN:
|
||||
if((ret = ioctl(fd, CDROMCLOSETRAY)) != 0) {
|
||||
cdio_warn ("ioctl CDROMCLOSETRAY failed: %s\n", strerror(errno));
|
||||
ret = 1;
|
||||
ret = DRIVER_OP_ERROR;
|
||||
}
|
||||
break;
|
||||
case CDS_DISC_OK:
|
||||
@@ -428,7 +428,7 @@ eject_media_linux (void *p_user_data) {
|
||||
if (0 != ret) {
|
||||
cdio_warn("ioctl CDROMEJECT failed: %s\n",
|
||||
strerror(eject_error));
|
||||
ret = 1;
|
||||
ret = DRIVER_OP_ERROR;
|
||||
}
|
||||
}
|
||||
/* force kernel to reread partition table when new disc inserted */
|
||||
@@ -436,15 +436,15 @@ eject_media_linux (void *p_user_data) {
|
||||
break;
|
||||
default:
|
||||
cdio_warn ("Unknown CD-ROM (%d)\n", status);
|
||||
ret = 1;
|
||||
ret = DRIVER_OP_ERROR;
|
||||
}
|
||||
} else {
|
||||
cdio_warn ("CDROM_DRIVE_STATUS failed: %s\n", strerror(errno));
|
||||
ret=1;
|
||||
ret=DRIVER_OP_ERROR;
|
||||
}
|
||||
close(fd);
|
||||
} else
|
||||
ret = 2;
|
||||
ret = DRIVER_OP_ERROR;
|
||||
close(p_env->gen.fd);
|
||||
p_env->gen.fd = -1;
|
||||
return ret;
|
||||
@@ -953,15 +953,14 @@ stat_size_linux (void *p_user_data)
|
||||
|
||||
0 is returned if no error was found, and nonzero if there as an error.
|
||||
*/
|
||||
static int
|
||||
static driver_return_code_t
|
||||
set_arg_linux (void *p_user_data, const char key[], const char value[])
|
||||
{
|
||||
_img_private_t *p_env = p_user_data;
|
||||
|
||||
if (!strcmp (key, "source"))
|
||||
{
|
||||
if (!value)
|
||||
return -2;
|
||||
if (!value) return DRIVER_OP_ERROR;
|
||||
|
||||
free (p_env->gen.source_name);
|
||||
|
||||
@@ -971,10 +970,9 @@ set_arg_linux (void *p_user_data, const char key[], const char value[])
|
||||
{
|
||||
return str_to_access_mode_linux(value);
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
else return DRIVER_OP_ERROR;
|
||||
|
||||
return 0;
|
||||
return DRIVER_OP_SUCCESS;
|
||||
}
|
||||
|
||||
/* checklist: /dev/cdrom, /dev/dvd /dev/hd?, /dev/scd? /dev/sr? */
|
||||
@@ -986,7 +984,7 @@ static char checklist2[][40] = {
|
||||
};
|
||||
|
||||
/* Set read blocksize */
|
||||
static int
|
||||
static driver_return_code_t
|
||||
set_blocksize_linux (void *p_user_data, int i_blocksize)
|
||||
{
|
||||
const _img_private_t *p_env = p_user_data;
|
||||
@@ -994,12 +992,12 @@ set_blocksize_linux (void *p_user_data, int i_blocksize)
|
||||
}
|
||||
|
||||
/* Set CD-ROM drive speed */
|
||||
static int
|
||||
static driver_return_code_t
|
||||
set_speed_linux (void *p_user_data, int i_speed)
|
||||
{
|
||||
const _img_private_t *p_env = p_user_data;
|
||||
|
||||
if (!p_env) return -1;
|
||||
if (!p_env) return DRIVER_OP_ERROR;
|
||||
return ioctl(p_env->gen.fd, CDROM_SELECT_SPEED, i_speed);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cdio.c,v 1.9 2005/01/17 17:20:09 rocky Exp $
|
||||
$Id: cdio.c,v 1.10 2005/01/19 09:23:24 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <cdio/util.h>
|
||||
#include "cdio_private.h"
|
||||
|
||||
static const char _rcsid[] = "$Id: cdio.c,v 1.9 2005/01/17 17:20:09 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: cdio.c,v 1.10 2005/01/19 09:23:24 rocky Exp $";
|
||||
|
||||
|
||||
/*!
|
||||
@@ -92,14 +92,14 @@ cdio_new (generic_img_private_t *p_env, cdio_funcs_t *p_funcs)
|
||||
/*!
|
||||
Set the arg "key" with "value" in the source device.
|
||||
*/
|
||||
int
|
||||
cdio_set_arg (CdIo_t *cdio, const char key[], const char value[])
|
||||
driver_return_code_t
|
||||
cdio_set_arg (CdIo_t *p_cdio, const char key[], const char value[])
|
||||
{
|
||||
cdio_assert (cdio != NULL);
|
||||
cdio_assert (cdio->op.set_arg != NULL);
|
||||
cdio_assert (key != NULL);
|
||||
if (!p_cdio) return DRIVER_OP_ERROR;
|
||||
if (!p_cdio->op.set_arg) return DRIVER_OP_UNSUPPORTED;
|
||||
if (!key) return DRIVER_OP_ERROR;
|
||||
|
||||
return cdio->op.set_arg (cdio->env, key, value);
|
||||
return p_cdio->op.set_arg (p_cdio->env, key, value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: device.c,v 1.5 2005/01/18 12:34:21 rocky Exp $
|
||||
$Id: device.c,v 1.6 2005/01/19 09:23:24 rocky Exp $
|
||||
|
||||
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -279,12 +279,13 @@ cdio_destroy (CdIo_t *p_cdio)
|
||||
free (p_cdio);
|
||||
}
|
||||
|
||||
/*!
|
||||
/*!
|
||||
Eject media in CD drive if there is a routine to do so.
|
||||
Return 0 if success and 1 for failure, and 2 if no routine.
|
||||
|
||||
@param p_cdio the CD object to be acted upon.
|
||||
If the CD is ejected *p_cdio is freed and p_cdio set to NULL.
|
||||
*/
|
||||
int
|
||||
driver_return_code_t
|
||||
cdio_eject_media (CdIo_t **pp_cdio)
|
||||
{
|
||||
|
||||
@@ -300,7 +301,7 @@ cdio_eject_media (CdIo_t **pp_cdio)
|
||||
} else {
|
||||
cdio_destroy(*pp_cdio);
|
||||
*pp_cdio = NULL;
|
||||
return 2;
|
||||
return DRIVER_OP_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,30 +694,25 @@ cdio_open_am_cd (const char *psz_source, const char *psz_access_mode)
|
||||
|
||||
/*!
|
||||
Set the blocksize for subsequent reads.
|
||||
|
||||
@return 0 if everything went okay, -1 if we had an error. is -2
|
||||
returned if this is not implemented for the current driver.
|
||||
*/
|
||||
int cdio_set_blocksize ( const CdIo_t *p_cdio, int i_blocksize )
|
||||
driver_return_code_t
|
||||
cdio_set_blocksize ( const CdIo_t *p_cdio, int i_blocksize )
|
||||
{
|
||||
if (!p_cdio) return -1;
|
||||
if (p_cdio->op.set_blocksize) return -2;
|
||||
if (!p_cdio) return DRIVER_OP_ERROR;
|
||||
if (p_cdio->op.set_blocksize) return DRIVER_OP_UNSUPPORTED;
|
||||
return p_cdio->op.set_blocksize(p_cdio->env, i_blocksize);
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the drive speed.
|
||||
|
||||
@return 0 if everything went okay, -1 if we had an error. is -2
|
||||
returned if this is not implemented for the current driver.
|
||||
|
||||
@see cdio_get_speed
|
||||
*/
|
||||
int
|
||||
driver_return_code_t
|
||||
cdio_set_speed (const CdIo_t *p_cdio, int i_speed)
|
||||
{
|
||||
if (!p_cdio) return -1;
|
||||
if (!p_cdio->op.set_speed) return -2;
|
||||
if (!p_cdio) return DRIVER_OP_ERROR;
|
||||
if (!p_cdio->op.set_speed) return DRIVER_OP_UNSUPPORTED;
|
||||
return p_cdio->op.set_speed(p_cdio->env, i_speed);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: generic.h,v 1.6 2005/01/18 00:57:20 rocky Exp $
|
||||
$Id: generic.h,v 1.7 2005/01/19 09:23:24 rocky Exp $
|
||||
|
||||
Copyright (C) 2004, 2005 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -74,14 +74,15 @@ extern "C" {
|
||||
Bogus eject media when there is no ejectable media, e.g. a disk image
|
||||
We always return 2. Should we also free resources?
|
||||
*/
|
||||
int cdio_generic_unimplemented_eject_media (void *p_env);
|
||||
driver_return_code_t cdio_generic_unimplemented_eject_media (void *p_env);
|
||||
|
||||
/*!
|
||||
Set the blocksize for subsequent reads.
|
||||
|
||||
@return -2 since it's not implemented.
|
||||
*/
|
||||
int cdio_generic_unimplemented_set_blocksize (void *p_user_data,
|
||||
driver_return_code_t
|
||||
cdio_generic_unimplemented_set_blocksize (void *p_user_data,
|
||||
int i_blocksize);
|
||||
|
||||
/*!
|
||||
@@ -89,31 +90,32 @@ extern "C" {
|
||||
|
||||
@return -2 since it's not implemented.
|
||||
*/
|
||||
int cdio_generic_unimplemented_set_speed (void *p_user_data, int i_speed);
|
||||
driver_return_code_t cdio_generic_unimplemented_set_speed (void *p_user_data,
|
||||
int i_speed);
|
||||
|
||||
/*!
|
||||
Release and free resources associated with cd.
|
||||
*/
|
||||
void cdio_generic_free (void *env);
|
||||
void cdio_generic_free (void *p_env);
|
||||
|
||||
/*!
|
||||
Initialize CD device.
|
||||
*/
|
||||
bool cdio_generic_init (void *env);
|
||||
bool cdio_generic_init (void *p_env);
|
||||
|
||||
/*!
|
||||
Reads into buf the next size bytes.
|
||||
Returns -1 on error.
|
||||
Is in fact libc's read().
|
||||
*/
|
||||
off_t cdio_generic_lseek (void *env, off_t offset, int whence);
|
||||
off_t cdio_generic_lseek (void *p_env, off_t offset, int whence);
|
||||
|
||||
/*!
|
||||
Reads into buf the next size bytes.
|
||||
Returns -1 on error.
|
||||
Is in fact libc's read().
|
||||
*/
|
||||
ssize_t cdio_generic_read (void *env, void *buf, size_t size);
|
||||
ssize_t cdio_generic_read (void *p_env, void *p_buf, size_t size);
|
||||
|
||||
/*!
|
||||
Reads a single form1 sector from cd device into data starting
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
$Id: image_common.c,v 1.4 2005/01/18 00:57:20 rocky Exp $
|
||||
$Id: image_common.c,v 1.5 2005/01/19 09:23:24 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
|
||||
@@ -42,11 +42,11 @@
|
||||
Eject media -- there's nothing to do here except free resources.
|
||||
We always return -2.
|
||||
*/
|
||||
int
|
||||
driver_return_code_t
|
||||
_eject_media_image(void *p_user_data)
|
||||
{
|
||||
_free_image (p_user_data);
|
||||
return -2;
|
||||
return DRIVER_OP_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -234,9 +234,8 @@ get_track_preemphasis_image(const void *p_user_data, track_t i_track)
|
||||
Currently "source" to set the source device in I/O operations
|
||||
is the only valid key.
|
||||
|
||||
0 is returned if no error was found, and nonzero if there as an error.
|
||||
*/
|
||||
int
|
||||
driver_return_code_t
|
||||
_set_arg_image (void *p_user_data, const char key[], const char value[])
|
||||
{
|
||||
_img_private_t *p_env = p_user_data;
|
||||
@@ -245,8 +244,7 @@ _set_arg_image (void *p_user_data, const char key[], const char value[])
|
||||
{
|
||||
free_if_notnull (p_env->gen.source_name);
|
||||
|
||||
if (!value)
|
||||
return -2;
|
||||
if (!value) return DRIVER_OP_ERROR;
|
||||
|
||||
p_env->gen.source_name = strdup (value);
|
||||
}
|
||||
@@ -254,8 +252,7 @@ _set_arg_image (void *p_user_data, const char key[], const char value[])
|
||||
{
|
||||
free_if_notnull (p_env->psz_cue_name);
|
||||
|
||||
if (!value)
|
||||
return -2;
|
||||
if (!value) return DRIVER_OP_ERROR;
|
||||
|
||||
p_env->psz_cue_name = strdup (value);
|
||||
}
|
||||
@@ -263,14 +260,13 @@ _set_arg_image (void *p_user_data, const char key[], const char value[])
|
||||
{
|
||||
free_if_notnull (p_env->psz_access_mode);
|
||||
|
||||
if (!value)
|
||||
return -2;
|
||||
if (!value) return DRIVER_OP_ERROR;
|
||||
|
||||
p_env->psz_access_mode = strdup (value);
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
return DRIVER_OP_ERROR;
|
||||
|
||||
return 0;
|
||||
return DRIVER_OP_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* Common SCSI Multimedia Command (MMC) routines.
|
||||
|
||||
$Id: scsi_mmc.c,v 1.5 2005/01/18 05:41:58 rocky Exp $
|
||||
$Id: scsi_mmc.c,v 1.6 2005/01/19 09:23:24 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
|
||||
@@ -170,7 +170,7 @@ scsi_mmc_get_cmd_len(uint8_t scsi_cmd)
|
||||
cdb CDB bytes. All values that are needed should be set on
|
||||
input. We'll figure out what the right CDB length should be.
|
||||
|
||||
We return 0 if command completed successfully and 1 if not.
|
||||
We return 0 if command completed successfully and DRIVER_OP_ERROR if not.
|
||||
*/
|
||||
int
|
||||
scsi_mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
|
||||
@@ -178,12 +178,11 @@ scsi_mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
|
||||
scsi_mmc_direction_t e_direction, unsigned int i_buf,
|
||||
/*in/out*/ void *p_buf )
|
||||
{
|
||||
if (p_cdio && p_cdio->op.run_scsi_mmc_cmd) {
|
||||
if (!p_cdio) return DRIVER_OP_ERROR;
|
||||
if (!p_cdio->op.run_scsi_mmc_cmd) return DRIVER_OP_UNSUPPORTED;
|
||||
return p_cdio->op.run_scsi_mmc_cmd(p_cdio->env, i_timeout_ms,
|
||||
scsi_mmc_get_cmd_len(p_cdb->field[0]),
|
||||
p_cdb, e_direction, i_buf, p_buf);
|
||||
} else
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define DEFAULT_TIMEOUT_MS 6000
|
||||
@@ -213,8 +212,8 @@ scsi_mmc_get_blocksize_private ( const void *p_env,
|
||||
|
||||
uint8_t *p = &mh.block_length_med;
|
||||
|
||||
if ( ! p_env || ! run_scsi_mmc_cmd )
|
||||
return -2;
|
||||
if ( ! p_env ) return DRIVER_OP_ERROR;
|
||||
if ( ! run_scsi_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
|
||||
|
||||
memset (&mh, 0, sizeof (mh));
|
||||
|
||||
@@ -234,7 +233,7 @@ scsi_mmc_get_blocksize_private ( const void *p_env,
|
||||
int
|
||||
scsi_mmc_get_blocksize ( const CdIo_t *p_cdio)
|
||||
{
|
||||
if ( ! p_cdio ) return -2;
|
||||
if ( ! p_cdio ) return DRIVER_OP_ERROR;
|
||||
return
|
||||
scsi_mmc_get_blocksize_private (p_cdio->env, p_cdio->op.run_scsi_mmc_cmd);
|
||||
|
||||
@@ -244,7 +243,7 @@ scsi_mmc_get_blocksize ( const CdIo_t *p_cdio)
|
||||
/*!
|
||||
* Eject using SCSI MMC commands. Return 0 if successful.
|
||||
*/
|
||||
int
|
||||
driver_return_code_t
|
||||
scsi_mmc_eject_media( const CdIo_t *p_cdio )
|
||||
{
|
||||
int i_status = 0;
|
||||
@@ -252,8 +251,8 @@ scsi_mmc_eject_media( const CdIo_t *p_cdio )
|
||||
uint8_t buf[1];
|
||||
scsi_mmc_run_cmd_fn_t run_scsi_mmc_cmd;
|
||||
|
||||
if ( ! p_cdio || ! p_cdio->op.run_scsi_mmc_cmd )
|
||||
return -2;
|
||||
if ( ! p_cdio ) return DRIVER_OP_ERROR;
|
||||
if ( ! p_cdio->op.run_scsi_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
|
||||
|
||||
run_scsi_mmc_cmd = p_cdio->op.run_scsi_mmc_cmd;
|
||||
|
||||
@@ -311,7 +310,7 @@ scsi_mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf, lba_t lba,
|
||||
p_buf);
|
||||
}
|
||||
|
||||
int
|
||||
driver_return_code_t
|
||||
scsi_mmc_set_blocksize_private ( const void *p_env,
|
||||
const scsi_mmc_run_cmd_fn_t run_scsi_mmc_cmd,
|
||||
unsigned int i_bsize)
|
||||
@@ -334,8 +333,8 @@ scsi_mmc_set_blocksize_private ( const void *p_env,
|
||||
uint8_t block_length_lo;
|
||||
} mh;
|
||||
|
||||
if ( ! p_env || ! run_scsi_mmc_cmd )
|
||||
return -2;
|
||||
if ( ! p_env ) return DRIVER_OP_ERROR;
|
||||
if ( ! run_scsi_mmc_cmd ) return DRIVER_OP_UNSUPPORTED;
|
||||
|
||||
memset (&mh, 0, sizeof (mh));
|
||||
mh.block_desc_length = 0x08;
|
||||
@@ -353,10 +352,10 @@ scsi_mmc_set_blocksize_private ( const void *p_env,
|
||||
SCSI_MMC_DATA_WRITE, sizeof(mh), &mh);
|
||||
}
|
||||
|
||||
int
|
||||
driver_return_code_t
|
||||
scsi_mmc_set_blocksize ( const CdIo_t *p_cdio, unsigned int i_blocksize)
|
||||
{
|
||||
if ( ! p_cdio ) return -2;
|
||||
if ( ! p_cdio ) return DRIVER_OP_ERROR;
|
||||
return
|
||||
scsi_mmc_set_blocksize_private (p_cdio->env, p_cdio->op.run_scsi_mmc_cmd,
|
||||
i_blocksize);
|
||||
|
||||
Reference in New Issue
Block a user