rbcdio 0.01
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -0
- data/COPYING +340 -0
- data/ChangeLog +315 -0
- data/INSTALL +236 -0
- data/Makefile.am +163 -0
- data/Makefile.in +557 -0
- data/NEWS +5 -0
- data/README +75 -0
- data/Rakefile +234 -0
- data/THANKS +3 -0
- data/VERSION +1 -0
- data/VERSION.in +1 -0
- data/config.guess +1473 -0
- data/config.sub +1576 -0
- data/configure +4802 -0
- data/configure.ac +158 -0
- data/data/copying.iso +0 -0
- data/data/isofs-m1.bin +0 -0
- data/data/isofs-m1.cue +3 -0
- data/doc/created.rid +1 -0
- data/doc/fr_class_index.html +42 -0
- data/doc/fr_file_index.html +40 -0
- data/doc/fr_method_index.html +133 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/example/COPYING +340 -0
- data/example/README +47 -0
- data/example/audio.rb +186 -0
- data/example/cd-read.rb +167 -0
- data/example/copying +340 -0
- data/example/device.rb +91 -0
- data/example/drivers.rb +63 -0
- data/example/drives.rb +63 -0
- data/example/eject.rb +69 -0
- data/example/iso1.rb +89 -0
- data/example/iso2.rb +106 -0
- data/example/iso3.rb +111 -0
- data/example/tracks.rb +83 -0
- data/ext/cdio/Makefile +139 -0
- data/ext/cdio/extconf.rb +9 -0
- data/ext/cdio/rubycdio_wrap.c +3410 -0
- data/ext/iso9660/Makefile +139 -0
- data/ext/iso9660/extconf.rb +10 -0
- data/ext/iso9660/rubyiso9660_wrap.c +3005 -0
- data/install-sh +323 -0
- data/lib/Makefile +7 -0
- data/lib/cdio.rb +1000 -0
- data/lib/iso9660.rb +566 -0
- data/missing +360 -0
- data/rubycdio.m4 +14 -0
- data/swig/Makefile +7 -0
- data/swig/audio.swg +63 -0
- data/swig/compat.swg +104 -0
- data/swig/device.swg +513 -0
- data/swig/device_const.swg +144 -0
- data/swig/disc.swg +96 -0
- data/swig/read.swg +164 -0
- data/swig/rubycdio.swg +86 -0
- data/swig/rubyiso9660.swg +827 -0
- data/swig/track.swg +206 -0
- data/swig/types.swg +65 -0
- data/test/Makefile +7 -0
- data/test/Rakefile +8 -0
- data/test/cdda.bin +0 -0
- data/test/cdda.cue +7 -0
- data/test/cdda.toc +14 -0
- data/test/cdiotest.rb +228 -0
- data/test/isocopy.rb +394 -0
- data/test/isotest.rb +187 -0
- metadata +116 -0
data/swig/disc.swg
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
/* -*- c -*-
|
2
|
+
$Id: disc.swg,v 1.1.1.1 2006/11/13 05:13:33 rocky Exp $
|
3
|
+
|
4
|
+
Copyright (C) 2006 Rocky Bernstein <rocky@cpan.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
+
*/
|
20
|
+
/* See <cdio/device.h> for more extensive documentation. */
|
21
|
+
|
22
|
+
%constant long int DISC_MODE_CD_DA = CDIO_DISC_MODE_CD_DA;
|
23
|
+
%constant long int DISC_MODE_CD_DATA = CDIO_DISC_MODE_CD_DATA;
|
24
|
+
%constant long int DISC_MODE_CD_XA = CDIO_DISC_MODE_CD_XA;
|
25
|
+
%constant long int DISC_MODE_CD_MIXED = CDIO_DISC_MODE_CD_MIXED;
|
26
|
+
%constant long int DISC_MODE_DVD_ROM = CDIO_DISC_MODE_DVD_ROM;
|
27
|
+
%constant long int DISC_MODE_DVD_RAM = CDIO_DISC_MODE_DVD_RAM;
|
28
|
+
%constant long int DISC_MODE_DVD_R = CDIO_DISC_MODE_DVD_R;
|
29
|
+
%constant long int DISC_MODE_DVD_RW = CDIO_DISC_MODE_DVD_RW;
|
30
|
+
%constant long int DISC_MODE_DVD_PR = CDIO_DISC_MODE_DVD_PR;
|
31
|
+
%constant long int DISC_MODE_DVD_PRW = CDIO_DISC_MODE_DVD_PRW;
|
32
|
+
%constant long int DISC_MODE_DVD_OTHER = CDIO_DISC_MODE_DVD_OTHER;
|
33
|
+
%constant long int DISC_MODE_NO_INFO = CDIO_DISC_MODE_NO_INFO;
|
34
|
+
%constant long int DISC_MODE_ERROR = CDIO_DISC_MODE_ERROR;
|
35
|
+
%constant long int DISC_MODE_CD_I = CDIO_DISC_MODE_CD_I;
|
36
|
+
|
37
|
+
%rename cdio_get_disc_last_lsn get_disc_last_lsn;
|
38
|
+
%feature("autodoc",
|
39
|
+
"get_disc_last_lsn(cdio)->lsn
|
40
|
+
Get the LSN of the end of the CD.
|
41
|
+
|
42
|
+
perlcdio.INVALID_LSN is returned on error.");
|
43
|
+
lsn_t cdio_get_disc_last_lsn(const CdIo_t *p_cdio);
|
44
|
+
|
45
|
+
|
46
|
+
%feature("autodoc",
|
47
|
+
"get_disc_mode(p_cdio) -> str
|
48
|
+
|
49
|
+
Get disc mode - the kind of CD (CD-DA, CD-ROM mode 1, CD-MIXED, etc.
|
50
|
+
that we've got. The notion of 'CD' is extended a little to include
|
51
|
+
DVD's.");
|
52
|
+
const char *get_disc_mode (CdIo_t *p_cdio);
|
53
|
+
|
54
|
+
%rename cdio_get_joliet_level get_joliet_level;
|
55
|
+
%feature("autodoc",
|
56
|
+
"get_joliet_level(cdio)->int
|
57
|
+
|
58
|
+
Return the Joliet level recognized for cdio.
|
59
|
+
This only makes sense for something that has an ISO-9660
|
60
|
+
filesystem.");
|
61
|
+
int cdio_get_joliet_level(const CdIo_t *p_cdio);
|
62
|
+
|
63
|
+
/*!
|
64
|
+
Get the media catalog number (MCN) from the CD.
|
65
|
+
|
66
|
+
@return the media catalog number or NULL if there is none or we
|
67
|
+
don't have the ability to get it.
|
68
|
+
|
69
|
+
Note: string is malloc'd so caller has to free() the returned
|
70
|
+
string when done with it.
|
71
|
+
|
72
|
+
*/
|
73
|
+
%rename cdio_get_mcn get_mcn;
|
74
|
+
%newobject cdio_get_mcn; // free malloc'd return value
|
75
|
+
char * cdio_get_mcn (const CdIo_t *p_cdio);
|
76
|
+
|
77
|
+
%rename cdio_get_num_tracks get_num_tracks;
|
78
|
+
%feature("autodoc",
|
79
|
+
"get_num_tracks(p_cdio)->int
|
80
|
+
|
81
|
+
Return the number of tracks on the CD.
|
82
|
+
On error rubycdio::INVALID_TRACK is returned.");
|
83
|
+
track_t cdio_get_num_tracks (const CdIo_t *p_cdio);
|
84
|
+
|
85
|
+
/*========================INLINE======================================*/
|
86
|
+
|
87
|
+
%inline %{
|
88
|
+
const char *
|
89
|
+
get_disc_mode (CdIo_t *p_cdio)
|
90
|
+
{
|
91
|
+
discmode_t discmode = cdio_get_discmode(p_cdio);
|
92
|
+
if (CDIO_DISC_MODE_ERROR == discmode) return NULL;
|
93
|
+
return discmode2str[discmode];
|
94
|
+
}
|
95
|
+
|
96
|
+
%}
|
data/swig/read.swg
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
/* -*- c -*-
|
2
|
+
$Id: read.swg,v 1.4 2006/11/29 01:43:28 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
|
+
/* See <cdio/read.h> for more extensive documentation. */
|
22
|
+
|
23
|
+
%constant long int READ_MODE_AUDIO = CDIO_READ_MODE_AUDIO;
|
24
|
+
%constant long int READ_MODE_M1F1 = CDIO_READ_MODE_M1F1;
|
25
|
+
%constant long int READ_MODE_M1F2 = CDIO_READ_MODE_M1F2;
|
26
|
+
%constant long int READ_MODE_M2F1 = CDIO_READ_MODE_M2F1;
|
27
|
+
%constant long int READ_MODE_M2F2 = CDIO_READ_MODE_M2F2;
|
28
|
+
|
29
|
+
%inline %{
|
30
|
+
typedef struct {
|
31
|
+
char *data;
|
32
|
+
size_t size;
|
33
|
+
driver_return_code_t drc;
|
34
|
+
} Buf_triple_t;
|
35
|
+
%}
|
36
|
+
|
37
|
+
%rename cdio_lseek lseek;
|
38
|
+
off_t cdio_lseek(const CdIo_t *p_cdio, off_t offset, int whence=SEEK_SET);
|
39
|
+
|
40
|
+
%typemap(out) Buf_triple_t
|
41
|
+
{
|
42
|
+
if (!$1.data)
|
43
|
+
return Qnil;
|
44
|
+
else {
|
45
|
+
VALUE data_triple = rb_ary_new();
|
46
|
+
rb_ary_push(data_triple, rb_str_new($1.data, $1.size));
|
47
|
+
rb_ary_push(data_triple, INT2NUM($1.size));
|
48
|
+
rb_ary_push(data_triple, INT2NUM($1.drc));
|
49
|
+
free($1.data);
|
50
|
+
return data_triple;
|
51
|
+
}
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
Buf_triple_t read_cd(const CdIo_t *p_cdio, size_t i_size);
|
56
|
+
|
57
|
+
%inline %{
|
58
|
+
Buf_triple_t read_cd(const CdIo_t *p_cdio, size_t i_size)
|
59
|
+
{
|
60
|
+
Buf_triple_t buf;
|
61
|
+
buf.data = calloc(1, i_size);
|
62
|
+
buf.size = cdio_read(p_cdio, buf.data, i_size);
|
63
|
+
if (buf.size == -1) {
|
64
|
+
free(buf.data);
|
65
|
+
buf.drc = DRIVER_OP_ERROR;
|
66
|
+
buf.data = NULL;
|
67
|
+
}
|
68
|
+
return buf;
|
69
|
+
}
|
70
|
+
%}
|
71
|
+
|
72
|
+
/* NOTE: arg 4 *must* be the size of the buf for the buf_t typemap. */
|
73
|
+
Buf_triple_t read_sectors(const CdIo_t *p_cdio, lsn_t i_lsn,
|
74
|
+
cdio_read_mode_t read_mode, size_t i_size);
|
75
|
+
%inline %{
|
76
|
+
/* NOTE: arg 4 *must* be the size of the buf for the buf_t typemap. */
|
77
|
+
Buf_triple_t
|
78
|
+
read_sectors(const CdIo_t *p_cdio, lsn_t i_lsn, cdio_read_mode_t read_mode,
|
79
|
+
size_t i_size)
|
80
|
+
{
|
81
|
+
Buf_triple_t buf;
|
82
|
+
uint32_t i_blocks;
|
83
|
+
uint16_t i_blocksize;
|
84
|
+
switch (read_mode) {
|
85
|
+
case CDIO_READ_MODE_AUDIO:
|
86
|
+
i_blocksize = CDIO_CD_FRAMESIZE_RAW;
|
87
|
+
break;
|
88
|
+
case CDIO_READ_MODE_M1F1:
|
89
|
+
i_blocksize = M2RAW_SECTOR_SIZE;
|
90
|
+
break;
|
91
|
+
case CDIO_READ_MODE_M1F2:
|
92
|
+
i_blocksize = M2RAW_SECTOR_SIZE;
|
93
|
+
break;
|
94
|
+
case CDIO_READ_MODE_M2F1:
|
95
|
+
i_blocksize = CDIO_CD_FRAMESIZE;
|
96
|
+
break;
|
97
|
+
case CDIO_READ_MODE_M2F2:
|
98
|
+
i_blocksize = M2F2_SECTOR_SIZE;
|
99
|
+
break;
|
100
|
+
default:
|
101
|
+
buf.data = NULL;
|
102
|
+
buf.drc = DRIVER_OP_BAD_PARAMETER;
|
103
|
+
buf.size = -1;
|
104
|
+
return buf;
|
105
|
+
}
|
106
|
+
buf.data = calloc(1, i_size);
|
107
|
+
i_blocks = i_size / i_blocksize;
|
108
|
+
buf.drc = cdio_read_sectors(p_cdio, buf.data, i_lsn, read_mode, i_blocks);
|
109
|
+
if (buf.drc < 0) {
|
110
|
+
free(buf.data);
|
111
|
+
buf.data = NULL;
|
112
|
+
buf.size = -1;
|
113
|
+
} else {
|
114
|
+
buf.size = i_size;
|
115
|
+
}
|
116
|
+
return buf;
|
117
|
+
|
118
|
+
}
|
119
|
+
%}
|
120
|
+
|
121
|
+
Buf_triple_t
|
122
|
+
read_data_bytes(const CdIo_t *p_cdio, lsn_t i_lsn, int16_t i_blocksize,
|
123
|
+
size_t i_size);
|
124
|
+
%inline %{
|
125
|
+
Buf_triple_t
|
126
|
+
read_data_bytes(const CdIo_t *p_cdio, lsn_t i_lsn, int16_t i_blocksize,
|
127
|
+
size_t i_size)
|
128
|
+
{
|
129
|
+
uint32_t i_blocks = i_size / i_blocksize;
|
130
|
+
Buf_triple_t buf;
|
131
|
+
|
132
|
+
switch (i_blocksize) {
|
133
|
+
case CDIO_CD_FRAMESIZE:
|
134
|
+
case CDIO_CD_FRAMESIZE_RAW:
|
135
|
+
case M2F2_SECTOR_SIZE:
|
136
|
+
case M2RAW_SECTOR_SIZE:
|
137
|
+
break;
|
138
|
+
default:
|
139
|
+
/* Don't know about these block sizes */
|
140
|
+
buf.data = NULL;
|
141
|
+
buf.drc = DRIVER_OP_BAD_PARAMETER;
|
142
|
+
buf.size = -1;
|
143
|
+
return buf;
|
144
|
+
}
|
145
|
+
buf.data = calloc(1, i_size);
|
146
|
+
|
147
|
+
#if DEBUGGING
|
148
|
+
printf("p_cdio: %x, i_size: %d, lsn: %d, blocksize %d, blocks %d\n",
|
149
|
+
p_cdio, i_size, i_lsn, i_blocksize, i_blocks);
|
150
|
+
#endif
|
151
|
+
buf.drc = cdio_read_data_sectors (p_cdio, buf.data, i_lsn,
|
152
|
+
i_blocksize, i_blocks);
|
153
|
+
#if DEBUGGING
|
154
|
+
printf("drc: %d\n", buf.drc);
|
155
|
+
#endif
|
156
|
+
if (buf.drc < 0) {
|
157
|
+
buf.data = NULL;
|
158
|
+
buf.size = -1;
|
159
|
+
} else {
|
160
|
+
buf.size = i_size;
|
161
|
+
}
|
162
|
+
return buf;
|
163
|
+
}
|
164
|
+
%}
|
data/swig/rubycdio.swg
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
/* -*- c -*-
|
2
|
+
$Id: rubycdio.swg,v 1.2 2006/11/13 21:44:31 rocky Exp $
|
3
|
+
|
4
|
+
Copyright (C) 2006 Rocky Bernstein <rocky@panix.com>
|
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 (libcdio) which
|
23
|
+
encapsulates CD-ROM reading and control. Python programs wishing to be
|
24
|
+
oblivious of the OS- and device-dependent properties of a CD-ROM can
|
25
|
+
use this library."
|
26
|
+
%enddef
|
27
|
+
%module(docstring=DOCSTRING) rubycdio
|
28
|
+
%{
|
29
|
+
/* Includes the header in the wrapper code */
|
30
|
+
#include <cdio/cdio.h>
|
31
|
+
#include <cdio/audio.h>
|
32
|
+
#include <cdio/cd_types.h>
|
33
|
+
%}
|
34
|
+
|
35
|
+
#include <cdio/cdio.h>
|
36
|
+
#include <cdio/audio.h>
|
37
|
+
|
38
|
+
%include "compat.swg"
|
39
|
+
|
40
|
+
%include "typemaps.i"
|
41
|
+
|
42
|
+
/* Various libcdio constants and typedefs */
|
43
|
+
%include "types.swg"
|
44
|
+
|
45
|
+
%feature("autodoc", 1);
|
46
|
+
|
47
|
+
%include "audio.swg"
|
48
|
+
%include "read.swg"
|
49
|
+
%include "track.swg"
|
50
|
+
|
51
|
+
/* In the presence of the exception handling, the order is important.
|
52
|
+
The below use %exception.
|
53
|
+
*/
|
54
|
+
%include "device.swg"
|
55
|
+
%include "disc.swg"
|
56
|
+
|
57
|
+
/* Encapsulation is done in two parts. The lower-level python
|
58
|
+
interface is called rubycdio and is generated by SWIG.
|
59
|
+
|
60
|
+
The more object-oriented module is cdio; it is a Python class that
|
61
|
+
uses rubycdio. Although rubycdio is perfectly usable on its own, it is
|
62
|
+
expected that cdio is what most people will use. As rubycdio more
|
63
|
+
closely models the C interface, it is conceivable (if unlikely) that
|
64
|
+
diehard libcdio C users who are very familiar with that interface
|
65
|
+
could prefer that.
|
66
|
+
|
67
|
+
It is probably possible to change the SWIG in such a way to combine
|
68
|
+
these pieces. However there are the problems. First, I'm not that much
|
69
|
+
of a SWIG expert. Second it looks as though the resulting SWIG code
|
70
|
+
would be more complex. Third the separation makes translation very
|
71
|
+
straight forward to understand and maintain: first get what's in C
|
72
|
+
into Python as a one-to-one translation. Then we implement some nice
|
73
|
+
abstraction off of that. The abstraction can be modified without
|
74
|
+
having to redo the underlying translation. (But the reverse is
|
75
|
+
generally not true: usually changes to the C-to-python translation,
|
76
|
+
rubycdio, do result in small, but obvious and straightforward changes to
|
77
|
+
the abstraction layer cdio.)
|
78
|
+
*/
|
79
|
+
#define INCLUDE_CLASS 0
|
80
|
+
#if INCLUDE_CLASS
|
81
|
+
/* In spite of the above, if we were to do things as a one-step approach,
|
82
|
+
this might be how it would be done. */
|
83
|
+
%rubycode %{
|
84
|
+
%include "cdio.rb"
|
85
|
+
%}
|
86
|
+
#endif
|