00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00036
00037 #ifndef __CDIO_ISO9660_H__
00038 #define __CDIO_ISO9660_H__
00039
00040 #include <time.h>
00041
00042 #include <cdio/cdio.h>
00043 #include <cdio/ds.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 #define _delta(from, to) ((to) - (from) + 1)
00071
00072 #define MIN_TRACK_SIZE 4*75
00073 #define MIN_ISO_SIZE MIN_TRACK_SIZE
00074
00080 extern enum iso_enum1_s {
00081 ISO_PVD_SECTOR = 16,
00082 ISO_EVD_SECTOR = 17,
00083 LEN_ISONAME = 31,
00085 ISO_MAX_SYSTEM_ID = 32,
00087 MAX_ISONAME = 37,
00089 ISO_MAX_PREPARER_ID = 128,
00091 MAX_ISOPATHNAME = 255,
00092 ISO_BLOCKSIZE = 2048
00093
00094 } iso_enums1;
00095
00101 extern enum iso_flag_enum_s {
00102 ISO_FILE = 0,
00103 ISO_EXISTENCE = 1,
00104 ISO_DIRECTORY = 2,
00105 ISO_ASSOCIATED = 4,
00106 ISO_RECORD = 8,
00107 ISO_PROECTION = 16,
00108 ISO_DRESERVED1 = 32,
00109 ISO_DRESERVED2 = 64,
00110 ISO_MULTIEXTENT = 128,
00111 } iso_flag_enums;
00112
00113 extern enum iso_vd_enum_s {
00114 ISO_VD_BOOT_RECORD = 0,
00115 ISO_VD_PRIMARY = 1,
00116 ISO_VD_SUPPLEMENARY = 2,
00117 ISO_VD_PARITION = 3,
00118 ISO_VD_END = 255
00119 } iso_vd_enums;
00120
00121
00140 #define LEN_ISONAME 31
00141
00143 #define MAX_ISONAME 37
00144
00146 #define MAX_ISOPATHNAME 255
00147
00149 #define ISO_MAX_PREPARER_ID 128
00150
00152 #define ISO_MAX_PUBLISHER_ID 128
00153
00155 #define ISO_MAX_APPLICATION_ID 128
00156
00158 #define ISO_MAX_SYSTEM_ID 32
00159
00161 #define ISO_MAX_VOLUME_ID 32
00162
00164 #define ISO_MAX_VOLUMESET_ID 128
00165
00167 #define ISO_FILE 0
00168 #define ISO_EXISTENCE 1
00169 #define ISO_DIRECTORY 2
00170 #define ISO_ASSOCIATED 4
00171 #define ISO_RECORD 8
00172 #define ISO_PROTECTION 16
00173 #define ISO_DRESERVED1 32
00174 #define ISO_DRESERVED2 64
00175 #define ISO_MULTIEXTENT 128
00178 #define ISO_VD_BOOT_RECORD 0
00179 #define ISO_VD_PRIMARY 1
00180 #define ISO_VD_SUPPLEMENTARY 2
00181 #define ISO_VD_PARITION 3
00182 #define ISO_VD_END 255
00183
00185 #define ISO_PVD_SECTOR 16
00186
00188 #define ISO_EVD_SECTOR 17
00189
00193 extern const char ISO_STANDARD_ID[sizeof("CD001")-1];
00194
00195 #define ISO_STANDARD_ID "CD001"
00196
00197
00199 #define ISO_BLOCKSIZE 2048
00200
00201 #ifdef __cplusplus
00202 extern "C" {
00203 #endif
00204
00205 typedef enum strncpy_pad_check {
00206 ISO9660_NOCHECK = 0,
00207 ISO9660_7BIT,
00208 ISO9660_ACHARS,
00209 ISO9660_DCHARS
00210 } strncpy_pad_check_t;
00211
00212 PRAGMA_BEGIN_PACKED
00213
00219 struct iso9660_dtime_s {
00220 iso711_t dt_year;
00221 iso711_t dt_month;
00223 iso711_t dt_day;
00224 iso711_t dt_hour;
00225 iso711_t dt_minute;
00226 iso711_t dt_second;
00227 iso712_t dt_gmtoff;
00229 } GNUC_PACKED;
00230
00231 typedef struct iso9660_dtime_s iso9660_dtime_t;
00232
00242 struct iso9660_ltime_s {
00243 char lt_year [_delta( 1, 4)];
00246 char lt_month [_delta( 5, 6)];
00250 char lt_day [_delta( 7, 8)];
00251 char lt_hour [_delta( 9, 10)];
00252 char lt_minute [_delta( 11, 12)];
00253 char lt_second [_delta( 13, 14)];
00254 char lt_hsecond [_delta( 15, 16)];
00257 iso712_t lt_gmtoff;
00261 } GNUC_PACKED;
00262
00263 typedef struct iso9660_ltime_s iso9660_ltime_t;
00264 typedef struct iso9660_dir_s iso9660_dir_t;
00265 typedef struct iso9660_stat_s iso9660_stat_t;
00266
00267 typedef uint32_t posix_mode_t;
00268 typedef uint32_t posix_nlink_t;
00269 typedef uint32_t posix_uid_t;
00270 typedef uint32_t posix_gid_t;
00271
00272 #include <cdio/rock.h>
00273
00288 struct iso9660_dir_s {
00289 iso711_t length;
00290 iso711_t xa_length;
00292 iso733_t extent;
00294 iso733_t size;
00297 iso9660_dtime_t recording_time;
00298 uint8_t file_flags;
00301 iso711_t file_unit_size;
00305 iso711_t interleave_gap;
00309 iso723_t volume_sequence_number;
00314 iso711_t filename_len;
00315 char filename[EMPTY_ARRAY_SIZE];
00316 } GNUC_PACKED;
00317
00321 struct iso9660_pvd_s {
00322 iso711_t type;
00323 char id[5];
00325 iso711_t version;
00326 char unused1[1];
00327 achar_t system_id[ISO_MAX_SYSTEM_ID];
00328 dchar_t volume_id[ISO_MAX_VOLUME_ID];
00329 uint8_t unused2[8];
00330 iso733_t volume_space_size;
00332 uint8_t unused3[32];
00333 iso723_t volume_set_size;
00334 iso723_t volume_sequence_number;
00335 iso723_t logical_block_size;
00336 iso733_t path_table_size;
00337 iso731_t type_l_path_table;
00339 iso731_t opt_type_l_path_table;
00341 iso732_t type_m_path_table;
00343 iso732_t opt_type_m_path_table;
00345 iso9660_dir_t root_directory_record;
00347 char root_directory_filename;
00348 dchar_t volume_set_id[ISO_MAX_VOLUMESET_ID];
00352 achar_t publisher_id[ISO_MAX_PUBLISHER_ID];
00363 achar_t preparer_id[ISO_MAX_PREPARER_ID];
00374 achar_t application_id[ISO_MAX_APPLICATION_ID];
00386 dchar_t copyright_file_id[37];
00393 dchar_t abstract_file_id[37];
00395 dchar_t bibliographic_file_id[37];
00397 iso9660_ltime_t creation_date;
00400 iso9660_ltime_t modification_date;
00404 iso9660_ltime_t expiration_date;
00407 iso9660_ltime_t effective_date;
00411 iso711_t file_structure_version;
00412 uint8_t unused4[1];
00413 char application_data[512];
00415 uint8_t unused5[653];
00416 } GNUC_PACKED;
00417
00418 typedef struct iso9660_pvd_s iso9660_pvd_t;
00419
00427 struct iso9660_svd_s {
00428 iso711_t type;
00430 char id[5];
00432 iso711_t version;
00433 char flags;
00434 achar_t system_id[ISO_MAX_SYSTEM_ID];
00435 dchar_t volume_id[ISO_MAX_VOLUME_ID];
00436 char unused2[8];
00437 iso733_t volume_space_size;
00439 char escape_sequences[32];
00440 iso723_t volume_set_size;
00441 iso723_t volume_sequence_number;
00442 iso723_t logical_block_size;
00443 iso733_t path_table_size;
00444 iso731_t type_l_path_table;
00446 iso731_t opt_type_l_path_table;
00448 iso732_t type_m_path_table;
00450 iso732_t opt_type_m_path_table;
00452 iso9660_dir_t root_directory_record;
00454 dchar_t volume_set_id[ISO_MAX_VOLUMESET_ID];
00455 achar_t publisher_id[ISO_MAX_PUBLISHER_ID];
00466 achar_t preparer_id[ISO_MAX_PREPARER_ID];
00477 achar_t application_id[ISO_MAX_APPLICATION_ID];
00489 dchar_t copyright_file_id[37];
00496 dchar_t abstract_file_id[37];
00498 dchar_t bibliographic_file_id[37];
00500 iso9660_ltime_t creation_date;
00503 iso9660_ltime_t modification_date;
00507 iso9660_ltime_t expiration_date;
00510 iso9660_ltime_t effective_date;
00514 iso711_t file_structure_version;
00515 uint8_t unused4[1];
00516 char application_data[512];
00518 uint8_t unused5[653];
00519 } GNUC_PACKED;
00520
00521 typedef struct iso9660_svd_s iso9660_svd_t;
00522
00523 PRAGMA_END_PACKED
00524
00534 struct iso9660_stat_s {
00535
00536 iso_rock_statbuf_t rr;
00538 struct tm tm;
00540 lsn_t lsn;
00541 uint32_t size;
00542 uint32_t secsize;
00543 iso9660_xa_t xa;
00544 enum { _STAT_FILE = 1, _STAT_DIR = 2 } type;
00545 char filename[EMPTY_ARRAY_SIZE];
00546 };
00547
00550 typedef uint8_t iso_extension_mask_t;
00551
00557 extern enum iso_extension_enum_s {
00558 ISO_EXTENSION_JOLIET_LEVEL1 = 0x01,
00559 ISO_EXTENSION_JOLIET_LEVEL2 = 0x02,
00560 ISO_EXTENSION_JOLIET_LEVEL3 = 0x04,
00561 ISO_EXTENSION_ROCK_RIDGE = 0x08,
00562 ISO_EXTENSION_HIGH_SIERRA = 0x10
00563 } iso_extension_enums;
00564
00565
00566 #define ISO_EXTENSION_JOLIET_LEVEL1 0x01
00567 #define ISO_EXTENSION_JOLIET_LEVEL2 0x02
00568 #define ISO_EXTENSION_JOLIET_LEVEL3 0x04
00569 #define ISO_EXTENSION_ROCK_RIDGE 0x08
00570 #define ISO_EXTENSION_HIGH_SIERRA 0x10
00571
00572 #define ISO_EXTENSION_ALL 0xFF
00573 #define ISO_EXTENSION_NONE 0x00
00574 #define ISO_EXTENSION_JOLIET \
00575 (ISO_EXTENSION_JOLIET_LEVEL1 | \
00576 ISO_EXTENSION_JOLIET_LEVEL2 | \
00577 ISO_EXTENSION_JOLIET_LEVEL3 )
00578
00579
00581 typedef struct _iso9660_s iso9660_t;
00582
00587 iso9660_t *iso9660_open (const char *psz_path );
00588
00594 iso9660_t *iso9660_open_ext (const char *psz_path,
00595 iso_extension_mask_t iso_extension_mask);
00596
00606 iso9660_t *iso9660_open_fuzzy (const char *psz_path ,
00607 uint16_t i_fuzz);
00608
00618 iso9660_t *iso9660_open_fuzzy_ext (const char *psz_path,
00619 iso_extension_mask_t iso_extension_mask,
00620 uint16_t i_fuzz
00621 );
00622
00629 bool iso9660_ifs_fuzzy_read_superblock (iso9660_t *p_iso,
00630 iso_extension_mask_t iso_extension_mask,
00631 uint16_t i_fuzz);
00632
00638 bool iso9660_close (iso9660_t * p_iso);
00639
00640
00644 long int iso9660_iso_seek_read (const iso9660_t *p_iso, void *ptr,
00645 lsn_t start, long int i_size);
00646
00651 bool iso9660_fs_read_pvd ( const CdIo_t *p_cdio,
00652 iso9660_pvd_t *p_pvd );
00653
00658 bool iso9660_ifs_read_pvd (const iso9660_t *p_iso,
00659 iso9660_pvd_t *p_pvd);
00660
00666 bool iso9660_fs_read_superblock (CdIo_t *p_cdio,
00667 iso_extension_mask_t iso_extension_mask);
00668
00674 bool iso9660_ifs_read_superblock (iso9660_t *p_iso,
00675 iso_extension_mask_t iso_extension_mask);
00676
00677
00678
00679
00680
00684 void iso9660_set_dtime (const struct tm *tm,
00685 iso9660_dtime_t *idr_date);
00686
00687
00691 void iso9660_set_ltime (const struct tm *_tm,
00692 iso9660_ltime_t *p_pvd_date);
00693
00702 bool iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool use_localtime,
00703 struct tm *tm);
00704
00705
00710 bool iso9660_get_ltime (const iso9660_ltime_t *p_ldate,
00711 struct tm *p_tm);
00712
00713
00714
00715
00721 bool iso9660_isdchar (int c);
00722
00728 bool iso9660_isachar (int c);
00729
00738 int iso9660_name_translate(const char *psz_oldname, char *psz_newname);
00739
00748 int iso9660_name_translate_ext(const char *psz_old, char *psz_new,
00749 uint8_t i_joliet_level);
00750
00762 char *iso9660_strncpy_pad(char dst[], const char src[], size_t len,
00763 enum strncpy_pad_check _check);
00764
00765
00766
00767
00768
00779 bool iso9660_dirname_valid_p (const char psz_path[]);
00780
00787 char *iso9660_pathname_isofy (const char psz_path[], uint16_t i_version);
00788
00800 bool iso9660_pathname_valid_p (const char psz_path[]);
00801
00802
00803
00804
00805
00806 void
00807 iso9660_dir_init_new (void *dir, uint32_t self, uint32_t ssize,
00808 uint32_t parent, uint32_t psize,
00809 const time_t *dir_time);
00810
00811 void
00812 iso9660_dir_init_new_su (void *dir, uint32_t self, uint32_t ssize,
00813 const void *ssu_data, unsigned int ssu_size,
00814 uint32_t parent, uint32_t psize,
00815 const void *psu_data, unsigned int psu_size,
00816 const time_t *dir_time);
00817
00818 void
00819 iso9660_dir_add_entry_su (void *dir, const char filename[], uint32_t extent,
00820 uint32_t size, uint8_t file_flags,
00821 const void *su_data,
00822 unsigned int su_size, const time_t *entry_time);
00823
00824 unsigned int
00825 iso9660_dir_calc_record_size (unsigned int namelen, unsigned int su_len);
00826
00833 iso9660_stat_t *iso9660_find_fs_lsn(CdIo_t *p_cdio, lsn_t i_lsn);
00834
00835
00842 iso9660_stat_t *iso9660_find_ifs_lsn(const iso9660_t *p_iso, lsn_t i_lsn);
00843
00844
00848 iso9660_stat_t *iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[]);
00849
00850
00856 iso9660_stat_t *iso9660_fs_stat_translate (CdIo_t *p_cdio,
00857 const char psz_path[],
00858 bool b_mode2);
00859
00863 iso9660_stat_t *iso9660_ifs_stat (iso9660_t *p_iso, const char psz_path[]);
00864
00865
00870 iso9660_stat_t *iso9660_ifs_stat_translate (iso9660_t *p_iso,
00871 const char psz_path[]);
00872
00877 CdioList_t * iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[],
00878 bool b_mode2);
00879
00884 CdioList_t * iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[]);
00885
00890 char * iso9660_get_application_id(iso9660_pvd_t *p_pvd);
00891
00896 bool iso9660_ifs_get_application_id(iso9660_t *p_iso,
00897 char **p_psz_app_id);
00898
00902 uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso);
00903
00904 uint8_t iso9660_get_dir_len(const iso9660_dir_t *p_idr);
00905
00906 #if FIXME
00907 uint8_t iso9660_get_dir_size(const iso9660_dir_t *p_idr);
00908
00909 lsn_t iso9660_get_dir_extent(const iso9660_dir_t *p_idr);
00910 #endif
00911
00917 char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir);
00918
00923 char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd);
00924
00929 bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso,
00930 char **p_psz_preparer_id);
00931
00936 char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd);
00937
00942 bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso,
00943 char **p_psz_publisher_id);
00944
00945 uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd);
00946
00947 const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd);
00948
00949 int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd);
00950
00951 int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ;
00952
00956 int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ;
00957
00962 char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd);
00963
00968 bool iso9660_ifs_get_system_id(iso9660_t *p_iso,
00969 char **p_psz_system_id);
00970
00971
00975 lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd);
00976
00980 char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd);
00981
00986 bool iso9660_ifs_get_volume_id(iso9660_t *p_iso,
00987 char **p_psz_volume_id);
00988
00993 char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd);
00994
00999 bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso,
01000 char **p_psz_volumeset_id);
01001
01002
01003
01005 void iso9660_pathtable_init (void *pt);
01006
01007 unsigned int iso9660_pathtable_get_size (const void *pt);
01008
01009 uint16_t
01010 iso9660_pathtable_l_add_entry (void *pt, const char name[], uint32_t extent,
01011 uint16_t parent);
01012
01013 uint16_t
01014 iso9660_pathtable_m_add_entry (void *pt, const char name[], uint32_t extent,
01015 uint16_t parent);
01016
01021 void
01022 iso9660_set_pvd (void *pd, const char volume_id[], const char application_id[],
01023 const char publisher_id[], const char preparer_id[],
01024 uint32_t iso_size, const void *root_dir,
01025 uint32_t path_table_l_extent, uint32_t path_table_m_extent,
01026 uint32_t path_table_size, const time_t *pvd_time);
01027
01028 void
01029 iso9660_set_evd (void *pd);
01030
01034 bool iso9660_ifs_is_xa (const iso9660_t * p_iso);
01035
01036
01037 #ifdef __cplusplus
01038 }
01039 #endif
01040
01041 #endif
01042
01043
01044
01045
01046
01047
01048
01049