rbcdio 0.01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/AUTHORS +1 -0
  2. data/COPYING +340 -0
  3. data/ChangeLog +315 -0
  4. data/INSTALL +236 -0
  5. data/Makefile.am +163 -0
  6. data/Makefile.in +557 -0
  7. data/NEWS +5 -0
  8. data/README +75 -0
  9. data/Rakefile +234 -0
  10. data/THANKS +3 -0
  11. data/VERSION +1 -0
  12. data/VERSION.in +1 -0
  13. data/config.guess +1473 -0
  14. data/config.sub +1576 -0
  15. data/configure +4802 -0
  16. data/configure.ac +158 -0
  17. data/data/copying.iso +0 -0
  18. data/data/isofs-m1.bin +0 -0
  19. data/data/isofs-m1.cue +3 -0
  20. data/doc/created.rid +1 -0
  21. data/doc/fr_class_index.html +42 -0
  22. data/doc/fr_file_index.html +40 -0
  23. data/doc/fr_method_index.html +133 -0
  24. data/doc/index.html +24 -0
  25. data/doc/rdoc-style.css +208 -0
  26. data/example/COPYING +340 -0
  27. data/example/README +47 -0
  28. data/example/audio.rb +186 -0
  29. data/example/cd-read.rb +167 -0
  30. data/example/copying +340 -0
  31. data/example/device.rb +91 -0
  32. data/example/drivers.rb +63 -0
  33. data/example/drives.rb +63 -0
  34. data/example/eject.rb +69 -0
  35. data/example/iso1.rb +89 -0
  36. data/example/iso2.rb +106 -0
  37. data/example/iso3.rb +111 -0
  38. data/example/tracks.rb +83 -0
  39. data/ext/cdio/Makefile +139 -0
  40. data/ext/cdio/extconf.rb +9 -0
  41. data/ext/cdio/rubycdio_wrap.c +3410 -0
  42. data/ext/iso9660/Makefile +139 -0
  43. data/ext/iso9660/extconf.rb +10 -0
  44. data/ext/iso9660/rubyiso9660_wrap.c +3005 -0
  45. data/install-sh +323 -0
  46. data/lib/Makefile +7 -0
  47. data/lib/cdio.rb +1000 -0
  48. data/lib/iso9660.rb +566 -0
  49. data/missing +360 -0
  50. data/rubycdio.m4 +14 -0
  51. data/swig/Makefile +7 -0
  52. data/swig/audio.swg +63 -0
  53. data/swig/compat.swg +104 -0
  54. data/swig/device.swg +513 -0
  55. data/swig/device_const.swg +144 -0
  56. data/swig/disc.swg +96 -0
  57. data/swig/read.swg +164 -0
  58. data/swig/rubycdio.swg +86 -0
  59. data/swig/rubyiso9660.swg +827 -0
  60. data/swig/track.swg +206 -0
  61. data/swig/types.swg +65 -0
  62. data/test/Makefile +7 -0
  63. data/test/Rakefile +8 -0
  64. data/test/cdda.bin +0 -0
  65. data/test/cdda.cue +7 -0
  66. data/test/cdda.toc +14 -0
  67. data/test/cdiotest.rb +228 -0
  68. data/test/isocopy.rb +394 -0
  69. data/test/isotest.rb +187 -0
  70. metadata +116 -0
@@ -0,0 +1,827 @@
1
+ /* -*- c -*-
2
+ $Id: rubyiso9660.swg,v 1.4 2006/11/29 10:29:00 rocky Exp $
3
+
4
+ Copyright (C) 2006 Rocky Bernstein <rocky@gnu.org>
5
+
6
+ This program is free software; you can redistribute it and/or modify
7
+ it under the terms of the GNU General Public License as published by
8
+ the Free Software Foundation; either version 2 of the License, or
9
+ (at your option) any later version.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ You should have received a copy of the GNU General Public License
17
+ along with this program; if not, write to the Free Software
18
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
+ 02110-1301 USA
20
+ */
21
+ %define DOCSTRING
22
+ "This is a wrapper for The CD Input and Control library's ISO-9660 library
23
+ See also the ISO-9660 specification. The freely available European
24
+ equivalant standard is called ECMA-119."
25
+ %enddef
26
+ %module(docstring=DOCSTRING) rubyiso9660
27
+
28
+ %{
29
+ /* Includes the header in the wrapper code */
30
+ #include <time.h>
31
+ #include <cdio/iso9660.h>
32
+ #include <cdio/version.h>
33
+ %}
34
+
35
+ #include <time.h>
36
+ #include <cdio/iso9660.h>
37
+ #include <cdio/version.h>
38
+
39
+ /* Various libcdio constants and typedefs */
40
+ %include "types.swg"
41
+ %include "compat.swg"
42
+
43
+ %include "typemaps.i"
44
+ /*%include "cstring.i"*/
45
+
46
+ %feature("autodoc", 1);
47
+
48
+ typedef unsigned int iso_extension_mask_t;
49
+
50
+ %constant long int ISO_BLOCKSIZE = CDIO_CD_FRAMESIZE;
51
+ %constant long int PVD_SECTOR = ISO_PVD_SECTOR ;
52
+ %constant long int EVD_SECTOR = ISO_EVD_SECTOR ;
53
+ %constant long int LEN_ISONAME = LEN_ISONAME;
54
+ %constant long int MAX_SYSTEM_ID = ISO_MAX_SYSTEM_ID ;
55
+ %constant long int MAX_ISONAME = MAX_ISONAME;
56
+ %constant long int MAX_PREPARER_ID = ISO_MAX_PREPARER_ID ;
57
+ %constant long int MAX_ISOPATHNAME = MAX_ISOPATHNAME;
58
+
59
+ %constant long int FILE = ISO_FILE;
60
+ %constant long int EXISTENCE = ISO_EXISTENCE;
61
+ %constant long int DIRECTORY = ISO_DIRECTORY;
62
+ %constant long int ASSOCIATED = ISO_ASSOCIATED;
63
+ %constant long int RECORD = ISO_RECORD;
64
+
65
+ #include <cdio/version.h>
66
+ #if LIBCDIO_VERSION_NUM <= 76
67
+ %constant long int PROTECTION = ISO_PROTECTION;
68
+ #else
69
+ %constant long int PROTECTION = 16;
70
+ #endif
71
+
72
+ %constant long int DRESERVED1 = ISO_DRESERVED1;
73
+ %constant long int DRESERVED2 = ISO_DRESERVED2;
74
+ %constant long int MULTIEXTENT = ISO_MULTIEXTENT;
75
+
76
+ %constant long int VD_BOOT_RECORD = ISO_VD_BOOT_RECORD;
77
+ %constant long int VD_PRIMARY = ISO_VD_PRIMARY;
78
+ %constant long int VD_SUPPLEMENTARY = ISO_VD_SUPPLEMENTARY;
79
+ %constant long int VD_PARITION = ISO_VD_PARITION;
80
+ %constant long int VD_END = ISO_VD_END;
81
+
82
+ %constant long int MAX_PUBLISHER_ID = ISO_MAX_PUBLISHER_ID;
83
+ %constant long int MAX_APPLICATION_ID = ISO_MAX_APPLICATION_ID;
84
+ %constant long int MAX_VOLUME_ID = ISO_MAX_VOLUME_ID;
85
+ %constant long int MAX_VOLUMESET_ID = ISO_MAX_VOLUMESET_ID;
86
+
87
+ %constant long int NOCHECK = ISO9660_NOCHECK;
88
+ %constant long int SEVEN_BIT = ISO9660_7BIT;
89
+ %constant long int ACHARS = ISO9660_ACHARS;
90
+ %constant long int DCHARS = ISO9660_DCHARS;
91
+
92
+ %constant long int EXTENSION_JOLIET_LEVEL1 = ISO_EXTENSION_JOLIET_LEVEL1;
93
+ %constant long int EXTENSION_JOLIET_LEVEL2 = ISO_EXTENSION_JOLIET_LEVEL2;
94
+ %constant long int EXTENSION_JOLIET_LEVEL3 = ISO_EXTENSION_JOLIET_LEVEL3;
95
+ %constant long int EXTENSION_ROCK_RIDGE = ISO_EXTENSION_ROCK_RIDGE;
96
+ %constant long int EXTENSION_HIGH_SIERRA = ISO_EXTENSION_HIGH_SIERRA;
97
+
98
+ %constant long int EXTENSION_ALL = ISO_EXTENSION_ALL;
99
+ %constant long int EXTENSION_NONE = ISO_EXTENSION_NONE;
100
+ %constant long int EXTENSION_JOLIET = ISO_EXTENSION_JOLIET;
101
+
102
+ /* Set up to allow functions to return stat lists of type "stat
103
+ *". We'll use a typedef so we can make sure to isolate this.
104
+ */
105
+ %inline %{
106
+ typedef CdioList_t IsoStatList_t;
107
+ typedef iso9660_stat_t IsoStat_t;
108
+ %}
109
+ typedef CdioList_t IsoStatList_t;
110
+ typedef iso9660_stat_t IsoStat_t;
111
+
112
+ %typemap(out) IsoStatList_t *{
113
+ CdioList_t *p_entlist = result;
114
+ CdioListNode_t *p_entnode;
115
+
116
+ if (result) {
117
+ VALUE resultobj = rb_ary_new();
118
+ _CDIO_LIST_FOREACH (p_entnode, p_entlist) {
119
+ VALUE stat = rb_hash_new();
120
+ iso9660_stat_t *p_statbuf =
121
+ (iso9660_stat_t *) _cdio_list_node_data (p_entnode);
122
+
123
+ rb_hash_aset(stat, rb_str_new2("filename"),
124
+ rb_str_new2(p_statbuf->filename));
125
+ rb_hash_aset(stat, rb_str_new2("lsn"),
126
+ INT2NUM(p_statbuf->lsn));
127
+ rb_hash_aset(stat, rb_str_new2("size"),
128
+ INT2NUM(p_statbuf->size));
129
+ rb_hash_aset(stat, rb_str_new2("secsize"),
130
+ INT2NUM(p_statbuf->secsize));
131
+ rb_hash_aset(stat, rb_str_new2("type"),
132
+ INT2NUM(p_statbuf->type));
133
+ rb_ary_push(resultobj, stat);
134
+
135
+ }
136
+ _cdio_list_free(result, 1);
137
+ return resultobj;
138
+ }
139
+ }
140
+
141
+ %typemap(out) IsoStat_t *{
142
+ iso9660_stat_t *p_statbuf = result;
143
+
144
+ if (result) {
145
+ VALUE resultobj = rb_hash_new();
146
+ rb_hash_aset(resultobj, rb_str_new2("filename"),
147
+ rb_str_new2(p_statbuf->filename));
148
+ rb_hash_aset(resultobj, rb_str_new2("lsn"),
149
+ INT2NUM(p_statbuf->lsn));
150
+ rb_hash_aset(resultobj, rb_str_new2("size"),
151
+ INT2NUM(p_statbuf->size));
152
+ rb_hash_aset(resultobj, rb_str_new2("secsize"),
153
+ INT2NUM(p_statbuf->secsize));
154
+ rb_hash_aset(resultobj, rb_str_new2("type"),
155
+ INT2NUM(p_statbuf->type));
156
+ free (p_statbuf);
157
+ return resultobj;
158
+ }
159
+ }
160
+
161
+ %typemap(out) struct tm *{
162
+ struct tm *p_tm = result;
163
+
164
+ if (result) {
165
+ VALUE resultobj = rb_hash_new();
166
+ rb_hash_aset(resultobj, rb_str_new2("year"),
167
+ INT2NUM(p_tm->tm_year+1900));
168
+ rb_hash_aset(resultobj, rb_str_new2("month"),
169
+ INT2NUM(p_tm->tm_mon+1));
170
+ rb_hash_aset(resultobj, rb_str_new2("mday"),
171
+ INT2NUM(p_tm->tm_mday));
172
+ rb_hash_aset(resultobj, rb_str_new2("hour"),
173
+ INT2NUM(p_tm->tm_hour));
174
+ rb_hash_aset(resultobj, rb_str_new2("min"),
175
+ INT2NUM(p_tm->tm_min));
176
+ rb_hash_aset(resultobj, rb_str_new2("sec"),
177
+ INT2NUM(p_tm->tm_sec));
178
+ rb_hash_aset(resultobj, rb_str_new2("wday"),
179
+ INT2NUM((p_tm->tm_wday-1))%7);
180
+ rb_hash_aset(resultobj, rb_str_new2("isdst"),
181
+ INT2NUM((p_tm->tm_isdst)));
182
+ free (p_tm);
183
+ return resultobj;
184
+ }
185
+ }
186
+
187
+ %feature("autodoc",
188
+ "open_iso(path)
189
+ Open an ISO 9660 image for reading. Maybe in the future we will have
190
+ mode. None is returned on error.
191
+ ");
192
+ %rename iso9660_open open_iso;
193
+ iso9660_t *iso9660_open (const char *psz_path /*flags, mode */);
194
+
195
+ %feature("autodoc",
196
+ "Open an ISO 9660 image for reading allowing various ISO 9660
197
+ extensions. Maybe in the future we will have a mode. None is
198
+ returned on error.");
199
+ %rename iso9660_open_ext open_ext;
200
+ iso9660_t *iso9660_open_ext (const char *psz_path,
201
+ iso_extension_mask_t iso_extension_mask);
202
+
203
+ %feature("autodoc",
204
+ "Open an ISO 9660 image for reading with some tolerence for positioning
205
+ of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set
206
+ the eventual offset to adjust by (as long as that is <= i_fuzz).
207
+
208
+ Maybe in the future we will have a mode. None is returned on error.
209
+
210
+ see iso9660_open");
211
+ %rename iso9660_open_fuzzy open_fuzzy;
212
+ iso9660_t *iso9660_open_fuzzy (const char *psz_path /*flags, mode */,
213
+ uint16_t i_fuzz);
214
+
215
+ %feature("autodoc",
216
+ "Open an ISO 9660 image for reading with some tolerence for positioning
217
+ of the ISO9660 image. We scan for ISO_STANDARD_ID and use that to set
218
+ the eventual offset to adjust by (as long as that is <= i_fuzz).
219
+
220
+ Maybe in the future we will have a mode. None is returned on error.
221
+
222
+ see open_iso
223
+ ");
224
+ %rename iso9660_open_fuzzy open_fuzzy_ext;
225
+ iso9660_t *iso9660_open_fuzzy_ext (const char *psz_path,
226
+ iso_extension_mask_t iso_extension_mask,
227
+ uint16_t i_fuzz
228
+ /*flags, mode */);
229
+ %feature("autodoc",
230
+ "Read the Super block of an ISO 9660 image but determine framesize
231
+ and datastart and a possible additional offset. Generally here we are
232
+ not reading an ISO 9660 image but a CD-Image which contains an ISO 9660
233
+ filesystem.
234
+ ");
235
+ %rename iso9660_ifs_fuzzy_read_superblock ifs_fuzzy_read_superblock;
236
+ bool iso9660_ifs_fuzzy_read_superblock (iso9660_t *p_iso,
237
+ iso_extension_mask_t iso_extension_mask,
238
+ uint16_t i_fuzz);
239
+ %feature("autodoc",
240
+ "Close previously opened ISO 9660 image.
241
+ True is unconditionally returned. If there was an error false would
242
+ be returned.");
243
+ %rename iso9660_close close;
244
+ bool iso9660_close (iso9660_t * p_iso);
245
+
246
+ %inline %{
247
+ typedef struct {
248
+ char *data;
249
+ size_t i_size;
250
+ } Buf_tuple_t;
251
+ %}
252
+
253
+ %typemap(out) Buf_tuple_t
254
+ {
255
+ if (!$1.data)
256
+ return Qnil;
257
+ else {
258
+ VALUE data_tuple = rb_ary_new();
259
+ rb_ary_push(data_tuple, INT2NUM($1.i_size));
260
+ rb_ary_push(data_tuple, rb_str_new($1.data, $1.i_size));
261
+ free($1.data);
262
+ return data_tuple;
263
+ }
264
+ }
265
+
266
+ %feature("autodoc",
267
+ "Seek to a position and then read n bytes. (buffer, size) are
268
+ returned.");
269
+ Buf_tuple_t seek_read (const iso9660_t *p_iso, lsn_t start, ssize_t i_size);
270
+ %inline %{
271
+ Buf_tuple_t
272
+ seek_read (const iso9660_t *p_iso, lsn_t start, ssize_t i_size)
273
+ {
274
+ Buf_tuple_t buf_tuple;
275
+ buf_tuple.data = calloc(1, i_size);
276
+ buf_tuple.i_size = iso9660_iso_seek_read(p_iso, buf_tuple.data, start,
277
+ (i_size) / ISO_BLOCKSIZE);
278
+ return buf_tuple;
279
+ }
280
+ %}
281
+
282
+
283
+ %feature("autodoc",
284
+ "Read the Primary Volume Descriptor for a CD.
285
+ None is returned if there was an error.");
286
+ iso9660_pvd_t *fs_read_pvd ( const CdIo_t *p_cdio );
287
+ %inline %{
288
+ iso9660_pvd_t *fs_read_pvd ( const CdIo_t *p_cdio ) {
289
+ static iso9660_pvd_t pvd;
290
+ bool b_ok = iso9660_fs_read_pvd ( p_cdio, &pvd );
291
+ if (!b_ok) return NULL;
292
+ return &pvd;
293
+ }
294
+ %}
295
+
296
+ %feature("autodoc",
297
+ "Read the Primary Volume Descriptor for an ISO 9660 image.
298
+ None is returned if there was an error.");
299
+ iso9660_pvd_t *ifs_read_pvd ( const iso9660_t *p_iso );
300
+ %inline %{
301
+ iso9660_pvd_t *ifs_read_pvd ( const iso9660_t *p_iso ) {
302
+ static iso9660_pvd_t pvd;
303
+ bool b_ok = iso9660_ifs_read_pvd ( p_iso, &pvd );
304
+ if (!b_ok) return NULL;
305
+ return &pvd;
306
+ }
307
+ %}
308
+
309
+ %feature("autodoc",
310
+ "Read the Super block of an ISO 9660 image. This is the
311
+ Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
312
+ Descriptor if (Joliet) extensions are acceptable.");
313
+ %rename iso9660_fs_read_superblock fs_read_superblock;
314
+ bool iso9660_fs_read_superblock (CdIo_t *p_cdio,
315
+ iso_extension_mask_t iso_extension_mask);
316
+
317
+ %feature("autodoc",
318
+ "Read the Super block of an ISO 9660 image. This is the
319
+ Primary Volume Descriptor (PVD) and perhaps a Supplemental Volume
320
+ Descriptor if (Joliet) extensions are acceptable.");
321
+ %rename iso9660_ifs_read_superblock ifs_read_superblock;
322
+ bool iso9660_ifs_read_superblock (iso9660_t *p_iso,
323
+ iso_extension_mask_t iso_extension_mask);
324
+
325
+
326
+ /*====================================================
327
+ Time conversion
328
+ ====================================================*/
329
+ %feature("autodoc",
330
+ "Set time in format used in ISO 9660 directory index record");
331
+ iso9660_dtime_t *
332
+ set_dtime ( int year, int mon, int mday, int hour, int min, int sec);
333
+ %inline %{
334
+ iso9660_dtime_t *
335
+ set_dtime ( int year, int mon, int mday, int hour, int min, int sec)
336
+ {
337
+ struct tm tm = { sec, min, hour, mday, mon-1, year-1900, 0, 0, -1 };
338
+ static iso9660_dtime_t dtime;
339
+ iso9660_set_dtime (&tm, &dtime);
340
+ return &dtime;
341
+ }
342
+ %}
343
+
344
+ %feature("autodoc",
345
+ "Set 'long' time in format used in ISO 9660 primary volume descriptor");
346
+ iso9660_ltime_t *
347
+ set_ltime ( int year, int mon, int mday, int hour, int min, int sec);
348
+
349
+ %inline %{
350
+ iso9660_ltime_t *
351
+ set_ltime ( int year, int mon, int mday, int hour, int min, int sec)
352
+ {
353
+ struct tm tm = { sec, min, hour, mday, mon-1, year-1900, 0, 0, -1 };
354
+ static iso9660_ltime_t ldate;
355
+ iso9660_set_ltime (&tm, &ldate);
356
+ return &ldate;
357
+ }
358
+ %}
359
+
360
+ %feature("autodoc",
361
+ "Get Unix time structure from format use in an ISO 9660 directory index
362
+ record. Even though tm_wday and tm_yday fields are not explicitly in
363
+ idr_date, they are calculated from the other fields.
364
+
365
+ If tm is to reflect the localtime, set 'use_localtime' true, otherwise
366
+ tm will reported in GMT.");
367
+ struct tm *get_dtime (const iso9660_dtime_t *p_dtime, bool use_localtime);
368
+ %inline %{
369
+ struct tm *get_dtime (const iso9660_dtime_t *p_dtime, bool use_localtime) {
370
+ struct tm *p_tm = (struct tm *) calloc(1, sizeof(struct tm));
371
+ if (!iso9660_get_dtime (p_dtime, use_localtime, p_tm)) {
372
+ free(p_tm);
373
+ return NULL;
374
+ }
375
+ return p_tm;
376
+ }
377
+ %}
378
+
379
+ %feature("autodoc",
380
+ "Get 'long' time in format used in ISO 9660 primary volume descriptor
381
+ from a Unix time structure.");
382
+ struct tm *get_ltime (const iso9660_ltime_t *p_ltime);
383
+ %inline %{
384
+ struct tm *get_ltime (const iso9660_ltime_t *p_ltime)
385
+ {
386
+ struct tm *p_tm = (struct tm *) calloc(1, sizeof(struct tm));
387
+ if (!iso9660_get_ltime (p_ltime, p_tm)) {
388
+ free(p_tm);
389
+ return NULL;
390
+ }
391
+ return p_tm;
392
+ }
393
+ %}
394
+
395
+ /*========================================================
396
+ Characters used in file and directory and manipulation
397
+ =======================================================*/
398
+ %feature("autodoc",
399
+ " Return true if c is a DCHAR - a character that can appear in an an
400
+ ISO-9600 level 1 directory name. These are the ASCII capital
401
+ letters A-Z, the digits 0-9 and an underscore.");
402
+ #if LIBCDIO_VERSION_NUM <= 76
403
+ %rename iso9660_isdchar "dchar?";
404
+ bool iso9660_isdchar (int c);
405
+ #else
406
+ %rename iso9660_is_dchar "dchar?";
407
+ bool iso9660_is_dchar (int c);
408
+ #endif
409
+
410
+ %feature("autodoc",
411
+ "Return true if c is an ACHAR -
412
+ These are the DCHAR's plus some ASCII symbols including the space
413
+ symbol.");
414
+ #if LIBCDIO_VERSION_NUM <= 76
415
+ %rename iso9660_isachar "achar?";
416
+ bool iso9660_isachar (int c);
417
+ #else
418
+ %rename iso9660_is_achar "achar?";
419
+ bool iso9660_is_achar (int c);
420
+ #endif
421
+
422
+ %feature("autodoc",
423
+ "Convert an ISO-9660 file name that stored in a directory entry into
424
+ what's usually listed as the file name in a listing.
425
+ Lowercase name, and remove trailing ;1's or .;1's and
426
+ turn the other ;'s into version numbers.
427
+
428
+ @param psz_oldname the ISO-9660 filename to be translated.
429
+ @param psz_newname returned string. The caller allocates this and
430
+ it should be at least the size of psz_oldname.
431
+ @return length of the translated string is returned.");
432
+ %newobject name_translate;
433
+ char * name_translate(const char *psz_oldname);
434
+ %inline %{
435
+ char *
436
+ name_translate(const char *psz_oldname) {
437
+ char *psz_newname=calloc(sizeof(char), strlen(psz_oldname));
438
+ iso9660_name_translate(psz_oldname, psz_newname);
439
+ return psz_newname;
440
+ }
441
+ %}
442
+
443
+ %feature("autodoc",
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.
448
+
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
453
+ Joliet level.
454
+ @return length of the translated string is returned. It will be no greater
455
+ than the length of psz_oldname.");
456
+ %newobject name_translate_ext;
457
+ char * name_translate_ext(const char *psz_oldname, uint8_t i_joliet_level);
458
+ %inline %{
459
+ char *
460
+ name_translate_ext(const char *psz_oldname, uint8_t i_joliet_level) {
461
+ char *psz_newname=calloc(sizeof(char), strlen(psz_oldname));
462
+ iso9660_name_translate_ext(psz_oldname, psz_newname, i_joliet_level);
463
+ return psz_newname;
464
+ }
465
+ %}
466
+
467
+ %feature("autodoc",
468
+ "Pad string src with spaces to size len and copy this to dst. If
469
+ en is less than the length of src, dst will be truncated to the
470
+ first len characters of src.
471
+
472
+ src can also be scanned to see if it contains only ACHARs, DCHARs,
473
+ 7-bit ASCII chars depending on the enumeration _check.
474
+
475
+ In addition to getting changed, dst is the return value.
476
+ Note: this string might not be NULL terminated.");
477
+ %newobject strncpy_pad; // free malloc'd return value
478
+ char *strncpy_pad(const char src[], size_t len, enum strncpy_pad_check _check);
479
+ %inline %{
480
+ char *
481
+ strncpy_pad(const char src[], size_t len, enum strncpy_pad_check _check) {
482
+ char *dst = calloc(sizeof(char), len+1);
483
+ return iso9660_strncpy_pad(dst, src, len, _check);
484
+ }
485
+ %}
486
+
487
+ /*=====================================================================
488
+ Files and Directory Names
489
+ ======================================================================*/
490
+
491
+ %feature("autodoc",
492
+ "Check that psz_path is a valid ISO-9660 directory name.
493
+
494
+ A valid directory name should not start out with a slash (/),
495
+ dot (.) or null byte, should be less than 37 characters long,
496
+ have no more than 8 characters in a directory component
497
+ which is separated by a /, and consist of only DCHARs.
498
+
499
+ True is returned if psz_path is valid.");
500
+ %rename iso9660_dirname_valid_p "dirname_valid?";
501
+ bool iso9660_dirname_valid_p (const char psz_path[]);
502
+
503
+ %feature("autodoc",
504
+ "Take psz_path and a version number and turn that into a ISO-9660
505
+ pathname. (That's just the pathname followed by ';' and the version
506
+ number. For example, mydir/file.ext -> MYDIR/FILE.EXT;1 for version
507
+ 1. The resulting ISO-9660 pathname is returned.");
508
+ %rename iso9660_pathname_isofy pathname_isofy;
509
+ %newobject iso9660_pathname_isofy; // free malloc'd return value
510
+ char *iso9660_pathname_isofy (const char psz_path[], uint16_t i_version=1);
511
+
512
+ %feature("autodoc",
513
+ "Check that psz_path is a valid ISO-9660 pathname.
514
+
515
+ A valid pathname contains a valid directory name, if one appears and
516
+ the filename portion should be no more than 8 characters for the
517
+ file prefix and 3 characters in the extension (or portion after a
518
+ dot). There should be exactly one dot somewhere in the filename
519
+ portion and the filename should be composed of only DCHARs.
520
+
521
+ True is returned if psz_path is valid.");
522
+ %rename iso9660_pathname_valid_p "pathname_valid?";
523
+ bool iso9660_pathname_valid_p (const char psz_path[]);
524
+
525
+ /* ... */
526
+
527
+ %feature("autodoc",
528
+ "Given a directory pointer, find the filesystem entry that contains
529
+ lsn and return information about it.
530
+
531
+ Returns stat_t of entry if we found lsn, or None otherwise.");
532
+ #if 0
533
+ %rename iso9660_find_fs_lsn fs_find_lsn;
534
+ IsoStat_t *iso9660_find_fs_lsn(CdIo_t *p_cdio, lsn_t i_lsn);
535
+
536
+
537
+ %feature("autodoc",
538
+ "Given a directory pointer, find the filesystem entry that contains
539
+ lsn and return information about it.
540
+
541
+ Returns stat_t of entry if we found lsn, or None otherwise.");
542
+ %rename iso9660_find_ifs_lsn ifs_find_lsn;
543
+ IsoStat_t *iso9660_find_ifs_lsn(const iso9660_t *p_iso, lsn_t i_lsn);
544
+ #endif
545
+
546
+
547
+ %feature("autodoc",
548
+ "Return file status for psz_path. None is returned on error.");
549
+ %rename iso9660_fs_stat fs_stat;
550
+ IsoStat_t *iso9660_fs_stat (CdIo_t *p_cdio, const char psz_path[]);
551
+
552
+
553
+ %feature("autodoc",
554
+ "Return file status for path name psz_path. None is returned on error.
555
+ pathname version numbers in the ISO 9660 name are dropped, i.e. ;1
556
+ is removed and if level 1 ISO-9660 names are lowercased.
557
+
558
+ The b_mode2 parameter is not used.");
559
+ %rename iso9660_fs_stat_translate fs_stat_translate;
560
+ IsoStat_t *iso9660_fs_stat_translate (CdIo_t *p_cdio,
561
+ const char psz_path[],
562
+ bool b_mode2=false);
563
+
564
+ %feature("autodoc",
565
+ "Return file status for pathname. None is returned on error.");
566
+ %rename iso9660_ifs_stat ifs_stat;
567
+ IsoStat_t *iso9660_ifs_stat (iso9660_t *p_iso, const char psz_path[]);
568
+
569
+
570
+ %feature("autodoc",
571
+ "Return file status for path name psz_path. undef is returned on error.
572
+ pathname version numbers in the ISO 9660 name are dropped, i.e. ;1 is
573
+ removed and if level 1 ISO-9660 names are lowercased.");
574
+ %rename iso9660_ifs_stat_translate ifs_stat_translate;
575
+ IsoStat_t *iso9660_ifs_stat_translate (iso9660_t *p_iso,
576
+ const char psz_path[]);
577
+
578
+ %feature("autodoc",
579
+ "Read psz_path (a directory) and return a list of iso9660_stat_t
580
+ pointers for the files inside that directory.");
581
+ IsoStatList_t *fs_readdir (CdIo_t *p_cdio, const char psz_path[]);
582
+
583
+ %inline %{
584
+ IsoStatList_t *fs_readdir (CdIo_t *p_cdio, const char psz_path[])
585
+ {
586
+ CdioList_t *p_statlist = iso9660_fs_readdir (p_cdio, psz_path, false);
587
+ return p_statlist;
588
+ }
589
+ %}
590
+
591
+ %feature("autodoc",
592
+ "Read psz_path (a directory) and return a list of iso9660_stat_t
593
+ pointers for the files inside that directory.");
594
+ IsoStatList_t *ifs_readdir (iso9660_t *p_iso, const char psz_path[]);
595
+
596
+ %inline %{
597
+ IsoStatList_t *ifs_readdir (iso9660_t *p_iso, const char psz_path[])
598
+ {
599
+ CdioList_t *p_statlist = iso9660_ifs_readdir (p_iso, psz_path);
600
+ return p_statlist;
601
+ }
602
+ %}
603
+
604
+ %feature("autodoc",
605
+ "Return the PVD's application ID.
606
+ None is returned if there is some problem in getting this.");
607
+ %rename iso9660_get_application_id get_application_id;
608
+ char * iso9660_get_application_id(iso9660_pvd_t *p_pvd);
609
+
610
+ typedef char * string_or_nil_t;
611
+
612
+ %typemap(out) string_or_nil_t{
613
+ if (result == NULL) return Qnil;
614
+ vresult = rb_str_new2(result);
615
+ }
616
+
617
+
618
+ %feature("autodoc",
619
+ "Get the application ID. Return None if there
620
+ is some problem in getting this.");
621
+ %newobject ifs_get_application_id; // free malloc'd return value
622
+ string_or_nil_t ifs_get_application_id(iso9660_t *p_iso);
623
+ %inline %{
624
+ typedef char * string_or_nil_t;
625
+ string_or_nil_t
626
+ ifs_get_application_id(iso9660_t *p_iso) {
627
+ char *psz;
628
+ bool ok = iso9660_ifs_get_application_id(p_iso, &psz);
629
+ if (!ok) return NULL;
630
+ return psz;
631
+ }
632
+ %}
633
+
634
+
635
+ %feature("autodoc",
636
+ "Return the Joliet level recognized for p_iso.");
637
+ %rename iso9660_ifs_get_joliet_level get_joliet_level;
638
+ uint8_t iso9660_ifs_get_joliet_level(iso9660_t *p_iso);
639
+
640
+ %rename iso9660_get_dir_len get_dir_len;
641
+ uint8_t iso9660_get_dir_len(const iso9660_dir_t *p_idr);
642
+
643
+ %feature("autodoc",
644
+ "Return the directory name stored in the iso9660_dir_t.");
645
+ %newobject iso9660_dir_to_name; // free malloc'd return value
646
+ %rename iso9660_get_to_name get_to_name;
647
+ char * iso9660_dir_to_name (const iso9660_dir_t *p_iso9660_dir);
648
+
649
+ #if LIBCDIO_VERSION_NUM > 76
650
+ %feature("autodoc",
651
+ "Returns a POSIX mode for a given p_iso_dirent.");
652
+ %rename iso9660_get_posix_filemode get_posix_filemode;
653
+ mode_t iso9660_get_posix_filemode(const iso9660_stat_t *p_iso_dirent);
654
+ #endif
655
+
656
+ %feature("autodoc",
657
+ "Return a string containing the preparer id with trailing
658
+ blanks removed.");
659
+ %rename iso9660_get_preparer_id get_preparer_id;
660
+ char *iso9660_get_preparer_id(const iso9660_pvd_t *p_pvd);
661
+
662
+ %feature("autodoc",
663
+ "Get the preparer ID. Return None if there is some problem in
664
+ getting this.");
665
+ %newobject ifs_get_preparer_id; // free malloc'd return value
666
+ string_or_nil_t ifs_get_preparer_id(iso9660_t *p_iso);
667
+ %inline %{
668
+ string_or_nil_t
669
+ ifs_get_preparer_id(iso9660_t *p_iso) {
670
+ char *psz;
671
+ bool ok = iso9660_ifs_get_preparer_id(p_iso, &psz);
672
+ if (!ok) return NULL;
673
+ return psz;
674
+ }
675
+ %}
676
+
677
+ %feature("autodoc",
678
+ "Return a string containing the PVD's publisher id with trailing
679
+ blanks removed.");
680
+ %rename iso9660_get_publisher_id get_publisher_id;
681
+ char *iso9660_get_publisher_id(const iso9660_pvd_t *p_pvd);
682
+
683
+ %feature("autodoc",
684
+ "Get the publisher ID. Return None if there
685
+ is some problem in getting this.");
686
+ %newobject ifs_get_publisher_id; // free malloc'd return value
687
+ string_or_nil_t ifs_get_publisher_id(iso9660_t *p_iso);
688
+ %inline %{
689
+ string_or_nil_t
690
+ ifs_get_publisher_id(iso9660_t *p_iso) {
691
+ char *psz;
692
+ bool ok = iso9660_ifs_get_publisher_id(p_iso, &psz);
693
+ if (!ok) return NULL;
694
+ return psz;
695
+ }
696
+ %}
697
+
698
+ %rename iso9660_get_pvd_type get_pvd_type;
699
+ uint8_t iso9660_get_pvd_type(const iso9660_pvd_t *p_pvd);
700
+
701
+ %rename iso9660_get_pvd_id get_pvd_id;
702
+ const char * iso9660_get_pvd_id(const iso9660_pvd_t *p_pvd);
703
+
704
+ %rename iso9660_get_pvd_space_size get_pvd_space_size;
705
+ int iso9660_get_pvd_space_size(const iso9660_pvd_t *p_pvd);
706
+
707
+ %rename iso9660_get_pvd_block_size get_pvd_block_size;
708
+ int iso9660_get_pvd_block_size(const iso9660_pvd_t *p_pvd) ;
709
+
710
+ %feature("autodoc",
711
+ "Return the primary volume id version number (of pvd).
712
+ If there is an error 0 is returned.");
713
+ %rename iso9660_get_pvd_version get_pvd_version;
714
+ int iso9660_get_pvd_version(const iso9660_pvd_t *pvd) ;
715
+
716
+ %feature("autodoc",
717
+ "Return a string containing the PVD's system id with trailing
718
+ blanks removed.");
719
+ %rename iso9660_get_system_id get_system_id;
720
+ char *iso9660_get_system_id(const iso9660_pvd_t *p_pvd);
721
+
722
+ %feature("autodoc",
723
+ "Get the system ID. None is returned if there
724
+ is some problem in getting this.");
725
+ %newobject ifs_get_system_id; // free malloc'd return value
726
+ char *ifs_get_system_id(iso9660_t *p_iso);
727
+ %inline %{
728
+ char *
729
+ ifs_get_system_id(iso9660_t *p_iso) {
730
+ char *psz;
731
+ bool ok = iso9660_ifs_get_system_id(p_iso, &psz);
732
+ if (!ok) return NULL;
733
+ return psz;
734
+ }
735
+ %}
736
+
737
+ %feature("autodoc",
738
+ "Return the LSN of the root directory for pvd. If there is an error
739
+ INVALID_LSN is returned.
740
+ ");
741
+ %rename iso9660_get_root_lsn get_root_lsn;
742
+ lsn_t iso9660_get_root_lsn(const iso9660_pvd_t *p_pvd);
743
+
744
+ %feature("autodoc",
745
+ "Return the PVD's volume ID.");
746
+ %rename iso9660_get_volume_id get_volume_id;
747
+ char *iso9660_get_volume_id(const iso9660_pvd_t *p_pvd);
748
+
749
+ %feature("autodoc",
750
+ "Get the system ID. None is returned if there
751
+ is some problem in getting this.");
752
+ %newobject ifs_get_volume_id; // free malloc'd return value
753
+ char *ifs_get_volume_id(iso9660_t *p_iso);
754
+ %inline %{
755
+ char *
756
+ ifs_get_volume_id(iso9660_t *p_iso) {
757
+ char *psz;
758
+ bool ok = iso9660_ifs_get_volume_id(p_iso, &psz);
759
+ if (!ok) return NULL;
760
+ return psz;
761
+ }
762
+ %}
763
+
764
+ %feature("autodoc",
765
+ " Return the PVD's volumeset ID.
766
+ None is returned if there is some problem in getting this.
767
+ ");
768
+ %rename iso9660_get_volumeset_id get_volumeset_id;
769
+ char *iso9660_get_volumeset_id(const iso9660_pvd_t *p_pvd);
770
+
771
+ %feature("autodoc",
772
+ "Get the volumeset ID. None is returned if there
773
+ is some problem in getting this.");
774
+ %newobject ifs_get_volumeset_id; // free malloc'd return value
775
+ string_or_nil_t ifs_get_volumeset_id(iso9660_t *p_iso);
776
+ %inline %{
777
+ string_or_nil_t
778
+ ifs_get_volumeset_id(iso9660_t *p_iso) {
779
+ char *psz;
780
+ bool ok = iso9660_ifs_get_volumeset_id(p_iso, &psz);
781
+ if (!ok) return NULL;
782
+ return psz;
783
+ }
784
+ %}
785
+
786
+ /* ================= pathtable ================== */
787
+
788
+ %feature("autodoc",
789
+ "Zero's out pathable. Do this first.");
790
+ %rename iso9660_pathtable_init pathtable_init;
791
+ void iso9660_pathtable_init (void *pt);
792
+
793
+ %rename iso9660_pathtable_get_size pathtable_get_size;
794
+ unsigned int iso9660_pathtable_get_size (const void *pt);
795
+
796
+ %rename iso9660_pathtable_l_add_entry pathtable_l_add_entry;
797
+ uint16_t iso9660_pathtable_l_add_entry (void *pt, const char name[],
798
+ uint32_t extent, uint16_t parent);
799
+
800
+ %rename iso9660_pathtable_m_add_entry pathtable_m_add_entry;
801
+ uint16_t iso9660_pathtable_m_add_entry (void *pt, const char name[],
802
+ uint32_t extent, uint16_t parent);
803
+
804
+ /*======================================================================
805
+ Volume Descriptors
806
+ ========================================================================*/
807
+
808
+ #ifdef FINSHED
809
+ void iso9660_set_pvd (void *pd, const char volume_id[],
810
+ const char application_id[],
811
+ const char publisher_id[], const char preparer_id[],
812
+ uint32_t iso_size, const void *root_dir,
813
+ uint32_t path_table_l_extent,
814
+ uint32_t path_table_m_extent,
815
+ uint32_t path_table_size, const time_t *pvd_time);
816
+ #endif /*FINISHED*/
817
+
818
+ %rename iso9660_set_evd set_evd;
819
+ void iso9660_set_evd (void *pd);
820
+
821
+ %feature("autodoc",
822
+ "Return true if ISO 9660 image has extended attrributes (XA).");
823
+ %rename iso9660_ifs_is_xa "xa?";
824
+ bool iso9660_ifs_is_xa (const iso9660_t * p_iso);
825
+
826
+ // %rubycode %{
827
+ //%}