rubyfb 0.5.2-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/LICENSE +411 -0
- data/Manifest +73 -0
- data/README +460 -0
- data/Rakefile +20 -0
- data/examples/example01.rb +65 -0
- data/ext/AddUser.c +464 -0
- data/ext/AddUser.h +37 -0
- data/ext/Backup.c +783 -0
- data/ext/Backup.h +37 -0
- data/ext/Blob.c +421 -0
- data/ext/Blob.h +65 -0
- data/ext/Common.c +54 -0
- data/ext/Common.h +37 -0
- data/ext/Connection.c +863 -0
- data/ext/Connection.h +50 -0
- data/ext/DataArea.c +274 -0
- data/ext/DataArea.h +38 -0
- data/ext/Database.c +449 -0
- data/ext/Database.h +48 -0
- data/ext/FireRuby.c +240 -0
- data/ext/FireRuby.h +50 -0
- data/ext/FireRubyException.c +268 -0
- data/ext/FireRubyException.h +51 -0
- data/ext/Generator.c +689 -0
- data/ext/Generator.h +53 -0
- data/ext/RemoveUser.c +212 -0
- data/ext/RemoveUser.h +37 -0
- data/ext/Restore.c +855 -0
- data/ext/Restore.h +37 -0
- data/ext/ResultSet.c +809 -0
- data/ext/ResultSet.h +60 -0
- data/ext/Row.c +965 -0
- data/ext/Row.h +55 -0
- data/ext/ServiceManager.c +316 -0
- data/ext/ServiceManager.h +48 -0
- data/ext/Services.c +124 -0
- data/ext/Services.h +42 -0
- data/ext/Statement.c +785 -0
- data/ext/Statement.h +62 -0
- data/ext/Transaction.c +684 -0
- data/ext/Transaction.h +50 -0
- data/ext/TypeMap.c +1182 -0
- data/ext/TypeMap.h +51 -0
- data/ext/extconf.rb +28 -0
- data/ext/mkmf.bat +1 -0
- data/lib/SQLType.rb +224 -0
- data/lib/active_record/connection_adapters/rubyfb_adapter.rb +805 -0
- data/lib/mkdoc +1 -0
- data/lib/rubyfb.rb +2 -0
- data/lib/rubyfb_lib.so +0 -0
- data/lib/src.rb +1800 -0
- data/rubyfb.gemspec +31 -0
- data/test/AddRemoveUserTest.rb +56 -0
- data/test/BackupRestoreTest.rb +99 -0
- data/test/BlobTest.rb +57 -0
- data/test/CharacterSetTest.rb +63 -0
- data/test/ConnectionTest.rb +111 -0
- data/test/DDLTest.rb +54 -0
- data/test/DatabaseTest.rb +83 -0
- data/test/GeneratorTest.rb +50 -0
- data/test/KeyTest.rb +140 -0
- data/test/ResultSetTest.rb +162 -0
- data/test/RoleTest.rb +73 -0
- data/test/RowCountTest.rb +65 -0
- data/test/RowTest.rb +203 -0
- data/test/SQLTest.rb +182 -0
- data/test/SQLTypeTest.rb +101 -0
- data/test/ServiceManagerTest.rb +29 -0
- data/test/StatementTest.rb +135 -0
- data/test/TestSetup.rb +11 -0
- data/test/TransactionTest.rb +112 -0
- data/test/TypeTest.rb +92 -0
- data/test/UnitTest.rb +65 -0
- metadata +149 -0
data/ext/Backup.h
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
/*------------------------------------------------------------------------------
|
2
|
+
* Backup.h
|
3
|
+
*----------------------------------------------------------------------------*/
|
4
|
+
/**
|
5
|
+
* Copyright � Peter Wood, 2005
|
6
|
+
*
|
7
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
8
|
+
* 1.1 (the "License"); you may not use this file except in compliance with the
|
9
|
+
* License. You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.mozilla.org/MPL/
|
12
|
+
*
|
13
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
14
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
15
|
+
* the specificlanguage governing rights and limitations under the License.
|
16
|
+
*
|
17
|
+
* The Original Code is the FireRuby extension for the Ruby language.
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
20
|
+
* Reserved.
|
21
|
+
*
|
22
|
+
* @author Peter Wood
|
23
|
+
* @version 1.0
|
24
|
+
*/
|
25
|
+
#ifndef FIRERUBY_BACKUP_H
|
26
|
+
#define FIRERUBY_BACKUP_H
|
27
|
+
|
28
|
+
/* Includes. */
|
29
|
+
#ifndef RUBY_H_INCLUDED
|
30
|
+
#include "ruby.h"
|
31
|
+
#define RUBY_H_INCLUDED
|
32
|
+
#endif
|
33
|
+
|
34
|
+
/* Function prototypes. */
|
35
|
+
void Init_Backup(VALUE);
|
36
|
+
|
37
|
+
#endif /* FIRERUBY_BACKUP_H */
|
data/ext/Blob.c
ADDED
@@ -0,0 +1,421 @@
|
|
1
|
+
/*------------------------------------------------------------------------------
|
2
|
+
* Blob.c
|
3
|
+
*----------------------------------------------------------------------------*/
|
4
|
+
/**
|
5
|
+
* Copyright � Peter Wood, 2005
|
6
|
+
*
|
7
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
8
|
+
* 1.1 (the "License"); you may not use this file except in compliance with the
|
9
|
+
* License. You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.mozilla.org/MPL/
|
12
|
+
*
|
13
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
14
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
15
|
+
* the specificlanguage governing rights and limitations under the License.
|
16
|
+
*
|
17
|
+
* The Original Code is the FireRuby extension for the Ruby language.
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
20
|
+
* Reserved.
|
21
|
+
*
|
22
|
+
* @author Peter Wood
|
23
|
+
* @version 1.0
|
24
|
+
*/
|
25
|
+
|
26
|
+
/* Includes. */
|
27
|
+
#include "Blob.h"
|
28
|
+
#include <limits.h>
|
29
|
+
#include "Common.h"
|
30
|
+
|
31
|
+
/* Function prototypes. */
|
32
|
+
static VALUE allocateBlob(VALUE);
|
33
|
+
static VALUE getBlobData(VALUE);
|
34
|
+
static VALUE closeBlob(VALUE);
|
35
|
+
static VALUE eachBlobSegment(VALUE);
|
36
|
+
char *loadBlobData(BlobHandle *);
|
37
|
+
char *loadBlobSegment(BlobHandle *, unsigned short *);
|
38
|
+
|
39
|
+
/* Globals. */
|
40
|
+
VALUE cBlob;
|
41
|
+
|
42
|
+
|
43
|
+
/**
|
44
|
+
* This function integrates with the Ruby language to allow for the allocation
|
45
|
+
* of new Blob objects.
|
46
|
+
*
|
47
|
+
* @param klass A reference to the Blob Class object.
|
48
|
+
*
|
49
|
+
*/
|
50
|
+
static VALUE allocateBlob(VALUE klass)
|
51
|
+
{
|
52
|
+
VALUE instance;
|
53
|
+
BlobHandle *blob = ALLOC(BlobHandle);
|
54
|
+
|
55
|
+
if(blob != NULL)
|
56
|
+
{
|
57
|
+
memset(&blob->description, 0, sizeof(ISC_BLOB_DESC));
|
58
|
+
blob->segments = blob->size = 0;
|
59
|
+
blob->handle = 0;
|
60
|
+
instance = Data_Wrap_Struct(klass, NULL, blobFree, blob);
|
61
|
+
}
|
62
|
+
else
|
63
|
+
{
|
64
|
+
rb_raise(rb_eNoMemError, "Memory allocation failure allocating a blob.");
|
65
|
+
}
|
66
|
+
|
67
|
+
return(instance);
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
/**
|
72
|
+
* This function provides the initialize method for the Blob class.
|
73
|
+
*
|
74
|
+
* @param self A reference to the Blob object to be initialized.
|
75
|
+
*
|
76
|
+
* @return A reference to the newly initialized Blob object.
|
77
|
+
*
|
78
|
+
*/
|
79
|
+
VALUE initializeBlob(VALUE self)
|
80
|
+
{
|
81
|
+
rb_iv_set(self, "@data", Qnil);
|
82
|
+
return(self);
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
/**
|
87
|
+
* This function fetches the data associated with a Blob object. This method
|
88
|
+
* provides the to_s method for the Blob class.
|
89
|
+
*
|
90
|
+
* @param self A reference to the Blob object to fetch the data for.
|
91
|
+
*
|
92
|
+
* @return A reference to a String containing the Blob object data.
|
93
|
+
*
|
94
|
+
*/
|
95
|
+
static VALUE getBlobData(VALUE self)
|
96
|
+
{
|
97
|
+
VALUE data = rb_iv_get(self, "@data");
|
98
|
+
|
99
|
+
if(data == Qnil)
|
100
|
+
{
|
101
|
+
BlobHandle *blob = NULL;
|
102
|
+
|
103
|
+
Data_Get_Struct(self, BlobHandle, blob);
|
104
|
+
if(blob->size > 0)
|
105
|
+
{
|
106
|
+
char *buffer = loadBlobData(blob);
|
107
|
+
|
108
|
+
if(buffer != NULL)
|
109
|
+
{
|
110
|
+
data = rb_str_new(buffer, blob->size);
|
111
|
+
}
|
112
|
+
free(buffer);
|
113
|
+
}
|
114
|
+
rb_iv_set(self, "@data", data);
|
115
|
+
}
|
116
|
+
|
117
|
+
return(data);
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
/**
|
122
|
+
* This function provides the close method for the Blob class, allowing the
|
123
|
+
* resources for a blob to be explicitly released. It is not valid to use a
|
124
|
+
* Blob object after it is closed.
|
125
|
+
*
|
126
|
+
* @param self A reference to the Blob object to be closed.
|
127
|
+
*
|
128
|
+
* @return A reference to the closed Blob object.
|
129
|
+
*
|
130
|
+
*/
|
131
|
+
static VALUE closeBlob(VALUE self)
|
132
|
+
{
|
133
|
+
VALUE data = rb_iv_get(self, "@data");
|
134
|
+
BlobHandle *blob = NULL;
|
135
|
+
|
136
|
+
if(data != Qnil)
|
137
|
+
{
|
138
|
+
rb_iv_set(self, "@data", Qnil);
|
139
|
+
}
|
140
|
+
|
141
|
+
Data_Get_Struct(self, BlobHandle, blob);
|
142
|
+
if(blob->handle != 0)
|
143
|
+
{
|
144
|
+
ISC_STATUS status[20];
|
145
|
+
|
146
|
+
if(isc_close_blob(status, &blob->handle) != 0)
|
147
|
+
{
|
148
|
+
rb_fireruby_raise(status, "Error closing blob.");
|
149
|
+
}
|
150
|
+
blob->handle = 0;
|
151
|
+
}
|
152
|
+
|
153
|
+
return(self);
|
154
|
+
}
|
155
|
+
|
156
|
+
|
157
|
+
/**
|
158
|
+
* This function provides the each method for the Blob class. This function
|
159
|
+
* feeds a segment of a blob to a block.
|
160
|
+
*
|
161
|
+
* @param self A reference to the Blob object to make the call for.
|
162
|
+
*
|
163
|
+
* @return A reference to the last return value from the block called.
|
164
|
+
*
|
165
|
+
*/
|
166
|
+
static VALUE eachBlobSegment(VALUE self)
|
167
|
+
{
|
168
|
+
VALUE result = Qnil;
|
169
|
+
|
170
|
+
if(rb_block_given_p())
|
171
|
+
{
|
172
|
+
BlobHandle *blob = NULL;
|
173
|
+
char *segment = NULL;
|
174
|
+
unsigned short size = 0;
|
175
|
+
|
176
|
+
Data_Get_Struct(self, BlobHandle, blob);
|
177
|
+
segment = loadBlobSegment(blob, &size);
|
178
|
+
while(segment != NULL)
|
179
|
+
{
|
180
|
+
result = rb_yield(rb_str_new(segment, size));
|
181
|
+
free(segment);
|
182
|
+
segment = loadBlobSegment(blob, &size);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
|
186
|
+
return(result);
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
/**
|
191
|
+
* This function allocates a BlobHandle structure and opens the structure for
|
192
|
+
* use.
|
193
|
+
*
|
194
|
+
* @param blobId The unique identifier for the blob to be opened.
|
195
|
+
* @param table The name of the table containing the blob being opened.
|
196
|
+
* @param column The name of the column in the table that contains the
|
197
|
+
* blob.
|
198
|
+
* @param connection A pointer to the connection to be used in accessing the
|
199
|
+
* blob.
|
200
|
+
* @param transaction A pointer to the transaction to be used in accessing
|
201
|
+
* the blob.
|
202
|
+
*
|
203
|
+
* @return A pointer to an allocated and opened BlobHandle structure.
|
204
|
+
*
|
205
|
+
*/
|
206
|
+
BlobHandle *openBlob(ISC_QUAD blobId,
|
207
|
+
char *table,
|
208
|
+
char *column,
|
209
|
+
isc_db_handle *connection,
|
210
|
+
isc_tr_handle *transaction)
|
211
|
+
{
|
212
|
+
BlobHandle *blob = ALLOC(BlobHandle);
|
213
|
+
|
214
|
+
if(blob != NULL)
|
215
|
+
{
|
216
|
+
ISC_STATUS status[20];
|
217
|
+
|
218
|
+
/* Extract the blob details and open it. */
|
219
|
+
blob->handle = 0;
|
220
|
+
isc_blob_default_desc(&blob->description,
|
221
|
+
(unsigned char *)table,
|
222
|
+
(unsigned char *)column);
|
223
|
+
if(isc_open_blob2(status, connection, transaction, &blob->handle, &blobId,
|
224
|
+
0, NULL) == 0)
|
225
|
+
{
|
226
|
+
char items[] = {isc_info_blob_num_segments,
|
227
|
+
isc_info_blob_total_length},
|
228
|
+
data[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
229
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
230
|
+
|
231
|
+
if(isc_blob_info(status, &blob->handle, 2, items, 20, data) == 0)
|
232
|
+
{
|
233
|
+
int offset = 0,
|
234
|
+
done = 0;
|
235
|
+
|
236
|
+
while(done < 2)
|
237
|
+
{
|
238
|
+
int length = isc_vax_integer(&data[offset + 1], 2);
|
239
|
+
|
240
|
+
if(data[offset] == isc_info_blob_num_segments)
|
241
|
+
{
|
242
|
+
blob->segments = isc_vax_integer(&data[offset + 3], length);
|
243
|
+
done++;
|
244
|
+
}
|
245
|
+
else if(data[offset] == isc_info_blob_total_length)
|
246
|
+
{
|
247
|
+
blob->size = isc_vax_integer(&data[offset + 3], length);
|
248
|
+
done++;
|
249
|
+
}
|
250
|
+
else
|
251
|
+
{
|
252
|
+
free(blob);
|
253
|
+
rb_fireruby_raise(NULL, "Error reading blob details.");
|
254
|
+
}
|
255
|
+
offset += length + 3;
|
256
|
+
}
|
257
|
+
}
|
258
|
+
else
|
259
|
+
{
|
260
|
+
free(blob);
|
261
|
+
rb_fireruby_raise(status, "Error fetching blob details.");
|
262
|
+
}
|
263
|
+
}
|
264
|
+
else
|
265
|
+
{
|
266
|
+
free(blob);
|
267
|
+
rb_fireruby_raise(status, "Error opening blob.");
|
268
|
+
}
|
269
|
+
}
|
270
|
+
|
271
|
+
return(blob);
|
272
|
+
}
|
273
|
+
|
274
|
+
|
275
|
+
/**
|
276
|
+
* This function fetches the data associated with a blob.
|
277
|
+
*
|
278
|
+
* @param blob A pointer to the BlobHandle structure that will be used in
|
279
|
+
* loading the data.
|
280
|
+
*
|
281
|
+
* @return A pointer to an array of character data containing the data of the
|
282
|
+
* blob.
|
283
|
+
*
|
284
|
+
*/
|
285
|
+
char *loadBlobData(BlobHandle *blob)
|
286
|
+
{
|
287
|
+
char *data = NULL;
|
288
|
+
|
289
|
+
if(blob != NULL && blob->handle != 0)
|
290
|
+
{
|
291
|
+
if((data = ALLOC_N(char, blob->size)) != NULL)
|
292
|
+
{
|
293
|
+
ISC_STATUS status[20],
|
294
|
+
result = 0;
|
295
|
+
int offset = 0;
|
296
|
+
|
297
|
+
while(result == 0 || result == isc_segment)
|
298
|
+
{
|
299
|
+
unsigned short quantity = 0,
|
300
|
+
available = 0;
|
301
|
+
int remains = blob->size - offset;
|
302
|
+
|
303
|
+
available = remains > USHRT_MAX ? USHRT_MAX : remains;
|
304
|
+
result = isc_get_segment(status, &blob->handle, &quantity,
|
305
|
+
available, &data[offset]);
|
306
|
+
if(result != 0 && result != isc_segment && result != isc_segstr_eof)
|
307
|
+
{
|
308
|
+
free(data);
|
309
|
+
rb_fireruby_raise(status, "Error loading blob data.");
|
310
|
+
}
|
311
|
+
offset = offset + quantity;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
else
|
315
|
+
{
|
316
|
+
rb_raise(rb_eNoMemError,
|
317
|
+
"Memory allocation failure loading blob data.");
|
318
|
+
}
|
319
|
+
}
|
320
|
+
else
|
321
|
+
{
|
322
|
+
rb_fireruby_raise(NULL, "Invalid blob specified for loading.");
|
323
|
+
}
|
324
|
+
|
325
|
+
return(data);
|
326
|
+
}
|
327
|
+
|
328
|
+
|
329
|
+
/**
|
330
|
+
* This function fetches the data for a single segment associated with a Blob.
|
331
|
+
*
|
332
|
+
* @param blob A pointer to the BlobHandle structure that will be used in
|
333
|
+
* fetching a blob segment.
|
334
|
+
* @param length A pointer to an short integer that will be set to the amount
|
335
|
+
* of data read in bytes.
|
336
|
+
*
|
337
|
+
* @return A pointer to a block of memory containing the next blob segement
|
338
|
+
* data. The return value will be NULL when there are no more blob
|
339
|
+
* segements to be read.
|
340
|
+
*
|
341
|
+
*/
|
342
|
+
char *loadBlobSegment(BlobHandle *blob, unsigned short *length)
|
343
|
+
{
|
344
|
+
char *data = NULL;
|
345
|
+
|
346
|
+
*length = 0;
|
347
|
+
if(blob != NULL && blob->handle != 0)
|
348
|
+
{
|
349
|
+
unsigned short size = blob->description.blob_desc_segment_size;
|
350
|
+
|
351
|
+
if((data = ALLOC_N(char, size)) != NULL)
|
352
|
+
{
|
353
|
+
ISC_STATUS status[20],
|
354
|
+
result;
|
355
|
+
|
356
|
+
result = isc_get_segment(status, &blob->handle, length, size, data);
|
357
|
+
if(result != 0 && result != isc_segstr_eof)
|
358
|
+
{
|
359
|
+
free(data);
|
360
|
+
rb_fireruby_raise(status, "Error reading blob segment.");
|
361
|
+
}
|
362
|
+
}
|
363
|
+
else
|
364
|
+
{
|
365
|
+
rb_raise(rb_eNoMemError,
|
366
|
+
"Memory allocation failre loading blob segment.");
|
367
|
+
}
|
368
|
+
}
|
369
|
+
else
|
370
|
+
{
|
371
|
+
rb_fireruby_raise(NULL, "Invalid blob specified for loading.");
|
372
|
+
}
|
373
|
+
|
374
|
+
return(data);
|
375
|
+
}
|
376
|
+
|
377
|
+
|
378
|
+
/**
|
379
|
+
* This function integrates with the Ruby garbage collection system to insure
|
380
|
+
* that all resources associated with a Blob object are released whenever such
|
381
|
+
* an object is collected.
|
382
|
+
*
|
383
|
+
* @param blob A pointer to the BlobHandle structure associated with the Blob
|
384
|
+
* object being collected.
|
385
|
+
*
|
386
|
+
*/
|
387
|
+
void blobFree(void *blob)
|
388
|
+
{
|
389
|
+
if(blob != NULL)
|
390
|
+
{
|
391
|
+
BlobHandle *handle = (BlobHandle *)blob;
|
392
|
+
|
393
|
+
if(handle->handle != 0)
|
394
|
+
{
|
395
|
+
ISC_STATUS status[20];
|
396
|
+
|
397
|
+
isc_close_blob(status, &handle->handle);
|
398
|
+
}
|
399
|
+
free(handle);
|
400
|
+
}
|
401
|
+
}
|
402
|
+
|
403
|
+
|
404
|
+
/**
|
405
|
+
* This function is used to create and initialize the Blob class within the
|
406
|
+
* Ruby environment.
|
407
|
+
*
|
408
|
+
* @param module A reference to the module that the Blob class will be created
|
409
|
+
* under.
|
410
|
+
*
|
411
|
+
*/
|
412
|
+
void Init_Blob(VALUE module)
|
413
|
+
{
|
414
|
+
cBlob = rb_define_class_under(module, "Blob", rb_cObject);
|
415
|
+
rb_define_alloc_func(cBlob, allocateBlob);
|
416
|
+
rb_define_method(cBlob, "initialize", initializeBlob, 0);
|
417
|
+
rb_define_method(cBlob, "initialize_copy", forbidObjectCopy, 1);
|
418
|
+
rb_define_method(cBlob, "to_s", getBlobData, 0);
|
419
|
+
rb_define_method(cBlob, "close", closeBlob, 0);
|
420
|
+
rb_define_method(cBlob, "each", eachBlobSegment, 0);
|
421
|
+
}
|
data/ext/Blob.h
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
/*------------------------------------------------------------------------------
|
2
|
+
* Blob.h
|
3
|
+
*----------------------------------------------------------------------------*/
|
4
|
+
/**
|
5
|
+
* Copyright � Peter Wood, 2005
|
6
|
+
*
|
7
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
8
|
+
* 1.1 (the "License"); you may not use this file except in compliance with the
|
9
|
+
* License. You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.mozilla.org/MPL/
|
12
|
+
*
|
13
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
14
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
15
|
+
* the specificlanguage governing rights and limitations under the License.
|
16
|
+
*
|
17
|
+
* The Original Code is the FireRuby extension for the Ruby language.
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
20
|
+
* Reserved.
|
21
|
+
*
|
22
|
+
* @author Peter Wood
|
23
|
+
* @version 1.0
|
24
|
+
*/
|
25
|
+
#ifndef FIRERUBY_BLOB_H
|
26
|
+
#define FIRERUBY_BLOB_H
|
27
|
+
|
28
|
+
/* Includes. */
|
29
|
+
#ifndef FIRERUBY_FIRE_RUBY_EXCEPTION_H
|
30
|
+
#include "FireRubyException.h"
|
31
|
+
#endif
|
32
|
+
|
33
|
+
#ifndef IBASE_H_INCLUDED
|
34
|
+
#include "ibase.h"
|
35
|
+
#define IBASE_H_INCLUDED
|
36
|
+
#endif
|
37
|
+
|
38
|
+
#ifndef RUBY_H_INCLUDED
|
39
|
+
#include "ruby.h"
|
40
|
+
#define RUBY_H_INCLUDED
|
41
|
+
#endif
|
42
|
+
|
43
|
+
/* Type definitions. */
|
44
|
+
typedef struct
|
45
|
+
{
|
46
|
+
ISC_BLOB_DESC description;
|
47
|
+
ISC_LONG segments,
|
48
|
+
size;
|
49
|
+
isc_blob_handle handle;
|
50
|
+
} BlobHandle;
|
51
|
+
|
52
|
+
/* Data elements. */
|
53
|
+
extern VALUE cBlob;
|
54
|
+
|
55
|
+
/* Function prototypes. */
|
56
|
+
BlobHandle *openBlob(ISC_QUAD,
|
57
|
+
char *,
|
58
|
+
char *,
|
59
|
+
isc_db_handle *,
|
60
|
+
isc_tr_handle *);
|
61
|
+
void Init_Blob(VALUE);
|
62
|
+
void blobFree(void *);
|
63
|
+
VALUE initializeBlob(VALUE);
|
64
|
+
|
65
|
+
#endif /* FIRERUBY_BLOB_H */
|
data/ext/Common.c
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
/*------------------------------------------------------------------------------
|
2
|
+
* Common.c
|
3
|
+
*----------------------------------------------------------------------------*/
|
4
|
+
/**
|
5
|
+
* Copyright � Peter Wood, 2005
|
6
|
+
*
|
7
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
8
|
+
* 1.1 (the "License"); you may not use this file except in compliance with the
|
9
|
+
* License. You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.mozilla.org/MPL/
|
12
|
+
*
|
13
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
14
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
15
|
+
* the specificlanguage governing rights and limitations under the License.
|
16
|
+
*
|
17
|
+
* The Original Code is the FireRuby extension for the Ruby language.
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
20
|
+
* Reserved.
|
21
|
+
*
|
22
|
+
* @author Peter Wood
|
23
|
+
* @version 1.0
|
24
|
+
*/
|
25
|
+
|
26
|
+
/* Includes. */
|
27
|
+
#include "Common.h"
|
28
|
+
#include "FireRubyException.h"
|
29
|
+
|
30
|
+
|
31
|
+
/**
|
32
|
+
* This function is used to preclude the use of any of the Ruby copy methods
|
33
|
+
* (clone or dup) with an object.
|
34
|
+
*
|
35
|
+
* @param copy A reference to the object copy.
|
36
|
+
* @param original A reference to the original object that is being copied.
|
37
|
+
*
|
38
|
+
* @return Never returns as an exception is always generated.
|
39
|
+
*
|
40
|
+
*/
|
41
|
+
VALUE forbidObjectCopy(VALUE copy, VALUE original)
|
42
|
+
{
|
43
|
+
VALUE message = rb_str_new2("Copying of CLASS_NAME objects is forbidden."),
|
44
|
+
value = rb_funcall(original, rb_intern("class"), 0),
|
45
|
+
array[2];
|
46
|
+
|
47
|
+
array[0] = rb_str_new2("CLASS_NAME");
|
48
|
+
array[1] = rb_funcall(value, rb_intern("name"), 0);
|
49
|
+
message = rb_funcall(message, rb_intern("gsub"), 2, array);
|
50
|
+
|
51
|
+
rb_fireruby_raise(NULL, STR2CSTR(message));
|
52
|
+
|
53
|
+
return(Qnil);
|
54
|
+
}
|
data/ext/Common.h
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
/*------------------------------------------------------------------------------
|
2
|
+
* Common.h
|
3
|
+
*----------------------------------------------------------------------------*/
|
4
|
+
/**
|
5
|
+
* Copyright � Peter Wood, 2005
|
6
|
+
*
|
7
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
8
|
+
* 1.1 (the "License"); you may not use this file except in compliance with the
|
9
|
+
* License. You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.mozilla.org/MPL/
|
12
|
+
*
|
13
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
14
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
15
|
+
* the specificlanguage governing rights and limitations under the License.
|
16
|
+
*
|
17
|
+
* The Original Code is the FireRuby extension for the Ruby language.
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
20
|
+
* Reserved.
|
21
|
+
*
|
22
|
+
* @author Peter Wood
|
23
|
+
* @version 1.0
|
24
|
+
*/
|
25
|
+
#ifndef FIRERUBY_COMMON_H
|
26
|
+
#define FIRERUBY_COMMON_H
|
27
|
+
|
28
|
+
/* Includes. */
|
29
|
+
#ifndef RUBY_H_INCLUDED
|
30
|
+
#include "ruby.h"
|
31
|
+
#define RUBY_H_INCLUDED
|
32
|
+
#endif
|
33
|
+
|
34
|
+
/* Function prototypes. */
|
35
|
+
VALUE forbidObjectCopy(VALUE, VALUE);
|
36
|
+
|
37
|
+
#endif /* FIRERUBY_COMMON_H */
|