rbcddb 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -0
- data/README +33 -0
- data/Rakefile +182 -0
- data/example/example.rb +68 -0
- data/ext/cddb_conn.c +576 -0
- data/ext/cddb_conn.h +15 -0
- data/ext/cddb_disc.c +497 -0
- data/ext/cddb_disc.h +16 -0
- data/ext/cddb_mod.c +134 -0
- data/ext/cddb_mod.h +11 -0
- data/ext/cddb_rb.c +15 -0
- data/ext/cddb_track.c +327 -0
- data/ext/cddb_track.h +18 -0
- data/ext/extconf.rb +6 -0
- data/ext/usage.c +19 -0
- data/ext/usage.h +8 -0
- metadata +61 -0
data/ext/cddb_track.c
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
#include<ruby.h>
|
|
2
|
+
#include<cddb/cddb.h>
|
|
3
|
+
|
|
4
|
+
#include "cddb_conn.h"
|
|
5
|
+
#include "cddb_disc.h"
|
|
6
|
+
#include "cddb_track.h"
|
|
7
|
+
|
|
8
|
+
#include "usage.h"
|
|
9
|
+
|
|
10
|
+
VALUE cddb_track_rb;
|
|
11
|
+
|
|
12
|
+
static void crb_track_free(void *p) {
|
|
13
|
+
cddb_track_destroy(p);
|
|
14
|
+
decLibUsage();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static VALUE crb_to_string(const char* str) {
|
|
18
|
+
if (str)
|
|
19
|
+
return rb_str_new2(str);
|
|
20
|
+
else
|
|
21
|
+
return Qnil;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
cddb_track_t *get_cddb_track_from_Value(VALUE self) {
|
|
25
|
+
cddb_track_t *track = NULL;
|
|
26
|
+
Data_Get_Struct(self,cddb_track_t,track);
|
|
27
|
+
return track;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
VALUE makeValueFrom_cddb_track_t(cddb_track_t *track) {
|
|
31
|
+
VALUE obj=Qnil;
|
|
32
|
+
if (track) {
|
|
33
|
+
incLibUsage();
|
|
34
|
+
obj=Data_Wrap_Struct(cddb_track_rb,0,crb_track_free,track);
|
|
35
|
+
}
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
VALUE _makeValueFrom_cddb_track_t(cddb_track_t *track) {
|
|
40
|
+
VALUE obj=Qnil;
|
|
41
|
+
if (track) {
|
|
42
|
+
obj=Data_Wrap_Struct(cddb_track_rb,0,0,track);
|
|
43
|
+
}
|
|
44
|
+
return obj;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
static VALUE crb_track_alloc(VALUE klass)
|
|
50
|
+
{
|
|
51
|
+
VALUE obj;
|
|
52
|
+
cddb_track_t *track = NULL;
|
|
53
|
+
incLibUsage();
|
|
54
|
+
track = cddb_track_new();
|
|
55
|
+
if (track == NULL) {
|
|
56
|
+
rb_sys_fail("out of memory, "
|
|
57
|
+
"unable to create cddb_track structure");
|
|
58
|
+
}
|
|
59
|
+
obj=Data_Wrap_Struct(klass,0,crb_track_free,track);
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
* call-seq:
|
|
66
|
+
* clone -> CDDB_Track
|
|
67
|
+
*
|
|
68
|
+
* Makes an object with the same content as the current object
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
static VALUE crb_cddb_track_clone(VALUE self) {
|
|
72
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
73
|
+
return makeValueFrom_cddb_track_t(cddb_track_clone(track));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
* call-seq:
|
|
79
|
+
* number -> number
|
|
80
|
+
*
|
|
81
|
+
* The number of the track on the disc
|
|
82
|
+
*
|
|
83
|
+
*/
|
|
84
|
+
static VALUE crb_cddb_track_get_number(VALUE self) {
|
|
85
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
86
|
+
return INT2FIX(cddb_track_get_number(track));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
* call-seq:
|
|
91
|
+
* frame_offset -> number
|
|
92
|
+
*
|
|
93
|
+
* return frame_offset of the track on the disc
|
|
94
|
+
*
|
|
95
|
+
*/
|
|
96
|
+
static VALUE crb_cddb_track_get_frame_offset(VALUE self) {
|
|
97
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
98
|
+
return INT2NUM(cddb_track_get_frame_offset(track));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/*
|
|
102
|
+
* call-seq:
|
|
103
|
+
* frame_offset= number
|
|
104
|
+
*
|
|
105
|
+
* set frame_offset of the track on the disc
|
|
106
|
+
*
|
|
107
|
+
*/
|
|
108
|
+
static VALUE crb_cddb_track_set_frame_offset(VALUE self,VALUE offset) {
|
|
109
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
110
|
+
cddb_track_set_frame_offset(track,NUM2INT(offset));
|
|
111
|
+
return self;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/*
|
|
115
|
+
* call-seq:
|
|
116
|
+
* length -> number
|
|
117
|
+
*
|
|
118
|
+
* gets the length of the track, the length could be
|
|
119
|
+
* set explicit or have been calculated by libcddb
|
|
120
|
+
*/
|
|
121
|
+
static VALUE crb_cddb_track_get_length(VALUE self) {
|
|
122
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
123
|
+
return INT2NUM(cddb_track_get_length(track));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
* call-seq:
|
|
128
|
+
* length= number
|
|
129
|
+
*
|
|
130
|
+
* sets the length of the track, the length
|
|
131
|
+
* can also be calculated from the difference between
|
|
132
|
+
* the frame_offset of the current track and the next
|
|
133
|
+
* track
|
|
134
|
+
*
|
|
135
|
+
*/
|
|
136
|
+
static VALUE crb_cddb_track_set_length(VALUE self,VALUE length) {
|
|
137
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
138
|
+
cddb_track_set_length(track,NUM2INT(length));
|
|
139
|
+
return self;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/*
|
|
143
|
+
* call-seq:
|
|
144
|
+
* title -> string
|
|
145
|
+
*
|
|
146
|
+
* returns the title of the track
|
|
147
|
+
*/
|
|
148
|
+
static VALUE crb_cddb_track_get_title(VALUE self) {
|
|
149
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
150
|
+
return crb_to_string(cddb_track_get_title(track));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/*
|
|
154
|
+
* call-seq:
|
|
155
|
+
* title= string
|
|
156
|
+
*
|
|
157
|
+
* sets the title of the track
|
|
158
|
+
*/
|
|
159
|
+
static VALUE crb_cddb_track_set_title(VALUE self,VALUE title) {
|
|
160
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
161
|
+
cddb_track_set_title(track,STR2CSTR(title));
|
|
162
|
+
return self;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/*
|
|
166
|
+
* call-seq:
|
|
167
|
+
* artist -> string
|
|
168
|
+
*
|
|
169
|
+
* returns the artist of the track
|
|
170
|
+
*/
|
|
171
|
+
static VALUE crb_cddb_track_get_artist(VALUE self) {
|
|
172
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
173
|
+
return crb_to_string(cddb_track_get_artist(track));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/*
|
|
177
|
+
* call-seq:
|
|
178
|
+
* title= string
|
|
179
|
+
*
|
|
180
|
+
* sets the artist of the track (not the disc)
|
|
181
|
+
*/
|
|
182
|
+
static VALUE crb_cddb_track_set_artist(VALUE self,VALUE artist) {
|
|
183
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
184
|
+
cddb_track_set_artist(track,STR2CSTR(artist));
|
|
185
|
+
return self;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
/*
|
|
190
|
+
* call-seq:
|
|
191
|
+
* ext_data -> string
|
|
192
|
+
*
|
|
193
|
+
* gets the extra data of the track (not the disc)
|
|
194
|
+
*/
|
|
195
|
+
static VALUE crb_cddb_track_get_ext_data(VALUE self) {
|
|
196
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
197
|
+
return crb_to_string(cddb_track_get_ext_data(track));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/*
|
|
201
|
+
* call-seq:
|
|
202
|
+
* ext_data= string
|
|
203
|
+
*
|
|
204
|
+
* sets the extra data of the track (not the disc)
|
|
205
|
+
*/
|
|
206
|
+
static VALUE crb_cddb_track_set_ext_data(VALUE self,VALUE ext_data) {
|
|
207
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
208
|
+
cddb_track_set_ext_data(track,STR2CSTR(ext_data));
|
|
209
|
+
return self;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/*
|
|
213
|
+
* call-seq:
|
|
214
|
+
* print
|
|
215
|
+
*
|
|
216
|
+
* a debug method from the libcddb, it dumps the content of the object
|
|
217
|
+
* to the STDOUT for a quick inspection, the to_hash method
|
|
218
|
+
* will be more useful in most cases
|
|
219
|
+
*/
|
|
220
|
+
static VALUE crb_cddb_track_print(VALUE self) {
|
|
221
|
+
cddb_track_t *track=get_cddb_track_from_Value(self);
|
|
222
|
+
cddb_track_print(track);
|
|
223
|
+
return self;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
/*
|
|
229
|
+
* call-seq:
|
|
230
|
+
* copy_from(CDDB_Track)
|
|
231
|
+
*
|
|
232
|
+
* Copies the content of another CDDB_Track object
|
|
233
|
+
*
|
|
234
|
+
*/
|
|
235
|
+
static VALUE crb_cddb_track_copy_from(VALUE self,VALUE source) {
|
|
236
|
+
cddb_track_t *src=get_cddb_track_from_Value(source);
|
|
237
|
+
cddb_track_t *dst=get_cddb_track_from_Value(self);
|
|
238
|
+
cddb_track_copy(dst,src);
|
|
239
|
+
return self;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
/*
|
|
244
|
+
* call-seq:
|
|
245
|
+
* to_hash -> Hash
|
|
246
|
+
*
|
|
247
|
+
* Gets all the fields together as a ruby Hash
|
|
248
|
+
*
|
|
249
|
+
* def to_hash
|
|
250
|
+
* return {
|
|
251
|
+
* 'title'=> self.title,
|
|
252
|
+
* 'artist'=> self.artist,
|
|
253
|
+
* 'length'=> self.length,
|
|
254
|
+
* 'frame_offset'=> self.frame_offset,
|
|
255
|
+
* 'number'=> self.number,
|
|
256
|
+
* 'ext_data'=> self.ext_data,
|
|
257
|
+
* }
|
|
258
|
+
* end
|
|
259
|
+
*
|
|
260
|
+
*/
|
|
261
|
+
static VALUE crb_cddb_track_to_hash(VALUE self) {
|
|
262
|
+
VALUE hash=rb_hash_new();
|
|
263
|
+
|
|
264
|
+
rb_hash_aset(hash, rb_str_new2("title"),
|
|
265
|
+
crb_cddb_track_get_title(self));
|
|
266
|
+
|
|
267
|
+
rb_hash_aset(hash, rb_str_new2("artist"),
|
|
268
|
+
crb_cddb_track_get_artist(self));
|
|
269
|
+
|
|
270
|
+
rb_hash_aset(hash, rb_str_new2("length"),
|
|
271
|
+
crb_cddb_track_get_length(self));
|
|
272
|
+
|
|
273
|
+
rb_hash_aset(hash, rb_str_new2("frame_offset"),
|
|
274
|
+
crb_cddb_track_get_frame_offset(self));
|
|
275
|
+
|
|
276
|
+
rb_hash_aset(hash, rb_str_new2("number"),
|
|
277
|
+
crb_cddb_track_get_number(self));
|
|
278
|
+
|
|
279
|
+
rb_hash_aset(hash, rb_str_new2("ext_data"),
|
|
280
|
+
crb_cddb_track_get_ext_data(self));
|
|
281
|
+
|
|
282
|
+
return hash;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
/*
|
|
289
|
+
* Class +CDDB_Track+ represenst a track and can belong
|
|
290
|
+
* to a +CDDB_Disc+ object
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
void init_cddb_track() {
|
|
294
|
+
cddb_track_rb=rb_define_class("CDDB_Track",rb_cObject);
|
|
295
|
+
rb_define_alloc_func(cddb_track_rb,crb_track_alloc);
|
|
296
|
+
rb_define_method(cddb_track_rb,"clone",
|
|
297
|
+
crb_cddb_track_clone ,1);
|
|
298
|
+
rb_define_method(cddb_track_rb,"number",
|
|
299
|
+
crb_cddb_track_get_number ,0);
|
|
300
|
+
rb_define_method(cddb_track_rb,"frame_offset",
|
|
301
|
+
crb_cddb_track_get_frame_offset,0);
|
|
302
|
+
rb_define_method(cddb_track_rb,"frame_offset=",
|
|
303
|
+
crb_cddb_track_set_frame_offset,1);
|
|
304
|
+
rb_define_method(cddb_track_rb,"length",
|
|
305
|
+
crb_cddb_track_get_length,0);
|
|
306
|
+
rb_define_method(cddb_track_rb,"length=",
|
|
307
|
+
crb_cddb_track_set_length,1);
|
|
308
|
+
rb_define_method(cddb_track_rb,"title",
|
|
309
|
+
crb_cddb_track_get_title,0);
|
|
310
|
+
rb_define_method(cddb_track_rb,"title=",
|
|
311
|
+
crb_cddb_track_set_title,1);
|
|
312
|
+
rb_define_method(cddb_track_rb,"artist",
|
|
313
|
+
crb_cddb_track_get_artist,0);
|
|
314
|
+
rb_define_method(cddb_track_rb,"artist=",
|
|
315
|
+
crb_cddb_track_set_artist,1);
|
|
316
|
+
rb_define_method(cddb_track_rb,"ext_data",
|
|
317
|
+
crb_cddb_track_get_ext_data,0);
|
|
318
|
+
rb_define_method(cddb_track_rb,"ext_data=",
|
|
319
|
+
crb_cddb_track_set_ext_data,1);
|
|
320
|
+
rb_define_method(cddb_track_rb,"copy_from",
|
|
321
|
+
crb_cddb_track_copy_from,1);
|
|
322
|
+
rb_define_method(cddb_track_rb,"to_hash",
|
|
323
|
+
crb_cddb_track_to_hash,0);
|
|
324
|
+
rb_define_method(cddb_track_rb,"print",
|
|
325
|
+
crb_cddb_track_print,0);
|
|
326
|
+
|
|
327
|
+
}
|
data/ext/cddb_track.h
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#ifndef TRACK_HEADER
|
|
2
|
+
#define TRACK_HEADER
|
|
3
|
+
|
|
4
|
+
#include<ruby.h>
|
|
5
|
+
#include<cddb/cddb.h>
|
|
6
|
+
|
|
7
|
+
extern VALUE cddb_track_rb;
|
|
8
|
+
|
|
9
|
+
cddb_track_t *get_cddb_track_from_Value(VALUE self);
|
|
10
|
+
|
|
11
|
+
VALUE makeValueFrom_cddb_track_t(cddb_track_t *track);
|
|
12
|
+
|
|
13
|
+
VALUE _makeValueFrom_cddb_track_t(cddb_track_t *track);
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
void init_cddb_track();
|
|
17
|
+
|
|
18
|
+
#endif
|
data/ext/extconf.rb
ADDED
data/ext/usage.c
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#include<cddb/cddb.h>
|
|
2
|
+
#include "usage.h"
|
|
3
|
+
|
|
4
|
+
#include <stdio.h>
|
|
5
|
+
|
|
6
|
+
int libUsage=0;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
void incLibUsage() {
|
|
10
|
+
if (libUsage++>=0) {
|
|
11
|
+
libcddb_init();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
void decLibUsage() {
|
|
16
|
+
if (--libUsage<=0) {
|
|
17
|
+
libcddb_shutdown();
|
|
18
|
+
}
|
|
19
|
+
}
|
data/ext/usage.h
ADDED
metadata
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
rubygems_version: 0.9.4
|
|
3
|
+
specification_version: 1
|
|
4
|
+
name: rbcddb
|
|
5
|
+
version: !ruby/object:Gem::Version
|
|
6
|
+
version: 0.0.2
|
|
7
|
+
date: 2007-11-11 16:48:26 +01:00
|
|
8
|
+
summary: Ruby to libcddb ( http://libcddb.sourceforge.net)
|
|
9
|
+
require_paths:
|
|
10
|
+
- lib
|
|
11
|
+
email: juvanham@rubyforge.org
|
|
12
|
+
homepage: http://rubyforge.org/projects/rbcddb/
|
|
13
|
+
rubyforge_project: rbcddb
|
|
14
|
+
description: "Libcddb is a C library to access data on a CDDB server (freedb.org). It allows you to: 1. search the database for possible CD matches; 2. retrieve detailed information about a specific CD; 3. submit new CD entries to the database."
|
|
15
|
+
autorequire: rbcddb
|
|
16
|
+
default_executable:
|
|
17
|
+
bindir: bin
|
|
18
|
+
has_rdoc: true
|
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
20
|
+
requirements:
|
|
21
|
+
- - ">="
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
23
|
+
version: 1.8.4
|
|
24
|
+
version:
|
|
25
|
+
platform: ruby
|
|
26
|
+
signing_key:
|
|
27
|
+
cert_chain:
|
|
28
|
+
post_install_message:
|
|
29
|
+
authors:
|
|
30
|
+
- Jurgen Van Ham
|
|
31
|
+
files:
|
|
32
|
+
- Rakefile
|
|
33
|
+
- AUTHORS
|
|
34
|
+
- README
|
|
35
|
+
- example/example.rb
|
|
36
|
+
- ext/cddb_rb.c
|
|
37
|
+
- ext/cddb_track.c
|
|
38
|
+
- ext/cddb_conn.c
|
|
39
|
+
- ext/cddb_disc.c
|
|
40
|
+
- ext/cddb_mod.c
|
|
41
|
+
- ext/usage.c
|
|
42
|
+
- ext/cddb_track.h
|
|
43
|
+
- ext/cddb_conn.h
|
|
44
|
+
- ext/cddb_disc.h
|
|
45
|
+
- ext/cddb_mod.h
|
|
46
|
+
- ext/usage.h
|
|
47
|
+
- ext/extconf.rb
|
|
48
|
+
test_files: []
|
|
49
|
+
|
|
50
|
+
rdoc_options: []
|
|
51
|
+
|
|
52
|
+
extra_rdoc_files: []
|
|
53
|
+
|
|
54
|
+
executables: []
|
|
55
|
+
|
|
56
|
+
extensions:
|
|
57
|
+
- ext/extconf.rb
|
|
58
|
+
requirements: []
|
|
59
|
+
|
|
60
|
+
dependencies: []
|
|
61
|
+
|