First commit after CVS conversion. Should be just administrative changes.

This commit is contained in:
R. Bernstein
2008-11-29 00:56:26 -05:00
parent 4ea407f746
commit 95f087cdc3
413 changed files with 86786 additions and 86 deletions

2
include/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/Makefile
/Makefile.in

22
include/Makefile.am Normal file
View File

@@ -0,0 +1,22 @@
# $Id: Makefile.am,v 1.4 2008/03/20 19:02:37 karl Exp $
#
# Copyright (C) 2003, 2004, 2006, 2008 Rocky Bernstein <rocky@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
# the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
if ENABLE_CXX_BINDINGS
cxxdirs = cdio++
endif
SUBDIRS = cdio $(cxxdirs)

View File

@@ -0,0 +1,2 @@
Makefile.in
Makefile

2
include/cdio++/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/Makefile
/Makefile.in

View File

@@ -0,0 +1,34 @@
# $Id: Makefile.am,v 1.5 2008/03/20 19:02:38 karl Exp $
#
# Copyright (C) 2005, 2008 Rocky Bernstein <rocky@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
# the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
########################################################
# Things to make the install (public) libcdio++ headers
########################################################
#
libcdioincludedir=$(includedir)/cdio++
libcdioinclude_HEADERS = \
cdio.hpp \
cdtext.hpp \
device.hpp \
devices.hpp \
disc.hpp \
enum.hpp \
iso9660.hpp \
mmc.hpp \
read.hpp \
track.hpp

181
include/cdio++/cdio.hpp Normal file
View File

@@ -0,0 +1,181 @@
/*
$Id: cdio.hpp,v 1.13 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file cdio.hpp
*
* \brief C++ class for libcdio: the CD Input and Control
* library. Applications use this for anything regarding libcdio.
*/
#ifndef __CDIO_HPP__
#define __CDIO_HPP__
#include <cdio/cdio.h>
#include <cdio/audio.h>
#include <cdio/dvd.h>
#include <cdio/mmc.h>
// Make pre- and post-increment operators for enums in libcdio where it
// makes sense.
#include <cdio++/enum.hpp>
/** Class for driver exceptions. **/
class DriverOpException
{
public:
driver_return_code_t driver_return_code;
DriverOpException( void ) { };
DriverOpException( driver_return_code_t drc ) {
driver_return_code = drc;
};
driver_return_code_t get_code(void) {
return driver_return_code;
};
const char *get_msg(void) {
return cdio_driver_errmsg(driver_return_code);
};
};
class DriverOpError: public DriverOpException
{
public:
DriverOpError(void) { driver_return_code = DRIVER_OP_ERROR; }
};
class DriverOpUnsupported: public DriverOpException
{
public:
DriverOpUnsupported(void) { driver_return_code = DRIVER_OP_UNSUPPORTED; }
};
class DriverOpUninit: public DriverOpException
{
public:
DriverOpUninit(void) { driver_return_code = DRIVER_OP_UNINIT; }
};
class DriverOpNotPermitted: public DriverOpException
{
public:
DriverOpNotPermitted(void) {driver_return_code = DRIVER_OP_NOT_PERMITTED;}
};
class DriverOpBadParameter: public DriverOpException
{
public:
DriverOpBadParameter(void) {driver_return_code = DRIVER_OP_BAD_PARAMETER;}
};
class DriverOpBadPointer: public DriverOpException
{
public:
DriverOpBadPointer(void) {driver_return_code = DRIVER_OP_BAD_POINTER;}
};
class DriverOpNoDriver: public DriverOpException
{
public:
DriverOpNoDriver(void) {driver_return_code = DRIVER_OP_NO_DRIVER;}
};
void possible_throw_device_exception(driver_return_code_t drc);
/** A class relating to CD-Text. Use invalid track number 0 to specify
CD-Text for the CD (as opposed to a specific track).
*/
class CdioCDText
{
public:
CdioCDText(cdtext_t *p)
{
p_cdtext = p;
cdtext_init(p); // make sure we're initialized on the C side
}
~CdioCDText()
{
cdtext_destroy(p_cdtext);
p_cdtext = (cdtext_t *) NULL;
}
// Other member functions
#include "cdtext.hpp"
private:
cdtext_t *p_cdtext;
};
/** A class relating to tracks. A track object basically saves device
and track number information so that in track operations these
don't have be specified.
*/
class CdioTrack
{
public:
CdioTrack(CdIo_t *p, track_t t)
{
i_track = t;
p_cdio = p;
}
// Other member functions
#include "track.hpp"
private:
track_t i_track;
CdIo_t *p_cdio;
};
/** A class relating to a CD-ROM device or pseudo CD-ROM device with
has a particular CD image. A device basically saves the libcdio
"object" (of type CdIo *).
*/
class CdioDevice
{
protected:
CdIo_t *p_cdio;
public:
CdioDevice()
{
p_cdio = (CdIo_t *) NULL;
};
~CdioDevice()
{
cdio_destroy(p_cdio);
p_cdio = (CdIo_t *) NULL;
};
// Other member functions
#include "device.hpp"
#include "disc.hpp"
#include "mmc.hpp"
#include "read.hpp"
};
/* Things related to devices. No class or object is needed. */
#include "devices.hpp"
#endif /* __CDIO_HPP__ */

90
include/cdio++/cdtext.hpp Normal file
View File

@@ -0,0 +1,90 @@
/*
$Id: cdtext.hpp,v 1.2 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file cdtext.hpp
* \brief methods relating to CD-Text information. This file
* should not be #included directly.
*/
/*! Return string representation of the enum values above */
const char *field2str (cdtext_field_t i)
{
return cdtext_field2str (i);
}
/*! returns an allocated string associated with the given field. NULL is
returned if key is CDTEXT_INVALID or the field is not set.
The user needs to free the string when done with it.
@see getConst to retrieve a constant string that doesn't
have to be freed.
*/
char *get (cdtext_field_t key)
{
return cdtext_get (key, p_cdtext);
}
/*! returns the C cdtext_t pointer associated with this object. */
cdtext_t *get ()
{
return p_cdtext;
}
/*! returns a const string associated with the given field. NULL is
returned if key is CDTEXT_INVALID or the field is not set.
Don't use the string when the cdtext object (i.e. the CdIo_t object
you got it from) is no longer valid.
@see cdio_get to retrieve an allocated string that persists past the
cdtext object.
*/
const char *getConst (cdtext_field_t key)
{
return cdtext_get_const (key, p_cdtext);
}
/*!
returns enum of keyword if key is a CD-Text keyword,
returns MAX_CDTEXT_FIELDS non-zero otherwise.
*/
cdtext_field_t isKeyword (const char *key)
{
return cdtext_is_keyword (key);
}
/*!
sets cdtext's keyword entry to field
*/
void set (cdtext_field_t key, const char *value)
{
cdtext_set (key, value, p_cdtext);
}
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

261
include/cdio++/device.hpp Normal file
View File

@@ -0,0 +1,261 @@
/*
$Id: device.hpp,v 1.7 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file device.hpp
*
* \brief C++ header for driver- or device-related libcdio calls.
* ("device" includes CD-image reading devices.)
*/
/*!
Free resources associated with CD-ROM Device/Image. After this we
must do another open before any more reading.
*/
bool
close()
{
cdio_destroy(p_cdio);
p_cdio = (CdIo_t *) NULL;
return true;
}
/*!
Eject media in CD drive if there is a routine to do so.
If the CD is ejected, object is destroyed.
*/
void
ejectMedia ()
{
driver_return_code_t drc = cdio_eject_media(&p_cdio);
possible_throw_device_exception(drc);
}
/*!
Free device list returned by GetDevices
@param device_list list returned by GetDevices
@see GetDevices
*/
void
freeDeviceList (char * device_list[])
{
cdio_free_device_list(device_list);
}
/*!
Get the value associatied with key.
@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 *
getArg (const char key[])
{
return cdio_get_arg (p_cdio, key);
}
/*!
Return an opaque CdIo_t pointer for the given track object.
*/
CdIo_t *getCdIo()
{
return p_cdio;
}
/*!
Return an opaque CdIo_t pointer for the given track object.
*/
cdtext_t *getCdtext(track_t i_track)
{
return cdio_get_cdtext (p_cdio, i_track);
}
/*!
Get the CD device name for the object.
@return a string containing the CD device for this object or NULL is
if we couldn't get a device anme.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
char *
getDevice ()
{
return cdio_get_default_device(p_cdio);
}
/*!
Get the what kind of device we've got.
@param p_read_cap pointer to return read capabilities
@param p_write_cap pointer to return write capabilities
@param p_misc_cap pointer to return miscellaneous other capabilities
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
void
getDriveCap (cdio_drive_read_cap_t &read_cap,
cdio_drive_write_cap_t &write_cap,
cdio_drive_misc_cap_t &misc_cap)
{
cdio_get_drive_cap(p_cdio, &read_cap, &write_cap, &misc_cap);
}
/*!
Get a string containing the name of the driver in use.
@return a string with driver name or NULL if CdIo_t is NULL (we
haven't initialized a specific device.
*/
const char *
getDriverName ()
{
return cdio_get_driver_name(p_cdio);
}
/*!
Get the driver id.
if CdIo_t is NULL (we haven't initialized a specific device driver),
then return DRIVER_UNKNOWN.
@return the driver id..
*/
driver_id_t
getDriverId ()
{
return cdio_get_driver_id(p_cdio);
}
/*!
Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
False is returned if we had an error getting the information.
*/
bool
getHWinfo ( /*out*/ cdio_hwinfo_t &hw_info )
{
return cdio_get_hwinfo(p_cdio, &hw_info);
}
/*! Get the LSN of the first track of the last session of
on the CD.
@param i_last_session pointer to the session number to be returned.
*/
void
getLastSession (/*out*/ lsn_t &i_last_session)
{
driver_return_code_t drc = cdio_get_last_session(p_cdio, &i_last_session);
possible_throw_device_exception(drc);
}
/*!
Find out if media has changed since the last call.
@return 1 if media has changed since last call, 0 if not. Error
return codes are the same as driver_return_code_t
*/
int
getMediaChanged()
{
return cdio_get_media_changed(p_cdio);
}
/*! True if CD-ROM understand ATAPI commands. */
bool_3way_t
haveATAPI ()
{
return cdio_have_atapi(p_cdio);
}
/*!
Sets up to read from the device specified by psz_source. An open
routine should be called before using any read routine. If device
object was previously opened it is closed first.
@return true if open succeeded or false if error.
*/
bool
open(const char *psz_source)
{
if (p_cdio) cdio_destroy(p_cdio);
p_cdio = cdio_open_cd(psz_source);
return NULL != p_cdio ;
}
/*!
Sets up to read from the device specified by psz_source and access
mode. An open routine should be called before using any read
routine. If device object was previously opened it is "closed".
@return true if open succeeded or false if error.
*/
bool
open (const char *psz_source, driver_id_t driver_id,
const char *psz_access_mode = (const char *) NULL)
{
if (p_cdio) cdio_destroy(p_cdio);
if (psz_access_mode)
p_cdio = cdio_open_am(psz_source, driver_id, psz_access_mode);
else
p_cdio = cdio_open(psz_source, driver_id);
return NULL != p_cdio ;
}
/*!
Set the blocksize for subsequent reads.
*/
void
setBlocksize ( int i_blocksize )
{
driver_return_code_t drc = cdio_set_blocksize ( p_cdio, i_blocksize );
possible_throw_device_exception(drc);
}
/*!
Set the drive speed.
*/
void
setSpeed ( int i_speed )
{
driver_return_code_t drc = cdio_set_speed ( p_cdio, i_speed );
possible_throw_device_exception(drc);
}
/*!
Set the arg "key" with "value" in "p_cdio".
@param key the key to set
@param value the value to assocaiate with key
*/
void
setArg (const char key[], const char value[])
{
driver_return_code_t drc = cdio_set_arg (p_cdio, key, value);
possible_throw_device_exception(drc);
}

181
include/cdio++/devices.hpp Normal file
View File

@@ -0,0 +1,181 @@
/*
$Id: devices.hpp,v 1.5 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file devices.hpp
*
* \brief methods relating to devices. It is *not* part of a class.
* This file should not be #included directly.
*/
/*!
Close media tray in CD drive if there is a routine to do so.
@param psz_drive the name of CD-ROM to be closed.
@param driver_id is the driver to be used or that got used if
it was DRIVER_UNKNOWN or DRIVER_DEVICE; If this is NULL, we won't
report back the driver used.
*/
void closeTray (const char *psz_drive, /*in/out*/ driver_id_t &driver_id);
/*!
Close media tray in CD drive if there is a routine to do so.
@param psz_drive the name of CD-ROM to be closed. If omitted or
NULL, we'll scan for a suitable CD-ROM.
*/
void closeTray (const char *psz_drive=(const char *)NULL);
/*!
Get a string decribing driver_id.
@param driver_id the driver you want the description for
@return a sring of driver description
*/
const char *driverDescribe (driver_id_t driver_id);
/*!
Eject media in CD drive if there is a routine to do so.
If the CD is ejected, object is destroyed.
*/
void ejectMedia (const char *psz_drive);
/*!
Free device list returned by GetDevices
@param device_list list returned by GetDevices
@see GetDevices
*/
void freeDeviceList (char * device_list[]);
/*!
Return a string containing the default CD device if none is specified.
if p_driver_id is DRIVER_UNKNOWN or DRIVER_DEVICE
then find a suitable one set the default device for that.
NULL is returned if we couldn't get a default device.
*/
char * getDefaultDevice(/*in/out*/ driver_id_t &driver_id);
/*! 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.
NULL is returned if we couldn't return a list of devices.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
char ** getDevices(driver_id_t driver_id=DRIVER_DEVICE);
/*! Like GetDevices above, but we may change the p_driver_id if we
were given DRIVER_DEVICE or DRIVER_UNKNOWN. This is because
often one wants to get a drive name and then *open* it
afterwards. Giving the driver back facilitates this, and speeds
things up for libcdio as well.
*/
char **getDevices (driver_id_t &driver_id);
/*!
Get an array of device names in search_devices that have at least
the capabilities listed by the capabities parameter. If
search_devices is NULL, then we'll search all possible CD drives.
If "b_any" is set false then every capability listed in the
extended portion of capabilities (i.e. not the basic filesystem)
must be satisified. If "any" is set true, then if any of the
capabilities matches, we call that a success.
To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
@return the array of device names or NULL 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 ** getDevices(/*in*/ char *ppsz_search_devices[],
cdio_fs_anal_t capabilities, bool b_any=false);
/*!
Like GetDevices above but we return the driver we found
as well. This is because often one wants to search for kind of drive
and then *open* it afterwards. Giving the driver back facilitates this,
and speeds things up for libcdio as well.
*/
char ** getDevices(/*in*/ char* ppsz_search_devices[],
cdio_fs_anal_t capabilities, /*out*/ driver_id_t &driver_id,
bool b_any=false);
/*! Return true if we Have driver for driver_id */
bool haveDriver (driver_id_t driver_id);
/*!
Determine if bin_name is the bin file part of a CDRWIN CD disk image.
@param bin_name location of presumed CDRWIN bin image file.
@return the corresponding CUE file if bin_name is a BIN file or
NULL if not a BIN file.
*/
char *isBinFile(const char *psz_bin_name);
/*!
Determine if cue_name is the cue sheet for a CDRWIN CD disk image.
@return corresponding BIN file if cue_name is a CDRWIN cue file or
NULL if not a CUE file.
*/
char *isCueFile(const char *psz_cue_name);
/*!
Determine if psz_source refers to a real hardware CD-ROM.
@param psz_source location name of object
@param driver_id driver for reading object. Use DRIVER_UNKNOWN if you
don't know what driver to use.
@return true if psz_source is a device; If false is returned we
could have a CD disk image.
*/
bool isDevice(const char *psz_source, driver_id_t driver_id);
/*!
Determine if psz_nrg is a Nero CD disk image.
@param psz_nrg location of presumed NRG image file.
@return true if psz_nrg is a Nero NRG image or false
if not a NRG image.
*/
bool isNero(const char *psz_nrg);
/*!
Determine if psz_toc is a TOC file for a cdrdao CD disk image.
@param psz_toc location of presumed TOC image file.
@return true if toc_name is a cdrdao TOC file or false
if not a TOC file.
*/
bool isTocFile(const char *psz_toc);

174
include/cdio++/disc.hpp Normal file
View File

@@ -0,0 +1,174 @@
/*
$Id: disc.hpp,v 1.2 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file disc.hpp
* \brief methods relating to getting Compact Disc information. This file
* should not be #included directly.
*/
/*!
Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc.
that we've got. The notion of "CD" is extended a little to include
DVD's.
*/
discmode_t getDiscmode ()
{
return cdio_get_discmode(p_cdio);
}
/*!
Get the lsn of the end of the CD
@return the lsn. On error 0 or CDIO_INVALD_LSN.
*/
lsn_t getDiscLastLsn()
{
return cdio_get_disc_last_lsn(p_cdio);
}
/*!
Get the number of the first track.
@return a track object or NULL;
on error.
*/
CdioTrack *getFirstTrack()
{
track_t i_track = cdio_get_first_track_num(p_cdio);
return (CDIO_INVALID_TRACK != i_track)
? new CdioTrack(p_cdio, i_track)
: (CdioTrack *) NULL;
}
/*!
Get the number of the first track.
@return the track number or CDIO_INVALID_TRACK
on error.
*/
track_t getFirstTrackNum()
{
return cdio_get_first_track_num(p_cdio);
}
/*!
Get the number of the first track.
@return a track object or NULL;
on error.
*/
CdioTrack *getLastTrack()
{
track_t i_track = cdio_get_last_track_num(p_cdio);
return (CDIO_INVALID_TRACK != i_track)
? new CdioTrack(p_cdio, i_track)
: (CdioTrack *) NULL;
}
/*!
Get the number of the first track.
@return the track number or CDIO_INVALID_TRACK
on error.
*/
track_t getLastTrackNum()
{
return cdio_get_last_track_num(p_cdio);
}
/*!
Return the Joliet level recognized for p_cdio.
*/
uint8_t getJolietLevel()
{
return cdio_get_joliet_level(p_cdio);
}
/*!
Get the media catalog number (MCN) from the CD.
@return the media catalog number r NULL if there is none or we
don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
*/
char * getMcn ()
{
return cdio_get_mcn (p_cdio);
}
/*!
Get the number of tracks on the CD.
@return the number of tracks, or CDIO_INVALID_TRACK if there is
an error.
*/
track_t getNumTracks ()
{
return cdio_get_num_tracks(p_cdio);
}
/*! Find the track which contans lsn.
CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
if there was some error.
If the lsn is before the pregap of the first track 0 is returned.
Otherwise we return the track that spans the lsn.
*/
CdioTrack *getTrackFromNum(track_t i_track)
{
return new CdioTrack(p_cdio, i_track);
}
/*! Find the track which contans lsn.
CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
if there was some error.
If the lsn is before the pregap of the first track 0 is returned.
Otherwise we return the track that spans the lsn.
*/
CdioTrack *getTrackFromLsn(lsn_t lsn)
{
track_t i_track = cdio_get_track(p_cdio, lsn);
return (CDIO_INVALID_TRACK != i_track)
? new CdioTrack(p_cdio, i_track)
: (CdioTrack *) NULL;
}
/*!
Return true if discmode is some sort of CD.
*/
bool isDiscmodeCdrom (discmode_t discmode) {
return cdio_is_discmode_cdrom(discmode);
}
/*!
Return true if discmode is some sort of DVD.
*/
bool isDiscmodeDvd (discmode_t discmode)
{
return cdio_is_discmode_dvd (discmode) ;
}

49
include/cdio++/enum.hpp Normal file
View File

@@ -0,0 +1,49 @@
/*
$Id: enum.hpp,v 1.2 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2005, 2008 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file enum.hpp
*
* \brief C++ header for pre- and post-increment operators for
* enumerations defined in libcdio that it makes sense to iterate over.
*/
#define ENUM_ITERATE_FNS(type) \
inline \
type &operator++(type &t) \
{ \
return t = type(t + 1); \
} \
inline \
type &operator++(type &t, int) \
{ \
return t = type(t + 1); \
} \
inline \
type &operator--(type &t) \
{ \
return t = type(t - 1); \
} \
inline \
type &operator--(type &t, int) \
{ \
return t = type(t - 1); \
}
ENUM_ITERATE_FNS(cdtext_field_t)
ENUM_ITERATE_FNS(driver_id_t)

428
include/cdio++/iso9660.hpp Normal file
View File

@@ -0,0 +1,428 @@
/*
$Id: iso9660.hpp,v 1.13 2008/06/13 15:58:50 flameeyes Exp $
Copyright (C) 2006, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file iso9660.hpp
*
* \brief C++ class for libcdio: the CD Input and Control
* library. Applications use this for anything regarding libcdio.
*/
#ifndef __ISO9660_HPP__
#define __ISO9660_HPP__
#include <cdio/iso9660.h>
#include <cdio++/cdio.hpp>
#include <vector> // vector class library
#include <cstdlib>
#include <cstring>
using namespace std;
/** ISO 9660 class.
*/
class ISO9660
{
public:
class PVD // Primary Volume ID
{
public:
iso9660_pvd_t pvd; // Make private?
PVD()
{
memset(&pvd, 0, sizeof(pvd));
}
PVD(iso9660_pvd_t *p_new_pvd)
{
memcpy(&pvd, p_new_pvd, sizeof(pvd));
};
/*!
Return the PVD's application ID.
NULL is returned if there is some problem in getting this.
*/
char * get_application_id();
int get_pvd_block_size();
/*!
Return the PVD's preparer ID.
NULL is returned if there is some problem in getting this.
*/
char * get_preparer_id();
/*!
Return the PVD's publisher ID.
NULL is returned if there is some problem in getting this.
*/
char * get_publisher_id();
const char *get_pvd_id();
int get_pvd_space_size();
uint8_t get_pvd_type();
/*! Return the primary volume id version number (of pvd).
If there is an error 0 is returned.
*/
int get_pvd_version();
/*! Return the LSN of the root directory for pvd.
If there is an error CDIO_INVALID_LSN is returned.
*/
lsn_t get_root_lsn();
/*!
Return the PVD's system ID.
NULL is returned if there is some problem in getting this.
*/
char * get_system_id();
/*!
Return the PVD's volume ID.
NULL is returned if there is some problem in getting this.
*/
char * get_volume_id();
/*!
Return the PVD's volumeset ID.
NULL is returned if there is some problem in getting this.
*/
char * get_volumeset_id();
};
class Stat // ISO 9660 file information
{
public:
iso9660_stat_t *p_stat;
typedef vector< ISO9660::Stat *> stat_vector_t;
Stat(iso9660_stat_t *p_new_stat)
{
p_stat = p_new_stat;
};
Stat(const Stat& copy_in)
{
free(p_stat);
p_stat = (iso9660_stat_t *)
calloc( 1, sizeof(iso9660_stat_t)
+ strlen(copy_in.p_stat->filename)+1 );
p_stat = copy_in.p_stat;
}
const Stat& operator= (const Stat& right)
{
free(p_stat);
this->p_stat = right.p_stat;
return right;
}
~Stat()
{
free(p_stat);
p_stat = NULL;
}
};
class FS : public CdioDevice // ISO 9660 Filesystem on a CD or CD-image
{
public:
typedef vector< ISO9660::Stat *> stat_vector_t;
/*!
Given a directory pointer, find the filesystem entry that contains
lsn and return information about it.
@return Stat * of entry if we found lsn, or NULL otherwise.
Caller must free return value.
*/
Stat *find_lsn(lsn_t i_lsn);
/*! Read the Primary Volume Descriptor for a CD. A
PVD object is returned if read, and NULL if there was an error.
*/
PVD *read_pvd ();
/*!
Read the Super block of an ISO 9660 image. This is the
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
Descriptor if (Joliet) extensions are acceptable.
*/
bool read_superblock (iso_extension_mask_t iso_extension_mask);
/*! Read psz_path (a directory) and return a vector of iso9660_stat_t
pointers for the files inside that directory. The caller must free the
returned result.
*/
bool readdir (const char psz_path[], stat_vector_t& stat_vector,
bool b_mode2=false);
/*!
Return file status for path name psz_path. NULL is returned on
error.
If translate is true, version numbers in the ISO 9660 name are
dropped, i.e. ;1 is removed and if level 1 ISO-9660 names are
lowercased.
Mode2 is used only if translate is true and is a hack that
really should go away in libcdio sometime. If set use mode 2
reading, otherwise use mode 1 reading.
@return file status object for psz_path. NULL is returned on
error.
*/
Stat *
stat (const char psz_path[], bool b_translate=false, bool b_mode2=false)
{
if (b_translate)
return new Stat(iso9660_fs_stat_translate (p_cdio, psz_path,
b_mode2));
else
return new Stat(iso9660_fs_stat (p_cdio, psz_path));
}
};
class IFS // ISO 9660 filesystem image
{
public:
typedef vector< ISO9660::Stat *> stat_vector_t;
IFS()
{
p_iso9660=NULL;
};
~IFS()
{
iso9660_close(p_iso9660);
p_iso9660 = (iso9660_t *) NULL;
};
/*! Close previously opened ISO 9660 image and free resources
associated with the image. Call this when done using using an ISO
9660 image.
@return true is unconditionally returned. If there was an error
false would be returned.
*/
bool close();
/*!
Given a directory pointer, find the filesystem entry that contains
lsn and return information about it.
Returns Stat* of entry if we found lsn, or NULL otherwise.
*/
Stat *find_lsn(lsn_t i_lsn);
/*!
Get the application ID. psz_app_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool get_application_id(/*out*/ char * &psz_app_id)
{
return iso9660_ifs_get_application_id(p_iso9660, &psz_app_id);
}
/*!
Return the Joliet level recognized.
*/
uint8_t get_joliet_level();
/*!
Get the preparer ID. psz_preparer_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool get_preparer_id(/*out*/ char * &psz_preparer_id)
{
return iso9660_ifs_get_preparer_id(p_iso9660, &psz_preparer_id);
}
/*!
Get the publisher ID. psz_publisher_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool get_publisher_id(/*out*/ char * &psz_publisher_id)
{
return iso9660_ifs_get_publisher_id(p_iso9660, &psz_publisher_id);
}
/*!
Get the system ID. psz_system_id is set to NULL if there
is some problem in getting this and false is returned.
*/
bool get_system_id(/*out*/ char * &psz_system_id)
{
return iso9660_ifs_get_system_id(p_iso9660, &psz_system_id);
}
/*! Return the volume ID in the PVD. psz_volume_id is set to
NULL if there is some problem in getting this and false is
returned.
*/
bool get_volume_id(/*out*/ char * &psz_volume_id)
{
return iso9660_ifs_get_volume_id(p_iso9660, &psz_volume_id);
}
/*! Return the volumeset ID in the PVD. psz_volumeset_id is set to
NULL if there is some problem in getting this and false is
returned.
*/
bool get_volumeset_id(/*out*/ char * &psz_volumeset_id)
{
return iso9660_ifs_get_volumeset_id(p_iso9660, &psz_volumeset_id);
}
/*!
Return true if ISO 9660 image has extended attrributes (XA).
*/
bool is_xa ();
/*! Open an ISO 9660 image for reading. Maybe in the future we will
have a mode. NULL is returned on error. An open routine should be
called before using any read routine. If device object was
previously opened it is closed first.
@param psz_path location of ISO 9660 image
@param iso_extension_mask the kinds of ISO 9660 extensions will be
considered on access.
@return true if open succeeded or false if error.
@see open_fuzzy
*/
bool open(const char *psz_path,
iso_extension_mask_t iso_extension_mask=ISO_EXTENSION_NONE)
{
if (p_iso9660) iso9660_close(p_iso9660);
p_iso9660 = iso9660_open_ext(psz_path, iso_extension_mask);
return NULL != (iso9660_t *) p_iso9660 ;
}
/*! Open an ISO 9660 image for "fuzzy" reading. This means that we
will try to guess various internal offset based on internal
checks. This may be useful when trying to read an ISO 9660 image
contained in a file format that libiso9660 doesn't know natively
(or knows imperfectly.)
Maybe in the future we will have a mode. NULL is returned on
error.
@see open
*/
bool open_fuzzy (const char *psz_path,
iso_extension_mask_t iso_extension_mask
=ISO_EXTENSION_NONE,
uint16_t i_fuzz=20);
/*! Read the Primary Volume Descriptor for an ISO 9660 image. A
PVD object is returned if read, and NULL if there was an error.
*/
PVD *read_pvd ();
/*!
Read the Super block of an ISO 9660 image but determine framesize
and datastart and a possible additional offset. Generally here we are
not reading an ISO 9660 image but a CD-Image which contains an ISO 9660
filesystem.
@see read_superblock
*/
bool read_superblock (iso_extension_mask_t iso_extension_mask
=ISO_EXTENSION_NONE,
uint16_t i_fuzz=20);
/*!
Read the Super block of an ISO 9660 image but determine framesize
and datastart and a possible additional offset. Generally here we are
not reading an ISO 9660 image but a CD-Image which contains an ISO 9660
filesystem.
@see read_superblock
*/
bool
read_superblock_fuzzy (iso_extension_mask_t iso_extension_mask
=ISO_EXTENSION_NONE,
uint16_t i_fuzz=20);
/*! Read psz_path (a directory) and return a list of iso9660_stat_t
pointers for the files inside that directory. The caller must free
the returned result.
*/
bool readdir (const char psz_path[], stat_vector_t& stat_vector)
{
CdioList_t *p_stat_list = iso9660_ifs_readdir (p_iso9660, psz_path);
if (p_stat_list) {
CdioListNode_t *p_entnode;
_CDIO_LIST_FOREACH (p_entnode, p_stat_list) {
iso9660_stat_t *p_statbuf =
(iso9660_stat_t *) _cdio_list_node_data (p_entnode);
stat_vector.push_back(new ISO9660::Stat(p_statbuf));
}
_cdio_list_free (p_stat_list, false);
return true;
} else {
return false;
}
}
/*!
Seek to a position and then read n bytes. Size read is returned.
*/
long int
seek_read (void *ptr, lsn_t start, long int i_size=1)
{
return iso9660_iso_seek_read (p_iso9660, ptr, start, i_size);
}
/*!
Return file status for pathname. NULL is returned on error.
*/
Stat *
stat (const char psz_path[], bool b_translate=false)
{
if (b_translate)
return new Stat(iso9660_ifs_stat_translate (p_iso9660, psz_path));
else
return new Stat(iso9660_ifs_stat (p_iso9660, psz_path));
}
private:
iso9660_t *p_iso9660;
};
};
typedef vector< ISO9660::Stat *> stat_vector_t;
typedef vector <ISO9660::Stat *>::iterator stat_vector_iterator_t;
#endif /* __ISO9660_HPP__ */

425
include/cdio++/mmc.hpp Normal file
View File

@@ -0,0 +1,425 @@
/*
$Id: mmc.hpp,v 1.3 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file mmc.hpp
* \brief methods relating to MMC (Multimedia Commands). This file
* should not be #included directly.
*/
/*!
Read Audio Subchannel information
@param p_cdio the CD object to be acted upon.
@param p_subchannel place for returned subchannel information
A DriverOpException is raised on error.
*/
void
mmcAudioReadSubchannel (/*out*/ cdio_subchannel_t *p_subchannel)
{
driver_return_code_t drc = mmc_audio_read_subchannel (p_cdio, p_subchannel);
possible_throw_device_exception(drc);
}
/*!
Eject using MMC commands. If CD-ROM is "locked" we'll unlock it.
Command is not "immediate" -- we'll wait for the command to complete.
For a more general (and lower-level) routine, @see mmc_start_stop_media.
A DriverOpException is raised on error.
*/
void mmcEjectMedia()
{
driver_return_code_t drc = mmc_eject_media( p_cdio );
possible_throw_device_exception(drc);
}
/*!
Get the lsn of the end of the CD
@return the lsn. On error return CDIO_INVALID_LSN.
*/
lsn_t mmcGetDiscLastLsn()
{
return mmc_get_disc_last_lsn( p_cdio );
}
/*!
Return the discmode as reported by the MMC Read (FULL) TOC
command.
Information was obtained from Section 5.1.13 (Read TOC/PMA/ATIP)
pages 56-62 from the MMC draft specification, revision 10a
at http://www.t10.org/ftp/t10/drafts/mmc/mmc-r10a.pdf See
especially tables 72, 73 and 75.
*/
discmode_t mmcGetDiscmode()
{
return mmc_get_discmode( p_cdio );
}
/*!
Get drive capabilities for a device.
@return the drive capabilities.
*/
void mmcGetDriveCap ( /*out*/ cdio_drive_read_cap_t *p_read_cap,
/*out*/ cdio_drive_write_cap_t *p_write_cap,
/*out*/ cdio_drive_misc_cap_t *p_misc_cap)
{
mmc_get_drive_cap ( p_cdio, p_read_cap, p_write_cap, p_misc_cap);
}
/*!
Get the MMC level supported by the device.
*/
cdio_mmc_level_t mmcGetDriveMmcCap()
{
return mmc_get_drive_mmc_cap(p_cdio);
}
/*!
Get the DVD type associated with cd object.
@return the DVD discmode.
*/
discmode_t mmcGetDvdStructPhysical (cdio_dvd_struct_t *s)
{
return mmc_get_dvd_struct_physical (p_cdio, s);
}
/*!
Get the CD-ROM hardware info via an MMC INQUIRY command.
@return true if we were able to get hardware info, false if we had
an error.
*/
bool mmcGetHwinfo ( /* out*/ cdio_hwinfo_t *p_hw_info )
{
return mmc_get_hwinfo ( p_cdio, p_hw_info );
}
/*!
Find out if media has changed since the last call.
@param p_cdio the CD object to be acted upon.
@return 1 if media has changed since last call, 0 if not. Error
return codes are the same as driver_return_code_t
*/
int mmcGetMediaChanged()
{
return mmc_get_media_changed(p_cdio);
}
/*!
Get the media catalog number (MCN) from the CD via MMC.
@return the media catalog number r NULL if there is none or we
don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
*/
char * mmcGetMcn ()
{
return mmc_get_mcn ( p_cdio );
}
/** Get the output port volumes and port selections used on AUDIO PLAY
commands via a MMC MODE SENSE command using the CD Audio Control
Page.
A DriverOpException is raised on error.
*/
void mmcAudioGetVolume (mmc_audio_volume_t *p_volume)
{
driver_return_code_t drc = mmc_audio_get_volume (p_cdio, p_volume);
possible_throw_device_exception(drc);
}
/*!
Report if CD-ROM has a praticular kind of interface (ATAPI, SCSCI, ...)
Is it possible for an interface to have serveral? If not this
routine could probably return the single mmc_feature_interface_t.
@return true if we have the interface and false if not.
*/
bool_3way_t mmcHaveInterface( cdio_mmc_feature_interface_t e_interface )
{
return mmc_have_interface( p_cdio, e_interface );
}
/*! Run a MODE_SENSE command (6- or 10-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmcModeSense( /*out*/ void *p_buf, int i_size, int page)
{
return mmc_mode_sense( p_cdio, /*out*/ p_buf, i_size, page);
}
/*! Run a MODE_SENSE command (10-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmcModeSense10( /*out*/ void *p_buf, int i_size, int page)
{
return mmc_mode_sense_10( p_cdio, /*out*/ p_buf, i_size, page);
}
/*! Run a MODE_SENSE command (6-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmcModeSense6( /*out*/ void *p_buf, int i_size, int page)
{
return mmc_mode_sense_6( p_cdio, /*out*/ p_buf, i_size, page);
}
/*! Issue a MMC READ_CD command.
@param p_cdio object to read from
@param p_buf Place to store data. The caller should ensure that
p_buf can hold at least i_blocksize * i_blocks bytes.
@param i_lsn sector to read
@param expected_sector_type restricts reading to a specific CD
sector type. Only 3 bits with values 1-5 are used:
0 all sector types
1 CD-DA sectors only
2 Mode 1 sectors only
3 Mode 2 formless sectors only. Note in contrast to all other
values an MMC CD-ROM is not required to support this mode.
4 Mode 2 Form 1 sectors only
5 Mode 2 Form 2 sectors only
@param b_digital_audio_play Control error concealment when the
data being read is CD-DA. If the data being read is not CD-DA,
this parameter is ignored. If the data being read is CD-DA and
DAP is false zero, then the user data returned should not be
modified by flaw obscuring mechanisms such as audio data mute and
interpolate. If the data being read is CD-DA and DAP is true,
then the user data returned should be modified by flaw obscuring
mechanisms such as audio data mute and interpolate.
b_sync_header return the sync header (which will probably have
the same value as CDIO_SECTOR_SYNC_HEADER of size
CDIO_CD_SYNC_SIZE).
@param header_codes Header Codes refer to the sector header and
the sub-header that is present in mode 2 formed sectors:
0 No header information is returned.
1 The 4-byte sector header of data sectors is be returned,
2 The 8-byte sector sub-header of mode 2 formed sectors is
returned.
3 Both sector header and sub-header (12 bytes) is returned.
The Header preceeds the rest of the bytes (e.g. user-data bytes)
that might get returned.
@param b_user_data Return user data if true.
For CD-DA, the User Data is CDIO_CD_FRAMESIZE_RAW bytes.
For Mode 1, The User Data is ISO_BLOCKSIZE bytes beginning at
offset CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE.
For Mode 2 formless, The User Data is M2RAW_SECTOR_SIZE bytes
beginning at offset CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE.
For data Mode 2, form 1, User Data is ISO_BLOCKSIZE bytes beginning at
offset CDIO_CD_XA_SYNC_HEADER.
For data Mode 2, form 2, User Data is 2 324 bytes beginning at
offset CDIO_CD_XA_SYNC_HEADER.
@param b_sync
@param b_edc_ecc true if we return EDC/ECC error detection/correction bits.
The presence and size of EDC redundancy or ECC parity is defined
according to sector type:
CD-DA sectors have neither EDC redundancy nor ECC parity.
Data Mode 1 sectors have 288 bytes of EDC redundancy, Pad, and
ECC parity beginning at offset 2064.
Data Mode 2 formless sectors have neither EDC redundancy nor ECC
parity
Data Mode 2 form 1 sectors have 280 bytes of EDC redundancy and
ECC parity beginning at offset 2072
Data Mode 2 form 2 sectors optionally have 4 bytes of EDC
redundancy beginning at offset 2348.
@param c2_error_information If true associate a bit with each
sector for C2 error The resulting bit field is ordered exactly as
the main channel bytes. Each 8-bit boundary defines a byte of
flag bits.
@param subchannel_selection subchannel-selection bits
0 No Sub-channel data shall be returned. (0 bytes)
1 RAW P-W Sub-channel data shall be returned. (96 byte)
2 Formatted Q sub-channel data shall be transferred (16 bytes)
3 Reserved
4 Corrected and de-interleaved R-W sub-channel (96 bytes)
5-7 Reserved
@param i_blocksize size of the a block expected to be returned
@param i_blocks number of blocks expected to be returned.
A DriverOpException is raised on error.
*/
void
mmcReadCd ( void *p_buf, lsn_t i_lsn, int expected_sector_type,
bool b_digital_audio_play, bool b_sync, uint8_t header_codes,
bool b_user_data, bool b_edc_ecc, uint8_t c2_error_information,
uint8_t subchannel_selection, uint16_t i_blocksize,
uint32_t i_blocks )
{
driver_return_code_t drc =
mmc_read_cd ( p_cdio, p_buf, i_lsn, expected_sector_type,
b_digital_audio_play, b_sync, header_codes,
b_user_data, b_edc_ecc, c2_error_information,
subchannel_selection, i_blocksize, i_blocks );
possible_throw_device_exception(drc);
}
/*! Read just the user data part of some sort of data sector (via
mmc_read_cd).
@param p_cdio object to read from
@param p_buf place to read data into. The caller should make sure
this location can store at least CDIO_CD_FRAMESIZE,
M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE depending on
the kind of sector getting read. If you don't know
whether you have a Mode 1/2, Form 1/ Form 2/Formless
sector best to reserve space for the maximum,
M2RAW_SECTOR_SIZE.
@param i_lsn sector to read
@param i_blocksize size of each block
@param i_blocks number of blocks to read
*/
void mmcReadDataSectors ( void *p_buf, lsn_t i_lsn, uint16_t i_blocksize,
uint32_t i_blocks=1)
{
driver_return_code_t drc = mmc_read_data_sectors ( p_cdio, p_buf, i_lsn,
i_blocksize, i_blocks );
possible_throw_device_exception(drc);
}
/*! Read MMC read mode2 sectors
A DriverOpException is raised on error.
*/
void mmcReadSectors ( void *p_buf, lsn_t i_lsn, int read_sector_type,
uint32_t i_blocks=1)
{
driver_return_code_t drc = mmc_read_sectors ( p_cdio, p_buf, i_lsn,
read_sector_type, i_blocks);
possible_throw_device_exception(drc);
}
/*!
Run an MMC command.
@param p_cdio CD structure set by cdio_open().
@param i_timeout_ms time in milliseconds we will wait for the command
to complete.
@param p_cdb CDB bytes. All values that are needed should be set
on input. We'll figure out what the right CDB length
should be.
@param e_direction direction the transfer is to go.
@param i_buf Size of buffer
@param p_buf Buffer for data, both sending and receiving.
@return 0 if command completed successfully.
*/
int mmcRunCmd( unsigned int i_timeout_ms, const mmc_cdb_t *p_cdb,
cdio_mmc_direction_t e_direction, unsigned int i_buf,
/*in/out*/ void *p_buf )
{
return mmc_run_cmd( p_cdio, i_timeout_ms, p_cdb, e_direction, i_buf, p_buf );
}
/*!
Set the block size for subsequent read requests, via MMC.
@param i_blocksize size to set for subsequent requests
A DriverOpException is raised on error.
*/
void mmcSetBlocksize ( uint16_t i_blocksize)
{
driver_return_code_t drc = mmc_set_blocksize ( p_cdio, i_blocksize);
possible_throw_device_exception(drc);
}
/*!
Set the drive speed via MMC.
@param i_speed speed to set drive to.
A DriverOpException is raised on error.
*/
void mmcSetSpeed( int i_speed )
{
driver_return_code_t drc = mmc_set_speed( p_cdio, i_speed );
possible_throw_device_exception(drc);
}
/*!
Load or Unload media using a MMC START STOP command.
@param p_cdio the CD object to be acted upon.
@param b_eject eject if true and close tray if false
@param b_immediate wait or don't wait for operation to complete
@param power_condition Set CD-ROM to idle/standby/sleep. If nonzero
eject/load is ignored, so set to 0 if you want to eject or load.
@see mmc_eject_media or mmc_close_tray
A DriverOpException is raised on error.
*/
void mmcStartStopMedia(bool b_eject, bool b_immediate,
uint8_t power_condition)
{
driver_return_code_t drc =
mmc_start_stop_media(p_cdio, b_eject, b_immediate, power_condition);
possible_throw_device_exception(drc);
}
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

121
include/cdio++/read.hpp Normal file
View File

@@ -0,0 +1,121 @@
/*
$Id: read.hpp,v 1.3 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2005, 2006, 2008 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file read.hpp
*
* \brief methods relating to reading blocks of Compact Discs. This file
* should not be #included directly.
*/
/*!
Reposition read offset
Similar to (if not the same as) libc's lseek()
@param offset amount to seek
@param whence like corresponding parameter in libc's lseek, e.g.
SEEK_SET or SEEK_END.
@return (off_t) -1 on error.
*/
off_t lseek(off_t offset, int whence)
{
return cdio_lseek(p_cdio, offset, whence);
}
/*!
Reads into buf the next size bytes.
Similar to (if not the same as) libc's read()
@param p_buf place to read data into. The caller should make sure
this location can store at least i_size bytes.
@param i_size number of bytes to read
@return (ssize_t) -1 on error.
*/
ssize_t read(void *p_buf, size_t i_size)
{
return cdio_read(p_cdio, p_buf, i_size);
}
/*!
Reads a number of sectors (AKA blocks).
@param p_buf place to read data into. The caller should make sure
this location is large enough. See below for size information.
@param read_mode the kind of "mode" to use in reading.
@param i_lsn sector to read
@param i_blocks number of sectors to read
If read_mode is CDIO_MODE_AUDIO,
*p_buf should hold at least CDIO_FRAMESIZE_RAW * i_blocks bytes.
If read_mode is CDIO_MODE_DATA,
*p_buf should hold at least i_blocks times either ISO_BLOCKSIZE,
M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of
sector getting read. If you don't know whether you have a Mode 1/2,
Form 1/ Form 2/Formless sector best to reserve space for the maximum
which is M2RAW_SECTOR_SIZE.
If read_mode is CDIO_MODE_M2F1,
*p_buf should hold at least M2RAW_SECTOR_SIZE * i_blocks bytes.
If read_mode is CDIO_MODE_M2F2,
*p_buf should hold at least CDIO_CD_FRAMESIZE * i_blocks bytes.
A DriverOpException is raised on error.
*/
void readSectors(void *p_buf, lsn_t i_lsn, cdio_read_mode_t read_mode,
uint32_t i_blocks=1)
{
driver_return_code_t drc = cdio_read_sectors(p_cdio, p_buf, i_lsn, read_mode,
i_blocks);
possible_throw_device_exception(drc);
}
/*!
Reads a number of data sectors (AKA blocks).
@param p_buf place to read data into. The caller should make sure
this location is large enough. See below for size information.
*p_buf should hold at least i_blocks times either ISO_BLOCKSIZE,
M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of
sector getting read. If you don't know whether you have a Mode 1/2,
Form 1/ Form 2/Formless sector best to reserve space for the maximum
which is M2RAW_SECTOR_SIZE.
@param i_lsn sector to read
@param i_blocksize size of block. Should be either CDIO_CD_FRAMESIZE,
M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE. See comment above under p_buf.
@param i_blocks number of sectors to read
A DriverOpException is raised on error.
*/
void readDataBlocks(void *p_buf, lsn_t i_lsn, uint16_t i_blocksize,
uint32_t i_blocks=1)
{
driver_return_code_t drc = cdio_read_data_sectors (p_cdio, p_buf, i_lsn,
i_blocksize, i_blocks);
possible_throw_device_exception(drc);
}

147
include/cdio++/track.hpp Normal file
View File

@@ -0,0 +1,147 @@
/*
$Id: track.hpp,v 1.2 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file track.hpp
* \brief methods relating to getting Compact Discs. This file
* should not be #included directly.
*/
/*!
Return an opaque CdIo_t pointer for the given track object.
*/
CdIo_t *getCdIo()
{
return p_cdio;
}
/*!
Get CD-Text information for a CdIo_t object.
@return the CD-Text object or NULL if obj is NULL
or CD-Text information does not exist.
*/
cdtext_t *getCdtext ()
{
return cdio_get_cdtext (p_cdio, i_track);
}
/*! Return number of channels in track: 2 or 4; -2 if not
implemented or -1 for error.
Not meaningful if track is not an audio track.
*/
int getChannels()
{
return cdio_get_track_channels(p_cdio, i_track);
}
/*! Return copy protection status on a track. Is this meaningful
if not an audio track?
*/
track_flag_t getCopyPermit()
{
return cdio_get_track_copy_permit(p_cdio, i_track);
}
/*!
Get the format (audio, mode2, mode1) of track.
*/
track_format_t getFormat()
{
return cdio_get_track_format(p_cdio, i_track);
}
/*!
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?
*/
bool getGreen()
{
return cdio_get_track_green(p_cdio, i_track);
}
/*!
Return the ending LSN. CDIO_INVALID_LSN is returned on error.
*/
lsn_t getLastLsn()
{
return cdio_get_track_last_lsn(p_cdio, i_track);
}
/*!
Get the starting LBA.
@return the starting LBA or CDIO_INVALID_LBA on error.
*/
lba_t getLba()
{
return cdio_get_track_lba(p_cdio, i_track);
}
/*!
@return the starting LSN or CDIO_INVALID_LSN on error.
*/
lsn_t getLsn()
{
return cdio_get_track_lsn(p_cdio, i_track);
}
/*!
Return the starting MSF (minutes/secs/frames) for track number
i_track in p_cdio.
@return true if things worked or false if there is no track entry.
*/
bool getMsf(/*out*/ msf_t &msf)
{
return cdio_get_track_msf(p_cdio, i_track,/*out*/ &msf);
}
/*!
Return the track number of the track object.
*/
track_t getTrackNum()
{
return i_track;
}
/*! Get linear preemphasis status on an audio track
This is not meaningful if not an audio track?
*/
track_flag_t getPreemphasis()
{
return cdio_get_track_preemphasis(p_cdio, i_track);
}
/*!
Get the number of sectors between this track an the next. This
includes any pregap sectors before the start of the next track.
@return the number of sectors or 0 if there is an error.
*/
unsigned int getSecCount()
{
return cdio_get_track_sec_count(p_cdio, i_track);
}

5
include/cdio/.cvsignore Normal file
View File

@@ -0,0 +1,5 @@
Makefile
Makefile.in
version.h
cdio_config.h

4
include/cdio/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
/Makefile
/Makefile.in
/cdio_config.h
/version.h

62
include/cdio/Makefile.am Normal file
View File

@@ -0,0 +1,62 @@
# $Id: Makefile.am,v 1.34 2008/03/20 19:02:37 karl Exp $
#
# Copyright (C) 2003, 2004, 2006, 2008 Rocky Bernstein <rocky@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
# the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
########################################################
# Things to make the install (public) libcdio headers
########################################################
#
if BUILD_CD_PARANOIA
paranoiaheaders = cdda.h cdtext.h
endif
libcdioincludedir=$(includedir)/cdio
libcdioinclude_HEADERS = \
audio.h \
bytesex.h \
bytesex_asm.h \
cdio.h \
cdio_config.h \
cd_types.h \
device.h \
disc.h \
ds.h \
dvd.h \
ecma_167.h \
iso9660.h \
logging.h \
mmc.h \
paranoia.h \
posix.h \
read.h \
rock.h \
sector.h \
track.h \
types.h \
udf.h \
udf_file.h \
udf_time.h \
utf8.h \
util.h \
version.h \
xa.h \
$(paranoiaheaders)
EXTRA_DIST = version.h.in
BUILT_SOURCES = version.h
DISTCLEANFILES = cdio_config.h

148
include/cdio/audio.h Normal file
View File

@@ -0,0 +1,148 @@
/* -*- c -*-
$Id: audio.h,v 1.12 2008/03/25 15:59:08 karl Exp $
Copyright (C) 2005, 2007, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file audio.h
*
* \brief The top-level header for CD audio-related libcdio
* calls. These control playing of the CD-ROM through its
* line-out jack.
*/
#ifndef __CDIO_AUDIO_H__
#define __CDIO_AUDIO_H__
#include <cdio/types.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! This struct is used by the cdio_audio_read_subchannel */
typedef struct cdio_subchannel_s
{
uint8_t format;
uint8_t audio_status;
uint8_t address: 4;
uint8_t control: 4;
uint8_t track;
uint8_t index;
msf_t abs_addr;
msf_t rel_addr;
} cdio_subchannel_t;
/*! This struct is used by cdio_audio_get_volume and cdio_audio_set_volume */
typedef struct cdio_audio_volume_s
{
uint8_t level[4];
} cdio_audio_volume_t;
/*! This struct is used by the CDROMPLAYTRKIND ioctl */
typedef struct cdio_track_index_s
{
uint8_t i_start_track; /**< start track */
uint8_t i_start_index; /**< start index */
uint8_t i_end_track; /**< end track */
uint8_t i_end_index; /**< end index */
} cdio_track_index_t;
/*!
Get volume of an audio CD.
@param p_cdio the CD object to be acted upon.
@param p_volume place to put the list of volume outputs levels
p_volume can be NULL in which case we return only whether the driver
has the ability to get the volume or not.
*/
driver_return_code_t cdio_audio_get_volume (CdIo_t *p_cdio, /*out*/
cdio_audio_volume_t *p_volume);
/*!
Return the number of seconds (discarding frame portion) of an MSF
*/
uint32_t cdio_audio_get_msf_seconds(msf_t *p_msf);
/*!
Pause playing CD through analog output
@param p_cdio the CD object to be acted upon.
*/
driver_return_code_t cdio_audio_pause (CdIo_t *p_cdio);
/*!
Playing CD through analog output at the given MSF.
@param p_cdio the CD object to be acted upon.
@param p_start_msf pointer to staring MSF
@param p_end_msf pointer to ending MSF
*/
driver_return_code_t cdio_audio_play_msf (CdIo_t *p_cdio,
/*in*/msf_t *p_start_msf,
/*in*/ msf_t *p_end_msf);
/*!
Playing CD through analog output at the desired track and index
@param p_cdio the CD object to be acted upon.
@param p_track_index location to start/end.
*/
driver_return_code_t cdio_audio_play_track_index
( CdIo_t *p_cdio, cdio_track_index_t *p_track_index);
/*!
Get subchannel information.
@param p_cdio the CD object to be acted upon.
@param p_subchannel place for returned subchannel information
*/
driver_return_code_t cdio_audio_read_subchannel (CdIo_t *p_cdio,
/*out*/ cdio_subchannel_t *p_subchannel);
/*!
Resume playing an audio CD.
@param p_cdio the CD object to be acted upon.
*/
driver_return_code_t cdio_audio_resume (CdIo_t *p_cdio);
/*!
Set volume of an audio CD.
@param p_cdio the CD object to be acted upon.
@param p_volume place for returned volume-level information
*/
driver_return_code_t cdio_audio_set_volume (CdIo_t *p_cdio, /*out*/
cdio_audio_volume_t *p_volume);
/*!
Stop playing an audio CD.
@param p_cdio the CD object to be acted upon.
*/
driver_return_code_t cdio_audio_stop (CdIo_t *p_cdio);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __CDIO_AUDIO_H__ */

220
include/cdio/bytesex.h Normal file
View File

@@ -0,0 +1,220 @@
/*
$Id: bytesex.h,v 1.5 2008/03/25 15:59:08 karl Exp $
Copyright (C) 2000, 2004 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file bytesex.h
* \brief Generic Byte-swapping routines.
*
* Note: this header will is slated to get removed and libcdio will
* use glib.h routines instead.
*/
#ifndef __CDIO_BYTESEX_H__
#define __CDIO_BYTESEX_H__
#include <cdio/types.h>
#include <cdio/bytesex_asm.h>
#include <cdio/logging.h>
/** 16-bit big-endian to little-endian */
#define UINT16_SWAP_LE_BE_C(val) ((uint16_t) ( \
(((uint16_t) (val) & (uint16_t) 0x00ffU) << 8) | \
(((uint16_t) (val) & (uint16_t) 0xff00U) >> 8)))
/** 32-bit big-endian to little-endian */
#define UINT32_SWAP_LE_BE_C(val) ((uint32_t) ( \
(((uint32_t) (val) & (uint32_t) 0x000000ffU) << 24) | \
(((uint32_t) (val) & (uint32_t) 0x0000ff00U) << 8) | \
(((uint32_t) (val) & (uint32_t) 0x00ff0000U) >> 8) | \
(((uint32_t) (val) & (uint32_t) 0xff000000U) >> 24)))
/** 64-bit big-endian to little-endian */
#define UINT64_SWAP_LE_BE_C(val) ((uint64_t) ( \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x00000000000000ff)) << 56) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x000000000000ff00)) << 40) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x0000000000ff0000)) << 24) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x00000000ff000000)) << 8) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x000000ff00000000)) >> 8) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x0000ff0000000000)) >> 24) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0x00ff000000000000)) >> 40) | \
(((uint64_t) (val) & (uint64_t) UINT64_C(0xff00000000000000)) >> 56)))
#ifndef UINT16_SWAP_LE_BE
# define UINT16_SWAP_LE_BE UINT16_SWAP_LE_BE_C
#endif
#ifndef UINT32_SWAP_LE_BE
# define UINT32_SWAP_LE_BE UINT32_SWAP_LE_BE_C
#endif
#ifndef UINT64_SWAP_LE_BE
# define UINT64_SWAP_LE_BE UINT64_SWAP_LE_BE_C
#endif
inline static
uint16_t uint16_swap_le_be (const uint16_t val)
{
return UINT16_SWAP_LE_BE (val);
}
inline static
uint32_t uint32_swap_le_be (const uint32_t val)
{
return UINT32_SWAP_LE_BE (val);
}
inline static
uint64_t uint64_swap_le_be (const uint64_t val)
{
return UINT64_SWAP_LE_BE (val);
}
# define UINT8_TO_BE(val) ((uint8_t) (val))
# define UINT8_TO_LE(val) ((uint8_t) (val))
#ifdef WORDS_BIGENDIAN
# define UINT16_TO_BE(val) ((uint16_t) (val))
# define UINT16_TO_LE(val) ((uint16_t) UINT16_SWAP_LE_BE(val))
# define UINT32_TO_BE(val) ((uint32_t) (val))
# define UINT32_TO_LE(val) ((uint32_t) UINT32_SWAP_LE_BE(val))
# define UINT64_TO_BE(val) ((uint64_t) (val))
# define UINT64_TO_LE(val) ((uint64_t) UINT64_SWAP_LE_BE(val))
#else
# define UINT16_TO_BE(val) ((uint16_t) UINT16_SWAP_LE_BE(val))
# define UINT16_TO_LE(val) ((uint16_t) (val))
# define UINT32_TO_BE(val) ((uint32_t) UINT32_SWAP_LE_BE(val))
# define UINT32_TO_LE(val) ((uint32_t) (val))
# define UINT64_TO_BE(val) ((uint64_t) UINT64_SWAP_LE_BE(val))
# define UINT64_TO_LE(val) ((uint64_t) (val))
#endif
/** symmetric conversions */
#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))
/** converter function template */
#define CVT_TO_FUNC(bits) \
static inline uint ## bits ## _t \
uint ## bits ## _to_be (uint ## bits ## _t val) \
{ return UINT ## bits ## _TO_BE (val); } \
static inline uint ## bits ## _t \
uint ## bits ## _to_le (uint ## bits ## _t val) \
{ return UINT ## bits ## _TO_LE (val); } \
CVT_TO_FUNC(8)
CVT_TO_FUNC(16)
CVT_TO_FUNC(32)
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 field conversion routines */
/** Convert from uint8_t to ISO 9660 7.1.1 format */
#define to_711(i) uint8_to_le(i)
/** Convert from ISO 9660 7.1.1 format to uint8_t */
#define from_711(i) uint8_from_le(i)
/** Convert from uint16_t to ISO 9669 7.2.1 format */
#define to_721(i) uint16_to_le(i)
/** Convert from ISO 9660 7.2.1 format to uint16_t */
#define from_721(i) uint16_from_le(i)
/** Convert from uint16_t to ISO 9669 7.2.2 format */
#define to_722(i) uint16_to_be(i)
/** Convert from ISO 9660 7.2.2 format to uint16_t */
#define from_722(i) uint16_from_be(i)
/** Convert from uint16_t to ISO 9669 7.2.3 format */
static inline uint32_t
to_723(uint16_t i)
{
return uint32_swap_le_be(i) | i;
}
/** Convert from ISO 9660 7.2.3 format to uint16_t */
static inline uint16_t
from_723 (uint32_t p)
{
if (uint32_swap_le_be (p) != p)
cdio_warn ("from_723: broken byte order");
return (0xFFFF & p);
}
/** Convert from uint16_t to ISO 9669 7.3.1 format */
#define to_731(i) uint32_to_le(i)
/** Convert from ISO 9660 7.3.1 format to uint32_t */
#define from_731(i) uint32_from_le(i)
/** Convert from uint32_t to ISO 9669 7.3.2 format */
#define to_732(i) uint32_to_be(i)
/** Convert from ISO 9660 7.3.2 format to uint32_t */
#define from_732(i) uint32_from_be(i)
/** Convert from uint16_t to ISO 9669 7.3.3 format */
static inline uint64_t
to_733(uint32_t i)
{
return uint64_swap_le_be(i) | i;
}
/** Convert from ISO 9660 7.3.3 format to uint32_t */
static inline uint32_t
from_733 (uint64_t p)
{
if (uint64_swap_le_be (p) != p)
cdio_warn ("from_733: broken byte order");
return (UINT32_C(0xFFFFFFFF) & p);
}
#endif /* __CDIO_BYTESEX_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

130
include/cdio/bytesex_asm.h Normal file
View File

@@ -0,0 +1,130 @@
/*
$Id: bytesex_asm.h,v 1.3 2008/03/25 15:59:08 karl Exp $
Copyright (C) 2008 Rocky Bernstein <rocky@gnu.org>
2001, 2004, 2005 Herbert Valerio Riedel <hvr@gnu.org>
2001 Sven Ottemann <ac-logic@freenet.de>
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file bytesex_asm.h
* \brief Assembly code to handle byte-swapping.
Note: this header will is slated to get removed and libcdio will use
glib.h routines instead.
*/
#ifndef __CDIO_BYTESEX_ASM_H__
#define __CDIO_BYTESEX_ASM_H__
#if !defined(DISABLE_ASM_OPTIMIZE)
#include <cdio/types.h>
#if defined(__powerpc__) && defined(__GNUC__)
inline static
uint32_t uint32_swap_le_be_asm(const uint32_t a)
{
uint32_t b;
__asm__ ("lwbrx %0,0,%1"
:"=r"(b)
:"r"(&a), "m"(a));
return b;
}
inline static
uint16_t uint16_swap_le_be_asm(const uint16_t a)
{
uint32_t b;
__asm__ ("lhbrx %0,0,%1"
:"=r"(b)
:"r"(&a), "m"(a));
return b;
}
#define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
#define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
#elif defined(__mc68000__) && defined(__STORMGCC__)
inline static
uint32_t uint32_swap_le_be_asm(uint32_t a __asm__("d0"))
{
/* __asm__("rolw #8,%0; swap %0; rolw #8,%0" : "=d" (val) : "0" (val)); */
__asm__("move.l %1,d0;rol.w #8,d0;swap d0;rol.w #8,d0;move.l d0,%0"
:"=r"(a)
:"r"(a));
return(a);
}
inline static
uint16_t uint16_swap_le_be_asm(uint16_t a __asm__("d0"))
{
__asm__("move.l %1,d0;rol.w #8,d0;move.l d0,%0"
:"=r"(a)
:"r"(a));
return(a);
}
#define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
#define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
#elif 0 && defined(__i386__) && defined(__GNUC__)
inline static
uint32_t uint32_swap_le_be_asm(uint32_t a)
{
__asm__("xchgb %b0,%h0\n\t" /* swap lower bytes */
"rorl $16,%0\n\t" /* swap words */
"xchgb %b0,%h0" /* swap higher bytes */
:"=q" (a)
: "0" (a));
return(a);
}
inline static
uint16_t uint16_swap_le_be_asm(uint16_t a)
{
__asm__("xchgb %b0,%h0" /* swap bytes */
: "=q" (a)
: "0" (a));
return(a);
}
#define UINT16_SWAP_LE_BE uint16_swap_le_be_asm
#define UINT32_SWAP_LE_BE uint32_swap_le_be_asm
#endif
#endif /* !defined(DISABLE_ASM_OPTIMIZE) */
#endif /* __CDIO_BYTESEX_ASM_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

175
include/cdio/cd_types.h Normal file
View File

@@ -0,0 +1,175 @@
/*
$Id: cd_types.h,v 1.18 2008/03/25 15:59:08 karl Exp $
Copyright (C) 2003, 2006, 2008 Rocky Bernstein <rocky@cpan.org>
Copyright (C) 1996,1997,1998 Gerd Knorr <kraxel@bytesex.org>
and Heiko Ei<45>feldt <heiko@hexco.de>
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \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__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* Filesystem types we understand. The highest-numbered fs type should
* be less than CDIO_FS_MASK defined below.
*/
typedef enum {
CDIO_FS_AUDIO = 1, /**< audio only - not really a
filesystem */
CDIO_FS_HIGH_SIERRA = 2, /**< High-Sierra Filesystem */
CDIO_FS_ISO_9660 = 3, /**< ISO 9660 filesystem */
CDIO_FS_INTERACTIVE = 4,
CDIO_FS_HFS = 5, /**< file system used on the Macintosh
system in MacOS 6 through MacOS 9
and deprecated in OSX. */
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 is EXT2 with a journal.
*/
CDIO_FS_EXT2 = 7,
CDIO_FS_ISO_HFS = 8, /**< both HFS & ISO-9660 filesystem */
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.
*/
CDIO_FS_3DO = 10,
/**<
Microsoft X-BOX CD.
*/
CDIO_FS_XISO = 11,
CDIO_FS_UDFX = 12,
CDIO_FS_UDF = 13,
CDIO_FS_ISO_UDF = 14
} cdio_fs_t;
/**
* 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. This
*/
typedef enum {
CDIO_FS_MASK = 0x000f, /**< Note: this should be 2**n-1 and
and greater than the highest
CDIO_FS number above */
CDIO_FS_ANAL_XA = 0x00010, /**< eXtended Architecture format */
CDIO_FS_ANAL_MULTISESSION = 0x00020, /**< CD has multisesion */
CDIO_FS_ANAL_PHOTO_CD = 0x00040, /**< Is a Kodak Photo CD */
CDIO_FS_ANAL_HIDDEN_TRACK = 0x00080, /**< Hidden track at the
beginning of the CD */
CDIO_FS_ANAL_CDTV = 0x00100,
CDIO_FS_ANAL_BOOTABLE = 0x00200, /**< CD is bootable */
CDIO_FS_ANAL_VIDEOCD = 0x00400, /**< VCD 1.1 */
CDIO_FS_ANAL_ROCKRIDGE = 0x00800, /**< Has Rock Ridge Extensions to
ISO 9660, */
CDIO_FS_ANAL_JOLIET = 0x01000, /**< Microsoft Joliet extensions
to ISO 9660, */
CDIO_FS_ANAL_SVCD = 0x02000, /**< Super VCD or Choiji Video CD */
CDIO_FS_ANAL_CVD = 0x04000, /**< Choiji Video CD */
CDIO_FS_ANAL_XISO = 0x08000, /**< XBOX CD */
CDIO_FS_ANAL_ISO9660_ANY = 0x10000, /**< Any sort fo ISO9660 FS */
CDIO_FS_ANAL_VCD_ANY = (CDIO_FS_ANAL_VIDEOCD|CDIO_FS_ANAL_SVCD|
CDIO_FS_ANAL_CVD),
CDIO_FS_MATCH_ALL = ~CDIO_FS_MASK /**< bitmask which can
be used by
cdio_get_devices to
specify matching any
sort of CD. */
} cdio_fs_cap_t;
#define CDIO_FS_UNKNOWN CDIO_FS_MASK
/**
*
*/
#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; /**< 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;
uint8_t UDFVerMinor; /**< For UDF filesystems only */
uint8_t UDFVerMajor; /**< For UDF filesystems only */
} 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 iso_analysis and the return value.
*/
cdio_fs_anal_t cdio_guess_cd_type(const CdIo_t *cdio, int start_session,
track_t track_num,
/*out*/ cdio_iso_analysis_t *iso_analysis);
#ifdef __cplusplus
}
#endif /* __cplusplus */
/** The below variables are trickery to force the above enum symbol
values to be recorded in debug symbol tables. They are used to
allow one to refer to the enumeration value names in the typedefs
above in a debugger and debugger expressions.
*/
extern cdio_fs_cap_t debug_cdio_fs_cap;
extern cdio_fs_t debug_cdio_fs;
#endif /* __CDIO_CD_TYPES_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

411
include/cdio/cdda.h Normal file
View File

@@ -0,0 +1,411 @@
/*
$Id: cdda.h,v 1.30 2008/03/25 15:59:08 karl Exp $
Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2001 Xiph.org and Heiko Eissfeldt heiko@escape.colossus.de
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file cdda.h
*
* \brief The top-level interface header for libcdio_cdda.
* Applications include this for paranoia access.
*
******************************************************************/
#ifndef _CDDA_INTERFACE_H_
#define _CDDA_INTERFACE_H_
#include <cdio/cdio.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** cdrom_paranoia is an opaque structure which is used in all of the
library operations.
*/
typedef struct cdrom_paranoia_s cdrom_paranoia_t;
typedef struct cdrom_drive_s cdrom_drive_t;
/** For compatibility. cdrom_drive_t is deprecated, use cdrom_drive_t
instead. */
/**
Flags for simulating jitter used in testing.
The enumeration type one probably wouldn't really use in a program.
It is here instead of defines to give symbolic names that can be
helpful in debuggers where wants just to say refer to
CDDA_TEST_JITTER_SMALL and get the correct value.
*/
typedef enum {
CDDA_MESSAGE_FORGETIT = 0,
CDDA_MESSAGE_PRINTIT = 1,
CDDA_MESSAGE_LOGIT = 2,
CD_FRAMESAMPLES = CDIO_CD_FRAMESIZE_RAW / 4,
MAXTRK = (CDIO_CD_MAX_TRACKS+1)
} paranoia_cdda_enums_t;
#include <signal.h>
/** We keep MAXTRK since this header is exposed publicly and other
programs may have used this.
*/
#define MAXTRK (CDIO_CD_MAX_TRACKS+1)
/** \brief Structure for cdparanoia's CD Table of Contents */
typedef struct TOC_s {
unsigned char bTrack;
int32_t dwStartSector;
} TOC_t;
/** For compatibility. TOC is deprecated, use TOC_t instead. */
#define TOC TOC_t
/** \brief Structure for cdparanoia's CD-ROM access */
struct cdrom_drive_s {
CdIo_t *p_cdio;
int opened; /**< This struct may just represent a candidate for opening */
char *cdda_device_name;
char *drive_model;
int drive_type;
int bigendianp; /**< Whether data returned on the CDDA is bigendian or
not. 1 if big endian, 0 if little endian and -1 if
we don't know.
*/
int nsectors; /**< Number of sectors use in reading. Multiply by
CDIO_CD_FRAMESIZE_RAW to get number of bytes used in
the read buffer. */
int cd_extra; /**< -1 if we can't get multisession info, 0 if
there is one session only or the multi-session
LBA is less than or 100 (don't ask me why -- I
don't know), and 1 if the multi-session lba is
greater than 100. */
bool b_swap_bytes; /**< Swap bytes if Endian-ness of drive
mismatches the endian-ness of the
computer? */
track_t tracks;
TOC_t disc_toc[MAXTRK]; /**< info here starts origin 0 rather than the
first track number (usually 1). So to take
a track number and use it here, subtract
off cdio_get_first_track_num() beforehand.
*/
lsn_t audio_first_sector;
lsn_t audio_last_sector;
int errordest;
int messagedest;
char *errorbuf;
char *messagebuf;
/* functions specific to particular drives/interfaces */
int (*enable_cdda) (cdrom_drive_t *d, int onoff);
int (*read_toc) (cdrom_drive_t *d);
long (*read_audio) (cdrom_drive_t *d, void *p, lsn_t begin,
long sectors);
int (*set_speed) (cdrom_drive_t *d, int speed);
int error_retry;
int report_all;
int is_atapi;
int is_mmc;
int i_test_flags; /**< Normally set 0. But if we are testing
paranoia operation this can be set to one of
the flag masks to simulate a particular kind of
failure. */
};
/**
Flags for simulating jitter used in testing.
The enumeration type one probably wouldn't really use in a program.
It is here instead of defines to give symbolic names that can be
helpful in debuggers where wants just to say refer to
CDDA_TEST_JITTER_SMALL and get the correct value.
*/
typedef enum {
CDDA_TEST_JITTER_SMALL = 1,
CDDA_TEST_JITTER_LARGE = 2,
CDDA_TEST_JITTER_MASSIVE = 3,
CDDA_TEST_FRAG_SMALL = (1<<3),
CDDA_TEST_FRAG_LARGE = (2<<3),
CDDA_TEST_FRAG_MASSIVE = (3<<3),
CDDA_TEST_UNDERRUN = 64
} paranoia_jitter_t;
/** jitter testing. The first two bits are set to determine the
byte-distance we will jitter the data; 0 is no shifting.
*/
/**< jitter testing. Set the below bit to always cause jittering on reads.
The below bit only has any effect if the first two (above) bits are
nonzero. If the above bits are set, but the below bit isn't we'll
jitter 90% of the time.
*/
#define CDDA_TEST_ALWAYS_JITTER 4
/** fragment testing */
#define CDDA_TEST_FRAG_SMALL (1<<3)
#define CDDA_TEST_FRAG_LARGE (2<<3)
#define CDDA_TEST_FRAG_MASSIVE (3<<3)
/**< under-run testing. The below bit is set for testing. */
#define CDDA_TEST_UNDERRUN 64
#if TESTING_IS_FINISHED
/** scratch testing */
#define CDDA_TEST_SCRATCH 128
#undef CDDA_TEST_BOGUS_BYTES 256
#undef CDDA_TEST_DROPDUPE_BYTES 512
#endif /* TESTING_IS_FINISHED */
/** autosense functions */
/** Get a CD-ROM drive with a CD-DA in it.
If mesagedest is 1, then any messages in the process will be stored
in message.
*/
extern cdrom_drive_t *cdio_cddap_find_a_cdrom(int messagedest,
char **ppsz_message);
/** Returns a paranoia CD-ROM drive object with a CD-DA in it or NULL
if there was an error.
@see cdio_cddap_identify_cdio
*/
extern cdrom_drive_t *cdio_cddap_identify(const char *psz_device,
int messagedest,
char **ppsz_message);
/** Returns a paranoia CD-ROM drive object with a CD-DA in it or NULL
if there was an error. In contrast to cdio_cddap_identify, we
start out with an initialized p_cdio object. For example you may
have used that for other purposes such as to get CDDB/CD-Text
information. @see cdio_cddap_identify
*/
cdrom_drive_t *cdio_cddap_identify_cdio(CdIo_t *p_cdio,
int messagedest, char **ppsz_messages);
/** drive-oriented functions */
extern int cdio_cddap_speed_set(cdrom_drive_t *d, int speed);
extern void cdio_cddap_verbose_set(cdrom_drive_t *d, int err_action,
int mes_action);
extern char *cdio_cddap_messages(cdrom_drive_t *d);
extern char *cdio_cddap_errors(cdrom_drive_t *d);
/*!
Closes d and releases all storage associated with it except
the internal p_cdio pointer.
@param d cdrom_drive_t object to be closed.
@return 0 if passed a null pointer and 1 if not in which case
some work was probably done.
@see cdio_cddap_close
*/
bool cdio_cddap_close_no_free_cdio(cdrom_drive_t *d);
/*!
Closes d and releases all storage associated with it.
Doubles as "cdrom_drive_free()".
@param d cdrom_drive_t object to be closed.
@return 0 if passed a null pointer and 1 if not in which case
some work was probably done.
@see cdio_cddap_close_no_free_cdio
*/
extern int cdio_cddap_close(cdrom_drive_t *d);
extern int cdio_cddap_open(cdrom_drive_t *d);
extern long cdio_cddap_read(cdrom_drive_t *d, void *p_buffer,
lsn_t beginsector, long sectors);
/*! Return the lsn for the start of track i_track */
extern lsn_t cdio_cddap_track_firstsector(cdrom_drive_t *d,
track_t i_track);
/*! Get last lsn of the track. This generally one less than the start
of the next track. -1 is returned on error. */
extern lsn_t cdio_cddap_track_lastsector(cdrom_drive_t *d, track_t i_track);
/*! Return the number of tracks on the CD. */
extern track_t cdio_cddap_tracks(cdrom_drive_t *d);
/*! Return the track containing the given LSN. If the LSN is before
the first track (in the pregap), 0 is returned. If there was an
error or the LSN after the LEADOUT (beyond the end of the CD), then
CDIO_INVALID_TRACK is returned.
*/
extern int cdio_cddap_sector_gettrack(cdrom_drive_t *d, lsn_t lsn);
/*! Return the number of channels in track: 2 or 4; -2 if not
implemented or -1 for error.
Not meaningful if track is not an audio track.
*/
extern int cdio_cddap_track_channels(cdrom_drive_t *d, track_t i_track);
/*! Return 1 is track is an audio track, 0 otherwise. */
extern int cdio_cddap_track_audiop(cdrom_drive_t *d, track_t i_track);
/*! Return 1 is track has copy permit set, 0 otherwise. */
extern int cdio_cddap_track_copyp(cdrom_drive_t *d, track_t i_track);
/*! Return 1 is audio track has linear preemphasis set, 0 otherwise.
Only makes sense for audio tracks.
*/
extern int cdio_cddap_track_preemp(cdrom_drive_t *d, track_t i_track);
/*! Get first lsn of the first audio track. -1 is returned on error. */
extern lsn_t cdio_cddap_disc_firstsector(cdrom_drive_t *d);
/*! Get last lsn of the last audio track. The last lsn is generally one
less than the start of the next track after the audio track. -1 is
returned on error. */
extern lsn_t cdio_cddap_disc_lastsector(cdrom_drive_t *d);
/*! Determine Endian-ness of the CD-drive based on reading data from
it. Some drives return audio data Big Endian while some (most)
return data Little Endian. Drives known to return data bigendian are
SCSI drives from Kodak, Ricoh, HP, Philips, Plasmon, Grundig
CDR100IPW, and Mitsumi CD-R. ATAPI and MMC drives are little endian.
rocky: As someone who didn't write the code, I have to say this is
nothing less than brilliant. An FFT is done both ways and the the
transform is looked at to see which has data in the FFT (or audible)
portion. (Or so that's how I understand it.)
@return 1 if big-endian, 0 if little-endian, -1 if we couldn't
figure things out or some error.
*/
extern int data_bigendianp(cdrom_drive_t *d);
/** transport errors: */
typedef enum {
TR_OK = 0,
TR_EWRITE = 1 /**< Error writing packet command (transport) */,
TR_EREAD = 2 /**< Error reading packet data (transport) */,
TR_UNDERRUN = 3 /**< Read underrun */,
TR_OVERRUN = 4 /**< Read overrun */,
TR_ILLEGAL = 5 /**< Illegal/rejected request */,
TR_MEDIUM = 6 /**< Medium error */,
TR_BUSY = 7 /**< Device busy */,
TR_NOTREADY = 8 /**< Device not ready */,
TR_FAULT = 9 /**< Device failure */,
TR_UNKNOWN = 10 /**< Unspecified error */,
TR_STREAMING = 11 /**< loss of streaming */,
} transport_error_t;
#ifdef NEED_STRERROR_TR
const char *strerror_tr[]={
"Success",
"Error writing packet command to device",
"Error reading command from device",
"SCSI packet data underrun (too little data)",
"SCSI packet data overrun (too much data)",
"Illegal SCSI request (rejected by target)",
"Medium reading data from medium",
"Device busy",
"Device not ready",
"Target hardware fault",
"Unspecified error",
"Drive lost streaming"
};
#endif /*NEED_STERROR_TR*/
/** Errors returned by lib:
\verbatim
001: Unable to set CDROM to read audio mode
002: Unable to read table of contents lead-out
003: CDROM reporting illegal number of tracks
004: Unable to read table of contents header
005: Unable to read table of contents entry
006: Could not read any data from drive
007: Unknown, unrecoverable error reading data
008: Unable to identify CDROM model
009: CDROM reporting illegal table of contents
010: Unaddressable sector
100: Interface not supported
101: Drive is neither a CDROM nor a WORM device
102: Permision denied on cdrom (ioctl) device
103: Permision denied on cdrom (data) device
300: Kernel memory error
400: Device not open
401: Invalid track number
402: Track not audio data
403: No audio tracks on disc
\endverbatim
*/
#ifndef DO_NOT_WANT_PARANOIA_COMPATIBILITY
/** For compatibility with good ol' paranoia */
#define cdda_find_a_cdrom cdio_cddap_find_a_cdrom
#define cdda_identify cdio_cddap_identify
#define cdda_speed_set cdio_cddap_speed_set
#define cdda_verbose_set cdio_cddap_verbose_set
#define cdda_messages cdio_cddap_messages
#define cdda_errors cdio_cddap_errors
#define cdda_close cdio_cddap_close
#define cdda_open cdio_cddap_open
#define cdda_read cdio_cddap_read
#define cdda_track_firstsector cdio_cddap_track_firstsector
#define cdda_track_lastsector cdio_cddap_track_lastsector
#define cdda_tracks cdio_cddap_tracks
#define cdda_sector_gettrack cdio_cddap_sector_gettrack
#define cdda_track_channels cdio_cddap_track_channels
#define cdda_track_audiop cdio_cddap_track_audiop
#define cdda_track_copyp cdio_cddap_track_copyp
#define cdda_track_preemp cdio_cddap_track_preemp
#define cdda_disc_firstsector cdio_cddap_disc_firstsector
#define cdda_disc_lastsector cdio_cddap_disc_lastsector
#define cdrom_drive cdrom_drive_t
#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
#ifdef __cplusplus
}
#endif /* __cplusplus */
/** The below variables are trickery to force the above enum symbol
values to be recorded in debug symbol tables. They are used to
allow one to refer to the enumeration value names in the typedefs
above in a debugger and debugger expressions
*/
extern paranoia_jitter_t debug_paranoia_jitter;
extern paranoia_cdda_enums_t debug_paranoia_cdda_enums;
#endif /*_CDDA_INTERFACE_H_*/

84
include/cdio/cdio.h Normal file
View File

@@ -0,0 +1,84 @@
/* -*- c -*-
$Id: cdio.h,v 1.82 2008/03/25 15:59:08 karl Exp $
Copyright (C) 2003, 2004, 2005, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2001 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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file cdio.h
*
* \brief The top-level header for libcdio: the CD Input and Control
* library. Applications include this for anything regarding libcdio.
*/
#ifndef __CDIO_H__
#define __CDIO_H__
/** Application Interface or Protocol version number. If the public
* interface changes, we increase this number.
*/
#define CDIO_API_VERSION 5
#include <cdio/version.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <cdio/types.h>
#include <cdio/sector.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* For compatibility. */
#define CdIo CdIo_t
/** This is an opaque structure for the CD object. */
typedef struct _CdIo CdIo_t;
/** This is an opaque structure for the CD-Text object. */
typedef struct cdtext cdtext_t;
#ifdef __cplusplus
}
#endif /* __cplusplus */
/* Drive(r)/Device-related functions. Perhaps we should break out
Driver from device?
*/
#include <cdio/device.h>
/* Disc-related functions. */
#include <cdio/disc.h>
/* Sector (frame, or block)-related functions. Uses driver_return_code_t
from <cdio/device.h> so it should come after that.
*/
#include <cdio/read.h>
/* CD-Text-related functions. */
#include <cdio/cdtext.h>
/* Track-related functions. */
#include <cdio/track.h>
#endif /* __CDIO_H__ */

125
include/cdio/cdtext.h Normal file
View File

@@ -0,0 +1,125 @@
/*
$Id: cdtext.h,v 1.14 2008/03/25 15:59:08 karl Exp $
Copyright (C) 2004, 2005, 2008 Rocky Bernstein <rocky@gnu.org>
adapted from cuetools
Copyright (C) 2003 Svend Sanjay Sorensen <ssorensen@fastmail.fm>
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file cdtext.h
*
* \brief The top-level header for CD-Text information. Applications
* include this for CD-Text access.
*/
#ifndef __CDIO_CDTEXT_H__
#define __CDIO_CDTEXT_H__
#include <cdio/cdio.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define MAX_CDTEXT_FIELDS 13
#define MIN_CDTEXT_FIELD 0
/*! \brief structure for holding CD-Text information
@see cdtext_init, cdtext_destroy, cdtext_get, and cdtext_set.
*/
struct cdtext {
char *field[MAX_CDTEXT_FIELDS];
};
/*! \brief A list of all of the CD-Text fields. Because
the interval has no gaps, we can use ++ to iterate over fields.
*/
typedef enum {
CDTEXT_ARRANGER = 0, /**< name(s) of the arranger(s) */
CDTEXT_COMPOSER = 1, /**< name(s) of the composer(s) */
CDTEXT_DISCID = 2, /**< disc identification information */
CDTEXT_GENRE = 3, /**< genre identification and genre information */
CDTEXT_MESSAGE = 4, /**< ISRC code of each track */
CDTEXT_ISRC = 5, /**< message(s) from the content provider or artist */
CDTEXT_PERFORMER = 6, /**< name(s) of the performer(s) */
CDTEXT_SIZE_INFO = 7, /**< size information of the block */
CDTEXT_SONGWRITER = 8, /**< name(s) of the songwriter(s) */
CDTEXT_TITLE = 9, /**< title of album name or track titles */
CDTEXT_TOC_INFO = 10, /**< table of contents information */
CDTEXT_TOC_INFO2 = 11, /**< second table of contents information */
CDTEXT_UPC_EAN = 12,
CDTEXT_INVALID = MAX_CDTEXT_FIELDS
} cdtext_field_t;
/*! Return string representation of the enum values above */
const char *cdtext_field2str (cdtext_field_t i);
/*! Initialize a new cdtext structure.
When the structure is no longer needed, release the
resources using cdtext_delete.
*/
void cdtext_init (cdtext_t *cdtext);
/*! Free memory assocated with cdtext*/
void cdtext_destroy (cdtext_t *cdtext);
/*! returns an allocated string associated with the given field. NULL is
returned if key is CDTEXT_INVALID or the field is not set.
The user needs to free the string when done with it.
@see cdio_get_const to retrieve a constant string that doesn't
have to be freed.
*/
char *cdtext_get (cdtext_field_t key, const cdtext_t *cdtext);
/*! returns a const string associated with the given field. NULL is
returned if key is CDTEXT_INVALID or the field is not set.
Don't use the string when the cdtext object (i.e. the CdIo_t object
you got it from) is no longer valid.
@see cdio_get to retrieve an allocated string that persists past
the cdtext object.
*/
const char *cdtext_get_const (cdtext_field_t key, const cdtext_t *cdtext);
/*!
returns enum of keyword if key is a CD-Text keyword,
returns MAX_CDTEXT_FIELDS non-zero otherwise.
*/
cdtext_field_t cdtext_is_keyword (const char *key);
/*!
sets cdtext's keyword entry to field
*/
void cdtext_set (cdtext_field_t key, const char *value, cdtext_t *cdtext);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __CDIO_CDTEXT_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

949
include/cdio/device.h Normal file
View File

@@ -0,0 +1,949 @@
/* -*- c -*-
$Id: device.h,v 1.39 2008/03/28 01:28:50 rocky Exp $
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file device.h
*
* \brief C header for driver- or device-related libcdio
* calls. ("device" includes CD-image reading devices).
*/
#ifndef __CDIO_DEVICE_H__
#define __CDIO_DEVICE_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! The type of an drive capability bit mask. See below for values*/
typedef uint32_t cdio_drive_read_cap_t;
typedef uint32_t cdio_drive_write_cap_t;
typedef uint32_t cdio_drive_misc_cap_t;
/*!
\brief Drive capability bits returned by cdio_get_drive_cap()
NOTE: Setting a bit here means the presence of a capability.
*/
/** Miscellaneous capabilities. */
typedef enum {
CDIO_DRIVE_CAP_ERROR = 0x40000, /**< Error */
CDIO_DRIVE_CAP_UNKNOWN = 0x80000, /**< Dunno. It can be on if we
have only partial information
or are not completely certain
*/
CDIO_DRIVE_CAP_MISC_CLOSE_TRAY = 0x00001, /**< caddy systems can't
close... */
CDIO_DRIVE_CAP_MISC_EJECT = 0x00002, /**< but can eject. */
CDIO_DRIVE_CAP_MISC_LOCK = 0x00004, /**< disable manual eject */
CDIO_DRIVE_CAP_MISC_SELECT_SPEED = 0x00008, /**< programmable speed */
CDIO_DRIVE_CAP_MISC_SELECT_DISC = 0x00010, /**< select disc from
juke-box */
CDIO_DRIVE_CAP_MISC_MULTI_SESSION= 0x00020, /**< read sessions>1 */
CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED= 0x00080, /**< media changed */
CDIO_DRIVE_CAP_MISC_RESET = 0x00100, /**< hard reset device */
CDIO_DRIVE_CAP_MISC_FILE = 0x20000 /**< drive is really a file,
i.e a CD file image */
} cdio_drive_cap_misc_t;
/*! Reading masks.. */
typedef enum {
CDIO_DRIVE_CAP_READ_AUDIO = 0x00001, /**< drive can play CD audio */
CDIO_DRIVE_CAP_READ_CD_DA = 0x00002, /**< drive can read CD-DA */
CDIO_DRIVE_CAP_READ_CD_G = 0x00004, /**< drive can read CD+G */
CDIO_DRIVE_CAP_READ_CD_R = 0x00008, /**< drive can read CD-R */
CDIO_DRIVE_CAP_READ_CD_RW = 0x00010, /**< drive can read CD-RW */
CDIO_DRIVE_CAP_READ_DVD_R = 0x00020, /**< drive can read DVD-R */
CDIO_DRIVE_CAP_READ_DVD_PR = 0x00040, /**< drive can read DVD+R */
CDIO_DRIVE_CAP_READ_DVD_RAM = 0x00080, /**< drive can read DVD-RAM */
CDIO_DRIVE_CAP_READ_DVD_ROM = 0x00100, /**< drive can read DVD-ROM */
CDIO_DRIVE_CAP_READ_DVD_RW = 0x00200, /**< drive can read DVD-RW */
CDIO_DRIVE_CAP_READ_DVD_RPW = 0x00400, /**< drive can read DVD+RW */
CDIO_DRIVE_CAP_READ_C2_ERRS = 0x00800, /**< has C2 error correction */
CDIO_DRIVE_CAP_READ_MODE2_FORM1 = 0x01000, /**< can read mode 2 form 1 */
CDIO_DRIVE_CAP_READ_MODE2_FORM2 = 0x02000, /**< can read mode 2 form 2 */
CDIO_DRIVE_CAP_READ_MCN = 0x04000, /**< can read MCN */
CDIO_DRIVE_CAP_READ_ISRC = 0x08000 /**< can read ISRC */
} cdio_drive_cap_read_t;
/*! Writing masks.. */
typedef enum {
CDIO_DRIVE_CAP_WRITE_CD_R = 0x00001, /**< drive can write CD-R */
CDIO_DRIVE_CAP_WRITE_CD_RW = 0x00002, /**< drive can write CD-RW */
CDIO_DRIVE_CAP_WRITE_DVD_R = 0x00004, /**< drive can write DVD-R */
CDIO_DRIVE_CAP_WRITE_DVD_PR = 0x00008, /**< drive can write DVD+R */
CDIO_DRIVE_CAP_WRITE_DVD_RAM = 0x00010, /**< drive can write DVD-RAM */
CDIO_DRIVE_CAP_WRITE_DVD_RW = 0x00020, /**< drive can write DVD-RW */
CDIO_DRIVE_CAP_WRITE_DVD_RPW = 0x00040, /**< drive can write DVD+RW */
CDIO_DRIVE_CAP_WRITE_MT_RAINIER = 0x00080, /**< Mount Rainier */
CDIO_DRIVE_CAP_WRITE_BURN_PROOF = 0x00100, /**< burn proof */
CDIO_DRIVE_CAP_WRITE_CD =
(CDIO_DRIVE_CAP_WRITE_CD_R | CDIO_DRIVE_CAP_WRITE_CD_RW),
/**< Has some sort of CD writer ability */
CDIO_DRIVE_CAP_WRITE_DVD =
(CDIO_DRIVE_CAP_WRITE_DVD_R | CDIO_DRIVE_CAP_WRITE_DVD_PR
| CDIO_DRIVE_CAP_WRITE_DVD_RAM | CDIO_DRIVE_CAP_WRITE_DVD_RW
| CDIO_DRIVE_CAP_WRITE_DVD_RPW ),
/**< Has some sort of DVD writer ability */
CDIO_DRIVE_CAP_WRITE =
(CDIO_DRIVE_CAP_WRITE_CD | CDIO_DRIVE_CAP_WRITE_DVD)
/**< Has some sort of DVD or CD writing ability */
} cdio_drive_cap_write_t;
/*! Size of fields returned by an INQUIRY command */
typedef enum {
CDIO_MMC_HW_VENDOR_LEN = 8, /**< length of vendor field */
CDIO_MMC_HW_MODEL_LEN = 16, /**< length of model field */
CDIO_MMC_HW_REVISION_LEN = 4 /**< length of revision field */
} cdio_mmc_hw_len_t;
/*! \brief Structure to return CD vendor, model, and revision-level
strings obtained via the INQUIRY command */
typedef struct cdio_hwinfo
{
char psz_vendor [CDIO_MMC_HW_VENDOR_LEN+1];
char psz_model [CDIO_MMC_HW_MODEL_LEN+1];
char psz_revision[CDIO_MMC_HW_REVISION_LEN+1];
} cdio_hwinfo_t;
/** Flags specifying the category of device to open or is opened. */
typedef enum {
CDIO_SRC_IS_DISK_IMAGE_MASK = 0x0001, /**< Read source is a CD image. */
CDIO_SRC_IS_DEVICE_MASK = 0x0002, /**< Read source is a CD device. */
CDIO_SRC_IS_SCSI_MASK = 0x0004, /**< Read source SCSI device. */
CDIO_SRC_IS_NATIVE_MASK = 0x0008
} cdio_src_category_mask_t;
/** 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.
* Also the enumeration values are assumed not to leave any holes so
* we can use ++ to iterate over values.
* We have to start with DRIVER_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, /**< Used as input when we don't care what kind
of driver to use. */
DRIVER_AIX, /**< AIX driver */
DRIVER_BSDI, /**< BSDI driver */
DRIVER_FREEBSD, /**< FreeBSD driver - includes CAM and ioctl access */
DRIVER_LINUX, /**< GNU/Linux Driver */
DRIVER_SOLARIS, /**< Sun Solaris Driver */
DRIVER_OSX, /**< Apple OSX Driver */
DRIVER_WIN32, /**< Microsoft Windows Driver. Includes ASPI and
ioctl access. */
DRIVER_NETBSD, /**< NetBSD Driver. */
DRIVER_CDRDAO, /**< cdrdao format CD image. This is listed
before BIN/CUE, to make the code prefer cdrdao
over BIN/CUE when both exist. */
DRIVER_BINCUE, /**< CDRWIN BIN/CUE format CD image. This is
listed before NRG, to make the code prefer
BIN/CUE 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;
/** 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.
*/
extern const driver_id_t cdio_os_driver;
/** 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_AIX
#define CDIO_MIN_DEVICE_DRIVER CDIO_MIN_DRIVER
#define CDIO_MAX_DRIVER DRIVER_NRG
#define CDIO_MAX_DEVICE_DRIVER DRIVER_NETBSD
/** The following are status codes for completion of a given cdio
operation. By design 0 is successful completion and -1 is error
completion. This is compatable with ioctl so those routines that
call ioctl can just pass the value the get back (cast as this
enum). Also, by using negative numbers for errors, the
enumeration values below can be used in places where a positive
value is expected when things complete successfully. For example,
get_blocksize returns the blocksize, but on error uses the error
codes below. So note that this enumeration is often cast to an
integer. C seems to tolerate this.
*/
typedef enum {
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_OP_ERROR = -1, /**< operation returned an error */
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_UNINIT = -3, /**< returned when a particular driver
hasn't been initialized or a null
pointer has been passed.
*/
DRIVER_OP_NOT_PERMITTED = -4, /**< Operation not permitted.
For example might be a permission
problem.
*/
DRIVER_OP_BAD_PARAMETER = -5, /**< Bad parameter passed */
DRIVER_OP_BAD_POINTER = -6, /**< Bad pointer to memory area */
DRIVER_OP_NO_DRIVER = -7, /**< Operaton called on a driver
not available on this OS */
} driver_return_code_t;
/*!
Close media tray in CD drive if there is a routine to do so.
@param psz_drive the name of CD-ROM to be closed. If NULL, we will
use the default device.
@param p_driver_id is the driver to be used or that got used if
it was DRIVER_UNKNOWN or DRIVER_DEVICE; If this is NULL, we won't
report back the driver used.
*/
driver_return_code_t cdio_close_tray (const char *psz_drive,
/*in/out*/ driver_id_t *p_driver_id);
/*!
@param drc the return code you want interpreted.
@return the string information about drc
*/
const char *cdio_driver_errmsg(driver_return_code_t drc);
/*!
Eject media in CD drive if there is a routine to do so.
@param p_cdio the CD object to be acted upon.
If the CD is ejected *p_cdio is free'd and p_cdio set to NULL.
*/
driver_return_code_t cdio_eject_media (CdIo_t **p_cdio);
/*!
Eject media in CD drive if there is a routine to do so.
@param psz_drive the name of the device to be acted upon.
If NULL is given as the drive, we'll use the default driver device.
*/
driver_return_code_t cdio_eject_media_drive (const char *psz_drive);
/*!
Free device list returned by cdio_get_devices or
cdio_get_devices_with_cap.
@param device_list list returned by cdio_get_devices or
cdio_get_devices_with_cap
@see cdio_get_devices, cdio_get_devices_with_cap
*/
void cdio_free_device_list (char * device_list[]);
/*!
Get the default CD device.
if p_cdio is NULL (we haven't initialized a specific device driver),
then find a suitable one and return the default device for that.
@param p_cdio the CD object queried
@return a string containing the default CD device or NULL is
if we couldn't get a default device.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
char * cdio_get_default_device (const CdIo_t *p_cdio);
/*!
Return a string containing the default CD device if none is specified.
if p_driver_id is DRIVER_UNKNOWN or DRIVER_DEVICE
then find a suitable one set the default device for that.
NULL is returned if we couldn't get a default device.
*/
char * cdio_get_default_device_driver (/*in/out*/ driver_id_t *p_driver_id);
/*! 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.
NULL is returned if we couldn't return a list of devices.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
char ** cdio_get_devices (driver_id_t driver_id);
/*!
Get an array of device names in search_devices that have at least
the capabilities listed by the capabities parameter. If
search_devices is NULL, then we'll search all possible CD drives.
Capabilities have two parts to them, a "filesystem" part and an
"analysis" part.
The filesystem part is mutually exclusive. For example either the
filesystem is at most one of the High-Sierra, UFS, or HFS, ISO9660,
fileystems. Valid combinations of say HFS and ISO9660 are
specified as a separate "filesystem".
Capabilities on the other hand are not mutually exclusive. For example
a filesystem may have none, either, or both of the XA or Rock-Ridge
extension properties.
If "b_any" is set false then every capability listed in the
analysis portion of capabilities (i.e. not the basic filesystem)
must be satisified. If no analysis capabilities are specified,
that's a match.
If "b_any" is set true, then if any of the analysis capabilities
matches, we call that a success.
In either case, in the filesystem portion different filesystem
either specify 0 to match any filesystem or the specific
filesystem type.
To find a CD-drive of any type, use the mask CDIO_FS_MATCH_ALL.
@return the array of device names or NULL 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 (/*in*/ char *ppsz_search_devices[],
cdio_fs_anal_t capabilities, bool b_any);
/*!
Like cdio_get_devices_with_cap but we return the driver we found
as well. This is because often one wants to search for kind of drive
and then *open* it afterwards. Giving the driver back facilitates this,
and speeds things up for libcdio as well.
*/
char ** cdio_get_devices_with_cap_ret (/*in*/ char* ppsz_search_devices[],
cdio_fs_anal_t capabilities,
bool b_any,
/*out*/ driver_id_t *p_driver_id);
/*! Like cdio_get_devices, but we may change the p_driver_id if we
were given DRIVER_DEVICE or DRIVER_UNKNOWN. This is because
often one wants to get a drive name and then *open* it
afterwards. Giving the driver back facilitates this, and speeds
things up for libcdio as well.
*/
char ** cdio_get_devices_ret (/*in/out*/ driver_id_t *p_driver_id);
/*!
Get the what kind of device we've got.
@param p_cdio the CD object queried
@param p_read_cap pointer to return read capabilities
@param p_write_cap pointer to return write capabilities
@param p_misc_cap pointer to return miscellaneous other capabilities
In some situations of drivers or OS's we can't find a CD device if
there is no media in it. In this situation capabilities will show up as
NULL even though there isa hardware CD-ROM.
*/
void cdio_get_drive_cap (const CdIo_t *p_cdio,
cdio_drive_read_cap_t *p_read_cap,
cdio_drive_write_cap_t *p_write_cap,
cdio_drive_misc_cap_t *p_misc_cap);
/*!
Get the drive capabilities for a specified device.
Return a list of device capabilities.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it. In this situation capabilities will show up as
NULL even though there isa hardware CD-ROM.
*/
void cdio_get_drive_cap_dev (const char *device,
cdio_drive_read_cap_t *p_read_cap,
cdio_drive_write_cap_t *p_write_cap,
cdio_drive_misc_cap_t *p_misc_cap);
/*!
Get a string containing the name of the driver in use.
@return a string with driver name or NULL if CdIo_t is NULL (we
haven't initialized a specific device.
*/
const char * cdio_get_driver_name (const CdIo_t *p_cdio);
/*!
Get the driver id.
if CdIo_t is NULL (we haven't initialized a specific device driver),
then return DRIVER_UNKNOWN.
@return the driver id..
*/
driver_id_t cdio_get_driver_id (const CdIo_t *p_cdio);
/*!
Get the CD-ROM hardware info via a SCSI MMC INQUIRY command.
False is returned if we had an error getting the information.
*/
bool cdio_get_hwinfo ( const CdIo_t *p_cdio,
/*out*/ cdio_hwinfo_t *p_hw_info );
/*! Get the LSN of the first track of the last session of
on the CD.
@param p_cdio the CD object to be acted upon.
@param i_last_session pointer to the session number to be returned.
*/
driver_return_code_t cdio_get_last_session (CdIo_t *p_cdio,
/*out*/ lsn_t *i_last_session);
/*!
Find out if media has changed since the last call.
@param p_cdio the CD object to be acted upon.
@return 1 if media has changed since last call, 0 if not. Error
return codes are the same as driver_return_code_t
*/
int cdio_get_media_changed(CdIo_t *p_cdio);
/*! True if CD-ROM understand ATAPI commands. */
bool_3way_t cdio_have_atapi (CdIo_t *p_cdio);
/*! Like cdio_have_xxx but uses an enumeration instead. */
bool cdio_have_driver (driver_id_t driver_id);
/*
Free any resources associated with p_cdio. Call this when done using p_cdio
and using CD reading/control operations.
@param p_cdio the CD object to eliminated.
*/
void cdio_destroy (CdIo_t *p_cdio);
/*!
Get a string decribing driver_id.
@param driver_id the driver you want the description for
@return a string of driver description
*/
const char *cdio_driver_describe (driver_id_t driver_id);
/*! Sets up to read from place specified by psz_source and
driver_id. This or cdio_open_* should be called before using any
other routine, except cdio_init or any routine that accesses the
CD-ROM drive by name. cdio_open will call cdio_init, if that hasn't
been done previously.
@return the cdio object or NULL on error or no device. If NULL
is given as the source, we'll use the default driver device.
*/
CdIo_t * cdio_open (const char *psz_source, driver_id_t driver_id);
/*! Sets up to read from place specified by psz_source, driver_id
and access mode. This or cdio_open* should be called before using
any other routine, except cdio_init or any routine that accesses
the CD-ROM drive by name. This will call cdio_init, if that
hasn't been done previously.
If NULL is given as the source, we'll use the default driver device.
@return the cdio object or NULL on error or no device.
*/
CdIo_t * cdio_open_am (const char *psz_source,
driver_id_t driver_id, const char *psz_access_mode);
/*! Set up BIN/CUE CD disk-image for reading. Source is the .bin or
.cue file
@return the cdio object or NULL on error or no device.
*/
CdIo_t * cdio_open_bincue (const char *psz_cue_name);
/*! Set up BIN/CUE CD disk-image for reading. Source is the .bin or
.cue file
@return the cdio object or NULL on error or no device..
*/
CdIo_t * cdio_open_am_bincue (const char *psz_cue_name,
const char *psz_access_mode);
/*! Set up cdrdao CD disk-image for reading. Source is the .toc file
@return the cdio object or NULL on error or no device.
*/
CdIo_t * cdio_open_cdrdao (const char *psz_toc_name);
/*! Set up cdrdao CD disk-image for reading. Source is the .toc file
@return the cdio object or NULL on error or no device..
*/
CdIo_t * cdio_open_am_cdrdao (const char *psz_toc_name,
const char *psz_access_mode);
/*! Return a string containing the default CUE file that would
be used when none is specified.
@return the cdio object or NULL on error or no device.
*/
char * cdio_get_default_device_bincue(void);
char **cdio_get_devices_bincue(void);
/*! @return 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_cdrdao(void);
char **cdio_get_devices_cdrdao(void);
/*! Set up CD-ROM for reading. The device_name is
the some sort of device name.
@return the cdio object for subsequent operations.
NULL on error or there is no driver for a some sort of hardware CD-ROM.
*/
CdIo_t * cdio_open_cd (const char *device_name);
/*! Set up CD-ROM for reading. The device_name is
the some sort of device name.
@return the cdio object for subsequent operations.
NULL on error or there is no driver for a some sort of hardware CD-ROM.
*/
CdIo_t * cdio_open_am_cd (const char *psz_device,
const char *psz_access_mode);
/*! CDRWIN BIN/CUE CD disc-image routines. Source is the .cue file
@return the cdio object for subsequent operations.
NULL on error.
*/
CdIo_t * cdio_open_cue (const char *cue_name);
/*! Set up CD-ROM for reading using the AIX driver. The device_name is
the some sort of device name.
@return the cdio object for subsequent operations.
NULL on error or there is no AIX driver.
@see cdio_open
*/
CdIo_t * cdio_open_am_aix (const char *psz_source,
const char *psz_access_mode);
/*! Set up CD-ROM for reading using the AIX driver. The device_name is
the some sort of device name.
@return the cdio object for subsequent operations.
NULL on error or there is no AIX driver.
@see cdio_open
*/
CdIo_t * cdio_open_aix (const char *psz_source);
/*! Return a string containing the default device name that the
BSDI driver would use when none is specified.
@return the cdio object for subsequent operations.
NULL on error or there is no AIX driver.
@see cdio_open_cd, cdio_open
*/
char * cdio_get_default_device_aix(void);
/*! Return a list of all of the CD-ROM devices that the AIX driver
can find.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
char **cdio_get_devices_aix(void);
/*! Set up CD-ROM for reading using the BSDI driver. The device_name is
the some sort of device name.
@param psz_source the name of the device to open
@return the cdio object for subsequent operations.
NULL on error or there is no BSDI driver.
@see cdio_open
*/
CdIo_t * cdio_open_bsdi (const char *psz_source);
/*! Set up CD-ROM for reading using the BSDI driver. The device_name is
the some sort of device name.
@return the cdio object for subsequent operations.
NULL on error or there is no BSDI driver.
@see cdio_open
*/
CdIo_t * cdio_open_am_bsdi (const char *psz_source,
const char *psz_access_mode);
/*! Return a string containing the default device name that the
BSDI driver would use when none is specified.
@return the cdio object for subsequent operations.
NULL on error or there is no BSDI driver.
@see cdio_open_cd, 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.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
char **cdio_get_devices_bsdi(void);
/*! 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, cdio_open
*/
CdIo_t * cdio_open_freebsd (const char *paz_psz_source);
/*! 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, cdio_open
*/
CdIo_t * cdio_open_am_freebsd (const char *psz_source,
const char *psz_access_mode);
/*! 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);
/*! Set up CD-ROM for reading using the GNU/Linux driver. The device_name is
the some sort of device name.
@return the cdio object for subsequent operations.
NULL on error or there is no GNU/Linux driver.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
CdIo_t * cdio_open_linux (const char *psz_source);
/*! Set up CD-ROM for reading using the GNU/Linux driver. The
device_name is the some sort of device name.
@return the cdio object for subsequent operations.
NULL on error or there is no GNU/Linux driver.
*/
CdIo_t * cdio_open_am_linux (const char *psz_source,
const char *access_mode);
/*! 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.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
@see cdio_open_cd, 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);
/*! Set up CD-ROM for reading using the Sun Solaris driver. The
device_name is the some sort of device name.
@return the cdio object for subsequent operations.
NULL on error or there is no Solaris driver.
*/
CdIo_t * cdio_open_solaris (const char *psz_source);
/*! Set up CD-ROM for reading using the Sun Solaris driver. The
device_name is the some sort of device name.
@return the cdio object for subsequent operations.
NULL on error or there is no Solaris driver.
*/
CdIo_t * cdio_open_am_solaris (const char *psz_source,
const char *psz_access_mode);
/*! 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.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
@see cdio_open_cd, 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);
/*! 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.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
@see cdio_open_cd, cdio_open
*/
CdIo_t * cdio_open_osx (const char *psz_source);
/*! 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, cdio_open
*/
CdIo_t * cdio_open_am_osx (const char *psz_source,
const char *psz_access_mode);
/*! 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.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
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);
/*! Set up CD-ROM for reading using the Microsoft Windows driver. The
device_name is the some sort of device name.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
*/
CdIo_t * cdio_open_win32 (const char *psz_source);
/*! 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_t * cdio_open_am_win32 (const char *psz_source,
const char *psz_access_mode);
/*! 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.
In some situations of drivers or OS's we can't find a CD device if
there is no media in it and it is possible for this routine to return
NULL even though there may be a hardware CD-ROM.
@see cdio_open_cd, cdio_open
*/
char * cdio_get_default_device_win32(void);
char **cdio_get_devices_win32(void);
/*! Set up CD-ROM for reading using the Nero driver. The
device_name is the some sort of device name.
@return true on success; NULL on error or there is no Nero driver.
*/
CdIo_t * cdio_open_nrg (const char *psz_source);
/*! Set up CD-ROM for reading using the Nero driver. The
device_name is the some sort of device name.
@return true on success; NULL on error or there is no Nero driver.
*/
CdIo_t * cdio_open_am_nrg (const char *psz_source,
const char *psz_access_mode);
/*! Get 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.
@return string containing the default device. NULL on error or
there is no CD-ROM device.
*/
char * cdio_get_default_device_nrg(void);
char **cdio_get_devices_nrg(void);
/*!
Determine if bin_name is the bin file part of a CDRWIN CD disk image.
@param bin_name location of presumed CDRWIN bin image file.
@return the corresponding CUE file if bin_name is a BIN file or
NULL if not a BIN file.
*/
char *cdio_is_binfile(const char *bin_name);
/*!
Determine if cue_name is the cue sheet for a CDRWIN CD disk image.
@return corresponding BIN file if cue_name is a CDRWIN cue file or
NULL if not a CUE file.
*/
char *cdio_is_cuefile(const char *cue_name);
/*!
Determine if psg_nrg is a Nero CD disc image.
@param psz_nrg location of presumed NRG image file.
@return true if psz_nrg is a Nero NRG image or false
if not a NRG image.
*/
bool cdio_is_nrg(const char *psz_nrg);
/*!
Determine if psz_toc is a TOC file for a cdrdao CD disc image.
@param psz_toc location of presumed TOC image file.
@return true if toc_name is a cdrdao TOC file or false
if not a TOC file.
*/
bool cdio_is_tocfile(const char *psz_toc);
/*!
Determine if psz_source refers to a real hardware CD-ROM.
@param psz_source location name of object
@param driver_id driver for reading object. Use DRIVER_UNKNOWN if you
don't know what driver to use.
@return true if psz_source is a device; If false is returned we
could have a CD disk image.
*/
bool cdio_is_device(const char *psz_source, driver_id_t driver_id);
/*!
Set the blocksize for subsequent reads.
*/
driver_return_code_t cdio_set_blocksize ( const CdIo_t *p_cdio,
int i_blocksize );
/*!
Set the drive speed.
@param p_cdio CD structure set by cdio_open().
@param i_drive_speed speed in CD-ROM speed units. Note this
not Kbs as would be used in the MMC spec or
in mmc_set_speed(). To convert CD-ROM speed units
to Kbs, multiply the number by 176 (for raw data)
and by 150 (for filesystem data). On many CD-ROM
drives, specifying a value too large will result
in using the fastest speed.
@see mmc_set_speed and mmc_set_drive_speed
*/
driver_return_code_t cdio_set_speed ( const CdIo_t *p_cdio,
int i_drive_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
}
#endif /* __cplusplus */
/** The below variables are trickery to force the above enum symbol
values to be recorded in debug symbol tables. They are used to
allow one to refer to the enumeration value names in the typedefs
above in a debugger and debugger expressions.
*/
extern cdio_drive_cap_misc_t debug_cdio_drive_cap_misc;
extern cdio_drive_cap_read_t debug_cdio_drive_cap_read_t;
extern cdio_drive_cap_write_t debug_drive_cap_write_t;
extern cdio_mmc_hw_len_t debug_cdio_mmc_hw_len;
extern cdio_src_category_mask_t debug_cdio_src_category_mask;
#endif /* __CDIO_DEVICE_H__ */

108
include/cdio/disc.h Normal file
View File

@@ -0,0 +1,108 @@
/* -*- c -*-
$Id: disc.h,v 1.9 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file disc.h
* \brief The top-level header for disc-related libcdio calls.
*/
#ifndef __CDIO_DISC_H__
#define __CDIO_DISC_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! disc modes. The first combined from MMC-3 5.29.2.8 (Send CUESHEET)
and GNU/Linux /usr/include/linux/cdrom.h and we've added DVD.
*/
typedef enum {
CDIO_DISC_MODE_CD_DA, /**< CD-DA */
CDIO_DISC_MODE_CD_DATA, /**< CD-ROM form 1 */
CDIO_DISC_MODE_CD_XA, /**< CD-ROM XA form2 */
CDIO_DISC_MODE_CD_MIXED, /**< Some combo of above. */
CDIO_DISC_MODE_DVD_ROM, /**< DVD ROM (e.g. movies) */
CDIO_DISC_MODE_DVD_RAM, /**< DVD-RAM */
CDIO_DISC_MODE_DVD_R, /**< DVD-R */
CDIO_DISC_MODE_DVD_RW, /**< DVD-RW */
CDIO_DISC_MODE_DVD_PR, /**< DVD+R */
CDIO_DISC_MODE_DVD_PRW, /**< DVD+RW */
CDIO_DISC_MODE_DVD_OTHER, /**< Unknown/unclassified DVD type */
CDIO_DISC_MODE_NO_INFO,
CDIO_DISC_MODE_ERROR,
CDIO_DISC_MODE_CD_I /**< CD-i. */
} discmode_t;
extern const char *discmode2str[];
/*!
Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc.
that we've got. The notion of "CD" is extended a little to include
DVD's.
*/
discmode_t cdio_get_discmode (CdIo_t *p_cdio);
/*!
Get the lsn of the end of the CD
@return the lsn. On error 0 or CDIO_INVALD_LSN.
*/
lsn_t cdio_get_disc_last_lsn(const CdIo_t *p_cdio);
/*!
Return the Joliet level recognized for p_cdio.
*/
uint8_t cdio_get_joliet_level(const CdIo_t *p_cdio);
/*!
Get the media catalog number (MCN) from the CD.
@return the media catalog number or NULL if there is none or we
don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
*/
char * cdio_get_mcn (const CdIo_t *p_cdio);
/*!
Get the number of tracks on the CD.
@return the number of tracks, or CDIO_INVALID_TRACK if there is
an error.
*/
track_t cdio_get_num_tracks (const CdIo_t *p_cdio);
/*!
Return true if discmode is some sort of CD.
*/
bool cdio_is_discmode_cdrom (discmode_t discmode);
/*!
Return true if discmode is some sort of DVD.
*/
bool cdio_is_discmode_dvd (discmode_t discmode);
/*! cdio_stat_size is deprecated. @see cdio_get_disc_last_lsn */
#define cdio_stat_size cdio_get_disc_last_lsn
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __CDIO_DISC_H__ */

98
include/cdio/ds.h Normal file
View File

@@ -0,0 +1,98 @@
/*
$Id: ds.h,v 1.5 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file ds.h
* \brief The top-level header for list-related data structures.
Note: this header will is slated to get removed and libcdio will use
glib.h routines instead.
*/
#ifndef __CDIO_DS_H__
#define __CDIO_DS_H__
#include <cdio/types.h>
/** opaque types... */
typedef struct _CdioList CdioList_t;
typedef struct _CdioListNode CdioListNode_t;
typedef int (*_cdio_list_cmp_func_t) (void *p_data1, void *p_data2);
typedef int (*_cdio_list_iterfunc_t) (void *p_data, void *p_user_data);
/** The below are given compatibility with old code. Please use
the above type names, not these. */
#define CdioList CdioList_t
#define CdioListNode CdioListNode_t
#define _cdio_list_cmp_func _cdio_list_cmp_func_t
#define _cdio_list_iterfunc _cdio_list_iterfunc_t
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** methods */
CdioList_t *_cdio_list_new (void);
void _cdio_list_free (CdioList_t *p_list, int free_data);
unsigned _cdio_list_length (const CdioList_t *list);
void _cdio_list_prepend (CdioList_t *p_list, void *p_data);
void _cdio_list_append (CdioList_t *p_list, void *p_data);
void _cdio_list_foreach (CdioList_t *p_list, _cdio_list_iterfunc_t func,
void *p_user_data);
CdioListNode_t *_cdio_list_find (CdioList_t *p_list,
_cdio_list_iterfunc_t cmp_func,
void *p_user_data);
#define _CDIO_LIST_FOREACH(node, list) \
for (node = _cdio_list_begin (list); node; node = _cdio_list_node_next (node))
/** node operations */
CdioListNode_t *_cdio_list_begin (const CdioList_t *p_list);
CdioListNode_t *_cdio_list_end (CdioList_t *p_list);
CdioListNode_t *_cdio_list_node_next (CdioListNode_t *p_node);
void _cdio_list_node_free (CdioListNode_t *p_node, int i_free_data);
void *_cdio_list_node_data (CdioListNode_t *p_node);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __CDIO_DS_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

112
include/cdio/dvd.h Normal file
View File

@@ -0,0 +1,112 @@
/*
$Id: dvd.h,v 1.5 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2004 Rocky Bernstein <rocky@gnu.org>
Modeled after GNU/Linux definitions in linux/cdrom.h
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/*!
\file dvd.h
\brief Definitions for DVD access.
*/
#ifndef __CDIO_DVD_H__
#define __CDIO_DVD_H__
#include <cdio/types.h>
/*! Values used in a READ DVD STRUCTURE */
#define CDIO_DVD_STRUCT_PHYSICAL 0x00
#define CDIO_DVD_STRUCT_COPYRIGHT 0x01
#define CDIO_DVD_STRUCT_DISCKEY 0x02
#define CDIO_DVD_STRUCT_BCA 0x03
#define CDIO_DVD_STRUCT_MANUFACT 0x04
/*! Media definitions for "Book Type" */
#define CDIO_DVD_BOOK_DVD_ROM 0
#define CDIO_DVD_BOOK_DVD_RAM 1
#define CDIO_DVD_BOOK_DVD_R 2 /**< DVD-R */
#define CDIO_DVD_BOOK_DVD_RW 3 /**< DVD-RW */
#define CDIO_DVD_BOOK_DVD_PR 8 /**< DVD+R */
#define CDIO_DVD_BOOK_DVD_PRW 9 /**< DVD+RW */
typedef struct cdio_dvd_layer {
uint8_t book_version : 4;
uint8_t book_type : 4;
uint8_t min_rate : 4;
uint8_t disc_size : 4;
uint8_t layer_type : 4;
uint8_t track_path : 1;
uint8_t nlayers : 2;
uint8_t track_density : 4;
uint8_t linear_density: 4;
uint8_t bca : 1;
uint32_t start_sector;
uint32_t end_sector;
uint32_t end_sector_l0;
} cdio_dvd_layer_t;
/*! Maximum number of layers in a DVD. */
#define CDIO_DVD_MAX_LAYERS 4
typedef struct cdio_dvd_physical {
uint8_t type;
uint8_t layer_num;
cdio_dvd_layer_t layer[CDIO_DVD_MAX_LAYERS];
} cdio_dvd_physical_t;
typedef struct cdio_dvd_copyright {
uint8_t type;
uint8_t layer_num;
uint8_t cpst;
uint8_t rmi;
} cdio_dvd_copyright_t;
typedef struct cdio_dvd_disckey {
uint8_t type;
unsigned agid : 2;
uint8_t value[2048];
} cdio_dvd_disckey_t;
typedef struct cdio_dvd_bca {
uint8_t type;
int len;
uint8_t value[188];
} cdio_dvd_bca_t;
typedef struct cdio_dvd_manufact {
uint8_t type;
uint8_t layer_num;
int len;
uint8_t value[2048];
} cdio_dvd_manufact_t;
typedef union {
uint8_t type;
cdio_dvd_physical_t physical;
cdio_dvd_copyright_t copyright;
cdio_dvd_disckey_t disckey;
cdio_dvd_bca_t bca;
cdio_dvd_manufact_t manufact;
} cdio_dvd_struct_t;
#endif /* __SCSI_MMC_H__ */

1006
include/cdio/ecma_167.h Normal file

File diff suppressed because it is too large Load Diff

1114
include/cdio/iso9660.h Normal file

File diff suppressed because it is too large Load Diff

136
include/cdio/logging.h Normal file
View File

@@ -0,0 +1,136 @@
/*
$Id: logging.h,v 1.11 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2003, 2004, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file logging.h
* \brief Header to control logging and level of detail of output.
*
*/
#ifndef __LOGGING_H__
#define __LOGGING_H__
#include <cdio/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* The different log levels supported.
*/
typedef enum {
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;
/**
* 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;
/**
* 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[]);
/**
* 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
* @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);
/**
* Handle an informative message.
*
* @see cdio_log for a more generic routine
*/
void cdio_info (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);
/**
* Handle an error message. Execution is terminated.
*
* @see cdio_log for a more generic routine.
*/
void cdio_error (const char format[], ...) GNUC_PRINTF(1,2);
#ifdef __cplusplus
}
#endif
#endif /* __LOGGING_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

907
include/cdio/mmc.h Normal file
View File

@@ -0,0 +1,907 @@
/*
$Id: mmc.h,v 1.32 2008/05/09 06:13:32 edsdead Exp $
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/**
* \file mmc.h
*
* \brief Common definitions for MMC (Multimedia Commands). Applications
* include this for direct MMC access.
*/
#ifndef __CDIO_MMC_H__
#define __CDIO_MMC_H__
#include <cdio/cdio.h>
#include <cdio/types.h>
#include <cdio/dvd.h>
#include <cdio/audio.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** Set this to the maximum value in milliseconds that we will
wait on an MMC command. */
extern uint32_t mmc_timeout_ms;
/** The default timeout (non-read) is 6 seconds. */
#define MMC_TIMEOUT_DEFAULT 6000
/** Set this to the maximum value in milliseconds that we will
wait on an MMC read command. */
extern uint32_t mmc_read_timeout_ms;
/** The default read timeout is 3 minutes. */
#define MMC_READ_TIMEOUT_DEFAULT 3*60*1000
/** \brief The opcode-portion (generic packet commands) of an MMC command.
In general, those opcodes that end in 6 take a 6-byte command
descriptor, those that end in 10 take a 10-byte
descriptor and those that in in 12 take a 12-byte descriptor.
(Not that you need to know that, but it seems to be a
big deal in the MMC specification.)
*/
typedef enum {
CDIO_MMC_GPCMD_INQUIRY = 0x12, /**< Request drive
information. */
CDIO_MMC_GPCMD_MODE_SELECT_6 = 0x15, /**< Select medium
(6 bytes). */
CDIO_MMC_GPCMD_MODE_SENSE_6 = 0x1a, /**< Get medium or device
information. Should be issued
before MODE SELECT to get
mode support or save current
settings. (6 bytes). */
CDIO_MMC_GPCMD_START_STOP = 0x1b, /**< Enable/disable Disc
operations. (6 bytes). */
CDIO_MMC_GPCMD_ALLOW_MEDIUM_REMOVAL = 0x1e, /**< Enable/disable Disc
removal. (6 bytes). */
/** Group 2 Commands (CDB's here are 10-bytes)
*/
CDIO_MMC_GPCMD_READ_10 = 0x28, /**< Read data from drive
(10 bytes). */
CDIO_MMC_GPCMD_READ_SUBCHANNEL = 0x42, /**< Read Sub-Channel data.
(10 bytes). */
CDIO_MMC_GPCMD_READ_TOC = 0x43, /**< READ TOC/PMA/ATIP.
(10 bytes). */
CDIO_MMC_GPCMD_READ_HEADER = 0x44,
CDIO_MMC_GPCMD_PLAY_AUDIO_10 = 0x45, /**< Begin audio playing at
current position
(10 bytes). */
CDIO_MMC_GPCMD_GET_CONFIGURATION = 0x46, /**< Get drive Capabilities
(10 bytes) */
CDIO_MMC_GPCMD_PLAY_AUDIO_MSF = 0x47, /**< Begin audio playing at
specified MSF (10
bytes). */
CDIO_MMC_GPCMD_PLAY_AUDIO_TI = 0x48,
CDIO_MMC_GPCMD_PLAY_TRACK_REL_10 = 0x49, /**< Play audio at the track
relative LBA. (10 bytes).
Doesn't seem to be part
of MMC standards but is
handled by Plextor drives.
*/
CDIO_MMC_GPCMD_GET_EVENT_STATUS = 0x4a, /**< Report events and
Status. */
CDIO_MMC_GPCMD_PAUSE_RESUME = 0x4b, /**< Stop or restart audio
playback. (10 bytes).
Used with a PLAY command. */
CDIO_MMC_GPCMD_READ_DISC_INFO = 0x51, /**< Get CD information.
(10 bytes). */
CDIO_MMC_GPCMD_MODE_SELECT_10 = 0x55, /**< Select medium
(10-bytes). */
CDIO_MMC_GPCMD_MODE_SENSE_10 = 0x5a, /**< Get medium or device
information. Should be issued
before MODE SELECT to get
mode support or save current
settings. (6 bytes). */
/** Group 5 Commands (CDB's here are 12-bytes)
*/
CDIO_MMC_GPCMD_PLAY_AUDIO_12 = 0xa5, /**< Begin audio playing at
current position
(12 bytes) */
CDIO_MMC_GPCMD_LOAD_UNLOAD = 0xa6, /**< Load/unload a Disc
(12 bytes) */
CDIO_MMC_GPCMD_READ_12 = 0xa8, /**< Read data from drive
(12 bytes). */
CDIO_MMC_GPCMD_PLAY_TRACK_REL_12 = 0xa9, /**< Play audio at the track
relative LBA. (12 bytes).
Doesn't seem to be part
of MMC standards but is
handled by Plextor drives.
*/
CDIO_MMC_GPCMD_READ_DVD_STRUCTURE = 0xad, /**< Get DVD structure info
from media (12 bytes). */
CDIO_MMC_GPCMD_READ_MSF = 0xb9, /**< Read almost any field
of a CD sector at specified
MSF. (12 bytes). */
CDIO_MMC_GPCMD_SET_SPEED = 0xbb, /**< Set drive speed
(12 bytes). This is listed
as optional in ATAPI 2.6,
but is (curiously)
missing from Mt. Fuji,
Table 57. It is mentioned
in Mt. Fuji Table 377 as an
MMC command for SCSI
devices though... Most
ATAPI drives support it. */
CDIO_MMC_GPCMD_READ_CD = 0xbe, /**< Read almost any field
of a CD sector at current
location. (12 bytes). */
/** Vendor-unique Commands
*/
CDIO_MMC_GPCMD_CD_PLAYBACK_STATUS = 0xc4 /**< SONY unique = command */,
CDIO_MMC_GPCMD_PLAYBACK_CONTROL = 0xc9 /**< SONY unique = command */,
CDIO_MMC_GPCMD_READ_CDDA = 0xd8 /**< Vendor unique = command */,
CDIO_MMC_GPCMD_READ_CDXA = 0xdb /**< Vendor unique = command */,
CDIO_MMC_GPCMD_READ_ALL_SUBCODES = 0xdf /**< Vendor unique = command */
} cdio_mmc_gpcmd_t;
/** Read Subchannel states */
typedef enum {
CDIO_MMC_READ_SUB_ST_INVALID = 0x00, /**< audio status not supported */
CDIO_MMC_READ_SUB_ST_PLAY = 0x11, /**< audio play operation in
progress */
CDIO_MMC_READ_SUB_ST_PAUSED = 0x12, /**< audio play operation paused */
CDIO_MMC_READ_SUB_ST_COMPLETED = 0x13, /**< audio play successfully
completed */
CDIO_MMC_READ_SUB_ST_ERROR = 0x14, /**< audio play stopped due to
error */
CDIO_MMC_READ_SUB_ST_NO_STATUS = 0x15, /**< no current audio status to
return */
} cdio_mmc_read_sub_state_t;
/** Level values that can go into READ_CD */
typedef enum {
CDIO_MMC_READ_TYPE_ANY = 0, /**< All types */
CDIO_MMC_READ_TYPE_CDDA = 1, /**< Only CD-DA sectors */
CDIO_MMC_READ_TYPE_MODE1 = 2, /**< mode1 sectors (user data = 2048) */
CDIO_MMC_READ_TYPE_MODE2 = 3, /**< mode2 sectors form1 or form2 */
CDIO_MMC_READ_TYPE_M2F1 = 4, /**< mode2 sectors form1 */
CDIO_MMC_READ_TYPE_M2F2 = 5 /**< mode2 sectors form2 */
} cdio_mmc_read_cd_type_t;
/** Format values for READ_TOC */
typedef enum {
CDIO_MMC_READTOC_FMT_TOC = 0,
CDIO_MMC_READTOC_FMT_SESSION = 1,
CDIO_MMC_READTOC_FMT_FULTOC = 2,
CDIO_MMC_READTOC_FMT_PMA = 3, /**< Q subcode data */
CDIO_MMC_READTOC_FMT_ATIP = 4, /**< includes media type */
CDIO_MMC_READTOC_FMT_CDTEXT = 5 /**< CD-TEXT info */
} cdio_mmc_readtoc_t;
/** Page codes for MODE SENSE and MODE SET. */
typedef enum {
CDIO_MMC_R_W_ERROR_PAGE = 0x01,
CDIO_MMC_WRITE_PARMS_PAGE = 0x05,
CDIO_MMC_CDR_PARMS_PAGE = 0x0d,
CDIO_MMC_AUDIO_CTL_PAGE = 0x0e,
CDIO_MMC_POWER_PAGE = 0x1a,
CDIO_MMC_FAULT_FAIL_PAGE = 0x1c,
CDIO_MMC_TO_PROTECT_PAGE = 0x1d,
CDIO_MMC_CAPABILITIES_PAGE = 0x2a,
CDIO_MMC_ALL_PAGES = 0x3f,
} cdio_mmc_mode_page_t;
PRAGMA_BEGIN_PACKED
struct mmc_audio_volume_entry_s
{
uint8_t selection; /* Only the lower 4 bits are used. */
uint8_t volume;
} GNUC_PACKED;
typedef struct mmc_audio_volume_entry_s mmc_audio_volume_entry_t;
/** This struct is used by cdio_audio_get_volume and cdio_audio_set_volume */
struct mmc_audio_volume_s
{
mmc_audio_volume_entry_t port[4];
} GNUC_PACKED;
typedef struct mmc_audio_volume_s mmc_audio_volume_t;
PRAGMA_END_PACKED
/** Return type codes for GET_CONFIGURATION. */
typedef enum {
CDIO_MMC_GET_CONF_ALL_FEATURES = 0, /**< all features without regard
to currency. */
CDIO_MMC_GET_CONF_CURRENT_FEATURES = 1, /**< features which are currently
in effect (e.g. based on
medium inserted). */
CDIO_MMC_GET_CONF_NAMED_FEATURE = 2 /**< just the feature named in
the GET_CONFIGURATION cdb. */
} cdio_mmc_get_conf_t;
/** FEATURE codes used in GET CONFIGURATION. */
typedef enum {
CDIO_MMC_FEATURE_PROFILE_LIST = 0x000, /**< Profile List Feature */
CDIO_MMC_FEATURE_CORE = 0x001,
CDIO_MMC_FEATURE_MORPHING = 0x002, /**< Report/prevent operational
changes */
CDIO_MMC_FEATURE_REMOVABLE_MEDIUM = 0x003, /**< Removable Medium Feature */
CDIO_MMC_FEATURE_WRITE_PROTECT = 0x004, /**< Write Protect Feature */
CDIO_MMC_FEATURE_RANDOM_READABLE = 0x010, /**< Random Readable Feature */
CDIO_MMC_FEATURE_MULTI_READ = 0x01D, /**< Multi-Read Feature */
CDIO_MMC_FEATURE_CD_READ = 0x01E, /**< CD Read Feature */
CDIO_MMC_FEATURE_DVD_READ = 0x01F, /**< DVD Read Feature */
CDIO_MMC_FEATURE_RANDOM_WRITABLE = 0x020, /**< Random Writable Feature */
CDIO_MMC_FEATURE_INCR_WRITE = 0x021, /**< Incremental Streaming
Writable Feature */
CDIO_MMC_FEATURE_SECTOR_ERASE = 0x022, /**< Sector Erasable Feature */
CDIO_MMC_FEATURE_FORMATABLE = 0x023, /**< Formattable Feature */
CDIO_MMC_FEATURE_DEFECT_MGMT = 0x024, /**< Management Ability of the
Logical Unit/media system to
provide an apparently
defect-free space.*/
CDIO_MMC_FEATURE_WRITE_ONCE = 0x025, /**< Write Once
Feature */
CDIO_MMC_FEATURE_RESTRICT_OVERW = 0x026, /**< Restricted Overwrite
Feature */
CDIO_MMC_FEATURE_CD_RW_CAV = 0x027, /**< CD-RW CAV Write Feature */
CDIO_MMC_FEATURE_MRW = 0x028, /**< MRW Feature */
CDIO_MMC_FEATURE_ENHANCED_DEFECT = 0x029, /**< Enhanced Defect Reporting */
CDIO_MMC_FEATURE_DVD_PRW = 0x02A, /**< DVD+RW Feature */
CDIO_MMC_FEATURE_DVD_PR = 0x02B, /**< DVD+R Feature */
CDIO_MMC_FEATURE_RIGID_RES_OVERW = 0x02C, /**< Rigid Restricted Overwrite */
CDIO_MMC_FEATURE_CD_TAO = 0x02D, /**< CD Track at Once */
CDIO_MMC_FEATURE_CD_SAO = 0x02E, /**< CD Mastering (Session at
Once) */
CDIO_MMC_FEATURE_DVD_R_RW_WRITE = 0x02F, /**< DVD-R/RW Write */
CDIO_MMC_FEATURE_CD_RW_MEDIA_WRITE= 0x037, /**< CD-RW Media Write Support */
CDIO_MMC_FEATURE_DVD_PR_2_LAYER = 0x03B, /**< DVD+R Double Layer */
CDIO_MMC_FEATURE_POWER_MGMT = 0x100, /**< Initiator and device directed
power management */
CDIO_MMC_FEATURE_CDDA_EXT_PLAY = 0x103, /**< Ability to play audio CDs
via the Logical Unit's own
analog output */
CDIO_MMC_FEATURE_MCODE_UPGRADE = 0x104, /* Ability for the device to
accept new microcode via
the interface */
CDIO_MMC_FEATURE_TIME_OUT = 0x105, /**< Ability to respond to all
commands within a specific
time */
CDIO_MMC_FEATURE_DVD_CSS = 0x106, /**< Ability to perform DVD
CSS/CPPM authentication and
RPC */
CDIO_MMC_FEATURE_RT_STREAMING = 0x107, /**< Ability to read and write
using Initiator requested
performance parameters */
CDIO_MMC_FEATURE_LU_SN = 0x108, /**< The Logical Unit has a unique
identifier. */
CDIO_MMC_FEATURE_FIRMWARE_DATE = 0x1FF, /**< Firmware creation date
report */
} cdio_mmc_feature_t;
/** Profile profile codes used in GET_CONFIGURATION - PROFILE LIST. */
typedef enum {
CDIO_MMC_FEATURE_PROF_NON_REMOVABLE = 0x0001, /**< Re-writable disk, capable
of changing behavior */
CDIO_MMC_FEATURE_PROF_REMOVABLE = 0x0002, /**< disk Re-writable; with
removable media */
CDIO_MMC_FEATURE_PROF_MO_ERASABLE = 0x0003, /**< Erasable Magneto-Optical
disk with sector erase
capability */
CDIO_MMC_FEATURE_PROF_MO_WRITE_ONCE = 0x0004, /**< Write Once Magneto-Optical
write once */
CDIO_MMC_FEATURE_PROF_AS_MO = 0x0005, /**< Advance Storage
Magneto-Optical */
CDIO_MMC_FEATURE_PROF_CD_ROM = 0x0008, /**< Read only Compact Disc
capable */
CDIO_MMC_FEATURE_PROF_CD_R = 0x0009, /**< Write once Compact Disc
capable */
CDIO_MMC_FEATURE_PROF_CD_RW = 0x000A, /**< CD-RW Re-writable
Compact Disc capable */
CDIO_MMC_FEATURE_PROF_DVD_ROM = 0x0010, /**< Read only DVD */
CDIO_MMC_FEATURE_PROF_DVD_R_SEQ = 0x0011, /**< Re-recordable DVD using
Sequential recording */
CDIO_MMC_FEATURE_PROF_DVD_RAM = 0x0012, /**< Re-writable DVD */
CDIO_MMC_FEATURE_PROF_DVD_RW_RO = 0x0013, /**< Re-recordable DVD using
Restricted Overwrite */
CDIO_MMC_FEATURE_PROF_DVD_RW_SEQ = 0x0014, /**< Re-recordable DVD using
Sequential recording */
CDIO_MMC_FEATURE_PROF_DVD_PRW = 0x001A, /**< DVD+RW - DVD ReWritable */
CDIO_MMC_FEATURE_PROF_DVD_PR = 0x001B, /**< DVD+R - DVD Recordable */
CDIO_MMC_FEATURE_PROF_DDCD_ROM = 0x0020, /**< Read only DDCD */
CDIO_MMC_FEATURE_PROF_DDCD_R = 0x0021, /**< DDCD-R Write only DDCD */
CDIO_MMC_FEATURE_PROF_DDCD_RW = 0x0022, /**< Re-Write only DDCD */
CDIO_MMC_FEATURE_PROF_DVD_PR2 = 0x002B, /**< DVD+R - DVD Recordable
double layer */
CDIO_MMC_FEATURE_PROF_NON_CONFORM = 0xFFFF, /**< The Logical Unit does not
conform to any Profile. */
} cdio_mmc_feature_profile_t;
typedef enum {
CDIO_MMC_FEATURE_INTERFACE_UNSPECIFIED = 0,
CDIO_MMC_FEATURE_INTERFACE_SCSI = 1,
CDIO_MMC_FEATURE_INTERFACE_ATAPI = 2,
CDIO_MMC_FEATURE_INTERFACE_IEEE_1394 = 3,
CDIO_MMC_FEATURE_INTERFACE_IEEE_1394A = 4,
CDIO_MMC_FEATURE_INTERFACE_FIBRE_CH = 5
} cdio_mmc_feature_interface_t;
/** The largest Command Descriptor Block (CDB) size.
The possible sizes are 6, 10, and 12 bytes.
*/
#define MAX_CDB_LEN 12
/** \brief A Command Descriptor Block (CDB) used in sending MMC
commands.
*/
typedef struct mmc_cdb_s {
uint8_t field[MAX_CDB_LEN];
} mmc_cdb_t;
/** \brief Format of header block in data returned from an MMC
GET_CONFIGURATION command.
*/
typedef struct mmc_feature_list_header_s {
unsigned char length_msb;
unsigned char length_1sb;
unsigned char length_2sb;
unsigned char length_lsb;
unsigned char reserved1;
unsigned char reserved2;
unsigned char profile_msb;
unsigned char profile_lsb;
} cdio_mmc_feature_list_header_t;
/** An enumeration indicating whether an MMC command is sending
data or getting data.
*/
typedef enum mmc_direction_s {
SCSI_MMC_DATA_READ,
SCSI_MMC_DATA_WRITE
} cdio_mmc_direction_t;
typedef struct mmc_subchannel_s
{
uint8_t reserved;
uint8_t audio_status;
uint16_t data_length; /**< Really ISO 9660 7.2.2 */
uint8_t format;
uint8_t address: 4;
uint8_t control: 4;
uint8_t track;
uint8_t index;
uint8_t abs_addr[4];
uint8_t rel_addr[4];
} cdio_mmc_subchannel_t;
#define CDIO_MMC_SET_COMMAND(cdb, command) \
cdb[0] = command
#define CDIO_MMC_SET_READ_TYPE(cdb, sector_type) \
cdb[1] = (sector_type << 2)
#define CDIO_MMC_GETPOS_LEN16(p, pos) \
(p[pos]<<8) + p[pos+1]
#define CDIO_MMC_GET_LEN16(p) \
(p[0]<<8) + p[1]
#define CDIO_MMC_GET_LEN32(p) \
(p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3];
#define CDIO_MMC_SET_LEN16(cdb, pos, len) \
cdb[pos ] = (len >> 8) & 0xff; \
cdb[pos+1] = (len ) & 0xff
#define CDIO_MMC_SET_READ_LBA(cdb, lba) \
cdb[2] = (lba >> 24) & 0xff; \
cdb[3] = (lba >> 16) & 0xff; \
cdb[4] = (lba >> 8) & 0xff; \
cdb[5] = (lba ) & 0xff
#define CDIO_MMC_SET_START_TRACK(cdb, command) \
cdb[6] = command
#define CDIO_MMC_SET_READ_LENGTH24(cdb, len) \
cdb[6] = (len >> 16) & 0xff; \
cdb[7] = (len >> 8) & 0xff; \
cdb[8] = (len ) & 0xff
#define CDIO_MMC_SET_READ_LENGTH16(cdb, len) \
CDIO_MMC_SET_LEN16(cdb, 7, len)
#define CDIO_MMC_SET_READ_LENGTH8(cdb, len) \
cdb[8] = (len ) & 0xff
#define CDIO_MMC_MCSB_ALL_HEADERS 0xf
#define CDIO_MMC_SET_MAIN_CHANNEL_SELECTION_BITS(cdb, val) \
cdb[9] = val << 3;
/**
Read Audio Subchannel information
@param p_cdio the CD object to be acted upon.
@param p_subchannel place for returned subchannel information
*/
driver_return_code_t
mmc_audio_read_subchannel (CdIo_t *p_cdio,
/*out*/ cdio_subchannel_t *p_subchannel);
/**
Return a string containing the name of the audio state as returned from
the Q_SUBCHANNEL.
*/
const char *mmc_audio_state2str( uint8_t i_audio_state );
/**
Eject using MMC commands. If CD-ROM is "locked" we'll unlock it.
Command is not "immediate" -- we'll wait for the command to complete.
For a more general (and lower-level) routine, @see mmc_start_stop_media.
*/
driver_return_code_t mmc_eject_media( const CdIo_t *p_cdio );
/**
Return a string containing the name of the given feature
*/
const char *mmc_feature2str( int i_feature );
/**
Return a string containing the name of the given feature
*/
const char *mmc_feature_profile2str( int i_feature_profile );
/**
Return the length in bytes of the Command Descriptor
Buffer (CDB) for a given MMC command. The length will be
either 6, 10, or 12.
*/
uint8_t mmc_get_cmd_len(uint8_t mmc_cmd);
/**
Get the block size used in read requests, via MMC.
@return the blocksize if > 0; error if <= 0
*/
int mmc_get_blocksize ( CdIo_t *p_cdio );
/**
* Close tray using a MMC START STOP command.
*/
driver_return_code_t mmc_close_tray( CdIo_t *p_cdio );
/**
Get the lsn of the end of the CD
@return the lsn. On error return CDIO_INVALID_LSN.
*/
lsn_t mmc_get_disc_last_lsn( const CdIo_t *p_cdio );
/**
Return the discmode as reported by the MMC Read (FULL) TOC
command.
Information was obtained from Section 5.1.13 (Read TOC/PMA/ATIP)
pages 56-62 from the MMC draft specification, revision 10a
at http://www.t10.org/ftp/t10/drafts/mmc/mmc-r10a.pdf See
especially tables 72, 73 and 75.
*/
discmode_t mmc_get_discmode( const CdIo_t *p_cdio );
/**
Get drive capabilities for a device.
@return the drive capabilities.
*/
void mmc_get_drive_cap ( CdIo_t *p_cdio,
/*out*/ cdio_drive_read_cap_t *p_read_cap,
/*out*/ cdio_drive_write_cap_t *p_write_cap,
/*out*/ cdio_drive_misc_cap_t *p_misc_cap);
typedef enum {
CDIO_MMC_LEVEL_WEIRD,
CDIO_MMC_LEVEL_1,
CDIO_MMC_LEVEL_2,
CDIO_MMC_LEVEL_3,
CDIO_MMC_LEVEL_NONE
} cdio_mmc_level_t;
/**
Get the MMC level supported by the device.
*/
cdio_mmc_level_t mmc_get_drive_mmc_cap(CdIo_t *p_cdio);
/**
Get the DVD type associated with cd object.
@return the DVD discmode.
*/
discmode_t mmc_get_dvd_struct_physical ( const CdIo_t *p_cdio,
cdio_dvd_struct_t *s);
/*!
Return results of media status
@param p_cdio the CD object to be acted upon.
@param out_buf media status code from operation
@return DRIVER_OP_SUCCESS (0) if we got the status.
return codes are the same as driver_return_code_t
*/
int mmc_get_event_status(const CdIo_t *p_cdio, uint8_t out_buf[2]);
/*!
Find out if media tray is open or closed.
@param p_cdio the CD object to be acted upon.
@return 1 if media is open, 0 if closed. Error
return codes are the same as driver_return_code_t
*/
int mmc_get_tray_status ( const CdIo_t *p_cdio );
/**
Get the CD-ROM hardware info via an MMC INQUIRY command.
@return true if we were able to get hardware info, false if we had
an error.
*/
bool mmc_get_hwinfo ( const CdIo_t *p_cdio,
/* out*/ cdio_hwinfo_t *p_hw_info );
/**
Find out if media has changed since the last call.
@param p_cdio the CD object to be acted upon.
@return 1 if media has changed since last call, 0 if not. Error
return codes are the same as driver_return_code_t
*/
int mmc_get_media_changed(const CdIo_t *p_cdio);
/**
Get the media catalog number (MCN) from the CD via MMC.
@return the media catalog number r NULL if there is none or we
don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
*/
char * mmc_get_mcn ( const CdIo_t *p_cdio );
/** Get the output port volumes and port selections used on AUDIO PLAY
commands via a MMC MODE SENSE command using the CD Audio Control
Page.
*/
driver_return_code_t mmc_audio_get_volume (CdIo_t *p_cdio, /*out*/
mmc_audio_volume_t *p_volume);
/**
Report if CD-ROM has a praticular kind of interface (ATAPI, SCSCI, ...)
Is it possible for an interface to have serveral? If not this
routine could probably return the single mmc_feature_interface_t.
@return true if we have the interface and false if not.
*/
bool_3way_t mmc_have_interface( CdIo_t *p_cdio,
cdio_mmc_feature_interface_t e_interface );
/** Run a MODE_SENSE command (6- or 10-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmc_mode_sense( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
int page);
/** Run a MODE_SENSE command (10-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmc_mode_sense_10( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
int page);
/** Run a MODE_SENSE command (6-byte version)
and put the results in p_buf
@return DRIVER_OP_SUCCESS if we ran the command ok.
*/
int mmc_mode_sense_6( CdIo_t *p_cdio, /*out*/ void *p_buf, int i_size,
int page);
/** Issue a MMC READ_CD command.
@param p_cdio object to read from
@param p_buf Place to store data. The caller should ensure that
p_buf can hold at least i_blocksize * i_blocks bytes.
@param i_lsn sector to read
@param expected_sector_type restricts reading to a specific CD
sector type. Only 3 bits with values 1-5 are used:
0 all sector types
1 CD-DA sectors only
2 Mode 1 sectors only
3 Mode 2 formless sectors only. Note in contrast to all other
values an MMC CD-ROM is not required to support this mode.
4 Mode 2 Form 1 sectors only
5 Mode 2 Form 2 sectors only
@param b_digital_audio_play Control error concealment when the
data being read is CD-DA. If the data being read is not CD-DA,
this parameter is ignored. If the data being read is CD-DA and
DAP is false zero, then the user data returned should not be
modified by flaw obscuring mechanisms such as audio data mute and
interpolate. If the data being read is CD-DA and DAP is true,
then the user data returned should be modified by flaw obscuring
mechanisms such as audio data mute and interpolate.
b_sync_header return the sync header (which will probably have
the same value as CDIO_SECTOR_SYNC_HEADER of size
CDIO_CD_SYNC_SIZE).
@param header_codes Header Codes refer to the sector header and
the sub-header that is present in mode 2 formed sectors:
0 No header information is returned.
1 The 4-byte sector header of data sectors is be returned,
2 The 8-byte sector sub-header of mode 2 formed sectors is
returned.
3 Both sector header and sub-header (12 bytes) is returned.
The Header preceeds the rest of the bytes (e.g. user-data bytes)
that might get returned.
@param b_user_data Return user data if true.
For CD-DA, the User Data is CDIO_CD_FRAMESIZE_RAW bytes.
For Mode 1, The User Data is ISO_BLOCKSIZE bytes beginning at
offset CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE.
For Mode 2 formless, The User Data is M2RAW_SECTOR_SIZE bytes
beginning at offset CDIO_CD_HEADER_SIZE+CDIO_CD_SUBHEADER_SIZE.
For data Mode 2, form 1, User Data is ISO_BLOCKSIZE bytes beginning at
offset CDIO_CD_XA_SYNC_HEADER.
For data Mode 2, form 2, User Data is 2 324 bytes beginning at
offset CDIO_CD_XA_SYNC_HEADER.
@param b_sync
@param b_edc_ecc true if we return EDC/ECC error detection/correction bits.
The presence and size of EDC redundancy or ECC parity is defined
according to sector type:
CD-DA sectors have neither EDC redundancy nor ECC parity.
Data Mode 1 sectors have 288 bytes of EDC redundancy, Pad, and
ECC parity beginning at offset 2064.
Data Mode 2 formless sectors have neither EDC redundancy nor ECC
parity
Data Mode 2 form 1 sectors have 280 bytes of EDC redundancy and
ECC parity beginning at offset 2072
Data Mode 2 form 2 sectors optionally have 4 bytes of EDC
redundancy beginning at offset 2348.
@param c2_error_information If true associate a bit with each
sector for C2 error The resulting bit field is ordered exactly as
the main channel bytes. Each 8-bit boundary defines a byte of
flag bits.
@param subchannel_selection subchannel-selection bits
0 No Sub-channel data shall be returned. (0 bytes)
1 RAW P-W Sub-channel data shall be returned. (96 byte)
2 Formatted Q sub-channel data shall be transferred (16 bytes)
3 Reserved
4 Corrected and de-interleaved R-W sub-channel (96 bytes)
5-7 Reserved
@param i_blocksize size of the a block expected to be returned
@param i_blocks number of blocks expected to be returned.
*/
driver_return_code_t
mmc_read_cd ( const CdIo_t *p_cdio, void *p_buf, lsn_t i_lsn,
int expected_sector_type, bool b_digital_audio_play,
bool b_sync, uint8_t header_codes, bool b_user_data,
bool b_edc_ecc, uint8_t c2_error_information,
uint8_t subchannel_selection, uint16_t i_blocksize,
uint32_t i_blocks );
/** Read just the user data part of some sort of data sector (via
mmc_read_cd).
@param p_cdio object to read from
@param p_buf place to read data into. The caller should make sure
this location can store at least CDIO_CD_FRAMESIZE,
M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE depending on
the kind of sector getting read. If you don't know
whether you have a Mode 1/2, Form 1/ Form 2/Formless
sector best to reserve space for the maximum,
M2RAW_SECTOR_SIZE.
@param i_lsn sector to read
@param i_blocksize size of each block
@param i_blocks number of blocks to read
*/
driver_return_code_t mmc_read_data_sectors ( CdIo_t *p_cdio, void *p_buf,
lsn_t i_lsn,
uint16_t i_blocksize,
uint32_t i_blocks );
/** Read sectors using SCSI-MMC GPCMD_READ_CD.
Can read only up to 25 blocks.
*/
driver_return_code_t mmc_read_sectors ( const CdIo_t *p_cdio, void *p_buf,
lsn_t i_lsn, int read_sector_type,
uint32_t i_blocks);
/**
Run a Multimedia command (MMC).
@param p_cdio CD structure set by cdio_open().
@param i_timeout_ms time in milliseconds we will wait for the command
to complete.
@param p_cdb CDB bytes. All values that are needed should be set
on input. We'll figure out what the right CDB length
should be.
@param e_direction direction the transfer is to go.
@param i_buf Size of buffer
@param p_buf Buffer for data, both sending and receiving.
@return 0 if command completed successfully.
*/
driver_return_code_t
mmc_run_cmd( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
const mmc_cdb_t *p_cdb,
cdio_mmc_direction_t e_direction, unsigned int i_buf,
/*in/out*/ void *p_buf );
/**
Run a Multimedia command (MMC) specifying the CDB length.
The motivation here is for example ot use in is an undocumented
debug command for LG drives (namely E7), whose length is being
miscalculated by mmc_get_cmd_len(); it doesn't follow the usual
code number to length conventions. Patch supplied by SukkoPera.
@param p_cdio CD structure set by cdio_open().
@param i_timeout_ms time in milliseconds we will wait for the command
to complete.
@param p_cdb CDB bytes. All values that are needed should be set
on input.
@param i_cdb number of CDB bytes.
@param e_direction direction the transfer is to go.
@param i_buf Size of buffer
@param p_buf Buffer for data, both sending and receiving.
@return 0 if command completed successfully.
*/
driver_return_code_t
mmc_run_cmd_len( const CdIo_t *p_cdio, unsigned int i_timeout_ms,
const mmc_cdb_t *p_cdb, unsigned int i_cdb,
cdio_mmc_direction_t e_direction, unsigned int i_buf,
/*in/out*/ void *p_buf );
/**
Set the block size for subsequest read requests, via MMC.
*/
driver_return_code_t mmc_set_blocksize ( const CdIo_t *p_cdio,
uint16_t i_blocksize);
/**
Set the drive speed in CD-ROM speed units.
@param p_cdio CD structure set by cdio_open().
@param i_drive_speed speed in CD-ROM speed units. Note this
not Kbs as would be used in the MMC spec or
in mmc_set_speed(). To convert CD-ROM speed units
to Kbs, multiply the number by 176 (for raw data)
and by 150 (for filesystem data). On many CD-ROM
drives, specifying a value too large will result
in using the fastest 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.
@see cdio_set_speed and mmc_set_speed
*/
driver_return_code_t mmc_set_drive_speed( const CdIo_t *p_cdio,
int i_drive_speed );
/**
Set the drive speed in K bytes per second.
@param p_cdio CD structure set by cdio_open().
@param i_Kbs_speed speed in K bytes per second. Note this is
not in standard CD-ROM speed units, e.g.
1x, 4x, 16x as it is in cdio_set_speed.
To convert CD-ROM speed units to Kbs,
multiply the number by 176 (for raw data)
and by 150 (for filesystem data).
Also note that ATAPI specs say that a value
less than 176 will result in an error.
On many CD-ROM drives,
specifying a value too large will result in using
the fastest 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.
@see cdio_set_speed and mmc_set_drive_speed
*/
driver_return_code_t mmc_set_speed( const CdIo_t *p_cdio,
int i_Kbs_speed );
/**
Load or Unload media using a MMC START STOP command.
@param p_cdio the CD object to be acted upon.
@param b_eject eject if true and close tray if false
@param b_immediate wait or don't wait for operation to complete
@param power_condition Set CD-ROM to idle/standby/sleep. If nonzero
eject/load is ignored, so set to 0 if you want to eject or load.
@see mmc_eject_media or mmc_close_tray
*/
driver_return_code_t
mmc_start_stop_media(const CdIo_t *p_cdio, bool b_eject, bool b_immediate,
uint8_t power_condition);
#ifdef __cplusplus
}
#endif /* __cplusplus */
/** The below variables are trickery to force the above enum symbol
values to be recorded in debug symbol tables. They are used to
allow one to refer to the enumeration value names in the typedefs
above in a debugger and debugger expressions
*/
extern cdio_mmc_feature_t debug_cdio_mmc_feature;
extern cdio_mmc_feature_interface_t debug_cdio_mmc_feature_interface;
extern cdio_mmc_feature_profile_t debug_cdio_mmc_feature_profile;
extern cdio_mmc_get_conf_t debug_cdio_mmc_get_conf;
extern cdio_mmc_gpcmd_t debug_cdio_mmc_gpcmd;
extern cdio_mmc_read_sub_state_t debug_cdio_mmc_read_sub_state;
extern cdio_mmc_read_cd_type_t debug_cdio_mmc_read_cd_type;
extern cdio_mmc_readtoc_t debug_cdio_mmc_readtoc;
extern cdio_mmc_mode_page_t debug_cdio_mmc_mode_page;
#endif /* __MMC_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

201
include/cdio/paranoia.h Normal file
View File

@@ -0,0 +1,201 @@
/*
$Id: paranoia.h,v 1.15 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2004, 2005, 2006, 2007, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 1998 Monty xiphmont@mit.edu
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file paranoia.h
*
* \brief The top-level header for libcdda_paranoia: a device- and OS-
* independent library for reading CD-DA with error tolerance and
* repair. Applications include this for paranoia access.
*/
#ifndef _CDIO_PARANOIA_H_
#define _CDIO_PARANOIA_H_
#include <cdio/cdda.h>
/*! Paranoia likes to work with 16-bit numbers rather than
(possibly byte-swapped) bytes. So there are this many
16-bit numbers block (frame, or sector) read.
*/
#define CD_FRAMEWORDS (CDIO_CD_FRAMESIZE_RAW/2)
/**
Flags used in paranoia_modeset.
The enumeration type one probably wouldn't really use in a program.
It is here instead of defines to give symbolic names that can be
helpful in debuggers where wants just to say refer to
PARANOIA_MODE_DISABLE and get the correct value.
*/
typedef enum {
PARANOIA_MODE_DISABLE = 0x00, /**< No fixups */
PARANOIA_MODE_VERIFY = 0x01, /**< Verify data integrety in overlap area*/
PARANOIA_MODE_FRAGMENT = 0x02, /**< unsupported */
PARANOIA_MODE_OVERLAP = 0x04, /**< Perform overlapped reads */
PARANOIA_MODE_SCRATCH = 0x08, /**< unsupported */
PARANOIA_MODE_REPAIR = 0x10, /**< unsupported */
PARANOIA_MODE_NEVERSKIP = 0x20, /**< Do not skip failed reads (retry
maxretries) */
PARANOIA_MODE_FULL = 0xff, /**< Maximum paranoia - all of the above
(except disable) */
} paranoia_mode_t;
/**
Flags set in a callback.
The enumeration type one probably wouldn't really use in a program.
It is here instead of defines to give symbolic names that can be
helpful in debuggers where wants just to say refer to
PARANOIA_CB_READ and get the correct value.
*/
typedef enum {
PARANOIA_CB_READ, /**< Read off adjust ??? */
PARANOIA_CB_VERIFY, /**< Verifying jitter */
PARANOIA_CB_FIXUP_EDGE, /**< Fixed edge jitter */
PARANOIA_CB_FIXUP_ATOM, /**< Fixed atom jitter */
PARANOIA_CB_SCRATCH, /**< Unsupported */
PARANOIA_CB_REPAIR, /**< Unsupported */
PARANOIA_CB_SKIP, /**< Skip exhausted retry */
PARANOIA_CB_DRIFT, /**< Skip exhausted retry */
PARANOIA_CB_BACKOFF, /**< Unsupported */
PARANOIA_CB_OVERLAP, /**< Dynamic overlap adjust */
PARANOIA_CB_FIXUP_DROPPED, /**< Fixed dropped bytes */
PARANOIA_CB_FIXUP_DUPED, /**< Fixed duplicate bytes */
PARANOIA_CB_READERR /**< Hard read error */
} paranoia_cb_mode_t;
extern const char *paranoia_cb_mode2str[];
#ifdef __cplusplus
extern "C" {
#endif
/*!
Get and initialize a new cdrom_paranoia object from cdrom_drive.
Run this before calling any of the other paranoia routines below.
@return new cdrom_paranoia object Call paranoia_free() when you are
done with it
*/
extern cdrom_paranoia_t *cdio_paranoia_init(cdrom_drive_t *d);
/*!
Free any resources associated with p.
@param p paranoia object to for which resources are to be freed.
@see paranoia_init.
*/
extern void cdio_paranoia_free(cdrom_paranoia_t *p);
/*!
Set the kind of repair you want to on for reading.
The modes are listed above
@param p paranoia type
@param mode_flags paranoia mode flags built from values in
paranoia_mode_t, e.g.
PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP
*/
extern void cdio_paranoia_modeset(cdrom_paranoia_t *p, int mode_flags);
/*!
reposition reading offset.
@param p paranoia type
@param seek byte offset to seek to
@param whence like corresponding parameter in libc's lseek, e.g.
SEEK_SET or SEEK_END.
*/
extern lsn_t cdio_paranoia_seek(cdrom_paranoia_t *p, off_t seek, int whence);
/*!
Reads the next sector of audio data and returns a pointer to a full
sector of verified samples.
@param p paranoia object.
@param callback callback routine which gets called with the status
on each read.
@return the audio data read, CDIO_CD_FRAMESIZE_RAW (2352)
bytes. This data is not to be freed by the caller. It will persist
only until the next call to paranoia_read() for this p.
*/
extern int16_t *cdio_paranoia_read(cdrom_paranoia_t *p,
void(*callback)(long int,
paranoia_cb_mode_t));
/*! The same as cdio_paranoia_read but the number of retries is set.
@param p paranoia object.
@param callback callback routine which gets called with the status
on each read.
@param max_retries number of times to try re-reading a block before
failing.
@return the block of CDIO_FRAMEIZE_RAW bytes (or
CDIO_FRAMESIZE_RAW / 2 16-bit integers). Unless byte-swapping has
been turned off the 16-bit integers Endian independent order.
@see cdio_paranoia_read.
*/
extern int16_t *cdio_paranoia_read_limited(cdrom_paranoia_t *p,
void(*callback)(long int,
paranoia_cb_mode_t),
int max_retries);
/*! a temporary hack */
extern void cdio_paranoia_overlapset(cdrom_paranoia_t *p,long overlap);
extern void cdio_paranoia_set_range(cdrom_paranoia_t *p, long int start,
long int end);
#ifndef DO_NOT_WANT_PARANOIA_COMPATIBILITY
/** For compatibility with good ol' paranoia */
#define paranoia_init cdio_paranoia_init
#define paranoia_free cdio_paranoia_free
#define paranoia_modeset cdio_paranoia_modeset
#define paranoia_seek cdio_paranoia_seek
#define paranoia_read cdio_paranoia_read
#define paranoia_read_limited cdio_paranoia_read_limited
#define paranoia_overlapset cdio_paranoia_overlapset
#define paranoia_set_range cdio_paranoia_set_range
#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/
#ifdef __cplusplus
}
#endif
/** The below variables are trickery to force the above enum symbol
values to be recorded in debug symbol tables. They are used to
allow one to refer to the enumeration value names in the typedefs
above in a debugger and debugger expressions
*/
extern paranoia_mode_t debug_paranoia_mode;
extern paranoia_cb_mode_t debug_paranoia_cb_mode;
#endif /*_CDIO_PARANOIA_H_*/

43
include/cdio/posix.h Normal file
View File

@@ -0,0 +1,43 @@
/*
$Id: posix.h,v 1.2 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file posix.h
*
* \brief various POSIX definitions.
*/
#ifndef __CDIO_POSIX_H__
#define __CDIO_POSIX_H__
typedef uint32_t posix_mode_t;
typedef uint32_t posix_nlink_t;
typedef uint32_t posix_uid_t;
typedef uint32_t posix_gid_t;
typedef uint16_t unicode16_t;
#endif /* __CDIO_POSIX_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

235
include/cdio/read.h Normal file
View File

@@ -0,0 +1,235 @@
/*
$Id: read.h,v 1.15 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2005, 2006, 2007, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file read.h
*
* \brief The top-level header for sector (block, frame)-related
* libcdio calls.
*/
#ifndef __CDIO_READ_H__
#define __CDIO_READ_H__
#ifndef EXTERNAL_LIBCDIO_CONFIG_H
#define EXTERNAL_LIBCDIO_CONFIG_H
/* Need for HAVE_SYS_TYPES_H */
#include <cdio/cdio_config.h>
#endif
#ifdef HAVE_SYS_TYPES_H
/* Some systems need this for off_t and ssize. */
#include <sys/types.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** All the different ways a block/sector can be read. */
typedef enum {
CDIO_READ_MODE_AUDIO, /**< CD-DA, audio, Red Book */
CDIO_READ_MODE_M1F1, /**< Mode 1 Form 1 */
CDIO_READ_MODE_M1F2, /**< Mode 1 Form 2 */
CDIO_READ_MODE_M2F1, /**< Mode 2 Form 1 */
CDIO_READ_MODE_M2F2 /**< Mode 2 Form 2 */
} cdio_read_mode_t;
/*!
Reposition read offset
Similar to (if not the same as) libc's fseek()
@param p_cdio object which gets adjusted
@param offset amount to seek
@param whence like corresponding parameter in libc's fseek, e.g.
SEEK_SET or SEEK_END.
@return (off_t) -1 on error.
*/
off_t cdio_lseek(const CdIo_t *p_cdio, off_t offset, int whence);
/*! Reads into buf the next size bytes. Similar to (if not the
same as) libc's read(). This is a "cooked" read, or one handled by
the OS. It probably won't work on audio data. For that use
cdio_read_audio_sector(s).
@param p_cdio object to read from
@param p_buf place to read data into. The caller should make sure
this location can store at least i_size bytes.
@param i_size number of bytes to read
@return (ssize_t) -1 on error.
*/
ssize_t cdio_read(const CdIo_t *p_cdio, void *p_buf, size_t i_size);
/*!
Read an audio sector
@param p_cdio object to read from
@param p_buf place to read data into. The caller should make sure
this location can store at least CDIO_FRAMESIZE_RAW
bytes.
@param i_lsn sector to read
*/
driver_return_code_t cdio_read_audio_sector (const CdIo_t *p_cdio,
void *p_buf, lsn_t i_lsn);
/*!
Reads audio sectors
@param p_cdio object to read from
@param p_buf place to read data into. The caller should make sure
this location can store at least CDIO_FRAMESIZE_RAW
* i_blocks bytes.
@param i_lsn sector to read
@param i_blocks number of sectors to read
*/
driver_return_code_t cdio_read_audio_sectors (const CdIo_t *p_cdio,
void *p_buf, lsn_t i_lsn,
uint32_t i_blocks);
/*!
Read data sectors
@param p_cdio object to read from
@param p_buf place to read data into. The caller should make sure
this location can store at least ISO_BLOCKSIZE,
M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE depending
on the kind of sector getting read. If you don't
know whether you have a Mode 1/2, Form 1/ Form 2/Formless
sector best to reserve space for the maximum,
M2RAW_SECTOR_SIZE.
@param i_lsn sector to read
@param i_blocksize size of block. Should be either CDIO_CD_FRAMESIZE,
M2RAW_SECTOR_SIZE, or M2F2_SECTOR_SIZE. See comment above under p_buf.
@param i_blocks number of blocks to read
*/
driver_return_code_t cdio_read_data_sectors ( const CdIo_t *p_cdio,
void *p_buf, lsn_t i_lsn,
uint16_t i_blocksize,
uint32_t i_blocks );
/*!
Reads a mode 1 sector
@param p_cdio object to read from
@param p_buf place to read data into.
@param i_lsn sector to read
@param b_form2 true for reading mode 1 form 2 sectors or false for
mode 1 form 1 sectors.
*/
driver_return_code_t cdio_read_mode1_sector (const CdIo_t *p_cdio,
void *p_buf, lsn_t i_lsn,
bool b_form2);
/*!
Reads mode 1 sectors
@param p_cdio object to read from
@param p_buf place to read data into
@param i_lsn sector to read
@param b_form2 true for reading mode 1 form 2 sectors or false for
mode 1 form 1 sectors.
@param i_blocks number of sectors to read
*/
driver_return_code_t cdio_read_mode1_sectors (const CdIo_t *p_cdio,
void *p_buf, lsn_t i_lsn,
bool b_form2,
uint32_t i_blocks);
/*!
Reads a mode 2 sector
@param p_cdio object to read from
@param p_buf place to read data into. The caller should make sure
this location can store at least
M2RAW_SECTOR_SIZE (for form 1) or CDIO_CD_FRAMESIZE (for
form 2) bytes.
@param i_lsn sector to read
@param b_form2 true for reading mode 2 form 2 sectors or false for
mode 2 form 1 sectors.
@return 0 if no error, nonzero otherwise.
*/
driver_return_code_t cdio_read_mode2_sector (const CdIo_t *p_cdio,
void *p_buf, lsn_t i_lsn,
bool b_form2);
/** The special case of reading a single block is a common one so we
provide a routine for that as a convenience.
*/
driver_return_code_t cdio_read_sector(const CdIo_t *p_cdio, void *p_buf,
lsn_t i_lsn,
cdio_read_mode_t read_mode);
/*!
Reads mode 2 sectors
@param p_cdio object to read from
@param p_buf place to read data into. The caller should make sure
this location can store at least
M2RAW_SECTOR_SIZE (for form 1) or CDIO_CD_FRAMESIZE (for
form 2) * i_blocks bytes.
@param i_lsn sector to read
@param b_form2 true for reading mode2 form 2 sectors or false for
mode 2 form 1 sectors.
@param i_blocks number of sectors to read
@return 0 if no error, nonzero otherwise.
*/
driver_return_code_t cdio_read_mode2_sectors (const CdIo_t *p_cdio,
void *p_buf, lsn_t i_lsn,
bool b_form2,
uint32_t i_blocks);
/*!
Reads a number of sectors (AKA blocks).
@param p_cdio cdio object
@param p_buf place to read data into. The caller should make sure
this location is large enough. See below for size information.
@param read_mode the kind of "mode" to use in reading.
@param i_lsn sector to read
@param i_blocks number of sectors to read
@return DRIVER_OP_SUCCESS (0) if no error, other (negative) enumerations
are returned on error.
If read_mode is CDIO_MODE_AUDIO,
*p_buf should hold at least CDIO_FRAMESIZE_RAW * i_blocks bytes.
If read_mode is CDIO_MODE_DATA,
*p_buf should hold at least i_blocks times either ISO_BLOCKSIZE,
M1RAW_SECTOR_SIZE or M2F2_SECTOR_SIZE depending on the kind of
sector getting read. If you don't know whether you have a Mode 1/2,
Form 1/ Form 2/Formless sector best to reserve space for the maximum
which is M2RAW_SECTOR_SIZE.
If read_mode is CDIO_MODE_M2F1,
*p_buf should hold at least M2RAW_SECTOR_SIZE * i_blocks bytes.
If read_mode is CDIO_MODE_M2F2,
*p_buf should hold at least CDIO_CD_FRAMESIZE * i_blocks bytes.
*/
driver_return_code_t cdio_read_sectors(const CdIo_t *p_cdio, void *p_buf,
lsn_t i_lsn,
cdio_read_mode_t read_mode,
uint32_t i_blocks);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __CDIO_TRACK_H__ */

396
include/cdio/rock.h Normal file
View File

@@ -0,0 +1,396 @@
/*
$Id: rock.h,v 1.15 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2005, 2006 2008 Rocky Bernstein <rocky@panix.com>
See also rock.c by Eric Youngdale (1993) from GNU/Linux
This is Copyright 1993 Yggdrasil Computing, Incorporated
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/*!
\file rock.h
\brief Things related to the Rock Ridge Interchange Protocol (RRIP)
Applications will probably not include this directly but via
the iso9660.h header.
*/
#ifndef __CDIO_ROCK_H__
#define __CDIO_ROCK_H__
#include <cdio/types.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* MSYS 1.0.10 with MinGW 3.4.2 (and perhaps others) don't have
S_ISSOCK() or S_ISLNK() macros, so we'll roll our own. */
#if !defined(HAVE_S_ISSOCK) && !defined(S_ISSOCK)
#define S_ISSOCK(st_mode) ((((st_mode)) & 0170000) == (0140000))
#endif
#if !defined(HAVE_S_ISLNK) && !defined(S_ISLNK)
#define S_ISLNK(st_mode) ((((st_mode)) & 0170000) == (0010000))
#endif
/*! An enumeration for some of the ISO_ROCK_* \#defines below. This isn't
really an enumeration one would really use in a program it is to
be helpful in debuggers where wants just to refer to the ISO_ROCK_*
names and get something.
*/
extern enum iso_rock_enums {
ISO_ROCK_IRUSR = 000400, /**< read permission (owner) */
ISO_ROCK_IWUSR = 000200, /**< write permission (owner) */
ISO_ROCK_IXUSR = 000100, /**< execute permission (owner) */
ISO_ROCK_IRGRP = 000040, /**< read permission (group) */
ISO_ROCK_IWGRP = 000020, /**< write permission (group) */
ISO_ROCK_IXGRP = 000010, /**< execute permission (group) */
ISO_ROCK_IROTH = 000004, /**< read permission (other) */
ISO_ROCK_IWOTH = 000002, /**< write permission (other) */
ISO_ROCK_IXOTH = 000001, /**< execute permission (other) */
ISO_ROCK_ISUID = 004000, /**< set user ID on execution */
ISO_ROCK_ISGID = 002000, /**< set group ID on execution */
ISO_ROCK_ISVTX = 001000, /**< save swapped text even after use */
ISO_ROCK_ISSOCK = 0140000, /**< socket */
ISO_ROCK_ISLNK = 0120000, /**< symbolic link */
ISO_ROCK_ISREG = 0100000, /**< regular */
ISO_ROCK_ISBLK = 060000, /**< block special */
ISO_ROCK_ISCHR = 020000, /**< character special */
ISO_ROCK_ISDIR = 040000, /**< directory */
ISO_ROCK_ISFIFO = 010000 /**< pipe or FIFO */
} iso_rock_enums;
#define ISO_ROCK_IRUSR 000400 /** read permission (owner) */
#define ISO_ROCK_IWUSR 000200 /** write permission (owner) */
#define ISO_ROCK_IXUSR 000100 /** execute permission (owner) */
#define ISO_ROCK_IRGRP 000040 /** read permission (group) */
#define ISO_ROCK_IWGRP 000020 /** write permission (group) */
#define ISO_ROCK_IXGRP 000010 /** execute permission (group) */
#define ISO_ROCK_IROTH 000004 /** read permission (other) */
#define ISO_ROCK_IWOTH 000002 /** write permission (other) */
#define ISO_ROCK_IXOTH 000001 /** execute permission (other) */
#define ISO_ROCK_ISUID 004000 /** set user ID on execution */
#define ISO_ROCK_ISGID 002000 /** set group ID on execution */
#define ISO_ROCK_ISVTX 001000 /** save swapped text even after use */
#define ISO_ROCK_ISSOCK 0140000 /** socket */
#define ISO_ROCK_ISLNK 0120000 /** symbolic link */
#define ISO_ROCK_ISREG 0100000 /** regular */
#define ISO_ROCK_ISBLK 060000 /** block special */
#define ISO_ROCK_ISCHR 020000 /** character special */
#define ISO_ROCK_ISDIR 040000 /** directory */
#define ISO_ROCK_ISFIFO 010000 /** pipe or FIFO */
/** Enforced file locking (shared w/set group ID) */
#define ISO_ROCK_ENFMT ISO_ROCK_ISGID
PRAGMA_BEGIN_PACKED
/*! The next two structs are used by the system-use-sharing protocol
(SUSP), in which the Rock Ridge extensions are embedded. It is
quite possible that other extensions are present on the disk, and
this is fine as long as they all use SUSP. */
/*! system-use-sharing protocol */
typedef struct iso_su_sp_s{
unsigned char magic[2];
uint8_t skip;
} GNUC_PACKED iso_su_sp_t;
/*! system-use extension record */
typedef struct iso_su_er_s {
iso711_t len_id; /**< Identifier length. Value 10?. */
unsigned char len_des;
unsigned char len_src;
iso711_t ext_ver; /**< Extension version. Value 1? */
char data[EMPTY_ARRAY_SIZE];
} GNUC_PACKED iso_su_er_t;
typedef struct iso_su_ce_s {
char extent[8];
char offset[8];
char size[8];
} iso_su_ce_t;
/*! POSIX file attributes, PX. See Rock Ridge Section 4.1.2 */
typedef struct iso_rock_px_s {
iso733_t st_mode; /*! file mode permissions; same as st_mode
of POSIX:5.6.1 */
iso733_t st_nlinks; /*! number of links to file; same as st_nlinks
of POSIX:5.6.1 */
iso733_t st_uid; /*! user id owner of file; same as st_uid
of POSIX:5.6.1 */
iso733_t st_gid; /*! group id of file; same as st_gid of
of POSIX:5.6.1 */
} GNUC_PACKED iso_rock_px_t ;
/*! POSIX device number, PN. A PN is mandatory if the file type
recorded in the "PX" File Mode field for a Directory Record
indicates a character or block device (ISO_ROCK_ISCHR |
ISO_ROCK_ISBLK). This entry is ignored for other (non-Direcotry)
file types. No more than one "PN" is recorded in the System Use Area
of a Directory Record.
See Rock Ridge Section 4.1.2 */
typedef struct iso_rock_pn_s {
iso733_t dev_high; /**< high-order 32 bits of the 64 bit device number.
7.2.3 encoded */
iso733_t dev_low; /**< low-order 32 bits of the 64 bit device number.
7.2.3 encoded */
} GNUC_PACKED iso_rock_pn_t ;
/*! These are the bits and their meanings for flags in the SL structure. */
typedef enum {
ISO_ROCK_SL_CONTINUE = 1,
ISO_ROCK_SL_CURRENT = 2,
ISO_ROCK_SL_PARENT = 4,
ISO_ROCK_SL_ROOT = 8
} iso_rock_sl_flag_t;
#define ISO_ROCK_SL_CONTINUE 1
#define ISO_ROCK_SL_CURRENT 2
#define ISO_ROCK_SL_PARENT 4
#define ISO_ROCK_SL_ROOT 8
typedef struct iso_rock_sl_part_s {
uint8_t flags;
uint8_t len;
char text[EMPTY_ARRAY_SIZE];
} GNUC_PACKED iso_rock_sl_part_t ;
/*! Symbolic link. See Rock Ridge Section 4.1.3 */
typedef struct iso_rock_sl_s {
unsigned char flags;
iso_rock_sl_part_t link;
} GNUC_PACKED iso_rock_sl_t ;
/*! Alternate name. See Rock Ridge Section 4.1.4 */
/*! These are the bits and their meanings for flags in the NM structure. */
typedef enum {
ISO_ROCK_NM_CONTINUE = 1,
ISO_ROCK_NM_CURRENT = 2,
ISO_ROCK_NM_PARENT = 4,
} iso_rock_nm_flag_t;
#define ISO_ROCK_NM_CONTINUE 1
#define ISO_ROCK_NM_CURRENT 2
#define ISO_ROCK_NM_PARENT 4
typedef struct iso_rock_nm_s {
unsigned char flags;
char name[EMPTY_ARRAY_SIZE];
} GNUC_PACKED iso_rock_nm_t ;
/*! Child link. See Section 4.1.5.1 */
typedef struct iso_rock_cl_s {
char location[1];
} GNUC_PACKED iso_rock_cl_t ;
/*! Parent link. See Section 4.1.5.2 */
typedef struct iso_rock_pl_s {
char location[1];
} GNUC_PACKED iso_rock_pl_t ;
/*! These are the bits and their meanings for flags in the TF structure. */
typedef enum {
ISO_ROCK_TF_CREATE = 1,
ISO_ROCK_TF_MODIFY = 2,
ISO_ROCK_TF_ACCESS = 4,
ISO_ROCK_TF_ATTRIBUTES = 8,
ISO_ROCK_TF_BACKUP = 16,
ISO_ROCK_TF_EXPIRATION = 32,
ISO_ROCK_TF_EFFECTIVE = 64,
ISO_ROCK_TF_LONG_FORM = 128
} iso_rock_tf_flag_t;
/* These are the bits and their meanings for flags in the TF structure. */
#define ISO_ROCK_TF_CREATE 1
#define ISO_ROCK_TF_MODIFY 2
#define ISO_ROCK_TF_ACCESS 4
#define ISO_ROCK_TF_ATTRIBUTES 8
#define ISO_ROCK_TF_BACKUP 16
#define ISO_ROCK_TF_EXPIRATION 32
#define ISO_ROCK_TF_EFFECTIVE 64
#define ISO_ROCK_TF_LONG_FORM 128
/*! Time stamp(s) for a file. See Rock Ridge Section 4.1.6 */
typedef struct iso_rock_tf_s {
uint8_t flags; /**< See ISO_ROCK_TF_* bits above. */
uint8_t time_bytes[EMPTY_ARRAY_SIZE]; /**< A homogenious array of
iso9660_ltime_t or
iso9660_dtime_t entries
depending on flags &
ISO_ROCK_TF_LONG_FORM. Lacking
a better method, we store
this as an array of bytes
and a cast to the
appropriate type will have
to be made before
extraction. */
} GNUC_PACKED iso_rock_tf_t ;
/*! File data in sparse format. See Rock Ridge Section 4.1.7 */
typedef struct iso_rock_sf_s {
iso733_t virtual_size_high; /**< high-order 32 bits of virtual size */
iso733_t virtual_size_low; /**< low-order 32 bits of virtual size */
uint8_t table_depth;
} GNUC_PACKED iso_rock_sf_t ;
typedef struct iso_extension_record_s {
char signature[2]; /**< signature word; either 'SP', 'CE', 'ER', 'RR',
'PX', 'PN', 'SL', 'NM', 'CL', 'PL', 'TF', or
'ZF' */
iso711_t len; /**< length of system-user area - 44 for PX
20 for PN, 5+strlen(text) for SL, 21 for
SF, etc. */
iso711_t version; /**< version number - value 1 */
union {
iso_su_sp_t SP; /**< system-use-sharing protocol - not
strictly part of Rock Ridge */
iso_su_er_t ER; /**< system-use extension packet - not
strictly part of Rock Ridge */
iso_su_ce_t CE; /**< system-use - strictly part of Rock Ridge */
iso_rock_px_t PX; /**< Rock Ridge POSIX file attributes */
iso_rock_pn_t PN; /**< Rock Ridge POSIX device number */
iso_rock_sl_t SL; /**< Rock Ridge symbolic link */
iso_rock_nm_t NM; /**< Rock Ridge alternate name */
iso_rock_cl_t CL; /**< Rock Ridge child link */
iso_rock_pl_t PL; /**< Rock Ridge parent link */
iso_rock_tf_t TF; /**< Rock Ridge timestamp(s) for a file */
} u;
} GNUC_PACKED iso_extension_record_t;
typedef struct iso_rock_time_s {
bool b_used; /**< If true, field has been set and is valid.
Otherwise remaning fields are meaningless. */
bool b_longdate; /**< If true date format is a iso9660_ltime_t.
Otherwise date is iso9660_dtime_t */
union
{
iso9660_ltime_t ltime;
iso9660_dtime_t dtime;
} t;
} GNUC_PACKED iso_rock_time_t;
typedef struct iso_rock_statbuf_s {
bool_3way_t b3_rock; /**< has Rock Ridge extension.
If "yep", then the fields
are used.
*/
posix_mode_t st_mode; /**< protection */
posix_nlink_t st_nlinks; /**< number of hard links */
posix_uid_t st_uid; /**< user ID of owner */
posix_gid_t st_gid; /**< group ID of owner */
uint8_t s_rock_offset;
int i_symlink; /**< size of psz_symlink */
int i_symlink_max; /**< max allocated to psz_symlink */
char *psz_symlink; /**< if symbolic link, name
of pointed to file. */
iso_rock_time_t create; /**< create time See ISO 9660:9.5.4. */
iso_rock_time_t modify; /**< time of last modification
ISO 9660:9.5.5. st_mtime field of
POSIX:5.6.1. */
iso_rock_time_t access; /**< time of last file access st_atime
field of POSIX:5.6.1. */
iso_rock_time_t attributes; /**< time of last attribute change.
st_ctime field of POSIX:5.6.1. */
iso_rock_time_t backup; /**< time of last backup. */
iso_rock_time_t expiration; /**< time of expiration; See ISO
9660:9.5.6. */
iso_rock_time_t effective; /**< Effective time; See ISO 9660:9.5.7.
*/
uint32_t i_rdev; /**< the upper 16-bits is major device
number, the lower 16-bits is the
minor device number */
} iso_rock_statbuf_t;
PRAGMA_END_PACKED
/*! return length of name field; 0: not found, -1: to be ignored */
int get_rock_ridge_filename(iso9660_dir_t * de, /*out*/ char * retname,
/*out*/ iso9660_stat_t *p_stat);
int parse_rock_ridge_stat(iso9660_dir_t *de, /*out*/ iso9660_stat_t *p_stat);
/*!
Returns POSIX mode bitstring for a given file.
*/
mode_t
iso9660_get_posix_filemode_from_rock(const iso_rock_statbuf_t *rr);
/*!
Returns a string which interpreting the POSIX mode st_mode.
For example:
\verbatim
drwxrws---
-rw---Sr--
lrwxrwxrwx
\endverbatim
A description of the characters in the string follows
The 1st character is either "d" if the entry is a directory, "l" is
a symbolic link or "-" if neither.
The 2nd to 4th characters refer to permissions for a user while the
the 5th to 7th characters refer to permissions for a group while, and
the 8th to 10h characters refer to permissions for everyone.
In each of these triplets the first character (2, 5, 8) is "r" if
the entry is allowed to be read.
The second character of a triplet (3, 6, 9) is "w" if the entry is
allowed to be written.
The third character of a triplet (4, 7, 10) is "x" if the entry is
executable but not user (for character 4) or group (for characters
6) settable and "s" if the item has the corresponding user/group set.
For a directory having an executable property on ("x" or "s") means
the directory is allowed to be listed or "searched". If the execute
property is not allowed for a group or user but the corresponding
group/user is set "S" indicates this. If none of these properties
holds the "-" indicates this.
*/
const char *iso9660_get_rock_attr_str(posix_mode_t st_mode);
/** These variables are not used, but are defined to facilatate debugging
by letting us use enumerations values (which also correspond to
\#define's inside a debugged program.
*/
extern iso_rock_nm_flag_t iso_rock_nm_flag;
extern iso_rock_sl_flag_t iso_rock_sl_flag;
extern iso_rock_tf_flag_t iso_rock_tf_flag;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __ISO_ROCK_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

26
include/cdio/scsi_mmc.h Normal file
View File

@@ -0,0 +1,26 @@
/*
$Id: scsi_mmc.h,v 1.46 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2003, 2004, 2005, 2008 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file scsi_mmc.h
*
* \brief Obsolete please use <cdio/mmc.h> instead.
*/
/* ust a moment while, I transfer your call... */
#include <cdio/mmc.h>

281
include/cdio/sector.h Normal file
View File

@@ -0,0 +1,281 @@
/*
$Id: sector.h,v 1.38 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2003, 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/*!
\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_
#define _CDIO_SECTOR_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <cdio/types.h>
/*! Information that can be obtained through a Read Subchannel
command.
*/
#define CDIO_SUBCHANNEL_SUBQ_DATA 0
#define CDIO_SUBCHANNEL_CURRENT_POSITION 1
#define CDIO_SUBCHANNEL_MEDIA_CATALOG 2
#define CDIO_SUBCHANNEL_TRACK_ISRC 3
/*! track flags
* Q Sub-channel Control Field (4.2.3.3)
*/
typedef enum {
NONE = 0x00, /* no flags set */
PRE_EMPHASIS = 0x01, /* audio track recorded with pre-emphasis */
COPY_PERMITTED = 0x02, /* digital copy permitted */
DATA = 0x04, /* data track */
FOUR_CHANNEL_AUDIO = 0x08, /* 4 audio channels */
SCMS = 0x10 /* SCMS (5.29.2.7) */
} flag_t;
#define CDIO_PREGAP_SECTORS 150
#define CDIO_POSTGAP_SECTORS 150
/*! An enumeration for some of the CDIO_CD \#defines below. This isn't
really an enumeration one would really use in a program it is to
be helpful in debuggers where wants just to refer to the CDIO_CD_
names and get something.
*/
extern enum cdio_cd_enums {
CDIO_CD_MINS = 74, /**< max. minutes per CD, not really
a limit */
CDIO_CD_SECS_PER_MIN = 60, /**< seconds per minute */
CDIO_CD_FRAMES_PER_SEC = 75, /**< frames per second */
CDIO_CD_SYNC_SIZE = 12, /**< 12 sync bytes per raw data
frame */
CDIO_CD_CHUNK_SIZE = 24, /**< lowest-level "data bytes
piece" */
CDIO_CD_NUM_OF_CHUNKS = 98, /**< chunks per frame */
CDIO_CD_FRAMESIZE_SUB = 96, /**< subchannel data "frame" size */
CDIO_CD_HEADER_SIZE = 4, /**< header (address) bytes per raw
frame */
CDIO_CD_SUBHEADER_SIZE = 8, /**< subheader bytes per raw XA data
frame */
CDIO_CD_ECC_SIZE = 276, /**< bytes ECC per most raw data
frame types */
CDIO_CD_FRAMESIZE = 2048, /**< bytes per frame, "cooked"
mode */
CDIO_CD_FRAMESIZE_RAW = 2352, /**< bytes per frame, "raw" mode */
CDIO_CD_FRAMESIZE_RAWER = 2646, /**< The maximum possible
returned */
CDIO_CD_FRAMESIZE_RAW1 = 2340,
CDIO_CD_FRAMESIZE_RAW0 = 2336,
CDIO_CD_MAX_SESSIONS = 99,
CDIO_CD_MIN_SESSION_NO = 1, /**<, Smallest CD session number */
CDIO_CD_MAX_LSN = 450150, /**< Largest LSN in a CD */
CDIO_CD_MIN_LSN = -450150, /**< Smallest LSN in a CD */
} cdio_cd_enums;
/*!
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 (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_HEADER_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 */
#define CDIO_CD_XA_TAIL (CDIO_CD_EDC_SIZE+CDIO_CD_ECC_SIZE)
/*! "before data" sync bytes + header of XA (green, mode2) frame */
#define CDIO_CD_XA_SYNC_HEADER (CDIO_CD_SYNC_SIZE+CDIO_CD_XA_HEADER)
/*! String of bytes used to identify the beginning of a Mode 1 or
Mode 2 sector. */
extern const uint8_t CDIO_SECTOR_SYNC_HEADER[CDIO_CD_SYNC_SIZE];
/**<
{0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0};
*/
/*! An enumeration for some of the M2*_SECTOR_SIZE \#defines
below. This isn't really an enumeration one would really use in a
program it is to be helpful in debuggers where wants just to refer
to the M2*_SECTOR_SIZE names and get something.
*/
extern enum m2_sector_enums {
M2F2_SECTOR_SIZE = 2324,
M2SUB_SECTOR_SIZE = 2332,
M2RAW_SECTOR_SIZE = 2336
} m2_sector_enums;
#define M2F2_SECTOR_SIZE 2324
#define M2SUB_SECTOR_SIZE 2332
#define M2RAW_SECTOR_SIZE 2336
/*! Largest CD session number */
#define CDIO_CD_MAX_SESSIONS 99
/*! Smallest CD session number */
#define CDIO_CD_MIN_SESSION_NO 1
/*! Largest LSN in a CD */
#define CDIO_CD_MAX_LSN 450150
/*! Smallest LSN in a CD */
#define CDIO_CD_MIN_LSN -450150
#define CDIO_CD_FRAMES_PER_MIN \
(CDIO_CD_FRAMES_PER_SEC*CDIO_CD_SECS_PER_MIN)
#define CDIO_CD_74MIN_SECTORS (UINT32_C(74)*CDIO_CD_FRAMES_PER_MIN)
#define CDIO_CD_80MIN_SECTORS (UINT32_C(80)*CDIO_CD_FRAMES_PER_MIN)
#define CDIO_CD_90MIN_SECTORS (UINT32_C(90)*CDIO_CD_FRAMES_PER_MIN)
#define CDIO_CD_MAX_SECTORS \
(UINT32_C(100)*CDIO_CD_FRAMES_PER_MIN-CDIO_PREGAP_SECTORS)
#define msf_t_SIZEOF 3
/*!
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 i_lba);
/*!
Convert an MSF into a string representation of the MSF.
\warning cdio_msf_to_msf_str returns new allocated string */
char *cdio_msf_to_str (const msf_t *p_msf);
/*!
Convert an LBA into the corresponding LSN.
*/
lba_t cdio_lba_to_lsn (lba_t i_lba);
/*!
Convert an LBA into the corresponding MSF.
*/
void cdio_lba_to_msf(lba_t i_lba, msf_t *p_msf);
/*!
Convert an LSN into the corresponding LBA.
CDIO_INVALID_LBA is returned if there is an error.
*/
lba_t cdio_lsn_to_lba (lsn_t i_lsn);
/*!
Convert an LSN into the corresponding MSF.
*/
void cdio_lsn_to_msf (lsn_t i_lsn, msf_t *p_msf);
/*!
Convert a MSF into the corresponding LBA.
CDIO_INVALID_LBA is returned if there is an error.
*/
lba_t cdio_msf_to_lba (const msf_t *p_msf);
/*!
Convert a MSF into the corresponding LSN.
CDIO_INVALID_LSN is returned if there is an error.
*/
lsn_t cdio_msf_to_lsn (const msf_t *p_msf);
/*!
Convert a MSF - broken out as 3 integer components into the
corresponding LBA.
CDIO_INVALID_LBA is returned if there is an error.
*/
lba_t cdio_msf3_to_lba (unsigned int minutes, unsigned int seconds,
unsigned int frames);
/*!
Convert a string of the form MM:SS:FF into the corresponding LBA.
CDIO_INVALID_LBA is returned if there is an error.
*/
lba_t cdio_mmssff_to_lba (const char *psz_mmssff);
#ifdef __cplusplus
}
#endif
#endif /* _CDIO_SECTOR_H_ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

269
include/cdio/track.h Normal file
View File

@@ -0,0 +1,269 @@
/*
$Id: track.h,v 1.14 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file track.h
* \brief The top-level header for track-related libcdio calls.
*/
#ifndef __CDIO_TRACK_H__
#define __CDIO_TRACK_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! Printable tags for track_format_t enumeration. */
extern const char *track_format2str[6];
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_ERROR /**< Dunno what is, or some other error. */
} track_format_t;
typedef enum {
CDIO_TRACK_FLAG_FALSE,
CDIO_TRACK_FLAG_TRUE,
CDIO_TRACK_FLAG_ERROR,
CDIO_TRACK_FLAG_UNKNOWN
} track_flag_t;
/*! \brief Structure containing attributes associated with a track */
typedef struct {
track_flag_t preemphasis; /**< Linear preemphasis on an audio track */
track_flag_t copy_permit; /**< Whether copying is permitted */
int channels; /**< Number of audio channels, 2, 4. -2 if not
implemented or -1 for error.
*/
} track_flags_t;
/*! The leadout track is always 0xAA, regardless of # of tracks on
disc, or what value may be used internally. For example although
OS X uses a different value for the lead-out track internally than
given below, programmers should use CDIO_CDROM_LEADOUT_TRACK and
not worry about this.
*/
/*! An enumeration for some of the CDIO_CDROM_* \#defines below. This
isn't really an enumeration one would really use in a program; it
is to be helpful in debuggers where wants just to refer to the
CDIO_CDROM_* names and get something.
*/
extern enum cdio_track_enums {
CDIO_CDROM_LBA = 0x01, /**< "logical block": first frame is #0 */
CDIO_CDROM_MSF = 0x02, /**< "minute-second-frame": binary, not
BCD here! */
CDIO_CDROM_DATA_TRACK = 0x04,
CDIO_CDROM_CDI_TRACK = 0x10,
CDIO_CDROM_XA_TRACK = 0x20,
CDIO_CD_MAX_TRACKS = 99, /**< Largest CD track number */
CDIO_CDROM_LEADOUT_TRACK = 0xAA, /**< Lead-out track number */
CDIO_INVALID_TRACK = 0xFF, /**< Constant for invalid track number */
} cdio_track_enums;
#define CDIO_CD_MIN_TRACK_NO 1 /**< Smallest CD track number */
/*! track modes (Table 350)
reference: MMC-3 draft revsion - 10g
*/
typedef enum {
AUDIO, /**< 2352 byte block length */
MODE1, /**< 2048 byte block length */
MODE1_RAW, /**< 2352 byte block length */
MODE2, /**< 2336 byte block length */
MODE2_FORM1, /**< 2048 byte block length */
MODE2_FORM2, /**< 2324 byte block length */
MODE2_FORM_MIX, /**< 2336 byte block length */
MODE2_RAW /**< 2352 byte block length */
} trackmode_t;
/*!
Get CD-Text information for a CdIo_t object.
@param p_cdio the CD object that may contain CD-Text information.
@param i_track track for which we are requesting CD-Text information.
@return the CD-Text object or NULL if obj is NULL
or CD-Text information does not exist.
If i_track is 0 or CDIO_CDROM_LEADOUT_TRACK the track returned
is the information assocated with the CD.
*/
cdtext_t *cdio_get_cdtext (CdIo_t *p_cdio, track_t i_track);
/*!
Get the number of the first track.
@return the track number or CDIO_INVALID_TRACK
on error.
*/
track_t cdio_get_first_track_num(const CdIo_t *p_cdio);
/*!
Return the last track number.
CDIO_INVALID_TRACK is returned on error.
*/
track_t cdio_get_last_track_num (const CdIo_t *p_cdio);
/*! Find the track which contains lsn.
CDIO_INVALID_TRACK is returned if the lsn outside of the CD or
if there was some error.
If the lsn is before the pregap of the first track 0 is returned.
Otherwise we return the track that spans the lsn.
*/
track_t cdio_get_track(const CdIo_t *p_cdio, lsn_t lsn);
/*! Return number of channels in track: 2 or 4; -2 if not
implemented or -1 for error.
Not meaningful if track is not an audio track.
*/
int cdio_get_track_channels(const CdIo_t *p_cdio, track_t i_track);
/*! Return copy protection status on a track. Is this meaningful
if not an audio track?
*/
track_flag_t cdio_get_track_copy_permit(const CdIo_t *p_cdio,
track_t i_track);
/*!
Get the format (audio, mode2, mode1) of track.
*/
track_format_t cdio_get_track_format(const CdIo_t *p_cdio, track_t i_track);
/*!
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?
*/
bool cdio_get_track_green(const CdIo_t *p_cdio, track_t i_track);
/*!
Return the ending LSN for track number
i_track in cdio. CDIO_INVALID_LSN is returned on error.
*/
lsn_t cdio_get_track_last_lsn(const CdIo_t *p_cdio, track_t i_track);
/*!
Get the starting LBA for track number
i_track in p_cdio. Track numbers usually start at something
greater than 0, usually 1.
The "leadout" track is specified either by
using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1.
@param p_cdio object to get information from
@param i_track the track number we want the LSN for
@return the starting LBA or CDIO_INVALID_LBA on error.
*/
lba_t cdio_get_track_lba(const CdIo_t *p_cdio, track_t i_track);
/*!
Return the starting LSN for track number
i_track in p_cdio. Track numbers usually start at something
greater than 0, usually 1.
The "leadout" track is specified either by
using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1.
@param p_cdio object to get information from
@param i_track the track number we want the LSN for
@return the starting LSN or CDIO_INVALID_LSN on error.
*/
lsn_t cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track);
/*!
Return the starting LBA for the pregap for track number
i_track in p_cdio. Track numbers usually start at something
greater than 0, usually 1.
@param p_cdio object to get information from
@param i_track the track number we want the LBA for
@return the starting LBA or CDIO_INVALID_LBA on error.
*/
lba_t cdio_get_track_pregap_lba(const CdIo_t *p_cdio, track_t i_track);
/*!
Return the starting LSN for the pregap for track number
i_track in p_cdio. Track numbers usually start at something
greater than 0, usually 1.
@param p_cdio object to get information from
@param i_track the track number we want the LSN for
@return the starting LSN or CDIO_INVALID_LSN on error.
*/
lsn_t cdio_get_track_pregap_lsn(const CdIo_t *p_cdio, track_t i_track);
/*!
Get the International Standard Recording Code (ISRC) for track number
i_track in p_cdio. Track numbers usually start at something
greater than 0, usually 1.
@return the International Standard Recording Code (ISRC) or NULL
if there is none or we don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
*/
char * cdio_get_track_isrc (const CdIo_t *p_cdio, track_t i_track);
/*!
Return the starting MSF (minutes/secs/frames) for track number
i_track in p_cdio. Track numbers usually start at something
greater than 0, usually 1.
The "leadout" track is specified either by
using i_track CDIO_CDROM_LEADOUT_TRACK or the total tracks+1.
@return true if things worked or false if there is no track entry.
*/
bool cdio_get_track_msf(const CdIo_t *p_cdio, track_t i_track,
/*out*/ msf_t *msf);
/*! Get linear preemphasis status on an audio track
This is not meaningful if not an audio track?
*/
track_flag_t cdio_get_track_preemphasis(const CdIo_t *p_cdio,
track_t i_track);
/*!
Get the number of sectors between this track an the next. This
includes any pregap sectors before the start of the next track.
Track numbers usually start at something
greater than 0, usually 1.
@return the number of sectors or 0 if there is an error.
*/
unsigned int cdio_get_track_sec_count(const CdIo_t *p_cdio, track_t i_track);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __CDIO_TRACK_H__ */

327
include/cdio/types.h Normal file
View File

@@ -0,0 +1,327 @@
/*
$Id: types.h,v 1.37 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008
Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/** \file types.h
* \brief Common type definitions used pervasively in libcdio.
*/
#ifndef __CDIO_TYPES_H__
#define __CDIO_TYPES_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef EXTERNAL_LIBCDIO_CONFIG_H
#define EXTERNAL_LIBCDIO_CONFIG_H
#include <cdio/cdio_config.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
/* provide some C99 definitions */
#if defined(HAVE_SYS_TYPES_H)
#include <sys/types.h>
#endif
#if defined(HAVE_STDINT_H)
# include <stdint.h>
#elif defined(HAVE_INTTYPES_H)
# include <inttypes.h>
#elif defined(AMIGA) || defined(__linux__)
typedef u_int8_t uint8_t;
typedef u_int16_t uint16_t;
typedef u_int32_t uint32_t;
typedef u_int64_t uint64_t;
#else
/* warning ISO/IEC 9899:1999 <stdint.h> was missing and even <inttypes.h> */
/* fixme */
#endif /* HAVE_STDINT_H */
typedef uint8_t ubyte;
/* default HP/UX macros are broken */
#if defined(__hpux__)
# undef UINT16_C
# undef UINT32_C
# undef UINT64_C
# undef INT64_C
#endif
/* if it's still not defined, take a good guess... should work for
most 32bit and 64bit archs */
#ifndef UINT16_C
# define UINT16_C(c) c ## U
#endif
#ifndef UINT32_C
# if defined (SIZEOF_INT) && SIZEOF_INT == 4
# define UINT32_C(c) c ## U
# elif defined (SIZEOF_LONG) && SIZEOF_LONG == 4
# define UINT32_C(c) c ## UL
# else
# define UINT32_C(c) c ## U
# endif
#endif
#ifndef UINT64_C
# if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
# define UINT64_C(c) c ## UL
# elif defined (SIZEOF_INT) && SIZEOF_INT == 8
# define UINT64_C(c) c ## U
# else
# define UINT64_C(c) c ## ULL
# endif
#endif
#ifndef INT64_C
# if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
# define INT64_C(c) c ## L
# elif defined (SIZEOF_INT) && SIZEOF_INT == 8
# define INT64_C(c) c
# else
# define INT64_C(c) c ## LL
# endif
#endif
#ifndef __cplusplus
# if defined(HAVE_STDBOOL_H)
# include <stdbool.h>
# else
/* ISO/IEC 9899:1999 <stdbool.h> missing -- enabling workaround */
# define false 0
# define true 1
# define bool uint8_t
# endif /*HAVE_STDBOOL_H*/
#endif /*C++*/
/* some GCC optimizations -- gcc 2.5+ */
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
#define GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((format (printf, format_idx, arg_idx)))
#define GNUC_SCANF( format_idx, arg_idx ) \
__attribute__((format (scanf, format_idx, arg_idx)))
#define GNUC_FORMAT( arg_idx ) \
__attribute__((format_arg (arg_idx)))
#define GNUC_NORETURN \
__attribute__((noreturn))
#define GNUC_CONST \
__attribute__((const))
#define GNUC_UNUSED \
__attribute__((unused))
#define GNUC_PACKED \
__attribute__((packed))
#else /* !__GNUC__ */
#define GNUC_PRINTF( format_idx, arg_idx )
#define GNUC_SCANF( format_idx, arg_idx )
#define GNUC_FORMAT( arg_idx )
#define GNUC_NORETURN
#define GNUC_CONST
#define GNUC_UNUSED
#define GNUC_PACKED
#endif /* !__GNUC__ */
#if defined(__GNUC__)
/* for GCC we try to use GNUC_PACKED */
# define PRAGMA_BEGIN_PACKED
# define PRAGMA_END_PACKED
#elif defined(HAVE_ISOC99_PRAGMA)
/* should work with most EDG-frontend based compilers */
# define PRAGMA_BEGIN_PACKED _Pragma("pack(1)")
# define PRAGMA_END_PACKED _Pragma("pack()")
#else /* neither gcc nor _Pragma() available... */
/* ...so let's be naive and hope the regression testsuite is run... */
# define PRAGMA_BEGIN_PACKED
# define PRAGMA_END_PACKED
#endif
/*
* user directed static branch prediction gcc 2.96+
*/
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
# define GNUC_LIKELY(x) __builtin_expect((x),true)
# define GNUC_UNLIKELY(x) __builtin_expect((x),false)
#else
# define GNUC_LIKELY(x) (x)
# define GNUC_UNLIKELY(x) (x)
#endif
#ifndef NULL
# define NULL ((void*) 0)
#endif
/* our own offsetof()-like macro */
#define __cd_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
/*!
\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.
Note: the fields in this structure are BCD encoded. Use
cdio_to_bcd8() or cdio_from_bcd8() to convert an integer into or
out of this format. The format specifier %x (not %d) can be used
if you need to format or print values in this structure.
@see lba_t
*/
PRAGMA_BEGIN_PACKED
struct msf_s {
uint8_t m, s, f; /* BCD encoded! */
} GNUC_PACKED;
PRAGMA_END_PACKED
typedef struct msf_s msf_t;
#define msf_t_SIZEOF 3
/*!
\brief UTF-8 char definition
Type to denote UTF-8 strings.
*/
typedef char cdio_utf8_t;
typedef enum {
nope = 0,
yep = 1,
dunno = 2
} bool_3way_t;
/* type used for bit-fields in structs (1 <= bits <= 8) */
#if defined(__GNUC__)
/* this is strict ISO C99 which allows only 'unsigned int', 'signed
int' and '_Bool' explicitly as bit-field type */
typedef unsigned int bitfield_t;
#else
/* other compilers might increase alignment requirements to match the
'unsigned int' type -- fixme: find out how unalignment accesses can
be pragma'ed on non-gcc compilers */
typedef uint8_t bitfield_t;
#endif
/*! The type of a Logical Block Address. We allow for an lba to be
negative to be consistent with an lba, although I'm not sure this
this is possible.
*/
typedef int32_t lba_t;
/*! The type of a Logical Sector Number. Note that an lba can be negative
and the MMC3 specs allow for a conversion of a negative lba.
@see msf_t
*/
typedef int32_t lsn_t;
/* Address in either MSF or logical format */
union cdio_cdrom_addr
{
msf_t msf;
lba_t lba;
};
/*! The type of a track number 0..99. */
typedef uint8_t track_t;
/*! The type of a session number 0..99. */
typedef uint8_t session_t;
/*!
Constant for invalid session number
*/
#define CDIO_INVALID_SESSION 0xFF
/*!
Constant for invalid LBA. It is 151 less than the most negative
LBA -45150. This provide slack for the 150-frame offset in
LBA to LSN 150 conversions
*/
#define CDIO_INVALID_LBA -45301
/*!
Constant for invalid LSN
*/
#define CDIO_INVALID_LSN CDIO_INVALID_LBA
/*!
Number of ASCII bytes in a media catalog number (MCN).
*/
#define CDIO_MCN_SIZE 13
/*!
Type to hold ASCII bytes in a media catalog number (MCN).
We include an extra 0 byte so these can be used as C strings.
*/
typedef char cdio_mcn_t[CDIO_MCN_SIZE+1];
/*!
Number of ASCII bytes in International Standard Recording Codes (ISRC)
*/
#define CDIO_ISRC_SIZE 12
/*!
Type to hold ASCII bytes in a media catalog number (MCN).
We include an extra 0 byte so these can be used as C strings.
*/
typedef char cdio_isrc_t[CDIO_ISRC_SIZE+1];
typedef int cdio_fs_anal_t;
/*!
track flags
Q Sub-channel Control Field (4.2.3.3)
*/
typedef enum {
CDIO_TRACK_FLAG_NONE = 0x00, /**< no flags set */
CDIO_TRACK_FLAG_PRE_EMPHASIS = 0x01, /**< audio track recorded with
pre-emphasis */
CDIO_TRACK_FLAG_COPY_PERMITTED = 0x02, /**< digital copy permitted */
CDIO_TRACK_FLAG_DATA = 0x04, /**< data track */
CDIO_TRACK_FLAG_FOUR_CHANNEL_AUDIO = 0x08, /**< 4 audio channels */
CDIO_TRACK_FLAG_SCMS = 0x10 /**< SCMS (5.29.2.7) */
} cdio_track_flag;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __CDIO_TYPES_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

171
include/cdio/udf.h Normal file
View File

@@ -0,0 +1,171 @@
/*
$Id: udf.h,v 1.22 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file udf.h
*
* \brief The top-level interface header for libudf: UDF filesystem
* library; applications include this.
*
*/
#ifndef UDF_H
#define UDF_H
#include <cdio/cdio.h>
#include <cdio/ecma_167.h>
#include <cdio/posix.h>
typedef uint16_t partition_num_t;
/** Opaque structures. */
typedef struct udf_s udf_t;
typedef struct udf_file_s udf_file_t;
typedef struct udf_dirent_s udf_dirent_t;
/**
Imagine the below a \#define'd value rather than distinct values of
an enum.
*/
typedef enum {
UDF_BLOCKSIZE = 2048
} udf_enum1_t;
/** This variable is trickery to force the above enum symbol value to
be recorded in debug symbol tables. It is used to allow one refer
to above enumeration values in a debugger and debugger
expressions */
extern udf_enum1_t debug_udf_enum1;
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*!
Close UDF and free resources associated with p_udf.
*/
bool udf_close (udf_t *p_udf);
/*!
Seek to a position i_start and then read i_blocks. Number of
blocks read is returned. One normally expects the return to be
equal to i_blocks.
*/
driver_return_code_t udf_read_sectors (const udf_t *p_udf, void *ptr,
lsn_t i_start, long int i_blocks);
/*!
Open an UDF for reading. Maybe in the future we will have
a mode. NULL is returned on error.
Caller must free result - use udf_close for that.
*/
udf_t *udf_open (const char *psz_path);
/*!
Return the partition number of the the opened udf handle. -1
Is returned if we have an error.
*/
int16_t udf_get_part_number(const udf_t *p_udf);
/*!
Get the root in p_udf. If b_any_partition is false then
the root must be in the given partition.
NULL is returned if the partition is not found or a root is not found or
there is on error.
Caller must free result - use udf_file_free for that.
*/
udf_dirent_t *udf_get_root (udf_t *p_udf, bool b_any_partition,
partition_num_t i_partition);
/**
* Gets the Volume Identifier string, in 8bit unicode (latin-1)
* psz_volid, place to put the string
* i_volid_size, size of the buffer volid points to
* returns the size of buffer needed for all data
*/
int udf_get_volume_id(udf_t *p_udf, /*out*/ char *psz_volid,
unsigned int i_volid);
/**
* Gets the Volume Set Identifier, as a 128-byte dstring (not decoded)
* WARNING This is not a null terminated string
* volsetid, place to put the data
* volsetid_size, size of the buffer volsetid points to
* the buffer should be >=128 bytes to store the whole volumesetidentifier
* returns the size of the available volsetid information (128)
* or 0 on error
*/
int udf_get_volumeset_id(udf_t *p_udf, /*out*/ uint8_t *volsetid,
unsigned int i_volsetid);
/*!
Return a file pointer matching pzz_name.
*/
udf_dirent_t *udf_fopen(udf_dirent_t *p_udf_root, const char *psz_name);
/*! udf_mode_string - fill in string PSZ_STR with an ls-style ASCII
representation of the i_mode. PSZ_STR is returned.
10 characters are stored in PSZ_STR; a terminating null byte is added.
The characters stored in PSZ_STR are:
0 File type. 'd' for directory, 'c' for character
special, 'b' for block special, 'm' for multiplex,
'l' for symbolic link, 's' for socket, 'p' for fifo,
'-' for regular, '?' for any other file type
1 'r' if the owner may read, '-' otherwise.
2 'w' if the owner may write, '-' otherwise.
3 'x' if the owner may execute, 's' if the file is
set-user-id, '-' otherwise.
'S' if the file is set-user-id, but the execute
bit isn't set.
4 'r' if group members may read, '-' otherwise.
5 'w' if group members may write, '-' otherwise.
6 'x' if group members may execute, 's' if the file is
set-group-id, '-' otherwise.
'S' if it is set-group-id but not executable.
7 'r' if any user may read, '-' otherwise.
8 'w' if any user may write, '-' otherwise.
9 'x' if any user may execute, 't' if the file is "sticky"
(will be retained in swap space after execution), '-'
otherwise.
'T' if the file is sticky but not executable. */
char *udf_mode_string (mode_t i_mode, char *psz_str);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#include <cdio/udf_time.h>
#include <cdio/udf_file.h>
#endif /*UDF_H*/

117
include/cdio/udf_file.h Normal file
View File

@@ -0,0 +1,117 @@
/*
$Id: udf_file.h,v 1.12 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2005, 2006, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/**
* \file udf_file.h
*
* \brief Routines involving UDF file operations
*
*/
#ifndef UDF_FILE_H
#define UDF_FILE_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
Return the file id descriptor of the given file.
*/
bool udf_get_fileid_descriptor(const udf_dirent_t *p_udf_dirent,
/*out*/ udf_fileid_desc_t *p_udf_fid);
/**
Return the name of the file
*/
const char *udf_get_filename(const udf_dirent_t *p_udf_dirent);
/**
Return the name of the file
*/
bool udf_get_file_entry(const udf_dirent_t *p_udf_dirent,
/*out*/ udf_file_entry_t *p_udf_fe);
/**
Return the number of hard links of the file. Return 0 if error.
*/
uint16_t udf_get_link_count(const udf_dirent_t *p_udf_dirent);
/**
Return the file length the file. Return 2147483647L if error.
*/
uint64_t udf_get_file_length(const udf_dirent_t *p_udf_dirent);
/**
Returns a POSIX mode for a given p_udf_dirent.
*/
mode_t udf_get_posix_filemode(const udf_dirent_t *p_udf_dirent);
/**
Return the next subdirectory.
*/
udf_dirent_t *udf_opendir(const udf_dirent_t *p_udf_dirent);
/**
Attempts to read up to count bytes from UDF directory entry
p_udf_dirent into the buffer starting at buf. buf should be a
multiple of UDF_BLOCKSIZE bytes. Reading continues after the
point at which we last read or from the beginning the first time.
If count is zero, read() returns zero and has no other results. If
count is greater than SSIZE_MAX, the result is unspecified.
If there is an error, cast the result to driver_return_code_t for
the specific error code.
*/
/**
Attempts to read up to count bytes from file descriptor fd into
the buffer starting at buf.
If count is zero, read() returns zero and has no other results. If
count is greater than SSIZE_MAX, the result is unspecified.
*/
ssize_t udf_read_block(const udf_dirent_t *p_udf_dirent,
void * buf, size_t count);
/**
Advances p_udf_direct to the the next directory entry in the
pointed to by p_udf_dir. It also returns this as the value. NULL
is returned on reaching the end-of-file or if an error. Also
p_udf_dirent is free'd. If the end of is not reached the caller
must call udf_dirent_free() with p_udf_dirent when done with it to
release resources.
*/
udf_dirent_t *udf_readdir(udf_dirent_t *p_udf_dirent);
/**
free free resources associated with p_udf_dirent.
*/
bool udf_dirent_free(udf_dirent_t *p_udf_dirent);
/**
Return true if the file is a directory.
*/
bool udf_is_dir(const udf_dirent_t *p_udf_dirent);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /*UDF_FILE_H*/

80
include/cdio/udf_time.h Normal file
View File

@@ -0,0 +1,80 @@
/*
$Id: udf_time.h,v 1.5 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file udf_time.h
*
* \brief UDF time conversion and access files.
*
*/
#ifndef UDF_TIME_H
#define UDF_TIME_H
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*!
Return the access time of the file.
*/
time_t udf_get_access_time(const udf_dirent_t *p_udf_dirent);
/*!
Return the attribute (most recent create or access) time of the file
*/
time_t udf_get_attribute_time(const udf_dirent_t *p_udf_dirent);
/*!
Return the modification time of the file.
*/
time_t udf_get_modification_time(const udf_dirent_t *p_udf_dirent);
/*!
Return the access timestamp of the file
*/
udf_timestamp_t *udf_get_access_timestamp(const udf_dirent_t *p_udf_dirent);
/*!
Return the modification timestamp of the file
*/
udf_timestamp_t *udf_get_modification_timestamp(const udf_dirent_t
*p_udf_dirent);
/*!
Return the attr timestamp of the file
*/
udf_timestamp_t *udf_get_attr_timestamp(const udf_dirent_t *p_udf_dirent);
/*!
Convert a UDF timestamp to a time_t. If microseconds are desired,
use dest_usec. The return value is the same as dest. */
time_t *udf_stamp_to_time(time_t *dest, long int *dest_usec,
const udf_timestamp_t src);
udf_timestamp_t *udf_timespec_to_stamp(const struct timespec ts,
udf_timestamp_t *dest);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /*UDF_TIME_H*/

92
include/cdio/utf8.h Normal file
View File

@@ -0,0 +1,92 @@
/*
$Id: utf8.h,v 1.2 2008/03/25 15:59:09 karl Exp $
Copyright (C) 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2006 Burkhard Plaum <plaum@ipf.uni-stuttgart.de>
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/* UTF-8 support */
#include <cdio/types.h>
/** \brief Opaque characterset converter
*/
typedef struct cdio_charset_coverter_s cdio_charset_coverter_t;
/** \brief Create a charset converter
* \param src_charset Source charset
* \param dst_charset Destination charset
* \returns A newly allocated charset converter
*/
cdio_charset_coverter_t *
cdio_charset_converter_create(const char * src_charset,
const char * dst_charset);
/** \brief Destroy a characterset converter
* \param cnv A characterset converter
*/
void cdio_charset_converter_destroy(cdio_charset_coverter_t*cnv);
/** \brief Convert a string from one character set to another
* \param cnv A charset converter
* \param src Source string
* \param src_len Length of source string
* \param dst Returns destination string
* \param dst_len If non NULL, returns the length of the destination string
* \returns true if conversion was sucessful, false else.
*
* The destination string must be freed by the caller with free().
* If you pass -1 for src_len, strlen() will be used.
*/
bool cdio_charset_convert(cdio_charset_coverter_t*cnv,
char * src, int src_len,
char ** dst, int * dst_len);
/** \brief Convert a string from UTF-8 to another charset
* \param src Source string (0 terminated)
* \param dst Returns destination string
* \param dst_len If non NULL, returns the length of the destination string
* \param dst_charset The characterset to convert to
* \returns true if conversion was sucessful, false else.
*
* This is a convenience function, which creates a charset converter,
* converts one string and destroys the charset converter.
*/
bool cdio_charset_from_utf8(cdio_utf8_t * src, char ** dst,
int * dst_len, const char * dst_charset);
/** \brief Convert a string from another charset to UTF-8
* \param src Source string
* \param src_len Length of the source string
* \param dst Returns destination string (0 terminated)
* \param src_charset The characterset to convert from
* \returns true if conversion was sucessful, false else.
*
* This is a convenience function, which creates a charset converter,
* converts one string and destroys the charset converter. If you pass -1
* for src_len, strlen() will be used.
*/
bool cdio_charset_to_utf8(char *src, size_t src_len, cdio_utf8_t **dst,
const char * src_charset);

117
include/cdio/util.h Normal file
View File

@@ -0,0 +1,117 @@
/*
$Id: util.h,v 1.12 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 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
the Free Software Foundation, either version 3 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, see <http://www.gnu.org/licenses/>.
*/
#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
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#undef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#undef IN
#define IN(x, low, high) ((x) >= (low) && (x) <= (high))
#undef CLAMP
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
static inline uint32_t
_cdio_len2blocks (uint32_t i_len, uint16_t i_blocksize)
{
uint32_t i_blocks;
i_blocks = i_len / (uint32_t) i_blocksize;
if (i_len % i_blocksize)
i_blocks++;
return i_blocks;
}
/* round up to next block boundary */
static inline unsigned
_cdio_ceil2block (unsigned offset, uint16_t i_blocksize)
{
return _cdio_len2blocks (offset, i_blocksize) * i_blocksize;
}
static inline unsigned int
_cdio_ofs_add (unsigned offset, unsigned length, uint16_t i_blocksize)
{
if (i_blocksize - (offset % i_blocksize) < length)
offset = _cdio_ceil2block (offset, i_blocksize);
offset += length;
return offset;
}
static inline const char *
_cdio_bool_str (bool b)
{
return b ? "yes" : "no";
}
#ifdef __cplusplus
extern "C" {
#endif
void *
_cdio_memdup (const void *mem, size_t count);
char *
_cdio_strdup_upper (const char str[]);
void
_cdio_strfreev(char **strv);
size_t
_cdio_strlenv(char **str_array);
char **
_cdio_strsplit(const char str[], char delim);
uint8_t cdio_to_bcd8(uint8_t n);
uint8_t cdio_from_bcd8(uint8_t p);
void cdio_follow_symlink (const char * src, char * dst);
#ifdef __cplusplus
}
#endif
#endif /* __CDIO_UTIL_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/

12
include/cdio/version.h.in Normal file
View File

@@ -0,0 +1,12 @@
/* $Id: version.h.in,v 1.6 2005/01/29 20:54:20 rocky Exp $ */
/** \file version.h
*
* \brief A file containing the libcdio package version
* number (@LIBCDIO_VERSION_NUM@) and OS build name.
*/
/*! CDIO_VERSION can as a string in programs to show what version is used. */
#define CDIO_VERSION "@VERSION@ @build@"
/*! LIBCDIO_VERSION_NUM can be used for testing in the C preprocessor */
#define LIBCDIO_VERSION_NUM @LIBCDIO_VERSION_NUM@

179
include/cdio/xa.h Normal file
View File

@@ -0,0 +1,179 @@
/*
$Id: xa.h,v 1.19 2008/03/25 15:59:10 karl Exp $
Copyright (C) 2003, 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
See also iso9660.h by Eric Youngdale (1993) and in cdrtools. These are
Copyright 1993 Yggdrasil Computing, Incorporated
Copyright (c) 1999,2000 J. Schilling
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 3 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, see <http://www.gnu.org/licenses/>.
*/
/*!
\file xa.h
\brief Things related to the ISO-9660 XA (Extended Attributes) format
Applications will probably not include this directly but via
the iso9660.h header.
*/
#ifndef __CDIO_XA_H__
#define __CDIO_XA_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*! An enumeration for some of the XA_* \#defines below. This isn't
really an enumeration one would really use in a program it is to
be helpful in debuggers where wants just to refer to the XA_*
names and get something.
*/
typedef enum {
ISO_XA_MARKER_OFFSET = 1024,
XA_PERM_RSYS = 0x0001, /**< System Group Read */
XA_PERM_XSYS = 0x0004, /**< System Group Execute */
XA_PERM_RUSR = 0x0010, /**< User (owner) Read */
XA_PERM_XUSR = 0x0040, /**< User (owner) Execute */
XA_PERM_RGRP = 0x0100, /**< Group Read */
XA_PERM_XGRP = 0x0400, /**< Group Execute */
XA_PERM_ROTH = 0x1000, /**< Other (world) Read */
XA_PERM_XOTH = 0x4000, /**< Other (world) Execute */
XA_ATTR_MODE2FORM1 = (1 << 11),
XA_ATTR_MODE2FORM2 = (1 << 12),
XA_ATTR_INTERLEAVED = (1 << 13),
XA_ATTR_CDDA = (1 << 14),
XA_ATTR_DIRECTORY = (1 << 15),
XA_PERM_ALL_READ = (XA_PERM_RUSR | XA_PERM_RSYS | XA_PERM_RGRP),
XA_PERM_ALL_EXEC = (XA_PERM_XUSR | XA_PERM_XSYS | XA_PERM_XGRP),
XA_PERM_ALL_ALL = (XA_PERM_ALL_READ | XA_PERM_ALL_EXEC),
XA_FORM1_DIR = (XA_ATTR_DIRECTORY | XA_ATTR_MODE2FORM1 | XA_PERM_ALL_ALL),
XA_FORM1_FILE = (XA_ATTR_MODE2FORM1 | XA_PERM_ALL_ALL),
XA_FORM2_FILE = (XA_ATTR_MODE2FORM2 | XA_PERM_ALL_ALL)
} xa_misc_enum_t;
extern const char ISO_XA_MARKER_STRING[sizeof("CD-XA001")-1];
#define ISO_XA_MARKER_STRING "CD-XA001"
/*! \brief "Extended Architecture" according to 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_s
{
uint16_t group_id; /**< 0 */
uint16_t user_id; /**< 0 */
uint16_t attributes; /**< XA_ATTR_ */
char signature[2]; /**< { 'X', 'A' } */
uint8_t filenum; /**< file number, see also XA subheader */
uint8_t reserved[5]; /**< zero */
} GNUC_PACKED iso9660_xa_t;
/*!
Returns POSIX mode bitstring for a given file.
*/
posix_mode_t iso9660_get_posix_filemode_from_xa(uint16_t i_perms);
/*!
Returns a string interpreting the extended attribute xa_attr.
For example:
\verbatim
d---1xrxrxr
---2--r-r-r
-a--1xrxrxr
\endverbatim
A description of the characters in the string follows.
The 1st character is either "d" if the entry is a directory, or "-" if not
The 2nd character is either "a" if the entry is CDDA (audio), or "-" if not
The 3rd character is either "i" if the entry is interleaved, or "-" if not
The 4th character is either "2" if the entry is mode2 form2 or "-" if not
The 5th character is either "1" if the entry is mode2 form1 or "-" if not
Note that an entry will either be in mode2 form1 or mode form2. That
is you will either see "2-" or "-1" in the 4th & 5th positions.
The 6th and 7th characters refer to permissions for a user while the
the 8th and 9th characters refer to permissions for a group while, and
the 10th and 11th characters refer to permissions for everyone.
In each of these pairs the first character (6, 8, 10) is "x" if the
entry is executable. For a directory this means the directory is
allowed to be listed or "searched".
The second character of a pair (7, 9, 11) is "r" if the entry is allowed
to be read.
*/
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);
#ifdef __cplusplus
}
/** The below variables are trickery to force the above enum symbol
values to be recorded in debug symbol tables. They are used to
allow one to refer to the enumeration value names in the typedefs
above in a debugger and debugger expressions.
*/
extern xa_misc_enum_t debugger_xa_misc_enum;
#endif /* __cplusplus */
#endif /* __CDIO_XA_H__ */
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
* indent-tabs-mode: nil
* End:
*/