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

28
.gitignore vendored Normal file
View File

@@ -0,0 +1,28 @@
/*~
/COPYING
/Makefile
/Makefile.in
/aclocal.m4
/autom4te.cache
/compile
/config.guess
/config.h
/config.h.in
/config.log
/config.rpath
/config.status
/config.sub
/configure
/depcomp
/install-sh
/libcdio++.pc
/libcdio.pc
/libcdio_cdda.pc
/libcdio_paranoia.pc
/libiso9660++.pc
/libiso9660.pc
/libtool
/libudf.pc
/ltmain.sh
/missing
/stamp-h1

237
INSTALL Normal file
View File

@@ -0,0 +1,237 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2007 Free Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
6. Often, you can also type `make uninstall' to remove the installed
files again.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

4
MSVC/README Normal file
View File

@@ -0,0 +1,4 @@
Files in this directory are for compiling with Microsoft Visual C.
They are courtesy of John Oseman (mog).
$Id: README,v 1.1 2004/10/30 14:18:17 rocky Exp $

365
MSVC/cd-info.vcproj Normal file
View File

@@ -0,0 +1,365 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="cd-info"
ProjectGUID="{8E55CFDB-5E38-4A07-84F8-36939C825735}"
RootNamespace="cd-info"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
<Platform
Name="Xbox"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="include;src;lib;lib\XBOX"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
ObjectFile="$(ProjectName)/$(IntDir)/"
ProgramDataBaseFileName="$(ProjectName)/$(IntDir)/vc70.pdb"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libcdiod.lib winmm.lib"
OutputFile="$(ProjectName)/$(OutDir)/cd-info.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="Debug"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(ProjectName)/$(OutDir)/cd-info.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Xbox"
ConfigurationType="1">
<Tool
Name="VCCLCompilerTool"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="XboxDeploymentTool"/>
<Tool
Name="XboxImageTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="include;src;lib;lib\XBOX"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
ObjectFile="$(ProjectName)/$(IntDir)/"
ProgramDataBaseFileName="$(ProjectName)/$(IntDir)/vc70.pdb"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libcdio.lib winmm.lib"
OutputFile="$(ProjectName)/$(OutDir)/cd-info.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="Release"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(ProjectName)/$(OutDir)/$(ProjectName).pdb"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Xbox"
ConfigurationType="1">
<Tool
Name="VCCLCompilerTool"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="XboxDeploymentTool"/>
<Tool
Name="XboxImageTool"/>
</Configuration>
<Configuration
Name="XBOX_Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="include;src;lib;lib\XBOX"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libcdiod.lib winmm.lib"
OutputFile="$(OutDir)/cd-info.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="Debug"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/cd-info.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="XBOX_Debug|Xbox"
OutputDirectory="$(ProjectName)\$(ConfigurationName)"
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)"
ConfigurationType="1">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="include;src;lib;lib\XBOX"
PreprocessorDefinitions="_XBOX;_DEBUG;_CONSOLE;HAVE_CONFIG_H"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
ObjectFile="$(IntDir)/"
ProgramDataBaseFileName="$(IntDir)/vc70.pdb"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="xapilibd.lib d3d8d.lib xgraphicsd.lib dsoundd.lib dmusic.lib xnetd.lib xboxkrnl.lib libcdiod.lib"
OutputFile="$(OutDir)/$(ProjectName).exe"
AdditionalLibraryDirectories="XBOX_Debug"
IgnoreDefaultLibraryNames=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="XboxDeploymentTool"/>
<Tool
Name="XboxImageTool"
StackSize="65536"
IncludeDebugInfo="TRUE"
NoLibWarn="TRUE"/>
</Configuration>
<Configuration
Name="XBOX_Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="include;src;lib;lib\XBOX"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="libcdio.lib winmm.lib"
OutputFile="$(OutDir)/cd-info.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="Release"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="XBOX_Release|Xbox"
OutputDirectory="$(ProjectName)\$(ConfigurationName)"
IntermediateDirectory="$(ProjectName)\$(ConfigurationName)"
ConfigurationType="1">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="include;src;lib;lib\XBOX"
PreprocessorDefinitions="_XBOX;NDEBUG;_CONSOLE;HAVE_CONFIG_H"
BasicRuntimeChecks="0"
RuntimeLibrary="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="xapilib.lib d3d8.lib d3dx8.lib xgraphics.lib dsound.lib dmusic.lib xacteng.lib xsndtrk.lib xvoice.lib xonlines.lib xboxkrnl.lib libcdio.lib "
AdditionalLibraryDirectories="XBOX_Release"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="XboxDeploymentTool"/>
<Tool
Name="XboxImageTool"
StackSize="65536"
NoLibWarn="TRUE"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\src\cd-info.c">
</File>
<File
RelativePath=".\src\findme.c">
</File>
<File
RelativePath=".\src\util.c">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\src\findme.h">
</File>
<File
RelativePath=".\src\util.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

188
MSVC/config.h Normal file
View File

@@ -0,0 +1,188 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* compiler does lsbf in struct bitfields */
#undef BITFIELD_LSBF
/* Define 1 if you are compiling using cygwin */
#undef CYGWIN
/* what to put between the brackets for empty arrays */
#define EMPTY_ARRAY_SIZE
/* Define 1 if you have BSDI-type CD-ROM support */
#undef HAVE_BSDI_CDROM
/* Define to 1 if you have the `bzero' function. */
#undef HAVE_BZERO
/* Define this if you have libcddb installed */
#undef HAVE_CDDB
/* Define to 1 if you have the <CoreFoundation/CFBase.h> header file. */
#undef HAVE_COREFOUNDATION_CFBASE_H
/* Define 1 if you have Darwin OS X-type CD-ROM support */
#undef HAVE_DARWIN_CDROM
/* Define if time.h defines extern long timezone and int daylight vars. */
#undef HAVE_DAYLIGHT
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <dvd.h> header file. */
#undef HAVE_DVD_H
/* Define to 1 if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define 1 if you have FreeBSD CD-ROM support */
#undef HAVE_FREEBSD_CDROM
/* Define to 1 if you have the <glob.h> header file. */
#undef HAVE_GLOB_H
/* Define if you have the iconv() function. */
#undef HAVE_ICONV
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <IOKit/IOKitLib.h> header file. */
#undef HAVE_IOKIT_IOKITLIB_H
/* Supports ISO _Pragma() macro */
#undef HAVE_ISOC99_PRAGMA
/* Define 1 if you want ISO-9660 Joliet extension support. You must have also
libiconv installed to get Joliet extension support. */
#undef HAVE_JOLIET
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
#undef HAVE_LANGINFO_CODESET
/* Define to 1 if you have the `nsl' library (-lnsl). */
#undef HAVE_LIBNSL
/* Define to 1 if you have the `socket' library (-lsocket). */
#undef HAVE_LIBSOCKET
/* Define 1 if you have Linux-type CD-ROM support */
#undef HAVE_LINUX_CDROM
/* Define to 1 if you have the <linux/cdrom.h> header file. */
#undef HAVE_LINUX_CDROM_H
/* Define 1 if timeout is in cdrom_generic_command struct */
#undef HAVE_LINUX_CDROM_TIMEOUT
/* Define to 1 if you have the <linux/version.h> header file. */
#undef HAVE_LINUX_VERSION_H
/* Define to 1 if you have the `memcpy' function. */
#define HAVE_MEMCPY 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF
/* Define 1 if you have Solaris CD-ROM support */
#undef HAVE_SOLARIS_CDROM
/* Define to 1 if you have the <stdbool.h> header file. */
#undef HAVE_STDBOOL_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/cdio.h> header file. */
#undef HAVE_SYS_CDIO_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if struct tm has the tm_gmtoff member. */
#undef HAVE_TM_GMTOFF
/* Define if time.h defines extern extern char *tzname[2] variable */
#undef HAVE_TZNAME
/* Define to 1 if you have the `tzset' function. */
#undef HAVE_TZSET
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define this if you have libvcdinfo installed */
#undef HAVE_VCDINFO
/* Define to 1 if you have the `vsnprintf' function. */
#undef HAVE_VSNPRINTF
/* Define 1 if you have MinGW CD-ROM support */
#define HAVE_WIN32_CDROM 1
/* Define as const if the declaration of iconv() needs const. */
#undef ICONV_CONST
/* Define 1 if you are compiling using MinGW */
#undef MINGW32
/* Name of package */
#define PACKAGE "libcdio"
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#define PACKAGE_NAME "libcdio"
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#define PACKAGE_VERSION 1
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1"
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#define inline

39
MSVC/libcdio.sln Normal file
View File

@@ -0,0 +1,39 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcdio", "libcdio.vcproj", "{E465056A-C6F3-45EE-B791-CAF8E0CE629D}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cd-info", "cd-info.vcproj", "{8E55CFDB-5E38-4A07-84F8-36939C825735}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
XBOX_Debug = XBOX_Debug
XBOX_Release = XBOX_Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{E465056A-C6F3-45EE-B791-CAF8E0CE629D}.Debug.ActiveCfg = Debug|Win32
{E465056A-C6F3-45EE-B791-CAF8E0CE629D}.Debug.Build.0 = Debug|Win32
{E465056A-C6F3-45EE-B791-CAF8E0CE629D}.Release.ActiveCfg = Release|Win32
{E465056A-C6F3-45EE-B791-CAF8E0CE629D}.Release.Build.0 = Release|Win32
{E465056A-C6F3-45EE-B791-CAF8E0CE629D}.XBOX_Debug.ActiveCfg = XBOX_Debug|Xbox
{E465056A-C6F3-45EE-B791-CAF8E0CE629D}.XBOX_Debug.Build.0 = XBOX_Debug|Xbox
{E465056A-C6F3-45EE-B791-CAF8E0CE629D}.XBOX_Release.ActiveCfg = XBOX_Release|Xbox
{E465056A-C6F3-45EE-B791-CAF8E0CE629D}.XBOX_Release.Build.0 = XBOX_Release|Xbox
{8E55CFDB-5E38-4A07-84F8-36939C825735}.Debug.ActiveCfg = Debug|Win32
{8E55CFDB-5E38-4A07-84F8-36939C825735}.Debug.Build.0 = Debug|Win32
{8E55CFDB-5E38-4A07-84F8-36939C825735}.Release.ActiveCfg = Release|Win32
{8E55CFDB-5E38-4A07-84F8-36939C825735}.Release.Build.0 = Release|Win32
{8E55CFDB-5E38-4A07-84F8-36939C825735}.XBOX_Debug.ActiveCfg = XBOX_Debug|Xbox
{8E55CFDB-5E38-4A07-84F8-36939C825735}.XBOX_Debug.Build.0 = XBOX_Debug|Xbox
{8E55CFDB-5E38-4A07-84F8-36939C825735}.XBOX_Release.ActiveCfg = XBOX_Release|Xbox
{8E55CFDB-5E38-4A07-84F8-36939C825735}.XBOX_Release.Build.0 = XBOX_Release|Xbox
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

547
MSVC/libcdio.vcproj Normal file
View File

@@ -0,0 +1,547 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="libcdio"
ProjectGUID="{E465056A-C6F3-45EE-B791-CAF8E0CE629D}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
<Platform
Name="Xbox"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="lib\XBOX;include;lib"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_H"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/$(ProjectName)d.lib"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Xbox"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="lib\XBOX;include;lib"
PreprocessorDefinitions="_XBOX;_DEBUG;_CONSOLE;HAVE_CONFIG_H"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/$(ProjectName)d.lib"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="lib\XBOX;include;lib"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_H"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Xbox"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="lib\XBOX;include;lib"
PreprocessorDefinitions="_XBOX;NDEBUG;_CONSOLE;HAVE_CONFIG_H"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
</Configuration>
<Configuration
Name="XBOX_Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/libcdio.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/libcdio.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="XBOX_Debug|Xbox"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="lib\XBOX;include;lib"
PreprocessorDefinitions="_XBOX;_DEBUG;_CONSOLE;HAVE_CONFIG_H"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"
OutputFile="$(OutDir)/$(ProjectName)d.lib"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
</Configuration>
<Configuration
Name="XBOX_Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="3"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/libcdio.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/libcdio.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="XBOX_Release|Xbox"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="lib\XBOX;include;lib"
PreprocessorDefinitions="_XBOX;NDEBUG;_CONSOLE;HAVE_CONFIG_H"
MinimalRebuild="TRUE"
BasicRuntimeChecks="0"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLibrarianTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\lib\_cdio_bsdi.c">
</File>
<File
RelativePath=".\lib\_cdio_generic.c">
</File>
<File
RelativePath=".\lib\_cdio_linux.c">
</File>
<File
RelativePath=".\lib\_cdio_osx.c">
</File>
<File
RelativePath=".\lib\_cdio_stdio.c">
</File>
<File
RelativePath=".\lib\_cdio_stdio.h">
</File>
<File
RelativePath=".\lib\_cdio_stream.c">
</File>
<File
RelativePath=".\lib\_cdio_stream.h">
</File>
<File
RelativePath=".\lib\_cdio_sunos.c">
</File>
<File
RelativePath=".\lib\bytesex.h">
</File>
<File
RelativePath=".\lib\bytesex_asm.h">
</File>
<File
RelativePath=".\lib\cd_types.c">
</File>
<File
RelativePath=".\lib\cdio.c">
</File>
<File
RelativePath=".\lib\cdio_assert.h">
</File>
<File
RelativePath=".\lib\cdio_private.h">
</File>
<File
RelativePath=".\lib\cdtext.c">
</File>
<File
RelativePath=".\lib\cdtext_private.h">
</File>
<File
RelativePath=".\lib\ds.c">
</File>
<File
RelativePath=".\lib\ds.h">
</File>
<File
RelativePath=".\lib\generic.h">
</File>
<File
RelativePath=".\lib\image.h">
</File>
<File
RelativePath=".\lib\image_common.h">
</File>
<File
RelativePath=".\lib\iso9660.c">
</File>
<File
RelativePath=".\lib\iso9660_fs.c">
</File>
<File
RelativePath=".\lib\iso9660_private.h">
</File>
<File
RelativePath=".\lib\logging.c">
</File>
<File
RelativePath=".\lib\scsi_mmc.c">
</File>
<File
RelativePath=".\lib\scsi_mmc_private.h">
</File>
<File
RelativePath=".\lib\sector.c">
</File>
<File
RelativePath=".\lib\util.c">
</File>
<File
RelativePath=".\lib\xa.c">
</File>
<Filter
Name="MSWindows"
Filter="">
<File
RelativePath=".\lib\MSWindows\win32.c">
</File>
<File
RelativePath=".\lib\MSWindows\win32.h">
</File>
<File
RelativePath=".\lib\MSWindows\win32_ioctl.c">
</File>
</Filter>
<Filter
Name="FreeBSD"
Filter="">
<File
RelativePath=".\lib\FreeBSD\freebsd.c">
</File>
<File
RelativePath=".\lib\FreeBSD\freebsd.h">
</File>
<File
RelativePath=".\lib\FreeBSD\freebsd_cam.c">
</File>
<File
RelativePath=".\lib\FreeBSD\freebsd_ioctl.c">
</File>
</Filter>
<Filter
Name="image"
Filter="">
<File
RelativePath=".\lib\image\bincue.c">
</File>
<File
RelativePath=".\lib\image\cdrdao.c">
</File>
<File
RelativePath=".\lib\image\nrg.c">
</File>
<File
RelativePath=".\lib\image\nrg.h">
</File>
</Filter>
</Filter>
<Filter
Name="Include Files"
Filter="">
<File
RelativePath=".\include\cdio\cd_types.h">
</File>
<File
RelativePath=".\include\cdio\cdio.h">
</File>
<File
RelativePath=".\include\cdio\cdtext.h">
</File>
<File
RelativePath=".\include\cdio\dvd.h">
</File>
<File
RelativePath=".\include\cdio\iso9660.h">
</File>
<File
RelativePath=".\include\cdio\logging.h">
</File>
<File
RelativePath=".\include\cdio\scsi_mmc.h">
</File>
<File
RelativePath=".\include\cdio\sector.h">
</File>
<File
RelativePath=".\include\cdio\types.h">
</File>
<File
RelativePath=".\include\cdio\util.h">
</File>
<File
RelativePath=".\include\cdio\version.h">
</File>
<File
RelativePath=".\include\cdio\xa.h">
</File>
</Filter>
<Filter
Name="XBOX"
Filter="">
<File
RelativePath=".\lib\Xbox\config.h">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\lib\Xbox\inttypes.h">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\lib\Xbox\NTScsi.cpp">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\lib\Xbox\NTScsi.h">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\lib\Xbox\Undocumented.h">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

137
Makefile.am Normal file
View File

@@ -0,0 +1,137 @@
# $Id: Makefile.am,v 1.50 2008/10/25 13:56:15 rocky 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/>.
#
## Process this file with automake to produce Makefile.in
## which configure then turns into a Makefile ...
## which make can then use to produce stuff. Isn't configuration simple?
AUTOMAKE_OPTIONS = dist-bzip2
EXTRA_DIST = \
MSVC/README MSVC/cd-info.vcproj \
MSVC/config.h \
MSVC/libcdio.sln \
MSVC/libcdio.vcproj \
README.libcdio \
THANKS \
example/README \
libcdio.pc.in \
libcdio++.pc.in \
libcdio_cdda.pc.in \
libiso9660.pc.in \
libiso9660++.pc.in \
libudf.pc.in \
package/libcdio.spec.in
SUBDIRS = doc include lib src test example
if BUILD_CD_PARANOIA
paranoiapcs = libcdio_paranoia.pc libcdio_cdda.pc
endif
# pkg-config(1) related rules
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libcdio.pc \
libiso9660.pc \
libudf.pc \
$(paranoiapcs)
if ENABLE_CPP
pkgconfig_DATA += \
libcdio++.pc \
libiso9660++.pc
endif
$(pkgconfig_DATA): config.status
# List of additional files for expanded regression tests
DISTFILES_REGRESSION = tests/monvoisin.nrg tests/monvoisin.right \
tests/svcdgs.nrg tests/svcdgs.nrg \
tests/svcd_ogt_test_ntsc.bin \
tests/svcd_ogt_test_ntsc.cue \
tests/svcd_ogt_test_ntsc.right \
tests/vcd_demo.bin tests/vcd_demo.cue \
tests/vcd_demo.right
REGRESSION_VERSION = 1.1
distdir_regression = ../$(PACKAGE)-$(REGRESSION_VERSION)-tests
test: check
doxygen:
-( cd ${top_srcdir}/doc/doxygen && /bin/sh ${srcdir}/run_doxygen )
dist-regression: distdir-regression
cd $(distdir) && $(AMTAR) chof - tests | GZIP=$(GZIP_ENV) gzip -c >$(distdir_regression).tar.gz
$(am__remove_distdir)
distdir-regression: $(DISTFILES_REGRESSION)
$(am__remove_distdir)
mkdir $(distdir)
@list='$(DISTFILES_REGRESSION)'; for file in $$list; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir_regressoin)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
check_nrg.sh: $(top_builddir)/config.status check_nrg.sh.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
chmod +x config_nrg.sh
check_cue.sh: $(top_builddir)/config.status check_cue.sh.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
chmod +x config_cue.sh
check_iso.sh: $(top_builddir)/config.status check_iso.sh.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
chmod +x config_iso.sh
make-executable:
# cvs2cl
MAINTAINERCLEANFILES = ChangeLog
if MAINTAINER_MODE
.PHONY: ChangeLog
ChangeLog:
( cd $(srcdir); $(CVS2CL) -W 450 --header cvs2cl_header --utc -w -I ChangeLog --usermap cvs2cl_usermap -P --stdout ) > ChangeLog
ACLOCAL_AMFLAGS=-I m4
endif

61
README Normal file
View File

@@ -0,0 +1,61 @@
See README.libcdio for installation instructions.
The libcdio package contains a library for CD-ROM and CD image
access. Applications wishing to be oblivious of the OS- and
device-dependent properties of a CD-ROM or of the specific details of
various CD-image formats may benefit from using this library.
A library for working with ISO-9660 filesystems libiso9660 is
included. A generic interface for issuing MMC (multimedia commands) is
also part of the libcdio library.
Also included is a library for working with ISO-9660 filesystems as is
also the CD-DA error/jitter correction library from cdparanoia
(http://www.xiph.org/paranoia).
Some support for disk image types like CDRWin's BIN/CUE format,
cdrdao's TOC format, and Nero's NRG format are available. Therefore,
applications that use this library also have the ability to read disc
images as though they were CD's.
The library is written in C, however there are OO C++, Perl, Python
and Ruby wrappers to interface to the library. However C++ is the only
one that is bundled with this package, and the interfaces provide only
a subset of the full features of the library.
Also included in the libcdio package are a number of utility programs:
* cd-info - displays CD information: number of tracks, CD-format and
if possible basic information about the format. If libcddb
(http://libcddb.sourceforge.net) is available, the cd-info
program will display CDDB matches on CD-DA discs. And if a
new enough version of libvcdinfo is available (from the
vcdimager project), then cd-info shows basic VCD information.
* cd-read - performs low-level block reading of a CD or CD image,
* iso-info - displays ISO-9660 information from an ISO-9660 image,
* iso-read - extracting files from an ISO-9660 image, a version of the
CD-DA extraction tool cdparanoia which corrects for
CD-ROM jitter, and a simple curses-based CD player,
cdda-player using the analog CD-ROM output.
* cd-paranoia - port of cdparanoia (CD-DA jitter and error correction)
using libcdio back-end CD-reading.
At present, there is no support for writing CD's, nor is there any
support for reading or writing DVDs. For some of these, there are
other libraries (e.g. libdi, libscg, or libdvdread) may be helpful.
Some of the projects using libcdio are the Video CD authoring and
ripping tools VCDImager (http://vcdimager.org), a navigation-capable
Video CD plugin and CD-DA plugins for the media players xine
(http://xinehq.de), videolan's vlc (http://videolan.org), media
players mplayerxp (http://mplayerxp.sourceforge.net/) and gmerlin
(http://gmerlin.sourceforge.net), kiso, a KDE GUI for creating,
extracting and editing ISO-9600 images (http://kiso.sourceforge.net),
and a Samba vfs module that allows exporting a CD without mounting it
(http://ontologistics.net/OpenSource/Samba/index.php).
$Id: README,v 1.13 2006/03/28 14:48:44 rocky Exp $

104
README.libcdio Normal file
View File

@@ -0,0 +1,104 @@
If you check out the source from CVS run
./autogen.sh then follow as below, except you don't need to run
./configure.
To compile the source:
./configure MAKE=gmake
make
make check
make install # may have to do this as root
If you have problems linking libcdio or libiso9660, see the BSD
section. You might also try the option --without-versioned-libs. However
this option does help with the situtation described below so it is
preferred all other things being equal.
If you are debugging libcdio, the libtool and the dynamic libraries
can make things harder. I suggest setting CFLAGS to include
'-fno-inline -g' and using --disable-shared on configure.
VCD dependency:
---------------
One thing that confuses people is the "dependency" on libvcdinfo from
vcdimager, while vcdimager has a dependency on libcdio. This libcdio
dependency on vcdimager is an optional (i.e. not mandatory) dependency,
while the vcdimager dependency right now is mandatory. libvcdinfo is
used only by the utility program cd-info. If you want cd-info to use
the VCD reporting portion and you don't already have vcdimager
installed, build and install libcdio, then vcdimager, then configure
libcdio again and it should find libvcdinfo.
People who make packages might consider making two packages, a libcdio
package with just the libraries (and no dependency on libvcdinfo) and
a libcdio-utils which contains cd-info and iso-info, cd-read,
iso-read. Should you want cd-info with VCD support then you'd add a
dependency in that package to libvcdinfo.
Another thing one can do is "make install" inside the library, or run
"configure --without-vcd-info --without-cddb" (since libcddb also has
an optional dependency on libcdio).
Microsoft Windows
-------
The building under Microsoft Windows the thing to do is to install
cygwin (http://www.cygwin.com). It has been reported that MinGW
(http://www.mingw.org/) also works, but it is possible you may
encounter more problems there.
Folks may have used Microsoft compilers (e.g. Visual C), but you may
find you need to make your own "project" files. Don't undertake this
unless you are willing to spend time hacking. xboxmediacenter team
folks I believe go this route, so you may be able to use their project
files as a starting point.
XBOX
-------
Consult the xboxmediacenter team (www.xboxmediacenter.de)
BSD
---
Unless you use --without-versioned-libs (not recommended), you need to
use GNU make which usually can be found under the name "gmake".
If you use another make you are likely to get problems linking libcdio
and libiso9660.
Solaris
-------
You may need to use --without-versioned-libs if you get a problem
building libcdio or libiso9660.
If you get a message like:
libcdio.so: attempted multiple inclusion of file
because you have enable vcd-info and it is installed, then the only
way I know how to get around is to use configure with --disable-shared.
OS Support
---------------
Support for Operating Systems's is really based on the desire, ability
and willingness of others to help out. I use GNU/Linux so that
probably works best. Before a release I'll test on servers I have
available. I also announce a pending release on libcdio-devel@gnu.org
and ask others to test out.
Steve Schultz has done a great job making BSDI CD support look like
GNU/Linux and usually he let's me know where I've blown things on BSDI
and Darwin. Usage on Darwin has been picking up although Darwin is in
a world of its own so support for that (e.g. issuing MMC commnads)
seems to lag behind.
Of late FreeBSD folks have been pretty good about testing new releases
and reporting problems.
$Id: README.libcdio,v 1.12 2008/03/22 22:51:30 rocky Exp $

64
THANKS Normal file
View File

@@ -0,0 +1,64 @@
Burkhard Plaum <plaum@ipf.uni-stuttgart.de>
some GNU/Linux and CD-Text patches
Carlo Bramini
fixes for Mingw+MSYS and DLL support
Diego 'Flameeyes' Petten<65>
patches to FreeBSD and making Gentoo-friendly
Frantisek Dvorak <valtri at atlas.cz>:
bug reports and miscellaneous fixes
Heiner <h.eichmann at gmx.de>
FreeBSD CAM support and FreeBSD debugging & testing
Ian MacIntosh
Sun-related things.
Justin B. Ruggles <jruggle at earthlink.net>
SCSI MMC discmode determination via Read TOC.
Justin F. Hallett <thesin at southofheaven.org>
Fink packaging and matters OSX
Kris Verbeeck <airborne at advalvas.be>:
CDDB library support from libcddb http://libcddb.sourceforge.net
Gentoo ebuild-file
Manfred Tremmel <Manfred.Tremmel at iiv.de>:
RPM spec file and inclusion of libcdio into
http://packman.links2linux.de/
Michael Kukat <michael at unixiron.org>,
for the hints in extractnrg.pl
Nicolas Boullis <nboullis at debian.org>
Build issues, library symbol versioning, Debian packaging and issues
Patrick Guimond
CD-Extra audio data boundaries
Peter Hartley
Cross-compiling to mingw32
Peter J. Creath
removal of libpopt, paranoia documentation, some bug fixes to
cd-* programs and the paranoia lib
Steven M. Schultz <sms at 2BSD.COM>
All things BSDI and the use of a really fabulous Darwin G5 box.
Svend S. Sorensen <ssorensen at fastmail.fm>
cdrdao TOC-reading and CDRWin CUE parsing code based on cuetools
http://cuetools.sourceforge.net/
xboxmediacenter team (www.xboxmediacenter.de)
X-Box detection and XDF filesystem things
Daniel Schwarz
log-summary option in cd-paranoia.
Robert William Fuller
get_track_pregap_lba, get_track_pregap_lsn. Section on "CD-DA pregap"
in libcdio manual.

95
TODO Normal file
View File

@@ -0,0 +1,95 @@
It isn't look hard to find a gap in libcdio or libiso9660 or think of
something you'd like added. Here are some of the many known problems
and feature requests.
* UDF support.
* API overhaul. hvr has expressed interest but it's unlikely he'll ever
have the time to do. It could be done in conjunction with a wrappers
for C++, Perl, Python, ... The idea is that those interfaces would not
show the ugliness of the current C interface. For example instead of
read_mode2, read_mode1, read_audio, there might be a read(mode, ...).
- Address static loglevel variable (nboullis at debian.org)
* All of the API should be finished on all OS's (or the API adjusted).
* Fix the current gaps:
- SCSI-MMC on OSX,
- CD-Text support working more often? wide character support
(Burkhard Plaum has indicated he might do)
- more accurate drive capabilities
- wxwindows interface to cd-drive
- more accurate CD track classification (Form 1/2, Mode 1/2)
- complete the image readers, e.g. "silence" and ability to use
more than one file in cdrdao.
- multi-session CDs
* mmc_read_cd often doesn't work when request reading a large number of blocks.
* Is paranoia correct? Get a better handle on it. Ensure more of the
drive and OS-specific features that work on GNU/Linux work
elsewhere. Regression tests over more kinds of failures.
* Exclusive access of CD-ROM versus non-exclusive?
* Adjusting operations based on known models. Via MMC, We often have
the ability to find out what drive is in use. That could be used (as
it was in cdparanoia) to customize the method used for various
operations. Alternatively it could be read from a configuration
file, but right now there's no internal structure for holding all of
the capabilities.
* Combine iso-read and iso-info into an "iso-tar" for listing or
extracting files". Ideally something matching the relevant command
set of "tar" would be nice, as that is widely used and probably
fairly complete in thing that might be desired for listing/extracting.
* Add something to show what kind of CD media is in a drive. Ideally: CD
(purchased), CD Write Once, CD Read/Write, but what is there is
probably something like Cyanine, PhthaloCyanine, Metallized Azo,
Advanced PhthaloCyanine, Formazan. See
http://www.cdmediaworld.com/hardware/cdrom/cd_dye.shtml or
http://www.cd-info.com/CDIC/History/Commentary/Parker/stcroix.html
The discmode type can be used to classify DVD media and it also
classifies for CD track formats (in addition to CD *content*
classification). Note there is nothing for DVD content; see the below
list of things which probably won't get added.
Given the mismatch between DVD and CD meanings in discmode, the
discmode type probably needs to be redone.
* Write a real cue parser and TOC parser using bison.
A pcct grammar is given in cdrdao's trackdb TocParser.g and CueParser.g
The parsing is pretty much done, need to fold in semantic routines and
improve error reporting.
* conversion tools. Assuming parser done, it should be simple to use
write simple conversion routines:
- CD images's to iso9660 .iso's
- TOC <=> CUE
* Test more disc image types in regression testing, like CD-I.
* Convert to use glib, removing ds.h
(Revise vcdimager too)
* Delete and rename files in an iso9660 image (mephisto75 at web.de)
* Some things where libcdio will probably not expand in:
- DVD things, especially DVD-ROM (use libdvdread)
- writing applications (use cdrdao or cdrtools)
- more proprietary undocumented image format (unless someone else is willing
to do the work). But the fuzzy ISO 9660 detection may help here.
If there is something you really want done on the above list or have
something else you want done, it will go a lot faster if you attempt
to undertake doing it. Patches are always welcome (and CVS write
access is available for those who have demonstrated reasonable ability
through contributions.)
$Id: TODO,v 1.11 2005/07/11 11:51:07 rocky Exp $

12
autogen.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
# Additional options go to configure.
echo "Rebuilding ./configure with autoreconf..."
autoreconf -f -i
if [ $? -ne 0 ]; then
echo "autoreconf failed"
exit $?
fi
./configure --enable-maintainer-mode "$@"

688
configure.ac Normal file
View File

@@ -0,0 +1,688 @@
dnl Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
dnl Rocky Bernstein <rocky@gnu.org>
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2, or (at your option)
dnl any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
dnl 02110-1301 USA.
define(RELEASE_NUM, 82cvs)
define(CDIO_VERSION_STR, 0.$1)
AC_PREREQ(2.52)
AC_REVISION([$Id: configure.ac,v 1.238 2008/11/27 21:09:51 rocky Exp $])dnl
AC_INIT(libcdio, CDIO_VERSION_STR(RELEASE_NUM))
AC_CONFIG_SRCDIR(src/cd-info.c)
dnl For multilanguage manual pages (e.g. japanese cdparanoia) we use
dnl $make_p and according to Steve Schultz this is a make_p is a 1.8
dnl feature.
AM_INIT_AUTOMAKE([1.7])
AC_CANONICAL_HOST
AM_CONFIG_HEADER(config.h)
AC_CONFIG_MACRO_DIR([m4])
LIBCDIO_VERSION_NUM=`echo RELEASE_NUM | cut -d . -f 1 | tr -d a-z`
AC_SUBST(LIBCDIO_VERSION_NUM)
AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir)
AM_MISSING_PROG(CVS2CL, cvs2cl, $missing_dir)
AM_MAINTAINER_MODE
AM_SANITY_CHECK
AC_ARG_WITH(cd-drive,
[ --without-cd-drive don't build program cd-drive (default with)],
enable_cd_drive="${withval}", enable_cd_drive=yes)
AC_ARG_WITH(cd-info,
[ --without-cd-info don't build program cd-info (default with)],
enable_cd_info="${withval}", enable_cd_info=yes)
AC_ARG_WITH(cd-paranoia,
[ --without-cd-paranoia don't build program cd-paranoia and paranoia libraries (default with)],
enable_cd_paranoia="${withval}", enable_cd_paranoia=yes)
AC_ARG_WITH(cdda-player,
[ --without-cdda-player don't build program cdda-player (default with)],
enable_cdda_player="${withval}", enable_cdda_player=yes)
AC_ARG_WITH(cd-paranoia-name,
[ --with-cd-paranoia-name name to use as the cd-paranoia program name (default cd-paranoia)],
cd_paranoia_name="${withval}", cd_paranoia_name="cd-paranoia")
CDPARANOIA_NAME="$cd_paranoia_name"
AC_SUBST(CDPARANOIA_NAME)
AC_ARG_WITH(cd-read,
[ --without-cd-read don't build program cd-read (default with)],
enable_cd_read="${withval}", enable_cd_read=yes)
AC_ARG_WITH(iso-info,
[ --without-iso-info don't build program iso-info (default with)],
enable_iso_info="${withval}", enable_iso_info=yes)
AC_ARG_WITH(iso-read,
[ --without-iso-read don't build program iso-read (default with)],
enable_iso_read="${withval}", enable_iso_read=yes)
AC_ARG_WITH(versioned-libs,
[ --without-versioned-libs build versioned library symbols (default enabled if you have GNU ld)],
enable_versioned_libs="${withval}", enable_versioned_libs=yes)
AC_ARG_ENABLE([cxx],
AC_HELP_STRING([--disable-cxx], [Disable C++ bindings (default enabled)]))
AM_CONDITIONAL([ENABLE_CXX_BINDINGS], [test "x$enable_cxx" != "xno"])
AC_ARG_ENABLE(cpp-progs,
[ --enable-cpp-progs make C++ example programs (default enabled)])
AM_CONDITIONAL(ENABLE_CPP, test x"$enable_cpp_progs" = "xyes")
AC_ARG_ENABLE(example-progs,
AC_HELP_STRING([--disable-example-progs], [Don't build libcdio sample programs]))
AM_CONDITIONAL(BUILD_EXAMPLES, test "x$enable_example_progs" != "xno")
dnl We use C
AC_PROG_CC
AM_PROG_CC_C_O
dnl We also use C++ in example programs and for CXX bindings
AC_PROG_CXX
dnl Checks for programs.
AC_AIX
cd_drivers='cdrdao, BIN/CUE, NRG'
if test "x$GCC" != "xyes"
then
echo "*** non GNU CC compiler detected."
echo "*** This package has not been tested very well with non GNU compilers"
echo "*** you should try to use 'gcc' for compiling this package."
else
WARN_CFLAGS="-Wall -Wchar-subscripts -Wmissing-prototypes -Wmissing-declarations -Wunused -Wpointer-arith -Wwrite-strings -Wnested-externs -Wno-sign-compare"
for WOPT in $WARN_CFLAGS; do
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $WOPT"
AC_MSG_CHECKING([whether $CC understands $WOPT])
AC_TRY_COMPILE([], [], has_option=yes, has_option=no,)
CFLAGS="$SAVE_CFLAGS"
AC_MSG_RESULT($has_option)
if test $has_option = yes; then
warning_flags="$warning_flags $option"
fi
unset has_option
unset SAVE_CFLAGS
done
WARNING_FLAGS="$warning_flags"
unset warning_flags
fi
# We use Perl for documentation and regression tests
AC_PATH_PROG(PERL, perl, false)
AC_SUBST(PERL)
AM_CONDITIONAL(HAVE_PERL, test "$PERL" != "false")
# We use a diff in regression testing
AC_PATH_PROG(DIFF, diff, no)
DIFF_OPTS=
if test "$DIFF" = no ; then
AC_PATH_PROG(DIFF, cmp, no)
else
# Try for GNU diff options.
# MSDOG output uses \r\n rather than \n in tests
for diff_opt in -w --unified ; do
if $DIFF $diff_opt ./configure ./configure > /dev/null 2>&1; then
AC_MSG_RESULT([adding $diff_opt to diff in regression tests])
DIFF_OPTS="$DIFF_OPTS $diff_opt"
fi
done
fi
AC_SUBST(DIFF)
AC_SUBST(DIFF_OPTS)
dnl check for large file support
AC_SYS_LARGEFILE
dnl we need to define _FILE_OFFSET_BITS or _LARGE_FILES on the compiler command
dnl line because otherwise the system headers risk being included before
dnl problems
if test "x$ac_cv_sys_largefiles" = "xyes"; then
if test "x$ac_cv_sys_file_offset_bits" = "x64"; then
LIBCDIO_LARGEFILE_FLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGE_FILES"
else
LIBCDIO_LARGEFILE_FLAGS="-D_LARGE_FILES"
fi
dnl AC_FUNC_FSEEKO sets HAVE_FSEEKO and $ac_cv_sys_largefile_source
AC_FUNC_FSEEKO
if test "$ac_cv_sys_largefile_source" != no; then
LIBCDIO_LARGEFILE_FLAGS="$LIBDDIO_LARGEFILE_FLAGS -D_LARGEFILE_SOURCE=$ac_cv_sys_largefile_source"
fi
CPPFLAGS="$CPPFLAGS $LIBCDIO_LARGEFILE_FLAGS"
fi
# We use cmp and cdparanoia in cd-paranoia regression testing
AC_PATH_PROG(CMP, cmp, no)
AC_SUBST(CMP)
AC_PATH_PROG(OLD_CDPARANOIA, cdparanoia, no)
AC_SUBST(OLD_CDPARANOIA)
AC_DEFINE(LIBCDIO_CONFIG_H, 1,
[Is set when libcdio's config.h has been included. Applications wishing to sue their own config.h values (such as set by the application's configure script can define this before including any of libcdio's headers.])
dnl headers
AC_HEADER_STDC
AC_CHECK_HEADERS(errno.h fcntl.h glob.h limits.h pwd.h)
AC_CHECK_HEADERS(stdarg.h stdbool.h stdio.h sys/cdio.h sys/param.h)
AC_CHECK_HEADERS(sys/time.h sys/timeb.h)
AC_CHECK_HEADERS(ncurses.h curses.h, break, [enable_cdda_player='no'])
dnl FreeBSD 4 has getopt in unistd.h. So we include that before
dnl getopt.h
AC_CHECK_HEADERS(unistd.h getopt.h)
AC_SUBST(SBPCD_H)
AC_SUBST(UCDROM_H)
AC_SUBST(TYPESIZES)
dnl compiler
AC_C_BIGENDIAN
AC_C_CONST
AC_C_INLINE
dnl ISOC99_PRAGMA
AC_MSG_CHECKING([whether $CC supports ISOC99 _Pragma()])
AC_TRY_COMPILE([],[_Pragma("pack(1)")], [
ISOC99_PRAGMA=yes
AC_DEFINE(HAVE_ISOC99_PRAGMA, [], [Supports ISO _Pragma() macro])
],ISOC99_PRAGMA=no)
AC_MSG_RESULT($ISOC99_PRAGMA)
##
## Check for S_ISSOCK() and S_ISLNK() macros
##
AC_MSG_CHECKING(for S_ISLNK() macro)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
],[return S_ISLNK(0);])],
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_S_ISLNK, [], [Define this <sys/stat.h> defines S_ISLNK()]) ],
[ AC_MSG_RESULT(no) ])
AC_MSG_CHECKING([for S_ISSOCK() macro])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
],[return S_ISSOCK(0);])],
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_S_ISSOCK, [], [Define this <sys/stat.h> defines S_ISSOCK()]) ],
[ AC_MSG_RESULT(no) ])
AC_MSG_CHECKING([for struct timespec])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
],[struct timespec ts;])],
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRUCT_TIMESPEC, [], [Define this if you have struct timespec]) ],
[ AC_MSG_RESULT(no) ])
dnl empty_array_size
AC_MSG_CHECKING([how to create empty arrays])
empty_array_size="xxxx"
AC_TRY_COMPILE([],[struct { int foo; int bar[]; } doo;], empty_array_size="")
if test "x$empty_array_size" = "xxxx";then
AC_TRY_COMPILE([],[struct { int foo; int bar[0]; } doo;], empty_array_size="0")
fi
if test "x$empty_array_size" = "xxxx"
then
AC_MSG_ERROR([compiler is unable to creaty empty arrays])
else
AC_DEFINE_UNQUOTED(EMPTY_ARRAY_SIZE, $empty_array_size,
[what to put between the brackets for empty arrays])
changequote(`,')
msg="[${empty_array_size}]"
changequote([,])
AC_MSG_RESULT($msg)
fi
dnl Enable the creation of shared libraries under Win32.
AC_LIBTOOL_WIN32_DLL
dnl AM_PROG_LIBTOOL tests whether we have GNU ld
dnl this must come before checking --with-versioned-libs
dnl which requires GNU ld.
AM_PROG_LIBTOOL
dnl system
# FIXME:
# I believe some OS's require -lm, but I don't recall for what function
# When we find it, put it in below instead of "cos".
AC_CHECK_LIB(m, cos, [LIBS="$LIBS -lm"; COS_LIB="-lm"])
CFLAGS="$CFLAGS $WARN_CFLAGS"
AC_SUBST(COS_LIB)
# Do we have GNU ld? If we don't, we can't build versioned symbols.
if test "$with_gnu_ld" != yes; then
AC_MSG_WARN([I don't see GNU ld. I'm going to assume --without-versioned-libs])
enable_versioned_libs='no'
fi
# We also need GNU make to build versioned symbols.
if test "x$enable_versioned_libs" = "xyes" ; then
if test -n "$MAKE" ; then
$MAKE --version 2>/dev/null >/dev/null
if test "$?" -ne 0 ; then
AC_MSG_ERROR(Either set MAKE variable to GNU make or use
--without-versioned-libs option)
fi
else
make --version 2>/dev/null >/dev/null
if test "$?" -ne 0 ; then
AC_MSG_ERROR(Either set MAKE variable to GNU make or use
--without-versioned-libs option)
fi
fi
fi
AM_CONDITIONAL(CYGWIN, test "x$CYGWIN" = "xyes")
AM_CONDITIONAL(BUILD_CD_DRIVE, test "x$enable_cd_drive" = "xyes")
AM_CONDITIONAL(BUILD_CDINFO, test "x$enable_cd_info" = "xyes")
AM_CONDITIONAL(BUILD_CD_READ, test "x$enable_cd_read" = "xyes")
AM_CONDITIONAL(BUILD_CD_PARANOIA, test "x$enable_cd_paranoia" = "xyes")
AM_CONDITIONAL(BUILD_ISO_INFO, test "x$enable_iso_info" = "xyes")
AM_CONDITIONAL(BUILD_ISO_READ, test "x$enable_iso_read" = "xyes")
AM_CONDITIONAL(BUILD_CDINFO_LINUX, test "x$enable_cd_info_linux" = "xyes")
AM_CONDITIONAL(BUILD_CDIOTEST, test "x$enable_cdiotest" = "xyes")
AM_CONDITIONAL(BUILD_VERSIONED_LIBS, test "x$enable_versioned_libs" = "xyes")
AM_CONDITIONAL(DISABLE_CPP, test "x$disable_cpp" = "xyes")
dnl Checks for header files.
LIBCDIO_CDDA_LIBS='$(top_builddir)/lib/cdda_interface/libcdio_cdda.la'
LIBCDIO_CFLAGS='-I$(top_srcdir)/lib/driver -I$(top_builddir)/include -I$(top_srcdir)/include/'
LIBCDIO_LIBS='$(top_builddir)/lib/driver/libcdio.la'
LIBCDIO_DEPS="$LIBCDIO_LIBS"
LIBCDIOPP_LIBS='$(top_builddir)/lib/cdio++/libcdio++.la'
LIBISO9660PP_LIBS='$(top_builddir)/lib/cdio++/libiso9660++.la'
LIBCDIO_PARANOIA_LIBS='$(top_builddir)/lib/paranoia/libcdio_paranoia.la'
LIBISO9660_CFLAGS='-I$(top_srcdir)/lib/iso9660/'
LIBISO9660_LIBS='$(top_builddir)/lib/iso9660/libiso9660.la'
LIBUDF_CFLAGS='-I$(top_srcdir)/lib/udf/'
LIBUDF_LIBS='$(top_builddir)/lib/udf/libudf.la'
AC_SUBST(LIBCDIO_CDDA_LIBS)
AC_SUBST(LIBCDIO_CFLAGS)
AC_SUBST(LIBISO9660_CFLAGS)
AC_SUBST(LIBISO9660PP_LIBS)
AC_SUBST(LIBCDIO_LIBS)
AC_SUBST(LIBCDIOPP_LIBS)
AC_SUBST(LIBCDIO_DEPS)
AC_SUBST(LIBCDIO_PARANOIA_LIBS)
AC_SUBST(LIBISO9660_LIBS)
AC_SUBST(LIBUDF_LIBS)
dnl Libtool flag for strict linkage
LT_NO_UNDEFINED=
case $host_os in
aix*)
## Don't use AIX driver until starts to really work
## cd_drivers="${cd_drivers}, AIX"
## AC_DEFINE([HAVE_AIX_CDROM], [1],
## [Define 1 if you have AIX CD-ROM support])
;;
darwin6*|darwin7*|darwin8*|darwin9*)
AC_CHECK_HEADERS(IOKit/IOKitLib.h CoreFoundation/CFBase.h,
[have_iokit_h="yes"])
if test "x$have_iokit_h" = "xyes" ; then
AC_DEFINE([HAVE_DARWIN_CDROM], [1],
[Define 1 if you have Darwin OS X-type CD-ROM support])
DARWIN_PKG_LIB_HACK="-Wl,-framework,CoreFoundation -Wl,-framework,IOKit"
dnl Prior to Mac OS X 10.4 (Tiger), DiskArbitration was a private framework.
dnl It's now public, and it's needed to do cd/dvd unmount/eject.
AC_MSG_CHECKING([for DiskArbitration framework])
ac_save_LIBS="$LIBS" LIBS="$LIBS -framework CoreFoundation -framework DiskArbitration"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <DiskArbitration/DiskArbitration.h>]], [[]])],
[have_diskarbitration_framework=yes], [have_diskarbitration_framework=no])
LIBS="$ac_save_LIBS"
AC_MSG_RESULT([$have_diskarbitration_framework])
if test x"$have_diskarbitration_framework" = x"yes"; then
AC_DEFINE([HAVE_DISKARBITRATION], 1, [Define to 1 if you have the Apple DiskArbitration framework])
DARWIN_PKG_LIB_HACK="$DARWIN_PKG_LIB_HACK -Wl,-framework,DiskArbitration"
fi
AC_SUBST(DARWIN_PKG_LIB_HACK)
LIBCDIO_LIBS="$LIBCDIO_LIBS $DARWIN_PKG_LIB_HACK"
cd_drivers="${cd_drivers}, Darwin"
fi
;;
linux*|uclinux)
AC_CHECK_HEADERS(linux/version.h linux/major.h)
AC_CHECK_HEADERS(linux/cdrom.h, [have_linux_cdrom_h="yes"])
if test "x$have_linux_cdrom_h" = "xyes" ; then
AC_TRY_COMPILE(,[
#include <linux/cdrom.h>
struct cdrom_generic_command test;
int has_timeout=sizeof(test.timeout);],
[AC_DEFINE([HAVE_LINUX_CDROM_TIMEOUT], [1],
[Define 1 if timeout is in cdrom_generic_command struct])])
AC_DEFINE([HAVE_LINUX_CDROM], [1],
[Define 1 if you have Linux-type CD-ROM support])
cd_drivers="${cd_drivers}, GNU/Linux"
fi
;;
bsdi*)
AC_CHECK_HEADERS(dvd.h, [have_bsdi_dvd_h="yes"])
if test "x$have_bsdi_dvd_h" = "xyes" ; then
AC_DEFINE([HAVE_BSDI_CDROM], [1],
[Define 1 if you have BSDI-type CD-ROM support])
LIBS="$LIBS -ldvd -lcdrom"
LIBCDIO_LIBS="$LIBCDIO_LIBS -lcdrom"
cd_drivers="${cd_drivers}, BSDI"
fi
;;
sunos*|sun*|solaris*)
AC_DEFINE([HAVE_SOLARIS_CDROM], [1],
[Define 1 if you have Solaris CD-ROM support])
cd_drivers="${cd_drivers}, Solaris"
;;
cygwin*)
AC_DEFINE([CYGWIN], [1],
[Define 1 if you are compiling using cygwin])
AC_DEFINE([HAVE_WIN32_CDROM], [1],
[Define 1 if you have MinGW CD-ROM support])
LIBS="$LIBS -lwinmm"
cd_drivers="${cd_drivers}, MinGW"
AC_DEFINE([NEED_TIMEZONEVAR], [1],
[Define 1 if you need timezone defined to get timzone
defined as a variable. In cygwin it is a function too])
;;
mingw*)
AC_CHECK_HEADERS(windows.h)
AC_DEFINE([MINGW32], [1],
[Define 1 if you are compiling using MinGW])
AC_DEFINE([HAVE_WIN32_CDROM], [1],
[Define 1 if you have MinGW CD-ROM support])
LIBS="$LIBS -lwinmm -mwindows"
LT_NO_UNDEFINED="-no-undefined"
cd_drivers="${cd_drivers}, MinGW "
;;
freebsd4.*|freebsd5.*|freebsd6*|freebsd7*|dragonfly*|kfreebsd*)
AC_DEFINE([HAVE_FREEBSD_CDROM], [1],
[Define 1 if you have FreeBSD CD-ROM support])
LIBS="$LIBS -lcam"
cd_drivers="${cd_drivers}, FreeBSD "
;;
netbsd*)
AC_DEFINE([HAVE_NETBSD_CDROM], [1],
[Define 1 if you have NetBSD CD-ROM support])
# LIBS="$LIBS -lcam"
cd_drivers="${cd_drivers}, NetBSD "
;;
*)
AC_MSG_WARN([Don't have OS CD-reading support for ${host_os}...])
AC_MSG_WARN([Will use generic support.])
;;
esac
AC_SUBST(LT_NO_UNDEFINED)
AC_MSG_CHECKING(extern long timezone variable)
AC_LINK_IFELSE([
#ifdef NEED_TIMEZONEVAR
#define timezonevar 1
#endif
#include <time.h>
extern long timezone;
int main(int argc, char **argv) {
long test_timezone = timezone;
return 0;
}
], [AC_MSG_RESULT(yes);
AC_DEFINE([HAVE_TIMEZONE_VAR], 1,
[Define if you have an extern long timenzone variable.])],
[AC_MSG_RESULT(no)])
dnl
AC_SUBST(LINUX_CDROM_TIMEOUT)
AC_SUBST(DARWIN_PKG_LIB_HACK)
AC_SUBST(HAVE_BSDI_CDROM)
AC_SUBST(HAVE_DARWIN_CDROM)
AC_SUBST(HAVE_FREEBSD_CDROM)
AC_SUBST(HAVE_LINUX_CDROM)
AC_SUBST(HAVE_SOLARIS_CDROM)
AC_SUBST(HAVE_WIN32_CDROM)
LIBCDIO_SOURCE_PATH="`pwd`"
AC_DEFINE_UNQUOTED(LIBCDIO_SOURCE_PATH, "$LIBCDIO_SOURCE_PATH",
[Full path to libcdio top_sourcedir.])
AC_SUBST(LIBCDIO_SOURCE_PATH)
AC_CHECK_FUNCS( [bzero drand48 ftruncate geteuid getgid \
getuid getpwuid gettimeofday lstat memcpy memset \
rand seteuid setegid snprintf setenv unsetenv tzset \
sleep vsnprintf readlink gmtime_r localtime_r] )
# check for timegm() support
AC_CHECK_FUNC(timegm, AC_DEFINE(HAVE_TIMEGM,1,
[Define to 1 if timegm is available]))
AC_CHECK_MEMBER([struct tm.tm_gmtoff],
[AC_DEFINE(HAVE_TM_GMTOFF, 1,
[Define if struct tm has the tm_gmtoff member.])],
,
[#include <time.h>])
if test $ac_cv_member_struct_tm_tm_gmtoff = yes ; then
AC_MSG_CHECKING([whether time.h defines daylight and timezone variables])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <time.h>
],[return (timezone != 0) + daylight;])],
[AC_DEFINE(HAVE_DAYLIGHT, 1,
[Define if time.h defines extern long timezone and int daylight vars.])
has_daylight=yes
],[has_daylight=no])
AC_MSG_RESULT($has_daylight)
AC_MSG_CHECKING([whether time.h defines tzname variable])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <time.h>
],[return (tzname != NULL);])],
[AC_DEFINE(HAVE_TZNAME, 1,
[Define if time.h defines extern extern char *tzname[2] variable])
has_tzname=yes
],[has_tzname=no])
AC_MSG_RESULT($has_tzname)
fi
AC_ARG_ENABLE(joliet,
AS_HELP_STRING([--disable-joliet], [don't include Joliet extension support (default enabled)]),
[enable_joliet=$enableval],
[enable_joliet=yes])
if test "${enable_joliet}" != "no" ; then
AM_ICONV
AM_LANGINFO_CODESET
if test "$am_cv_func_iconv" = yes ; then
AC_DEFINE(HAVE_JOLIET, [1],
[Define 1 if you want ISO-9660 Joliet extension support.
You must have also libiconv installed to get Joliet extension support.])
HAVE_JOLIET=1
else
AC_MSG_ERROR([You must have iconv installed.])
fi
fi
AC_SUBST(HAVE_JOLIET)
if test x$enable_rock = x; then
enable_rock=yes
AC_ARG_ENABLE(rock,
[ --enable-rock include Rock-Ridge extension support (default enabled)],
enable_rock=yes, enable_rock=no)
fi
if test "${enable_rock}" != "no" ; then
AC_DEFINE(HAVE_ROCK, [1],
[Define 1 if you want ISO-9660 Rock-Ridge extension support.])
HAVE_ROCK=1
fi
AC_SUBST(HAVE_ROCK)
AM_CONDITIONAL(ENABLE_ROCK, test x"$enable_rock" = "xyes")
if test x$enable_cddb = x; then
enable_cddb=yes
AC_ARG_ENABLE(cddb,
[ --enable-cddb include CDDB lookups in cd_info (default enabled)],
enable_cddb=yes, enable_cddb=no)
fi
if test x$enable_cddb != "no" ; then
PKG_CHECK_MODULES(CDDB, libcddb >= 1.0.1, [
HAVE_CDDB=yes
AC_DEFINE(HAVE_CDDB, [], [Define this if you have libcddb installed])
],
[AC_MSG_WARN([new enough libcddb not found. CDDB access disabled. Get libcddb from http://libcddb.sourceforge.net])
HAVE_CDDB=no])
AC_CHECK_LIB(socket, connect)
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
fi
AC_SUBST(CDDB_LIBS)
AC_DEFINE(HAVE_KEYPAD, [], [Define this if your libcurses has keypad])
if test x$enable_cdda_player = xyes; then
AC_CHECK_LIB(ncurses, mvprintw,
[LIBCURSES=ncurses; CDDA_PLAYER_LIBS="$CDDA_PLAYER_LIBS -lncurses"],
AC_CHECK_LIB(curses, mvprintw,
[LIBCURSES=curses; CDDA_PLAYER_LIBS="$CDDA_PLAYER_LIBS -lcurses"],
[AC_MSG_WARN([Will not build cdda-player - did not find libcurses or libncurses])
enable_cdda_player=no]))
if test x$enable_cdda_player = xyes; then
AC_CHECK_LIB($LIBCURSES, keypad, [HAVE_KEYPAD=yes])
fi
fi
AM_CONDITIONAL(BUILD_CDDA_PLAYER, test "x$enable_cdda_player" = "xyes")
AC_SUBST(CDDA_PLAYER_LIBS)
if test x$enable_vcd_info = x; then
AC_ARG_ENABLE(vcd_info,
[ --enable-vcd-info include Video CD Info from libvcd],
enable_vcd_info=yes,
enable_vcd_info=no)
fi
if test x$enable_vcd_info = xyes; then
PKG_CHECK_MODULES(VCDINFO, libvcdinfo >= 0.7.21,
[AC_DEFINE([HAVE_VCDINFO],1,
[Define this if you have libvcdinfo installed])],
[AC_MSG_WARN(a new enough libvcdinfo not found.
VCD info display in cd-info disabled.
libvcdinfo is part of vcdimager. Get it from http://vcdimager.org)
enable_vcd_info=no])
fi
AC_SUBST(VCDINFO_LIBS)
AC_SUBST(VCDINFO_CFLAGS)
dnl
dnl Newest automake workaround - needed for multi-language manual pages
dnl
AC_SUBST(mkdir_p)
AC_CONFIG_COMMANDS([checks],
[chmod +x test/check_cue.sh; chmod +x test/check_nrg.sh
])
dnl
dnl Output configuration files
dnl
## AC_CONFIG_FILES([ po/Makefile.in\
AC_CONFIG_FILES([
Makefile \
example/C++/Makefile \
example/C++/OO/Makefile \
example/Makefile \
include/Makefile \
include/cdio/Makefile \
include/cdio++/Makefile \
include/cdio/version.h \
doc/doxygen/Doxyfile \
doc/Makefile \
lib/Makefile \
lib/cdda_interface/Makefile \
lib/cdio++/Makefile \
lib/driver/Makefile \
lib/iso9660/Makefile \
lib/paranoia/Makefile \
lib/udf/Makefile \
libcdio.pc \
libcdio++.pc \
libcdio_cdda.pc \
libcdio_paranoia.pc \
libiso9660.pc \
libiso9660++.pc \
libudf.pc \
package/libcdio.spec \
src/cd-paranoia/Makefile \
src/cd-paranoia/usage.txt \
src/cd-paranoia/doc/Makefile \
src/cd-paranoia/doc/en/cd-paranoia.1 \
src/cd-paranoia/doc/en/Makefile \
src/cd-paranoia/doc/ja/cd-paranoia.1 \
src/cd-paranoia/doc/ja/Makefile \
src/Makefile \
test/testbincue.c \
test/testisocd2.c \
test/testpregap.c \
test/testnrg.c \
test/check_common_fn \
test/Makefile \
])
# AC_CONFIG_FILES([po/Makefile])
AC_CONFIG_FILES([test/check_cue.sh], [chmod +x test/check_cue.sh])
AC_CONFIG_FILES([test/check_iso.sh], [chmod +x test/check_iso.sh])
AC_CONFIG_FILES([test/check_nrg.sh], [chmod +x test/check_nrg.sh])
AC_CONFIG_FILES([test/check_paranoia.sh], [chmod +x test/check_paranoia.sh])
AC_CONFIG_COMMANDS([default],[[
# Make sure scripts are executable
# This is a big hack, but I don't know any other way around it.
cat > include/cdio/cdio_config.h << EOF
/** \file cdio_config.h
* \brief configuration-time settings useful in compilation; a run-time
version of config.h
*/
EOF
head -n 233 config.h >> include/cdio/cdio_config.h
]],[[]])
AC_OUTPUT
echo "Using CD-ROM drivers: $cd_drivers"
echo "Building cd-paranoia: $(test "x$enable_cd_paranoia" = "xyes" && echo yes || echo no)"
echo "Building cd-info : $(test "x$enable_cd_info" = "xyes" && echo yes || echo no)"
echo "Building cd-read : $(test "x$enable_cd_read" = "xyes" && echo yes || echo no)"
echo "Building cdda-player: $(test "x$enable_cdda_player" = "xyes" && echo yes || echo no)"
echo "Building iso-info : $(test "x$enable_iso_info" = "xyes" && echo yes || echo no)"
echo "Building iso-read : $(test "x$enable_iso_read" = "xyes" && echo yes || echo no)"

4
cvs2cl_header Normal file
View File

@@ -0,0 +1,4 @@
##
## autogenerated ChangeLog -- don't edit
##

7
cvs2cl_usermap Normal file
View File

@@ -0,0 +1,7 @@
edsdead:Robert William Fuller
flameeyes:Diego 'Flameeyes' Petten<65>
hvr:Herbert Valerio Riedel
karl:Karl Berry
nboullis:Nicolas Boullis
rocky:Rocky Bernstein
thesin:Justin F. Hallett

7
doc/.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
/Makefile
/Makefile.in
/libcdio.info
/mdate-sh
/stamp-vti
/texinfo.tex
/version.texi

46
doc/Makefile.am Normal file
View File

@@ -0,0 +1,46 @@
# $Id: Makefile.am,v 1.9 2008/04/17 17:39:47 karl Exp $
#
# Copyright (C) 2003, 2004, 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/>.
EXTRA_DIST = doxygen/Doxyfile.in doxygen/run_doxygen
info_TEXINFOS = libcdio.texi
libcdio_TEXINFOS = fdl.texi glossary.texi
reference:
-( cd ${top_srcdir} && $(MAKE) doxygen )
pdf: libcdio.pdf
txt: libcdio.txt
ps: libcdio.ps
html: libcdio.html
%.ps.gz: %.ps
gzip -9c $< > $@
.texi.pdf:
texi2pdf $<
.texi.html:
texi2html $<
.texi.txt:
makeinfo --no-headers $< > $@
all-formats: pdf dvi txt ps html
MOSTLYCLEANFILES = libcdio.html libcdio.pdf libcdio.ps.gz

1
doc/doxygen/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/Doxyfile

1302
doc/doxygen/Doxyfile.in Normal file

File diff suppressed because it is too large Load Diff

107
doc/doxygen/run_doxygen Executable file
View File

@@ -0,0 +1,107 @@
#!/bin/sh
# $Id: run_doxygen,v 1.1 2003/11/09 14:11:02 rocky Exp $
# Runs doxygen and massages the output files.
# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
#
# Synopsis: run_doxygen --mode=[user|maint|man] v3srcdir v3builddir
#
# Originally hacked together by Phil Edwards <pme@gcc.gnu.org>
# We can check now that the version of doxygen is >= this variable.
DOXYVER=1.2.15
doxygen=
find_doxygen() {
v_required=`echo $DOXYVER | \
awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
testing_version=
# thank you goat book
set `IFS=:; X="$PATH:/usr/local/bin:/bin:/usr/bin"; echo $X`
for dir
do
# AC_EXEEXT could come in useful here
maybedoxy="$dir/doxygen"
test -f "$maybedoxy" && testing_version=`$maybedoxy --version`
if test -n "$testing_version"; then
v_found=`echo $testing_version | \
awk -F. '{if(NF<3)$3=0;print ($1*100+$2)*100+$3}'`
if test $v_found -ge $v_required; then
doxygen="$maybedoxy"
break
fi
fi
done
if test -z "$doxygen"; then
echo run_doxygen error: Could not find Doxygen $DOXYVER in path. 1>&2
print_usage
fi
}
print_usage() {
cat 1>&2 <<EOF
Usage: run_doxygen --mode=MODE [<options>] <v3-src-dir> <v3-build-dir>
MODE is one of:
user Generate user-level HTML library documentation.
maint Generate maintainers' HTML documentation (lots more;
exposes non-public members, etc).
man Generate user-level man pages.
more options when i think of them
Note: Requires Doxygen ${DOXYVER} or later; get it at
ftp://ftp.stack.nl/pub/users/dimitri/doxygen-${DOXYVER}.src.tar.gz
EOF
exit 1
}
parse_options() {
for o
do
# Blatantly ripped from autoconf, er, I mean, "gratefully standing
# on the shoulders of those giants who have gone before us."
case "$o" in
-*=*) arg=`echo "$o" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) arg= ;;
esac
case "$o" in
--mode=*)
mode=$arg ;;
--mode | --help | -h)
print_usage ;;
*)
# this turned out to be a mess, maybe change to --srcdir=, etc
if test $srcdir = unset; then
srcdir=$o
elif test $outdir = unset; then
builddir=${o}
outdir=${o}/doc/doxygen
else
echo run_doxygen error: Too many arguments 1>&2
exit 1
fi
;;
esac
done
}
# script begins here
mode=unset
srcdir=unset
outdir=unset
do_html=no
do_man=no
enabled_sections=
DATEtext=`date '+%Y-%m-%d'`
parse_options $*
find_doxygen
$doxygen ./Doxyfile
exit 0
# vim:ts=4:et:

451
doc/fdl.texi Normal file
View File

@@ -0,0 +1,451 @@
@c The GNU Free Documentation License.
@center Version 1.2, November 2002
@c This file is intended to be included within another document,
@c hence no sectioning command or @node.
@display
Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@end display
@enumerate 0
@item
PREAMBLE
The purpose of this License is to make a manual, textbook, or other
functional and useful document @dfn{free} in the sense of freedom: to
assure everyone the effective freedom to copy and redistribute it,
with or without modifying it, either commercially or noncommercially.
Secondarily, this License preserves for the author and publisher a way
to get credit for their work, while not being considered responsible
for modifications made by others.
This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
@item
APPLICABILITY AND DEFINITIONS
This License applies to any manual or other work, in any medium, that
contains a notice placed by the copyright holder saying it can be
distributed under the terms of this License. Such a notice grants a
world-wide, royalty-free license, unlimited in duration, to use that
work under the conditions stated herein. The ``Document'', below,
refers to any such manual or work. Any member of the public is a
licensee, and is addressed as ``you''. You accept the license if you
copy, modify or distribute the work in a way requiring permission
under copyright law.
A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A ``Secondary Section'' is a named appendix or a front-matter section
of the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall
subject (or to related matters) and contains nothing that could fall
directly within that overall subject. (Thus, if the Document is in
part a textbook of mathematics, a Secondary Section may not explain
any mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License. If a
section does not fit the above definition of Secondary then it is not
allowed to be designated as Invariant. The Document may contain zero
Invariant Sections. If the Document does not identify any Invariant
Sections then there are none.
The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License. A Front-Cover Text may
be at most 5 words, and a Back-Cover Text may be at most 25 words.
A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, that is suitable for revising the document
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup, or absence of markup, has been arranged to thwart
or discourage subsequent modification by readers is not Transparent.
An image format is not Transparent if used for any substantial amount
of text. A copy that is not ``Transparent'' is called ``Opaque''.
Examples of suitable formats for Transparent copies include plain
@sc{ascii} without markup, Texinfo input format, La@TeX{} input
format, @acronym{SGML} or @acronym{XML} using a publicly available
@acronym{DTD}, and standard-conforming simple @acronym{HTML},
PostScript or @acronym{PDF} designed for human modification. Examples
of transparent image formats include @acronym{PNG}, @acronym{XCF} and
@acronym{JPG}. Opaque formats include proprietary formats that can be
read and edited only by proprietary word processors, @acronym{SGML} or
@acronym{XML} for which the @acronym{DTD} and/or processing tools are
not generally available, and the machine-generated @acronym{HTML},
PostScript or @acronym{PDF} produced by some word processors for
output purposes only.
The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
A section ``Entitled XYZ'' means a named subunit of the Document whose
title either is precisely XYZ or contains XYZ in parentheses following
text that translates XYZ in another language. (Here XYZ stands for a
specific section name mentioned below, such as ``Acknowledgements'',
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
of such a section when you modify the Document means that it remains a
section ``Entitled XYZ'' according to this definition.
The Document may include Warranty Disclaimers next to the notice which
states that this License applies to the Document. These Warranty
Disclaimers are considered to be included by reference in this
License, but only as regards disclaiming warranties: any other
implication that these Warranty Disclaimers may have is void and has
no effect on the meaning of this License.
@item
VERBATIM COPYING
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
@item
COPYING IN QUANTITY
If you publish printed copies (or copies in media that commonly have
printed covers) of the Document, numbering more than 100, and the
Document's license notice requires Cover Texts, you must enclose the
copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a computer-network location from which the general network-using
public has access to download using public-standard network protocols
a complete Transparent copy of the Document, free of added material.
If you use the latter option, you must take reasonably prudent steps,
when you begin distribution of Opaque copies in quantity, to ensure
that this Transparent copy will remain thus accessible at the stated
location until at least one year after the last time you distribute an
Opaque copy (directly or through your agents or retailers) of that
edition to the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
@item
MODIFICATIONS
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
@enumerate A
@item
Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
@item
List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has fewer than five),
unless they release you from this requirement.
@item
State on the Title page the name of the publisher of the
Modified Version, as the publisher.
@item
Preserve all the copyright notices of the Document.
@item
Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
@item
Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
@item
Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
@item
Include an unaltered copy of this License.
@item
Preserve the section Entitled ``History'', Preserve its Title, and add
to it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section Entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
@item
Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
@item
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
the Title of the section, and preserve in the section all the
substance and tone of each of the contributor acknowledgements and/or
dedications given therein.
@item
Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
@item
Delete any section Entitled ``Endorsements''. Such a section
may not be included in the Modified Version.
@item
Do not retitle any existing section to be Entitled ``Endorsements'' or
to conflict in title with any Invariant Section.
@item
Preserve any Warranty Disclaimers.
@end enumerate
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section Entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties---for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
@item
COMBINING DOCUMENTS
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice, and that you preserve all their Warranty Disclaimers.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections Entitled ``History''
in the various original documents, forming one section Entitled
``History''; likewise combine any sections Entitled ``Acknowledgements'',
and any sections Entitled ``Dedications''. You must delete all
sections Entitled ``Endorsements.''
@item
COLLECTIONS OF DOCUMENTS
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
@item
AGGREGATION WITH INDEPENDENT WORKS
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, is called an ``aggregate'' if the copyright
resulting from the compilation is not used to limit the legal rights
of the compilation's users beyond what the individual works permit.
When the Document is included in an aggregate, this License does not
apply to the other works in the aggregate which are not themselves
derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one half of
the entire aggregate, the Document's Cover Texts may be placed on
covers that bracket the Document within the aggregate, or the
electronic equivalent of covers if the Document is in electronic form.
Otherwise they must appear on printed covers that bracket the whole
aggregate.
@item
TRANSLATION
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License, and all the license notices in the
Document, and any Warranty Disclaimers, provided that you also include
the original English version of this License and the original versions
of those notices and disclaimers. In case of a disagreement between
the translation and the original version of this License or a notice
or disclaimer, the original version will prevail.
If a section in the Document is Entitled ``Acknowledgements'',
``Dedications'', or ``History'', the requirement (section 4) to Preserve
its Title (section 1) will typically require changing the actual
title.
@item
TERMINATION
You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License. Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License. However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.
@item
FUTURE REVISIONS OF THIS LICENSE
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
@uref{http://www.gnu.org/copyleft/}.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License ``or any later version'' applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
@end enumerate
@page
@heading ADDENDUM: How to use this License for your documents
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
@smallexample
@group
Copyright (C) @var{year} @var{your name}.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
@end group
@end smallexample
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
replace the ``with@dots{}Texts.'' line with this:
@smallexample
@group
with the Invariant Sections being @var{list their titles}, with
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
being @var{list}.
@end group
@end smallexample
If you have Invariant Sections without Cover Texts, or some other
combination of the three, merge those two alternatives to suit the
situation.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
@c Local Variables:
@c ispell-local-pdict: "ispell-dict"
@c End:

360
doc/glossary.texi Normal file
View File

@@ -0,0 +1,360 @@
See also @uref{http://www.dvdrhelp.com/glossary}.
@table @dfn
@item ASPI
@cindex ASPI
See @acronym{Win32 ASPI}
@item ATA
Advanced Technology Attachment (ATA). The same things as IDE.
@item ATAPI
Advanced Technology Attachment (ATA) Packet Interface. The interface
provides a mechanism for transferring and executing SCSI CDBs on IDE
CD Drives and DVD Drives.
IDE (also called ATA) was originally designed for hard drives only,
but with help of ATAPI it is possible to connect other devices, in
particular CD-ROMS to the IDE/EIDE connections.
The ATAPI CD-ROM drives understand a subset of MMC commands. In
particular multi-initiator commands are neither needed nor deviced for
ATAPI devices.
@item BIN/CUE
A CD-image format developed by Jeff Arnold for CDRWIN software on
Microsoft Windows. Many other programs subsequently support using this
format. The @code{.CUE} file is a text file which contains CD format
and track layout information, while the @code{.BIN} file holds the
actual data of each track.
@item CD
Compact Disc
@item CD-DA
@cindex CD-DA
Compact Disc Digital Audio, described in the ``Red Book'' or IEC 60908
(formerly IEC 908). This commonly referred to as an audio @acronym{CD}
and what most people think of when you play a @acronym{CD} as it was
the first to use the @acronym{CD} medium.
See @url{http://en.wikipedia.org/wiki/Red_Book_(audio_CD_standard)}
@item CD+G
@cindex CD+G
Compact Disc + Graphics. An extension of the CD audio format contains
a limited amount of graphics in subcode channels. This disc works in
all audio players but the graphics portion is only available in a
special CD+G or Karaoke player.
@item CD-i
@cindex CD-i
Compact Disc Interactive. An extension of the CD format designed
around a set-top computer that connects to a TV to provide interactive
home entertainment, including digital audio and video, video games,
and software applications. Defined by the ``Green Book'' standard.
@uref{http://www.icdia.org/}. CD-i for video and video music has
largely (if not totally) been superceded by VCDs.
@item CD-i Bridge
@cindex CD-i Bridge
A standard allowing CD-ROM XA discs to play on CD-i. Kodak PhotoCDs
are CD-XA Bridge discs.
@item CD-ROM
@cindex CD-ROM
Compact Disc Read Only Memory or ``Yellow Book'' describe in Standards
ISO/IEC 10149. The data stored on it can be either in the form of
audio, computer or video files.
@item CD-ROM Mode 1 and Mode2
The Yellow Book specifies two types of tracks, Mode 1 and Mode 2. Mode
1 is used for computer data and text and has an extra error correction
layer. Mode 2 is for audio and video data and has no extra correction
layer. CD-ROM/XA An expansion of the CD-ROM Mode 2 format that allows
both computer and audio/video to be mixed in the same track.
@item CD Text
@cindex CD Text
CD Text is a technology developed by Sony Corporation and Philips
Electronics in 1996 that allows storing in an audio CD and its tracks
information such as artist name, title, songwriter, composer, or
arranger. Commercially available audio CDs sometimes contain CD Text
information.
@item CD XA
@cindex CD XA
CD-ROM EXtended Architecture. 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.
@item Command Packet
@cindex Command Packet
The data structure that is used to issue an ATAPI command. The same
thing as a SCSI Command Descriptor Block (CDB).
@item FSF
@cindex FSF
Free Software Foundation, @uref{http://www.fsf.org/}
@item GNU
@cindex GNU
@acronym{GNU} is not @acronym{UNIX}, @uref{http://www.gnu.org/}
@item IDE
Integrated Drive Electronics. This is a commonly used interface for
hard disk drives and CD-ROM drives. It is less expensive than SCSI,
but offers slightly less in terms of performance.
@item ISO
@cindex ISO
International Standards Organization.
@item ISO 9660
@cindex ISO 9660
The ISO 9660 is an operating-system independent filesystem format for
CD-ROM media and DVD-ROMs. It was standardized in 1988 and replaced the
High Sierra standard for the logical format on CD-ROM media (ISO 9660
and High Sierra are identical in content, but the exact format is
different).
There are several specification levels. In Level 1, file names must be
in the 8.3 format (no more than eight characters in the name, no more
than three characters in the suffix) and in capital letters. Directory
names can be no longer than eight characters. There can be no more
than eight nested directory levels. Level 2 and 3 specifications allow
file names up to 32 characters long.
ECMA-119
(@uref{http://www.ecma-international.org/publications/standards/Ecma-119.htm}
is the European specification which is identical to ISO 9660.
ISO 13490 is basically ISO 9660 with multisession support.
@item Joliet extensions
@cindex Joliet extensions
This ISO-9660 upward-compatible standard was developed for Windows 95
and Windows NT by Microsoft as an extension of ISO 9600 which allows
the use of Unicode characters and supports file names up to 64
characters.
See @uref{http://bmrc.berkeley.edu/people/chaffee/jolspec.html} for
the Joliet Specification.
The name Joliet comes from the city in Illinois (U.S) that the
standard was defined.
@item LBA
@cindex LBA
Logical Block Addressing. Mapped integer numbers from CD Red Book
Addressing MSF. The starting sector is -150 and ending sector is
449849, which correlates directly to MSF: 00:00:00 to 99:59:74.
Because an LBA is a single number it is often easier to work with in
programming than an MSF.
@item Lead in
@cindex lead in
The area of a CD where the Table Of Contents (TOC) and CD Text are
stored. I think it is supposed to be around 4500 (1 min) or more
sectors in length. On a CDR(W) the lead-in length is variable,
because each manufacturer will have a different starting position
indicated by the ATIP start of lead-in position that is recorded in
the ATIP groove on the disk.
@item LSN
@cindex LSN
Logical Sector Number. Mapped integer numbers from CD Red Book
Addressing MSF. The starting sector is 0 and ending sector is 449699,
which correlates to MSF: 00:00:00 to 99:59:74. Because an LSN is a
single number it is often easier to work with in programming than an
MSF. Because it starts at 0 rather than -150 as is the case of an LBA
it can be represented as an unsigned value.
@item MCN
@cindex MCN
Media Catalog Number. A identification number on an audio CD. Also
called a UPC. Another identification number is ISRC.
@item MMC
@cindex MMC (Multimedia Commands)
MMC (Multimedia Commands). A SCSI programming specification made by
the SCSI committee T10 organization @url{http://www.t10.org/}. MMC
are raw commands for communicating with CDROM drives, CD-Rewriters,
DVD-Rewriters, etc.
Many manufacturers have adopted this standard and it also applies to
ATAPI versions of their drives.
@item Mixed Mode CD
@cindex Mixed Mode CD
A Mixed Mode is a CD that contains tracks of differing CD-ROM Mode
formats. In particular the first track may contain both computer data
(Yellow Book) CD ROM data while the remaining tracks are audio or
video data. Video CD's can be Mixed Mode CDs.
@item Multisession
@cindex Multisession
A way of writing to a CD that allows more data to be
added to readable discs at a later time.
@item Nero NRG format file
@cindex Nero NRG, CD-Image format
A proprietary CD image file format use by a popular program for
Microsoft Windows, Ahead Nero. The specification of this format is
not to our knowlege published.
@item Rock Ridge Extensions
@cindex Rock Ridge extensions
An extension to the ISO-9660 standard which adds POSIX information to files.
@item SCSI
@cindex SCSI
Small Computer System Interface. A set of ANSI standard electronic
interfaces (originally developed at Apple Computer) that allow
personal computers to communicate with peripheral hardware such as
CD-ROM drives, disk drives, printers, etc.
@item SCSI CDB
@cindex SCSI CDB
SCSI Command Descriptor Block. The data structure that is used to
issue a SCSI command.
@item SCSI Pass Through Interface.
@cindex SCSI Pass Through Interface.
Yet another way of issuing MMC commands for accessing a CD-ROM. As
with MMC or ASPI, the CD-ROM doesn't necessarily have to be a
SCSI-attached drive. See also @acronym{MMC} and @acronym{ASPI}.
@item Session
A fully readable complete recording that contains one or more tracks
of computer data or audio on a CD.
@item SVCD
@cindex Super VCD (SVCD)
Super @acronym{VCD}
An improvement of Video CD 2.0 specification which includes most
notably a switch from @acronym{MPEG}-1 (constant bit rate encoding) to
@acronym{MPEG}-2 (variable bit rate encoding) for the video stream.
Also added was higher video-stream resolution, up to 4 overlay
graphics and text (@dfn{OGT}) sub-channels for user switchable
subtitle displaying, closed caption text, and command lists for
controlling the @acronym{SVCD} virtual machine.
See @uref{http://www.dvdrhelp.com/svcd}
@item TOC
@cindex TOC (CD Table of Contents)
(Compact Disc) Table of Contents. The TOC contains the starting track
number, last track number individual track starting time, and some
track flags (copy protection, linear audio preemphasis, track format:
CDDA or data). Every CD must have at least 1 TOC, the first TOC is
always recorded at the start of the CD (lead-in area). A
multi-session CD may have several TOCs.
@item Track
@cindex track
A unit of data of a CD. The size of a track can vary; it can occupy
the entire contents of the CD. Most CD standards however require that
tracks have a 150 frame (or ``2 second'') lead-in gap.
@item VCD
@cindex Video CD (VCD)
The Video Compact Disc (@dfn{Video CD} or @dfn{VCD}) is a standardized
digital video storage format. It is based on the commonly available
Compact Disc technology, which allows for low-cost video authoring.
Video CD's can be played in most @acronym{DVD} standalone player,
dedicated VCD players and finally, modern Personal Computers with
multimedia support.
A Video CD is made up of @acronym{CD-ROM XA} sectors,
i.e. @acronym{CD-ROM} mode 2 form 1 & 2 sectors. Non-@acronym{MPEG} data
is stored in mode 2 form 1 sectors with a user data area of 2048 byte,
which have a similiar L2 error correction and detection
(@acronym{ECC}/@acronym{EDC}) to @acronym{CD-ROM} mode 1 sectors. While
realtime @acronym{MPEG} streams is stored in @acronym{CD-ROM} mode 2
form 2 sectors, which by have no L2 @acronym{ECC}, yield a ~14% greater
user data area consisting of 2324 bytes@footnote{actually raw mode 2
sectors have a 2336 byte user data area, but parts of it are used for
error codes and headers when using the mode 2 form 1 or form 2
configurations.}
@uref{http://www.dvdrhelp.com/vcd}
@item Win32 ASPI
@cindex ASPI
The ASPI interface specification was developed by Adaptec for
sending commands to a SCSI host adapter (such as those controlling CD
and DVD drives) and used on Window 9x/NT and later. Emulation for
ATAPI drives was added so that the same sets of commands worked those
even though the drives might not be SCSI nor might there even be a
SCSI controller attached.
However in Windows NT/2K/XP, Microsoft provides their Win32 ioctl
interface, and has take steps to make using ASPI more inaccessible
(e.g. requiring adminstrative access to use ASPI).
See also @acronym{MMC}
@item Win32 ioctl driver
Ioctl (Input Output ConTroLs). A Win32 function, implemented in all
Microsoft Windows. It is used for sending commands to devices using
defined codes and structures.
@item XA
@cindex XA
See @acronym{CD-ROM XA}
@end table

2421
doc/libcdio.texi Normal file

File diff suppressed because it is too large Load Diff

3
example/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/.deps
/Makefile
/Makefile.in

15
example/C++/.cvsignore Normal file
View File

@@ -0,0 +1,15 @@
Makefile
Makefile.in
.deps
.libs
copying
device
eject
isolist
isofile
isofile2
mmc1
mmc2
paranoia
paranoia2

3
example/C++/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/.deps
/Makefile
/Makefile.in

67
example/C++/Makefile.am Normal file
View File

@@ -0,0 +1,67 @@
# $Id: Makefile.am,v 1.13 2008/08/31 13:38:21 flameeyes 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/>.
##########################################################
# Sample C++ programs using libcdio (without OO wrapper)
#########################################################
#
SUBDIRS = OO
if BUILD_CD_PARANOIA
paranoia_progs = paranoia paranoia2
endif
if BUILD_EXAMPLES
noinst_PROGRAMS = device eject isofile isofile2 isolist \
mmc1 mmc2 $(paranoia_progs)
endif
INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS)
device_DEPENDENCIES = $(LIBCDIO_DEPS)
device_SOURCES = device.cpp
device_LDADD = $(LIBCDIO_LIBS)
eject_DEPENDENCIES = $(LIBCDIO_DEPS)
eject_SOURCES = eject.cpp
eject_LDADD = $(LIBCDIO_LIBS)
if BUILD_CD_PARANOIA
paranoia_SOURCES = paranoia.cpp
paranoia_LDADD = $(LIBCDIO_PARANOIA_LIBS) $(LIBCDIO_CDDA_LIBS) \
$(LIBCDIO_LIBS)
paranoia2_SOURCES = paranoia.cpp
paranoia2_LDADD = $(LIBCDIO_PARANOIA_LIBS) $(LIBCDIO_CDDA_LIBS) \
$(LIBCDIO_LIBS)
endif
isofile_SOURCES = isofile.cpp
isofile_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
isofile2_SOURCES = isofile2.cpp
isofile2_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
isolist_SOURCES = isolist.cpp
isolist_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
mmc1_SOURCES = mmc1.cpp
mmc1_DEPENDENCIES = $(LIBCDIO_DEPS)
mmc1_LDADD = $(LIBCDIO_LIBS)
mmc2_SOURCES = mmc2.cpp
mmc2_DEPENDENCIES = $(LIBCDIO_DEPS)
mmc2_LDADD = $(LIBCDIO_LIBS)
# iso programs create file "copying"
MOSTLYCLEANFILES = copying

17
example/C++/OO/.cvsignore Normal file
View File

@@ -0,0 +1,17 @@
.deps
.libs
Makefile
Makefile.am
Makefile.in
cdtext
copying
device
drives
eject
iso4
isofile2
isofile
isolist
mmc1
mmc2
tracks

3
example/C++/OO/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/.deps
/Makefile
/Makefile.in

View File

@@ -0,0 +1,69 @@
# $Id: Makefile.am,v 1.13 2008/08/31 13:38:21 flameeyes 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/>.
############################################################
# Sample C++ programs using libcdio++ (with C++ OO wrapper)
############################################################
#
noinst_PROGRAMS = cdtext device drives eject \
isofile isofile2 isolist iso4 mmc1 mmc2 tracks
INCLUDES = -I$(top_srcdir)/include $(LIBCDIO_CFLAGS)
cdtext_SOURCES = cdtext.cpp
cdtext_DEPENDENCIES = $(LIBCDIO_DEPS)
cdtext_LDADD = $(LIBCDIOPP_LIBS) $(LIBCDIO_LIBS)
device_SOURCES = device.cpp
device_DEPENDENCIES = $(LIBCDIO_DEPS)
device_LDADD = $(LIBCDIOPP_LIBS) $(LIBCDIO_LIBS)
drives_SOURCES = drives.cpp
drives_DEPENDENCIES = $(LIBCDIO_DEPS)
drives_LDADD = $(LIBCDIOPP_LIBS) $(LIBCDIO_LIBS)
eject_SOURCES = eject.cpp
eject_DEPENDENCIES = $(LIBCDIO_DEPS)
eject_LDADD = $(LIBCDIOPP_LIBS) $(LIBCDIO_LIBS)
isofile_SOURCES = isofile.cpp
isofile_LDADD = $(LIBISO9660PP_LIBS) $(LIBISO9660_LIBS) \
$(LIBCDIOPP_LIBS) $(LTLIBICONV)
isofile2_SOURCES = isofile2.cpp
isofile2_LDADD = $(LIBISO9660PP_LIBS) $(LIBISO9660_LIBS) \
$(LIBCDIOPP_LIBS) $(LTLIBICONV)
isolist_SOURCES = isolist.cpp
isolist_LDADD = $(LIBISO9660PP_LIBS) $(LIBISO9660_LIBS) \
$(LIBCDIOPP_LIBS) $(LTLIBICONV)
iso4_SOURCES = iso4.cpp
iso4_LDADD = $(LIBISO9660PP_LIBS) $(LIBISO9660_LIBS) \
$(LIBCDIOPP_LIBS) $(LTLIBICONV)
mmc1_SOURCES = mmc1.cpp
mmc1_DEPENDENCIES = $(LIBCDIO_DEPS)
mmc1_LDADD = $(LIBCDIOPP_LIBS) $(LIBCDIO_LIBS)
mmc2_SOURCES = mmc2.cpp
mmc2_DEPENDENCIES = $(LIBCDIO_DEPS)
mmc2_LDADD = $(LIBCDIOPP_LIBS) $(LIBCDIO_LIBS)
tracks_SOURCES = tracks.cpp
tracks_LDADD = $(LIBCDIOPP_LIBS) $(LIBCDIO_LIBS)

105
example/C++/OO/cdtext.cpp Normal file
View File

@@ -0,0 +1,105 @@
/*
$Id: cdtext.cpp,v 1.4 2008/03/24 15:30:57 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/>.
*/
/* Simple program to list CD-Text info of a Compact Disc using
libcdio. An optional drive name can be supplied as an argument.
See also corresponding C program of a similar name.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio++/cdio.hpp>
/* Set up a CD-DA image to test on which is in the libcdio distribution. */
#define CDDA_IMAGE_PATH "../../../test/"
#define CDDA_IMAGE CDDA_IMAGE_PATH "cdda.cue"
static void
print_cdtext_track_info(CdioDevice *device, track_t i_track,
const char *psz_msg) {
cdtext_t *cdtext = device->getCdtext(0);
if (NULL != cdtext) {
cdtext_field_t i;
printf("%s\n", psz_msg);
for (i= (cdtext_field_t) MIN_CDTEXT_FIELD; i < MAX_CDTEXT_FIELDS; i++) {
if (cdtext->field[i]) {
printf("\t%s: %s\n", cdtext_field2str(i), cdtext->field[i]);
}
}
}
}
static void
print_disc_info(CdioDevice *device, track_t i_tracks, track_t i_first_track) {
track_t i_last_track = i_first_track+i_tracks;
discmode_t cd_discmode = device->getDiscmode();
printf("%s\n", discmode2str[cd_discmode]);
print_cdtext_track_info(device, 0, "\nCD-Text for Disc:");
for ( ; i_first_track < i_last_track; i_first_track++ ) {
char psz_msg[50];
sprintf(psz_msg, "CD-Text for Track %d:", i_first_track);
print_cdtext_track_info(device, i_first_track, psz_msg);
}
}
int
main(int argc, const char *argv[])
{
track_t i_first_track;
track_t i_tracks;
CdioDevice *device = new CdioDevice;
const char *psz_drive = NULL;
if (!device->open(CDDA_IMAGE, DRIVER_BINCUE)) {
printf("Couldn't open " CDDA_IMAGE " with BIN/CUE driver.\n");
} else {
i_first_track = device->getFirstTrackNum();
i_tracks = device->getNumTracks();
print_disc_info(device, i_tracks, i_first_track);
}
if (argc > 1) psz_drive = argv[1];
if (!device->open(psz_drive, DRIVER_DEVICE)) {
printf("Couldn't find CD\n");
return 1;
} else {
i_first_track = device->getFirstTrackNum();
i_tracks = device->getNumTracks();
print_disc_info(device, i_tracks, i_first_track);
}
delete(device);
return 0;
}

138
example/C++/OO/device.cpp Normal file
View File

@@ -0,0 +1,138 @@
/*
$Id: device.cpp,v 1.4 2008/03/24 15:30:57 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/>.
*/
/* Simple program to show drivers installed and what the default
CD-ROM drive is. See also corresponding C program of a similar
name. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio++/cdio.hpp>
#define _(x) x
/* Prints out drive capabilities */
static void
print_drive_capabilities(cdio_drive_read_cap_t i_read_cap,
cdio_drive_write_cap_t i_write_cap,
cdio_drive_misc_cap_t i_misc_cap)
{
if (CDIO_DRIVE_CAP_ERROR == i_misc_cap) {
printf("Error in getting drive hardware properties\n");
} else {
printf(_("Hardware : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_FILE
? "Disk Image" : "CD-ROM or DVD");
printf(_("Can eject : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_EJECT ? "Yes" : "No");
printf(_("Can close tray : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_CLOSE_TRAY ? "Yes" : "No");
printf(_("Can disable manual eject : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_LOCK ? "Yes" : "No");
printf(_("Can select juke-box disc : %s\n\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_DISC ? "Yes" : "No");
printf(_("Can set drive speed : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_SPEED ? "Yes" : "No");
printf(_("Can detect if CD changed : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED ? "Yes" : "No");
printf(_("Can read multiple sessions : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_MULTI_SESSION ? "Yes" : "No");
printf(_("Can hard reset device : %s\n\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_RESET ? "Yes" : "No");
}
if (CDIO_DRIVE_CAP_ERROR == i_read_cap) {
printf("Error in getting drive reading properties\n");
} else {
printf("Reading....\n");
printf(_(" Can play audio : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_AUDIO ? "Yes" : "No");
printf(_(" Can read CD-R : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_CD_R ? "Yes" : "No");
printf(_(" Can read CD-RW : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_CD_RW ? "Yes" : "No");
printf(_(" Can read DVD-ROM : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_DVD_ROM ? "Yes" : "No");
}
if (CDIO_DRIVE_CAP_ERROR == i_write_cap) {
printf("Error in getting drive writing properties\n");
} else {
printf("\nWriting....\n");
printf(_(" Can write CD-RW : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_CD_RW ? "Yes" : "No");
printf(_(" Can write DVD-R : %s\n"),
i_write_cap & CDIO_DRIVE_CAP_READ_DVD_R ? "Yes" : "No");
printf(_(" Can write DVD-RAM : %s\n"),
i_write_cap & CDIO_DRIVE_CAP_READ_DVD_RAM ? "Yes" : "No");
}
}
int
main(int argc, const char *argv[])
{
CdioDevice device;
if (device.open(NULL)) {
char *default_device = device.getDevice();
cdio_drive_read_cap_t i_read_cap;
cdio_drive_write_cap_t i_write_cap;
cdio_drive_misc_cap_t i_misc_cap;
printf("The driver selected is %s\n", device.getDriverName());
if (default_device)
printf("The default device for this driver is %s\n", default_device);
device.getDriveCap(i_read_cap, i_write_cap, i_misc_cap);
print_drive_capabilities(i_read_cap, i_write_cap, i_misc_cap);
free(default_device);
printf("\n");
} else {
printf("Problem in trying to find a driver.\n\n");
}
{
driver_id_t driver_id;
for (driver_id=CDIO_MIN_DRIVER; driver_id<=CDIO_MAX_DRIVER; driver_id++)
if (cdio_have_driver(driver_id))
printf("We have: %s\n", cdio_driver_describe(driver_id));
else
printf("We don't have: %s\n", cdio_driver_describe(driver_id));
}
return 0;
}

90
example/C++/OO/drives.cpp Normal file
View File

@@ -0,0 +1,90 @@
/*
$Id: drives.cpp,v 1.6 2008/03/24 15:30:57 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/>.
*/
/* Simple program to show drivers installed and what the default
CD-ROM drive is and what CD drives are available. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio++/cdio.hpp>
#include <cdio/cd_types.h>
#include <cdio/logging.h>
static void
log_handler (cdio_log_level_t level, const char message[])
{
switch(level) {
case CDIO_LOG_DEBUG:
case CDIO_LOG_INFO:
return;
default:
printf("cdio %d message: %s\n", level, message);
}
}
static void
print_drive_class(const char *psz_msg, cdio_fs_anal_t bitmask,
bool b_any=false) {
char **ppsz_cd_drives=NULL, **c;
printf("%s...\n", psz_msg);
ppsz_cd_drives = getDevices(NULL, bitmask, b_any);
if (NULL != ppsz_cd_drives)
for( c = ppsz_cd_drives; *c != NULL; c++ ) {
printf("Drive %s\n", *c);
}
freeDeviceList(ppsz_cd_drives);
printf("-----\n");
}
int
main(int argc, const char *argv[])
{
char **ppsz_cd_drives=NULL, **c;
cdio_log_set_handler (log_handler);
/* Print out a list of CD-drives */
printf("All CD-ROM/DVD drives...\n");
ppsz_cd_drives = getDevices();
if (NULL != ppsz_cd_drives)
for( c = ppsz_cd_drives; *c != NULL; c++ ) {
printf("Drive %s\n", *c);
}
freeDeviceList(ppsz_cd_drives);
print_drive_class("All CD-ROM drives (again)", CDIO_FS_MATCH_ALL);
print_drive_class("CD-ROM drives with a CD-DA loaded...", CDIO_FS_AUDIO);
print_drive_class("CD-ROM drives with some sort of ISO 9660 filesystem...",
CDIO_FS_ANAL_ISO9660_ANY, true);
print_drive_class("(S)VCD drives...", CDIO_FS_ANAL_VCD_ANY, true);
return 0;
}

83
example/C++/OO/eject.cpp Normal file
View File

@@ -0,0 +1,83 @@
/*
$Id: eject.cpp,v 1.7 2008/03/24 15:30:57 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/>.
*/
/* Simple program to eject a CD-ROM drive door and then close it again.
If a single argument is given, it is used as the CD-ROM device to
eject/close. Otherwise a CD-ROM drive will be scanned for.
See also corresponding C program of a similar name.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cdio++/cdio.hpp>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
int
main(int argc, const char *argv[])
{
driver_return_code_t ret;
driver_id_t driver_id = DRIVER_DEVICE;
char *psz_drive = NULL;
CdioDevice device;
if (argc > 1)
psz_drive = strdup(argv[1]);
if (!psz_drive) {
psz_drive = getDefaultDevice(driver_id);
if (!psz_drive) {
printf("Can't find a CD-ROM to perform eject operation\n");
exit(1);
}
}
try {
ejectMedia(psz_drive);
printf("CD in CD-ROM drive %s ejected.\n", psz_drive);
}
catch ( DriverOpUninit e ) {
printf("Can't Eject CD from CD-ROM drive: driver is not initialized.\n",
psz_drive);
}
catch ( DriverOpException e ) {
printf("Ejecting CD from CD-ROM drive %s operation error:\n\t%s.\n",
psz_drive, e.get_msg());
}
try {
closeTray(psz_drive);
printf("Closed CD-ROM %s tray.\n", psz_drive);
}
catch ( DriverOpException e ) {
printf("Closing CD-ROM %s tray operation error error:\n\t%s.\n",
psz_drive, e.get_msg());
}
free(psz_drive);
return 0;
}

118
example/C++/OO/iso4.cpp Normal file
View File

@@ -0,0 +1,118 @@
/*
$Id: iso4.cpp,v 1.2 2008/03/24 15:30:57 karl 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/>.
*/
/* Simple program to show using libiso9660 to list files in a directory of
an ISO-9660 image and give some iso9660 information. See the code
to iso-info for a more complete example.
If a single argument is given, it is used as the ISO 9660 image to
use in the listing. Otherwise a compiled-in default ISO 9660 image
name (that comes with the libcdio distribution) will be used.
This program can be compiled with either a C or C++ compiler. In
the distributuion we perfer C++ just to make sure we haven't broken
things on the C++ side.
*/
/* Set up a CD-DA image to test on which is in the libcdio distribution. */
#define ISO9660_IMAGE_PATH "../../../"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/isofs-m1.cue"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <sys/types.h>
#include <cdio++/iso9660.hpp>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define print_vd_info(title, fn) \
psz_str = p_pvd->fn(); \
if (psz_str) { \
printf(title ": %s\n", psz_str); \
free(psz_str); \
psz_str = NULL; \
}
int
main(int argc, const char *argv[])
{
stat_vector_t stat_vector;
ISO9660::FS *p_iso = new ISO9660::FS;
char const *psz_fname;
const char *psz_path="/";
ISO9660::PVD *p_pvd;
if (argc > 1)
psz_fname = argv[1];
else
psz_fname = ISO9660_IMAGE;
if (!p_iso->open(psz_fname, DRIVER_UNKNOWN)) {
fprintf(stderr, "Sorry, couldn't open %s as a CD or CD image.\n",
psz_fname);
return 1;
}
p_pvd = p_iso->read_pvd();
if (p_pvd) {
char *psz_str = NULL;
print_vd_info("Application", get_application_id);
print_vd_info("Preparer ", get_preparer_id);
print_vd_info("Publisher ", get_publisher_id);
print_vd_info("System ", get_system_id);
print_vd_info("Volume ", get_volume_id);
print_vd_info("Volume Set ", get_volumeset_id);
}
if (p_iso->readdir (psz_path, stat_vector))
{
/* Iterate over the list of files. */
stat_vector_iterator_t i;
for(i=stat_vector.begin(); i != stat_vector.end(); ++i)
{
char filename[4096];
ISO9660::Stat *p_s = *i;
iso9660_name_translate(p_s->p_stat->filename, filename);
printf ("%s [LSN %6d] %8u %s%s\n",
2 == p_s->p_stat->type ? "d" : "-",
p_s->p_stat->lsn, p_s->p_stat->size, psz_path, filename);
delete(p_s);
}
stat_vector.clear();
}
delete(p_iso);
return 0;
}

158
example/C++/OO/isofile.cpp Normal file
View File

@@ -0,0 +1,158 @@
/*
$Id: isofile.cpp,v 1.2 2008/03/24 15:30:57 karl 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/>.
*/
/* Simple program to show using libiso9660 to extract a file from an
ISO-9660 image.
If a single argument is given, it is used as the ISO 9660 image to
use in the extraction. Otherwise a compiled in default ISO 9660 image
name (that comes with the libcdio distribution) will be used.
*/
/* This is the ISO 9660 image. */
#define ISO9660_IMAGE_PATH "../../../"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/copying.iso"
#define LOCAL_FILENAME "copying"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "portable.h"
#include <sys/types.h>
#include <cdio++/iso9660.hpp>
#include <stdio.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define CEILING(x, y) ((x+(y-1))/y)
#define my_exit(rc) \
fclose (p_outfd); \
delete (p_stat); \
delete (p_iso); \
return rc; \
int
main(int argc, const char *argv[])
{
ISO9660::Stat *p_stat;
FILE *p_outfd;
int i;
char const *psz_image;
char const *psz_fname;
ISO9660::IFS *p_iso = new ISO9660::IFS;
if (argc > 3) {
printf("usage %s [ISO9660-image.ISO [filename]]\n", argv[0]);
printf("Extracts filename from ISO-9660-image.ISO.\n");
return 1;
}
if (argc > 1)
psz_image = argv[1];
else
psz_image = ISO9660_IMAGE;
if (argc > 2)
psz_fname = argv[2];
else
psz_fname = LOCAL_FILENAME;
if (!p_iso->open(psz_image)) {
fprintf(stderr, "Sorry, couldn't open ISO 9660 image %s\n", psz_image);
return 1;
}
p_stat = p_iso->stat(psz_fname, true);
if (!p_stat)
{
fprintf(stderr,
"Could not get ISO-9660 file information for file %s\n",
psz_fname);
delete(p_iso);
return 2;
}
if (!(p_outfd = fopen (psz_fname, "wb")))
{
perror ("fopen()");
delete (p_stat);
delete (p_iso);
return 3;
}
/* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */
{
const unsigned int i_blocks = CEILING(p_stat->p_stat->size, ISO_BLOCKSIZE);
for (i = 0; i < i_blocks ; i++)
{
char buf[ISO_BLOCKSIZE];
const lsn_t lsn = p_stat->p_stat->lsn + i;
memset (buf, 0, ISO_BLOCKSIZE);
if ( ISO_BLOCKSIZE != p_iso->seek_read (buf, lsn, 1) )
{
fprintf(stderr, "Error reading ISO 9660 file %s at LSN %lu\n",
psz_fname, (long unsigned int) lsn);
my_exit(4);
}
fwrite (buf, ISO_BLOCKSIZE, 1, p_outfd);
if (ferror (p_outfd))
{
perror ("fwrite()");
my_exit(5);
}
}
}
fflush (p_outfd);
/* Make sure the file size has the exact same byte size. Without the
truncate below, the file will a multiple of ISO_BLOCKSIZE.
*/
if (ftruncate (fileno (p_outfd), p_stat->p_stat->size))
perror ("ftruncate()");
printf("Extraction of file '%s' from %s successful.\n",
psz_fname, psz_image);
my_exit(0);
}

178
example/C++/OO/isofile2.cpp Normal file
View File

@@ -0,0 +1,178 @@
/*
$Id: isofile2.cpp,v 1.2 2008/03/24 15:30:57 karl 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/>.
*/
/* Simple program to show using libiso9660 to extract a file from a
CUE/BIN CD image.
If a single argument is given, it is used as the CUE file of a CD image
to use. Otherwise a compiled-in default image name (that
comes with the libcdio distribution) will be used.
This program can be compiled with either a C or C++ compiler. In
the distribution we prefer C++ just to make sure we haven't broken
things on the C++ side.
*/
/* This is the CD-image with an ISO-9660 filesystem */
#define ISO9660_IMAGE_PATH "../../../"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/isofs-m1.cue"
#define ISO9660_PATH "/"
#define ISO9660_FILENAME "COPYING"
#define LOCAL_FILENAME "copying"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "portable.h"
#include <cdio++/cdio.hpp>
#include <cdio++/iso9660.hpp>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define CEILING(x, y) ((x+(y-1))/y)
#define my_exit(rc) \
fclose (p_outfd); \
delete (p_stat); \
delete (p_iso); \
return rc; \
int
main(int argc, const char *argv[])
{
ISO9660::Stat *p_stat;
FILE *p_outfd;
unsigned int i;
char const *psz_image;
char const *psz_fname;
char translated_name[256];
char untranslated_name[256] = ISO9660_PATH;
ISO9660::FS *p_iso = new ISO9660::FS;
if (argc > 3) {
printf("usage %s [CD-ROM-or-image [filename]]\n", argv[0]);
printf("Extracts filename from CD-ROM-or-image.\n");
return 1;
}
if (argc > 1)
psz_image = argv[1];
else
psz_image = ISO9660_IMAGE;
if (argc > 2)
psz_fname = argv[2];
else
psz_fname = ISO9660_FILENAME;
strcat(untranslated_name, psz_fname);
if (!p_iso->open(psz_image, DRIVER_UNKNOWN)) {
fprintf(stderr, "Sorry, couldn't open %s\n", psz_image);
return 1;
}
p_stat = p_iso->stat(psz_fname);
if (!p_stat)
{
fprintf(stderr,
"Could not get ISO-9660 file information for file %s\n",
untranslated_name);
delete(p_iso);
return 2;
}
iso9660_name_translate(psz_fname, translated_name);
if (!(p_outfd = fopen (translated_name, "wb")))
{
perror ("fopen()");
delete (p_stat);
delete (p_iso);
return 3;
}
/* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */
{
const unsigned int i_blocks = CEILING(p_stat->p_stat->size, ISO_BLOCKSIZE);
for (i = 0; i < i_blocks; i ++)
{
char buf[ISO_BLOCKSIZE];
const lsn_t lsn = p_stat->p_stat->lsn + i;
memset (buf, 0, ISO_BLOCKSIZE);
try {
p_iso->readDataBlocks(buf, lsn, ISO_BLOCKSIZE);
}
catch ( DriverOpException e ) {
fprintf(stderr, "Error reading ISO 9660 file at lsn %lu:\n\t%s.\n",
(long unsigned int) lsn, e.get_msg());
my_exit(4);
}
fwrite (buf, ISO_BLOCKSIZE, 1, p_outfd);
if (ferror (p_outfd))
{
perror ("fwrite()");
my_exit(5);
}
}
}
fflush (p_outfd);
/* Make sure the file size has the exact same byte size. Without the
truncate below, the file will a multiple of ISO_BLOCKSIZE.
*/
if (ftruncate (fileno (p_outfd), p_stat->p_stat->size))
perror ("ftruncate()");
printf("Extraction of file '%s' from '%s' successful.\n",
translated_name, untranslated_name);
my_exit(0);
}

117
example/C++/OO/isolist.cpp Normal file
View File

@@ -0,0 +1,117 @@
/*
$Id: isolist.cpp,v 1.2 2008/03/24 15:30:57 karl 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/>.
*/
/* Simple program to show using libiso9660 to list files in a directory of
an ISO-9660 image and give some iso9660 information. See the code
to iso-info for a more complete example.
If a single argument is given, it is used as the ISO 9660 image to
use in the listing. Otherwise a compiled-in default ISO 9660 image
name (that comes with the libcdio distribution) will be used.
This program can be compiled with either a C or C++ compiler. In
the distributuion we perfer C++ just to make sure we haven't broken
things on the C++ side.
*/
/* Set up a CD-DA image to test on which is in the libcdio distribution. */
#define ISO9660_IMAGE_PATH "../../../"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/copying.iso"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <sys/types.h>
#include <cdio++/iso9660.hpp>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define print_vd_info(title, fn) \
if (p_iso->fn(psz_str)) { \
printf(title ": %s\n", psz_str); \
} \
free(psz_str); \
psz_str = NULL;
int
main(int argc, const char *argv[])
{
stat_vector_t stat_vector;
ISO9660::IFS *p_iso = new ISO9660::IFS;
char const *psz_fname;
const char *psz_path="/";
if (argc > 1)
psz_fname = argv[1];
else
psz_fname = ISO9660_IMAGE;
if (!p_iso->open(psz_fname)) {
fprintf(stderr, "Sorry, couldn't open %s as an ISO-9660 image\n",
psz_fname);
return 1;
}
/* Show basic CD info from the Primary Volume Descriptor. */
{
char *psz_str = NULL;
print_vd_info("Application", get_application_id);
print_vd_info("Preparer ", get_preparer_id);
print_vd_info("Publisher ", get_publisher_id);
print_vd_info("System ", get_system_id);
print_vd_info("Volume ", get_volume_id);
print_vd_info("Volume Set ", get_volumeset_id);
}
if (p_iso->readdir (psz_path, stat_vector))
{
/* Iterate over the list of files. */
stat_vector_iterator_t i;
for(i=stat_vector.begin(); i != stat_vector.end(); ++i)
{
char filename[4096];
ISO9660::Stat *p_s = *i;
iso9660_name_translate(p_s->p_stat->filename, filename);
printf ("%s [LSN %6d] %8u %s%s\n",
2 == p_s->p_stat->type ? "d" : "-",
p_s->p_stat->lsn, p_s->p_stat->size, psz_path, filename);
delete(p_s);
}
stat_vector.clear();
}
delete(p_iso);
return 0;
}

85
example/C++/OO/mmc1.cpp Normal file
View File

@@ -0,0 +1,85 @@
/*
$Id: mmc1.cpp,v 1.2 2008/03/24 15:30:57 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/>.
*/
/* Sample program to show use of the MMC interface.
An optional drive name can be supplied as an argument.
This basically the libdio mmc_get_hwinfo() routine.
See also corresponding C and non OO C++ program.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <cdio++/cdio.hpp>
/* Set how long to wait for MMC commands to complete */
#define DEFAULT_TIMEOUT_MS 10000
int
main(int argc, const char *argv[])
{
CdioDevice device;
const char *psz_drive = NULL;
if (argc > 1) psz_drive = argv[1];
if (!device.open(psz_drive)) {
printf("Couldn't find CD\n");
return 1;
} else {
int i_status; /* Result of MMC command */
char buf[36] = { 0, }; /* Place to hold returned data */
mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Buffer */
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_INQUIRY);
cdb.field[4] = sizeof(buf);
i_status = device.mmcRunCmd(DEFAULT_TIMEOUT_MS, &cdb,
SCSI_MMC_DATA_READ, sizeof(buf), &buf);
if (i_status == 0) {
char psz_vendor[CDIO_MMC_HW_VENDOR_LEN+1];
char psz_model[CDIO_MMC_HW_MODEL_LEN+1];
char psz_rev[CDIO_MMC_HW_REVISION_LEN+1];
memcpy(psz_vendor, buf + 8, sizeof(psz_vendor)-1);
psz_vendor[sizeof(psz_vendor)-1] = '\0';
memcpy(psz_model,
buf + 8 + CDIO_MMC_HW_VENDOR_LEN,
sizeof(psz_model)-1);
psz_model[sizeof(psz_model)-1] = '\0';
memcpy(psz_rev,
buf + 8 + CDIO_MMC_HW_VENDOR_LEN +CDIO_MMC_HW_MODEL_LEN,
sizeof(psz_rev)-1);
psz_rev[sizeof(psz_rev)-1] = '\0';
printf("Vendor: %s\nModel: %s\nRevision: %s\n",
psz_vendor, psz_model, psz_rev);
} else {
printf("Couldn't get INQUIRY data (vendor, model, and revision).\n");
}
}
return 0;
}

189
example/C++/OO/mmc2.cpp Normal file
View File

@@ -0,0 +1,189 @@
/*
$Id: mmc2.cpp,v 1.2 2008/03/24 15:30:57 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/>.
*/
/* A program to using the MMC interface to list CD and drive features
from the MMC GET_CONFIGURATION command . */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#ifdef HAVE_SYS_TYPE_H
#include <sys/types.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <cdio++/cdio.hpp>
/* Set how long do wto wait for SCSI-MMC commands to complete */
#define DEFAULT_TIMEOUT_MS 10000
int
main(int argc, const char *argv[])
{
CdioDevice device;
const char *psz_drive = NULL;
if (argc > 1) psz_drive = argv[1];
if (!device.open(psz_drive)) {
printf("Couldn't find CD\n");
return 1;
} else {
int i_status; /* Result of MMC command */
uint8_t buf[500] = { 0, }; /* Place to hold returned data */
mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Buffer */
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_GET_CONFIGURATION);
CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf));
cdb.field[1] = CDIO_MMC_GET_CONF_ALL_FEATURES;
cdb.field[3] = 0x0;
i_status = device.mmcRunCmd(0, &cdb, SCSI_MMC_DATA_READ, sizeof(buf),
&buf);
if (i_status == 0) {
uint8_t *p;
uint32_t i_data;
uint8_t *p_max = buf + 65530;
i_data = (unsigned int) CDIO_MMC_GET_LEN32(buf);
/* set to first sense feature code, and then walk through the masks */
p = buf + 8;
while( (p < &(buf[i_data])) && (p < p_max) ) {
uint16_t i_feature;
uint8_t i_feature_additional = p[3];
i_feature = CDIO_MMC_GET_LEN16(p);
{
uint8_t *q;
const char *feature_str = mmc_feature2str(i_feature);
printf("%s Feature\n", feature_str);
switch( i_feature )
{
case CDIO_MMC_FEATURE_PROFILE_LIST:
for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) {
int i_profile=CDIO_MMC_GET_LEN16(q);
const char *feature_profile_str =
mmc_feature_profile2str(i_profile);
printf( "\t%s", feature_profile_str );
if (q[2] & 1) {
printf(" - on");
}
printf("\n");
}
printf("\n");
break;
case CDIO_MMC_FEATURE_CORE:
{
uint8_t *q = p+4;
uint32_t i_interface_standard = CDIO_MMC_GET_LEN32(q);
switch(i_interface_standard) {
case 0:
printf("\tunspecified interface\n");
break;
case 1:
printf("\tSCSI interface\n");
break;
case 2:
printf("\tATAPI interface\n");
break;
case 3:
printf("\tIEEE 1394 interface\n");
break;
case 4:
printf("\tIEEE 1394A interface\n");
break;
case 5:
printf("\tFibre Channel interface\n");
}
printf("\n");
break;
}
case CDIO_MMC_FEATURE_REMOVABLE_MEDIUM:
switch(p[4] >> 5) {
case 0:
printf("\tCaddy/Slot type loading mechanism\n");
break;
case 1:
printf("\tTray type loading mechanism\n");
break;
case 2:
printf("\tPop-up type loading mechanism\n");
break;
case 4:
printf("\tEmbedded changer with individually changeable discs\n");
break;
case 5:
printf("\tEmbedded changer using a magazine mechanism\n");
break;
default:
printf("\tUnknown changer mechanism\n");
}
printf("\tcan%s eject the medium or magazine via the normal "
"START/STOP command\n",
(p[4] & 8) ? "": "not");
printf("\tcan%s be locked into the Logical Unit\n",
(p[4] & 1) ? "": "not");
printf("\n");
break;
case CDIO_MMC_FEATURE_CD_READ:
printf("CD Read Feature\n");
printf("\tC2 Error pointers are %ssupported\n",
(p[4] & 2) ? "": "not ");
printf("\tCD-Text is %ssupported\n",
(p[4] & 1) ? "": "not ");
printf("\n");
break;
case CDIO_MMC_FEATURE_CDDA_EXT_PLAY:
printf("\tSCAN command is %ssupported\n",
(p[4] & 4) ? "": "not ");
printf("\taudio channels can %sbe muted separately\n",
(p[4] & 2) ? "": "not ");
printf("\taudio channels can %shave separate volume levels\n",
(p[4] & 1) ? "": "not ");
{
uint8_t *q = p+6;
uint16_t i_vol_levels = CDIO_MMC_GET_LEN16(q);
printf("\t%d volume levels can be set\n", i_vol_levels);
}
printf("\n");
break;
case CDIO_MMC_FEATURE_LU_SN: {
uint8_t i_serial = *(p+3);
char serial[257] = { '\0', };
memcpy(serial, p+4, i_serial);
printf("\t%s\n\n", serial);
break;
}
default:
printf("\n");
break;
}
p += i_feature_additional + 4;
}
}
} else {
printf("Didn't get all feature codes\n");
}
}
return 0;
}

64
example/C++/OO/tracks.cpp Normal file
View File

@@ -0,0 +1,64 @@
/*
$Id: tracks.cpp,v 1.2 2008/03/24 15:30:57 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/>.
*/
/* Simple program to list track numbers and logical sector numbers of
a Compact Disc using libcdio. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio++/cdio.hpp>
int
main(int argc, const char *argv[])
{
CdioDevice device;
track_t i_first_track;
track_t i_tracks;
int j, i;
CdioTrack *track;
if (!device.open (NULL)) {
printf("Couldn't find a driver.. leaving.\n");
return 1;
}
i_tracks = device.getNumTracks();
i_first_track = i = device.getFirstTrackNum();
printf("CD-ROM Track List (%i - %i)\n", i_first_track, i_tracks);
printf(" #: LSN\n");
for (j = 0; j < i_tracks; i++, j++) {
track = device.getTrackFromNum(i);
lsn_t lsn = track->getLsn();
if (CDIO_INVALID_LSN != lsn)
printf("%3d: %06lu\n", (int) i, (long unsigned int) lsn);
delete(track);
}
track = device.getTrackFromNum(CDIO_CDROM_LEADOUT_TRACK);
printf("%3X: %06lu leadout\n", CDIO_CDROM_LEADOUT_TRACK,
(long unsigned int) track->getLsn());
delete(track);
return 0;
}

41
example/C++/README Normal file
View File

@@ -0,0 +1,41 @@
$Id: README,v 1.4 2006/04/15 16:22:49 rocky Exp $
This directory contains some simple C++ examples of the use of the libcdio
library.
Descriptions of the programs in this example directory are as follows...
device.cpp: A program to show drivers installed and what the default
CD-ROM drive is and what CD drives are available.
eject.cpp: A program eject a CD from a CD-ROM drive and then close the door
again.
isofile.cpp: A program to show using libiso9660 to extract a file from an
ISO-9660 image.
isofile2.cpp: A program to show using libiso9660 to extract a file
from a CDRWIN cue/bin CD image.
isolist.cpp: A program to show using libiso9660 to list files in a
directory of an ISO-9660 image and give basic iso9660
information.
mmc1.cpp: A program to show issuing a simple MMC command (INQUIRY).
mmc2.cpp: A more involved MMC command to list features from
a MMC GET_CONFIGURATION command.
paranoia.cpp: A program to show using CD-DA paranoia (a library for jitter
detection and audio-read error correction). This program uses
an interface compatible (mostly) with cdparanoia.
paranoia2.cpp: Another program to show using CD-DA paranoia using a more
libcdio-oriented initialization. Probably more suited to
things that otherwise use libcdio such as media players
(e.g. for getting CDDB or CD-Text info)

140
example/C++/device.cpp Normal file
View File

@@ -0,0 +1,140 @@
/*
$Id: device.cpp,v 1.3 2008/03/24 15:30:56 karl Exp $
Copyright (C) 2003, 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/>.
*/
/* Simple program to show drivers installed and what the default
CD-ROM drive is. See also corresponding C program of a similar
name. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio/cdio.h>
#define _(x) x
/* Prints out drive capabilities */
static void
print_drive_capabilities(cdio_drive_read_cap_t i_read_cap,
cdio_drive_write_cap_t i_write_cap,
cdio_drive_misc_cap_t i_misc_cap)
{
if (CDIO_DRIVE_CAP_ERROR == i_misc_cap) {
printf("Error in getting drive hardware properties\n");
} else {
printf(_("Hardware : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_FILE
? "Disk Image" : "CD-ROM or DVD");
printf(_("Can eject : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_EJECT ? "Yes" : "No");
printf(_("Can close tray : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_CLOSE_TRAY ? "Yes" : "No");
printf(_("Can disable manual eject : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_LOCK ? "Yes" : "No");
printf(_("Can select juke-box disc : %s\n\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_DISC ? "Yes" : "No");
printf(_("Can set drive speed : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_SPEED ? "Yes" : "No");
printf(_("Can detect if CD changed : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED ? "Yes" : "No");
printf(_("Can read multiple sessions : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_MULTI_SESSION ? "Yes" : "No");
printf(_("Can hard reset device : %s\n\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_RESET ? "Yes" : "No");
}
if (CDIO_DRIVE_CAP_ERROR == i_read_cap) {
printf("Error in getting drive reading properties\n");
} else {
printf("Reading....\n");
printf(_(" Can play audio : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_AUDIO ? "Yes" : "No");
printf(_(" Can read CD-R : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_CD_R ? "Yes" : "No");
printf(_(" Can read CD-RW : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_CD_RW ? "Yes" : "No");
printf(_(" Can read DVD-ROM : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_DVD_ROM ? "Yes" : "No");
}
if (CDIO_DRIVE_CAP_ERROR == i_write_cap) {
printf("Error in getting drive writing properties\n");
} else {
printf("\nWriting....\n");
printf(_(" Can write CD-RW : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_CD_RW ? "Yes" : "No");
printf(_(" Can write DVD-R : %s\n"),
i_write_cap & CDIO_DRIVE_CAP_READ_DVD_R ? "Yes" : "No");
printf(_(" Can write DVD-RAM : %s\n"),
i_write_cap & CDIO_DRIVE_CAP_READ_DVD_RAM ? "Yes" : "No");
}
}
inline
driver_id_t &operator++(driver_id_t &d)
{
return d = driver_id_t(d + 1);
}
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio = cdio_open (NULL, DRIVER_UNKNOWN);
driver_id_t driver_id;
if (NULL != p_cdio) {
char *default_device = cdio_get_default_device(p_cdio);
cdio_drive_read_cap_t i_read_cap;
cdio_drive_write_cap_t i_write_cap;
cdio_drive_misc_cap_t i_misc_cap;
printf("The driver selected is %s\n", cdio_get_driver_name(p_cdio));
if (default_device)
printf("The default device for this driver is %s\n", default_device);
cdio_get_drive_cap(p_cdio, &i_read_cap, &i_write_cap, &i_misc_cap);
print_drive_capabilities(i_read_cap, i_write_cap, i_misc_cap);
free(default_device);
cdio_destroy(p_cdio);
printf("\n");
} else {
printf("Problem in trying to find a driver.\n\n");
}
for (driver_id=CDIO_MIN_DRIVER; driver_id<=CDIO_MAX_DRIVER; ++driver_id)
if (cdio_have_driver(driver_id))
printf("We have: %s\n", cdio_driver_describe(driver_id));
else
printf("We don't have: %s\n", cdio_driver_describe(driver_id));
return 0;
}

99
example/C++/eject.cpp Normal file
View File

@@ -0,0 +1,99 @@
/*
$Id: eject.cpp,v 1.4 2008/03/24 15:30:56 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/>.
*/
/* Simple program to eject a CD-ROM drive door and then close it again.
If a single argument is given, it is used as the CD-ROM device to
eject/close. Otherwise a CD-ROM drive will be scanned for.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <cdio/cdio.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
int
main(int argc, const char *argv[])
{
driver_return_code_t ret;
driver_id_t driver_id = DRIVER_DEVICE;
char *psz_drive = NULL;
if (argc > 1)
psz_drive = strdup(argv[1]);
if (!psz_drive) {
psz_drive = cdio_get_default_device_driver(&driver_id);
if (!psz_drive) {
printf("Can't find a CD-ROM to eject\n");
exit(1);
}
}
ret = cdio_eject_media_drive(psz_drive);
switch(ret) {
case DRIVER_OP_UNSUPPORTED:
printf("Eject not supported for %s.\n", psz_drive);
break;
case DRIVER_OP_SUCCESS:
printf("CD-ROM drive %s ejected.\n", psz_drive);
break;
default:
printf("Eject of CD-ROM drive %s failed.\n", psz_drive);
break;
}
if (DRIVER_OP_SUCCESS == cdio_close_tray(psz_drive, &driver_id)) {
printf("Closed tray of CD-ROM drive %s.\n", psz_drive);
} else {
printf("Closing tray of CD-ROM drive %s failed.\n", psz_drive);
}
free(psz_drive);
ret = cdio_eject_media_drive(NULL);
switch(ret) {
case DRIVER_OP_UNSUPPORTED:
printf("Eject not supported for default device.\n");
break;
case DRIVER_OP_SUCCESS:
printf("CD-ROM drive ejected for default device.\n");
break;
default:
printf("Eject of CD-ROM drive failed for default device.\n");
break;
}
driver_id = DRIVER_DEVICE;
if (DRIVER_OP_SUCCESS == cdio_close_tray(NULL, &driver_id)) {
printf("Closed tray of CD-ROM drive for default disc driver:\n\t%s\n",
cdio_driver_describe(driver_id));
} else {
printf("Closing tray of CD-ROM drive failed for default "
"disc driver:\n\t%s\n", cdio_driver_describe(driver_id));
}
return 0;
}

161
example/C++/isofile.cpp Normal file
View File

@@ -0,0 +1,161 @@
/*
$Id: isofile.cpp,v 1.2 2008/03/24 15:30:56 karl Exp $
Copyright (C) 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/>.
*/
/* Simple program to show using libiso9660 to extract a file from an
ISO-9660 image.
If a single argument is given, it is used as the ISO 9660 image to
use in the extraction. Otherwise a compiled in default ISO 9660 image
name (that comes with the libcdio distribution) will be used.
*/
/* This is the ISO 9660 image. */
#define ISO9660_IMAGE_PATH "../../"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/copying.iso"
#define LOCAL_FILENAME "copying"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "portable.h"
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/iso9660.h>
#include <stdio.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define CEILING(x, y) ((x+(y-1))/y)
#define my_exit(rc) \
fclose (p_outfd); \
free(p_statbuf); \
iso9660_close(p_iso); \
return rc; \
int
main(int argc, const char *argv[])
{
iso9660_stat_t *p_statbuf;
FILE *p_outfd;
int i;
char const *psz_image;
char const *psz_fname;
iso9660_t *p_iso;
if (argc > 3) {
printf("usage %s [ISO9660-image.ISO [filename]]\n", argv[0]);
printf("Extracts filename from ISO-9660-image.ISO.\n");
return 1;
}
if (argc > 1)
psz_image = argv[1];
else
psz_image = ISO9660_IMAGE;
if (argc > 2)
psz_fname = argv[2];
else
psz_fname = LOCAL_FILENAME;
p_iso = iso9660_open (psz_image);
if (NULL == p_iso) {
fprintf(stderr, "Sorry, couldn't open ISO 9660 image %s\n", psz_image);
return 1;
}
p_statbuf = iso9660_ifs_stat_translate (p_iso, psz_fname);
if (NULL == p_statbuf)
{
fprintf(stderr,
"Could not get ISO-9660 file information for file %s\n",
psz_fname);
iso9660_close(p_iso);
return 2;
}
if (!(p_outfd = fopen (psz_fname, "wb")))
{
perror ("fopen()");
free(p_statbuf);
iso9660_close(p_iso);
return 3;
}
/* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */
{
const unsigned int i_blocks = CEILING(p_statbuf->size, ISO_BLOCKSIZE);
for (i = 0; i < i_blocks ; i++)
{
char buf[ISO_BLOCKSIZE];
const lsn_t lsn = p_statbuf->lsn + i;
memset (buf, 0, ISO_BLOCKSIZE);
if ( ISO_BLOCKSIZE != iso9660_iso_seek_read (p_iso, buf, lsn, 1) )
{
fprintf(stderr, "Error reading ISO 9660 file %s at LSN %lu\n",
psz_fname, (long unsigned int) lsn);
my_exit(4);
}
fwrite (buf, ISO_BLOCKSIZE, 1, p_outfd);
if (ferror (p_outfd))
{
perror ("fwrite()");
my_exit(5);
}
}
}
fflush (p_outfd);
/* Make sure the file size has the exact same byte size. Without the
truncate below, the file will a multiple of ISO_BLOCKSIZE.
*/
if (ftruncate (fileno (p_outfd), p_statbuf->size))
perror ("ftruncate()");
printf("Extraction of file '%s' from %s successful.\n",
psz_fname, psz_image);
my_exit(0);
}

161
example/C++/isofile2.cpp Normal file
View File

@@ -0,0 +1,161 @@
/*
$Id: isofile2.cpp,v 1.2 2008/03/24 15:30:56 karl Exp $
Copyright (C) 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/>.
*/
/* Simple program to show using libiso9660 to extract a file from an
ISO-9660 image.
If a single argument is given, it is used as the ISO 9660 image to
use in the extraction. Otherwise a compiled in default ISO 9660 image
name (that comes with the libcdio distribution) will be used.
*/
/* This is the ISO 9660 image. */
#define ISO9660_IMAGE_PATH "../../"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/copying.iso"
#define LOCAL_FILENAME "copying"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "portable.h"
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/iso9660.h>
#include <stdio.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define CEILING(x, y) ((x+(y-1))/y)
#define my_exit(rc) \
fclose (p_outfd); \
free(p_statbuf); \
iso9660_close(p_iso); \
return rc; \
int
main(int argc, const char *argv[])
{
iso9660_stat_t *p_statbuf;
FILE *p_outfd;
int i;
char const *psz_image;
char const *psz_fname;
iso9660_t *p_iso;
if (argc > 3) {
printf("usage %s [ISO9660-image.ISO [filename]]\n", argv[0]);
printf("Extracts filename from ISO-9660-image.ISO.\n");
return 1;
}
if (argc > 1)
psz_image = argv[1];
else
psz_image = ISO9660_IMAGE;
if (argc > 2)
psz_fname = argv[2];
else
psz_fname = LOCAL_FILENAME;
p_iso = iso9660_open (psz_image);
if (NULL == p_iso) {
fprintf(stderr, "Sorry, couldn't open ISO 9660 image %s\n", psz_image);
return 1;
}
p_statbuf = iso9660_ifs_stat_translate (p_iso, psz_fname);
if (NULL == p_statbuf)
{
fprintf(stderr,
"Could not get ISO-9660 file information for file %s\n",
psz_fname);
iso9660_close(p_iso);
return 2;
}
if (!(p_outfd = fopen (psz_fname, "wb")))
{
perror ("fopen()");
free(p_statbuf);
iso9660_close(p_iso);
return 3;
}
/* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */
{
const unsigned int i_blocks = CEILING(p_statbuf->size, ISO_BLOCKSIZE);
for (i = 0; i < i_blocks ; i++)
{
char buf[ISO_BLOCKSIZE];
const lsn_t lsn = p_statbuf->lsn + i;
memset (buf, 0, ISO_BLOCKSIZE);
if ( ISO_BLOCKSIZE != iso9660_iso_seek_read (p_iso, buf, lsn, 1) )
{
fprintf(stderr, "Error reading ISO 9660 file %s at LSN %lu\n",
psz_fname, (long unsigned int) lsn);
my_exit(4);
}
fwrite (buf, ISO_BLOCKSIZE, 1, p_outfd);
if (ferror (p_outfd))
{
perror ("fwrite()");
my_exit(5);
}
}
}
fflush (p_outfd);
/* Make sure the file size has the exact same byte size. Without the
truncate below, the file will a multiple of ISO_BLOCKSIZE.
*/
if (ftruncate (fileno (p_outfd), p_statbuf->size))
perror ("ftruncate()");
printf("Extraction of file '%s' from %s successful.\n",
psz_fname, psz_image);
my_exit(0);
}

121
example/C++/isolist.cpp Normal file
View File

@@ -0,0 +1,121 @@
/*
$Id: isolist.cpp,v 1.2 2008/03/24 15:30:56 karl Exp $
Copyright (C) 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/>.
*/
/* Simple program to show using libiso9660 to list files in a directory of
an ISO-9660 image and give some iso9660 information. See the code
to iso-info for a more complete example.
If a single argument is given, it is used as the ISO 9660 image to
use in the listing. Otherwise a compiled-in default ISO 9660 image
name (that comes with the libcdio distribution) will be used.
This program can be compiled with either a C or C++ compiler. In
the distributuion we perfer C++ just to make sure we haven't broken
things on the C++ side.
*/
/* Set up a CD-DA image to test on which is in the libcdio distribution. */
#define ISO9660_IMAGE_PATH "../../"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/copying.iso"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cdio/iso9660.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define print_vd_info(title, fn) \
if (fn(p_iso, &psz_str)) { \
printf(title ": %s\n", psz_str); \
} \
free(psz_str); \
psz_str = NULL;
int
main(int argc, const char *argv[])
{
CdioList_t *p_entlist;
CdioListNode_t *p_entnode;
char const *psz_fname;
iso9660_t *p_iso;
const char *psz_path="/";
if (argc > 1)
psz_fname = argv[1];
else
psz_fname = ISO9660_IMAGE;
p_iso = iso9660_open (psz_fname);
if (NULL == p_iso) {
fprintf(stderr, "Sorry, couldn't open %s as an ISO-9660 image\n",
psz_fname);
return 1;
}
/* Show basic CD info from the Primary Volume Descriptor. */
{
char *psz_str = NULL;
print_vd_info("Application", iso9660_ifs_get_application_id);
print_vd_info("Preparer ", iso9660_ifs_get_preparer_id);
print_vd_info("Publisher ", iso9660_ifs_get_publisher_id);
print_vd_info("System ", iso9660_ifs_get_system_id);
print_vd_info("Volume ", iso9660_ifs_get_volume_id);
print_vd_info("Volume Set ", iso9660_ifs_get_volumeset_id);
}
p_entlist = iso9660_ifs_readdir (p_iso, psz_path);
/* Iterate over the list of nodes that iso9660_ifs_readdir gives */
if (p_entlist) {
_CDIO_LIST_FOREACH (p_entnode, p_entlist)
{
char filename[4096];
iso9660_stat_t *p_statbuf =
(iso9660_stat_t *) _cdio_list_node_data (p_entnode);
iso9660_name_translate(p_statbuf->filename, filename);
printf ("%s [LSN %6d] %8u %s%s\n",
2 == p_statbuf->type ? "d" : "-",
p_statbuf->lsn, p_statbuf->size, psz_path, filename);
}
_cdio_list_free (p_entlist, true);
}
iso9660_close(p_iso);
return 0;
}

86
example/C++/mmc1.cpp Normal file
View File

@@ -0,0 +1,86 @@
/*
$Id: mmc1.cpp,v 1.4 2008/03/24 15:30:56 karl Exp $
Copyright (C) 2004, 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/>.
*/
/* Sample program to show use of the MMC interface.
An optional drive name can be supplied as an argument.
This basically the libdio mmc_get_hwinfo() routine.
See also corresponding C and OO C++ program.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/mmc.h>
#include <string.h>
/* Set how long to wait for MMC commands to complete */
#define DEFAULT_TIMEOUT_MS 10000
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio;
const char *psz_drive = NULL;
if (argc > 1) psz_drive = argv[1];
p_cdio = cdio_open (psz_drive, DRIVER_UNKNOWN);
if (NULL == p_cdio) {
printf("Couldn't find CD\n");
return 1;
} else {
int i_status; /* Result of MMC command */
char buf[36] = { 0, }; /* Place to hold returned data */
mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Buffer */
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_INQUIRY);
cdb.field[4] = sizeof(buf);
i_status = mmc_run_cmd(p_cdio, DEFAULT_TIMEOUT_MS, &cdb,
SCSI_MMC_DATA_READ, sizeof(buf), &buf);
if (i_status == 0) {
char psz_vendor[CDIO_MMC_HW_VENDOR_LEN+1];
char psz_model[CDIO_MMC_HW_MODEL_LEN+1];
char psz_rev[CDIO_MMC_HW_REVISION_LEN+1];
memcpy(psz_vendor, buf + 8, sizeof(psz_vendor)-1);
psz_vendor[sizeof(psz_vendor)-1] = '\0';
memcpy(psz_model,
buf + 8 + CDIO_MMC_HW_VENDOR_LEN,
sizeof(psz_model)-1);
psz_model[sizeof(psz_model)-1] = '\0';
memcpy(psz_rev,
buf + 8 + CDIO_MMC_HW_VENDOR_LEN +CDIO_MMC_HW_MODEL_LEN,
sizeof(psz_rev)-1);
psz_rev[sizeof(psz_rev)-1] = '\0';
printf("Vendor: %s\nModel: %s\nRevision: %s\n",
psz_vendor, psz_model, psz_rev);
} else {
printf("Couldn't get INQUIRY data (vendor, model, and revision).\n");
}
}
cdio_destroy(p_cdio);
return 0;
}

187
example/C++/mmc2.cpp Normal file
View File

@@ -0,0 +1,187 @@
/*
$Id: mmc2.cpp,v 1.3 2008/03/24 15:30:56 karl Exp $
Copyright (C) 2004, 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/>.
*/
/* A program to using the MMC interface to list CD and drive features
from the MMC GET_CONFIGURATION command . */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/mmc.h>
#include <string.h>
/* Set how long do wto wait for SCSI-MMC commands to complete */
#define DEFAULT_TIMEOUT_MS 10000
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio;
p_cdio = cdio_open (NULL, DRIVER_UNKNOWN);
if (NULL == p_cdio) {
printf("Couldn't find CD\n");
return 1;
} else {
int i_status; /* Result of MMC command */
uint8_t buf[500] = { 0, }; /* Place to hold returned data */
mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Buffer */
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_GET_CONFIGURATION);
CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf));
cdb.field[1] = CDIO_MMC_GET_CONF_ALL_FEATURES;
cdb.field[3] = 0x0;
i_status = mmc_run_cmd(p_cdio, 0, &cdb, SCSI_MMC_DATA_READ, sizeof(buf),
&buf);
if (i_status == 0) {
uint8_t *p;
uint32_t i_data;
uint8_t *p_max = buf + 65530;
i_data = (unsigned int) CDIO_MMC_GET_LEN32(buf);
/* set to first sense feature code, and then walk through the masks */
p = buf + 8;
while( (p < &(buf[i_data])) && (p < p_max) ) {
uint16_t i_feature;
uint8_t i_feature_additional = p[3];
i_feature = CDIO_MMC_GET_LEN16(p);
{
uint8_t *q;
const char *feature_str = mmc_feature2str(i_feature);
printf("%s Feature\n", feature_str);
switch( i_feature )
{
case CDIO_MMC_FEATURE_PROFILE_LIST:
for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) {
int i_profile=CDIO_MMC_GET_LEN16(q);
const char *feature_profile_str =
mmc_feature_profile2str(i_profile);
printf( "\t%s", feature_profile_str );
if (q[2] & 1) {
printf(" - on");
}
printf("\n");
}
printf("\n");
break;
case CDIO_MMC_FEATURE_CORE:
{
uint8_t *q = p+4;
uint32_t i_interface_standard = CDIO_MMC_GET_LEN32(q);
switch(i_interface_standard) {
case 0:
printf("\tunspecified interface\n");
break;
case 1:
printf("\tSCSI interface\n");
break;
case 2:
printf("\tATAPI interface\n");
break;
case 3:
printf("\tIEEE 1394 interface\n");
break;
case 4:
printf("\tIEEE 1394A interface\n");
break;
case 5:
printf("\tFibre Channel interface\n");
}
printf("\n");
break;
}
case CDIO_MMC_FEATURE_REMOVABLE_MEDIUM:
switch(p[4] >> 5) {
case 0:
printf("\tCaddy/Slot type loading mechanism\n");
break;
case 1:
printf("\tTray type loading mechanism\n");
break;
case 2:
printf("\tPop-up type loading mechanism\n");
break;
case 4:
printf("\tEmbedded changer with individually changeable discs\n");
break;
case 5:
printf("\tEmbedded changer using a magazine mechanism\n");
break;
default:
printf("\tUnknown changer mechanism\n");
}
printf("\tcan%s eject the medium or magazine via the normal "
"START/STOP command\n",
(p[4] & 8) ? "": "not");
printf("\tcan%s be locked into the Logical Unit\n",
(p[4] & 1) ? "": "not");
printf("\n");
break;
case CDIO_MMC_FEATURE_CD_READ:
printf("CD Read Feature\n");
printf("\tC2 Error pointers are %ssupported\n",
(p[4] & 2) ? "": "not ");
printf("\tCD-Text is %ssupported\n",
(p[4] & 1) ? "": "not ");
printf("\n");
break;
case CDIO_MMC_FEATURE_CDDA_EXT_PLAY:
printf("\tSCAN command is %ssupported\n",
(p[4] & 4) ? "": "not ");
printf("\taudio channels can %sbe muted separately\n",
(p[4] & 2) ? "": "not ");
printf("\taudio channels can %shave separate volume levels\n",
(p[4] & 1) ? "": "not ");
{
uint8_t *q = p+6;
uint16_t i_vol_levels = CDIO_MMC_GET_LEN16(q);
printf("\t%d volume levels can be set\n", i_vol_levels);
}
printf("\n");
break;
case CDIO_MMC_FEATURE_LU_SN: {
uint8_t i_serial = *(p+3);
char serial[257] = { '\0', };
memcpy(serial, p+4, i_serial);
printf("\t%s\n\n", serial);
break;
}
default:
printf("\n");
break;
}
p += i_feature_additional + 4;
}
}
} else {
printf("Didn't get all feature codes\n");
}
}
cdio_destroy(p_cdio);
return 0;
}

119
example/C++/paranoia.cpp Normal file
View File

@@ -0,0 +1,119 @@
/*
$Id: paranoia.cpp,v 1.3 2008/03/24 15:30:56 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/>.
*/
/* Simple program to show using libcdio's version of the CD-DA paranoia.
library. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cdio/paranoia.h>
#include <cdio/cd_types.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
int
main(int argc, const char *argv[])
{
cdrom_drive_t *d = NULL; /* Place to store handle given by cd-paranoia. */
char **ppsz_cd_drives; /* List of all drives with a loaded CDDA in it. */
/* See if we can find a device with a loaded CD-DA in it. */
ppsz_cd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
if (ppsz_cd_drives) {
/* Found such a CD-ROM with a CD-DA loaded. Use the first drive in
the list. */
d=cdda_identify(*ppsz_cd_drives, 1, NULL);
} else {
printf("Unable find or access a CD-ROM drive with an audio CD in it.\n");
exit(1);
}
/* Don't need a list of CD's with CD-DA's any more. */
cdio_free_device_list(ppsz_cd_drives);
if ( !d ) {
printf("Unable to identify audio CD disc.\n");
exit(1);
}
/* We'll set for verbose paranoia messages. */
cdda_verbose_set(d, CDDA_MESSAGE_PRINTIT, CDDA_MESSAGE_PRINTIT);
if ( 0 != cdda_open(d) ) {
printf("Unable to open disc.\n");
exit(1);
}
/* Okay now set up to read up to the first 300 frames of the first
audio track of the Audio CD. */
{
cdrom_paranoia_t *p = paranoia_init(d);
lsn_t i_first_lsn = cdda_disc_firstsector(d);
if ( -1 == i_first_lsn ) {
printf("Trouble getting starting LSN\n");
} else {
lsn_t i_cursor;
track_t i_track = cdda_sector_gettrack(d, i_first_lsn);
lsn_t i_last_lsn = cdda_track_lastsector(d, i_track);
/* For demo purposes we'll read only 300 frames (about 4
seconds). We don't want this to take too long. On the other
hand, I suppose it should be something close to a real test.
*/
if ( i_last_lsn - i_first_lsn > 300) i_last_lsn = i_first_lsn + 299;
printf("Reading track %d from LSN %ld to LSN %ld\n", i_track,
(long int) i_first_lsn, (long int) i_last_lsn);
/* Set reading mode for full paranoia, but allow skipping sectors. */
paranoia_modeset(p, PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP);
paranoia_seek(p, i_first_lsn, SEEK_SET);
for ( i_cursor = i_first_lsn; i_cursor <= i_last_lsn; i_cursor ++) {
/* read a sector */
int16_t *p_readbuf=paranoia_read(p, NULL);
char *psz_err=cdda_errors(d);
char *psz_mes=cdda_messages(d);
if (psz_mes || psz_err)
printf("%s%s\n", psz_mes ? psz_mes: "", psz_err ? psz_err: "");
if (psz_err) free(psz_err);
if (psz_mes) free(psz_mes);
if( !p_readbuf ) {
printf("paranoia read error. Stopping.\n");
break;
}
}
}
paranoia_free(p);
}
cdda_close(d);
exit(0);
}

101
example/C++/paranoia2.cpp Normal file
View File

@@ -0,0 +1,101 @@
/*
$Id: paranoia2.cpp,v 1.2 2008/03/24 15:30:57 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/>.
*/
/* Simple program to show using libcdio's version of the CD-DA
paranoia library. But in this version, we'll open a cdio object before
calling paranoia's open. I imagine in many cases such as media
players this may be what will be done since, one may want to get
CDDB/CD-Text info beforehand. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cdio/cdda.h>
#include <cdio/cd_types.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
int
main(int argc, const char *argv[])
{
cdrom_drive_t *d = NULL; /* Place to store handle given by cd-paranoia. */
char **ppsz_cd_drives; /* List of all drives with a loaded CDDA in it. */
CdIo_t *p_cdio = NULL;
/* See if we can find a device with a loaded CD-DA in it. */
ppsz_cd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
if (ppsz_cd_drives) {
/* Found such a CD-ROM with a CD-DA loaded. Use the first drive in
the list. */
p_cdio = cdio_open(*ppsz_cd_drives, DRIVER_UNKNOWN);
d=cdio_cddap_identify_cdio(p_cdio, 1, NULL);
} else {
printf("Unable find or access a CD-ROM drive with an audio CD in it.\n");
exit(1);
}
/* Don't need a list of CD's with CD-DA's any more. */
cdio_free_device_list(ppsz_cd_drives);
if ( !d ) {
printf("Unable to identify audio CD disc.\n");
exit(1);
}
/* We'll set for verbose paranoia messages. */
cdio_cddap_verbose_set(d, CDDA_MESSAGE_PRINTIT, CDDA_MESSAGE_PRINTIT);
if ( 0 != cdio_cddap_open(d) ) {
printf("Unable to open disc.\n");
exit(1);
}
/* In the paranoia example was a reading. Here we are going to do
something trivial (but I think neat any way - get the Endian-ness
of the drive. */
{
const int i_endian = data_bigendianp(d);
switch (i_endian) {
case 0:
printf("Drive returns audio data Little Endian."
" Your drive is like most.\n");
break;
case 1:
printf("Drive returns audio data Big Endian.\n");
break;
case -1:
printf("Don't know whether drive is Big or Little Endian.\n");
break;
default:
printf("Whoah - got a return result I'm not expecting %d.\n",
i_endian);
break;
}
}
cdio_cddap_close_no_free_cdio(d);
cdio_destroy( p_cdio );
exit(0);
}

97
example/Makefile.am Normal file
View File

@@ -0,0 +1,97 @@
# $Id: Makefile.am,v 1.44 2008/08/31 13:38:21 flameeyes Exp $
#
# Copyright (C) 2003, 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/>.
####################################################
# Sample programs
####################################################
#
if ENABLE_CPP
SUBDIRS = C++
endif
if BUILD_CD_PARANOIA
paranoia_progs = paranoia paranoia2
endif
if BUILD_EXAMPLES
noinst_PROGRAMS = audio cdchange cdtext device drives eject \
isofile isofile2 isofuzzy isolist isolsn \
mmc1 mmc2 mmc2a mmc3 $(paranoia_progs) tracks \
sample3 sample4 udf1 udffile cdio-eject
endif
INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS)
audio_DEPENDENCIES = $(LIBCDIO_DEPS)
audio_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
cdchange_DEPENDENCIES = $(LIBCDIO_DEPS)
cdchange_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
cdtext_DEPENDENCIES = $(LIBCDIO_DEPS)
cdtext_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
device_DEPENDENCIES = $(LIBCDIO_DEPS)
device_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
drives_DEPENDENCIES = $(LIBCDIO_DEPS)
drives_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
eject_DEPENDENCIES = $(LIBCDIO_DEPS)
eject_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
cdio_eject_DEPENDENCIES = $(LIBCDIO_DEPS)
cdio_eject_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
if BUILD_CD_PARANOIA
paranoia_LDADD = $(LIBCDIO_PARANOIA_LIBS) $(LIBCDIO_CDDA_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
paranoia2_LDADD = $(LIBCDIO_PARANOIA_LIBS) $(LIBCDIO_CDDA_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
endif
isofile_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
isofile2_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
isofuzzy_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
isolist_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
isolsn_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
mmc1_DEPENDENCIES = $(LIBCDIO_DEPS)
mmc1_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
mmc2_DEPENDENCIES = $(LIBCDIO_DEPS)
mmc2_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
mmc2a_DEPENDENCIES = $(LIBCDIO_DEPS)
mmc2a_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
mmc3_DEPENDENCIES = $(LIBCDIO_DEPS)
mmc3_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
sample3_DEPENDENCIES = $(LIBCDIO_DEPS)
sample3_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
sample4_DEPENDENCIES = $(LIBCDIO_DEPS)
sample4_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
tracks_DEPENDENCIES = $(LIBCDIO_DEPS)
tracks_LDADD = $(LIBCDIO_LIBS) $(LTLIBICONV)
udf1_DEPENDENCIES = $(LIBUDF_LIBS) $(LIBCDIO_DEPS)
udf1_LDADD = $(LIBUDF_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
udffile_DEPENDENCIES = $(LIBUDF_LIBS) $(LIBCDIO_DEPS)
udffile_LDADD = $(LIBUDF_LIBS) $(LIBCDIO_LIBS) $(LTLIBICONV)
# iso programs create file "copying"
MOSTLYCLEANFILES = copying

View File

@@ -1,86 +0,0 @@
$Id: README,v 1.28 2007/08/12 00:56:10 rocky Exp $
This directory contains some simple examples of the use of the libcdio
library.
One might also possibly find useful C code among the regression tests
(directory test), e.g. testbincue.c, testdefault.c, testiso9660.c,
testparanoia.c, or testtoc.c
Larger more-complicated examples are the cd-drive, cd-info, cd-read,
cdda-player, iso-info and iso-read programs in the src directory.
And going further there's the cd-paranoia program (in
src/cd-paranoia), and "real-world' code in the xine VCD plugin, or the
vlc CD-DA plugin which are part of those distributions.
Descriptions of the programs in this example directory are as follows...
audio.c: Sample program to show audio controls.
cdchange.c: A program to test if a CD has been changed since the last
change test.
cdio-eject.c: a stripped-down "eject" command to open or close a CDROM
tray
cdtext.c: A program to show CD-Text and CD disc mode info.
drives.c: A program to show drivers installed and what the default
CD-ROM drive is and what CD drives are available.
eject.c: A program eject a CD from a CD-ROM drive and then close the door
again.
isofile.c: A program to show using libiso9660 to extract a file from an
ISO-9660 image.
isofile2.c: A program to show using libiso9660 to extract a file
from a CDRWIN cue/bin CD image.
isofuzzy.c : A program showing fuzzy ISO-9660 detection/reading.
isolist.c: A program to show using libiso9660 to list files in a
directory of an ISO-9660 image and give basic iso9660
information.
isolsn.c: A program to show using libiso9660 to get the file
path for a given LSN.
mmc1.c: A program to show issuing a simple MMC command (INQUIRY).
mmc2.c: A more involved MMC command to list features from
a MMC GET_CONFIGURATION command.
mmc2a.c: Show MODE_SENSE page 2A paramaters:
CD/DVD Capabilities and Mechanical Status Page
paranoia: A program to show using CD-DA paranoia (a library for jitter
detection and audio-read error correction). This program uses
an interface compatible (mostly) with cdparanoia.
paranoia2: Another program to show using CD-DA paranoia using a more
libcdio-oriented initialization. Probably more suited to
things that otherwise use libcdio such as media players
(e.g. for getting CDDB or CD-Text info)
sample2.c: A simple program to show drivers installed and what the
default CD-ROM drive is.
sample3.c: A simple program to show the use of cdio_guess_cd_type().
Figure out the kind of CD image we've got.
sample4.c: A slightly improved sample3 program: we handle cdio logging
and take an optional CD-location.
tracks.c: A program to list track numbers and logical sector
numbers of a Compact Disc using libcdio.
udf1.c: A program to show using libudf to list files in a directory of
an UDF image.
udf2.c: A program to show using libudf to extract a file from
an UDF image.
Many of the above programs can be compiled in C++. See that directory
for C++ examples which include some of the above.

490
example/audio.c Normal file
View File

@@ -0,0 +1,490 @@
/*
$Id: audio.c,v 1.10 2008/06/19 15:44:10 flameeyes Exp $
Copyright (C) 2005, 2008 Rocky Bernstein <rocky@gnu.org>
Adapted from Gerd Knorr's player.c program <kraxel@bytesex.org>
Copyright (C) 1997, 1998
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/>.
*/
/* A program to show use of audio controls. For a more expanded
CDDA player program using curses display see cdda-player in this
distribution.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <sys/time.h>
#include <signal.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#include <cdio/cdio.h>
#include <cdio/mmc.h>
#include <cdio/util.h>
#include <cdio/cd_types.h>
static bool play_track(track_t t1, track_t t2);
static CdIo_t *p_cdio = NULL; /* libcdio handle */
static driver_id_t driver_id = DRIVER_DEVICE;
/* cdrom data */
static track_t i_first_track;
static track_t i_last_track;
static track_t i_first_audio_track;
static track_t i_last_audio_track;
static track_t i_tracks;
static msf_t toc[CDIO_CDROM_LEADOUT_TRACK+1];
static cdio_subchannel_t sub; /* subchannel last time read */
static int i_data; /* # of data tracks present ? */
static int start_track = 0;
static int stop_track = 0;
static int one_track = 0;
static bool b_cd = false;
static bool auto_mode = false;
static bool b_verbose = false;
static bool debug = false;
static bool b_record = false; /* we have a record for
the inserted CD */
static char *psz_device=NULL;
static char *psz_program;
inline static void
xperror(const char *psz_msg)
{
if (b_verbose) {
fprintf(stderr, "error: ");
perror(psz_msg);
}
return;
}
static void
oops(const char *psz_msg, int rc)
{
cdio_destroy (p_cdio);
free (psz_device);
exit (rc);
}
/* ---------------------------------------------------------------------- */
/*! Stop playing audio CD */
static bool
cd_stop(CdIo_t *p_cdio)
{
bool b_ok = true;
if (b_cd && p_cdio) {
i_last_audio_track = CDIO_INVALID_TRACK;
b_ok = DRIVER_OP_SUCCESS == cdio_audio_stop(p_cdio);
if ( !b_ok )
xperror("stop");
}
return b_ok;
}
/*! Eject CD */
static bool
cd_eject(void)
{
bool b_ok = true;
if (p_cdio) {
cd_stop(p_cdio);
b_ok = DRIVER_OP_SUCCESS == cdio_eject_media(&p_cdio);
if (!b_ok)
xperror("eject");
b_cd = false;
p_cdio = NULL;
}
return b_ok;
}
/*! Close CD tray */
static bool
cd_close(const char *psz_device)
{
bool b_ok = true;
if (!b_cd) {
b_ok = DRIVER_OP_SUCCESS == cdio_close_tray(psz_device, &driver_id);
if (!b_ok)
xperror("close");
}
return b_ok;
}
/*! Pause playing audio CD */
static bool
cd_pause(CdIo_t *p_cdio)
{
bool b_ok = true;
if (sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY) {
b_ok = DRIVER_OP_SUCCESS == cdio_audio_pause(p_cdio);
if (!b_ok)
xperror("pause");
}
return b_ok;
}
/*! Get status/track/position info of an audio CD */
static bool
read_subchannel(CdIo_t *p_cdio)
{
bool b_ok = true;
if (!b_cd) return false;
b_ok = DRIVER_OP_SUCCESS == cdio_audio_read_subchannel(p_cdio, &sub);
if (!b_ok) {
xperror("read subchannel");
b_cd = 0;
}
if (auto_mode && sub.audio_status == CDIO_MMC_READ_SUB_ST_COMPLETED)
cd_eject();
return b_ok;
}
/*! Read CD TOC and set CD information. */
static void
read_toc(CdIo_t *p_cdio)
{
track_t i;
i_first_track = cdio_get_first_track_num(p_cdio);
i_last_track = cdio_get_last_track_num(p_cdio);
i_tracks = cdio_get_num_tracks(p_cdio);
i_first_audio_track = i_first_track;
i_last_audio_track = i_last_track;
if ( CDIO_INVALID_TRACK == i_first_track ||
CDIO_INVALID_TRACK == i_last_track ) {
xperror("read toc header");
b_cd = false;
b_record = false;
} else {
b_cd = true;
i_data = 0;
for (i = i_first_track; i <= i_last_track+1; i++) {
if ( !cdio_get_track_msf(p_cdio, i, &(toc[i])) )
{
xperror("read toc entry");
b_cd = false;
return;
}
if ( TRACK_FORMAT_AUDIO != cdio_get_track_format(p_cdio, i) ) {
if ((i != i_last_track+1) ) {
i_data++;
if (i == i_first_track) {
if (i == i_last_track)
i_first_audio_track = CDIO_CDROM_LEADOUT_TRACK;
else
i_first_audio_track++;
}
}
}
}
b_record = true;
read_subchannel(p_cdio);
if (auto_mode && sub.audio_status != CDIO_MMC_READ_SUB_ST_PLAY)
play_track(1, CDIO_CDROM_LEADOUT_TRACK);
}
}
/*! Play an audio track. */
static bool
play_track(track_t i_start_track, track_t i_end_track)
{
bool b_ok = true;
if (!b_cd) {
cd_close(psz_device);
read_toc(p_cdio);
}
read_subchannel(p_cdio);
if (!b_cd || i_first_track == CDIO_CDROM_LEADOUT_TRACK)
return false;
if (debug)
fprintf(stderr,"play tracks: %d-%d => ", i_start_track, i_end_track);
if (i_start_track < i_first_track) i_start_track = i_first_track;
if (i_start_track > i_last_audio_track) i_start_track = i_last_audio_track;
if (i_end_track < i_first_track) i_end_track = i_first_track;
if (i_end_track > i_last_audio_track) i_end_track = i_last_audio_track;
if (debug)
fprintf(stderr,"%d-%d\n",i_start_track, i_end_track);
cd_pause(p_cdio);
b_ok = (DRIVER_OP_SUCCESS == cdio_audio_play_msf(p_cdio,
&(toc[i_start_track]),
&(toc[i_end_track])) );
if (!b_ok) xperror("play");
return b_ok;
}
static void
usage(char *prog)
{
fprintf(stderr,
"%s is a simple interface to issuing CD audio comamnds\n"
"\n"
"usage: %s [options] [device]\n"
"\n"
"default for to search for a CD-ROM device with a CD-DA loaded\n"
"\n"
"These command line options available:\n"
" -h print this help\n"
" -a start up in auto-mode\n"
" -v verbose\n"
"\n"
" Use only one of these:\n"
" -C close CD-ROM tray. If you use this option,\n"
" a CD-ROM device name must be specified.\n"
" -p play the whole CD\n"
" -t n play track >n<\n"
" -t a-b play all tracks between a and b (inclusive)\n"
" -L set volume level\n"
" -s stop playing\n"
" -S list audio subchannel information\n"
" -e eject cdrom\n"
"\n"
"That's all. Oh, maybe a few words more about the auto-mode. This\n"
"is the 'dont-touch-any-key' feature. You load a CD, player starts\n"
"to play it, and when it is done it ejects the CD. Start it that\n"
"way on a spare console and forget about it...\n"
"\n"
"(c) 1997,98 Gerd Knorr <kraxel@goldbach.in-berlin.de>\n"
"(c) 2005 Rocky Bernstein <rocky@panix.com>\n"
, prog, prog);
}
typedef enum {
NO_OP=0,
PLAY_CD=1,
PLAY_TRACK=2,
STOP_PLAYING=3,
EJECT_CD=4,
CLOSE_CD=5,
SET_VOLUME=6,
LIST_SUBCHANNEL=7,
} cd_operation_t;
int
main(int argc, char *argv[])
{
int c, nostop=0;
char *h;
int i_rc = 0;
int i_volume_level = -1;
cd_operation_t todo = NO_OP; /* operation to do in non-interactive mode */
psz_program = strrchr(argv[0],'/');
psz_program = psz_program ? psz_program+1 : argv[0];
/* parse options */
while ( 1 ) {
if (-1 == (c = getopt(argc, argv, "aCdehkpL:sSt:vx")))
break;
switch (c) {
case 'v':
b_verbose = true;
break;
case 'd':
debug = 1;
break;
case 'a':
auto_mode = 1;
break;
case 'L':
if (NULL != (h = strchr(optarg,'-'))) {
i_volume_level = atoi(optarg);
todo = SET_VOLUME;
}
case 't':
if (NULL != (h = strchr(optarg,'-'))) {
*h = 0;
start_track = atoi(optarg);
stop_track = atoi(h+1)+1;
if (0 == start_track) start_track = 1;
if (1 == stop_track) stop_track = CDIO_CDROM_LEADOUT_TRACK;
} else {
start_track = atoi(optarg);
stop_track = start_track+1;
one_track = 1;
}
todo = PLAY_TRACK;
break;
case 'p':
todo = PLAY_CD;
break;
case 'C':
todo = CLOSE_CD;
break;
break;
case 's':
todo = STOP_PLAYING;
break;
case 'S':
todo = LIST_SUBCHANNEL;
break;
case 'e':
todo = EJECT_CD;
break;
case 'h':
usage(psz_program);
exit(1);
default:
usage(psz_program);
exit(1);
}
}
if (argc > optind) {
psz_device = strdup(argv[optind]);
} else {
char **ppsz_cdda_drives=NULL;
char **ppsz_all_cd_drives = cdio_get_devices_ret(&driver_id);
if (!ppsz_all_cd_drives) {
fprintf(stderr, "Can't find a CD-ROM drive\n");
exit(2);
}
ppsz_cdda_drives = cdio_get_devices_with_cap(ppsz_all_cd_drives,
CDIO_FS_AUDIO, false);
if (!ppsz_cdda_drives || !ppsz_cdda_drives[0]) {
fprintf(stderr, "Can't find a CD-ROM drive with a CD-DA in it\n");
exit(3);
}
psz_device = strdup(ppsz_cdda_drives[0]);
cdio_free_device_list(ppsz_all_cd_drives);
cdio_free_device_list(ppsz_cdda_drives);
}
if (!b_cd && todo != EJECT_CD) {
cd_close(psz_device);
}
/* open device */
if (b_verbose)
fprintf(stderr,"open %s... ", psz_device);
p_cdio = cdio_open (psz_device, driver_id);
if (!p_cdio) {
if (b_verbose)
fprintf(stderr, "error: %s\n", strerror(errno));
else
fprintf(stderr, "open %s: %s\n", psz_device, strerror(errno));
exit(1);
} else
if (b_verbose)
fprintf(stderr,"ok\n");
{
nostop=1;
if (EJECT_CD == todo) {
i_rc = cd_eject() ? 0 : 1;
} else {
read_toc(p_cdio);
if (!b_cd) {
cd_close(psz_device);
read_toc(p_cdio);
}
if (b_cd)
switch (todo) {
case NO_OP:
break;
case STOP_PLAYING:
i_rc = cd_stop(p_cdio) ? 0 : 1;
break;
case EJECT_CD:
/* Should have been handled above. */
cd_eject();
break;
case PLAY_TRACK:
/* play just this one track */
play_track(start_track, stop_track);
break;
case PLAY_CD:
play_track(1,CDIO_CDROM_LEADOUT_TRACK);
break;
case CLOSE_CD:
i_rc = cdio_close_tray(psz_device, NULL) ? 0 : 1;
break;
case SET_VOLUME:
{
cdio_audio_volume_t volume;
volume.level[0] = i_volume_level;
i_rc = (DRIVER_OP_SUCCESS == cdio_audio_set_volume(p_cdio,
&volume))
? 0 : 1;
break;
}
case LIST_SUBCHANNEL:
if (read_subchannel(p_cdio)) {
if (sub.audio_status == CDIO_MMC_READ_SUB_ST_PAUSED ||
sub.audio_status == CDIO_MMC_READ_SUB_ST_PLAY) {
{
printf("track %2d - %02x:%02x (%02x:%02x abs) ",
sub.track, sub.rel_addr.m, sub.rel_addr.s,
sub.abs_addr.m, sub.abs_addr.s);
}
}
printf("drive state: %s\n",
mmc_audio_state2str(sub.audio_status));
} else {
i_rc = 1;
}
break;
}
else {
fprintf(stderr,"no CD in drive (%s)\n", psz_device);
}
}
}
if (!nostop) cd_stop(p_cdio);
oops("bye", i_rc);
return 0; /* keep compiler happy */
}

100
example/cdchange.c Normal file
View File

@@ -0,0 +1,100 @@
/*
$Id: cdchange.c,v 1.9 2008/06/25 08:01:53 rocky 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/>.
*/
/* Test media changed */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_ERRNO_H
# include <errno.h>
#endif
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#ifndef HAVE_SLEEP
static void
sleep(unsigned int ms)
{
#if defined(_WIN32)
Sleep(ms);
#else
#error sleep() unimplemented
#endif
}
#endif
#include <cdio/cdio.h>
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio;
unsigned long i_sleep=30;
if (argc > 1) {
p_cdio = cdio_open (argv[1], DRIVER_DEVICE);
if (argc > 2) {
errno = 0;
i_sleep = strtol(argv[2], (char **)NULL, 10);
if ( (LONG_MIN == i_sleep || LONG_MAX == i_sleep) && errno != 0 ) {
printf("Invalid sleep parameter %s\n", argv[2]);
printf("Error reported back from strtol: %s\n", strerror(errno));
return 2;
}
}
} else {
p_cdio = cdio_open (NULL, DRIVER_DEVICE);
}
if (NULL == p_cdio) {
printf("Couldn't find a driver.. leaving.\n");
return 1;
}
if (cdio_get_media_changed(p_cdio))
printf("Initial media status: changed\n");
else
printf("Initial media status: not changed\n");
printf("Giving you %lu seconds to change CD if you want to do so.\n",
i_sleep);
sleep(30);
if (cdio_get_media_changed(p_cdio))
printf("Media status: changed\n");
else
printf("Media status: not changed\n");
cdio_destroy(p_cdio);
return 0;
}

82
example/cdio-eject.c Normal file
View File

@@ -0,0 +1,82 @@
/*
$Id: cdio-eject.c,v 1.4 2008/03/24 15:30:55 karl Exp $
Copyright (C) 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/>.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cdio/cdio.h>
#include <stdio.h>
#include <string.h>
static void usage(char * progname)
{
fprintf(stderr, "Usage: %s [-t] <device>\n", progname);
}
int main(int argc, char ** argv)
{
driver_return_code_t err;
int close_tray = 0;
const char * device = NULL;
if(argc < 2 || argc > 3)
{
usage(argv[0]);
return -1;
}
if((argc == 3) && strcmp(argv[1], "-t"))
{
usage(argv[0]);
return -1;
}
if(argc == 2)
device = argv[1];
else if(argc == 3)
{
close_tray = 1;
device = argv[2];
}
if(close_tray)
{
err = cdio_close_tray(device, NULL);
if(err)
{
fprintf(stderr, "Closing tray failed for device %s: %s\n",
device, cdio_driver_errmsg(err));
return -1;
}
}
else
{
err = cdio_eject_media_drive(device);
if(err)
{
fprintf(stderr, "Ejecting failed for device %s: %s\n",
device, cdio_driver_errmsg(err));
return -1;
}
}
return 0;
}

101
example/cdtext.c Normal file
View File

@@ -0,0 +1,101 @@
/*
$Id: cdtext.c,v 1.5 2008/03/24 15:30:55 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/>.
*/
/* Simple program to list CD-Text info of a Compact Disc using
libcdio. See also corresponding C++ programs of similar names. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio/cdio.h>
#include <cdio/cdtext.h>
static void
print_cdtext_track_info(CdIo_t *p_cdio, track_t i_track, const char *psz_msg) {
const cdtext_t *cdtext = cdio_get_cdtext(p_cdio, 0);
if (NULL != cdtext) {
cdtext_field_t i;
printf("%s\n", psz_msg);
for (i=0; i < MAX_CDTEXT_FIELDS; i++) {
if (cdtext->field[i]) {
printf("\t%s: %s\n", cdtext_field2str(i), cdtext->field[i]);
}
}
}
}
static void
print_disc_info(CdIo_t *p_cdio, track_t i_tracks, track_t i_first_track) {
track_t i_last_track = i_first_track+i_tracks;
discmode_t cd_discmode = cdio_get_discmode(p_cdio);
printf("%s\n", discmode2str[cd_discmode]);
print_cdtext_track_info(p_cdio, 0, "\nCD-Text for Disc:");
for ( ; i_first_track < i_last_track; i_first_track++ ) {
char psz_msg[50];
snprintf(psz_msg, sizeof(psz_msg), "CD-Text for Track %d:", i_first_track);
print_cdtext_track_info(p_cdio, i_first_track, psz_msg);
}
}
int
main(int argc, const char *argv[])
{
track_t i_first_track;
track_t i_tracks;
CdIo_t *p_cdio = cdio_open ("../test/cdda.cue", DRIVER_BINCUE);
if (NULL == p_cdio) {
printf("Couldn't open ../test/cdda.cue with BIN/CUE driver.\n");
} else {
i_first_track = cdio_get_first_track_num(p_cdio);
i_tracks = cdio_get_num_tracks(p_cdio);
print_disc_info(p_cdio, i_tracks, i_first_track);
cdio_destroy(p_cdio);
}
p_cdio = cdio_open (NULL, DRIVER_DEVICE);
i_first_track = cdio_get_first_track_num(p_cdio);
i_tracks = cdio_get_num_tracks(p_cdio);
if (NULL == p_cdio) {
printf("Couldn't find CD\n");
return 1;
} else {
print_disc_info(p_cdio, i_tracks, i_first_track);
}
cdio_destroy(p_cdio);
return 0;
}

135
example/device.c Normal file
View File

@@ -0,0 +1,135 @@
/*
$Id: device.c,v 1.3 2008/03/24 15:30:55 karl Exp $
Copyright (C) 2003, 2004, 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/>.
*/
/* Simple program to show drivers installed and what the default
CD-ROM drive is. See also corresponding C++ programs of similar
names .*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio/cdio.h>
#define _(x) x
/* Prints out drive capabilities */
static void
print_drive_capabilities(cdio_drive_read_cap_t i_read_cap,
cdio_drive_write_cap_t i_write_cap,
cdio_drive_misc_cap_t i_misc_cap)
{
if (CDIO_DRIVE_CAP_ERROR == i_misc_cap) {
printf("Error in getting drive hardware properties\n");
} else {
printf(_("Hardware : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_FILE
? "Disk Image" : "CD-ROM or DVD");
printf(_("Can eject : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_EJECT ? "Yes" : "No");
printf(_("Can close tray : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_CLOSE_TRAY ? "Yes" : "No");
printf(_("Can disable manual eject : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_LOCK ? "Yes" : "No");
printf(_("Can select juke-box disc : %s\n\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_DISC ? "Yes" : "No");
printf(_("Can set drive speed : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_SPEED ? "Yes" : "No");
printf(_("Can detect if CD changed : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED ? "Yes" : "No");
printf(_("Can read multiple sessions : %s\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_MULTI_SESSION ? "Yes" : "No");
printf(_("Can hard reset device : %s\n\n"),
i_misc_cap & CDIO_DRIVE_CAP_MISC_RESET ? "Yes" : "No");
}
if (CDIO_DRIVE_CAP_ERROR == i_read_cap) {
printf("Error in getting drive reading properties\n");
} else {
printf("Reading....\n");
printf(_(" Can play audio : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_AUDIO ? "Yes" : "No");
printf(_(" Can read CD-R : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_CD_R ? "Yes" : "No");
printf(_(" Can read CD-RW : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_CD_RW ? "Yes" : "No");
printf(_(" Can read DVD-ROM : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_DVD_ROM ? "Yes" : "No");
}
if (CDIO_DRIVE_CAP_ERROR == i_write_cap) {
printf("Error in getting drive writing properties\n");
} else {
printf("\nWriting....\n");
printf(_(" Can write CD-RW : %s\n"),
i_read_cap & CDIO_DRIVE_CAP_READ_CD_RW ? "Yes" : "No");
printf(_(" Can write DVD-R : %s\n"),
i_write_cap & CDIO_DRIVE_CAP_READ_DVD_R ? "Yes" : "No");
printf(_(" Can write DVD-RAM : %s\n"),
i_write_cap & CDIO_DRIVE_CAP_READ_DVD_RAM ? "Yes" : "No");
}
}
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio = cdio_open (NULL, DRIVER_UNKNOWN);
if (NULL != p_cdio) {
char *default_device = cdio_get_default_device(p_cdio);
cdio_drive_read_cap_t i_read_cap;
cdio_drive_write_cap_t i_write_cap;
cdio_drive_misc_cap_t i_misc_cap;
printf("The driver selected is %s\n", cdio_get_driver_name(p_cdio));
if (default_device)
printf("The default device for this driver is %s\n", default_device);
cdio_get_drive_cap(p_cdio, &i_read_cap, &i_write_cap, &i_misc_cap);
print_drive_capabilities(i_read_cap, i_write_cap, i_misc_cap);
free(default_device);
cdio_destroy(p_cdio);
printf("\n");
} else {
printf("Problem in trying to find a driver.\n\n");
}
{
driver_id_t driver_id;
for (driver_id=CDIO_MIN_DRIVER; driver_id<=CDIO_MAX_DRIVER; driver_id++)
if (cdio_have_driver(driver_id))
printf("We have: %s\n", cdio_driver_describe(driver_id));
else
printf("We don't have: %s\n", cdio_driver_describe(driver_id));
}
return 0;
}

93
example/drives.c Normal file
View File

@@ -0,0 +1,93 @@
/*
$Id: drives.c,v 1.6 2008/03/24 15:30:55 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/>.
*/
/* Simple program to show drivers installed and what the default
CD-ROM drive is and what CD drives are available. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio/cdio.h>
#include <cdio/cd_types.h>
#include <cdio/logging.h>
static void
log_handler (cdio_log_level_t level, const char message[])
{
switch(level) {
case CDIO_LOG_DEBUG:
case CDIO_LOG_INFO:
return;
default:
printf("cdio %d message: %s\n", level, message);
}
}
static void
print_drive_class(const char *psz_msg, cdio_fs_anal_t bitmask, bool b_any) {
char **ppsz_cd_drives=NULL, **c;
printf("%s...\n", psz_msg);
ppsz_cd_drives = cdio_get_devices_with_cap(NULL, bitmask, b_any);
if (NULL != ppsz_cd_drives)
for( c = ppsz_cd_drives; *c != NULL; c++ ) {
printf("Drive %s\n", *c);
}
cdio_free_device_list(ppsz_cd_drives);
printf("-----\n");
}
int
main(int argc, const char *argv[])
{
char **ppsz_cd_drives=NULL, **c;
cdio_log_set_handler (log_handler);
/* Print out a list of CD-drives */
ppsz_cd_drives = cdio_get_devices(DRIVER_DEVICE);
if (NULL != ppsz_cd_drives)
for( c = ppsz_cd_drives; *c != NULL; c++ ) {
printf("Drive %s\n", *c);
}
cdio_free_device_list(ppsz_cd_drives);
ppsz_cd_drives = NULL;
printf("-----\n");
/* Print out a list of CD-drives the harder way. */
print_drive_class("All CD-ROM drives (again)", CDIO_FS_MATCH_ALL, false);
print_drive_class("CD-ROM drives with a CD-DA loaded...",
CDIO_FS_AUDIO, false);
print_drive_class("CD-ROM drives with some sort of ISO 9660 filesystem...",
CDIO_FS_ANAL_ISO9660_ANY, true);
print_drive_class("(S)VCD drives...", CDIO_FS_ANAL_VCD_ANY, true);
return 0;
}

101
example/eject.c Normal file
View File

@@ -0,0 +1,101 @@
/*
$Id: eject.c,v 1.5 2008/03/24 15:30:55 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/>.
*/
/* Simple program to eject a CD-ROM drive door and then close it again.
If a single argument is given, it is used as the CD-ROM device to
eject/close. Otherwise a CD-ROM drive will be scanned for.
See also corresponding C++ program of a similar name.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <cdio/cdio.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
int
main(int argc, const char *argv[])
{
driver_return_code_t ret;
driver_id_t driver_id = DRIVER_DEVICE;
char *psz_drive = NULL;
if (argc > 1)
psz_drive = strdup(argv[1]);
if (!psz_drive) {
psz_drive = cdio_get_default_device_driver(&driver_id);
if (!psz_drive) {
printf("Can't find a CD-ROM to eject\n");
exit(1);
}
}
ret = cdio_eject_media_drive(psz_drive);
switch(ret) {
case DRIVER_OP_UNSUPPORTED:
printf("Eject not supported for %s.\n", psz_drive);
break;
case DRIVER_OP_SUCCESS:
printf("CD-ROM drive %s ejected.\n", psz_drive);
break;
default:
printf("Eject of CD-ROM drive %s failed.\n", psz_drive);
break;
}
if (DRIVER_OP_SUCCESS == cdio_close_tray(psz_drive, &driver_id)) {
printf("Closed tray of CD-ROM drive %s.\n", psz_drive);
} else {
printf("Closing tray of CD-ROM drive %s failed.\n", psz_drive);
}
free(psz_drive);
ret = cdio_eject_media_drive(NULL);
switch(ret) {
case DRIVER_OP_UNSUPPORTED:
printf("Eject not supported for default device.\n");
break;
case DRIVER_OP_SUCCESS:
printf("CD-ROM drive ejected for default device.\n");
break;
default:
printf("Eject of CD-ROM drive failed for default device.\n");
break;
}
driver_id = DRIVER_DEVICE;
if (DRIVER_OP_SUCCESS == cdio_close_tray(NULL, &driver_id)) {
printf("Closed tray of CD-ROM drive for default disc driver:\n\t%s\n",
cdio_driver_describe(driver_id));
} else {
printf("Closing tray of CD-ROM drive failed for default "
"disc driver:\n\t%s\n", cdio_driver_describe(driver_id));
}
return 0;
}

161
example/isofile.c Normal file
View File

@@ -0,0 +1,161 @@
/*
$Id: isofile.c,v 1.2 2008/03/24 15:30:55 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/>.
*/
/* Simple program to show using libiso9660 to extract a file from an
ISO-9660 image.
If a single argument is given, it is used as the ISO 9660 image to
use in the extraction. Otherwise a compiled in default ISO 9660 image
name (that comes with the libcdio distribution) will be used.
*/
/* This is the ISO 9660 image. */
#define ISO9660_IMAGE_PATH "../"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/copying.iso"
#define LOCAL_FILENAME "copying"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "portable.h"
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/iso9660.h>
#include <stdio.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define CEILING(x, y) ((x+(y-1))/y)
#define my_exit(rc) \
fclose (p_outfd); \
free(p_statbuf); \
iso9660_close(p_iso); \
return rc; \
int
main(int argc, const char *argv[])
{
iso9660_stat_t *p_statbuf;
FILE *p_outfd;
int i;
char const *psz_image;
char const *psz_fname;
iso9660_t *p_iso;
if (argc > 3) {
printf("usage %s [ISO9660-image.ISO [filename]]\n", argv[0]);
printf("Extracts filename from ISO-9660-image.ISO\n");
return 1;
}
if (argc > 1)
psz_image = argv[1];
else
psz_image = ISO9660_IMAGE;
if (argc > 2)
psz_fname = argv[2];
else
psz_fname = LOCAL_FILENAME;
p_iso = iso9660_open (psz_image);
if (NULL == p_iso) {
fprintf(stderr, "Sorry, couldn't open ISO 9660 image %s\n", psz_image);
return 1;
}
p_statbuf = iso9660_ifs_stat_translate (p_iso, psz_fname);
if (NULL == p_statbuf)
{
fprintf(stderr,
"Could not get ISO-9660 file information for file %s\n",
psz_fname);
iso9660_close(p_iso);
return 2;
}
if (!(p_outfd = fopen (psz_fname, "wb")))
{
perror ("fopen()");
free(p_statbuf);
iso9660_close(p_iso);
return 3;
}
/* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */
{
const unsigned int i_blocks = CEILING(p_statbuf->size, ISO_BLOCKSIZE);
for (i = 0; i < i_blocks ; i++)
{
char buf[ISO_BLOCKSIZE];
const lsn_t lsn = p_statbuf->lsn + i;
memset (buf, 0, ISO_BLOCKSIZE);
if ( ISO_BLOCKSIZE != iso9660_iso_seek_read (p_iso, buf, lsn, 1) )
{
fprintf(stderr, "Error reading ISO 9660 file %s at LSN %lu\n",
psz_fname, (long unsigned int) lsn);
my_exit(4);
}
fwrite (buf, ISO_BLOCKSIZE, 1, p_outfd);
if (ferror (p_outfd))
{
perror ("fwrite()");
my_exit(5);
}
}
}
fflush (p_outfd);
/* Make sure the file size has the exact same byte size. Without the
truncate below, the file will a multiple of ISO_BLOCKSIZE.
*/
if (ftruncate (fileno (p_outfd), p_statbuf->size))
perror ("ftruncate()");
printf("Extraction of file '%s' from %s successful.\n",
psz_fname, psz_image);
my_exit(0);
}

180
example/isofile2.c Normal file
View File

@@ -0,0 +1,180 @@
/*
$Id: isofile2.c,v 1.2 2008/03/24 15:30:55 karl Exp $
Copyright (C) 2003, 2004, 2005, 2006 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/>.
*/
/* Simple program to show using libiso9660 to extract a file from a
CUE/BIN CD image.
If a single argument is given, it is used as the CUE file of a CD image
to use. Otherwise a compiled-in default image name (that
comes with the libcdio distribution) will be used.
This program can be compiled with either a C or C++ compiler. In
the distribution we prefer C++ just to make sure we haven't broken
things on the C++ side.
*/
/* This is the CD-image with an ISO-9660 filesystem */
#define ISO9660_IMAGE_PATH "../"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/isofs-m1.cue"
#define ISO9660_PATH "/"
#define ISO9660_FILENAME "COPYING"
#define LOCAL_FILENAME "copying"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "portable.h"
#include <cdio/cdio.h>
#include <cdio/iso9660.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define CEILING(x, y) ((x+(y-1))/y)
#define my_exit(rc) \
fclose (p_outfd); \
free(p_statbuf); \
cdio_destroy(p_cdio); \
return rc; \
int
main(int argc, const char *argv[])
{
iso9660_stat_t *p_statbuf;
FILE *p_outfd;
int i;
char const *psz_image;
char const *psz_fname;
char translated_name[256];
char untranslated_name[256] = ISO9660_PATH;
CdIo_t *p_cdio;
unsigned int i_fname=sizeof(ISO9660_FILENAME);
if (argc > 3) {
printf("usage %s [CD-ROM-or-image [filename]]\n", argv[0]);
printf("Extracts filename from CD-ROM-or-image.\n");
return 1;
}
if (argc > 1)
psz_image = argv[1];
else
psz_image = ISO9660_IMAGE;
if (argc > 2) {
psz_fname = argv[2];
i_fname = strlen(psz_fname)+1;
} else
psz_fname = ISO9660_FILENAME;
strncat(untranslated_name, psz_fname, i_fname);
p_cdio = cdio_open (psz_image, DRIVER_UNKNOWN);
if (!p_cdio) {
fprintf(stderr, "Sorry, couldn't open %s\n", psz_image);
return 1;
}
p_statbuf = iso9660_fs_stat (p_cdio, untranslated_name);
if (NULL == p_statbuf)
{
fprintf(stderr,
"Could not get ISO-9660 file information for file %s\n",
untranslated_name);
cdio_destroy(p_cdio);
return 2;
}
iso9660_name_translate(psz_fname, translated_name);
if (!(p_outfd = fopen (translated_name, "wb")))
{
perror ("fopen()");
cdio_destroy(p_cdio);
free(p_statbuf);
return 3;
}
/* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */
{
const unsigned int i_blocks = CEILING(p_statbuf->size, ISO_BLOCKSIZE);
for (i = 0; i < i_blocks; i ++)
{
char buf[ISO_BLOCKSIZE];
const lsn_t lsn = p_statbuf->lsn + i;
memset (buf, 0, ISO_BLOCKSIZE);
if ( 0 != cdio_read_data_sectors (p_cdio, buf, lsn, ISO_BLOCKSIZE, 1) )
{
fprintf(stderr, "Error reading ISO 9660 file at lsn %lu\n",
(long unsigned int) p_statbuf->lsn);
my_exit(4);
}
fwrite (buf, ISO_BLOCKSIZE, 1, p_outfd);
if (ferror (p_outfd))
{
perror ("fwrite()");
my_exit(5);
}
}
}
fflush (p_outfd);
/* Make sure the file size has the exact same byte size. Without the
truncate below, the file will a multiple of ISO_BLOCKSIZE.
*/
if (ftruncate (fileno (p_outfd), p_statbuf->size))
perror ("ftruncate()");
printf("Extraction of file '%s' from '%s' successful.\n",
translated_name, untranslated_name);
my_exit(0);
}

99
example/isofuzzy.c Normal file
View File

@@ -0,0 +1,99 @@
/*
$Id: isofuzzy.c,v 1.3 2008/03/24 15:30:56 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/>.
*/
/* Program to show using libiso9660 with fuzzy search to get file info.
If a single argument is given, it is used as the ISO 9660 image.
Otherwise we use a compiled-in default ISO 9660 image
name.
*/
/* This is the BIN we think there is an ISO 9660 image inside of. */
#define ISO9660_IMAGE_PATH "/tmp/"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "vcd_demo.bin"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "portable.h"
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/iso9660.h>
#include <stdio.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
int
main(int argc, const char *argv[])
{
CdioList_t *entlist;
CdioListNode_t *entnode;
char const *psz_fname;
iso9660_t *p_iso;
if (argc > 1)
psz_fname = argv[1];
else
psz_fname = ISO9660_IMAGE;
p_iso = iso9660_open_fuzzy (psz_fname, 5);
if (NULL == p_iso) {
fprintf(stderr, "Sorry, could not find an ISO 9660 image from %s\n",
psz_fname);
return 1;
}
entlist = iso9660_ifs_readdir (p_iso, "/");
/* Iterate over the list of nodes that iso9660_ifs_readdir gives */
if (entlist) {
_CDIO_LIST_FOREACH (entnode, entlist)
{
char filename[4096];
iso9660_stat_t *p_statbuf =
(iso9660_stat_t *) _cdio_list_node_data (entnode);
iso9660_name_translate(p_statbuf->filename, filename);
printf ("/%s\n", filename);
}
_cdio_list_free (entlist, true);
}
iso9660_close(p_iso);
exit(0);
}

119
example/isolist.c Normal file
View File

@@ -0,0 +1,119 @@
/*
$Id: isolist.c,v 1.3 2008/03/24 15:30:56 karl Exp $
Copyright (C) 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/>.
*/
/* Simple program to show using libiso9660 to list files in a directory of
an ISO-9660 image and give some iso9660 information. See the code
to iso-info for a more complete example.
If a single argument is given, it is used as the ISO 9660 image to
use in the listing. Otherwise a compiled-in default ISO 9660 image
name (that comes with the libcdio distribution) will be used.
*/
/* Set up a CD-DA image to test on which is in the libcdio distribution. */
#define ISO9660_IMAGE_PATH "../test/"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "copying.iso"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/iso9660.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define print_vd_info(title, fn) \
if (fn(p_iso, &psz_str)) { \
printf(title ": %s\n", psz_str); \
} \
free(psz_str); \
psz_str = NULL;
int
main(int argc, const char *argv[])
{
CdioList_t *p_entlist;
CdioListNode_t *p_entnode;
char const *psz_fname;
iso9660_t *p_iso;
const char *psz_path="/";
if (argc > 1)
psz_fname = argv[1];
else
psz_fname = ISO9660_IMAGE;
p_iso = iso9660_open (psz_fname);
if (NULL == p_iso) {
fprintf(stderr, "Sorry, couldn't open %s as an ISO-9660 image\n",
psz_fname);
return 1;
}
/* Show basic CD info from the Primary Volume Descriptor. */
{
char *psz_str = NULL;
print_vd_info("Application", iso9660_ifs_get_application_id);
print_vd_info("Preparer ", iso9660_ifs_get_preparer_id);
print_vd_info("Publisher ", iso9660_ifs_get_publisher_id);
print_vd_info("System ", iso9660_ifs_get_system_id);
print_vd_info("Volume ", iso9660_ifs_get_volume_id);
print_vd_info("Volume Set ", iso9660_ifs_get_volumeset_id);
}
p_entlist = iso9660_ifs_readdir (p_iso, psz_path);
/* Iterate over the list of nodes that iso9660_ifs_readdir gives */
if (p_entlist) {
_CDIO_LIST_FOREACH (p_entnode, p_entlist)
{
char filename[4096];
iso9660_stat_t *p_statbuf =
(iso9660_stat_t *) _cdio_list_node_data (p_entnode);
iso9660_name_translate(p_statbuf->filename, filename);
printf ("%s [LSN %6d] %8u %s%s\n",
_STAT_DIR == p_statbuf->type ? "d" : "-",
p_statbuf->lsn, p_statbuf->size, psz_path, filename);
}
_cdio_list_free (p_entlist, true);
}
iso9660_close(p_iso);
return 0;
}

98
example/isolsn.c Normal file
View File

@@ -0,0 +1,98 @@
/*
$Id: isolsn.c,v 1.2 2008/03/24 15:30:56 karl Exp $
Copyright (C) 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/>.
*/
/* Simple program to show using libiso9660 to get a file path
for a given LSN of an ISO-9660 image.
If a single argument is given, it is used as the LSN to search for.
Otherwise we use a built-in default value.
If a second argument is given, it is ISO 9660 image to use in the
listing. Otherwise a compiled-in default ISO 9660 image name (that
comes with the libcdio distribution) will be used.
*/
/* Set up a CD-DA image to test on which is in the libcdio distribution. */
#define ISO9660_IMAGE_PATH "../test/"
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "copying.iso"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/iso9660.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define print_vd_info(title, fn) \
if (fn(p_iso, &psz_str)) { \
printf(title ": %s\n", psz_str); \
} \
free(psz_str); \
psz_str = NULL;
int
main(int argc, const char *argv[])
{
char const *psz_fname;
iso9660_t *p_iso;
lsn_t lsn = 24;
char *psz_path = NULL;
if (argc > 1)
lsn = strtol(argv[1], (char **)NULL, 10);
if (argc > 2)
psz_fname = argv[2];
else
psz_fname = ISO9660_IMAGE;
p_iso = iso9660_open (psz_fname);
if (NULL == p_iso) {
fprintf(stderr, "Sorry, couldn't open %s as an ISO-9660 image\n",
psz_fname);
return 1;
}
iso9660_ifs_find_lsn_with_path (p_iso, lsn, &psz_path);
if (psz_path != NULL) {
printf("File at LSN %u is %s\n", lsn, psz_path);
free(psz_path);
}
iso9660_close(p_iso);
return 0;
}

89
example/mmc1.c Normal file
View File

@@ -0,0 +1,89 @@
/*
$Id: mmc1.c,v 1.7 2008/03/24 15:30:56 karl Exp $
Copyright (C) 2004, 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/>.
*/
/* Sample program to show use of the MMC interface.
An optional drive name can be supplied as an argument.
This basically the libdio mmc_get_hwinfo() routine.
See also corresponding C++ programs.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <cdio/cdio.h>
#include <cdio/mmc.h>
/* Set how long to wait for MMC commands to complete */
#define DEFAULT_TIMEOUT_MS 10000
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio;
const char *psz_drive = NULL;
if (argc > 1) psz_drive = argv[1];
p_cdio = cdio_open (psz_drive, DRIVER_UNKNOWN);
if (!p_cdio) {
printf("Couldn't find CD\n");
return 1;
} else {
int i_status; /* Result of MMC command */
char buf[36] = { 0, }; /* Place to hold returned data */
mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Buffer */
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_INQUIRY);
cdb.field[4] = sizeof(buf);
i_status = mmc_run_cmd(p_cdio, DEFAULT_TIMEOUT_MS, &cdb,
SCSI_MMC_DATA_READ, sizeof(buf), &buf);
if (i_status == 0) {
char psz_vendor[CDIO_MMC_HW_VENDOR_LEN+1];
char psz_model[CDIO_MMC_HW_MODEL_LEN+1];
char psz_rev[CDIO_MMC_HW_REVISION_LEN+1];
memcpy(psz_vendor, buf + 8, sizeof(psz_vendor)-1);
psz_vendor[sizeof(psz_vendor)-1] = '\0';
memcpy(psz_model,
buf + 8 + CDIO_MMC_HW_VENDOR_LEN,
sizeof(psz_model)-1);
psz_model[sizeof(psz_model)-1] = '\0';
memcpy(psz_rev,
buf + 8 + CDIO_MMC_HW_VENDOR_LEN +CDIO_MMC_HW_MODEL_LEN,
sizeof(psz_rev)-1);
psz_rev[sizeof(psz_rev)-1] = '\0';
printf("Vendor: %s\nModel: %s\nRevision: %s\n",
psz_vendor, psz_model, psz_rev);
} else {
printf("Couldn't get INQUIRY data (vendor, model, and revision).\n");
}
}
cdio_destroy(p_cdio);
return 0;
}

196
example/mmc2.c Normal file
View File

@@ -0,0 +1,196 @@
/*
$Id: mmc2.c,v 1.8 2008/03/24 15:30:56 karl Exp $
Copyright (C) 2004, 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/>.
*/
/* A program to using the MMC interface to list CD and drive features
from the MMC GET_CONFIGURATION command . */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <cdio/cdio.h>
#include <cdio/mmc.h>
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio;
const char *psz_drive = NULL;
if (argc > 1) psz_drive = argv[1];
p_cdio = cdio_open (psz_drive, DRIVER_DEVICE);
if (NULL == p_cdio) {
printf("Couldn't find CD\n");
return 1;
} else {
int i_status; /* Result of MMC command */
uint8_t buf[500] = { 0, }; /* Place to hold returned data */
mmc_cdb_t cdb = {{0, }}; /* Command Descriptor Buffer */
CDIO_MMC_SET_COMMAND(cdb.field, CDIO_MMC_GPCMD_GET_CONFIGURATION);
CDIO_MMC_SET_READ_LENGTH8(cdb.field, sizeof(buf));
cdb.field[1] = CDIO_MMC_GET_CONF_ALL_FEATURES;
cdb.field[3] = 0x0;
i_status = mmc_run_cmd(p_cdio, 0, &cdb, SCSI_MMC_DATA_READ, sizeof(buf),
&buf);
if (i_status == 0) {
uint8_t *p;
uint32_t i_data;
uint8_t *p_max = buf + 65530;
i_data = (unsigned int) CDIO_MMC_GET_LEN32(buf);
/* set to first sense feature code, and then walk through the masks */
p = buf + 8;
while( (p < &(buf[i_data])) && (p < p_max) ) {
uint16_t i_feature;
uint8_t i_feature_additional = p[3];
i_feature = CDIO_MMC_GET_LEN16(p);
{
uint8_t *q;
const char *feature_str = mmc_feature2str(i_feature);
printf("%s Feature\n", feature_str);
switch( i_feature )
{
case CDIO_MMC_FEATURE_PROFILE_LIST:
for ( q = p+4 ; q < p + i_feature_additional ; q += 4 ) {
int i_profile=CDIO_MMC_GET_LEN16(q);
const char *feature_profile_str =
mmc_feature_profile2str(i_profile);
printf( "\t%s", feature_profile_str );
if (q[2] & 1) {
printf(" - on");
}
printf("\n");
}
printf("\n");
break;
case CDIO_MMC_FEATURE_CORE:
{
uint8_t *q = p+4;
uint32_t i_interface_standard = CDIO_MMC_GET_LEN32(q);
switch(i_interface_standard) {
case 0:
printf("\tunspecified interface.\n");
break;
case 1:
printf("\tSCSI interface.\n");
break;
case 2:
printf("\tATAPI interface.\n");
break;
case 3:
printf("\tIEEE 1394 interface.\n");
break;
case 4:
printf("\tIEEE 1394A interface.\n");
break;
case 5:
printf("\tFibre Channel interface.\n");
}
printf("\n");
break;
}
case CDIO_MMC_FEATURE_REMOVABLE_MEDIUM:
switch(p[4] >> 5) {
case 0:
printf("\tCaddy/Slot type loading mechanism,\n");
break;
case 1:
printf("\tTray type loading mechanism,\n");
break;
case 2:
printf("\tPop-up type loading mechanism,\n");
break;
case 4:
printf("\tEmbedded changer with individually changeable discs,\n");
break;
case 5:
printf("\tEmbedded changer using a magazine mechanism,\n");
break;
default:
printf("\tUnknown changer mechanism,\n");
}
printf("\tcan%s eject the medium or magazine via the normal "
"START/STOP command,\n",
(p[4] & 8) ? "": "not");
printf("\tcan%s be locked into the Logical Unit.\n",
(p[4] & 1) ? "": "not");
printf("\n");
break;
case CDIO_MMC_FEATURE_CD_READ:
printf("CD Read Feature\n");
printf("\tC2 Error pointers are %ssupported,\n",
(p[4] & 2) ? "": "not ");
printf("\tCD-Text is %ssupported.\n",
(p[4] & 1) ? "": "not ");
printf("\n");
break;
case CDIO_MMC_FEATURE_CDDA_EXT_PLAY:
printf("\tSCAN command is %ssupported,\n",
(p[4] & 4) ? "": "not ");
printf("\taudio channels can %sbe muted separately,\n",
(p[4] & 2) ? "": "not ");
printf("\taudio channels can %shave separate volume levels.\n",
(p[4] & 1) ? "": "not ");
{
uint8_t *q = p+6;
uint16_t i_vol_levels = CDIO_MMC_GET_LEN16(q);
printf("\t%d volume levels can be set\n", i_vol_levels);
}
printf("\n");
break;
case CDIO_MMC_FEATURE_LU_SN: {
uint8_t i_serial = *(p+3);
char serial[257] = { '\0', };
memcpy(serial, p+4, i_serial);
printf("\t%s\n\n", serial);
break;
}
default:
printf("\n");
break;
}
p += i_feature_additional + 4;
}
}
} else {
printf("Didn't get all feature codes.\n");
}
}
if (mmc_have_interface(p_cdio, CDIO_MMC_FEATURE_INTERFACE_ATAPI))
printf("CD-ROM is an ATAPI interface.\n");
else
printf("CD-ROM is not an ATAPI interface.\n");
cdio_destroy(p_cdio);
return 0;
}

234
example/mmc2a.c Normal file
View File

@@ -0,0 +1,234 @@
/*
$Id: mmc2a.c,v 1.5 2008/03/24 15:30:56 karl 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/>.
*/
/* Sample program to show use of the MMC interface.
An optional drive name can be supplied as an argument.
This basically calls to the libdio mmc_mode_sense_10() and mmc_mode_sense_6
routines.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <cdio/cdio.h>
#include <cdio/mmc.h>
static void
print_mode_sense (const char *psz_drive, const char *six_or_ten,
const uint8_t buf[22])
{
printf("Mode sense %s information for %s:\n", six_or_ten, psz_drive);
if (buf[2] & 0x01) {
printf("\tReads CD-R media.\n");
}
if (buf[2] & 0x02) {
printf("\tReads CD-RW media.\n");
}
if (buf[2] & 0x04) {
printf("\tReads fixed-packet tracks when Addressing type is method 2.\n");
}
if (buf[2] & 0x08) {
printf("\tReads DVD ROM media.\n");
}
if (buf[2] & 0x10) {
printf("\tReads DVD-R media.\n");
}
if (buf[2] & 0x20) {
printf("\tReads DVD-RAM media.\n");
}
if (buf[2] & 0x40) {
printf("\tReads DVD-RAM media.\n");
}
if (buf[3] & 0x01) {
printf("\tWrites CD-R media.\n");
}
if (buf[3] & 0x02) {
printf("\tWrites CD-RW media.\n");
}
if (buf[3] & 0x04) {
printf("\tSupports emulation write.\n");
}
if (buf[3] & 0x10) {
printf("\tWrites DVD-R media.\n");
}
if (buf[3] & 0x20) {
printf("\tWrites DVD-RAM media.\n");
}
if (buf[4] & 0x01) {
printf("\tCan play audio.\n");
}
if (buf[4] & 0x02) {
printf("\tDelivers composition A/V stream.\n");
}
if (buf[4] & 0x04) {
printf("\tSupports digital output on port 2.\n");
}
if (buf[4] & 0x08) {
printf("\tSupports digital output on port 1.\n");
}
if (buf[4] & 0x10) {
printf("\tReads Mode-2 form 1 (e.g. XA) media.\n");
}
if (buf[4] & 0x20) {
printf("\tReads Mode-2 form 2 media.\n");
}
if (buf[4] & 0x40) {
printf("\tReads multi-session CD media.\n");
}
if (buf[4] & 0x80) {
printf("\tSupports Buffer under-run free recording on CD-R/RW media.\n");
}
if (buf[4] & 0x01) {
printf("\tCan read audio data with READ CD.\n");
}
if (buf[4] & 0x02) {
printf("\tREAD CD data stream is accurate.\n");
}
if (buf[5] & 0x04) {
printf("\tReads R-W subchannel information.\n");
}
if (buf[5] & 0x08) {
printf("\tReads de-interleaved R-W subchannel.\n");
}
if (buf[5] & 0x10) {
printf("\tSupports C2 error pointers.\n");
}
if (buf[5] & 0x20) {
printf("\tReads ISRC information.\n");
}
if (buf[5] & 0x40) {
printf("\tReads ISRC informaton.\n");
}
if (buf[5] & 0x40) {
printf("\tReads media catalog number (MCN also known as UPC).\n");
}
if (buf[5] & 0x80) {
printf("\tReads bar codes.\n");
}
if (buf[6] & 0x01) {
printf("\tPREVENT/ALLOW may lock media.\n");
}
printf("\tLock state is %slocked.\n", (buf[6] & 0x02) ? "" : "un");
printf("\tPREVENT/ALLOW jumper is %spresent.\n", (buf[6] & 0x04) ? "": "not ");
if (buf[6] & 0x08) {
printf("\tEjects media with START STOP UNIT.\n");
}
{
const unsigned int i_load_type = (buf[6]>>5 & 0x07);
printf("\tLoading mechanism type is %d: ", i_load_type);
switch (buf[6]>>5 & 0x07) {
case 0:
printf("caddy type loading mechanism.\n");
break;
case 1:
printf("tray type loading mechanism.\n");
break;
case 2:
printf("popup type loading mechanism.\n");
break;
case 3:
printf("reserved\n");
break;
case 4:
printf("changer with individually changeable discs.\n");
break;
case 5:
printf("changer using Magazine mechanism.\n");
break;
case 6:
printf("changer using Magazine mechanism.\n");
break;
default:
printf("Invalid.\n");
break;
}
}
if (buf[7] & 0x01) {
printf("\tVolume controls each channel separately.\n");
}
if (buf[7] & 0x02) {
printf("\tHas a changer that supports disc present reporting.\n");
}
if (buf[7] & 0x04) {
printf("\tCan load empty slot in changer.\n");
}
if (buf[7] & 0x08) {
printf("\tSide change capable.\n");
}
if (buf[7] & 0x10) {
printf("\tReads raw R-W subchannel information from lead in.\n");
}
{
const unsigned int i_speed_Kbs = CDIO_MMC_GETPOS_LEN16(buf, 8);
printf("\tMaximum read speed is %d K bytes/sec (about %dX)\n",
i_speed_Kbs, i_speed_Kbs / 176) ;
}
printf("\tNumber of Volume levels is %d\n", CDIO_MMC_GETPOS_LEN16(buf, 10));
printf("\tBuffers size for data is %d KB\n", CDIO_MMC_GETPOS_LEN16(buf, 12));
printf("\tCurrent read speed is %d KB\n", CDIO_MMC_GETPOS_LEN16(buf, 14));
printf("\tMaximum write speed is %d KB\n", CDIO_MMC_GETPOS_LEN16(buf, 18));
printf("\tCurrent write speed is %d KB\n", CDIO_MMC_GETPOS_LEN16(buf, 28));
}
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio;
const char *psz_drive = NULL;
if (argc > 1) psz_drive = argv[1];
p_cdio = cdio_open (psz_drive, DRIVER_UNKNOWN);
if (!p_cdio) {
printf("Couldn't find CD\n");
return 1;
} else {
uint8_t buf[22] = { 0, }; /* Place to hold returned data */
char *psz_cd = cdio_get_default_device(p_cdio);
if (DRIVER_OP_SUCCESS == mmc_mode_sense_6(p_cdio, buf, sizeof(buf),
CDIO_MMC_CAPABILITIES_PAGE) ) {
print_mode_sense(psz_cd, "6", buf);
} else {
printf("Couldn't get MODE_SENSE 6 data.\n");
}
if (DRIVER_OP_SUCCESS == mmc_mode_sense_10(p_cdio, buf, sizeof(buf),
CDIO_MMC_CAPABILITIES_PAGE) ) {
print_mode_sense(psz_cd, "10", buf);
} else {
printf("Couldn't get MODE_SENSE 10 data.\n");
}
free(psz_cd);
}
cdio_destroy(p_cdio);
return 0;
}

130
example/mmc3.c Normal file
View File

@@ -0,0 +1,130 @@
/*
$Id: mmc3.c,v 1.2 2008/03/24 15:30:56 karl 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/>.
*/
/* Simple program to show use of SCSI MMC interface. Is basically the
the libdio scsi_mmc_get_hwinfo() routine.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <sys/types.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <cdio/cdio.h>
#include <cdio/mmc.h>
#include <string.h>
/* Set how long to wait for MMC commands to complete */
#define DEFAULT_TIMEOUT_MS 10000
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio;
driver_return_code_t ret;
driver_id_t driver_id = DRIVER_DEVICE;
char *psz_drive = NULL;
bool do_eject = false;
if (argc > 1)
psz_drive = strdup(argv[1]);
if (!psz_drive) {
psz_drive = cdio_get_default_device_driver(&driver_id);
if (!psz_drive) {
printf("Can't find a CD-ROM\n");
exit(1);
}
}
p_cdio = cdio_open (psz_drive, driver_id);
if (!p_cdio) {
printf("Can't open %s\n", psz_drive);
exit(2);
}
ret = mmc_get_tray_status(p_cdio);
switch(ret) {
case 0:
printf("CD-ROM drive %s is closed.\n", psz_drive);
do_eject = true;
break;
case 1:
printf("CD-ROM drive %s is open.\n", psz_drive);
break;
default:
printf("Error status for drive %s: %s.\n", psz_drive,
cdio_driver_errmsg(ret));
return 1;
}
ret = mmc_get_media_changed(p_cdio);
switch(ret) {
case 0:
printf("CD-ROM drive %s media not changed since last test.\n", psz_drive);
break;
case 1:
printf("CD-ROM drive %s media changed since last test.\n", psz_drive);
break;
default:
printf("Error status for drive %s: %s.\n", psz_drive,
cdio_driver_errmsg(ret));
return 1;
}
if (do_eject)
ret = cdio_eject_media_drive(psz_drive);
else
ret = cdio_close_tray(psz_drive, &driver_id);
ret = mmc_get_tray_status(p_cdio);
switch(ret) {
case 0:
printf("CD-ROM drive %s is closed.\n", psz_drive);
break;
case 1:
printf("CD-ROM drive %s is open.\n", psz_drive);
break;
default:
printf("Error status for drive %s: %s.\n", psz_drive,
cdio_driver_errmsg(ret));
return 1;
}
ret = mmc_get_media_changed(p_cdio);
switch(ret) {
case 0:
printf("CD-ROM drive %s media not changed since last test.\n", psz_drive);
break;
case 1:
printf("CD-ROM drive %s media changed since last test.\n", psz_drive);
break;
default:
printf("Error status for drive %s: %s.\n", psz_drive,
cdio_driver_errmsg(ret));
return 1;
}
free(psz_drive);
cdio_destroy(p_cdio);
return 0;
}

119
example/paranoia.c Normal file
View File

@@ -0,0 +1,119 @@
/*
$Id: paranoia.c,v 1.9 2008/03/24 15:30:56 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/>.
*/
/* Simple program to show using libcdio's version of the CD-DA paranoia.
library. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cdio/paranoia.h>
#include <cdio/cd_types.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
int
main(int argc, const char *argv[])
{
cdrom_drive_t *d = NULL; /* Place to store handle given by cd-paranoia. */
char **ppsz_cd_drives; /* List of all drives with a loaded CDDA in it. */
/* See if we can find a device with a loaded CD-DA in it. */
ppsz_cd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
if (ppsz_cd_drives) {
/* Found such a CD-ROM with a CD-DA loaded. Use the first drive in
the list. */
d=cdda_identify(*ppsz_cd_drives, 1, NULL);
} else {
printf("Unable find or access a CD-ROM drive with an audio CD in it.\n");
exit(1);
}
/* Don't need a list of CD's with CD-DA's any more. */
cdio_free_device_list(ppsz_cd_drives);
if ( !d ) {
printf("Unable to identify audio CD disc.\n");
exit(1);
}
/* We'll set for verbose paranoia messages. */
cdda_verbose_set(d, CDDA_MESSAGE_PRINTIT, CDDA_MESSAGE_PRINTIT);
if ( 0 != cdda_open(d) ) {
printf("Unable to open disc.\n");
exit(1);
}
/* Okay now set up to read up to the first 300 frames of the first
audio track of the Audio CD. */
{
cdrom_paranoia_t *p = paranoia_init(d);
lsn_t i_first_lsn = cdda_disc_firstsector(d);
if ( -1 == i_first_lsn ) {
printf("Trouble getting starting LSN\n");
} else {
lsn_t i_cursor;
track_t i_track = cdda_sector_gettrack(d, i_first_lsn);
lsn_t i_last_lsn = cdda_track_lastsector(d, i_track);
/* For demo purposes we'll read only 300 frames (about 4
seconds). We don't want this to take too long. On the other
hand, I suppose it should be something close to a real test.
*/
if ( i_last_lsn - i_first_lsn > 300) i_last_lsn = i_first_lsn + 299;
printf("Reading track %d from LSN %ld to LSN %ld\n", i_track,
(long int) i_first_lsn, (long int) i_last_lsn);
/* Set reading mode for full paranoia, but allow skipping sectors. */
paranoia_modeset(p, PARANOIA_MODE_FULL^PARANOIA_MODE_NEVERSKIP);
paranoia_seek(p, i_first_lsn, SEEK_SET);
for ( i_cursor = i_first_lsn; i_cursor <= i_last_lsn; i_cursor ++) {
/* read a sector */
int16_t *p_readbuf=paranoia_read(p, NULL);
char *psz_err=cdda_errors(d);
char *psz_mes=cdda_messages(d);
if (psz_mes || psz_err)
printf("%s%s\n", psz_mes ? psz_mes: "", psz_err ? psz_err: "");
if (psz_err) free(psz_err);
if (psz_mes) free(psz_mes);
if( !p_readbuf ) {
printf("paranoia read error. Stopping.\n");
break;
}
}
}
paranoia_free(p);
}
cdda_close(d);
exit(0);
}

102
example/paranoia2.c Normal file
View File

@@ -0,0 +1,102 @@
/*
$Id: paranoia2.c,v 1.8 2008/03/24 15:30:56 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/>.
*/
/* Simple program to show using libcdio's version of the CD-DA
paranoia library. But in this version, we'll open a cdio object before
calling paranoia's open. I imagine in many cases such as media
players this may be what will be done since, one may want to get
CDDB/CD-Text info beforehand.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <cdio/cdda.h>
#include <cdio/cd_types.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
int
main(int argc, const char *argv[])
{
cdrom_drive_t *d = NULL; /* Place to store handle given by cd-paranoia. */
char **ppsz_cd_drives; /* List of all drives with a loaded CDDA in it. */
CdIo_t *p_cdio = NULL;
/* See if we can find a device with a loaded CD-DA in it. */
ppsz_cd_drives = cdio_get_devices_with_cap(NULL, CDIO_FS_AUDIO, false);
if (ppsz_cd_drives) {
/* Found such a CD-ROM with a CD-DA loaded. Use the first drive in
the list. */
p_cdio = cdio_open(*ppsz_cd_drives, DRIVER_UNKNOWN);
d=cdio_cddap_identify_cdio(p_cdio, 1, NULL);
} else {
printf("Unable find or access a CD-ROM drive with an audio CD in it.\n");
exit(1);
}
/* Don't need a list of CD's with CD-DA's any more. */
cdio_free_device_list(ppsz_cd_drives);
if ( !d ) {
printf("Unable to identify audio CD disc.\n");
exit(1);
}
/* We'll set for verbose paranoia messages. */
cdio_cddap_verbose_set(d, CDDA_MESSAGE_PRINTIT, CDDA_MESSAGE_PRINTIT);
if ( 0 != cdio_cddap_open(d) ) {
printf("Unable to open disc.\n");
exit(1);
}
/* In the paranoia example was a reading. Here we are going to do
something trivial (but I think neat any way - get the Endian-ness
of the drive. */
{
const int i_endian = data_bigendianp(d);
switch (i_endian) {
case 0:
printf("Drive returns audio data Little Endian."
" Your drive is like most.\n");
break;
case 1:
printf("Drive returns audio data Big Endian.\n");
break;
case -1:
printf("Don't know whether drive is Big or Little Endian.\n");
break;
default:
printf("Whoah - got a return result I'm not expecting %d.\n",
i_endian);
break;
}
}
cdio_cddap_close_no_free_cdio(d);
cdio_destroy( p_cdio );
exit(0);
}

200
example/sample3.c Normal file
View File

@@ -0,0 +1,200 @@
/*
$Id: sample3.c,v 1.10 2008/03/24 15:30:56 karl Exp $
Copyright (C) 2003, 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/>.
*/
/*
A somewhat simplified program to show the use of cdio_guess_cd_type().
Figure out the kind of CD image we've got.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/cd_types.h>
static void
print_analysis(cdio_iso_analysis_t cdio_iso_analysis,
cdio_fs_anal_t fs, int first_data, unsigned int num_audio,
track_t num_tracks, track_t first_track_num, CdIo_t *p_cdio)
{
switch(CDIO_FSTYPE(fs)) {
case CDIO_FS_AUDIO:
break;
case CDIO_FS_ISO_9660:
printf("CD-ROM with ISO 9660 filesystem");
if (fs & CDIO_FS_ANAL_JOLIET) {
printf(" and joliet extension level %d", cdio_iso_analysis.joliet_level);
}
if (fs & CDIO_FS_ANAL_ROCKRIDGE)
printf(" and rockridge extensions");
printf("\n");
break;
case CDIO_FS_ISO_9660_INTERACTIVE:
printf("CD-ROM with CD-RTOS and ISO 9660 filesystem\n");
break;
case CDIO_FS_HIGH_SIERRA:
printf("CD-ROM with High Sierra filesystem\n");
break;
case CDIO_FS_INTERACTIVE:
printf("CD-Interactive%s\n", num_audio > 0 ? "/Ready" : "");
break;
case CDIO_FS_HFS:
printf("CD-ROM with Macintosh HFS\n");
break;
case CDIO_FS_ISO_HFS:
printf("CD-ROM with both Macintosh HFS and ISO 9660 filesystem\n");
break;
case CDIO_FS_UFS:
printf("CD-ROM with Unix UFS\n");
break;
case CDIO_FS_EXT2:
printf("CD-ROM with Linux second extended filesystem\n");
break;
case CDIO_FS_3DO:
printf("CD-ROM with Panasonic 3DO filesystem\n");
break;
case CDIO_FS_UNKNOWN:
printf("CD-ROM with unknown filesystem\n");
break;
}
switch(CDIO_FSTYPE(fs)) {
case CDIO_FS_ISO_9660:
case CDIO_FS_ISO_9660_INTERACTIVE:
case CDIO_FS_ISO_HFS:
printf("ISO 9660: %i blocks, label `%.32s'\n",
cdio_iso_analysis.isofs_size, cdio_iso_analysis.iso_label);
break;
}
if (first_data == 1 && num_audio > 0)
printf("mixed mode CD ");
if (fs & CDIO_FS_ANAL_XA)
printf("XA sectors ");
if (fs & CDIO_FS_ANAL_MULTISESSION)
printf("Multisession");
if (fs & CDIO_FS_ANAL_HIDDEN_TRACK)
printf("Hidden Track ");
if (fs & CDIO_FS_ANAL_PHOTO_CD)
printf("%sPhoto CD ",
num_audio > 0 ? " Portfolio " : "");
if (fs & CDIO_FS_ANAL_CDTV)
printf("Commodore CDTV ");
if (first_data > 1)
printf("CD-Plus/Extra ");
if (fs & CDIO_FS_ANAL_BOOTABLE)
printf("bootable CD ");
if (fs & CDIO_FS_ANAL_VIDEOCD && num_audio == 0) {
printf("Video CD ");
}
if (fs & CDIO_FS_ANAL_SVCD)
printf("Super Video CD (SVCD) or Chaoji Video CD (CVD)");
if (fs & CDIO_FS_ANAL_CVD)
printf("Chaoji Video CD (CVD)");
printf("\n");
}
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio = cdio_open (NULL, DRIVER_UNKNOWN);
cdio_fs_anal_t fs=0;
track_t num_tracks;
track_t first_track_num;
lsn_t start_track; /* first sector of track */
lsn_t data_start =0; /* start of data area */
int first_data = -1; /* # of first data track */
int first_audio = -1; /* # of first audio track */
unsigned int num_data = 0; /* # of data tracks */
unsigned int num_audio = 0; /* # of audio tracks */
unsigned int i;
if (NULL == p_cdio) {
printf("Problem in trying to find a driver.\n\n");
return 1;
}
first_track_num = cdio_get_first_track_num(p_cdio);
num_tracks = cdio_get_num_tracks(p_cdio);
/* Count the number of data and audio tracks. */
for (i = first_track_num; i <= num_tracks; i++) {
if (TRACK_FORMAT_AUDIO == cdio_get_track_format(p_cdio, i)) {
num_audio++;
if (-1 == first_audio) first_audio = i;
} else {
num_data++;
if (-1 == first_data) first_data = i;
}
}
/* try to find out what sort of CD we have */
if (0 == num_data) {
printf("Audio CD\n");
} else {
/* we have data track(s) */
int j;
cdio_iso_analysis_t cdio_iso_analysis;
memset(&cdio_iso_analysis, 0, sizeof(cdio_iso_analysis));
for (j = 2, i = first_data; i <= num_tracks; i++) {
lsn_t lsn;
track_format_t track_format = cdio_get_track_format(p_cdio, i);
lsn = cdio_get_track_lsn(p_cdio, i);
switch ( track_format ) {
case TRACK_FORMAT_AUDIO:
case TRACK_FORMAT_ERROR:
break;
case TRACK_FORMAT_CDI:
case TRACK_FORMAT_XA:
case TRACK_FORMAT_DATA:
case TRACK_FORMAT_PSX:
;
}
start_track = (i == 1) ? 0 : lsn;
/* save the start of the data area */
if (i == first_data)
data_start = start_track;
/* skip tracks which belong to the current walked session */
if (start_track < data_start + cdio_iso_analysis.isofs_size)
continue;
fs = cdio_guess_cd_type(p_cdio, start_track, i, &cdio_iso_analysis);
print_analysis(cdio_iso_analysis, fs, first_data, num_audio,
num_tracks, first_track_num, p_cdio);
if ( !(CDIO_FSTYPE(fs) == CDIO_FS_ISO_9660 ||
CDIO_FSTYPE(fs) == CDIO_FS_ISO_HFS ||
CDIO_FSTYPE(fs) == CDIO_FS_ISO_9660_INTERACTIVE) )
/* no method for non-ISO9660 multisessions */
break;
}
}
cdio_destroy(p_cdio);
return 0;
}

221
example/sample4.c Normal file
View File

@@ -0,0 +1,221 @@
/*
$Id: sample4.c,v 1.8 2008/03/24 15:30:56 karl Exp $
Copyright (C) 2003, 2004 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/>.
*/
/*
A slightly improved sample3 program: we handle cdio logging and
take an optional CD-location.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/cd_types.h>
#include <cdio/logging.h>
static void
log_handler (cdio_log_level_t level, const char message[])
{
switch(level) {
case CDIO_LOG_DEBUG:
case CDIO_LOG_INFO:
return;
default:
printf("cdio %d message: %s\n", level, message);
}
}
static void
print_analysis(cdio_iso_analysis_t cdio_iso_analysis,
cdio_fs_anal_t fs, int first_data, unsigned int num_audio,
track_t num_tracks, track_t first_track_num, CdIo_t *p_cdio)
{
switch(CDIO_FSTYPE(fs)) {
case CDIO_FS_AUDIO:
break;
case CDIO_FS_ISO_9660:
printf("CD-ROM with ISO 9660 filesystem");
if (fs & CDIO_FS_ANAL_JOLIET) {
printf(" and joliet extension level %d", cdio_iso_analysis.joliet_level);
}
if (fs & CDIO_FS_ANAL_ROCKRIDGE)
printf(" and rockridge extensions");
printf("\n");
break;
case CDIO_FS_ISO_9660_INTERACTIVE:
printf("CD-ROM with CD-RTOS and ISO 9660 filesystem\n");
break;
case CDIO_FS_HIGH_SIERRA:
printf("CD-ROM with High Sierra filesystem\n");
break;
case CDIO_FS_INTERACTIVE:
printf("CD-Interactive%s\n", num_audio > 0 ? "/Ready" : "");
break;
case CDIO_FS_HFS:
printf("CD-ROM with Macintosh HFS\n");
break;
case CDIO_FS_ISO_HFS:
printf("CD-ROM with both Macintosh HFS and ISO 9660 filesystem\n");
break;
case CDIO_FS_UFS:
printf("CD-ROM with Unix UFS\n");
break;
case CDIO_FS_EXT2:
printf("CD-ROM with Linux second extended filesystem\n");
break;
case CDIO_FS_3DO:
printf("CD-ROM with Panasonic 3DO filesystem\n");
break;
case CDIO_FS_UNKNOWN:
printf("CD-ROM with unknown filesystem\n");
break;
}
switch(CDIO_FSTYPE(fs)) {
case CDIO_FS_ISO_9660:
case CDIO_FS_ISO_9660_INTERACTIVE:
case CDIO_FS_ISO_HFS:
printf("ISO 9660: %i blocks, label `%.32s'\n",
cdio_iso_analysis.isofs_size, cdio_iso_analysis.iso_label);
break;
}
if (first_data == 1 && num_audio > 0)
printf("mixed mode CD ");
if (fs & CDIO_FS_ANAL_XA)
printf("XA sectors ");
if (fs & CDIO_FS_ANAL_MULTISESSION)
printf("Multisession");
if (fs & CDIO_FS_ANAL_HIDDEN_TRACK)
printf("Hidden Track ");
if (fs & CDIO_FS_ANAL_PHOTO_CD)
printf("%sPhoto CD ",
num_audio > 0 ? " Portfolio " : "");
if (fs & CDIO_FS_ANAL_CDTV)
printf("Commodore CDTV ");
if (first_data > 1)
printf("CD-Plus/Extra ");
if (fs & CDIO_FS_ANAL_BOOTABLE)
printf("bootable CD ");
if (fs & CDIO_FS_ANAL_VIDEOCD && num_audio == 0) {
printf("Video CD ");
}
if (fs & CDIO_FS_ANAL_SVCD)
printf("Super Video CD (SVCD) or Chaoji Video CD (CVD)");
if (fs & CDIO_FS_ANAL_CVD)
printf("Chaoji Video CD (CVD)");
printf("\n");
}
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio;
cdio_fs_anal_t fs=0;
track_t num_tracks;
track_t first_track_num;
lsn_t start_track; /* first sector of track */
lsn_t data_start =0; /* start of data area */
int first_data = -1; /* # of first data track */
int first_audio = -1; /* # of first audio track */
unsigned int num_data = 0; /* # of data tracks */
unsigned int num_audio = 0; /* # of audio tracks */
unsigned int i;
char *cd_image_name = NULL;
if (argc > 1)
cd_image_name = strdup(argv[1]);
cdio_log_set_handler (log_handler);
p_cdio = cdio_open (cd_image_name, DRIVER_UNKNOWN);
if (NULL == p_cdio) {
printf("Problem in trying to find a driver.\n\n");
return 1;
}
first_track_num = cdio_get_first_track_num(p_cdio);
num_tracks = cdio_get_num_tracks(p_cdio);
/* Count the number of data and audio tracks. */
for (i = first_track_num; i <= num_tracks; i++) {
if (TRACK_FORMAT_AUDIO == cdio_get_track_format(p_cdio, i)) {
num_audio++;
if (-1 == first_audio) first_audio = i;
} else {
num_data++;
if (-1 == first_data) first_data = i;
}
}
/* try to find out what sort of CD we have */
if (0 == num_data) {
printf("Audio CD\n");
} else {
/* we have data track(s) */
int j;
cdio_iso_analysis_t cdio_iso_analysis;
memset(&cdio_iso_analysis, 0, sizeof(cdio_iso_analysis));
for (j = 2, i = first_data; i <= num_tracks; i++) {
lsn_t lsn;
track_format_t track_format = cdio_get_track_format(p_cdio, i);
lsn = cdio_get_track_lsn(p_cdio, i);
switch ( track_format ) {
case TRACK_FORMAT_AUDIO:
case TRACK_FORMAT_ERROR:
break;
case TRACK_FORMAT_CDI:
case TRACK_FORMAT_XA:
case TRACK_FORMAT_DATA:
case TRACK_FORMAT_PSX:
;
}
start_track = (i == 1) ? 0 : lsn;
/* save the start of the data area */
if (i == first_data)
data_start = start_track;
/* skip tracks which belong to the current walked session */
if (start_track < data_start + cdio_iso_analysis.isofs_size)
continue;
fs = cdio_guess_cd_type(p_cdio, start_track, i, &cdio_iso_analysis);
print_analysis(cdio_iso_analysis, fs, first_data, num_audio,
num_tracks, first_track_num, p_cdio);
if ( !(CDIO_FSTYPE(fs) == CDIO_FS_ISO_9660 ||
CDIO_FSTYPE(fs) == CDIO_FS_ISO_HFS ||
CDIO_FSTYPE(fs) == CDIO_FS_ISO_9660_INTERACTIVE) )
/* no method for non-ISO9660 multisessions */
break;
}
}
cdio_destroy(p_cdio);
return 0;
}

64
example/tracks.c Normal file
View File

@@ -0,0 +1,64 @@
/*
$Id: tracks.c,v 1.7 2008/03/24 15:30:56 karl Exp $
Copyright (C) 2003, 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/>.
*/
/* Simple program to list track numbers and logical sector numbers of
a Compact Disc using libcdio. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <cdio/cdio.h>
int
main(int argc, const char *argv[])
{
CdIo_t *p_cdio = cdio_open (NULL, DRIVER_UNKNOWN);
track_t i_first_track;
track_t i_tracks;
int j, i;
if (NULL == p_cdio) {
printf("Couldn't find a driver.. leaving.\n");
return 1;
}
printf("Disc last LSN: %d\n", cdio_get_disc_last_lsn(p_cdio));
i_tracks = cdio_get_num_tracks(p_cdio);
i_first_track = i = cdio_get_first_track_num(p_cdio);
printf("CD-ROM Track List (%i - %i)\n", i_first_track,
i_first_track+i_tracks-1);
printf(" #: LSN\n");
for (j = 0; j < i_tracks; i++, j++) {
lsn_t lsn = cdio_get_track_lsn(p_cdio, i);
if (CDIO_INVALID_LSN != lsn)
printf("%3d: %06lu\n", (int) i, (long unsigned int) lsn);
}
printf("%3X: %06lu leadout\n", CDIO_CDROM_LEADOUT_TRACK,
(long unsigned int) cdio_get_track_lsn(p_cdio,
CDIO_CDROM_LEADOUT_TRACK));
cdio_destroy(p_cdio);
return 0;
}

144
example/udf1.c Normal file
View File

@@ -0,0 +1,144 @@
/*
$Id: udf1.c,v 1.19 2008/03/24 15:30:56 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/>.
*/
/* Simple program to show using libudf to list files in a directory of
an UDF image.
*/
/* This is the UDF image. */
#define UDF_IMAGE_PATH "../"
#define UDF_IMAGE "/src2/cd-images/udf/UDF102ISO.iso"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/udf.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define udf_PATH_DELIMITERS "/\\"
static void
print_file_info(const udf_dirent_t *p_udf_dirent, const char* psz_dirname)
{
time_t mod_time = udf_get_modification_time(p_udf_dirent);
char psz_mode[11]="invalid";
const char *psz_fname= psz_dirname
? psz_dirname : udf_get_filename(p_udf_dirent);
/* Print directory attributes*/
printf("%s ", udf_mode_string(udf_get_posix_filemode(p_udf_dirent),
psz_mode));
printf("%4d ", udf_get_link_count(p_udf_dirent));
printf("%lu ", (long unsigned int) udf_get_file_length(p_udf_dirent));
printf("%s %s", *psz_fname ? psz_fname : "/", ctime(&mod_time));
}
static udf_dirent_t *
list_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const char *psz_path)
{
if (!p_udf_dirent) return NULL;
print_file_info(p_udf_dirent, psz_path);
while (udf_readdir(p_udf_dirent)) {
if (udf_is_dir(p_udf_dirent)) {
udf_dirent_t *p_udf_dirent2 = udf_opendir(p_udf_dirent);
if (p_udf_dirent2) {
const char *psz_dirname = udf_get_filename(p_udf_dirent);
const unsigned int i_newlen=2 + strlen(psz_path) + strlen(psz_dirname);
char *psz_newpath = calloc(1, sizeof(char)*i_newlen);
snprintf(psz_newpath, i_newlen, "%s%s/", psz_path, psz_dirname);
list_files(p_udf, p_udf_dirent2, psz_newpath);
free(psz_newpath);
}
} else {
print_file_info(p_udf_dirent, NULL);
}
}
return p_udf_dirent;
}
int
main(int argc, const char *argv[])
{
udf_t *p_udf;
char const *psz_udf_image;
if (argc > 1)
psz_udf_image = argv[1];
else
psz_udf_image = UDF_IMAGE;
p_udf = udf_open (psz_udf_image);
if (NULL == p_udf) {
fprintf(stderr, "Sorry, couldn't open %s as something using UDF\n",
psz_udf_image);
return 1;
} else {
udf_dirent_t *p_udf_root = udf_get_root(p_udf, true, 0);
if (NULL == p_udf_root) {
fprintf(stderr, "Sorry, couldn't find / in %s\n",
psz_udf_image);
return 1;
}
{
char vol_id[UDF_VOLID_SIZE] = "";
char volset_id[UDF_VOLSET_ID_SIZE+1] = "";
if (0 < udf_get_volume_id(p_udf, vol_id, sizeof(vol_id)) )
printf("volume id: %s\n", vol_id);
if (0 < udf_get_volume_id(p_udf, volset_id, sizeof(volset_id)) ) {
volset_id[UDF_VOLSET_ID_SIZE]='\0';
printf("volume set id: %s\n", volset_id);
}
printf("partition number: %d\n", udf_get_part_number(p_udf));
}
list_files(p_udf, p_udf_root, "");
}
udf_close(p_udf);
return 0;
}

134
example/udf2.c Normal file
View File

@@ -0,0 +1,134 @@
/*
$Id: udf2.c,v 1.6 2008/03/24 15:30:56 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/>.
*/
/* Simple program to show using libudf to extract a file.
This program can be compiled with either a C or C++ compiler. In
the distribution we prefer C++ just to make sure we haven't broken
things on the C++ side.
*/
/* This is the UDF image. */
#define UDF_IMAGE_PATH "../"
#define UDF_IMAGE "/src2/cd-images/udf/test2.iso"
#define UDF_FILENAME "/parse/cue.L"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/udf.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define CEILING(x, y) ((x+(y-1))/y)
#define udf_PATH_DELIMITERS "/\\"
static void
print_file_info(const udf_dirent_t *p_udf_dirent, const char* psz_dirname)
{
time_t mod_time = udf_get_modification_time(p_udf_dirent);
char psz_mode[11]="invalid";
const char *psz_fname= psz_dirname
? psz_dirname : udf_get_filename(p_udf_dirent);
/* Print directory attributes*/
printf("%s ", udf_mode_string(udf_get_posix_filemode(p_udf_dirent),
psz_mode));
printf("%4d ", udf_get_link_count(p_udf_dirent));
printf("%ld ", (long unsigned int) udf_get_file_length(p_udf_dirent));
printf("%s %s\n", *psz_fname ? psz_fname : "/", ctime(&mod_time));
}
int
main(int argc, const char *argv[])
{
udf_t *p_udf;
char const *psz_udf_image;
char const *psz_udf_fname;
if (argc > 1)
psz_udf_image = argv[1];
else
psz_udf_image = UDF_IMAGE;
if (argc > 2)
psz_udf_fname = argv[2];
else
psz_udf_fname = UDF_FILENAME;
p_udf = udf_open (psz_udf_image);
if (NULL == p_udf) {
fprintf(stderr, "Sorry, couldn't open %s as something using UDF\n",
psz_udf_image);
return 1;
} else {
udf_dirent_t *p_udf_root = udf_get_root(p_udf, true, 0);
udf_dirent_t *p_udf_file = NULL;
if (NULL == p_udf_root) {
fprintf(stderr, "Sorry, couldn't find / in %s\n",
psz_udf_image);
return 1;
}
p_udf_file = udf_fopen(p_udf_root, psz_udf_fname);
if (!p_udf_file) {
fprintf(stderr, "Sorry, couldn't find %s in %s\n",
psz_udf_fname, psz_udf_image);
return 2;
}
print_file_info(p_udf_file, udf_get_filename(p_udf_file));
{
long unsigned int i_file_length = udf_get_file_length(p_udf_file);
char *p_buf;
unsigned int i_blocks = CEILING(i_file_length, UDF_BLOCKSIZE);
char fmt_string[100] = {'\0'};
snprintf(fmt_string, sizeof(fmt_string), "%%%lus", i_file_length);
p_buf = (char *) calloc(sizeof(char), UDF_BLOCKSIZE*i_blocks);
udf_read_block(p_udf_file, p_buf, i_blocks);
printf(fmt_string, p_buf);
free(p_buf);
}
udf_dirent_free(p_udf_file);
udf_dirent_free(p_udf_root);
}
udf_close(p_udf);
return 0;
}

154
example/udffile.c Normal file
View File

@@ -0,0 +1,154 @@
/*
$Id: udffile.c,v 1.3 2008/03/24 15:30:56 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/>.
*/
/* Simple program to show using libudf to extract a file.
This program can be compiled with either a C or C++ compiler. In
the distribution we prefer C++ just to make sure we haven't broken
things on the C++ side.
*/
/* This is the UDF image. */
#define UDF_IMAGE_PATH "../"
#define UDF_IMAGE "../test/udf102.iso"
#define UDF_FILENAME "/COPYING"
#define LOCAL_FILENAME "copying"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <sys/types.h>
#include <cdio/cdio.h>
#include <cdio/udf.h>
#include <stdio.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define CEILING(x, y) ((x+(y-1))/y)
#define udf_PATH_DELIMITERS "/\\"
int
main(int argc, const char *argv[])
{
udf_t *p_udf;
FILE *p_outfd;
char const *psz_udf_image;
char const *psz_udf_fname;
char const *psz_local_fname;
if (argc > 1)
psz_udf_image = argv[1];
else
psz_udf_image = UDF_IMAGE;
if (argc > 2)
psz_udf_fname = argv[2];
else
psz_udf_fname = UDF_FILENAME;
if (argc > 3)
psz_local_fname = argv[3];
else
psz_local_fname = LOCAL_FILENAME;
p_udf = udf_open (psz_udf_image);
if (NULL == p_udf) {
fprintf(stderr, "Sorry, couldn't open %s as something using UDF\n",
psz_udf_image);
return 1;
} else {
udf_dirent_t *p_udf_root = udf_get_root(p_udf, true, 0);
udf_dirent_t *p_udf_file = NULL;
if (NULL == p_udf_root) {
fprintf(stderr, "Sorry, couldn't find / in %s\n",
psz_udf_image);
return 1;
}
p_udf_file = udf_fopen(p_udf_root, psz_udf_fname);
if (!p_udf_file) {
fprintf(stderr, "Sorry, couldn't find %s in %s\n",
psz_udf_fname, psz_udf_image);
return 2;
}
if (!(p_outfd = fopen (psz_local_fname, "wb")))
{
perror ("fopen()");
return 3;
}
{
long unsigned int i_file_length = udf_get_file_length(p_udf_file);
const unsigned int i_blocks = CEILING(i_file_length, UDF_BLOCKSIZE);
unsigned int i;
for (i = 0; i < i_blocks ; i++) {
char buf[UDF_BLOCKSIZE] = {'\0',};
ssize_t i_read = udf_read_block(p_udf_file, buf, 1);
if ( i_read < 0 ) {
fprintf(stderr, "Error reading UDF file %s at block %u\n",
psz_local_fname, i);
return 4;
}
fwrite (buf, i_read, 1, p_outfd);
if (ferror (p_outfd)) {
perror ("fwrite()");
return 5;
}
}
fflush (p_outfd);
udf_dirent_free(p_udf_root);
udf_close(p_udf);
/* Make sure the file size has the exact same byte size. Without the
truncate below, the file will a multiple of UDF_BLOCKSIZE.
*/
if (ftruncate (fileno (p_outfd), i_file_length))
perror ("ftruncate()");
printf("Extraction of file '%s' from %s successful.\n",
psz_local_fname, psz_udf_image);
return 0;
}
}
}

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:
*/

Some files were not shown because too many files have changed in this diff Show More