rubyfb 0.5.5 → 0.5.6

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/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
- /* Includes. */
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
- /* Function prototypes. */
49
- void Init_Generator(VALUE);
50
- VALUE rb_generator_new(VALUE, VALUE);
51
- void generatorFree(void *);
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 , 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
- VALUE actual = rb_funcall(username, rb_intern("to_s"), 0),
55
- value = Qnil;
56
- int length = 0;
57
-
58
- /* Check that the parameters are valid. */
59
- value = rb_funcall(actual, rb_intern("length"), 0);
60
- length = TYPE(value) == T_FIXNUM ? FIX2INT(value) : NUM2INT(value);
61
- if(length < 1 || length > 31)
62
- {
63
- rb_fireruby_raise(NULL,
64
- "Invalid user name specified. A user name must not be "\
65
- "blank and may have no more than 31 characters.");
66
- }
67
-
68
- /* Assign class values. */
69
- rb_iv_set(self, "@user_name", actual);
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
- VALUE actual = rb_funcall(setting, rb_intern("to_s"), 0),
103
- value = rb_funcall(actual, rb_intern("length"), 0);
104
- int length = 0;
105
-
106
- length = TYPE(value) == T_FIXNUM ? FIX2INT(value) : NUM2INT(value);
107
- if(length < 1 || length > 31)
108
- {
109
- rb_fireruby_raise(NULL,
110
- "Invalid user name specified. A user name must not be "\
111
- "blank and may have no more than 31 characters.");
112
- }
113
- rb_iv_set(self, "@user_name", actual);
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
- ManagerHandle *handle = NULL;
133
- char *buffer = NULL;
134
- short length = 0;
135
- ISC_STATUS status[20];
136
-
137
- /* Check that the service manager is connected. */
138
- Data_Get_Struct(manager, ManagerHandle, handle);
139
- if(handle->handle == 0)
140
- {
141
- rb_fireruby_raise(NULL,
142
- "Remove user error. Service manager not connected.");
143
- }
144
-
145
- createRemoveUserBuffer(self, &buffer, &length);
146
-
147
- /* Start the service request. */
148
- if(isc_service_start(status, &handle->handle, NULL, length, buffer))
149
- {
150
- free(buffer);
151
- rb_fireruby_raise(status, "Error removing user.");
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
- VALUE value = Qnil,
172
- tmp_str = Qnil;
173
- char *offset = NULL;
174
- int number = 0;
175
-
176
- /* Calculate the required buffer length. */
177
- *length = 1;
178
- tmp_str = rb_iv_get(self, "@user_name");
179
- *length += strlen(StringValuePtr(tmp_str)) + 3;
180
-
181
- /* Create and populate the buffer. */
182
- offset = *buffer = ALLOC_N(char, *length);
183
- if(*buffer == NULL)
184
- {
185
- rb_raise(rb_eNoMemError,
186
- "Memory allocation error preparing to remove user.");
187
- }
188
- memset(*buffer, 0, *length);
189
-
190
- *offset++ = isc_action_svc_delete_user;
191
-
192
- *offset++ = isc_spb_sec_username;
193
- value = rb_iv_get(self, "@user_name");
194
- number = strlen(StringValuePtr(value));
195
- ADD_SPB_LENGTH(offset, number);
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
- cRemoveUser = rb_define_class_under(module, "RemoveUser", rb_cObject);
210
- rb_define_method(cRemoveUser, "initialize", initializeRemoveUser, 1);
211
- rb_define_method(cRemoveUser, "user_name", getUserName, 0);
212
- rb_define_method(cRemoveUser, "user_name=", setUserName, 1);
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
- /* Includes. */
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
- /* Function prototypes. */
35
- void Init_RemoveUser(VALUE);
34
+ /* Function prototypes. */
35
+ void Init_RemoveUser(VALUE);
36
36
 
37
37
  #endif /* FIRERUBY_REMOVE_USER_H */