diff --git a/example/C++/device.cpp b/example/C++/device.cpp index eb1d5789..f4b2af7d 100644 --- a/example/C++/device.cpp +++ b/example/C++/device.cpp @@ -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 + Copyright (C) 2003, 2004, 2005, 2006 Rocky Bernstein 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 @@ -18,8 +18,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Simple program to show drivers installed and what the default - CD-ROM drive is. */ +/* 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 diff --git a/include/cdio++/cdio.hpp b/include/cdio++/cdio.hpp index 3669e7ee..ec3bb7e6 100644 --- a/include/cdio++/cdio.hpp +++ b/include/cdio++/cdio.hpp @@ -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 @@ -174,9 +174,9 @@ class CdioDevice { public: - CdioDevice(CdIo_t *p = (CdIo_t *) NULL) + CdioDevice() { - p_cdio=p; + p_cdio = (CdIo_t *) NULL; }; ~CdioDevice() diff --git a/include/cdio++/device.hpp b/include/cdio++/device.hpp index 863eda40..a377180b 100644 --- a/include/cdio++/device.hpp +++ b/include/cdio++/device.hpp @@ -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 @@ -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); - p_cdio = cdio_open_am(psz_source, driver_id, psz_access_mode); + 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 ; } diff --git a/include/cdio++/iso9660.hpp b/include/cdio++/iso9660.hpp new file mode 100644 index 00000000..b948ec63 --- /dev/null +++ b/include/cdio++/iso9660.hpp @@ -0,0 +1,142 @@ +/* -*- C++ -*- + $Id: iso9660.hpp,v 1.1 2006/03/05 06:52:15 rocky Exp $ + + Copyright (C) 2006 Rocky Bernstein + + 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 + +/** 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__ */ diff --git a/include/cdio/iso9660.h b/include/cdio/iso9660.h index e77c1509..adb268b4 100644 --- a/include/cdio/iso9660.h +++ b/include/cdio/iso9660.h @@ -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 Copyright (C) 2003, 2004, 2005, 2006 Rocky Bernstein @@ -532,84 +532,93 @@ extern enum iso_extension_enum_s { /** This is an opaque structure. */ typedef struct _iso9660_s iso9660_t; -/*! - 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 */); + /*! 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 allowing various ISO 9660 - extensions. Maybe in the future we will have a mode. NULL is - returned on error. -*/ + + /*! + 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 "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.) -/*! - 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). + 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 -*/ + Maybe in the future we will have a mode. NULL is returned on error. + + @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 -*/ + /*! + 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_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. -*/ + /*! + 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. -*/ + /*! + 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. -*/ + + /*! + 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. -*/ + + /*! + 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); - + /*! Read the Super block of an ISO 9660 image. This is the Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume @@ -617,12 +626,12 @@ 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. -*/ + + /*! + 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,130 +646,130 @@ 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. */ + /*! + 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. -*/ + + /*! + 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. -*/ + + + /*! + 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); - -/*! - 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); - -/*! - 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 - or .;1's and turn the other ;'s into version numbers. - - @param psz_oldname the ISO-9660 filename to be translated. - @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, - /*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 - interpretation. Remove trailing ;1's or .;1's and turn the other - ;'s into version numbers. - - @param psz_oldname the ISO-9660 filename to be translated. - @param psz_newname returned string. The caller allocates this and - it should be at least the size of psz_oldname. - @param i_joliet_level 0 if not using Joliet Extension. Otherwise the - 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, - 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. - - src can also be scanned to see if it contains only ACHARs, DCHARs, - 7-bit ASCII chars depending on the enumeration _check. - - 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, - 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 (/), - dot (.) or null byte, should be less than 37 characters long, - have no more than 8 characters in a directory component - which is separated by a /, and consist of only DCHARs. - - True is returned if psz_path is valid. - */ -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); - -/*! - Check that psz_path is a valid ISO-9660 pathname. - - A valid pathname contains a valid directory name, if one appears and - the filename portion should be no more than 8 characters for the - file prefix and 3 characters in the extension (or portion after a - dot). There should be exactly one dot somewhere in the filename - portion and the filename should be composed of only DCHARs. + /*==================================================== + 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); - True is returned if psz_path is valid. - */ -bool iso9660_pathname_valid_p (const char psz_path[]); + /*! + 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); + + /*! + 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 + or .;1's and turn the other ;'s into version numbers. + + @param psz_oldname the ISO-9660 filename to be translated. + @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, + /*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 + interpretation. Remove trailing ;1's or .;1's and turn the other + ;'s into version numbers. + + @param psz_oldname the ISO-9660 filename to be translated. + @param psz_newname returned string. The caller allocates this and + it should be at least the size of psz_oldname. + @param i_joliet_level 0 if not using Joliet Extension. Otherwise the + 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, + 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. + + src can also be scanned to see if it contains only ACHARs, DCHARs, + 7-bit ASCII chars depending on the enumeration _check. + + 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, + 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 (/), + dot (.) or null byte, should be less than 37 characters long, + have no more than 8 characters in a directory component + which is separated by a /, and consist of only DCHARs. + + True is returned if psz_path is valid. + */ + 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); + + /*! + Check that psz_path is a valid ISO-9660 pathname. + + A valid pathname contains a valid directory name, if one appears and + the filename portion should be no more than 8 characters for the + file prefix and 3 characters in the extension (or portion after a + dot). There should be exactly one dot somewhere in the filename + portion and the filename should be composed of only DCHARs. + + True is returned if psz_path is valid. + */ + bool iso9660_pathname_valid_p (const char psz_path[]); /*===================================================================== directory tree diff --git a/lib/cdio++/Makefile.am b/lib/cdio++/Makefile.am index 0bc1848d..91978a5c 100644 --- a/lib/cdio++/Makefile.am +++ b/lib/cdio++/Makefile.am @@ -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 # @@ -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/ diff --git a/lib/cdio++/stub.cpp b/lib/cdio++/cdio_stub.cpp similarity index 100% rename from lib/cdio++/stub.cpp rename to lib/cdio++/cdio_stub.cpp diff --git a/lib/cdio++/iso9660_stub.cpp b/lib/cdio++/iso9660_stub.cpp new file mode 100644 index 00000000..51eb462a --- /dev/null +++ b/lib/cdio++/iso9660_stub.cpp @@ -0,0 +1,3 @@ +#include +#include +