iso9660.h

Go to the documentation of this file.
00001 /*
00002     $Id: iso9660.h,v 1.90 2006/03/18 02:35:07 rocky Exp $
00003 
00004     Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
00005     Copyright (C) 2003, 2004, 2005, 2006 Rocky Bernstein <rocky@panix.com>
00006 
00007     See also iso9660.h by Eric Youngdale (1993).
00008 
00009     Copyright 1993 Yggdrasil Computing, Incorporated
00010     Copyright (c) 1999,2000 J. Schilling
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00025     02110-1301 USA.
00026 */
00037 
00038 #ifndef __CDIO_ISO9660_H__
00039 #define __CDIO_ISO9660_H__
00040 
00041 #include <time.h>
00042 
00043 #include <cdio/cdio.h>
00044 #include <cdio/ds.h>
00045 #include <cdio/posix.h>
00046 
00053 typedef uint8_t  iso711_t; 
00054 typedef int8_t   iso712_t; 
00055 typedef uint16_t iso721_t; 
00056 typedef uint16_t iso722_t; 
00057 typedef uint32_t iso723_t; 
00058 typedef uint32_t iso731_t; 
00059 typedef uint32_t iso732_t; 
00060 typedef uint64_t iso733_t; 
00062 typedef char     achar_t;  
00063 typedef char     dchar_t;  
00065 #ifndef  EMPTY_ARRAY_SIZE
00066 #define EMPTY_ARRAY_SIZE 0
00067 #endif
00068 
00069 #include <cdio/types.h>
00070 #include <cdio/xa.h>
00071 
00072 #define _delta(from, to)        ((to) - (from) + 1)
00073 
00074 #define MIN_TRACK_SIZE 4*75
00075 #define MIN_ISO_SIZE MIN_TRACK_SIZE
00076 
00083 extern enum iso_enum1_s {
00084   ISO_PVD_SECTOR      =   16, 
00085   ISO_EVD_SECTOR      =   17, 
00086   LEN_ISONAME         =   31, 
00088   ISO_MAX_SYSTEM_ID   =   32, 
00090   MAX_ISONAME         =   37, 
00092   ISO_MAX_PREPARER_ID =  128, 
00094   MAX_ISOPATHNAME     =  255, 
00096   ISO_BLOCKSIZE       = 2048  
00098 } iso_enums1;
00099 
00107 extern enum iso_flag_enum_s {
00108   ISO_FILE            =   0,   
00109   ISO_EXISTENCE       =   1,   
00110   ISO_DIRECTORY       =   2,   
00111   ISO_ASSOCIATED      =   4,   
00112   ISO_RECORD          =   8,   
00113   ISO_PROTECTION      =  16,   
00114   ISO_DRESERVED1      =  32,   
00115   ISO_DRESERVED2      =  64,   
00116   ISO_MULTIEXTENT     = 128,   
00117 } iso_flag_enums;
00118 
00120 extern enum iso_vd_enum_s {
00121   ISO_VD_BOOT_RECORD   =  0,  
00122   ISO_VD_PRIMARY       =  1,  
00123   ISO_VD_SUPPLEMENTARY =  2,  
00124   ISO_VD_PARITION      =  3,  
00125   ISO_VD_END           = 255
00126 } iso_vd_enums;
00127 
00128   
00146 #define ISO_MAX_PUBLISHER_ID 128
00147 
00149 #define ISO_MAX_APPLICATION_ID 128
00150 
00152 #define ISO_MAX_VOLUME_ID 32
00153 
00155 #define ISO_MAX_VOLUMESET_ID 128
00156 
00160 extern const char ISO_STANDARD_ID[sizeof("CD001")-1];
00161 
00162 #define ISO_STANDARD_ID      "CD001" 
00163 
00164 #ifdef __cplusplus
00165 extern "C" {
00166 #endif /* __cplusplus */
00167 
00168 typedef enum strncpy_pad_check {
00169   ISO9660_NOCHECK = 0,
00170   ISO9660_7BIT,
00171   ISO9660_ACHARS,
00172   ISO9660_DCHARS
00173 } strncpy_pad_check_t;
00174 
00175 PRAGMA_BEGIN_PACKED
00176 
00182 struct  iso9660_dtime_s {
00183   iso711_t      dt_year;   
00184   iso711_t      dt_month;  
00186   iso711_t      dt_day;    
00187   iso711_t      dt_hour;   
00188   iso711_t      dt_minute; 
00189   iso711_t      dt_second; 
00190   iso712_t      dt_gmtoff; 
00192 } GNUC_PACKED;
00193 
00194 typedef struct iso9660_dtime_s  iso9660_dtime_t;
00195 
00205 struct  iso9660_ltime_s {
00206   char   lt_year        [_delta(   1,   4)];   
00209   char   lt_month       [_delta(   5,   6)];   
00213   char   lt_day         [_delta(   7,   8)];   
00214   char   lt_hour        [_delta(   9,   10)];  
00215   char   lt_minute      [_delta(  11,   12)];  
00216   char   lt_second      [_delta(  13,   14)];  
00217   char   lt_hsecond     [_delta(  15,   16)];  
00220   iso712_t lt_gmtoff;  
00224 } GNUC_PACKED;
00225 
00226 typedef struct iso9660_ltime_s  iso9660_ltime_t;
00227 typedef struct iso9660_dir_s    iso9660_dir_t;
00228 typedef struct iso9660_stat_s   iso9660_stat_t;
00229 
00230 #include <cdio/rock.h>
00231 
00246 struct iso9660_dir_s {
00247   iso711_t         length;            
00248   iso711_t         xa_length;         
00250   iso733_t         extent;            
00252   iso733_t         size;              
00255   iso9660_dtime_t  recording_time;    
00256   uint8_t          file_flags;        
00259   iso711_t         file_unit_size;    
00263   iso711_t         interleave_gap;    
00267   iso723_t volume_sequence_number;    
00272   iso711_t         filename_len;      
00273   char             filename[EMPTY_ARRAY_SIZE];
00274 } GNUC_PACKED;
00275 
00279 struct iso9660_pvd_s {
00280   iso711_t         type;                         
00281   char             id[5];                        
00283   iso711_t         version;                      
00284   char             unused1[1];                   
00285   achar_t          system_id[ISO_MAX_SYSTEM_ID]; 
00286   dchar_t          volume_id[ISO_MAX_VOLUME_ID]; 
00287   uint8_t          unused2[8];                   
00288   iso733_t         volume_space_size;            
00290   uint8_t          unused3[32];                  
00291   iso723_t         volume_set_size;              
00292   iso723_t         volume_sequence_number;       
00293   iso723_t         logical_block_size;           
00294   iso733_t         path_table_size;              
00295   iso731_t         type_l_path_table;            
00297   iso731_t         opt_type_l_path_table;        
00299   iso732_t         type_m_path_table;            
00301   iso732_t         opt_type_m_path_table;        
00303   iso9660_dir_t    root_directory_record;        
00305   char             root_directory_filename;      
00306   dchar_t          volume_set_id[ISO_MAX_VOLUMESET_ID]; 
00310   achar_t          publisher_id[ISO_MAX_PUBLISHER_ID];  
00321   achar_t          preparer_id[ISO_MAX_PREPARER_ID]; 
00332   achar_t          application_id[ISO_MAX_APPLICATION_ID]; 
00344   dchar_t          copyright_file_id[37];     
00351   dchar_t          abstract_file_id[37];      
00353   dchar_t          bibliographic_file_id[37]; 
00355   iso9660_ltime_t  creation_date;             
00358   iso9660_ltime_t  modification_date;         
00362   iso9660_ltime_t  expiration_date;           
00365   iso9660_ltime_t  effective_date;            
00369   iso711_t         file_structure_version;    
00370   uint8_t           unused4[1];                
00371   char             application_data[512];     
00373   uint8_t          unused5[653];              
00374 } GNUC_PACKED;
00375 
00376 typedef struct iso9660_pvd_s  iso9660_pvd_t;
00377 
00385 struct iso9660_svd_s {
00386   iso711_t         type;                         
00388   char             id[5];                        
00390   iso711_t         version;                      
00391   char             flags;                        
00392   achar_t          system_id[ISO_MAX_SYSTEM_ID]; 
00393   dchar_t          volume_id[ISO_MAX_VOLUME_ID]; 
00394   char             unused2[8];
00395   iso733_t         volume_space_size;            
00397   char             escape_sequences[32];         
00398   iso723_t         volume_set_size;              
00399   iso723_t         volume_sequence_number;       
00400   iso723_t         logical_block_size;           
00401   iso733_t         path_table_size;              
00402   iso731_t         type_l_path_table;            
00404   iso731_t         opt_type_l_path_table;        
00406   iso732_t         type_m_path_table;            
00408   iso732_t         opt_type_m_path_table;        
00410   iso9660_dir_t    root_directory_record;        
00412   dchar_t          volume_set_id[ISO_MAX_VOLUMESET_ID];    
00413   achar_t          publisher_id[ISO_MAX_PUBLISHER_ID];  
00424   achar_t          preparer_id[ISO_MAX_PREPARER_ID]; 
00435   achar_t          application_id[ISO_MAX_APPLICATION_ID]; 
00447   dchar_t          copyright_file_id[37];     
00454   dchar_t          abstract_file_id[37];      
00456   dchar_t          bibliographic_file_id[37]; 
00458   iso9660_ltime_t  creation_date;             
00461   iso9660_ltime_t  modification_date;         
00465   iso9660_ltime_t  expiration_date;           
00468   iso9660_ltime_t  effective_date;            
00472   iso711_t         file_structure_version;    
00473   uint8_t           unused4[1];                
00474   char             application_data[512];     
00476   uint8_t          unused5[653];              
00477 } GNUC_PACKED;
00478 
00479 typedef struct iso9660_svd_s  iso9660_svd_t;
00480 
00481 PRAGMA_END_PACKED
00482 
00492 struct iso9660_stat_s { /* big endian!! */
00493 
00494   iso_rock_statbuf_t rr;              
00496   struct tm          tm;              
00498   lsn_t              lsn;             
00499   uint32_t           size;            
00500   uint32_t           secsize;         
00501   iso9660_xa_t       xa;              
00502   enum { _STAT_FILE = 1, _STAT_DIR = 2 } type;
00503   bool               b_xa;
00504   char         filename[EMPTY_ARRAY_SIZE]; 
00505 };
00506 
00509 typedef uint8_t iso_extension_mask_t;
00510 
00516 extern enum iso_extension_enum_s {
00517   ISO_EXTENSION_JOLIET_LEVEL1 = 0x01,
00518   ISO_EXTENSION_JOLIET_LEVEL2 = 0x02,
00519   ISO_EXTENSION_JOLIET_LEVEL3 = 0x04,
00520   ISO_EXTENSION_ROCK_RIDGE    = 0x08,
00521   ISO_EXTENSION_HIGH_SIERRA   = 0x10
00522 } iso_extension_enums;
00523   
00524 
00525 #define ISO_EXTENSION_ALL           0xFF
00526 #define ISO_EXTENSION_NONE          0x00
00527 #define ISO_EXTENSION_JOLIET     \
00528   (ISO_EXTENSION_JOLIET_LEVEL1 | \
00529    ISO_EXTENSION_JOLIET_LEVEL2 | \
00530    ISO_EXTENSION_JOLIET_LEVEL3 )
00531   
00532 
00534 typedef struct _iso9660_s iso9660_t; 
00535 
00543   bool iso9660_close (iso9660_t * p_iso);
00544 
00545 
00550   iso9660_t *iso9660_open (const char *psz_path /*flags, mode */);
00551   
00559   iso9660_t *iso9660_open_ext (const char *psz_path, 
00560                                iso_extension_mask_t iso_extension_mask);
00561   
00576   iso9660_t *iso9660_open_fuzzy (const char *psz_path /*flags, mode */,
00577                                  uint16_t i_fuzz);
00578 
00588   iso9660_t *iso9660_open_fuzzy_ext (const char *psz_path,
00589                                      iso_extension_mask_t iso_extension_mask,
00590                                      uint16_t i_fuzz
00591                                      /*flags, mode */);
00592 
00599   bool iso9660_ifs_fuzzy_read_superblock (iso9660_t *p_iso, 
00600                                           iso_extension_mask_t iso_extension_mask,
00601                                           uint16_t i_fuzz);
00602   
00606   long int iso9660_iso_seek_read (const iso9660_t *p_iso, void *ptr, 
00607                                   lsn_t start, long int i_size);
00608   
00613   bool iso9660_fs_read_pvd ( const CdIo_t *p_cdio, 
00614                              /*out*/ iso9660_pvd_t *p_pvd );
00615   
00620   bool iso9660_ifs_read_pvd (const iso9660_t *p_iso, 
00621                              /*out*/ iso9660_pvd_t *p_pvd);
00622   
00628   bool iso9660_fs_read_superblock (CdIo_t *p_cdio, 
00629                                    iso_extension_mask_t iso_extension_mask);
00630   
00636   bool iso9660_ifs_read_superblock (iso9660_t *p_iso,
00637                                     iso_extension_mask_t iso_extension_mask);
00638 
00639 
00640 /*====================================================
00641   Time conversion 
00642  ====================================================*/
00646   void iso9660_set_dtime (const struct tm *tm, 
00647                           /*out*/ iso9660_dtime_t *idr_date);
00648 
00649 
00653   void iso9660_set_ltime (const struct tm *_tm, 
00654                           /*out*/ iso9660_ltime_t *p_pvd_date);
00655   
00664   bool iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool use_localtime,
00665                           /*out*/ struct tm *tm);
00666   
00667   
00672   bool iso9660_get_ltime (const iso9660_ltime_t *p_ldate, 
00673                           /*out*/ struct tm *p_tm);
00674   
00675   /*====================================================
00676     Character Classification and String Manipulation
00677     ====================================================*/
00683   bool iso9660_is_dchar (int c);
00684   
00690   bool iso9660_is_achar (int c);
00691   
00703   int iso9660_name_translate(const char *psz_oldname, 
00704                              /*out*/ char *psz_newname);
00705   
00721   int iso9660_name_translate_ext(const char *psz_oldname, char *psz_newname, 
00722                                  uint8_t i_joliet_level);
00723   
00735   char *iso9660_strncpy_pad(char dst[], const char src[], size_t len, 
00736                             enum strncpy_pad_check _check);
00737   
00738   /*=====================================================================
00739     File and Directory Names 
00740     ======================================================================*/
00741   
00752   bool iso9660_dirname_valid_p (const char psz_path[]);
00753   
00760   char *iso9660_pathname_isofy (const char psz_path[], uint16_t i_version);
00761   
00773   bool iso9660_pathname_valid_p (const char psz_path[]);
00774 
00775 /*=====================================================================
00776   directory tree 
00777 ======================================================================*/
00778 
00779 void
00780 iso9660_dir_init_new (void *dir, uint32_t self, uint32_t ssize, 
00781                       uint32_t parent, uint32_t psize, 
00782                       const time_t *dir_time);
00783 
00784 void
00785 iso9660_dir_init_new_su (void *dir, uint32_t self, uint32_t ssize, 
00786                          const void *ssu_data, unsigned int ssu_size, 
00787                          uint32_t parent, uint32_t psize, 
00788                          const void *psu_data, unsigned int psu_size,
00789                          const time_t *dir_time);
00790 
00791 void
00792 iso9660_dir_add_entry_su (void *dir, const char filename[], uint32_t extent,
00793                           uint32_t size, uint8_t file_flags, 
00794                           const void *su_data,
00795                           unsigned int su_size, const time_t *entry_time);
00796 
00797 unsigned int 
00798 iso9660_dir_calc_record_size (unsigned int namelen, unsigned int su_len);
00799 
00807 #define iso9660_fs_find_lsn  iso9660_find_fs_lsn 
00808 iso9660_stat_t *iso9660_fs_find_lsn(CdIo_t *p_cdio, lsn_t i_lsn);
00809 
00810 
00818 iso9660_stat_t *iso9660_ifs_find_lsn(iso9660_t *p_iso, lsn_t i_lsn);
00819 
00820 
00824 iso9660_stat_t *iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[]);
00825   
00826 
00834 iso9660_stat_t *iso9660_fs_stat_translate (CdIo_t *p_cdio, 
00835                                            const char psz_path[], 
00836                                            bool b_mode2);
00837 
00841 iso9660_stat_t *iso9660_ifs_stat (iso9660_t *p_iso, const char psz_path[]);
00842 
00843 
00848 iso9660_stat_t *iso9660_ifs_stat_translate (iso9660_t *p_iso, 
00849                                             const char psz_path[]);
00850 
00857 CdioList_t * iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[], 
00858                                  bool b_mode2);
00859 
00864 CdioList_t * iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[]);
00865 
00870 char * iso9660_get_application_id(iso9660_pvd_t *p_pvd);
00871   
00876 bool iso9660_ifs_get_application_id(iso9660_t *p_iso,
00877                                     /*out*/ char **p_psz_app_id);
00878 
00882 uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso);
00883 
00884 uint8_t iso9660_get_dir_len(const iso9660_dir_t *p_idr);
00885 
00886 #if FIXME
00887 uint8_t iso9660_get_dir_size(const iso9660_dir_t *p_idr);
00888 
00889 lsn_t iso9660_get_dir_extent(const iso9660_dir_t *p_idr);
00890 #endif
00891 
00897   char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir);
00898   
00902   mode_t iso9660_get_posix_filemode(const iso9660_stat_t *p_iso_dirent);
00903 
00908   char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd);
00909   
00914   bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso,
00915                                    /*out*/ char **p_psz_preparer_id);
00916   
00921   char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd);
00922   
00927   bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso,
00928                                     /*out*/ char **p_psz_publisher_id);
00929   
00930   uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd);
00931   
00932   const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd);
00933   
00934   int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd);
00935   
00936   int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ;
00937   
00941   int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ;
00942   
00947   char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd);
00948   
00953   bool iso9660_ifs_get_system_id(iso9660_t *p_iso,
00954                                  /*out*/ char **p_psz_system_id);
00955   
00956   
00960   lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd);
00961   
00966   char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd);
00967   
00972   bool iso9660_ifs_get_volume_id(iso9660_t *p_iso,
00973                                  /*out*/ char **p_psz_volume_id);
00974   
00979   char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd);
00980   
00985   bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso,
00986                                     /*out*/ char **p_psz_volumeset_id);
00987   
00988   /* pathtable */
00989   
00991   void iso9660_pathtable_init (void *pt);
00992   
00993   unsigned int iso9660_pathtable_get_size (const void *pt);
00994   
00995   uint16_t iso9660_pathtable_l_add_entry (void *pt, const char name[], 
00996                                           uint32_t extent, uint16_t parent);
00997   
00998   uint16_t iso9660_pathtable_m_add_entry (void *pt, const char name[], 
00999                                           uint32_t extent, uint16_t parent);
01000   
01005   void iso9660_set_pvd (void *pd, const char volume_id[], 
01006                         const char application_id[], 
01007                         const char publisher_id[], const char preparer_id[],
01008                         uint32_t iso_size, const void *root_dir, 
01009                         uint32_t path_table_l_extent, 
01010                         uint32_t path_table_m_extent,
01011                         uint32_t path_table_size, const time_t *pvd_time);
01012 
01013   void iso9660_set_evd (void *pd);
01014 
01018   bool iso9660_ifs_is_xa (const iso9660_t * p_iso);
01019 
01020 
01021 #ifndef DO_NOT_WANT_COMPATIBILITY
01022 
01023 #define iso9660_isdchar       iso9660_is_dchar
01024 #define iso9660_isachar       iso9660_is_achar
01025 #endif /*DO_NOT_WANT_COMPATIBILITY*/
01026 
01027 #ifdef __cplusplus
01028 }
01029 #endif /* __cplusplus */
01030 
01031 #endif /* __CDIO_ISO9660_H__ */
01032 
01033 /* 
01034  * Local variables:
01035  *  c-file-style: "gnu"
01036  *  tab-width: 8
01037  *  indent-tabs-mode: nil
01038  * End:
01039  */

Generated on Fri Sep 14 20:54:16 2007 for libcdio by  doxygen 1.5.1