| 1 |
/* -*- c -*- |
| 2 |
See end for copyright and license. |
| 3 |
*/ |
| 4 |
%define DOCSTRING |
| 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." |
| 8 |
%enddef |
| 9 |
%module(docstring=DOCSTRING) perliso9660 |
| 10 |
|
| 11 |
%{ |
| 12 |
/* Includes the header in the wrapper code */ |
| 13 |
#include <time.h> |
| 14 |
#include <cdio/types.h> |
| 15 |
#include <cdio/iso9660.h> |
| 16 |
#include <cdio/version.h> |
| 17 |
%} |
| 18 |
|
| 19 |
#include <time.h> |
| 20 |
#include <cdio/iso9660.h> |
| 21 |
#include <cdio/version.h> |
| 22 |
|
| 23 |
/* Various libcdio constants and typedefs */ |
| 24 |
%include "types.swg" |
| 25 |
|
| 26 |
%include "typemaps.i" |
| 27 |
|
| 28 |
typedef uint8_t iso_extension_mask_t; |
| 29 |
|
| 30 |
%constant long int ISO_BLOCKSIZE = CDIO_CD_FRAMESIZE; |
| 31 |
%constant long int PVD_SECTOR = ISO_PVD_SECTOR ; |
| 32 |
%constant long int EVD_SECTOR = ISO_EVD_SECTOR ; |
| 33 |
%constant long int LEN_ISONAME = LEN_ISONAME; |
| 34 |
%constant long int MAX_SYSTEM_ID = ISO_MAX_SYSTEM_ID ; |
| 35 |
%constant long int MAX_ISONAME = MAX_ISONAME; |
| 36 |
%constant long int MAX_PREPARER_ID = ISO_MAX_PREPARER_ID ; |
| 37 |
%constant long int MAX_ISOPATHNAME = MAX_ISOPATHNAME; |
| 38 |
|
| 39 |
%constant long int FILE = ISO_FILE; |
| 40 |
%constant long int EXISTENCE = ISO_EXISTENCE; |
| 41 |
%constant long int DIRECTORY = ISO_DIRECTORY; |
| 42 |
%constant long int ASSOCIATED = ISO_ASSOCIATED; |
| 43 |
%constant long int RECORD = ISO_RECORD; |
| 44 |
%constant long int PROTECTION = ISO_PROTECTION; |
| 45 |
%constant long int DRESERVED1 = ISO_DRESERVED1; |
| 46 |
%constant long int DRESERVED2 = ISO_DRESERVED2; |
| 47 |
%constant long int MULTIEXTENT = ISO_MULTIEXTENT; |
| 48 |
|
| 49 |
%constant long int VD_BOOT_RECORD = ISO_VD_BOOT_RECORD; |
| 50 |
%constant long int VD_PRIMARY = ISO_VD_PRIMARY; |
| 51 |
%constant long int VD_SUPPLEMENTARY = ISO_VD_SUPPLEMENTARY; |
| 52 |
%constant long int VD_PARITION = ISO_VD_PARITION; |
| 53 |
%constant long int VD_END = ISO_VD_END; |
| 54 |
|
| 55 |
%constant long int MAX_PUBLISHER_ID = ISO_MAX_PUBLISHER_ID; |
| 56 |
%constant long int MAX_APPLICATION_ID = ISO_MAX_APPLICATION_ID; |
| 57 |
%constant long int MAX_VOLUME_ID = ISO_MAX_VOLUME_ID; |
| 58 |
%constant long int MAX_VOLUMESET_ID = ISO_MAX_VOLUMESET_ID; |
| 59 |
%constant long int STANDARD_ID = ISO_STANDARD_ID; |
| 60 |
|
| 61 |
%constant long int NOCHECK = ISO9660_NOCHECK; |
| 62 |
%constant long int SEVEN_BIT = ISO9660_7BIT; |
| 63 |
%constant long int ACHARS = ISO9660_ACHARS; |
| 64 |
%constant long int DCHARS = ISO9660_DCHARS; |
| 65 |
|
| 66 |
%constant long int EXTENSION_JOLIET_LEVEL1 = ISO_EXTENSION_JOLIET_LEVEL1; |
| 67 |
%constant long int EXTENSION_JOLIET_LEVEL2 = ISO_EXTENSION_JOLIET_LEVEL2; |
| 68 |
%constant long int EXTENSION_JOLIET_LEVEL3 = ISO_EXTENSION_JOLIET_LEVEL3; |
| 69 |
%constant long int EXTENSION_ROCK_RIDGE = ISO_EXTENSION_ROCK_RIDGE; |
| 70 |
%constant long int EXTENSION_HIGH_SIERRA = ISO_EXTENSION_HIGH_SIERRA; |
| 71 |
|
| 72 |
%constant long int EXTENSION_ALL = ISO_EXTENSION_ALL; |
| 73 |
%constant long int EXTENSION_NONE = ISO_EXTENSION_NONE; |
| 74 |
%constant long int EXTENSION_JOLIET = ISO_EXTENSION_JOLIET; |
| 75 |
|
| 76 |
/* Set up to allow functions to return stat lists of type "stat |
| 77 |
*". We'll use a typedef so we can make sure to isolate this. |
| 78 |
*/ |
| 79 |
%inline %{ |
| 80 |
typedef CdioList_t IsoStatList_t; |
| 81 |
typedef iso9660_stat_t IsoStat_t; |
| 82 |
%} |
| 83 |
typedef CdioList_t IsoStatList_t; |
| 84 |
typedef iso9660_stat_t IsoStat_t; |
| 85 |
|
| 86 |
%typemap(out) IsoStat_t *{ |
| 87 |
// $1 is of type IsoStatList_t |
| 88 |
iso9660_stat_t *p_statbuf = result; |
| 89 |
|
| 90 |
if (!result) goto out; |
| 91 |
|
| 92 |
PPCODE: |
| 93 |
/* Have Perl compute the length of the string using strlen() */ |
| 94 |
XPUSHs(sv_2mortal(newSVpv(p_statbuf->filename, 0))); |
| 95 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->lsn))); |
| 96 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->size))); |
| 97 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->secsize))); |
| 98 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->type))); |
| 99 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_sec))); |
| 100 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_min))); |
| 101 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_hour))); |
| 102 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_mday))); |
| 103 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_mon))); |
| 104 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_year))); |
| 105 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_wday))); |
| 106 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_yday))); |
| 107 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_isdst))); |
| 108 |
argvi += 16; |
| 109 |
free (p_statbuf); |
| 110 |
out: ; |
| 111 |
} |
| 112 |
|
| 113 |
%typemap(out) IsoStatList_t *{ |
| 114 |
// $1 is of type IsoStatList_t |
| 115 |
CdioISO9660FileList_t *p_entlist = result; |
| 116 |
CdioListNode_t *p_entnode; |
| 117 |
unsigned int num = 0; |
| 118 |
|
| 119 |
if (!result) goto out; |
| 120 |
|
| 121 |
PPCODE: |
| 122 |
/* For each element in the array of strings, create a new |
| 123 |
* mortalscalar, and stuff it into the above array. */ |
| 124 |
_CDIO_LIST_FOREACH (p_entnode, p_entlist) { |
| 125 |
iso9660_stat_t *p_statbuf = |
| 126 |
(iso9660_stat_t *) _cdio_list_node_data (p_entnode); |
| 127 |
/* Have perl compute the length of the string using strlen() */ |
| 128 |
XPUSHs(sv_2mortal(newSVpv(p_statbuf->filename, 0))); |
| 129 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->lsn))); |
| 130 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->size))); |
| 131 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->secsize))); |
| 132 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->type))); |
| 133 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_sec))); |
| 134 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_min))); |
| 135 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_hour))); |
| 136 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_mday))); |
| 137 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_mon))); |
| 138 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_year))); |
| 139 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_wday))); |
| 140 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_yday))); |
| 141 |
XPUSHs(sv_2mortal(newSViv(p_statbuf->tm.tm_isdst))); |
| 142 |
num += 14; |
| 143 |
} |
| 144 |
iso9660_filelist_free(p_entlist); |
| 145 |
argvi += num + 2; |
| 146 |
out: ; |
| 147 |
} |
| 148 |
|
| 149 |
/*! |
| 150 |
Open an ISO 9660 image for reading. Maybe in the future we will have |
| 151 |
a mode. NULL is returned on error. |
| 152 |
*/ |
| 153 |
%rename iso9660_open open_iso; |
| 154 |
iso9660_t *iso9660_open (const char *psz_path /*flags, mode */); |
| 155 |
|
| 156 |
/*! |
| 157 |
Open an ISO 9660 image for reading allowing various ISO 9660 |
| 158 |
extensions. Maybe in the future we will have a mode. NULL is |
| 159 |
returned on error. |
| 160 |
*/ |
| 161 |
%rename iso9660_open_ext open_ext; |
| 162 |
iso9660_t *iso9660_open_ext (const char *psz_path, |
| 163 |
iso_extension_mask_t iso_extension_mask); |
| 164 |
|
| 165 |
/*! |
| 166 |
Open an ISO 9660 image for reading with some tolerence for positioning |
| 167 |
of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set |
| 168 |
the eventual offset to adjust by (as long as that is <= i_fuzz). |
| 169 |
|
| 170 |
Maybe in the future we will have a mode. NULL is returned on error. |
| 171 |
|
| 172 |
@see iso9660_open |
| 173 |
*/ |
| 174 |
%rename iso9660_open_fuzzy open_fuzzy; |
| 175 |
iso9660_t *iso9660_open_fuzzy (const char *psz_path /*flags, mode */, |
| 176 |
uint16_t i_fuzz); |
| 177 |
|
| 178 |
/*! |
| 179 |
Open an ISO 9660 image for reading with some tolerence for positioning |
| 180 |
of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set |
| 181 |
the eventual offset to adjust by (as long as that is <= i_fuzz). |
| 182 |
|
| 183 |
Maybe in the future we will have a mode. NULL is returned on error. |
| 184 |
|
| 185 |
@see iso9660_open |
| 186 |
*/ |
| 187 |
%rename iso9660_open_fuzzy open_fuzzy_ext; |
| 188 |
iso9660_t *iso9660_open_fuzzy_ext (const char *psz_path, |
| 189 |
iso_extension_mask_t iso_extension_mask, |
| 190 |
uint16_t i_fuzz |
| 191 |
/*flags, mode */); |
| 192 |
/*! |
| 193 |
Read the Super block of an ISO 9660 image but determine framesize |
| 194 |
and datastart and a possible additional offset. Generally here we are |
| 195 |
not reading an ISO 9660 image but a CD-Image which contains an ISO 9660 |
| 196 |
filesystem. |
| 197 |
*/ |
| 198 |
%rename iso9660_ifs_fuzzy_read_superblock ifs_fuzzy_read_superblock; |
| 199 |
bool iso9660_ifs_fuzzy_read_superblock (iso9660_t *p_iso, |
| 200 |
iso_extension_mask_t iso_extension_mask, |
| 201 |
uint16_t i_fuzz); |
| 202 |
/*! |
| 203 |
Close previously opened ISO 9660 image. |
| 204 |
True is unconditionally returned. If there was an error false would |
| 205 |
be returned. |
| 206 |
*/ |
| 207 |
%rename iso9660_close close; |
| 208 |
bool iso9660_close (iso9660_t * p_iso); |
| 209 |
|
| 210 |
%typemap(out) buf_t { |
| 211 |
/* $1 is of type buf_t */ |
| 212 |
ST(argvi) = sv_newmortal(); |
| 213 |
if (result) { |
| 214 |
/* I don't yet know how to pick up arg4 another way. |
| 215 |
THIS MEANS ARG3 MUST ALWAYS BE THE SIZE. */ |
| 216 |
sv_setpvn((SV*)ST(argvi++), (char *) result, *arg4); |
| 217 |
/* Don't leak memory. return value was malloc'd by libcdio. */ |
| 218 |
/* free(result); */ |
| 219 |
} else { |
| 220 |
sv_setsv((SV*)ST(argvi++), &PL_sv_undef); |
| 221 |
} |
| 222 |
} |
| 223 |
%inline %{ |
| 224 |
typedef long int my_ssize_t; |
| 225 |
%} |
| 226 |
%apply my_ssize_t *OUTPUT { my_ssize_t *pi_size }; |
| 227 |
|
| 228 |
/*! Seek to a position and then read n bytes. (buffer, size) are |
| 229 |
returned. |
| 230 |
*/ |
| 231 |
%newobject seek_read; // free malloc'd return value |
| 232 |
typedef char *buf_t; |
| 233 |
buf_t seek_read (const iso9660_t *p_iso, |
| 234 |
lsn_t start, long int i_size, |
| 235 |
/*out*/ my_ssize_t *pi_size); |
| 236 |
%inline %{ |
| 237 |
typedef char *buf_t; |
| 238 |
buf_t seek_read (const iso9660_t *p_iso, |
| 239 |
lsn_t start, long int i_size, |
| 240 |
/*out*/ my_ssize_t *pi_size) { |
| 241 |
|
| 242 |
char *p_buf = calloc(ISO_BLOCKSIZE, i_size); |
| 243 |
*pi_size = iso9660_iso_seek_read(p_iso, p_buf, start, i_size); |
| 244 |
return p_buf; |
| 245 |
} |
| 246 |
%} |
| 247 |
|
| 248 |
|
| 249 |
/*! |
| 250 |
Read the Primary Volume Descriptor for a CD. |
| 251 |
True is returned if read, and false if there was an error. |
| 252 |
*/ |
| 253 |
iso9660_pvd_t *fs_read_pvd ( const CdIo_t *p_cdio ); |
| 254 |
%inline %{ |
| 255 |
iso9660_pvd_t *fs_read_pvd ( const CdIo_t *p_cdio ) { |
| 256 |
static iso9660_pvd_t pvd; |
| 257 |
bool b_ok = iso9660_fs_read_pvd ( p_cdio, &pvd ); |
| 258 |
if (!b_ok) return NULL; |
| 259 |
return &pvd; |
| 260 |
} |
| 261 |
%} |
| 262 |
|
| 263 |
/*! |
| 264 |
Read the Primary Volume Descriptor for an ISO 9660 image. |
| 265 |
True is returned if read, and false if there was an error. |
| 266 |
*/ |
| 267 |
iso9660_pvd_t *ifs_read_pvd ( const iso9660_t *p_iso ); |
| 268 |
%inline %{ |
| 269 |
iso9660_pvd_t *ifs_read_pvd ( const iso9660_t *p_iso ) { |
| 270 |
static iso9660_pvd_t pvd; |
| 271 |
bool b_ok = iso9660_ifs_read_pvd ( p_iso, &pvd ); |
| 272 |
if (!b_ok) return NULL; |
| 273 |
return &pvd; |
| 274 |
} |
| 275 |
%} |
| 276 |
|
| 277 |
/*! |
| 278 |
Read the Super block of an ISO 9660 image. This is the |
| 279 |
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume |
| 280 |
Descriptor if (Joliet) extensions are acceptable. |
| 281 |
*/ |
| 282 |
%rename iso9660_fs_read_superblock fs_read_superblock; |
| 283 |
bool iso9660_fs_read_superblock (CdIo_t *p_cdio, |
| 284 |
iso_extension_mask_t iso_extension_mask); |
| 285 |
|
| 286 |
/*! |
| 287 |
Read the Super block of an ISO 9660 image. This is the |
| 288 |
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume |
| 289 |
Descriptor if (Joliet) extensions are acceptable. |
| 290 |
*/ |
| 291 |
%rename iso9660_ifs_read_superblock ifs_read_superblock; |
| 292 |
bool iso9660_ifs_read_superblock (iso9660_t *p_iso, |
| 293 |
iso_extension_mask_t iso_extension_mask); |
| 294 |
|
| 295 |
|
| 296 |
/*==================================================== |
| 297 |
Time conversion |
| 298 |
====================================================*/ |
| 299 |
/*! |
| 300 |
Set time in format used in ISO 9660 directory index record |
| 301 |
from a Unix time structure. */ |
| 302 |
iso9660_dtime_t * |
| 303 |
set_dtime ( int tm_sec, int tm_min, int tm_hour, int tm_mday, int tm_mon, |
| 304 |
int tm_year); |
| 305 |
%inline %{ |
| 306 |
iso9660_dtime_t * |
| 307 |
set_dtime ( int tm_sec, int tm_min, int tm_hour, int tm_mday, int tm_mon, |
| 308 |
int tm_year) |
| 309 |
{ |
| 310 |
struct tm tm = { tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, 0, 0, 0 }; |
| 311 |
static iso9660_dtime_t dtime; |
| 312 |
iso9660_set_dtime (&tm, &dtime); |
| 313 |
return &dtime; |
| 314 |
} |
| 315 |
%} |
| 316 |
|
| 317 |
/*! |
| 318 |
Set "long" time in format used in ISO 9660 primary volume descriptor |
| 319 |
from a Unix time structure. */ |
| 320 |
iso9660_ltime_t * |
| 321 |
set_ltime ( int tm_sec, int tm_min, int tm_hour, int tm_mday, int tm_mon, |
| 322 |
int tm_year); |
| 323 |
|
| 324 |
%inline %{ |
| 325 |
iso9660_ltime_t * |
| 326 |
set_ltime ( int tm_sec, int tm_min, int tm_hour, int tm_mday, int tm_mon, |
| 327 |
int tm_year) |
| 328 |
|
| 329 |
{ |
| 330 |
struct tm tm = { tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, 0, 0, 0 }; |
| 331 |
static iso9660_ltime_t ldate; |
| 332 |
iso9660_set_ltime (&tm, &ldate); |
| 333 |
return &ldate; |
| 334 |
} |
| 335 |
%} |
| 336 |
|
| 337 |
/*! |
| 338 |
Get Unix time structure from format use in an ISO 9660 directory index |
| 339 |
record. Even though tm_wday and tm_yday fields are not explicitly in |
| 340 |
dtime, they are calculated from the other fields. |
| 341 |
|
| 342 |
If tm is to reflect the localtime, set "use_localtime" true, otherwise |
| 343 |
tm will reported in GMT. |
| 344 |
*/ |
| 345 |
%apply int *OUTPUT { int *tm_sec, int *tm_min, int *tm_hour, int *tm_mday, |
| 346 |
int *tm_mon, int *tm_year, int *tm_wday, int *tm_yday, |
| 347 |
int *tm_isdst }; |
| 348 |
|
| 349 |
bool get_dtime (const iso9660_dtime_t *dtime, bool use_localtime, |
| 350 |
int *tm_sec, int *tm_min, int *tm_hour, int *tm_mday, |
| 351 |
int *tm_mon, int *tm_year, int *tm_wday, int *tm_yday, |
| 352 |
int *tm_isdst); |
| 353 |
|
| 354 |
%inline %{ |
| 355 |
bool get_dtime (const iso9660_dtime_t *dtime, bool use_localtime, |
| 356 |
int *tm_sec, int *tm_min, int *tm_hour, int *tm_mday, |
| 357 |
int *tm_mon, int *tm_year, int *tm_wday, int *tm_yday, |
| 358 |
int *tm_isdst) |
| 359 |
{ |
| 360 |
struct tm tm; |
| 361 |
bool b_okay = iso9660_get_dtime (dtime, use_localtime, &tm); |
| 362 |
if (b_okay) { |
| 363 |
*tm_sec = tm.tm_sec; |
| 364 |
*tm_min = tm.tm_min; |
| 365 |
*tm_hour = tm.tm_hour; |
| 366 |
*tm_mon = tm.tm_mon; |
| 367 |
*tm_mday = tm.tm_mday; |
| 368 |
*tm_year = tm.tm_year; |
| 369 |
*tm_wday = tm.tm_wday; |
| 370 |
*tm_yday = tm.tm_yday; |
| 371 |
*tm_isdst = tm.tm_isdst; |
| 372 |
} |
| 373 |
return b_okay; |
| 374 |
} |
| 375 |
%} |
| 376 |
|
| 377 |
/*! |
| 378 |
Get "long" time in format used in ISO 9660 primary volume descriptor |
| 379 |
from a Unix time structure. |
| 380 |
*/ |
| 381 |
bool get_ltime (const iso9660_ltime_t *dtime, |
| 382 |
int *tm_sec, int *tm_min, int *tm_hour, int *tm_mday, |
| 383 |
int *tm_mon, int *tm_year, int *tm_wday, int *tm_yday, |
| 384 |
int *tm_isdst); |
| 385 |
|
| 386 |
%inline %{ |
| 387 |
bool get_ltime (const iso9660_ltime_t *p_ldate, |
| 388 |
int *tm_sec, int *tm_min, int *tm_hour, int *tm_mday, |
| 389 |
int *tm_mon, int *tm_year, int *tm_wday, int *tm_yday, |
| 390 |
int *tm_isdst) |
| 391 |
{ |
| 392 |
struct tm tm; |
| 393 |
bool b_okay = iso9660_get_ltime (p_ldate, &tm); |
| 394 |
if (b_okay) { |
| 395 |
*tm_sec = tm.tm_sec; |
| 396 |
*tm_min = tm.tm_min; |
| 397 |
*tm_hour = tm.tm_hour; |
| 398 |
*tm_mon = tm.tm_mon; |
| 399 |
*tm_mday = tm.tm_mday; |
| 400 |
*tm_year = tm.tm_year; |
| 401 |
*tm_wday = tm.tm_wday; |
| 402 |
*tm_yday = tm.tm_yday; |
| 403 |
*tm_isdst = tm.tm_isdst; |
| 404 |
} |
| 405 |
return b_okay; |
| 406 |
} |
| 407 |
%} |
| 408 |
|
| 409 |
|
| 410 |
/*======================================================== |
| 411 |
Characters used in file and directory and manipulation |
| 412 |
=======================================================*/ |
| 413 |
/*! |
| 414 |
Return true if c is a DCHAR - a character that can appear in an an |
| 415 |
ISO-9600 level 1 directory name. These are the ASCII capital |
| 416 |
letters A-Z, the digits 0-9 and an underscore. |
| 417 |
*/ |
| 418 |
%rename iso9660_isdchar is_dchar; |
| 419 |
bool iso9660_isdchar (int c); |
| 420 |
|
| 421 |
/*! |
| 422 |
Return true if c is an ACHAR - |
| 423 |
These are the DCHAR's plus some ASCII symbols including the space |
| 424 |
symbol. |
| 425 |
*/ |
| 426 |
%rename iso9660_isachar is_achar; |
| 427 |
bool iso9660_isachar (int c); |
| 428 |
|
| 429 |
/*! |
| 430 |
Convert an ISO-9660 file name that stored in a directory entry into |
| 431 |
what's usually listed as the file name in a listing. |
| 432 |
Lowercase name, and remove trailing ;1's or .;1's and |
| 433 |
turn the other ;'s into version numbers. |
| 434 |
|
| 435 |
@param psz_oldname the ISO-9660 filename to be translated. |
| 436 |
@param psz_newname returned string. The caller allocates this and |
| 437 |
it should be at least the size of psz_oldname. |
| 438 |
@return length of the translated string is returned. |
| 439 |
*/ |
| 440 |
%newobject name_translate; |
| 441 |
char * name_translate(const char *psz_oldname); |
| 442 |
%inline %{ |
| 443 |
char * |
| 444 |
name_translate(const char *psz_oldname) { |
| 445 |
char *psz_newname=calloc(sizeof(char), strlen(psz_oldname)+1); |
| 446 |
iso9660_name_translate(psz_oldname, psz_newname); |
| 447 |
return psz_newname; |
| 448 |
} |
| 449 |
%} |
| 450 |
|
| 451 |
/*! |
| 452 |
Convert an ISO-9660 file name that stored in a directory entry into |
| 453 |
what's usually listed as the file name in a listing. Lowercase |
| 454 |
name if no Joliet Extension interpretation. Remove trailing ;1's or |
| 455 |
.;1's and turn the other ;'s into version numbers. |
| 456 |
|
| 457 |
@param psz_oldname the ISO-9660 filename to be translated. |
| 458 |
@param psz_newname returned string. The caller allocates this and |
| 459 |
it should be at least the size of psz_oldname. |
| 460 |
@param i_joliet_level 0 if not using Joliet Extension. Otherwise the |
| 461 |
Joliet level. |
| 462 |
@return length of the translated string is returned. It will be no greater |
| 463 |
than the length of psz_oldname. |
| 464 |
*/ |
| 465 |
%newobject name_translate_ext; |
| 466 |
char * name_translate_ext(const char *psz_oldname, uint8_t i_joliet_level); |
| 467 |
%inline %{ |
| 468 |
char * |
| 469 |
name_translate_ext(const char *psz_oldname, uint8_t i_joliet_level) { |
| 470 |
char *psz_newname=calloc(sizeof(char), strlen(psz_oldname)+1); |
| 471 |
iso9660_name_translate_ext(psz_oldname, psz_newname, i_joliet_level); |
| 472 |
return psz_newname; |
| 473 |
} |
| 474 |
%} |
| 475 |
|
| 476 |
/*! |
| 477 |
Pad string src with spaces to size len and copy this to dst. If |
| 478 |
len is less than the length of src, dst will be truncated to the |
| 479 |
first len characters of src. |
| 480 |
|
| 481 |
src can also be scanned to see if it contains only ACHARs, DCHARs, |
| 482 |
7-bit ASCII chars depending on the enumeration _check. |
| 483 |
|
| 484 |
In addition to getting changed, dst is the return value. |
| 485 |
Note: this string might not be NULL terminated. |
| 486 |
*/ |
| 487 |
%newobject strncpy_pad; // free malloc'd return value |
| 488 |
char *strncpy_pad(const char src[], size_t len, enum strncpy_pad_check _check); |
| 489 |
%inline %{ |
| 490 |
char * |
| 491 |
strncpy_pad(const char src[], size_t len, enum strncpy_pad_check _check) { |
| 492 |
char *dst = calloc(sizeof(char), len+1); |
| 493 |
return iso9660_strncpy_pad(dst, src, len, _check); |
| 494 |
} |
| 495 |
%} |
| 496 |
|
| 497 |
/*===================================================================== |
| 498 |
Files and Directory Names |
| 499 |
======================================================================*/ |
| 500 |
|
| 501 |
/*! |
| 502 |
Check that psz_path is a valid ISO-9660 directory name. |
| 503 |
|
| 504 |
A valid directory name should not start out with a slash (/), |
| 505 |
dot (.) or null byte, should be less than 37 characters long, |
| 506 |
have no more than 8 characters in a directory component |
| 507 |
which is separated by a /, and consist of only DCHARs. |
| 508 |
|
| 509 |
True is returned if psz_path is valid. |
| 510 |
*/ |
| 511 |
%rename iso9660_dirname_valid_p dirname_valid_p; |
| 512 |
bool iso9660_dirname_valid_p (const char psz_path[]); |
| 513 |
|
| 514 |
/*! |
| 515 |
Take psz_path and a version number and turn that into a ISO-9660 |
| 516 |
pathname. (That's just the pathname followed by ";" and the version |
| 517 |
number. For example, mydir/file.ext -> MYDIR/FILE.EXT;1 for version |
| 518 |
1. The resulting ISO-9660 pathname is returned. |
| 519 |
*/ |
| 520 |
%rename iso9660_pathname_isofy pathname_isofy; |
| 521 |
%newobject iso9660_pathname_isofy; // free malloc'd return value |
| 522 |
char *iso9660_pathname_isofy (const char psz_path[], uint16_t i_version); |
| 523 |
|
| 524 |
/*! |
| 525 |
Check that psz_path is a valid ISO-9660 pathname. |
| 526 |
|
| 527 |
A valid pathname contains a valid directory name, if one appears and |
| 528 |
the filename portion should be no more than 8 characters for the |
| 529 |
file prefix and 3 characters in the extension (or portion after a |
| 530 |
dot). There should be exactly one dot somewhere in the filename |
| 531 |
portion and the filename should be composed of only DCHARs. |
| 532 |
|
| 533 |
True is returned if psz_path is valid. |
| 534 |
*/ |
| 535 |
%rename iso9660_pathname_valid_p pathname_valid_p; |
| 536 |
bool iso9660_pathname_valid_p (const char psz_path[]); |
| 537 |
|
| 538 |
/* ... */ |
| 539 |
|
| 540 |
/*! |
| 541 |
Given a directory pointer, find the filesystem entry that contains |
| 542 |
lsn and return information about it. |
| 543 |
|
| 544 |
Returns stat_t of entry if we found lsn, or NULL otherwise. |
| 545 |
*/ |
| 546 |
%rename iso9660_fs_find_lsn fs_find_lsn; |
| 547 |
IsoStat_t *iso9660_fs_find_lsn(CdIo_t *p_cdio, lsn_t i_lsn); |
| 548 |
|
| 549 |
|
| 550 |
/*! |
| 551 |
Given a directory pointer, find the filesystem entry that contains |
| 552 |
lsn and return information about it. |
| 553 |
|
| 554 |
Returns stat_t of entry if we found lsn, or NULL otherwise. |
| 555 |
*/ |
| 556 |
%rename iso9660_ifs_find_lsn ifs_find_lsn; |
| 557 |
IsoStat_t *iso9660_ifs_find_lsn(iso9660_t *p_iso, lsn_t i_lsn); |
| 558 |
|
| 559 |
|
| 560 |
/*! |
| 561 |
Return file status for psz_path. NULL is returned on error. |
| 562 |
*/ |
| 563 |
%rename iso9660_fs_stat fs_stat; |
| 564 |
IsoStat_t *iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[]); |
| 565 |
|
| 566 |
|
| 567 |
/*! |
| 568 |
Return file status for path name psz_path. NULL is returned on error. |
| 569 |
pathname version numbers in the ISO 9660 name are dropped, i.e. ;1 |
| 570 |
is removed and if level 1 ISO-9660 names are lowercased. |
| 571 |
|
| 572 |
The b_mode2 parameter is not used. |
| 573 |
*/ |
| 574 |
%rename iso9660_fs_stat_translate fs_stat_translate; |
| 575 |
IsoStat_t *iso9660_fs_stat_translate (CdIo_t *p_cdio, |
| 576 |
const char psz_path[]); |
| 577 |
|
| 578 |
/*! |
| 579 |
Return file status for pathname. NULL is returned on error. |
| 580 |
*/ |
| 581 |
%rename iso9660_ifs_stat ifs_stat; |
| 582 |
IsoStat_t *iso9660_ifs_stat (iso9660_t *p_iso, const char psz_path[]); |
| 583 |
|
| 584 |
|
| 585 |
/*! Return file status for path name psz_path. NULL is returned on |
| 586 |
error. pathname version numbers in the ISO 9660 name are dropped, |
| 587 |
i.e. ;1 is removed and if level 1 ISO-9660 names are lowercased. |
| 588 |
*/ |
| 589 |
%rename iso9660_ifs_stat_translate ifs_stat_translate; |
| 590 |
IsoStat_t *iso9660_ifs_stat_translate (iso9660_t *p_iso, |
| 591 |
const char psz_path[]); |
| 592 |
|
| 593 |
/*! Read psz_path (a directory) and return a list of iso9660_stat_t |
| 594 |
pointers for the files inside that directory. The caller must free the |
| 595 |
returned result. |
| 596 |
*/ |
| 597 |
%newobject fs_readdir; // free malloc'd return value |
| 598 |
IsoStatList_t *fs_readdir (CdIo_t *p_cdio, const char psz_path[]); |
| 599 |
|
| 600 |
%inline %{ |
| 601 |
IsoStatList_t *fs_readdir (CdIo_t *p_cdio, const char psz_path[]) |
| 602 |
{ |
| 603 |
CdioList_t *p_statlist = iso9660_fs_readdir (p_cdio, psz_path); |
| 604 |
return p_statlist; |
| 605 |
} |
| 606 |
%} |
| 607 |
|
| 608 |
/*! Read psz_path (a directory) and return a list of iso9660_stat_t |
| 609 |
pointers for the files inside that directory. The caller must free |
| 610 |
the returned result. |
| 611 |
*/ |
| 612 |
%newobject ifs_readdir; // free malloc'd return value |
| 613 |
IsoStatList_t *ifs_readdir (iso9660_t *p_iso, const char psz_path[]); |
| 614 |
|
| 615 |
%inline %{ |
| 616 |
IsoStatList_t *ifs_readdir (iso9660_t *p_iso, const char psz_path[]) |
| 617 |
{ |
| 618 |
CdioList_t *p_statlist = iso9660_ifs_readdir (p_iso, psz_path); |
| 619 |
return p_statlist; |
| 620 |
} |
| 621 |
%} |
| 622 |
|
| 623 |
/*! |
| 624 |
Return the PVD's application ID. |
| 625 |
NULL is returned if there is some problem in getting this. |
| 626 |
*/ |
| 627 |
%rename iso9660_get_application_id get_application_id; |
| 628 |
char * iso9660_get_application_id(iso9660_pvd_t *p_pvd); |
| 629 |
|
| 630 |
/*! |
| 631 |
Get the application ID. Return NULL if there |
| 632 |
is some problem in getting this. |
| 633 |
*/ |
| 634 |
%newobject get_application_id; // free malloc'd return value |
| 635 |
char *ifs_get_application_id(iso9660_t *p_iso); |
| 636 |
%inline %{ |
| 637 |
char * |
| 638 |
ifs_get_application_id(iso9660_t *p_iso) { |
| 639 |
char *psz; |
| 640 |
bool ok = iso9660_ifs_get_application_id(p_iso, &psz); |
| 641 |
if (!ok) return NULL; |
| 642 |
return psz; |
| 643 |
} |
| 644 |
%} |
| 645 |
|
| 646 |
|
| 647 |
/*! |
| 648 |
Return the Joliet level recognized for p_iso. |
| 649 |
*/ |
| 650 |
%rename iso9660_ifs_get_joliet_level get_joliet_level; |
| 651 |
uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso); |
| 652 |
|
| 653 |
%rename iso9660_get_dir_len get_dir_len; |
| 654 |
uint8_t iso9660_get_dir_len(const iso9660_dir_t *p_idr); |
| 655 |
|
| 656 |
/*! |
| 657 |
Return the directory name stored in the iso9660_dir_t |
| 658 |
*/ |
| 659 |
%rename iso9660_get_to_name get_to_name; |
| 660 |
%newobject iso9660_dir_to_name; // free malloc'd return value |
| 661 |
char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir); |
| 662 |
|
| 663 |
/*! |
| 664 |
Returns a POSIX mode for a given p_iso_dirent. |
| 665 |
*/ |
| 666 |
%rename iso9660_get_posix_filemode get_posix_filemode; |
| 667 |
mode_t iso9660_get_posix_filemode(const iso9660_stat_t *p_iso_dirent); |
| 668 |
|
| 669 |
/*! |
| 670 |
Return a string containing the preparer id with trailing |
| 671 |
blanks removed. |
| 672 |
*/ |
| 673 |
%rename iso9660_get_preparer_id get_preparer_id; |
| 674 |
char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd); |
| 675 |
|
| 676 |
/*! Get the preparer ID. Return NULL if there is some problem in |
| 677 |
getting this. |
| 678 |
*/ |
| 679 |
%newobject ifs_get_preparer_id; // free malloc'd return value |
| 680 |
char *ifs_get_preparer_id(iso9660_t *p_iso); |
| 681 |
%inline %{ |
| 682 |
char * |
| 683 |
ifs_get_preparer_id(iso9660_t *p_iso) { |
| 684 |
char *psz; |
| 685 |
bool ok = iso9660_ifs_get_preparer_id(p_iso, &psz); |
| 686 |
if (!ok) return NULL; |
| 687 |
return psz; |
| 688 |
} |
| 689 |
%} |
| 690 |
|
| 691 |
/*! |
| 692 |
Return a string containing the PVD's publisher id with trailing |
| 693 |
blanks removed. |
| 694 |
*/ |
| 695 |
%rename iso9660_get_publisher_id get_publisher_id; |
| 696 |
char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd); |
| 697 |
|
| 698 |
/*! |
| 699 |
Get the publisher ID. return NULL if there |
| 700 |
is some problem in getting this. |
| 701 |
*/ |
| 702 |
%newobject ifs_get_publisher_id; // free malloc'd return value |
| 703 |
char *ifs_get_publisher_id(iso9660_t *p_iso); |
| 704 |
%inline %{ |
| 705 |
char * |
| 706 |
ifs_get_publisher_id(iso9660_t *p_iso) { |
| 707 |
char *psz; |
| 708 |
bool ok = iso9660_ifs_get_publisher_id(p_iso, &psz); |
| 709 |
if (!ok) return NULL; |
| 710 |
return psz; |
| 711 |
} |
| 712 |
%} |
| 713 |
|
| 714 |
%rename iso9660_get_pvd_type get_pvd_type; |
| 715 |
uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd); |
| 716 |
|
| 717 |
%rename iso9660_get_pvd_id get_pvd_id; |
| 718 |
const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd); |
| 719 |
|
| 720 |
%rename iso9660_get_pvd_space_size get_pvd_space_size; |
| 721 |
int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd); |
| 722 |
|
| 723 |
%rename iso9660_get_pvd_block_size get_pvd_block_size; |
| 724 |
int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ; |
| 725 |
|
| 726 |
/*! Return the primary volume id version number (of pvd). |
| 727 |
If there is an error 0 is returned. |
| 728 |
*/ |
| 729 |
%rename iso9660_get_pvd_version get_pvd_version; |
| 730 |
int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ; |
| 731 |
|
| 732 |
/*! |
| 733 |
Return a string containing the PVD's system id with trailing |
| 734 |
blanks removed. |
| 735 |
*/ |
| 736 |
%rename iso9660_get_system_id get_system_id; |
| 737 |
char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd); |
| 738 |
|
| 739 |
/*! |
| 740 |
Get the system ID. return NULL if there |
| 741 |
is some problem in getting this. |
| 742 |
*/ |
| 743 |
%newobject ifs_get_system_id; // free malloc'd return value |
| 744 |
char *ifs_get_system_id(iso9660_t *p_iso); |
| 745 |
%inline %{ |
| 746 |
char * |
| 747 |
ifs_get_system_id(iso9660_t *p_iso) { |
| 748 |
char *psz; |
| 749 |
bool ok = iso9660_ifs_get_system_id(p_iso, &psz); |
| 750 |
if (!ok) return NULL; |
| 751 |
return psz; |
| 752 |
} |
| 753 |
%} |
| 754 |
|
| 755 |
/*! Return the LSN of the root directory for pvd. |
| 756 |
If there is an error CDIO_INVALID_LSN is returned. |
| 757 |
*/ |
| 758 |
%rename iso9660_get_root_lsn get_root_lsn; |
| 759 |
lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd); |
| 760 |
|
| 761 |
/*! |
| 762 |
Return the PVD's volume ID. |
| 763 |
*/ |
| 764 |
%rename iso9660_get_volume_id get_volume_id; |
| 765 |
char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd); |
| 766 |
|
| 767 |
/*! |
| 768 |
Get the system ID. return NULL if there |
| 769 |
is some problem in getting this. |
| 770 |
*/ |
| 771 |
%newobject ifs_get_volume_id; // free malloc'd return value |
| 772 |
char *ifs_get_volume_id(iso9660_t *p_iso); |
| 773 |
%inline %{ |
| 774 |
char * |
| 775 |
ifs_get_volume_id(iso9660_t *p_iso) { |
| 776 |
char *psz; |
| 777 |
bool ok = iso9660_ifs_get_volume_id(p_iso, &psz); |
| 778 |
if (!ok) return NULL; |
| 779 |
return psz; |
| 780 |
} |
| 781 |
%} |
| 782 |
|
| 783 |
/*! |
| 784 |
Return the PVD's volumeset ID. |
| 785 |
NULL is returned if there is some problem in getting this. |
| 786 |
*/ |
| 787 |
%rename iso9660_get_volumeset_id get_volumeset_id; |
| 788 |
char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd); |
| 789 |
|
| 790 |
/*! |
| 791 |
Get the volumeset ID. return NULL if there |
| 792 |
is some problem in getting this. |
| 793 |
*/ |
| 794 |
%newobject ifs_get_volumeset_id; // free malloc'd return value |
| 795 |
char *ifs_get_volumeset_id(iso9660_t *p_iso); |
| 796 |
%inline %{ |
| 797 |
char * |
| 798 |
ifs_get_volumeset_id(iso9660_t *p_iso) { |
| 799 |
char *psz; |
| 800 |
bool ok = iso9660_ifs_get_volumeset_id(p_iso, &psz); |
| 801 |
if (!ok) return NULL; |
| 802 |
return psz; |
| 803 |
} |
| 804 |
%} |
| 805 |
|
| 806 |
/* ================= pathtable ================== */ |
| 807 |
|
| 808 |
/*! Zero's out pathable. Do this first. */ |
| 809 |
%rename iso9660_pathtable_init pathtable_init; |
| 810 |
void iso9660_pathtable_init (void *pt); |
| 811 |
|
| 812 |
%rename iso9660_pathtable_get_size pathtable_get_size; |
| 813 |
unsigned int iso9660_pathtable_get_size (const void *pt); |
| 814 |
|
| 815 |
%rename iso9660_pathtable_l_add_entry pathtable_l_add_entry; |
| 816 |
uint16_t iso9660_pathtable_l_add_entry (void *pt, const char name[], |
| 817 |
uint32_t extent, uint16_t parent); |
| 818 |
|
| 819 |
%rename iso9660_pathtable_m_add_entry pathtable_m_add_entry; |
| 820 |
uint16_t iso9660_pathtable_m_add_entry (void *pt, const char name[], |
| 821 |
uint32_t extent, uint16_t parent); |
| 822 |
|
| 823 |
/*====================================================================== |
| 824 |
Volume Descriptors |
| 825 |
========================================================================*/ |
| 826 |
|
| 827 |
#ifdef FINSHED |
| 828 |
void iso9660_set_pvd (void *pd, const char volume_id[], |
| 829 |
const char application_id[], |
| 830 |
const char publisher_id[], const char preparer_id[], |
| 831 |
uint32_t iso_size, const void *root_dir, |
| 832 |
uint32_t path_table_l_extent, |
| 833 |
uint32_t path_table_m_extent, |
| 834 |
uint32_t path_table_size, const time_t *pvd_time); |
| 835 |
#endif /*FINISHED*/ |
| 836 |
|
| 837 |
%rename iso9660_set_evd set_evd; |
| 838 |
void iso9660_set_evd (void *pd); |
| 839 |
|
| 840 |
/*! |
| 841 |
Return true if ISO 9660 image has extended attrributes (XA). |
| 842 |
*/ |
| 843 |
%rename iso9660_ifs_is_xa is_xa; |
| 844 |
bool iso9660_ifs_is_xa (const iso9660_t * p_iso); |
| 845 |
|
| 846 |
%perlcode %{ |
| 847 |
|
| 848 |
import Device::Cdio::VERSION; |
| 849 |
$VERSION = $Device::Cdio::VERSION; |
| 850 |
use strict; |
| 851 |
=pod |
| 852 |
|
| 853 |
=head1 NAME |
| 854 |
|
| 855 |
perliso9660 - lower-level wrapper to libiso9660, the ISO 9660 library of the CD Input and Control package |
| 856 |
|
| 857 |
=head1 SYNOPSIS |
| 858 |
|
| 859 |
This is fairly straight-forward wrapper around the C library libiso9660 |
| 860 |
Although this is perfectly usable on its own, it is expected that the |
| 861 |
Object-Oriented interface L<Device::Cdio::ISO9660> is what most people will |
| 862 |
want to use. |
| 863 |
|
| 864 |
There are various constants that are defined here. |
| 865 |
|
| 866 |
=head1 DESCRIPTION |
| 867 |
|
| 868 |
Encapsulation is done in two parts. The lower-level Perl |
| 869 |
interface is called perliso9660 (this file) and is generated via SWIG. |
| 870 |
|
| 871 |
=head1 CONSTANTS |
| 872 |
|
| 873 |
=over 4 |
| 874 |
|
| 875 |
=item ISO_BLOCKSIZE |
| 876 |
|
| 877 |
Number of bytes in an ISO 9660 block (2048) |
| 878 |
|
| 879 |
=item PVD_SECTOR |
| 880 |
|
| 881 |
"Primary Volume Descriptor" sector (16) |
| 882 |
|
| 883 |
=item EVD_SECTOR |
| 884 |
|
| 885 |
"End Volume Descriptor" sector (17) |
| 886 |
|
| 887 |
=item LEN_ISONAME |
| 888 |
|
| 889 |
Size in bytes of the filename portion + null byte (31) |
| 890 |
|
| 891 |
=item MAX_SYSTEM_ID |
| 892 |
|
| 893 |
Maximum number of characters in a system id (32) |
| 894 |
|
| 895 |
=item MAX_ISONAME |
| 896 |
|
| 897 |
Size in bytes of the filename portion + null byte. (37) |
| 898 |
|
| 899 |
=item MAX_PREPARER_ID |
| 900 |
|
| 901 |
Maximum number of characters in a preparer id. (128) |
| 902 |
|
| 903 |
=item MAX_ISOPATHNAME |
| 904 |
|
| 905 |
Maximum number of characters in the entire ISO 9660 filename. (255) |
| 906 |
|
| 907 |
=item MAX_PUBLISHER_ID |
| 908 |
|
| 909 |
Maximum number of characters in a publisher id. |
| 910 |
|
| 911 |
=item MAX_APPLICATION_ID |
| 912 |
|
| 913 |
Maximum number of characters in an application id. |
| 914 |
|
| 915 |
=item MAX_VOLUME_ID |
| 916 |
|
| 917 |
Maximum number of characters in a volume id. |
| 918 |
|
| 919 |
=item MAX_VOLUMESET_ID |
| 920 |
|
| 921 |
Maximum number of characters in a volume-set id. |
| 922 |
|
| 923 |
=item STANDARD_ID |
| 924 |
|
| 925 |
String inside frame which identifies an ISO 9660 filesystem. This |
| 926 |
string is the "id" field of an iso9660_pvd_t or an iso9660_svd_t. |
| 927 |
|
| 928 |
=item EXTENSION_JOLIET_LEVEL1 |
| 929 |
|
| 930 |
Use Joliet Level 1. |
| 931 |
|
| 932 |
=item EXTENSION_JOLIET_LEVEL2 |
| 933 |
|
| 934 |
Use Joliet Level 2. |
| 935 |
|
| 936 |
=item EXTENSION_JOLIET_LEVEL3 |
| 937 |
|
| 938 |
Use Joliet Level 3 |
| 939 |
|
| 940 |
=item EXTENSION_ROCK_RIDGE |
| 941 |
|
| 942 |
Use Rock-Ridge Extensions. |
| 943 |
|
| 944 |
=item EXTENSION_HIGH_SIERRA |
| 945 |
|
| 946 |
Use High-Sierra Extensions. |
| 947 |
|
| 948 |
=item EXTENSION_ALL |
| 949 |
|
| 950 |
Use any of the above extensions. |
| 951 |
|
| 952 |
=item EXTENSION_NONE |
| 953 |
|
| 954 |
Use none of the above extensions. |
| 955 |
|
| 956 |
=item EXTENSION_JOLIET |
| 957 |
|
| 958 |
Use any Joliet Extension available. |
| 959 |
|
| 960 |
=back |
| 961 |
|
| 962 |
=head2 Directory Flags |
| 963 |
|
| 964 |
=over 4 |
| 965 |
|
| 966 |
=item FILE |
| 967 |
|
| 968 |
Not really a flag but the lack of one. |
| 969 |
|
| 970 |
=item EXISTENCE |
| 971 |
|
| 972 |
Do not make existence known (hidden). |
| 973 |
|
| 974 |
=item DIRECTORY |
| 975 |
|
| 976 |
This file is a directory. |
| 977 |
|
| 978 |
=item ASSOCIATED |
| 979 |
|
| 980 |
This file is an associated file |
| 981 |
|
| 982 |
=item RECORD |
| 983 |
|
| 984 |
Record format is in extended attribute if not set. |
| 985 |
|
| 986 |
=item PROTECTION |
| 987 |
|
| 988 |
No read/execute permission in extended attribute. |
| 989 |
|
| 990 |
=item DRESERVED1 |
| 991 |
|
| 992 |
Reserved bit 5. |
| 993 |
|
| 994 |
=item DRESERVED2 |
| 995 |
|
| 996 |
Reserved bit 6 |
| 997 |
|
| 998 |
=item MULTIEXTENT |
| 999 |
|
| 1000 |
Not the final entry of a multi-extent file. |
| 1001 |
|
| 1002 |
=back |
| 1003 |
|
| 1004 |
=head2 Volume Descriptor Types |
| 1005 |
|
| 1006 |
=over 4 |
| 1007 |
|
| 1008 |
=item VD_BOOT_RECORD |
| 1009 |
|
| 1010 |
CD is bootable |
| 1011 |
|
| 1012 |
=item VD_PRIMARY |
| 1013 |
|
| 1014 |
Primary Volume descriptor which must be in any ISO-9660 |
| 1015 |
|
| 1016 |
=item VD_SUPPLEMENTARY |
| 1017 |
|
| 1018 |
(optional) Supplimentary Volume Descriptor. But used by Joliet, for |
| 1019 |
example. |
| 1020 |
|
| 1021 |
=item VD_PARITION |
| 1022 |
|
| 1023 |
Indicates a partition of a CD. |
| 1024 |
|
| 1025 |
=item VD_END |
| 1026 |
|
| 1027 |
=back |
| 1028 |
|
| 1029 |
=head2 Flags for strncpy |
| 1030 |
|
| 1031 |
=over 4 |
| 1032 |
|
| 1033 |
=item NOCHECK |
| 1034 |
|
| 1035 |
Enumeration meaning don not check in strncpy_pad. |
| 1036 |
|
| 1037 |
=item SEVEN_BIT |
| 1038 |
|
| 1039 |
Enumeration in strncpy_pad for checking entry has only 7-bit characters. |
| 1040 |
|
| 1041 |
|
| 1042 |
=item ACHARS |
| 1043 |
|
| 1044 |
Enumeration in strncpy_pad for checking entry has only ACHARs. |
| 1045 |
|
| 1046 |
=item DCHARS |
| 1047 |
|
| 1048 |
Enumeration in strncpy_pad for checking entry has only DCHARs. |
| 1049 |
|
| 1050 |
=back |
| 1051 |
|
| 1052 |
=head1 SUBROUTINES |
| 1053 |
|
| 1054 |
=head2 Input Output |
| 1055 |
|
| 1056 |
=head3 open_iso |
| 1057 |
|
| 1058 |
Open an ISO 9660 image for reading. Maybe in the future we will have |
| 1059 |
mode. undef is returned on error. |
| 1060 |
|
| 1061 |
=head3 open_ext |
| 1062 |
|
| 1063 |
Open an ISO 9660 image for reading allowing various ISO 9660 |
| 1064 |
extensions. Maybe in the future we will have a mode. undef is |
| 1065 |
eturned on error. |
| 1066 |
|
| 1067 |
=head3 open_fuzzy |
| 1068 |
|
| 1069 |
Open an ISO 9660 image for reading with some tolerence for positioning |
| 1070 |
of the ISO9660 image. We scan for $perliso9660::ISO_STANDARD_ID and |
| 1071 |
use that to set he eventual offset to adjust by (as long as that is <= |
| 1072 |
i_fuzz). |
| 1073 |
|
| 1074 |
Maybe in the future we will have a mode. undef is returned on error. |
| 1075 |
|
| 1076 |
See also open_iso |
| 1077 |
|
| 1078 |
=head3 open_fuzzy_ext |
| 1079 |
|
| 1080 |
Open an ISO 9660 image for reading with some tolerence for positioning |
| 1081 |
of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set |
| 1082 |
the eventual offset to adjust by (as long as that is <= i_fuzz). |
| 1083 |
|
| 1084 |
Maybe in the future we will have a mode. undef is returned on error. |
| 1085 |
|
| 1086 |
=head3 ifs_fuzzy_read_superblock |
| 1087 |
|
| 1088 |
Read the Super block of an ISO 9660 image but determine framesize |
| 1089 |
and datastart and a possible additional offset. Generally here we are |
| 1090 |
not reading an ISO 9660 image but a CD-Image which contains an ISO 9660 |
| 1091 |
filesystem. |
| 1092 |
|
| 1093 |
=head3 close |
| 1094 |
|
| 1095 |
Close previously opened ISO 9660 image. |
| 1096 |
1 is unconditionally returned. If there was an error 0 would |
| 1097 |
be returned. |
| 1098 |
|
| 1099 |
=head3 seek_read |
| 1100 |
|
| 1101 |
Seek to a position and then read n bytes. (buffer, size) are is returned. |
| 1102 |
|
| 1103 |
=head3 fs_read_pvd |
| 1104 |
|
| 1105 |
Read the Primary Volume Descriptor for a CD. |
| 1106 |
1 is returned if read, and 0 if there was an error. |
| 1107 |
|
| 1108 |
=head3 ifs_read_pvd |
| 1109 |
|
| 1110 |
Read the Primary Volume Descriptor for an ISO 9660 image. |
| 1111 |
1 is returned if read, and 0 if there was an error. |
| 1112 |
|
| 1113 |
=head3 _fs_read_superblock |
| 1114 |
|
| 1115 |
Read the Super block of an ISO 9660 image. This is the |
| 1116 |
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume |
| 1117 |
Descriptor if (Joliet) extensions are acceptable. |
| 1118 |
|
| 1119 |
=head3 ifs_read_superblock |
| 1120 |
|
| 1121 |
Read the Super block of an ISO 9660 image. This is the |
| 1122 |
Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume |
| 1123 |
Descriptor if (Joliet) extensions are acceptable. |
| 1124 |
|
| 1125 |
=head2 Time Conversion |
| 1126 |
|
| 1127 |
=head3 set_dtime |
| 1128 |
|
| 1129 |
Set time in format used in ISO 9660 directory index record |
| 1130 |
from a Unix time structure. |
| 1131 |
|
| 1132 |
|
| 1133 |
=head3 set_ltime |
| 1134 |
|
| 1135 |
Set "long" time in format used in ISO 9660 primary volume descriptor |
| 1136 |
from a Unix time structure. |
| 1137 |
|
| 1138 |
=head3 get_dtime |
| 1139 |
|
| 1140 |
Get Unix time structure from format use in an ISO 9660 directory index |
| 1141 |
record. Even though tm_wday and tm_yday fields are not explicitly in |
| 1142 |
dtime, they are calculated from the other fields. |
| 1143 |
|
| 1144 |
If tm is to reflect the localtime, set "use_localtime" 1, otherwise |
| 1145 |
tm will reported in GMT. |
| 1146 |
|
| 1147 |
=head3 get_ltime |
| 1148 |
|
| 1149 |
Get "long" time in format used in ISO 9660 primary volume descriptor |
| 1150 |
from a Unix time structure. |
| 1151 |
|
| 1152 |
=head2 Character Classification and String Manipulation |
| 1153 |
|
| 1154 |
=head3 is_dchar |
| 1155 |
|
| 1156 |
Return 1 if c (an int) is a DCHAR - a character that can appear in an an |
| 1157 |
ISO-9600 level 1 directory name. These are the ASCII capital |
| 1158 |
letters A-Z, the digits 0-9 and an underscore. |
| 1159 |
|
| 1160 |
=head3 is_achar |
| 1161 |
|
| 1162 |
=head3 name_translate |
| 1163 |
|
| 1164 |
Convert an ISO-9660 file name that stored in a directory entry into |
| 1165 |
what is usually listed as the file name in a listing. |
| 1166 |
wercase name, and remove trailing ;1's or .;1's and |
| 1167 |
turn the others into version numbers. |
| 1168 |
|
| 1169 |
=head3 name_translate_ext |
| 1170 |
|
| 1171 |
Convert an ISO-9660 file name that stored in a directory entry into |
| 1172 |
what is usually listed as the file name in a listing. Lowercase |
| 1173 |
name if no Joliet Extension interpretation. Remove trailing ;1's or |
| 1174 |
.;1's and turn the others into version numbers. |
| 1175 |
|
| 1176 |
=head3 strncpy_pad |
| 1177 |
|
| 1178 |
Pad string src with spaces to size len and copy this to dst. If len is |
| 1179 |
less than the length of src, dst will be truncated to the first len |
| 1180 |
characters of src. |
| 1181 |
|
| 1182 |
src can also be scanned to see if it contains only ACHARs, DCHARs, |
| 1183 |
7-bit ASCII chars depending on the enumeration _check. |
| 1184 |
|
| 1185 |
In addition to getting changed, dst is the return value. Note: this |
| 1186 |
string might not be undef terminated. |
| 1187 |
|
| 1188 |
=head2 File and Directory Names |
| 1189 |
|
| 1190 |
=head3 dirname_valid_p |
| 1191 |
|
| 1192 |
Check that psz_path is a valid ISO-9660 directory name. |
| 1193 |
|
| 1194 |
A valid directory name should not start out with a slash (/), |
| 1195 |
dot (.) or null byte, should be less than 37 characters long, |
| 1196 |
have no more than 8 characters in a directory component |
| 1197 |
which is separated by a /, and consist of only DCHARs. |
| 1198 |
|
| 1199 |
1 is returned if psz_path is valid. |
| 1200 |
|
| 1201 |
=head3 pathname_isofy |
| 1202 |
|
| 1203 |
Take psz_path and a version number and turn that into a ISO-9660 |
| 1204 |
pathname. (That is just the pathname followed by ";" and the version |
| 1205 |
number. For example, mydir/file.ext -> MYDIR/FILE.EXT;1 for version |
| 1206 |
1. The resulting ISO-9660 pathname is returned. |
| 1207 |
|
| 1208 |
=head3 pathname_valid_p |
| 1209 |
|
| 1210 |
Check that psz_path is a valid ISO-9660 pathname. |
| 1211 |
|
| 1212 |
A valid pathname contains a valid directory name, if one appears and |
| 1213 |
the filename portion should be no more than 8 characters for the |
| 1214 |
file prefix and 3 characters in the extension (or portion after a |
| 1215 |
dot). There should be exactly one dot somewhere in the filename |
| 1216 |
portion and the filename should be composed of only DCHARs. |
| 1217 |
|
| 1218 |
1 is returned if psz_path is valid. |
| 1219 |
|
| 1220 |
=head3 fs_find_lsn |
| 1221 |
|
| 1222 |
Given a directory pointer, find the filesystem entry that contains |
| 1223 |
lsn and return information about it. |
| 1224 |
|
| 1225 |
Returns stat_t of entry if we found lsn, or undef otherwise. |
| 1226 |
|
| 1227 |
=head3 ifs_find_lsn |
| 1228 |
|
| 1229 |
Given a directory pointer, find the filesystem entry that contains |
| 1230 |
lsn and return information about it. |
| 1231 |
|
| 1232 |
Returns stat_t of entry if we found lsn, or undef otherwise. |
| 1233 |
|
| 1234 |
=head3 fs_stat |
| 1235 |
|
| 1236 |
Return file status for psz_path. undef is returned on error. |
| 1237 |
|
| 1238 |
=head3 fs_stat_translate |
| 1239 |
|
| 1240 |
Return file status for path name psz_path. undef is returned on error. |
| 1241 |
pathname version numbers in the ISO 9660 name are dropped, i.e. ;1 |
| 1242 |
is removed and if level 1 ISO-9660 names are lowercased. |
| 1243 |
|
| 1244 |
=head3 ifs_stat |
| 1245 |
|
| 1246 |
Return file status for pathname. undef is returned on error. |
| 1247 |
|
| 1248 |
=head3 ifs_stat_translate |
| 1249 |
|
| 1250 |
Return file status for path name psz_path. undef is returned on |
| 1251 |
error. pathname version numbers in the ISO 9660 name are dropped, |
| 1252 |
i.e. ;1 is removed and if level 1 ISO-9660 names are lowercased. |
| 1253 |
|
| 1254 |
|
| 1255 |
=head3 fs_readdir |
| 1256 |
|
| 1257 |
Read psz_path (a directory) and return a list of iso9660_stat_t |
| 1258 |
pointers for the files inside that directory. The caller must free the |
| 1259 |
returned result. |
| 1260 |
|
| 1261 |
=head3 ifs_readdir |
| 1262 |
|
| 1263 |
Read psz_path (a directory) and return a list of iso9660_stat_t |
| 1264 |
pointers for the files inside that directory. The caller must free |
| 1265 |
the returned result. |
| 1266 |
|
| 1267 |
=head3 get_dir_len |
| 1268 |
|
| 1269 |
Return the directory name stored in the iso9660_dir_t |
| 1270 |
|
| 1271 |
A string is allocated: the caller must deallocate. |
| 1272 |
|
| 1273 |
=head3 dir_to_name |
| 1274 |
|
| 1275 |
=head3 get_posix_filemode |
| 1276 |
|
| 1277 |
Returns a POSIX mode for a given p_iso_dirent. |
| 1278 |
|
| 1279 |
=head2 Primary Volume Descriptor Routines |
| 1280 |
|
| 1281 |
=head3 get_application_id |
| 1282 |
|
| 1283 |
Return the PVD's application ID. |
| 1284 |
|
| 1285 |
undef is returned if there is some problem in getting this. |
| 1286 |
|
| 1287 |
=head3 ifs_get_application_id |
| 1288 |
|
| 1289 |
Get the application ID. psz_app_id is set to undef if there |
| 1290 |
is some problem in getting this and 0 is returned. |
| 1291 |
|
| 1292 |
=head3 get_preparer_id |
| 1293 |
|
| 1294 |
Return a string containing the preparer id with trailing |
| 1295 |
blanks removed. |
| 1296 |
|
| 1297 |
=head3 ifs_get_preparer_id |
| 1298 |
|
| 1299 |
Get the preparer ID. psz_preparer_id is set to undef if there |
| 1300 |
is some problem in getting this and 0 is returned. |
| 1301 |
|
| 1302 |
=head3 get_publisher_id |
| 1303 |
|
| 1304 |
Return a string containing the PVD's publisher id with trailing |
| 1305 |
blanks removed. |
| 1306 |
|
| 1307 |
=head3 ifs_get_publisher_id |
| 1308 |
|
| 1309 |
Get the publisher ID. psz_publisher_id is set to undef if there |
| 1310 |
is some problem in getting this and 0 is returned. |
| 1311 |
|
| 1312 |
=head3 get_pvd_type |
| 1313 |
|
| 1314 |
=head3 get_pvd_id |
| 1315 |
|
| 1316 |
=head3 get_pvd_space_size |
| 1317 |
|
| 1318 |
=head3 get_pvd_block_size |
| 1319 |
|
| 1320 |
=head3 get_pvd_version |
| 1321 |
|
| 1322 |
Return the primary volume id version number (of pvd). |
| 1323 |
If there is an error 0 is returned. |
| 1324 |
|
| 1325 |
=head3 get_system_id |
| 1326 |
|
| 1327 |
Return a string containing the PVD's system id with trailing |
| 1328 |
blanks removed. |
| 1329 |
|
| 1330 |
=head3 ifs_get_system_id |
| 1331 |
|
| 1332 |
Get the system ID. psz_system_id is set to undef if there |
| 1333 |
is some problem in getting this and 0 is returned. |
| 1334 |
|
| 1335 |
=head3 get_root_lsn |
| 1336 |
|
| 1337 |
Return the LSN of the root directory for pvd. |
| 1338 |
If there is an error CDIO_INVALID_LSN is returned. |
| 1339 |
|
| 1340 |
=head3 get_volume_id |
| 1341 |
|
| 1342 |
Return the PVD's volume ID. |
| 1343 |
|
| 1344 |
=head3 ifs_get_volume_id |
| 1345 |
|
| 1346 |
Get the system ID. psz_system_id is set to undef if there |
| 1347 |
s some problem in getting this and 0 is returned. |
| 1348 |
|
| 1349 |
=head3 get_volumeset_id |
| 1350 |
|
| 1351 |
Return the PVD's volumeset ID. |
| 1352 |
undef is returned if there is some problem in getting this. |
| 1353 |
|
| 1354 |
=head3 ifs_get_volumeset_id |
| 1355 |
|
| 1356 |
Get the systemset ID. psz_systemset_id is set to undef if there |
| 1357 |
is some problem in getting this and 0 is returned. |
| 1358 |
|
| 1359 |
=head2 Path Table Routines |
| 1360 |
|
| 1361 |
=head3 iso9660_pathtable_init |
| 1362 |
|
| 1363 |
Zero out pathable. Do this first. |
| 1364 |
|
| 1365 |
=head3 pathtable_get_size |
| 1366 |
|
| 1367 |
=head3 pathtable_l_add_entry |
| 1368 |
|
| 1369 |
=head3 pathtable_m_add_entry |
| 1370 |
|
| 1371 |
=head3 set_evd |
| 1372 |
|
| 1373 |
=head2 Miscellaneous |
| 1374 |
|
| 1375 |
=head3 get_joliet_level |
| 1376 |
|
| 1377 |
Return the Joliet level recognized for p_iso. |
| 1378 |
|
| 1379 |
=head3 ifs_is_xa |
| 1380 |
|
| 1381 |
Return 1 if ISO 9660 image has extended attrributes (XA). |
| 1382 |
|
| 1383 |
=head1 METHODS |
| 1384 |
|
| 1385 |
=head2 this |
| 1386 |
|
| 1387 |
This seems to be an artifact of SWIG. |
| 1388 |
|
| 1389 |
=head1 SEE ALSO |
| 1390 |
|
| 1391 |
L<http://www.gnu.org/software/libcdio> has documentation on |
| 1392 |
libcdio including the a manual and the API via doxygen. |
| 1393 |
|
| 1394 |
=head1 AUTHORS |
| 1395 |
|
| 1396 |
Rocky Bernstein C<< <rocky at cpan.org> >>. |
| 1397 |
|
| 1398 |
=head1 COPYRIGHT |
| 1399 |
|
| 1400 |
Copyright (C) 2006, 2008, 2011, 2017 Rocky Bernstein <[email protected]> |
| 1401 |
|
| 1402 |
This program is free software: you can redistribute it and/or modify |
| 1403 |
it under the terms of the GNU General Public License as published by |
| 1404 |
the Free Software Foundation, either version 3 of the License, or |
| 1405 |
(at your option) any later version. |
| 1406 |
|
| 1407 |
This program is distributed in the hope that it will be useful, |
| 1408 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 1409 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 1410 |
GNU General Public License for more details. |
| 1411 |
|
| 1412 |
You should have received a copy of the GNU General Public License |
| 1413 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 1414 |
|
| 1415 |
=cut |
| 1416 |
%} |