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/ext/Connection.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_CONNECTION_H
26
26
  #define FIRERUBY_CONNECTION_H
27
27
 
28
- /* Includes. */
28
+ /* Includes. */
29
29
  #ifndef FIRERUBY_FIRE_RUBY_H
30
30
  #include "FireRuby.h"
31
31
  #endif
@@ -34,17 +34,16 @@
34
34
  #include "FireRubyException.h"
35
35
  #endif
36
36
 
37
- /* Structure definitions. */
38
- typedef struct
39
- {
40
- isc_db_handle handle;
41
- } ConnectionHandle;
42
-
43
- /* Function prototypes. */
44
- void Init_Connection(VALUE);
45
- VALUE rb_connection_new(VALUE, VALUE, VALUE, VALUE);
46
- void rb_tx_started(VALUE, VALUE);
47
- void rb_tx_released(VALUE, VALUE);
48
- void connectionFree(void *);
37
+ /* Structure definitions. */
38
+ typedef struct {
39
+ isc_db_handle handle;
40
+ } ConnectionHandle;
41
+
42
+ /* Function prototypes. */
43
+ void Init_Connection(VALUE);
44
+ VALUE rb_connection_new(VALUE, VALUE, VALUE, VALUE);
45
+ void rb_tx_started(VALUE, VALUE);
46
+ void rb_tx_released(VALUE, VALUE);
47
+ void connectionFree(void *);
49
48
 
50
49
  #endif /* FIRERUBY_CONNECTION_H */
data/ext/DataArea.c CHANGED
@@ -40,32 +40,27 @@
40
40
  * @return A pointer to the newly allocated XSQLDA.
41
41
  *
42
42
  */
43
- XSQLDA *allocateOutXSQLDA(int size, isc_stmt_handle *statement, short dialect)
44
- {
45
- XSQLDA *area = (XSQLDA *)ALLOC_N(char, XSQLDA_LENGTH(size));
46
-
47
- if(area != NULL)
48
- {
49
- ISC_STATUS status[20];
50
-
51
- area->sqln = size;
52
- area->version = SQLDA_VERSION1;
53
- if(isc_dsql_describe(status, statement, dialect, area) != 0)
54
- {
55
- /* Release the memory and generate an error. */
56
- free(area);
57
- rb_fireruby_raise(status, "Error allocating output storage space.");
58
- }
59
- }
60
- else
61
- {
62
- /* Generate an error. */
63
- rb_raise(rb_eNoMemError,
64
- "Memory allocation failure preparing output SQL data "\
65
- "definition area.");
66
- }
67
-
68
- return(area);
43
+ XSQLDA *allocateOutXSQLDA(int size, isc_stmt_handle *statement, short dialect) {
44
+ XSQLDA *area = (XSQLDA *)ALLOC_N(char, XSQLDA_LENGTH(size));
45
+
46
+ if(area != NULL) {
47
+ ISC_STATUS status[ISC_STATUS_LENGTH];
48
+
49
+ area->sqln = size;
50
+ area->version = SQLDA_VERSION1;
51
+ if(isc_dsql_describe(status, statement, dialect, area) != 0) {
52
+ /* Release the memory and generate an error. */
53
+ free(area);
54
+ rb_fireruby_raise(status, "Error allocating output storage space.");
55
+ }
56
+ } else {
57
+ /* Generate an error. */
58
+ rb_raise(rb_eNoMemError,
59
+ "Memory allocation failure preparing output SQL data " \
60
+ "definition area.");
61
+ }
62
+
63
+ return(area);
69
64
  }
70
65
 
71
66
 
@@ -81,34 +76,29 @@ XSQLDA *allocateOutXSQLDA(int size, isc_stmt_handle *statement, short dialect)
81
76
  * @return A pointer to the newly allocated XSQLDA.
82
77
  *
83
78
  */
84
- XSQLDA *allocateInXSQLDA(int size, isc_stmt_handle *statement, short dialect)
85
- {
86
- XSQLDA *area = NULL;
87
-
88
- area = (XSQLDA *)ALLOC_N(char, XSQLDA_LENGTH(size));
89
-
90
- if(area != NULL)
91
- {
92
- ISC_STATUS status[20];
93
-
94
- area->sqln = size;
95
- area->version = SQLDA_VERSION1;
96
- if(isc_dsql_describe_bind(status, statement, dialect, area) != 0)
97
- {
98
- /* Release the memory and generate an error. */
99
- free(area);
100
- rb_fireruby_raise(status, "Error allocating input storage space.");
101
- }
102
- }
103
- else
104
- {
105
- /* Generate an error. */
106
- rb_raise(rb_eNoMemError,
107
- "Memory allocation failure preparing input SQL data "\
108
- "definition area.");
109
- }
110
-
111
- return(area);
79
+ XSQLDA *allocateInXSQLDA(int size, isc_stmt_handle *statement, short dialect) {
80
+ XSQLDA *area = NULL;
81
+
82
+ area = (XSQLDA *)ALLOC_N(char, XSQLDA_LENGTH(size));
83
+
84
+ if(area != NULL) {
85
+ ISC_STATUS status[ISC_STATUS_LENGTH];
86
+
87
+ area->sqln = size;
88
+ area->version = SQLDA_VERSION1;
89
+ if(isc_dsql_describe_bind(status, statement, dialect, area) != 0) {
90
+ /* Release the memory and generate an error. */
91
+ free(area);
92
+ rb_fireruby_raise(status, "Error allocating input storage space.");
93
+ }
94
+ } else {
95
+ /* Generate an error. */
96
+ rb_raise(rb_eNoMemError,
97
+ "Memory allocation failure preparing input SQL data " \
98
+ "definition area.");
99
+ }
100
+
101
+ return(area);
112
102
  }
113
103
 
114
104
 
@@ -119,74 +109,71 @@ XSQLDA *allocateInXSQLDA(int size, isc_stmt_handle *statement, short dialect)
119
109
  * @param da A pointer to the XSQLDA to have data space allocated for.
120
110
  *
121
111
  */
122
- void prepareDataArea(XSQLDA *da)
123
- {
124
- XSQLVAR *field = da->sqlvar;
125
- int index;
126
-
127
- for(index = 0; index < da->sqld; index++, field++)
128
- {
129
- int type = (field->sqltype & ~1),
130
- total = (field->sqllen / 2) + 2;
131
-
132
- field->sqldata = NULL;
133
- field->sqlind = NULL;
134
- switch(type)
135
- {
136
- case SQL_ARRAY :
137
- fprintf(stderr, "Allocating for an array (NOT).\n");
138
- break;
139
-
140
- case SQL_BLOB :
141
- field->sqldata = (char *)ALLOC(ISC_QUAD);
142
- break;
143
-
144
- case SQL_DOUBLE :
145
- field->sqldata = (char *)ALLOC(double);
146
- break;
147
-
148
- case SQL_FLOAT :
149
- field->sqldata = (char *)ALLOC(float);
150
- break;
151
-
152
- case SQL_INT64 :
153
- field->sqldata = (char *)ALLOC(int64_t);
154
- break;
155
-
156
- case SQL_LONG :
157
- field->sqldata = (char *)ALLOC(int32_t);
158
- break;
159
-
160
- case SQL_SHORT :
161
- field->sqldata = (char *)ALLOC(int16_t);
162
- break;
163
-
164
- case SQL_TEXT :
165
- field->sqldata = ALLOC_N(char, field->sqllen + 1);
166
- break;
167
-
168
- case SQL_TIMESTAMP :
169
- field->sqldata = (char *)ALLOC(ISC_TIMESTAMP);
170
- break;
171
-
172
- case SQL_TYPE_DATE :
173
- field->sqldata = (char *)ALLOC(ISC_DATE);
174
- break;
175
-
176
- case SQL_TYPE_TIME:
177
- field->sqldata = (char *)ALLOC(ISC_TIME);
178
- break;
179
-
180
- case SQL_VARYING :
181
- field->sqldata = (char *)ALLOC_N(short, total);
182
- break;
183
-
184
- default :
185
- rb_fireruby_raise(NULL, "Unknown SQL data type encountered.");
186
- }
187
- field->sqlind = ALLOC(short);
188
- *field->sqlind = 0;
189
- }
112
+ void prepareDataArea(XSQLDA *da) {
113
+ XSQLVAR *field = da->sqlvar;
114
+ int index;
115
+
116
+ for(index = 0; index < da->sqld; index++, field++) {
117
+ int type = (field->sqltype & ~1),
118
+ total = (field->sqllen / 2) + 2;
119
+
120
+ field->sqldata = NULL;
121
+ field->sqlind = NULL;
122
+ switch(type) {
123
+ case SQL_ARRAY:
124
+ fprintf(stderr, "Allocating for an array (NOT).\n");
125
+ break;
126
+
127
+ case SQL_BLOB:
128
+ field->sqldata = (char *)ALLOC(ISC_QUAD);
129
+ break;
130
+
131
+ case SQL_DOUBLE:
132
+ field->sqldata = (char *)ALLOC(double);
133
+ break;
134
+
135
+ case SQL_FLOAT:
136
+ field->sqldata = (char *)ALLOC(float);
137
+ break;
138
+
139
+ case SQL_INT64:
140
+ field->sqldata = (char *)ALLOC(int64_t);
141
+ break;
142
+
143
+ case SQL_LONG:
144
+ field->sqldata = (char *)ALLOC(int32_t);
145
+ break;
146
+
147
+ case SQL_SHORT:
148
+ field->sqldata = (char *)ALLOC(int16_t);
149
+ break;
150
+
151
+ case SQL_TEXT:
152
+ field->sqldata = ALLOC_N(char, field->sqllen + 1);
153
+ break;
154
+
155
+ case SQL_TIMESTAMP:
156
+ field->sqldata = (char *)ALLOC(ISC_TIMESTAMP);
157
+ break;
158
+
159
+ case SQL_TYPE_DATE:
160
+ field->sqldata = (char *)ALLOC(ISC_DATE);
161
+ break;
162
+
163
+ case SQL_TYPE_TIME:
164
+ field->sqldata = (char *)ALLOC(ISC_TIME);
165
+ break;
166
+
167
+ case SQL_VARYING:
168
+ field->sqldata = (char *)ALLOC_N(short, total);
169
+ break;
170
+
171
+ default:
172
+ rb_fireruby_raise(NULL, "Unknown SQL data type encountered.");
173
+ }
174
+ field->sqlind = ALLOC(short);
175
+ *field->sqlind = 0;
176
+ }
190
177
  }
191
178
 
192
179
 
@@ -196,71 +183,67 @@ void prepareDataArea(XSQLDA *da)
196
183
  * @param da A reference to the XSQLDA to be cleared up.
197
184
  *
198
185
  */
199
- void releaseDataArea(XSQLDA *da)
200
- {
201
- XSQLVAR *field = da->sqlvar;
202
- int index;
203
-
204
- for(index = 0; index < da->sqld; index++, field++)
205
- {
206
- int type = (field->sqltype & ~1);
207
-
208
- switch(type)
209
- {
210
- case SQL_ARRAY :
211
- fprintf(stderr, "Releasing an array (NOT).\n");
212
- break;
213
-
214
- case SQL_BLOB :
215
- free((ISC_QUAD *)field->sqldata);
216
- break;
217
-
218
- case SQL_DOUBLE :
219
- free((double *)field->sqldata);
220
- break;
221
-
222
- case SQL_FLOAT :
223
- free((float *)field->sqldata);
224
- break;
225
-
226
- case SQL_INT64 :
227
- free((int64_t *)field->sqldata);
228
- break;
229
-
230
- case SQL_LONG :
231
- free((int32_t *)field->sqldata);
232
- break;
233
-
234
- case SQL_SHORT :
235
- free((int16_t *)field->sqldata);
236
- break;
237
-
238
- case SQL_TEXT :
239
- free(field->sqldata);
240
- break;
241
-
242
- case SQL_TIMESTAMP :
243
- free((ISC_TIMESTAMP *)field->sqldata);
244
- break;
245
-
246
- case SQL_TYPE_DATE :
247
- free((ISC_DATE *)field->sqldata);
248
- break;
249
-
250
- case SQL_TYPE_TIME:
251
- free((ISC_TIME *)field->sqldata);
252
- break;
253
-
254
- case SQL_VARYING :
255
- free((short *)field->sqldata);
256
- break;
257
- }
258
- if(field->sqlind != NULL)
259
- {
260
- free(field->sqlind);
261
- }
262
-
263
- field->sqldata = NULL;
264
- field->sqlind = NULL;
265
- }
186
+ void releaseDataArea(XSQLDA *da) {
187
+ XSQLVAR *field = da->sqlvar;
188
+ int index;
189
+
190
+ for(index = 0; index < da->sqld; index++, field++) {
191
+ int type = (field->sqltype & ~1);
192
+
193
+ switch(type) {
194
+ case SQL_ARRAY:
195
+ fprintf(stderr, "Releasing an array (NOT).\n");
196
+ break;
197
+
198
+ case SQL_BLOB:
199
+ free((ISC_QUAD *)field->sqldata);
200
+ break;
201
+
202
+ case SQL_DOUBLE:
203
+ free((double *)field->sqldata);
204
+ break;
205
+
206
+ case SQL_FLOAT:
207
+ free((float *)field->sqldata);
208
+ break;
209
+
210
+ case SQL_INT64:
211
+ free((int64_t *)field->sqldata);
212
+ break;
213
+
214
+ case SQL_LONG:
215
+ free((int32_t *)field->sqldata);
216
+ break;
217
+
218
+ case SQL_SHORT:
219
+ free((int16_t *)field->sqldata);
220
+ break;
221
+
222
+ case SQL_TEXT:
223
+ free(field->sqldata);
224
+ break;
225
+
226
+ case SQL_TIMESTAMP:
227
+ free((ISC_TIMESTAMP *)field->sqldata);
228
+ break;
229
+
230
+ case SQL_TYPE_DATE:
231
+ free((ISC_DATE *)field->sqldata);
232
+ break;
233
+
234
+ case SQL_TYPE_TIME:
235
+ free((ISC_TIME *)field->sqldata);
236
+ break;
237
+
238
+ case SQL_VARYING:
239
+ free((short *)field->sqldata);
240
+ break;
241
+ }
242
+ if(field->sqlind != NULL) {
243
+ free(field->sqlind);
244
+ }
245
+
246
+ field->sqldata = NULL;
247
+ field->sqlind = NULL;
248
+ }
266
249
  }
data/ext/DataArea.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
@@ -29,10 +29,10 @@
29
29
  #include "ibase.h"
30
30
  #define IBASE_H_INCLUDED
31
31
  #endif
32
-
33
- XSQLDA *allocateOutXSQLDA(int, isc_stmt_handle *, short);
34
- XSQLDA *allocateInXSQLDA(int, isc_stmt_handle *, short);
35
- void prepareDataArea(XSQLDA *);
36
- void releaseDataArea(XSQLDA *);
32
+
33
+ XSQLDA *allocateOutXSQLDA(int, isc_stmt_handle *, short);
34
+ XSQLDA *allocateInXSQLDA(int, isc_stmt_handle *, short);
35
+ void prepareDataArea(XSQLDA *);
36
+ void releaseDataArea(XSQLDA *);
37
37
 
38
38
  #endif /* FIRERUBY_DATA_AREA_H */