libcdio  0.83
iso9660.h
Go to the documentation of this file.
00001 /*
00002     $Id: iso9660.h,v 1.102 2008/07/16 00:28:54 rocky Exp $
00003 
00004     Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
00005                   Rocky Bernstein <rocky@gnu.org>
00006     Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
00007 
00008     See also iso9660.h by Eric Youngdale (1993).
00009 
00010     Copyright 1993 Yggdrasil Computing, Incorporated
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 3 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, see <http://www.gnu.org/licenses/>.
00024 */
00035 
00036 #ifndef __CDIO_ISO9660_H__
00037 #define __CDIO_ISO9660_H__
00038 
00039 #include <time.h>
00040 
00041 #include <cdio/cdio.h>
00042 #include <cdio/ds.h>
00043 #include <cdio/posix.h>
00044 
00051 typedef uint8_t  iso711_t; 
00052 typedef int8_t   iso712_t; 
00053 typedef uint16_t iso721_t; 
00054 typedef uint16_t iso722_t; 
00055 typedef uint32_t iso723_t; 
00056 typedef uint32_t iso731_t; 
00057 typedef uint32_t iso732_t; 
00058 typedef uint64_t iso733_t; 
00060 typedef char     achar_t;  
00061 typedef char     dchar_t;  
00063 #ifndef  EMPTY_ARRAY_SIZE
00064 #define EMPTY_ARRAY_SIZE 0
00065 #endif
00066 
00067 #include <cdio/types.h>
00068 #include <cdio/xa.h>
00069 
00070 #ifdef ISODCL
00071 #undef ISODCL
00072 #endif
00073 /* This part borrowed from the bsd386 isofs */
00074 #define ISODCL(from, to)        ((to) - (from) + 1)
00075 
00076 #define MIN_TRACK_SIZE 4*75
00077 #define MIN_ISO_SIZE MIN_TRACK_SIZE
00078 
00085 extern enum iso_enum1_s {
00086   ISO_PVD_SECTOR      =   16, 
00087   ISO_EVD_SECTOR      =   17, 
00088   LEN_ISONAME         =   31, 
00090   ISO_MAX_SYSTEM_ID   =   32, 
00092   MAX_ISONAME         =   37, 
00094   ISO_MAX_PREPARER_ID =  128, 
00096   MAX_ISOPATHNAME     =  255, 
00098   ISO_BLOCKSIZE       = 2048  
00100 } iso_enums1;
00101 
00109 extern enum iso_flag_enum_s {
00110   ISO_FILE            =   0,   
00111   ISO_EXISTENCE       =   1,   
00112   ISO_DIRECTORY       =   2,   
00113   ISO_ASSOCIATED      =   4,   
00114   ISO_RECORD          =   8,   
00115   ISO_PROTECTION      =  16,   
00116   ISO_DRESERVED1      =  32,   
00117   ISO_DRESERVED2      =  64,   
00118   ISO_MULTIEXTENT     = 128,   
00119 } iso_flag_enums;
00120 
00122 extern enum iso_vd_enum_s {
00123   ISO_VD_BOOT_RECORD   =  0,  
00124   ISO_VD_PRIMARY       =  1,  
00125   ISO_VD_SUPPLEMENTARY =  2,  
00126   ISO_VD_PARITION      =  3,  
00127   ISO_VD_END           = 255
00128 } iso_vd_enums;
00129 
00130   
00150 #define ISO_MAX_PUBLISHER_ID 128
00151 
00153 #define ISO_MAX_APPLICATION_ID 128
00154 
00156 #define ISO_MAX_VOLUME_ID 32
00157 
00159 #define ISO_MAX_VOLUMESET_ID 128
00160 
00164 extern const char ISO_STANDARD_ID[sizeof("CD001")-1];
00165 
00166 #define ISO_STANDARD_ID      "CD001" 
00167 
00168 #ifdef __cplusplus
00169 extern "C" {
00170 #endif /* __cplusplus */
00171 
00172 typedef enum strncpy_pad_check {
00173   ISO9660_NOCHECK = 0,
00174   ISO9660_7BIT,
00175   ISO9660_ACHARS,
00176   ISO9660_DCHARS
00177 } strncpy_pad_check_t;
00178 
00179 PRAGMA_BEGIN_PACKED
00180 
00186 struct  iso9660_dtime_s {
00187   iso711_t      dt_year;   
00188   iso711_t      dt_month;  
00190   iso711_t      dt_day;    
00191   iso711_t      dt_hour;   
00192   iso711_t      dt_minute; 
00193   iso711_t      dt_second; 
00194   iso712_t      dt_gmtoff; 
00196 } GNUC_PACKED;
00197 
00198 typedef struct iso9660_dtime_s  iso9660_dtime_t;
00199 
00209 struct  iso9660_ltime_s {
00210   char   lt_year        [ISODCL(   1,   4)];   
00213   char   lt_month       [ISODCL(   5,   6)];   
00217   char   lt_day         [ISODCL(   7,   8)];   
00218   char   lt_hour        [ISODCL(   9,   10)];  
00219   char   lt_minute      [ISODCL(  11,   12)];  
00220   char   lt_second      [ISODCL(  13,   14)];  
00221   char   lt_hsecond     [ISODCL(  15,   16)];  
00224   iso712_t lt_gmtoff;  
00228 } GNUC_PACKED;
00229 
00230 typedef struct iso9660_ltime_s  iso9660_ltime_t;
00231 typedef struct iso9660_dir_s    iso9660_dir_t;
00232 typedef struct iso9660_stat_s   iso9660_stat_t;
00233 
00234 #include <cdio/rock.h>
00235 
00250 struct iso9660_dir_s {
00251   iso711_t         length;            
00252   iso711_t         xa_length;         
00254   iso733_t         extent;            
00256   iso733_t         size;              
00259   iso9660_dtime_t  recording_time;    
00260   uint8_t          file_flags;        
00263   iso711_t         file_unit_size;    
00267   iso711_t         interleave_gap;    
00271   iso723_t volume_sequence_number;    
00276   iso711_t         filename_len;      
00277   char             filename[EMPTY_ARRAY_SIZE];
00278 } GNUC_PACKED;
00279 
00283 struct iso9660_pvd_s {
00284   iso711_t         type;                         
00285   char             id[5];                        
00287   iso711_t         version;                      
00288   char             unused1[1];                   
00289   achar_t          system_id[ISO_MAX_SYSTEM_ID]; 
00290   dchar_t          volume_id[ISO_MAX_VOLUME_ID]; 
00291   uint8_t          unused2[8];                   
00292   iso733_t         volume_space_size;            
00294   uint8_t          unused3[32];                  
00295   iso723_t         volume_set_size;              
00296   iso723_t         volume_sequence_number;       
00297   iso723_t         logical_block_size;           
00298   iso733_t         path_table_size;              
00299   iso731_t         type_l_path_table;            
00301   iso731_t         opt_type_l_path_table;        
00303   iso732_t         type_m_path_table;            
00305   iso732_t         opt_type_m_path_table;        
00307   iso9660_dir_t    root_directory_record;        
00310   char             root_directory_filename;      
00313   dchar_t          volume_set_id[ISO_MAX_VOLUMESET_ID]; 
00317   achar_t          publisher_id[ISO_MAX_PUBLISHER_ID];  
00328   achar_t          preparer_id[ISO_MAX_PREPARER_ID]; 
00339   achar_t          application_id[ISO_MAX_APPLICATION_ID]; 
00351   dchar_t          copyright_file_id[37];     
00358   dchar_t          abstract_file_id[37];      
00360   dchar_t          bibliographic_file_id[37]; 
00362   iso9660_ltime_t  creation_date;             
00365   iso9660_ltime_t  modification_date;         
00369   iso9660_ltime_t  expiration_date;           
00372   iso9660_ltime_t  effective_date;            
00376   iso711_t         file_structure_version;    
00377   uint8_t           unused4[1];                
00378   char             application_data[512];     
00380   uint8_t          unused5[653];              
00381 } GNUC_PACKED;
00382 
00383 typedef struct iso9660_pvd_s  iso9660_pvd_t;
00384 
00392 struct iso9660_svd_s {
00393   iso711_t         type;                         
00395   char             id[5];                        
00397   iso711_t         version;                      
00398   char             flags;                        
00399   achar_t          system_id[ISO_MAX_SYSTEM_ID]; 
00401   dchar_t          volume_id[ISO_MAX_VOLUME_ID]; 
00403   char             unused2[8];
00404   iso733_t         volume_space_size;            
00406   char             escape_sequences[32];         
00407   iso723_t         volume_set_size;              
00408   iso723_t         volume_sequence_number;       
00409   iso723_t         logical_block_size;           
00410   iso733_t         path_table_size;              
00412   iso731_t         type_l_path_table;            
00414   iso731_t         opt_type_l_path_table;        
00417   iso732_t         type_m_path_table;            
00419   iso732_t         opt_type_m_path_table;        
00422   iso9660_dir_t    root_directory_record;        
00424   char             root_directory_filename;      
00427   dchar_t          volume_set_id[ISO_MAX_VOLUMESET_ID];    
00429   achar_t          publisher_id[ISO_MAX_PUBLISHER_ID]; 
00441   achar_t          preparer_id[ISO_MAX_PREPARER_ID]; 
00453   achar_t          application_id[ISO_MAX_APPLICATION_ID]; 
00465   dchar_t          copyright_file_id[37];     
00472   dchar_t          abstract_file_id[37];      
00474   dchar_t          bibliographic_file_id[37]; 
00476   iso9660_ltime_t  creation_date;             
00479   iso9660_ltime_t  modification_date;         
00483   iso9660_ltime_t  expiration_date;           
00486   iso9660_ltime_t  effective_date;            
00490   iso711_t         file_structure_version;    
00491   uint8_t           unused4[1];                
00492   char             application_data[512];     
00494   uint8_t          unused5[653];              
00495 } GNUC_PACKED;
00496 
00497 typedef struct iso9660_svd_s  iso9660_svd_t;
00498 
00499 PRAGMA_END_PACKED
00500 
00510 struct iso9660_stat_s { /* big endian!! */
00511 
00512   iso_rock_statbuf_t rr;              
00514   struct tm          tm;              
00516   lsn_t              lsn;             
00517   uint32_t           size;            
00518   uint32_t           secsize;         
00519   iso9660_xa_t       xa;              
00520   enum { _STAT_FILE = 1, _STAT_DIR = 2 } type;
00521   bool               b_xa;
00522   char         filename[EMPTY_ARRAY_SIZE]; 
00523 };
00524 
00527 typedef uint8_t iso_extension_mask_t;
00528 
00534 extern enum iso_extension_enum_s {
00535   ISO_EXTENSION_JOLIET_LEVEL1 = 0x01,
00536   ISO_EXTENSION_JOLIET_LEVEL2 = 0x02,
00537   ISO_EXTENSION_JOLIET_LEVEL3 = 0x04,
00538   ISO_EXTENSION_ROCK_RIDGE    = 0x08,
00539   ISO_EXTENSION_HIGH_SIERRA   = 0x10
00540 } iso_extension_enums;
00541   
00542 
00543 #define ISO_EXTENSION_ALL           0xFF
00544 #define ISO_EXTENSION_NONE          0x00
00545 #define ISO_EXTENSION_JOLIET     \
00546   (ISO_EXTENSION_JOLIET_LEVEL1 | \
00547    ISO_EXTENSION_JOLIET_LEVEL2 | \
00548    ISO_EXTENSION_JOLIET_LEVEL3 )
00549   
00550 
00552 typedef struct _iso9660_s iso9660_t; 
00553 
00561   bool iso9660_close (iso9660_t * p_iso);
00562 
00563 
00568   iso9660_t *iso9660_open (const char *psz_path /*flags, mode */);
00569   
00577   iso9660_t *iso9660_open_ext (const char *psz_path, 
00578                                iso_extension_mask_t iso_extension_mask);
00579   
00594   iso9660_t *iso9660_open_fuzzy (const char *psz_path /*flags, mode */,
00595                                  uint16_t i_fuzz);
00596 
00606   iso9660_t *iso9660_open_fuzzy_ext (const char *psz_path,
00607                                      iso_extension_mask_t iso_extension_mask,
00608                                      uint16_t i_fuzz
00609                                      /*flags, mode */);
00610 
00617   bool iso9660_ifs_fuzzy_read_superblock (iso9660_t *p_iso, 
00618                                           iso_extension_mask_t iso_extension_mask,
00619                                           uint16_t i_fuzz);
00620   
00637   long int iso9660_iso_seek_read (const iso9660_t *p_iso, /*out*/ void *ptr, 
00638                                   lsn_t start, long int i_size);
00639   
00644   bool iso9660_fs_read_pvd ( const CdIo_t *p_cdio, 
00645                              /*out*/ iso9660_pvd_t *p_pvd );
00646   
00651   bool iso9660_ifs_read_pvd (const iso9660_t *p_iso, 
00652                              /*out*/ iso9660_pvd_t *p_pvd);
00653   
00659   bool iso9660_fs_read_superblock (CdIo_t *p_cdio, 
00660                                    iso_extension_mask_t iso_extension_mask);
00661   
00667   bool iso9660_ifs_read_superblock (iso9660_t *p_iso,
00668                                     iso_extension_mask_t iso_extension_mask);
00669 
00670 
00671 /*====================================================
00672   Time conversion 
00673  ====================================================*/
00674 
00679   void iso9660_set_dtime (const struct tm *tm, 
00680                           /*out*/ iso9660_dtime_t *idr_date);
00681     
00682     
00688   void iso9660_set_dtime_with_timezone (const struct tm *p_tm, 
00689                                         int timezone,
00690                                         /*out*/ iso9660_dtime_t *p_idr_date);
00691     
00695   void iso9660_set_ltime (const struct tm *_tm, 
00696                           /*out*/ iso9660_ltime_t *p_pvd_date);
00697   
00701   void iso9660_set_ltime_with_timezone (const struct tm *_tm, 
00702                                         int timezone,
00703                                         /*out*/ iso9660_ltime_t *p_pvd_date);
00704   
00713   bool iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool b_localtime,
00714                           /*out*/ struct tm *tm);
00715   
00716   
00721   bool iso9660_get_ltime (const iso9660_ltime_t *p_ldate, 
00722                           /*out*/ struct tm *p_tm);
00723   
00724   /*====================================================
00725     Character Classification and String Manipulation
00726     ====================================================*/
00732   bool iso9660_is_dchar (int c);
00733   
00739   bool iso9660_is_achar (int c);
00740   
00752   int iso9660_name_translate(const char *psz_oldname, 
00753                              /*out*/ char *psz_newname);
00754   
00770   int iso9660_name_translate_ext(const char *psz_oldname, char *psz_newname, 
00771                                  uint8_t i_joliet_level);
00772   
00784   char *iso9660_strncpy_pad(char dst[], const char src[], size_t len, 
00785                             enum strncpy_pad_check _check);
00786   
00787   /*=====================================================================
00788     File and Directory Names 
00789     ======================================================================*/
00790   
00801   bool iso9660_dirname_valid_p (const char psz_path[]);
00802   
00809   char *iso9660_pathname_isofy (const char psz_path[], uint16_t i_version);
00810   
00822   bool iso9660_pathname_valid_p (const char psz_path[]);
00823 
00824 /*=====================================================================
00825   directory tree 
00826 ======================================================================*/
00827 
00828 void
00829 iso9660_dir_init_new (void *dir, uint32_t self, uint32_t ssize, 
00830                       uint32_t parent, uint32_t psize, 
00831                       const time_t *dir_time);
00832 
00833 void
00834 iso9660_dir_init_new_su (void *dir, uint32_t self, uint32_t ssize, 
00835                          const void *ssu_data, unsigned int ssu_size, 
00836                          uint32_t parent, uint32_t psize, 
00837                          const void *psu_data, unsigned int psu_size,
00838                          const time_t *dir_time);
00839 
00840 void
00841 iso9660_dir_add_entry_su (void *dir, const char filename[], uint32_t extent,
00842                           uint32_t size, uint8_t file_flags, 
00843                           const void *su_data,
00844                           unsigned int su_size, const time_t *entry_time);
00845 
00846 unsigned int 
00847 iso9660_dir_calc_record_size (unsigned int namelen, unsigned int su_len);
00848 
00856 #define iso9660_fs_find_lsn  iso9660_find_fs_lsn 
00857 iso9660_stat_t *iso9660_fs_find_lsn(CdIo_t *p_cdio, lsn_t i_lsn);
00858 
00859 
00867 iso9660_stat_t *iso9660_fs_find_lsn_with_path(CdIo_t *p_cdio, lsn_t i_lsn,
00868                                               /*out*/ char **ppsz_path);
00869 
00877 iso9660_stat_t *iso9660_ifs_find_lsn(iso9660_t *p_iso, lsn_t i_lsn);
00878 
00879 
00894 iso9660_stat_t *iso9660_ifs_find_lsn_with_path(iso9660_t *p_iso, 
00895                                                lsn_t i_lsn,
00896                                                /*out*/ char **ppsz_path);
00897 
00898 
00917 iso9660_stat_t *iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[]);
00918   
00919 
00927 iso9660_stat_t *iso9660_fs_stat_translate (CdIo_t *p_cdio, 
00928                                            const char psz_path[], 
00929                                            bool b_mode2);
00930 
00934 iso9660_stat_t *iso9660_ifs_stat (iso9660_t *p_iso, const char psz_path[]);
00935 
00936 
00941 iso9660_stat_t *iso9660_ifs_stat_translate (iso9660_t *p_iso, 
00942                                             const char psz_path[]);
00943 
00950 CdioList_t * iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[], 
00951                                  bool b_mode2);
00952 
00957 CdioList_t * iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[]);
00958 
00963 char * iso9660_get_application_id(iso9660_pvd_t *p_pvd);
00964   
00969 bool iso9660_ifs_get_application_id(iso9660_t *p_iso,
00970                                     /*out*/ cdio_utf8_t **p_psz_app_id);
00971 
00975 uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso);
00976 
00977 uint8_t iso9660_get_dir_len(const iso9660_dir_t *p_idr);
00978 
00979 #if FIXME
00980 uint8_t iso9660_get_dir_size(const iso9660_dir_t *p_idr);
00981 
00982 lsn_t iso9660_get_dir_extent(const iso9660_dir_t *p_idr);
00983 #endif
00984 
00991   char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir);
00992   
00996   mode_t iso9660_get_posix_filemode(const iso9660_stat_t *p_iso_dirent);
00997 
01002   char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd);
01003   
01008   bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso,
01009                                    /*out*/ cdio_utf8_t **p_psz_preparer_id);
01010   
01015   char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd);
01016   
01021   bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso,
01022                                     /*out*/ cdio_utf8_t **p_psz_publisher_id);
01023   
01024   uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd);
01025   
01026   const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd);
01027   
01028   int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd);
01029   
01030   int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ;
01031   
01035   int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ;
01036   
01041   char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd);
01042   
01047   bool iso9660_ifs_get_system_id(iso9660_t *p_iso,
01048                                  /*out*/ cdio_utf8_t **p_psz_system_id);
01049   
01050   
01054   lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd);
01055   
01060   char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd);
01061   
01066   bool iso9660_ifs_get_volume_id(iso9660_t *p_iso,
01067                                  /*out*/ cdio_utf8_t **p_psz_volume_id);
01068   
01073   char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd);
01074   
01079   bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso,
01080                                     /*out*/ cdio_utf8_t **p_psz_volumeset_id);
01081   
01082   /* pathtable */
01083   
01085   void iso9660_pathtable_init (void *pt);
01086   
01087   unsigned int iso9660_pathtable_get_size (const void *pt);
01088   
01089   uint16_t iso9660_pathtable_l_add_entry (void *pt, const char name[], 
01090                                           uint32_t extent, uint16_t parent);
01091   
01092   uint16_t iso9660_pathtable_m_add_entry (void *pt, const char name[], 
01093                                           uint32_t extent, uint16_t parent);
01094   
01099   void iso9660_set_pvd (void *pd, const char volume_id[], 
01100                         const char application_id[], 
01101                         const char publisher_id[], const char preparer_id[],
01102                         uint32_t iso_size, const void *root_dir, 
01103                         uint32_t path_table_l_extent, 
01104                         uint32_t path_table_m_extent,
01105                         uint32_t path_table_size, const time_t *pvd_time);
01106 
01107   void iso9660_set_evd (void *pd);
01108 
01112   bool iso9660_ifs_is_xa (const iso9660_t * p_iso);
01113 
01114 
01115 #ifndef DO_NOT_WANT_COMPATIBILITY
01116 
01117 #define iso9660_isdchar       iso9660_is_dchar
01118 #define iso9660_isachar       iso9660_is_achar
01119 #endif /*DO_NOT_WANT_COMPATIBILITY*/
01120 
01121 #ifdef __cplusplus
01122 }
01123 #endif /* __cplusplus */
01124 
01125 #undef ISODCL
01126 #endif /* __CDIO_ISO9660_H__ */
01127 
01128 /* 
01129  * Local variables:
01130  *  c-file-style: "gnu"
01131  *  tab-width: 8
01132  *  indent-tabs-mode: nil
01133  * End:
01134  */

Generated for libcdio by doxygen 1.8.0