diff --git a/doc/libcdio.texi b/doc/libcdio.texi index 90b6f4af..a71db6af 100644 --- a/doc/libcdio.texi +++ b/doc/libcdio.texi @@ -46,7 +46,7 @@ development.'' @titlepage @title GNU libcdio library -@subtitle $Id: libcdio.texi,v 1.48 2006/02/16 20:11:14 rocky Exp $ +@subtitle $Id: libcdio.texi,v 1.49 2006/03/06 19:39:35 rocky Exp $ @author Rocky Bernstein et al. @page @@ -2187,7 +2187,7 @@ CD-ROM device names There are a some other naming conventions. Generally if a routine name starts @code{cdio_}, e.g. @code{cdio_open}, then it is an externally visible routine in @code{libcdio}. If a name starts -@code{iso9660_}, e.g. @code{iso9660_isdchar} then it is an externally +@code{iso9660_}, e.g. @code{iso9660_is_dchar} then it is an externally visible routine in @code{libiso9660}. If a name starts @code{scsi_mmc_}, e.g. @code{scsi_mmc_get_discmode}, then it is an externally visible MMC routine. (We don't have a separate library for diff --git a/example/C++/OO/iso1.cpp b/example/C++/OO/iso1.cpp index bd559a28..206a3a27 100644 --- a/example/C++/OO/iso1.cpp +++ b/example/C++/OO/iso1.cpp @@ -1,5 +1,5 @@ /* - $Id: iso1.cpp,v 1.1 2006/03/06 04:48:38 rocky Exp $ + $Id: iso1.cpp,v 1.2 2006/03/06 19:39:35 rocky Exp $ Copyright (C) 2006 Rocky Bernstein @@ -67,7 +67,7 @@ int main(int argc, const char *argv[]) { - list < ISO9660::Stat > entlist; + list < ISO9660::Stat *> stat_list; ISO9660::IFS *p_iso = new ISO9660::IFS; char const *psz_fname; const char *psz_path="/"; @@ -94,25 +94,23 @@ main(int argc, const char *argv[]) print_vd_info("Volume Set ", get_volumeset_id); } -#if 0 - entlist = p_iso->readdir (psz_path); - - /* Iterate over the list of nodes that iso9660_ifs_readdir gives */ - + if (p_iso->readdir (psz_path, stat_list)) { - ISO9660::Stat *p_stat; - for(p_stat=entlist.begin(); p_stat != entlist.end(); ++p_stat) + /* Iterate over the list of files. */ + list ::iterator i; + for(i=stat_list.begin(); i != stat_list.end(); ++i) { char filename[4096]; - p_stat->iso9660_name_translate(p_statbuf->filename, filename); + ISO9660::Stat *p_s = *i; + iso9660_name_translate(p_s->p_stat->filename, filename); printf ("%s [LSN %6d] %8u %s%s\n", - 2 == p_statbuf->type ? "d" : "-", - p_statbuf->lsn, p_statbuf->size, psz_path, filename); + 2 == p_s->p_stat->type ? "d" : "-", + p_s->p_stat->lsn, p_s->p_stat->size, psz_path, filename); + delete(p_s); } - delete(stat); + stat_list.clear(); } -#endif delete(p_iso); return 0; diff --git a/include/cdio++/iso9660.hpp b/include/cdio++/iso9660.hpp index 205b3486..41f5d196 100644 --- a/include/cdio++/iso9660.hpp +++ b/include/cdio++/iso9660.hpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - $Id: iso9660.hpp,v 1.4 2006/03/06 04:48:38 rocky Exp $ + $Id: iso9660.hpp,v 1.5 2006/03/06 19:39:35 rocky Exp $ Copyright (C) 2006 Rocky Bernstein @@ -39,6 +39,24 @@ class ISO9660 public: + /*! + 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 name_translate(const char *psz_oldname, + /*out*/ char *psz_newname) + { + return iso9660_name_translate(psz_oldname, psz_newname); + } + + class Stat { public: @@ -377,19 +395,23 @@ public: pointers for the files inside that directory. The caller must free the returned result. */ - list< ISO9660::Stat *> readdir (const char psz_path[]) + bool + readdir (const char psz_path[], list< ISO9660::Stat *>& stat_list) { CdioList_t *p_stat_list = iso9660_ifs_readdir (p_iso9660, psz_path); - CdioListNode_t *p_entnode; - list< ISO9660::Stat *> stat_list; - _CDIO_LIST_FOREACH (p_entnode, p_stat_list) { - iso9660_stat_t *p_statbuf = - (iso9660_stat_t *) _cdio_list_node_data (p_entnode); - stat_list.push_back(new ISO9660::Stat(p_statbuf)); - } - _cdio_list_free (p_stat_list, false); - return stat_list; + 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_list.push_back(new ISO9660::Stat(p_statbuf)); + } + _cdio_list_free (p_stat_list, false); + return true; + } else { + return false; + } } /*! diff --git a/include/cdio/iso9660.h b/include/cdio/iso9660.h index e6264c60..d9f4a522 100644 --- a/include/cdio/iso9660.h +++ b/include/cdio/iso9660.h @@ -1,5 +1,5 @@ /* - $Id: iso9660.h,v 1.85 2006/03/05 08:31:03 rocky Exp $ + $Id: iso9660.h,v 1.86 2006/03/06 19:39:35 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005, 2006 Rocky Bernstein @@ -679,14 +679,14 @@ typedef struct _iso9660_s iso9660_t; 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_is_dchar (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_is_achar (int c); /*! Convert an ISO-9660 file name which is in the format usually stored @@ -1012,6 +1012,12 @@ lsn_t iso9660_get_dir_extent(const iso9660_dir_t *p_idr); bool iso9660_ifs_is_xa (const iso9660_t * p_iso); +#ifndef DO_NOT_WANT_PARANOIA_COMPATIBILITY +/** For compatibility with good ol' paranoia */ +#define iso9660_isdchar iso9660_is_dchar +#define iso9660_isachar iso9660_is_achar +#endif /*DO_NOT_WANT_PARANOIA_COMPATIBILITY*/ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lib/iso9660/iso9660.c b/lib/iso9660/iso9660.c index 0da07121..6ca0eb0e 100644 --- a/lib/iso9660/iso9660.c +++ b/lib/iso9660/iso9660.c @@ -1,5 +1,5 @@ /* - $Id: iso9660.c,v 1.19 2006/03/02 18:59:13 rocky Exp $ + $Id: iso9660.c,v 1.20 2006/03/06 19:39:35 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005, 2006 Rocky Bernstein @@ -51,7 +51,7 @@ const char ISO_STANDARD_ID[] = {'C', 'D', '0', '0', '1'}; #include #endif -static const char _rcsid[] = "$Id: iso9660.c,v 1.19 2006/03/02 18:59:13 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660.c,v 1.20 2006/03/06 19:39:35 rocky Exp $"; /* Variables to hold debugger-helping enumerations */ enum iso_enum1_s iso_enums1; @@ -388,7 +388,7 @@ iso9660_strncpy_pad(char dst[], const char src[], size_t len, case ISO9660_ACHARS: for (idx = 0; src[idx]; idx++) - if (!iso9660_isachar (src[idx])) + if (!iso9660_is_achar (src[idx])) { cdio_warn ("string '%s' fails a-character constraint (pos = %d)", src, idx); @@ -398,7 +398,7 @@ iso9660_strncpy_pad(char dst[], const char src[], size_t len, case ISO9660_DCHARS: for (idx = 0; src[idx]; idx++) - if (!iso9660_isdchar (src[idx])) + if (!iso9660_is_dchar (src[idx])) { cdio_warn ("string '%s' fails d-character constraint (pos = %d)", src, idx); @@ -429,7 +429,7 @@ iso9660_strncpy_pad(char dst[], const char src[], size_t len, underscore. */ bool -iso9660_isdchar (int c) +iso9660_is_dchar (int c) { if (!IN (c, 0x30, 0x5f) || IN (c, 0x3a, 0x40) @@ -446,7 +446,7 @@ iso9660_isdchar (int c) symbol. */ bool -iso9660_isachar (int c) +iso9660_is_achar (int c) { if (!IN (c, 0x20, 0x5f) || IN (c, 0x23, 0x24) @@ -874,7 +874,7 @@ iso9660_dirname_valid_p (const char pathname[]) len = 0; for (; *p; p++) - if (iso9660_isdchar (*p)) + if (iso9660_is_dchar (*p)) { len++; if (len > 8) @@ -940,7 +940,7 @@ iso9660_pathname_valid_p (const char pathname[]) int dots = 0; for (; *p; p++) - if (iso9660_isdchar (*p)) + if (iso9660_is_dchar (*p)) { len++; if (dots == 0 ? len > 8 : len > 3) diff --git a/lib/iso9660/libiso9660.sym b/lib/iso9660/libiso9660.sym index b48471a3..ee319acd 100644 --- a/lib/iso9660/libiso9660.sym +++ b/lib/iso9660/libiso9660.sym @@ -53,8 +53,8 @@ iso9660_ifs_read_superblock iso9660_ifs_readdir iso9660_ifs_stat iso9660_ifs_stat_translate -iso9660_isachar -iso9660_isdchar +iso9660_is_achar +iso9660_is_dchar iso9660_iso_seek_read iso9660_name_translate iso9660_name_translate_ext diff --git a/test/testischar.c b/test/testischar.c index 718ef095..2826d7cd 100644 --- a/test/testischar.c +++ b/test/testischar.c @@ -1,5 +1,5 @@ /* - $Id: testischar.c,v 1.1 2003/08/17 05:31:19 rocky Exp $ + $Id: testischar.c,v 1.2 2006/03/06 19:39:35 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel @@ -52,7 +52,7 @@ main (int argc, const char *argv[]) { int c = (j << 4) + i; - printf (" %c", iso9660_isdchar (c) ? c : ' '); + printf (" %c", iso9660_is_dchar (c) ? c : ' '); } printf (" |"); diff --git a/test/testiso9660.c b/test/testiso9660.c index 331483dd..8e483ef6 100644 --- a/test/testiso9660.c +++ b/test/testiso9660.c @@ -1,5 +1,5 @@ /* - $Id: testiso9660.c,v 1.7 2006/02/25 12:10:53 rocky Exp $ + $Id: testiso9660.c,v 1.8 2006/03/06 19:39:35 rocky Exp $ Copyright (C) 2003, 2006 Rocky Bernstein @@ -51,12 +51,12 @@ main (int argc, const char *argv[]) *********************************************/ for (c='A'; c<='Z'; c++ ) { - if (!iso9660_isdchar(c)) { - printf("Failed iso9660_isdchar test on %c\n", c); + if (!iso9660_is_dchar(c)) { + printf("Failed iso9660_is_dchar test on %c\n", c); i_bad++; } - if (!iso9660_isachar(c)) { - printf("Failed iso9660_isachar test on %c\n", c); + if (!iso9660_is_achar(c)) { + printf("Failed iso9660_is_achar test on %c\n", c); i_bad++; } } @@ -64,12 +64,12 @@ main (int argc, const char *argv[]) if (i_bad) return i_bad; for (c='0'; c<='9'; c++ ) { - if (!iso9660_isdchar(c)) { - printf("Failed iso9660_isdchar test on %c\n", c); + if (!iso9660_is_dchar(c)) { + printf("Failed iso9660_is_dchar test on %c\n", c); i_bad++; } - if (!iso9660_isachar(c)) { - printf("Failed iso9660_isachar test on %c\n", c); + if (!iso9660_is_achar(c)) { + printf("Failed iso9660_is_achar test on %c\n", c); i_bad++; } } @@ -78,12 +78,12 @@ main (int argc, const char *argv[]) for (i=0; i<=13; i++ ) { c=achars[i]; - if (iso9660_isdchar(c)) { - printf("Should not pass iso9660_isdchar test on %c\n", c); + if (iso9660_is_dchar(c)) { + printf("Should not pass iso9660_is_dchar test on %c\n", c); i_bad++; } - if (!iso9660_isachar(c)) { - printf("Failed iso9660_isachar test on symbol %c\n", c); + if (!iso9660_is_achar(c)) { + printf("Failed iso9660_is_achar test on symbol %c\n", c); i_bad++; } }