2
See end for copyright and license.
5
"A Perl wrapper for The CD Input and Control library's ISO-9660 library
6
See also the ISO-9660 specification. The freely available European
7
equivalant standard is called ECMA-119."
9
%module(docstring=DOCSTRING) perliso9660
12
/* Includes the header in the wrapper code */
14
#include <cdio/iso9660.h>
15
#include <cdio/version.h>
19
#include <cdio/iso9660.h>
20
#include <cdio/version.h>
22
/* Various libcdio constants and typedefs */
27
typedef uint8_t iso_extension_mask_t;
29
%constant long int ISO_BLOCKSIZE = CDIO_CD_FRAMESIZE;
30
%constant long int PVD_SECTOR = ISO_PVD_SECTOR ;
31
%constant long int EVD_SECTOR = ISO_EVD_SECTOR ;
32
%constant long int LEN_ISONAME = LEN_ISONAME;
33
%constant long int MAX_SYSTEM_ID = ISO_MAX_SYSTEM_ID ;
34
%constant long int MAX_ISONAME = MAX_ISONAME;
35
%constant long int MAX_PREPARER_ID = ISO_MAX_PREPARER_ID ;
36
%constant long int MAX_ISOPATHNAME = MAX_ISOPATHNAME;
38
%constant long int FILE = ISO_FILE;
39
%constant long int EXISTENCE = ISO_EXISTENCE;
40
%constant long int DIRECTORY = ISO_DIRECTORY;
41
%constant long int ASSOCIATED = ISO_ASSOCIATED;
42
%constant long int RECORD = ISO_RECORD;
44
/* When version 0.77 comes out, require it and fix this fix this. */
45
#if LIBCDIO_VERSION_NUM >= 77
46
%constant long int PROTECTION = ISO_PROTECTION;
48
%constant long int PROTECTION = 16;
51
%constant long int DRESERVED1 = ISO_DRESERVED1;
52
%constant long int DRESERVED2 = ISO_DRESERVED2;
53
%constant long int MULTIEXTENT = ISO_MULTIEXTENT;
55
%constant long int VD_BOOT_RECORD = ISO_VD_BOOT_RECORD;
56
%constant long int VD_PRIMARY = ISO_VD_PRIMARY;
57
%constant long int VD_SUPPLEMENTARY = ISO_VD_SUPPLEMENTARY;
58
%constant long int VD_PARITION = ISO_VD_PARITION;
59
%constant long int VD_END = ISO_VD_END;
61
%constant long int MAX_PUBLISHER_ID = ISO_MAX_PUBLISHER_ID;
62
%constant long int MAX_APPLICATION_ID = ISO_MAX_APPLICATION_ID;
63
%constant long int MAX_VOLUME_ID = ISO_MAX_VOLUME_ID;
64
%constant long int MAX_VOLUMESET_ID = ISO_MAX_VOLUMESET_ID;
65
%constant long int STANDARD_ID = ISO_STANDARD_ID;
67
%constant long int NOCHECK = ISO9660_NOCHECK;
68
%constant long int SEVEN_BIT = ISO9660_7BIT;
69
%constant long int ACHARS = ISO9660_ACHARS;
70
%constant long int DCHARS = ISO9660_DCHARS;
72
%constant long int EXTENSION_JOLIET_LEVEL1 = ISO_EXTENSION_JOLIET_LEVEL1;
73
%constant long int EXTENSION_JOLIET_LEVEL2 = ISO_EXTENSION_JOLIET_LEVEL2;
74
%constant long int EXTENSION_JOLIET_LEVEL3 = ISO_EXTENSION_JOLIET_LEVEL3;
75
%constant long int EXTENSION_ROCK_RIDGE = ISO_EXTENSION_ROCK_RIDGE;
76
%constant long int EXTENSION_HIGH_SIERRA = ISO_EXTENSION_HIGH_SIERRA;
78
%constant long int EXTENSION_ALL = ISO_EXTENSION_ALL;
79
%constant long int EXTENSION_NONE = ISO_EXTENSION_NONE;
80
%constant long int EXTENSION_JOLIET = ISO_EXTENSION_JOLIET;
82
/* Set up to allow functions to return stat lists of type "stat
83
*". We'll use a typedef so we can make sure to isolate this.
86
typedef CdioList_t IsoStatList_t;
87
typedef iso9660_stat_t IsoStat_t;
89
typedef CdioList_t IsoStatList_t;
90
typedef iso9660_stat_t IsoStat_t;
92
%typemap(out) IsoStat_t *{
93
// $1 is of type IsoStatList_t
94
iso9660_stat_t *p_statbuf = result;
96
if (!result) goto out;
99
/* Have perl compute the length of the string using strlen() */
100
XPUSHs(sv_2mortal(newSVpv(p_statbuf->filename, 0)));
101
XPUSHs(sv_2mortal(newSViv(p_statbuf->lsn)));
102
XPUSHs(sv_2mortal(newSViv(p_statbuf->size)));
103
XPUSHs(sv_2mortal(newSViv(p_statbuf->secsize)));
104
XPUSHs(sv_2mortal(newSViv(p_statbuf->type)));
110
%typemap(out) IsoStatList_t *{
111
// $1 is of type IsoStatList_t
112
CdioList_t *p_entlist = result;
113
CdioListNode_t *p_entnode;
114
unsigned int num = 0;
116
if (!result) goto out;
119
/* Figure out how many items in the array */
120
_CDIO_LIST_FOREACH (p_entnode, p_entlist) {
124
/* For each element in the array of strings, create a new
125
* mortalscalar, and stuff it into the above array. */
126
_CDIO_LIST_FOREACH (p_entnode, p_entlist) {
127
iso9660_stat_t *p_statbuf =
128
(iso9660_stat_t *) _cdio_list_node_data (p_entnode);
129
/* Have perl compute the length of the string using strlen() */
130
XPUSHs(sv_2mortal(newSVpv(p_statbuf->filename, 0)));
131
XPUSHs(sv_2mortal(newSViv(p_statbuf->lsn)));
132
XPUSHs(sv_2mortal(newSViv(p_statbuf->size)));
133
XPUSHs(sv_2mortal(newSViv(p_statbuf->secsize)));
134
XPUSHs(sv_2mortal(newSViv(p_statbuf->type)));
136
_cdio_list_free (p_entlist, true);
142
Open an ISO 9660 image for reading. Maybe in the future we will have
143
a mode. NULL is returned on error.
145
%rename iso9660_open open_iso;
146
iso9660_t *iso9660_open (const char *psz_path /*flags, mode */);
149
Open an ISO 9660 image for reading allowing various ISO 9660
150
extensions. Maybe in the future we will have a mode. NULL is
153
%rename iso9660_open_ext open_ext;
154
iso9660_t *iso9660_open_ext (const char *psz_path,
155
iso_extension_mask_t iso_extension_mask);
158
Open an ISO 9660 image for reading with some tolerence for positioning
159
of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set
160
the eventual offset to adjust by (as long as that is <= i_fuzz).
162
Maybe in the future we will have a mode. NULL is returned on error.
166
%rename iso9660_open_fuzzy open_fuzzy;
167
iso9660_t *iso9660_open_fuzzy (const char *psz_path /*flags, mode */,
171
Open an ISO 9660 image for reading with some tolerence for positioning
172
of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set
173
the eventual offset to adjust by (as long as that is <= i_fuzz).
175
Maybe in the future we will have a mode. NULL is returned on error.
179
%rename iso9660_open_fuzzy open_fuzzy_ext;
180
iso9660_t *iso9660_open_fuzzy_ext (const char *psz_path,
181
iso_extension_mask_t iso_extension_mask,
185
Read the Super block of an ISO 9660 image but determine framesize
186
and datastart and a possible additional offset. Generally here we are
187
not reading an ISO 9660 image but a CD-Image which contains an ISO 9660
190
%rename iso9660_ifs_fuzzy_read_superblock ifs_fuzzy_read_superblock;
191
bool iso9660_ifs_fuzzy_read_superblock (iso9660_t *p_iso,
192
iso_extension_mask_t iso_extension_mask,
195
Close previously opened ISO 9660 image.
196
True is unconditionally returned. If there was an error false would
199
%rename iso9660_close close;
200
bool iso9660_close (iso9660_t * p_iso);
202
%typemap(out) buf_t {
203
/* $1 is of type buf_t */
204
ST(argvi) = sv_newmortal();
206
/* I don't yet know how to pick up arg4 another way.
207
THIS MEANS ARG3 MUST ALWAYS BE THE SIZE. */
208
sv_setpvn((SV*)ST(argvi++), (char *) result, *arg4);
209
/* Don't leak memory. return value was malloc'd by libcdio. */
212
sv_setsv((SV*)ST(argvi++), &PL_sv_undef);
216
typedef long int my_ssize_t;
218
%apply my_ssize_t *OUTPUT { my_ssize_t *pi_size };
220
/*! Seek to a position and then read n bytes. (buffer, size) are
223
%newobject seek_read; // free malloc'd return value
225
buf_t seek_read (const iso9660_t *p_iso,
226
lsn_t start, long int i_size,
227
/*out*/ my_ssize_t *pi_size);
230
buf_t seek_read (const iso9660_t *p_iso,
231
lsn_t start, long int i_size,
232
/*out*/ my_ssize_t *pi_size) {
234
char *p_buf = calloc(ISO_BLOCKSIZE, i_size);
235
*pi_size = iso9660_iso_seek_read(p_iso, p_buf, start, i_size);
242
Read the Primary Volume Descriptor for a CD.
243
True is returned if read, and false if there was an error.
245
iso9660_pvd_t *fs_read_pvd ( const CdIo_t *p_cdio );
247
iso9660_pvd_t *fs_read_pvd ( const CdIo_t *p_cdio ) {
248
static iso9660_pvd_t pvd;
249
bool b_ok = iso9660_fs_read_pvd ( p_cdio, &pvd );
250
if (!b_ok) return NULL;
256
Read the Primary Volume Descriptor for an ISO 9660 image.
257
True is returned if read, and false if there was an error.
259
iso9660_pvd_t *ifs_read_pvd ( const iso9660_t *p_iso );
261
iso9660_pvd_t *ifs_read_pvd ( const iso9660_t *p_iso ) {
262
static iso9660_pvd_t pvd;
263
bool b_ok = iso9660_ifs_read_pvd ( p_iso, &pvd );
264
if (!b_ok) return NULL;
270
Read the Super block of an ISO 9660 image. This is the
271
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
272
Descriptor if (Joliet) extensions are acceptable.
274
%rename iso9660_fs_read_superblock fs_read_superblock;
275
bool iso9660_fs_read_superblock (CdIo_t *p_cdio,
276
iso_extension_mask_t iso_extension_mask);
279
Read the Super block of an ISO 9660 image. This is the
280
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
281
Descriptor if (Joliet) extensions are acceptable.
283
%rename iso9660_ifs_read_superblock ifs_read_superblock;
284
bool iso9660_ifs_read_superblock (iso9660_t *p_iso,
285
iso_extension_mask_t iso_extension_mask);
288
/*====================================================
290
====================================================*/
292
Set time in format used in ISO 9660 directory index record
293
from a Unix time structure. */
295
set_dtime ( int tm_sec, int tm_min, int tm_hour, int tm_mday, int tm_mon,
299
set_dtime ( int tm_sec, int tm_min, int tm_hour, int tm_mday, int tm_mon,
302
struct tm tm = { tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, 0, 0, 0 };
303
static iso9660_dtime_t dtime;
304
iso9660_set_dtime (&tm, &dtime);
310
Set "long" time in format used in ISO 9660 primary volume descriptor
311
from a Unix time structure. */
313
set_ltime ( int tm_sec, int tm_min, int tm_hour, int tm_mday, int tm_mon,
318
set_ltime ( int tm_sec, int tm_min, int tm_hour, int tm_mday, int tm_mon,
322
struct tm tm = { tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, 0, 0, 0 };
323
static iso9660_ltime_t ldate;
324
iso9660_set_ltime (&tm, &ldate);
330
Get Unix time structure from format use in an ISO 9660 directory index
331
record. Even though tm_wday and tm_yday fields are not explicitly in
332
dtime, they are calculated from the other fields.
334
If tm is to reflect the localtime, set "use_localtime" true, otherwise
335
tm will reported in GMT.
337
%apply int *OUTPUT { int *tm_sec, int *tm_min, int *tm_hour, int *tm_mday,
338
int *tm_mon, int *tm_year, int *tm_wday, int *tm_yday,
341
bool get_dtime (const iso9660_dtime_t *dtime, bool use_localtime,
342
int *tm_sec, int *tm_min, int *tm_hour, int *tm_mday,
343
int *tm_mon, int *tm_year, int *tm_wday, int *tm_yday,
347
bool get_dtime (const iso9660_dtime_t *dtime, bool use_localtime,
348
int *tm_sec, int *tm_min, int *tm_hour, int *tm_mday,
349
int *tm_mon, int *tm_year, int *tm_wday, int *tm_yday,
353
bool b_okay = iso9660_get_dtime (dtime, use_localtime, &tm);
357
*tm_hour = tm.tm_hour;
359
*tm_mday = tm.tm_mday;
360
*tm_year = tm.tm_year;
361
*tm_wday = tm.tm_wday;
362
*tm_yday = tm.tm_yday;
363
*tm_isdst = tm.tm_isdst;
370
Get "long" time in format used in ISO 9660 primary volume descriptor
371
from a Unix time structure.
373
bool get_ltime (const iso9660_ltime_t *dtime,
374
int *tm_sec, int *tm_min, int *tm_hour, int *tm_mday,
375
int *tm_mon, int *tm_year, int *tm_wday, int *tm_yday,
379
bool get_ltime (const iso9660_ltime_t *p_ldate,
380
int *tm_sec, int *tm_min, int *tm_hour, int *tm_mday,
381
int *tm_mon, int *tm_year, int *tm_wday, int *tm_yday,
385
bool b_okay = iso9660_get_ltime (p_ldate, &tm);
389
*tm_hour = tm.tm_hour;
391
*tm_mday = tm.tm_mday;
392
*tm_year = tm.tm_year;
393
*tm_wday = tm.tm_wday;
394
*tm_yday = tm.tm_yday;
395
*tm_isdst = tm.tm_isdst;
402
/*========================================================
403
Characters used in file and directory and manipulation
404
=======================================================*/
406
Return true if c is a DCHAR - a character that can appear in an an
407
ISO-9600 level 1 directory name. These are the ASCII capital
408
letters A-Z, the digits 0-9 and an underscore.
410
%rename iso9660_isdchar is_dchar;
411
bool iso9660_isdchar (int c);
414
Return true if c is an ACHAR -
415
These are the DCHAR's plus some ASCII symbols including the space
418
%rename iso9660_isachar is_achar;
419
bool iso9660_isachar (int c);
422
Convert an ISO-9660 file name that stored in a directory entry into
423
what's usually listed as the file name in a listing.
424
Lowercase name, and remove trailing ;1's or .;1's and
425
turn the other ;'s into version numbers.
427
@param psz_oldname the ISO-9660 filename to be translated.
428
@param psz_newname returned string. The caller allocates this and
429
it should be at least the size of psz_oldname.
430
@return length of the translated string is returned.
432
%newobject name_translate;
433
char * name_translate(const char *psz_oldname);
436
name_translate(const char *psz_oldname) {
437
char *psz_newname=calloc(sizeof(char), strlen(psz_oldname)+1);
438
iso9660_name_translate(psz_oldname, psz_newname);
444
Convert an ISO-9660 file name that stored in a directory entry into
445
what's usually listed as the file name in a listing. Lowercase
446
name if no Joliet Extension interpretation. Remove trailing ;1's or
447
.;1's and turn the other ;'s into version numbers.
449
@param psz_oldname the ISO-9660 filename to be translated.
450
@param psz_newname returned string. The caller allocates this and
451
it should be at least the size of psz_oldname.
452
@param i_joliet_level 0 if not using Joliet Extension. Otherwise the
454
@return length of the translated string is returned. It will be no greater
455
than the length of psz_oldname.
457
%newobject name_translate_ext;
458
char * name_translate_ext(const char *psz_oldname, uint8_t i_joliet_level);
461
name_translate_ext(const char *psz_oldname, uint8_t i_joliet_level) {
462
char *psz_newname=calloc(sizeof(char), strlen(psz_oldname)+1);
463
iso9660_name_translate_ext(psz_oldname, psz_newname, i_joliet_level);
469
Pad string src with spaces to size len and copy this to dst. If
470
len is less than the length of src, dst will be truncated to the
471
first len characters of src.
473
src can also be scanned to see if it contains only ACHARs, DCHARs,
474
7-bit ASCII chars depending on the enumeration _check.
476
In addition to getting changed, dst is the return value.
477
Note: this string might not be NULL terminated.
479
%newobject strncpy_pad; // free malloc'd return value
480
char *strncpy_pad(const char src[], size_t len, enum strncpy_pad_check _check);
483
strncpy_pad(const char src[], size_t len, enum strncpy_pad_check _check) {
484
char *dst = calloc(sizeof(char), len+1);
485
return iso9660_strncpy_pad(dst, src, len, _check);
489
/*=====================================================================
490
Files and Directory Names
491
======================================================================*/
494
Check that psz_path is a valid ISO-9660 directory name.
496
A valid directory name should not start out with a slash (/),
497
dot (.) or null byte, should be less than 37 characters long,
498
have no more than 8 characters in a directory component
499
which is separated by a /, and consist of only DCHARs.
501
True is returned if psz_path is valid.
503
%rename iso9660_dirname_valid_p dirname_valid_p;
504
bool iso9660_dirname_valid_p (const char psz_path[]);
507
Take psz_path and a version number and turn that into a ISO-9660
508
pathname. (That's just the pathname followed by ";" and the version
509
number. For example, mydir/file.ext -> MYDIR/FILE.EXT;1 for version
510
1. The resulting ISO-9660 pathname is returned.
512
%rename iso9660_pathname_isofy pathname_isofy;
513
%newobject iso9660_pathname_isofy; // free malloc'd return value
514
char *iso9660_pathname_isofy (const char psz_path[], uint16_t i_version);
517
Check that psz_path is a valid ISO-9660 pathname.
519
A valid pathname contains a valid directory name, if one appears and
520
the filename portion should be no more than 8 characters for the
521
file prefix and 3 characters in the extension (or portion after a
522
dot). There should be exactly one dot somewhere in the filename
523
portion and the filename should be composed of only DCHARs.
525
True is returned if psz_path is valid.
527
%rename iso9660_pathname_valid_p pathname_valid_p;
528
bool iso9660_pathname_valid_p (const char psz_path[]);
533
Given a directory pointer, find the filesystem entry that contains
534
lsn and return information about it.
536
Returns stat_t of entry if we found lsn, or NULL otherwise.
538
%rename iso9660_find_fs_lsn fs_find_lsn;
539
IsoStat_t *iso9660_find_fs_lsn(CdIo_t *p_cdio, lsn_t i_lsn);
542
#if LIBCDIO_VERSION_NUM > 76
544
Given a directory pointer, find the filesystem entry that contains
545
lsn and return information about it.
547
Returns stat_t of entry if we found lsn, or NULL otherwise.
549
%rename iso9660_ifs_find_lsn ifs_find_lsn;
550
IsoStat_t *iso9660_ifs_find_lsn(const iso9660_t *p_iso, lsn_t i_lsn);
555
Return file status for psz_path. NULL is returned on error.
557
%rename iso9660_fs_stat fs_stat;
558
IsoStat_t *iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[]);
562
Return file status for path name psz_path. NULL is returned on error.
563
pathname version numbers in the ISO 9660 name are dropped, i.e. ;1
564
is removed and if level 1 ISO-9660 names are lowercased.
566
The b_mode2 parameter is not used.
568
%rename iso9660_fs_stat_translate fs_stat_translate;
569
IsoStat_t *iso9660_fs_stat_translate (CdIo_t *p_cdio,
570
const char psz_path[],
574
Return file status for pathname. NULL is returned on error.
576
%rename iso9660_ifs_stat ifs_stat;
577
IsoStat_t *iso9660_ifs_stat (iso9660_t *p_iso, const char psz_path[]);
580
/*! Return file status for path name psz_path. NULL is returned on
581
error. pathname version numbers in the ISO 9660 name are dropped,
582
i.e. ;1 is removed and if level 1 ISO-9660 names are lowercased.
584
%rename iso9660_ifs_stat_translate ifs_stat_translate;
585
IsoStat_t *iso9660_ifs_stat_translate (iso9660_t *p_iso,
586
const char psz_path[]);
588
/*! Read psz_path (a directory) and return a list of iso9660_stat_t
589
pointers for the files inside that directory. The caller must free the
592
%newobject fs_readdir; // free malloc'd return value
593
IsoStatList_t *fs_readdir (CdIo_t *p_cdio, const char psz_path[]);
596
IsoStatList_t *fs_readdir (CdIo_t *p_cdio, const char psz_path[])
598
CdioList_t *p_statlist = iso9660_fs_readdir (p_cdio, psz_path, false);
603
/*! Read psz_path (a directory) and return a list of iso9660_stat_t
604
pointers for the files inside that directory. The caller must free
607
%newobject ifs_readdir; // free malloc'd return value
608
IsoStatList_t *ifs_readdir (iso9660_t *p_iso, const char psz_path[]);
611
IsoStatList_t *ifs_readdir (iso9660_t *p_iso, const char psz_path[])
613
CdioList_t *p_statlist = iso9660_ifs_readdir (p_iso, psz_path);
619
Return the PVD's application ID.
620
NULL is returned if there is some problem in getting this.
622
%rename iso9660_get_application_id get_application_id;
623
char * iso9660_get_application_id(iso9660_pvd_t *p_pvd);
626
Get the application ID. Return NULL if there
627
is some problem in getting this.
629
%newobject get_application_id; // free malloc'd return value
630
char *ifs_get_application_id(iso9660_t *p_iso);
633
ifs_get_application_id(iso9660_t *p_iso) {
635
bool ok = iso9660_ifs_get_application_id(p_iso, &psz);
636
if (!ok) return NULL;
643
Return the Joliet level recognized for p_iso.
645
%rename iso9660_ifs_get_joliet_level get_joliet_level;
646
uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso);
648
%rename iso9660_get_dir_len get_dir_len;
649
uint8_t iso9660_get_dir_len(const iso9660_dir_t *p_idr);
652
Return the directory name stored in the iso9660_dir_t
654
%rename iso9660_get_to_name get_to_name;
655
%newobject iso9660_dir_to_name; // free malloc'd return value
656
char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir);
658
#if LIBCDIO_VERSION_NUM > 76
660
Returns a POSIX mode for a given p_iso_dirent.
662
%rename iso9660_get_posix_filemode get_posix_filemode;
663
mode_t iso9660_get_posix_filemode(const iso9660_stat_t *p_iso_dirent);
667
Return a string containing the preparer id with trailing
670
%rename iso9660_get_preparer_id get_preparer_id;
671
char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd);
673
/*! Get the preparer ID. Return NULL if there is some problem in
676
%newobject ifs_get_preparer_id; // free malloc'd return value
677
char *ifs_get_preparer_id(iso9660_t *p_iso);
680
ifs_get_preparer_id(iso9660_t *p_iso) {
682
bool ok = iso9660_ifs_get_preparer_id(p_iso, &psz);
683
if (!ok) return NULL;
689
Return a string containing the PVD's publisher id with trailing
692
%rename iso9660_get_publisher_id get_publisher_id;
693
char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd);
696
Get the publisher ID. return NULL if there
697
is some problem in getting this.
699
%newobject ifs_get_publisher_id; // free malloc'd return value
700
char *ifs_get_publisher_id(iso9660_t *p_iso);
703
ifs_get_publisher_id(iso9660_t *p_iso) {
705
bool ok = iso9660_ifs_get_publisher_id(p_iso, &psz);
706
if (!ok) return NULL;
711
%rename iso9660_get_pvd_type get_pvd_type;
712
uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd);
714
%rename iso9660_get_pvd_id get_pvd_id;
715
const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd);
717
%rename iso9660_get_pvd_space_size get_pvd_space_size;
718
int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd);
720
%rename iso9660_get_pvd_block_size get_pvd_block_size;
721
int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ;
723
/*! Return the primary volume id version number (of pvd).
724
If there is an error 0 is returned.
726
%rename iso9660_get_pvd_version get_pvd_version;
727
int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ;
730
Return a string containing the PVD's system id with trailing
733
%rename iso9660_get_system_id get_system_id;
734
char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd);
737
Get the system ID. return NULL if there
738
is some problem in getting this.
740
%newobject ifs_get_system_id; // free malloc'd return value
741
char *ifs_get_system_id(iso9660_t *p_iso);
744
ifs_get_system_id(iso9660_t *p_iso) {
746
bool ok = iso9660_ifs_get_system_id(p_iso, &psz);
747
if (!ok) return NULL;
752
/*! Return the LSN of the root directory for pvd.
753
If there is an error CDIO_INVALID_LSN is returned.
755
%rename iso9660_get_root_lsn get_root_lsn;
756
lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd);
759
Return the PVD's volume ID.
761
%rename iso9660_get_volume_id get_volume_id;
762
char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd);
765
Get the system ID. return NULL if there
766
is some problem in getting this.
768
%newobject ifs_get_volume_id; // free malloc'd return value
769
char *ifs_get_volume_id(iso9660_t *p_iso);
772
ifs_get_volume_id(iso9660_t *p_iso) {
774
bool ok = iso9660_ifs_get_volume_id(p_iso, &psz);
775
if (!ok) return NULL;
781
Return the PVD's volumeset ID.
782
NULL is returned if there is some problem in getting this.
784
%rename iso9660_get_volumeset_id get_volumeset_id;
785
char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd);
788
Get the volumeset ID. return NULL if there
789
is some problem in getting this.
791
%newobject ifs_get_volumeset_id; // free malloc'd return value
792
char *ifs_get_volumeset_id(iso9660_t *p_iso);
795
ifs_get_volumeset_id(iso9660_t *p_iso) {
797
bool ok = iso9660_ifs_get_volumeset_id(p_iso, &psz);
798
if (!ok) return NULL;
803
/* ================= pathtable ================== */
805
/*! Zero's out pathable. Do this first. */
806
%rename iso9660_pathtable_init pathtable_init;
807
void iso9660_pathtable_init (void *pt);
809
%rename iso9660_pathtable_get_size pathtable_get_size;
810
unsigned int iso9660_pathtable_get_size (const void *pt);
812
%rename iso9660_pathtable_l_add_entry pathtable_l_add_entry;
813
uint16_t iso9660_pathtable_l_add_entry (void *pt, const char name[],
814
uint32_t extent, uint16_t parent);
816
%rename iso9660_pathtable_m_add_entry pathtable_m_add_entry;
817
uint16_t iso9660_pathtable_m_add_entry (void *pt, const char name[],
818
uint32_t extent, uint16_t parent);
820
/*======================================================================
822
========================================================================*/
825
void iso9660_set_pvd (void *pd, const char volume_id[],
826
const char application_id[],
827
const char publisher_id[], const char preparer_id[],
828
uint32_t iso_size, const void *root_dir,
829
uint32_t path_table_l_extent,
830
uint32_t path_table_m_extent,
831
uint32_t path_table_size, const time_t *pvd_time);
834
%rename iso9660_set_evd set_evd;
835
void iso9660_set_evd (void *pd);
838
Return true if ISO 9660 image has extended attrributes (XA).
840
%rename iso9660_ifs_is_xa is_xa;
841
bool iso9660_ifs_is_xa (const iso9660_t * p_iso);
845
import Device::Cdio::VERSION;
846
$VERSION = $Device::Cdio::VERSION;
852
perliso9660 - lower-level wrapper to libiso9660, the ISO 9660 library of the CD Input and Control package
856
This is fairly straight-forward wrapper around the C library libiso9660
857
Although this is perfectly usable on its own, it is expected that the
858
Object-Oriented interface L<Device::Cdio::ISO9660> is what most people will
861
There are various constants that are defined here.
865
Encapsulation is done in two parts. The lower-level Perl
866
interface is called perliso9660 (this file) and is generated via SWIG.
874
Number of bytes in an ISO 9660 block (2048)
878
"Primary Volume Descriptor" sector (16)
882
"End Volume Descriptor" sector (17)
886
Size in bytes of the filename portion + null byte (31)
890
Maximum number of characters in a system id (32)
894
Size in bytes of the filename portion + null byte. (37)
896
=item MAX_PREPARER_ID
898
Maximum number of characters in a preparer id. (128)
900
=item MAX_ISOPATHNAME
902
Maximum number of characters in the entire ISO 9660 filename. (255)
904
=item MAX_PUBLISHER_ID
906
Maximum number of characters in a publisher id.
908
=item MAX_APPLICATION_ID
910
Maximum number of characters in an application id.
914
Maximum number of characters in a volume id.
916
=item MAX_VOLUMESET_ID
918
Maximum number of characters in a volume-set id.
922
String inside frame which identifies an ISO 9660 filesystem. This
923
string is the "id" field of an iso9660_pvd_t or an iso9660_svd_t.
925
=item EXTENSION_JOLIET_LEVEL1
929
=item EXTENSION_JOLIET_LEVEL2
933
=item EXTENSION_JOLIET_LEVEL3
937
=item EXTENSION_ROCK_RIDGE
939
Use Rock-Ridge Extensions.
941
=item EXTENSION_HIGH_SIERRA
943
Use High-Sierra Extensions.
947
Use any of the above extensions.
951
Use none of the above extensions.
953
=item EXTENSION_JOLIET
955
Use any Joliet Extension available.
959
=head2 Directory Flags
965
Not really a flag but the lack of one.
969
Do not make existence known (hidden).
973
This file is a directory.
977
This file is an associated file
981
Record format is in extended attribute if not set.
985
No read/execute permission in extended attribute.
997
Not the final entry of a multi-extent file.
1001
=head2 Volume Descriptor Types
1005
=item VD_BOOT_RECORD
1011
Primary Volume descriptor which must be in any ISO-9660
1013
=item VD_SUPPLEMENTARY
1015
(optional) Supplimentary Volume Descriptor. But used by Joliet, for
1020
Indicates a partition of a CD.
1026
=head2 Flags for strncpy
1032
Enumeration meaning don not check in strncpy_pad.
1036
Enumeration in strncpy_pad for checking entry has only 7-bit characters.
1041
Enumeration in strncpy_pad for checking entry has only ACHARs.
1045
Enumeration in strncpy_pad for checking entry has only DCHARs.
1055
Open an ISO 9660 image for reading. Maybe in the future we will have
1056
mode. undef is returned on error.
1060
Open an ISO 9660 image for reading allowing various ISO 9660
1061
extensions. Maybe in the future we will have a mode. undef is
1066
Open an ISO 9660 image for reading with some tolerence for positioning
1067
of the ISO9660 image. We scan for $perliso9660::ISO_STANDARD_ID and
1068
use that to set he eventual offset to adjust by (as long as that is <=
1071
Maybe in the future we will have a mode. undef is returned on error.
1075
=head3 open_fuzzy_ext
1077
Open an ISO 9660 image for reading with some tolerence for positioning
1078
of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set
1079
the eventual offset to adjust by (as long as that is <= i_fuzz).
1081
Maybe in the future we will have a mode. undef is returned on error.
1083
=head3 ifs_fuzzy_read_superblock
1085
Read the Super block of an ISO 9660 image but determine framesize
1086
and datastart and a possible additional offset. Generally here we are
1087
not reading an ISO 9660 image but a CD-Image which contains an ISO 9660
1092
Close previously opened ISO 9660 image.
1093
1 is unconditionally returned. If there was an error 0 would
1098
Seek to a position and then read n bytes. (buffer, size) are is returned.
1102
Read the Primary Volume Descriptor for a CD.
1103
1 is returned if read, and 0 if there was an error.
1107
Read the Primary Volume Descriptor for an ISO 9660 image.
1108
1 is returned if read, and 0 if there was an error.
1110
=head3 _fs_read_superblock
1112
Read the Super block of an ISO 9660 image. This is the
1113
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
1114
Descriptor if (Joliet) extensions are acceptable.
1116
=head3 ifs_read_superblock
1118
Read the Super block of an ISO 9660 image. This is the
1119
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
1120
Descriptor if (Joliet) extensions are acceptable.
1122
=head2 Time Conversion
1126
Set time in format used in ISO 9660 directory index record
1127
from a Unix time structure.
1132
Set "long" time in format used in ISO 9660 primary volume descriptor
1133
from a Unix time structure.
1137
Get Unix time structure from format use in an ISO 9660 directory index
1138
record. Even though tm_wday and tm_yday fields are not explicitly in
1139
dtime, they are calculated from the other fields.
1141
If tm is to reflect the localtime, set "use_localtime" 1, otherwise
1142
tm will reported in GMT.
1146
Get "long" time in format used in ISO 9660 primary volume descriptor
1147
from a Unix time structure.
1149
=head2 Character Classification and String Manipulation
1153
Return 1 if c (an int) is a DCHAR - a character that can appear in an an
1154
ISO-9600 level 1 directory name. These are the ASCII capital
1155
letters A-Z, the digits 0-9 and an underscore.
1159
=head3 name_translate
1161
Convert an ISO-9660 file name that stored in a directory entry into
1162
what is usually listed as the file name in a listing.
1163
wercase name, and remove trailing ;1's or .;1's and
1164
turn the others into version numbers.
1166
=head3 name_translate_ext
1168
Convert an ISO-9660 file name that stored in a directory entry into
1169
what is usually listed as the file name in a listing. Lowercase
1170
name if no Joliet Extension interpretation. Remove trailing ;1's or
1171
.;1's and turn the others into version numbers.
1175
Pad string src with spaces to size len and copy this to dst. If len is
1176
less than the length of src, dst will be truncated to the first len
1179
src can also be scanned to see if it contains only ACHARs, DCHARs,
1180
7-bit ASCII chars depending on the enumeration _check.
1182
In addition to getting changed, dst is the return value. Note: this
1183
string might not be undef terminated.
1185
=head2 File and Directory Names
1187
=head3 dirname_valid_p
1189
Check that psz_path is a valid ISO-9660 directory name.
1191
A valid directory name should not start out with a slash (/),
1192
dot (.) or null byte, should be less than 37 characters long,
1193
have no more than 8 characters in a directory component
1194
which is separated by a /, and consist of only DCHARs.
1196
1 is returned if psz_path is valid.
1198
=head3 pathname_isofy
1200
Take psz_path and a version number and turn that into a ISO-9660
1201
pathname. (That is just the pathname followed by ";" and the version
1202
number. For example, mydir/file.ext -> MYDIR/FILE.EXT;1 for version
1203
1. The resulting ISO-9660 pathname is returned.
1205
=head3 pathname_valid_p
1207
Check that psz_path is a valid ISO-9660 pathname.
1209
A valid pathname contains a valid directory name, if one appears and
1210
the filename portion should be no more than 8 characters for the
1211
file prefix and 3 characters in the extension (or portion after a
1212
dot). There should be exactly one dot somewhere in the filename
1213
portion and the filename should be composed of only DCHARs.
1215
1 is returned if psz_path is valid.
1219
Given a directory pointer, find the filesystem entry that contains
1220
lsn and return information about it.
1222
Returns stat_t of entry if we found lsn, or undef otherwise.
1226
Given a directory pointer, find the filesystem entry that contains
1227
lsn and return information about it.
1229
Returns stat_t of entry if we found lsn, or undef otherwise.
1233
Return file status for psz_path. undef is returned on error.
1235
=head3 fs_stat_translate
1237
Return file status for path name psz_path. undef is returned on error.
1238
pathname version numbers in the ISO 9660 name are dropped, i.e. ;1
1239
is removed and if level 1 ISO-9660 names are lowercased.
1243
Return file status for pathname. undef is returned on error.
1245
=head3 ifs_stat_translate
1247
Return file status for path name psz_path. undef is returned on
1248
error. pathname version numbers in the ISO 9660 name are dropped,
1249
i.e. ;1 is removed and if level 1 ISO-9660 names are lowercased.
1254
Read psz_path (a directory) and return a list of iso9660_stat_t
1255
pointers for the files inside that directory. The caller must free the
1260
Read psz_path (a directory) and return a list of iso9660_stat_t
1261
pointers for the files inside that directory. The caller must free
1262
the returned result.
1266
Return the directory name stored in the iso9660_dir_t
1268
A string is allocated: the caller must deallocate.
1272
=head3 get_posix_filemode
1274
Returns a POSIX mode for a given p_iso_dirent.
1276
=head2 Primary Volume Descriptor Routines
1278
=head3 get_application_id
1280
Return the PVD's application ID.
1282
undef is returned if there is some problem in getting this.
1284
=head3 ifs_get_application_id
1286
Get the application ID. psz_app_id is set to undef if there
1287
is some problem in getting this and 0 is returned.
1289
=head3 get_preparer_id
1291
Return a string containing the preparer id with trailing
1294
=head3 ifs_get_preparer_id
1296
Get the preparer ID. psz_preparer_id is set to undef if there
1297
is some problem in getting this and 0 is returned.
1299
=head3 get_publisher_id
1301
Return a string containing the PVD's publisher id with trailing
1304
=head3 ifs_get_publisher_id
1306
Get the publisher ID. psz_publisher_id is set to undef if there
1307
is some problem in getting this and 0 is returned.
1313
=head3 get_pvd_space_size
1315
=head3 get_pvd_block_size
1317
=head3 get_pvd_version
1319
Return the primary volume id version number (of pvd).
1320
If there is an error 0 is returned.
1322
=head3 get_system_id
1324
Return a string containing the PVD's system id with trailing
1327
=head3 ifs_get_system_id
1329
Get the system ID. psz_system_id is set to undef if there
1330
is some problem in getting this and 0 is returned.
1334
Return the LSN of the root directory for pvd.
1335
If there is an error CDIO_INVALID_LSN is returned.
1337
=head3 get_volume_id
1339
Return the PVD's volume ID.
1341
=head3 ifs_get_volume_id
1343
Get the system ID. psz_system_id is set to undef if there
1344
s some problem in getting this and 0 is returned.
1346
=head3 get_volumeset_id
1348
Return the PVD's volumeset ID.
1349
undef is returned if there is some problem in getting this.
1351
=head3 ifs_get_volumeset_id
1353
Get the systemset ID. psz_systemset_id is set to undef if there
1354
is some problem in getting this and 0 is returned.
1356
=head2 Path Table Routines
1358
=head3 iso9660_pathtable_init
1360
Zero out pathable. Do this first.
1362
=head3 pathtable_get_size
1364
=head3 pathtable_l_add_entry
1366
=head3 pathtable_m_add_entry
1370
=head2 Miscellaneous
1372
=head3 get_joliet_level
1374
Return the Joliet level recognized for p_iso.
1378
Return 1 if ISO 9660 image has extended attrributes (XA).
1384
This seems to be an artifact of SWIG.
1388
L<http://www.gnu.org/software/libcdio> has documentation on
1389
libcdio including the a manual and the API via doxygen.
1393
Rocky Bernstein C<< <rocky at cpan.org> >>.
1397
Copyright (C) 2006, 2008, 2011 Rocky Bernstein <rocky@cpan.org>
1399
This program is free software: you can redistribute it and/or modify
1400
it under the terms of the GNU General Public License as published by
1401
the Free Software Foundation, either version 3 of the License, or
1402
(at your option) any later version.
1404
This program is distributed in the hope that it will be useful,
1405
but WITHOUT ANY WARRANTY; without even the implied warranty of
1406
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1407
GNU General Public License for more details.
1409
You should have received a copy of the GNU General Public License
1410
along with this program. If not, see <http://www.gnu.org/licenses/>.