rubyfb 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/Manifest +0 -1
- data/Rakefile +1 -1
- data/ext/AddUser.c +217 -248
- data/ext/AddUser.h +3 -3
- data/ext/Backup.c +337 -404
- data/ext/Backup.h +3 -3
- data/ext/Blob.c +197 -248
- data/ext/Blob.h +30 -31
- data/ext/Common.c +17 -18
- data/ext/Common.h +10 -10
- data/ext/Connection.c +413 -487
- data/ext/Connection.h +18 -19
- data/ext/DataArea.c +172 -189
- data/ext/DataArea.h +11 -11
- data/ext/Database.c +198 -238
- data/ext/Database.h +16 -17
- data/ext/FireRuby.c +118 -142
- data/ext/FireRuby.h +17 -17
- data/ext/FireRubyException.c +68 -138
- data/ext/FireRubyException.h +14 -21
- data/ext/Generator.c +296 -377
- data/ext/Generator.h +17 -18
- data/ext/RemoveUser.c +91 -102
- data/ext/RemoveUser.h +3 -3
- data/ext/Restore.c +353 -423
- data/ext/Restore.h +3 -3
- data/ext/ResultSet.c +423 -456
- data/ext/ResultSet.h +26 -27
- data/ext/Row.c +505 -568
- data/ext/Row.h +27 -28
- data/ext/ServiceManager.c +143 -164
- data/ext/ServiceManager.h +17 -18
- data/ext/Services.c +58 -67
- data/ext/Services.h +3 -3
- data/ext/Statement.c +388 -449
- data/ext/Statement.h +30 -31
- data/ext/Transaction.c +374 -448
- data/ext/Transaction.h +17 -18
- data/ext/TypeMap.c +654 -774
- data/ext/TypeMap.h +17 -17
- data/ext/rfbint.h +3 -3
- data/lib/active_record/connection_adapters/rubyfb_adapter.rb +1 -1
- data/lib/rubyfb_lib.so +0 -0
- data/lib/src.rb +33 -0
- data/rubyfb.gemspec +3 -3
- data/test/ResultSetTest.rb +13 -0
- data/test/RowTest.rb +16 -0
- metadata +4 -5
- data/test/UnitTest.rb +0 -65
data/ext/Generator.h
CHANGED
@@ -3,20 +3,20 @@
|
|
3
3
|
*----------------------------------------------------------------------------*/
|
4
4
|
/**
|
5
5
|
* Copyright � Peter Wood, 2005
|
6
|
-
*
|
6
|
+
*
|
7
7
|
* The contents of this file are subject to the Mozilla Public License Version
|
8
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
|
9
|
+
* License. You may obtain a copy of the License at
|
10
10
|
*
|
11
11
|
* http://www.mozilla.org/MPL/
|
12
|
-
*
|
12
|
+
*
|
13
13
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
14
14
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
15
15
|
* the specificlanguage governing rights and limitations under the License.
|
16
|
-
*
|
16
|
+
*
|
17
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
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is Peter Wood. All Rights
|
20
20
|
* Reserved.
|
21
21
|
*
|
22
22
|
* @author Peter Wood
|
@@ -25,7 +25,7 @@
|
|
25
25
|
#ifndef FIRERUBY_GENERATOR_H
|
26
26
|
#define FIRERUBY_GENERATOR_H
|
27
27
|
|
28
|
-
|
28
|
+
/* Includes. */
|
29
29
|
#ifndef FIRERUBY_FIRE_RUBY_EXCEPTION_H
|
30
30
|
#include "FireRubyException.h"
|
31
31
|
#endif
|
@@ -33,21 +33,20 @@
|
|
33
33
|
#ifndef FIRERUBY_CONNECTION_H
|
34
34
|
#include "Connection.h"
|
35
35
|
#endif
|
36
|
-
|
36
|
+
|
37
37
|
#ifndef RUBY_H_INCLUDED
|
38
38
|
#include "ruby.h"
|
39
39
|
#define RUBY_H_INCLUDED
|
40
40
|
#endif
|
41
|
-
|
42
|
-
/* Type definitions. */
|
43
|
-
typedef struct
|
44
|
-
{
|
45
|
-
isc_db_handle *connection;
|
46
|
-
} GeneratorHandle;
|
47
41
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
42
|
+
/* Type definitions. */
|
43
|
+
typedef struct {
|
44
|
+
isc_db_handle *connection;
|
45
|
+
} GeneratorHandle;
|
46
|
+
|
47
|
+
/* Function prototypes. */
|
48
|
+
void Init_Generator(VALUE);
|
49
|
+
VALUE rb_generator_new(VALUE, VALUE);
|
50
|
+
void generatorFree(void *);
|
52
51
|
|
53
52
|
#endif /* FIRERUBY_GENERATOR_H */
|
data/ext/RemoveUser.c
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
#include "ServiceManager.h"
|
30
30
|
|
31
31
|
/* Function prototypes. */
|
32
|
-
static VALUE initializeRemoveUser(VALUE
|
32
|
+
static VALUE initializeRemoveUser(VALUE, VALUE);
|
33
33
|
static VALUE getUserName(VALUE);
|
34
34
|
static VALUE setUserName(VALUE, VALUE);
|
35
35
|
static void createRemoveUserBuffer(VALUE, char **, short *);
|
@@ -49,26 +49,24 @@ VALUE cRemoveUser;
|
|
49
49
|
* @return A reference to the newly initialized RemoveUser object.
|
50
50
|
*
|
51
51
|
*/
|
52
|
-
VALUE initializeRemoveUser(VALUE self, VALUE username)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
return(self);
|
52
|
+
VALUE initializeRemoveUser(VALUE self, VALUE username) {
|
53
|
+
VALUE actual = rb_funcall(username, rb_intern("to_s"), 0),
|
54
|
+
value = Qnil;
|
55
|
+
int length = 0;
|
56
|
+
|
57
|
+
/* Check that the parameters are valid. */
|
58
|
+
value = rb_funcall(actual, rb_intern("length"), 0);
|
59
|
+
length = TYPE(value) == T_FIXNUM ? FIX2INT(value) : NUM2INT(value);
|
60
|
+
if(length < 1 || length > 31) {
|
61
|
+
rb_fireruby_raise(NULL,
|
62
|
+
"Invalid user name specified. A user name must not be " \
|
63
|
+
"blank and may have no more than 31 characters.");
|
64
|
+
}
|
65
|
+
|
66
|
+
/* Assign class values. */
|
67
|
+
rb_iv_set(self, "@user_name", actual);
|
68
|
+
|
69
|
+
return(self);
|
72
70
|
}
|
73
71
|
|
74
72
|
|
@@ -81,9 +79,8 @@ VALUE initializeRemoveUser(VALUE self, VALUE username)
|
|
81
79
|
* @return A reference to the attribute value for the object.
|
82
80
|
*
|
83
81
|
*/
|
84
|
-
VALUE getUserName(VALUE self)
|
85
|
-
|
86
|
-
return(rb_iv_get(self, "@user_name"));
|
82
|
+
VALUE getUserName(VALUE self) {
|
83
|
+
return(rb_iv_get(self, "@user_name"));
|
87
84
|
}
|
88
85
|
|
89
86
|
|
@@ -97,22 +94,20 @@ VALUE getUserName(VALUE self)
|
|
97
94
|
* @return A reference to the newly update RemoveUser object.
|
98
95
|
*
|
99
96
|
*/
|
100
|
-
VALUE setUserName(VALUE self, VALUE setting)
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
return(self);
|
97
|
+
VALUE setUserName(VALUE self, VALUE setting) {
|
98
|
+
VALUE actual = rb_funcall(setting, rb_intern("to_s"), 0),
|
99
|
+
value = rb_funcall(actual, rb_intern("length"), 0);
|
100
|
+
int length = 0;
|
101
|
+
|
102
|
+
length = TYPE(value) == T_FIXNUM ? FIX2INT(value) : NUM2INT(value);
|
103
|
+
if(length < 1 || length > 31) {
|
104
|
+
rb_fireruby_raise(NULL,
|
105
|
+
"Invalid user name specified. A user name must not be " \
|
106
|
+
"blank and may have no more than 31 characters.");
|
107
|
+
}
|
108
|
+
rb_iv_set(self, "@user_name", actual);
|
109
|
+
|
110
|
+
return(self);
|
116
111
|
}
|
117
112
|
|
118
113
|
|
@@ -127,32 +122,29 @@ VALUE setUserName(VALUE self, VALUE setting)
|
|
127
122
|
* @return A reference to the RemoveUser object executed.
|
128
123
|
*
|
129
124
|
*/
|
130
|
-
VALUE executeRemoveUser(VALUE self, VALUE manager)
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
free(buffer);
|
154
|
-
|
155
|
-
return(self);
|
125
|
+
VALUE executeRemoveUser(VALUE self, VALUE manager) {
|
126
|
+
ManagerHandle *handle = NULL;
|
127
|
+
char *buffer = NULL;
|
128
|
+
short length = 0;
|
129
|
+
ISC_STATUS status[ISC_STATUS_LENGTH];
|
130
|
+
|
131
|
+
/* Check that the service manager is connected. */
|
132
|
+
Data_Get_Struct(manager, ManagerHandle, handle);
|
133
|
+
if(handle->handle == 0) {
|
134
|
+
rb_fireruby_raise(NULL,
|
135
|
+
"Remove user error. Service manager not connected.");
|
136
|
+
}
|
137
|
+
|
138
|
+
createRemoveUserBuffer(self, &buffer, &length);
|
139
|
+
|
140
|
+
/* Start the service request. */
|
141
|
+
if(isc_service_start(status, &handle->handle, NULL, length, buffer)) {
|
142
|
+
free(buffer);
|
143
|
+
rb_fireruby_raise(status, "Error removing user.");
|
144
|
+
}
|
145
|
+
free(buffer);
|
146
|
+
|
147
|
+
return(self);
|
156
148
|
}
|
157
149
|
|
158
150
|
|
@@ -166,35 +158,33 @@ VALUE executeRemoveUser(VALUE self, VALUE manager)
|
|
166
158
|
* of the buffer.
|
167
159
|
*
|
168
160
|
*/
|
169
|
-
void createRemoveUserBuffer(VALUE self, char **buffer, short *length)
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
memcpy(offset, StringValuePtr(value), number);
|
197
|
-
offset += number;
|
161
|
+
void createRemoveUserBuffer(VALUE self, char **buffer, short *length) {
|
162
|
+
VALUE value = Qnil,
|
163
|
+
tmp_str = Qnil;
|
164
|
+
char *offset = NULL;
|
165
|
+
int number = 0;
|
166
|
+
|
167
|
+
/* Calculate the required buffer length. */
|
168
|
+
*length = 1;
|
169
|
+
tmp_str = rb_iv_get(self, "@user_name");
|
170
|
+
*length += strlen(StringValuePtr(tmp_str)) + 3;
|
171
|
+
|
172
|
+
/* Create and populate the buffer. */
|
173
|
+
offset = *buffer = ALLOC_N(char, *length);
|
174
|
+
if(*buffer == NULL) {
|
175
|
+
rb_raise(rb_eNoMemError,
|
176
|
+
"Memory allocation error preparing to remove user.");
|
177
|
+
}
|
178
|
+
memset(*buffer, 0, *length);
|
179
|
+
|
180
|
+
*offset++ = isc_action_svc_delete_user;
|
181
|
+
|
182
|
+
*offset++ = isc_spb_sec_username;
|
183
|
+
value = rb_iv_get(self, "@user_name");
|
184
|
+
number = strlen(StringValuePtr(value));
|
185
|
+
ADD_SPB_LENGTH(offset, number);
|
186
|
+
memcpy(offset, StringValuePtr(value), number);
|
187
|
+
offset += number;
|
198
188
|
}
|
199
189
|
|
200
190
|
|
@@ -204,11 +194,10 @@ void createRemoveUserBuffer(VALUE self, char **buffer, short *length)
|
|
204
194
|
* @param module The module to create the new class definition under.
|
205
195
|
*
|
206
196
|
*/
|
207
|
-
void Init_RemoveUser(VALUE module)
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
rb_define_method(cRemoveUser, "execute", executeRemoveUser, 1);
|
197
|
+
void Init_RemoveUser(VALUE module) {
|
198
|
+
cRemoveUser = rb_define_class_under(module, "RemoveUser", rb_cObject);
|
199
|
+
rb_define_method(cRemoveUser, "initialize", initializeRemoveUser, 1);
|
200
|
+
rb_define_method(cRemoveUser, "user_name", getUserName, 0);
|
201
|
+
rb_define_method(cRemoveUser, "user_name=", setUserName, 1);
|
202
|
+
rb_define_method(cRemoveUser, "execute", executeRemoveUser, 1);
|
214
203
|
}
|
data/ext/RemoveUser.h
CHANGED
@@ -25,13 +25,13 @@
|
|
25
25
|
#ifndef FIRERUBY_REMOVE_USER_H
|
26
26
|
#define FIRERUBY_REMOVE_USER_H
|
27
27
|
|
28
|
-
|
28
|
+
/* Includes. */
|
29
29
|
#ifndef RUBY_H_INCLUDED
|
30
30
|
#include "ruby.h"
|
31
31
|
#define RUBY_H_INCLUDED
|
32
32
|
#endif
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
/* Function prototypes. */
|
35
|
+
void Init_RemoveUser(VALUE);
|
36
36
|
|
37
37
|
#endif /* FIRERUBY_REMOVE_USER_H */
|