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
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
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;
00306 char root_directory_filename;
00309 dchar_t volume_set_id[ISO_MAX_VOLUMESET_ID];
00313 achar_t publisher_id[ISO_MAX_PUBLISHER_ID];
00324 achar_t preparer_id[ISO_MAX_PREPARER_ID];
00335 achar_t application_id[ISO_MAX_APPLICATION_ID];
00347 dchar_t copyright_file_id[37];
00354 dchar_t abstract_file_id[37];
00356 dchar_t bibliographic_file_id[37];
00358 iso9660_ltime_t creation_date;
00361 iso9660_ltime_t modification_date;
00365 iso9660_ltime_t expiration_date;
00368 iso9660_ltime_t effective_date;
00372 iso711_t file_structure_version;
00373 uint8_t unused4[1];
00374 char application_data[512];
00376 uint8_t unused5[653];
00377 } GNUC_PACKED;
00378
00379 typedef struct iso9660_pvd_s iso9660_pvd_t;
00380
00388 struct iso9660_svd_s {
00389 iso711_t type;
00391 char id[5];
00393 iso711_t version;
00394 char flags;
00395 achar_t system_id[ISO_MAX_SYSTEM_ID];
00397 dchar_t volume_id[ISO_MAX_VOLUME_ID];
00399 char unused2[8];
00400 iso733_t volume_space_size;
00402 char escape_sequences[32];
00403 iso723_t volume_set_size;
00404 iso723_t volume_sequence_number;
00405 iso723_t logical_block_size;
00406 iso733_t path_table_size;
00408 iso731_t type_l_path_table;
00410 iso731_t opt_type_l_path_table;
00413 iso732_t type_m_path_table;
00415 iso732_t opt_type_m_path_table;
00418 iso9660_dir_t root_directory_record;
00420 char root_directory_filename;
00423 dchar_t volume_set_id[ISO_MAX_VOLUMESET_ID];
00425 achar_t publisher_id[ISO_MAX_PUBLISHER_ID];
00437 achar_t preparer_id[ISO_MAX_PREPARER_ID];
00449 achar_t application_id[ISO_MAX_APPLICATION_ID];
00461 dchar_t copyright_file_id[37];
00468 dchar_t abstract_file_id[37];
00470 dchar_t bibliographic_file_id[37];
00472 iso9660_ltime_t creation_date;
00475 iso9660_ltime_t modification_date;
00479 iso9660_ltime_t expiration_date;
00482 iso9660_ltime_t effective_date;
00486 iso711_t file_structure_version;
00487 uint8_t unused4[1];
00488 char application_data[512];
00490 uint8_t unused5[653];
00491 } GNUC_PACKED;
00492
00493 typedef struct iso9660_svd_s iso9660_svd_t;
00494
00495 PRAGMA_END_PACKED
00496
00506 struct iso9660_stat_s {
00507
00508 iso_rock_statbuf_t rr;
00510 struct tm tm;
00512 lsn_t lsn;
00513 uint32_t size;
00514 uint32_t secsize;
00515 iso9660_xa_t xa;
00516 enum { _STAT_FILE = 1, _STAT_DIR = 2 } type;
00517 bool b_xa;
00518 char filename[EMPTY_ARRAY_SIZE];
00519 };
00520
00523 typedef uint8_t iso_extension_mask_t;
00524
00530 extern enum iso_extension_enum_s {
00531 ISO_EXTENSION_JOLIET_LEVEL1 = 0x01,
00532 ISO_EXTENSION_JOLIET_LEVEL2 = 0x02,
00533 ISO_EXTENSION_JOLIET_LEVEL3 = 0x04,
00534 ISO_EXTENSION_ROCK_RIDGE = 0x08,
00535 ISO_EXTENSION_HIGH_SIERRA = 0x10
00536 } iso_extension_enums;
00537
00538
00539 #define ISO_EXTENSION_ALL 0xFF
00540 #define ISO_EXTENSION_NONE 0x00
00541 #define ISO_EXTENSION_JOLIET \
00542 (ISO_EXTENSION_JOLIET_LEVEL1 | \
00543 ISO_EXTENSION_JOLIET_LEVEL2 | \
00544 ISO_EXTENSION_JOLIET_LEVEL3 )
00545
00546
00548 typedef struct _iso9660_s iso9660_t;
00549
00557 bool iso9660_close (iso9660_t * p_iso);
00558
00559
00564 iso9660_t *iso9660_open (const char *psz_path );
00565
00573 iso9660_t *iso9660_open_ext (const char *psz_path,
00574 iso_extension_mask_t iso_extension_mask);
00575
00590 iso9660_t *iso9660_open_fuzzy (const char *psz_path ,
00591 uint16_t i_fuzz);
00592
00602 iso9660_t *iso9660_open_fuzzy_ext (const char *psz_path,
00603 iso_extension_mask_t iso_extension_mask,
00604 uint16_t i_fuzz
00605 );
00606
00613 bool iso9660_ifs_fuzzy_read_superblock (iso9660_t *p_iso,
00614 iso_extension_mask_t iso_extension_mask,
00615 uint16_t i_fuzz);
00616
00633 long int iso9660_iso_seek_read (const iso9660_t *p_iso, void *ptr,
00634 lsn_t start, long int i_size);
00635
00640 bool iso9660_fs_read_pvd ( const CdIo_t *p_cdio,
00641 iso9660_pvd_t *p_pvd );
00642
00647 bool iso9660_ifs_read_pvd (const iso9660_t *p_iso,
00648 iso9660_pvd_t *p_pvd);
00649
00655 bool iso9660_fs_read_superblock (CdIo_t *p_cdio,
00656 iso_extension_mask_t iso_extension_mask);
00657
00663 bool iso9660_ifs_read_superblock (iso9660_t *p_iso,
00664 iso_extension_mask_t iso_extension_mask);
00665
00666
00667
00668
00669
00673 void iso9660_set_dtime (const struct tm *tm,
00674 iso9660_dtime_t *idr_date);
00675
00676
00680 void iso9660_set_ltime (const struct tm *_tm,
00681 iso9660_ltime_t *p_pvd_date);
00682
00691 bool iso9660_get_dtime (const iso9660_dtime_t *idr_date, bool use_localtime,
00692 struct tm *tm);
00693
00694
00699 bool iso9660_get_ltime (const iso9660_ltime_t *p_ldate,
00700 struct tm *p_tm);
00701
00702
00703
00704
00710 bool iso9660_is_dchar (int c);
00711
00717 bool iso9660_is_achar (int c);
00718
00730 int iso9660_name_translate(const char *psz_oldname,
00731 char *psz_newname);
00732
00748 int iso9660_name_translate_ext(const char *psz_oldname, char *psz_newname,
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
00834 #define iso9660_fs_find_lsn iso9660_find_fs_lsn
00835 iso9660_stat_t *iso9660_fs_find_lsn(CdIo_t *p_cdio, lsn_t i_lsn);
00836
00837
00845 iso9660_stat_t *iso9660_ifs_find_lsn(iso9660_t *p_iso, lsn_t i_lsn);
00846
00847
00866 iso9660_stat_t *iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[]);
00867
00868
00876 iso9660_stat_t *iso9660_fs_stat_translate (CdIo_t *p_cdio,
00877 const char psz_path[],
00878 bool b_mode2);
00879
00883 iso9660_stat_t *iso9660_ifs_stat (iso9660_t *p_iso, const char psz_path[]);
00884
00885
00890 iso9660_stat_t *iso9660_ifs_stat_translate (iso9660_t *p_iso,
00891 const char psz_path[]);
00892
00899 CdioList_t * iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[],
00900 bool b_mode2);
00901
00906 CdioList_t * iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[]);
00907
00912 char * iso9660_get_application_id(iso9660_pvd_t *p_pvd);
00913
00918 bool iso9660_ifs_get_application_id(iso9660_t *p_iso,
00919 cdio_utf8_t **p_psz_app_id);
00920
00924 uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso);
00925
00926 uint8_t iso9660_get_dir_len(const iso9660_dir_t *p_idr);
00927
00928 #if FIXME
00929 uint8_t iso9660_get_dir_size(const iso9660_dir_t *p_idr);
00930
00931 lsn_t iso9660_get_dir_extent(const iso9660_dir_t *p_idr);
00932 #endif
00933
00939 char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir);
00940
00944 mode_t iso9660_get_posix_filemode(const iso9660_stat_t *p_iso_dirent);
00945
00950 char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd);
00951
00956 bool iso9660_ifs_get_preparer_id(iso9660_t *p_iso,
00957 cdio_utf8_t **p_psz_preparer_id);
00958
00963 char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd);
00964
00969 bool iso9660_ifs_get_publisher_id(iso9660_t *p_iso,
00970 cdio_utf8_t **p_psz_publisher_id);
00971
00972 uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd);
00973
00974 const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd);
00975
00976 int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd);
00977
00978 int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ;
00979
00983 int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ;
00984
00989 char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd);
00990
00995 bool iso9660_ifs_get_system_id(iso9660_t *p_iso,
00996 cdio_utf8_t **p_psz_system_id);
00997
00998
01002 lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd);
01003
01008 char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd);
01009
01014 bool iso9660_ifs_get_volume_id(iso9660_t *p_iso,
01015 cdio_utf8_t **p_psz_volume_id);
01016
01021 char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd);
01022
01027 bool iso9660_ifs_get_volumeset_id(iso9660_t *p_iso,
01028 cdio_utf8_t **p_psz_volumeset_id);
01029
01030
01031
01033 void iso9660_pathtable_init (void *pt);
01034
01035 unsigned int iso9660_pathtable_get_size (const void *pt);
01036
01037 uint16_t iso9660_pathtable_l_add_entry (void *pt, const char name[],
01038 uint32_t extent, uint16_t parent);
01039
01040 uint16_t iso9660_pathtable_m_add_entry (void *pt, const char name[],
01041 uint32_t extent, uint16_t parent);
01042
01047 void iso9660_set_pvd (void *pd, const char volume_id[],
01048 const char application_id[],
01049 const char publisher_id[], const char preparer_id[],
01050 uint32_t iso_size, const void *root_dir,
01051 uint32_t path_table_l_extent,
01052 uint32_t path_table_m_extent,
01053 uint32_t path_table_size, const time_t *pvd_time);
01054
01055 void iso9660_set_evd (void *pd);
01056
01060 bool iso9660_ifs_is_xa (const iso9660_t * p_iso);
01061
01062
01063 #ifndef DO_NOT_WANT_COMPATIBILITY
01064
01065 #define iso9660_isdchar iso9660_is_dchar
01066 #define iso9660_isachar iso9660_is_achar
01067 #endif
01068
01069 #ifdef __cplusplus
01070 }
01071 #endif
01072
01073 #endif
01074
01075
01076
01077
01078
01079
01080
01081