lib/cdio++/Makeifle.am iso9660.hpp iso9660_stub.cpp: start C++ libiso9660 library

iso9660.h: documentation changes.
device.hpp: reduce number of methods

stub.cpp->cdio_stub.cpp
This commit is contained in:
rocky
2006-03-05 06:52:15 +00:00
parent 3c41003124
commit 66d6e093aa
8 changed files with 360 additions and 207 deletions

View File

@@ -1,7 +1,7 @@
/*
$Id: device.cpp,v 1.1 2005/07/15 21:38:57 rocky Exp $
$Id: device.cpp,v 1.2 2006/03/05 06:52:15 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 2003, 2004, 2005, 2006 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
@@ -19,7 +19,9 @@
*/
/* Simple program to show drivers installed and what the default
CD-ROM drive is. */
CD-ROM drive is. See also corresponding C program of a similar
name. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

View File

@@ -1,5 +1,5 @@
/* -*- C++ -*-
$Id: cdio.hpp,v 1.8 2006/02/02 04:37:29 rocky Exp $
$Id: cdio.hpp,v 1.9 2006/03/05 06:52:15 rocky Exp $
Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
@@ -174,9 +174,9 @@ class CdioDevice
{
public:
CdioDevice(CdIo_t *p = (CdIo_t *) NULL)
CdioDevice()
{
p_cdio=p;
p_cdio = (CdIo_t *) NULL;
};
~CdioDevice()

View File

@@ -1,5 +1,5 @@
/* -*- C++ -*-
$Id: device.hpp,v 1.5 2006/01/25 07:21:52 rocky Exp $
$Id: device.hpp,v 1.6 2006/03/05 06:52:15 rocky Exp $
Copyright (C) 2005, 2006 Rocky Bernstein <rocky@panix.com>
@@ -195,7 +195,7 @@ haveATAPI ()
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".
object was previously opened it is closed first.
@return true if open succeeded or false if error.
@@ -208,21 +208,6 @@ open(const char *psz_source)
return NULL != p_cdio ;
}
/*!
Sets up to read from the device specified by psz_source and
driver_id. 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)
{
if (p_cdio) cdio_destroy(p_cdio);
p_cdio = cdio_open(psz_source, driver_id);
return NULL != p_cdio ;
}
/*!
Sets up to read from the device specified by psz_source and access
@@ -233,10 +218,13 @@ open (const char *psz_source, driver_id_t driver_id)
*/
bool
open (const char *psz_source, driver_id_t driver_id,
const char *psz_access_mode)
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 ;
}

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

@@ -0,0 +1,142 @@
/* -*- C++ -*-
$Id: iso9660.hpp,v 1.1 2006/03/05 06:52:15 rocky Exp $
Copyright (C) 2006 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 2 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, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** \file iso966o.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>
/** ISO 9660 class.
*/
class ISO9660
{
public:
class IFS
{
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()
{
iso9660_close(p_iso9660);
p_iso9660 = (iso9660_t *) NULL;
return true;
};
/*! 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)
{
p_iso9660 = iso9660_open_fuzzy_ext(psz_path, iso_extension_mask, i_fuzz);
//return p_iso9660 != (iso9660_t *) NULL;
return true;
};
/*!
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.
*/
bool
fuzzy_read_superblock (iso_extension_mask_t iso_extension_mask=
ISO_EXTENSION_NONE,
uint16_t i_fuzz=20)
{
return iso9660_ifs_fuzzy_read_superblock (p_iso9660, iso_extension_mask,
i_fuzz);
};
/*!
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);
};
private:
iso9660_t *p_iso9660;
};
};
#endif /* __ISO9660_HPP__ */

View File

@@ -1,5 +1,5 @@
/*
$Id: iso9660.h,v 1.83 2006/03/02 18:59:13 rocky Exp $
$Id: iso9660.h,v 1.84 2006/03/05 06:52:15 rocky Exp $
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003, 2004, 2005, 2006 Rocky Bernstein <rocky@panix.com>
@@ -532,81 +532,90 @@ extern enum iso_extension_enum_s {
/** This is an opaque structure. */
typedef struct _iso9660_s iso9660_t;
/*!
/*! 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 iso9660_close (iso9660_t * p_iso);
/*!
Open an ISO 9660 image for reading. Maybe in the future we will have
a mode. NULL is returned on error.
*/
*/
iso9660_t *iso9660_open (const char *psz_path /*flags, mode */);
/*!
/*!
Open an ISO 9660 image for reading allowing various ISO 9660
extensions. Maybe in the future we will have a mode. NULL is
returned on error.
*/
@see iso9660_open_fuzzy
*/
iso9660_t *iso9660_open_ext (const char *psz_path,
iso_extension_mask_t iso_extension_mask);
/*!
Open an ISO 9660 image for reading with some tolerence for positioning
of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set
the eventual offset to adjust by (as long as that is <= i_fuzz).
/*! 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.)
Some tolerence allowed for positioning the ISO 9660 image. We scan
for STANDARD_ID and use that to set the eventual offset to adjust
by (as long as that is <= i_fuzz).
Maybe in the future we will have a mode. NULL is returned on error.
@see iso9660_open
*/
@see iso9660_open, @see iso9660_fuzzy_ext
*/
iso9660_t *iso9660_open_fuzzy (const char *psz_path /*flags, mode */,
uint16_t i_fuzz);
/*!
/*!
Open an ISO 9660 image for reading with some tolerence for positioning
of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set
the eventual offset to adjust by (as long as that is <= i_fuzz).
Maybe in the future we will have a mode. NULL is returned on error.
@see iso9660_open
*/
@see iso9660_open_ext @see iso9660_open_fuzzy
*/
iso9660_t *iso9660_open_fuzzy_ext (const char *psz_path,
iso_extension_mask_t iso_extension_mask,
uint16_t i_fuzz
/*flags, mode */);
/*!
/*!
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.
*/
*/
bool iso9660_ifs_fuzzy_read_superblock (iso9660_t *p_iso,
iso_extension_mask_t iso_extension_mask,
uint16_t i_fuzz);
/*!
Close previously opened ISO 9660 image.
True is unconditionally returned. If there was an error false would
be returned.
*/
bool iso9660_close (iso9660_t * p_iso);
/*!
/*!
Seek to a position and then read n bytes. Size read is returned.
*/
*/
long int iso9660_iso_seek_read (const iso9660_t *p_iso, void *ptr,
lsn_t start, long int i_size);
/*!
/*!
Read the Primary Volume Descriptor for a CD.
True is returned if read, and false if there was an error.
*/
*/
bool iso9660_fs_read_pvd ( const CdIo_t *p_cdio,
/*out*/ iso9660_pvd_t *p_pvd );
/*!
/*!
Read the Primary Volume Descriptor for an ISO 9660 image.
True is returned if read, and false if there was an error.
*/
*/
bool iso9660_ifs_read_pvd (const iso9660_t *p_iso,
/*out*/ iso9660_pvd_t *p_pvd);
@@ -618,11 +627,11 @@ typedef struct _iso9660_s iso9660_t;
bool iso9660_fs_read_superblock (CdIo_t *p_cdio,
iso_extension_mask_t iso_extension_mask);
/*!
/*!
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 iso9660_ifs_read_superblock (iso9660_t *p_iso,
iso_extension_mask_t iso_extension_mask);
@@ -637,49 +646,49 @@ typedef struct _iso9660_s iso9660_t;
/*out*/ iso9660_dtime_t *idr_date);
/*!
/*!
Set "long" time in format used in ISO 9660 primary volume descriptor
from a Unix time structure. */
void iso9660_set_ltime (const struct tm *_tm,
/*out*/ iso9660_ltime_t *p_pvd_date);
/*!
/*!
Get Unix time structure from format use in an ISO 9660 directory index
record. Even though tm_wday and tm_yday fields are not explicitly in
idr_date, they are calculated from the other fields.
If tm is to reflect the localtime, set "use_localtime" true, otherwise
tm will reported in GMT.
*/
*/
bool iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool use_localtime,
/*out*/ struct tm *tm);
/*!
/*!
Get "long" time in format used in ISO 9660 primary volume descriptor
from a Unix time structure.
*/
*/
bool iso9660_get_ltime (const iso9660_ltime_t *p_ldate,
/*out*/ struct tm *p_tm);
/*====================================================
/*====================================================
Character Classification and String Manipulation
====================================================*/
/*!
/*!
Return true if c is a DCHAR - a character that can appear in an an
ISO-9600 level 1 directory name. These are the ASCII capital
letters A-Z, the digits 0-9 and an underscore.
*/
bool iso9660_isdchar (int c);
*/
bool iso9660_isdchar (int c);
/*!
/*!
Return true if c is an ACHAR -
These are the DCHAR's plus some ASCII symbols including the space
symbol.
*/
bool iso9660_isachar (int c);
*/
bool iso9660_isachar (int c);
/*!
/*!
Convert an ISO-9660 file name which is in the format usually stored
in a ISO 9660 directory entry into what's usually listed as the
file name in a listing. Lowercase name, and remove trailing ;1's
@@ -689,11 +698,11 @@ bool iso9660_isachar (int c);
@param psz_newname returned string. The caller allocates this and
it should be at least the size of psz_oldname.
@return length of the translated string is returned.
*/
int iso9660_name_translate(const char *psz_oldname,
*/
int iso9660_name_translate(const char *psz_oldname,
/*out*/ char *psz_newname);
/*!
/*!
Convert an ISO-9660 file name which is in the format usually stored
in a ISO 9660 directory entry into what's usually listed as the
file name in a listing. Lowercase name if no Joliet Extension
@@ -707,11 +716,11 @@ int iso9660_name_translate(const char *psz_oldname,
Joliet level.
@return length of the translated string is returned. It will be no greater
than the length of psz_oldname.
*/
int iso9660_name_translate_ext(const char *psz_old, char *psz_new,
*/
int iso9660_name_translate_ext(const char *psz_old, char *psz_new,
uint8_t i_joliet_level);
/*!
/*!
Pad string src with spaces to size len and copy this to dst. If
len is less than the length of src, dst will be truncated to the
first len characters of src.
@@ -722,14 +731,14 @@ int iso9660_name_translate_ext(const char *psz_old, char *psz_new,
In addition to getting changed, dst is the return value.
Note: this string might not be NULL terminated.
*/
char *iso9660_strncpy_pad(char dst[], const char src[], size_t len,
char *iso9660_strncpy_pad(char dst[], const char src[], size_t len,
enum strncpy_pad_check _check);
/*=====================================================================
/*=====================================================================
File and Directory Names
======================================================================*/
======================================================================*/
/*!
/*!
Check that psz_path is a valid ISO-9660 directory name.
A valid directory name should not start out with a slash (/),
@@ -739,17 +748,17 @@ char *iso9660_strncpy_pad(char dst[], const char src[], size_t len,
True is returned if psz_path is valid.
*/
bool iso9660_dirname_valid_p (const char psz_path[]);
bool iso9660_dirname_valid_p (const char psz_path[]);
/*!
/*!
Take psz_path and a version number and turn that into a ISO-9660
pathname. (That's just the pathname followd by ";" and the version
number. For example, mydir/file.ext -> MYDIR/FILE.EXT;1 for version
1. The resulting ISO-9660 pathname is returned.
*/
char *iso9660_pathname_isofy (const char psz_path[], uint16_t i_version);
*/
char *iso9660_pathname_isofy (const char psz_path[], uint16_t i_version);
/*!
/*!
Check that psz_path is a valid ISO-9660 pathname.
A valid pathname contains a valid directory name, if one appears and
@@ -760,7 +769,7 @@ char *iso9660_pathname_isofy (const char psz_path[], uint16_t i_version);
True is returned if psz_path is valid.
*/
bool iso9660_pathname_valid_p (const char psz_path[]);
bool iso9660_pathname_valid_p (const char psz_path[]);
/*=====================================================================
directory tree

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.1 2005/11/10 11:11:16 rocky Exp $
# $Id: Makefile.am,v 1.2 2006/03/05 06:52:15 rocky Exp $
#
# Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
#
@@ -42,15 +42,24 @@
# public release, then set AGE to 0. A changed interface means an
# incompatibility with previous versions.
lib_LTLIBRARIES = libcdio++.la
lib_LTLIBRARIES = libiso9660pp.la libcdio++.la
libcdiopp_la_CURRENT := 0
libcdiopp_la_REVISION := 0
libcdiopp_la_AGE := 0
libcdiopp_sources = stub.cpp
libcdiopp_sources = cdio_stub.cpp
libcdio___la_SOURCES = $(libcdiopp_sources)
libcdio___la_ldflags = -version-info $(libcdiopp_la_CURRENT):$(libcdiopp_la_REVISION):$(libcdiopp_la_AGE)
libiso9660pp_la_CURRENT := 0
libiso9660pp_la_REVISION := 0
libiso9660pp_la_AGE := 0
libiso9660pp_sources = iso9660_stub.cpp
libiso9660pp_la_SOURCES = $(libiso9660pp_sources)
libiso9660pp_la_ldflags = -version-info $(libiso9660pp_la_CURRENT):$(libiso9660pp_la_REVISION):$(libiso9660pp_la_AGE)
INCLUDES = -I$(top_srcdir)/include/

View File

@@ -0,0 +1,3 @@
#include <sys/types.h>
#include <cdio++/iso9660.hpp>