libcdio  0.82
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  ====================================================*/
00677   void iso9660_set_dtime (const struct tm *tm, 
00678                           /*out*/ iso9660_dtime_t *idr_date);
00679 
00680 
00684   void iso9660_set_ltime (const struct tm *_tm, 
00685                           /*out*/ iso9660_ltime_t *p_pvd_date);
00686   
00695   bool iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool b_localtime,
00696                           /*out*/ struct tm *tm);
00697   
00698   
00703   bool iso9660_get_ltime (const iso9660_ltime_t *p_ldate, 
00704                           /*out*/ struct tm *p_tm);
00705   
00706   /*====================================================
00707     Character Classification and String Manipulation
00708     ====================================================*/
00714   bool iso9660_is_dchar (int c);
00715   
00721   bool iso9660_is_achar (int c);
00722   
00734   int iso9660_name_translate(const char *psz_oldname, 
00735                              /*out*/ char *psz_newname);
00736   
00752   int iso9660_name_translate_ext(const char *psz_oldname, char *psz_newname, 
00753                                  uint8_t i_joliet_level);
00754   
00766   char *iso9660_strncpy_pad(char dst[], const char src[], size_t len, 
00767                             enum strncpy_pad_check _check);
00768   
00769   /*=====================================================================
00770     File and Directory Names 
00771     ======================================================================*/
00772   
00783   bool iso9660_dirname_valid_p (const char psz_path[]);
00784   
00791   char *iso9660_pathname_isofy (const char psz_path[], uint16_t i_version);
00792   
00804   bool iso9660_pathname_valid_p (const char psz_path[]);
00805 
00806 /*=====================================================================
00807   directory tree 
00808 ======================================================================*/
00809 
00810 void
00811 iso9660_dir_init_new (void *dir, uint32_t self, uint32_t ssize, 
00812                       uint32_t parent, uint32_t psize, 
00813                       const time_t *dir_time);
00814 
00815 void
00816 iso9660_dir_init_new_su (void *dir, uint32_t self, uint32_t ssize, 
00817                          const void *ssu_data, unsigned int ssu_size, 
00818                          uint32_t parent, uint32_t psize, 
00819                          const void *psu_data, unsigned int psu_size,
00820                          const time_t *dir_time);
00821 
00822 void
00823 iso9660_dir_add_entry_su (void *dir, const char filename[], uint32_t extent,
00824                           uint32_t size, uint8_t file_flags, 
00825                           const void *su_data,
00826                           unsigned int su_size, const time_t *entry_time);
00827 
00828 unsigned int 
00829 iso9660_dir_calc_record_size (unsigned int namelen, unsigned int su_len);
00830 
00838 #define iso9660_fs_find_lsn  iso9660_find_fs_lsn 
00839 iso9660_stat_t *iso9660_fs_find_lsn(CdIo_t *p_cdio, lsn_t i_lsn);
00840 
00841 
00849 iso9660_stat_t *iso9660_fs_find_lsn_with_path(CdIo_t *p_cdio, lsn_t i_lsn,
00850                                               /*out*/ char **ppsz_path);
00851 
00859 iso9660_stat_t *iso9660_ifs_find_lsn(iso9660_t *p_iso, lsn_t i_lsn);
00860 
00861 
00876 iso9660_stat_t *iso9660_ifs_find_lsn_with_path(iso9660_t *p_iso, 
00877                                                lsn_t i_lsn,
00878                                                /*out*/ char **ppsz_path);
00879 
00880 
00899 iso9660_stat_t *iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[]);
00900   
00901 
00909 iso9660_stat_t *iso9660_fs_stat_translate (CdIo_t *p_cdio, 
00910                                            const char psz_path[], 
00911                                            bool b_mode2);
00912 
00916 iso9660_stat_t *iso9660_ifs_stat (iso9660_t *p_iso, const char psz_path[]);
00917 
00918 
00923 iso9660_stat_t *iso9660_ifs_stat_translate (iso9660_t *p_iso, 
00924                                             const char psz_path[]);
00925 
00932 CdioList_t * iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[], 
00933                                  bool b_mode2);
00934 
00939 CdioList_t * iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[]);
00940 
00945 char * iso9660_get_application_id(iso9660_pvd_t *p_pvd);
00946   
00951 bool iso9660_ifs_get_application_id(iso9660_t *p_iso,
00952                                     /*out*/ cdio_utf8_t **p_psz_app_id);
00953 
00957 uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso);
00958 
00959 uint8_t iso9660_get_dir_len(const iso9660_dir_t *p_idr);
00960 
00961 #if FIXME
00962 uint8_t iso9660_get_dir_size(const iso9660_dir_t *p_idr);
00963 
00964 lsn_t iso9660_get_dir_extent(const iso9660_dir_t *p_idr);
00965 #endif
00966 
00973   char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir);
00974   
00978   mode_t iso9660_get_posix_filemode(const iso9660_stat_t *p_iso_dirent);
00979 
00984   char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd);
00985   
00990   bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso,
00991                                    /*out*/ cdio_utf8_t **p_psz_preparer_id);
00992   
00997   char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd);
00998   
01003   bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso,
01004                                     /*out*/ cdio_utf8_t **p_psz_publisher_id);
01005   
01006   uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd);
01007   
01008   const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd);
01009   
01010   int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd);
01011   
01012   int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ;
01013   
01017   int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ;
01018   
01023   char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd);
01024   
01029   bool iso9660_ifs_get_system_id(iso9660_t *p_iso,
01030                                  /*out*/ cdio_utf8_t **p_psz_system_id);
01031   
01032   
01036   lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd);
01037   
01042   char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd);
01043   
01048   bool iso9660_ifs_get_volume_id(iso9660_t *p_iso,
01049                                  /*out*/ cdio_utf8_t **p_psz_volume_id);
01050   
01055   char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd);
01056   
01061   bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso,
01062                                     /*out*/ cdio_utf8_t **p_psz_volumeset_id);
01063   
01064   /* pathtable */
01065   
01067   void iso9660_pathtable_init (void *pt);
01068   
01069   unsigned int iso9660_pathtable_get_size (const void *pt);
01070   
01071   uint16_t iso9660_pathtable_l_add_entry (void *pt, const char name[], 
01072                                           uint32_t extent, uint16_t parent);
01073   
01074   uint16_t iso9660_pathtable_m_add_entry (void *pt, const char name[], 
01075                                           uint32_t extent, uint16_t parent);
01076   
01081   void iso9660_set_pvd (void *pd, const char volume_id[], 
01082                         const char application_id[], 
01083                         const char publisher_id[], const char preparer_id[],
01084                         uint32_t iso_size, const void *root_dir, 
01085                         uint32_t path_table_l_extent, 
01086                         uint32_t path_table_m_extent,
01087                         uint32_t path_table_size, const time_t *pvd_time);
01088 
01089   void iso9660_set_evd (void *pd);
01090 
01094   bool iso9660_ifs_is_xa (const iso9660_t * p_iso);
01095 
01096 
01097 #ifndef DO_NOT_WANT_COMPATIBILITY
01098 
01099 #define iso9660_isdchar       iso9660_is_dchar
01100 #define iso9660_isachar       iso9660_is_achar
01101 #endif /*DO_NOT_WANT_COMPATIBILITY*/
01102 
01103 #ifdef __cplusplus
01104 }
01105 #endif /* __cplusplus */
01106 
01107 #undef ISODCL
01108 #endif /* __CDIO_ISO9660_H__ */
01109 
01110 /* 
01111  * Local variables:
01112  *  c-file-style: "gnu"
01113  *  tab-width: 8
01114  *  indent-tabs-mode: nil
01115  * End:
01116  */

Generated for libcdio by doxygen 1.7.6.1