advantage 0.1.0-x86-linux → 0.1.1-x86-linux

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/LICENSE CHANGED
File without changes
data/README CHANGED
File without changes
data/Rakefile CHANGED
File without changes
@@ -12,11 +12,11 @@ ECHO = $(ECHO1:0=@echo)
12
12
  #### Start of system configuration section. ####
13
13
 
14
14
  srcdir = .
15
- topdir = /home/ADS/edgars/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1
16
- hdrdir = /home/ADS/edgars/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1
17
- arch_hdrdir = /home/ADS/edgars/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/$(arch)
15
+ topdir = /home/sybase/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1
16
+ hdrdir = /home/sybase/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1
17
+ arch_hdrdir = /home/sybase/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/$(arch)
18
18
  VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
19
- prefix = $(DESTDIR)/home/ADS/edgars/.rvm/rubies/ruby-1.9.3-p125
19
+ prefix = $(DESTDIR)/home/sybase/.rvm/rubies/ruby-1.9.3-p327
20
20
  rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
21
21
  exec_prefix = $(prefix)
22
22
  vendorhdrdir = $(rubyhdrdir)/vendor_ruby
@@ -59,21 +59,22 @@ LIBRUBY = $(LIBRUBY_SO)
59
59
  LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
60
60
  LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
61
61
  LIBRUBYARG_STATIC = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)-static
62
- OUTFLAG = -o
63
- COUTFLAG = -o
62
+ empty =
63
+ OUTFLAG = -o $(empty)
64
+ COUTFLAG = -o $(empty)
64
65
 
65
66
  RUBY_EXTCONF_H =
66
67
  cflags = $(optflags) $(debugflags) $(warnflags)
67
68
  optflags = -O3
68
69
  debugflags = -ggdb
69
- warnflags = -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
70
+ warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration
70
71
  CFLAGS = -fPIC $(cflags) -fPIC $(ARCH_FLAG)
71
72
  INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
72
73
  DEFS = -D_FILE_OFFSET_BITS=64
73
- CPPFLAGS = -I/home/ADS/edgars/.rvm/usr/include $(DEFS) $(cppflags)
74
+ CPPFLAGS = $(DEFS) $(cppflags) -I/home/sybase/.rvm/usr/include
74
75
  CXXFLAGS = $(CFLAGS) $(cxxflags)
75
- ldflags = -L. -rdynamic -Wl,-export-dynamic
76
- dldflags =
76
+ ldflags = -L. -rdynamic -Wl,-export-dynamic -L/home/sybase/.rvm/usr/lib -Wl,-R/home/sybase/.rvm/usr/lib
77
+ dldflags = -L/home/sybase/.rvm/usr/lib -Wl,-R/home/sybase/.rvm/usr/lib
77
78
  ARCH_FLAG =
78
79
  DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
79
80
  LDSHARED = $(CC) -shared
@@ -87,7 +88,7 @@ RUBY_SO_NAME = ruby
87
88
  arch = i686-linux
88
89
  sitearch = $(arch)
89
90
  ruby_version = 1.9.1
90
- ruby = /home/ADS/edgars/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
91
+ ruby = /home/sybase/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
91
92
  RUBY = $(ruby)
92
93
  RM = rm -f
93
94
  RM_RF = $(RUBY) -run -e rm -- -rf
@@ -97,13 +98,14 @@ INSTALL = /usr/bin/install -c
97
98
  INSTALL_PROG = $(INSTALL) -m 0755
98
99
  INSTALL_DATA = $(INSTALL) -m 644
99
100
  COPY = cp
101
+ TOUCH = exit >
100
102
 
101
103
  #### End of system configuration section. ####
102
104
 
103
105
  preload =
104
106
 
105
- libpath = . $(libdir) /home/ADS/edgars/.rvm/usr/lib
106
- LIBPATH = -L. -L$(libdir) -Wl,-R$(libdir) -L/home/ADS/edgars/.rvm/usr/lib -Wl,-R/home/ADS/edgars/.rvm/usr/lib
107
+ libpath = . $(libdir) /home/sybase/.rvm/usr/lib
108
+ LIBPATH = -L. -L$(libdir) -Wl,-R$(libdir) -L/home/sybase/.rvm/usr/lib -Wl,-R/home/sybase/.rvm/usr/lib
107
109
  DEFFILE =
108
110
 
109
111
  CLEANFILES = mkmf.log
@@ -115,8 +117,8 @@ extout_prefix =
115
117
  target_prefix =
116
118
  LOCAL_LIBS =
117
119
  LIBS = $(LIBRUBYARG_SHARED) -lpthread -lrt -ldl -lcrypt -lm -lc
118
- SRCS = advantage.c adscapidll.c
119
- OBJS = advantage.o adscapidll.o
120
+ SRCS = adscapidll.c advantage.c dbcapi.cpp
121
+ OBJS = adscapidll.o advantage.o dbcapi.o
120
122
  TARGET = advantage
121
123
  DLLIB = $(TARGET).so
122
124
  EXTSTATIC =
@@ -155,19 +157,21 @@ distclean: clean distclean-so distclean-rb-default distclean-rb
155
157
  realclean: distclean
156
158
  install: install-so install-rb
157
159
 
158
- install-so: $(RUBYARCHDIR)
159
160
  install-so: $(RUBYARCHDIR)/$(DLLIB)
160
161
  $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
161
- @-$(MAKEDIRS) $(@D)
162
+ -$(Q)$(MAKEDIRS) $(@D)
162
163
  $(INSTALL_PROG) $(DLLIB) $(@D)
164
+ clean-static::
165
+ -$(Q)$(RM) $(STATIC_LIB)
163
166
  install-rb: pre-install-rb install-rb-default
164
167
  install-rb-default: pre-install-rb-default
165
168
  pre-install-rb: Makefile
166
169
  pre-install-rb-default: Makefile
167
170
  pre-install-rb-default:
168
171
  $(ECHO) installing default advantage libraries
169
- $(RUBYARCHDIR):
170
- $(Q) $(MAKEDIRS) $@
172
+ ./.RUBYARCHDIR.time:
173
+ $(Q) $(MAKEDIRS) $(RUBYARCHDIR)
174
+ $(Q) $(TOUCH) $@
171
175
 
172
176
  site-install: site-install-so site-install-rb
173
177
  site-install-so: install-so
@@ -205,8 +209,8 @@ site-install-rb: install-rb
205
209
 
206
210
  $(DLLIB): $(OBJS) Makefile
207
211
  $(ECHO) linking shared-object $(DLLIB)
208
- @-$(RM) $(@)
209
- $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
212
+ -$(Q)$(RM) $(@)
213
+ $(Q) $(LDSHAREDXX) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
210
214
 
211
215
 
212
216
 
data/ext/ace.h CHANGED
@@ -19,7 +19,7 @@
19
19
  // cost of servicing or repair. No oral or written information or advice given
20
20
  // by an Extended Systems Inc. representative shall create a warranty or in any
21
21
  // way increase the scope of this warranty.
22
- // LIBACE_VERSION 10.99
22
+ // LIBACE_VERSION 11.10
23
23
  /*******************************************************************************
24
24
  * Source File : ace.h
25
25
  * Description : This is the main header file for the Advantage Client
@@ -1503,6 +1503,11 @@ typedef struct _ADD_FIELD_DESC_
1503
1503
  #define ADS_CIPHER_SUITE_STRING_AES128 "AES128-SHA"
1504
1504
  #define ADS_CIPHER_SUITE_STRING_AES256 "AES256-SHA"
1505
1505
 
1506
+ /*
1507
+ * System alias which always resolves to the root dictionary
1508
+ * defined by ADS_ROOT_DICTIONARY server configuration setting
1509
+ */
1510
+ #define ADS_ROOT_DD_ALIAS "__rootdd"
1506
1511
 
1507
1512
  /* Options for the AdsGetKeyFilter */
1508
1513
  #define ADS_FILTER_FORMAT_ODATA 0x00000001
File without changes
File without changes
Binary file
@@ -21,12 +21,13 @@
21
21
  #include "ruby.h"
22
22
  #include "adscapidll.h"
23
23
 
24
- const char* VERSION = "0.1.0";
24
+ const char* VERSION = "0.1.1";
25
25
 
26
- typedef struct imp_drh_st {
27
- AdvantageInterface api;
28
- void *adscapi_context;
29
- } imp_drh_st;
26
+ typedef struct imp_drh_st
27
+ {
28
+ AdvantageInterface api;
29
+ void *adscapi_context;
30
+ } imp_drh_st;
30
31
 
31
32
  // Defining the Ruby Modules
32
33
  static VALUE mAdvantage;
@@ -36,163 +37,166 @@ static VALUE cAdvantageInterface;
36
37
  // Defining binder for DBCAPI types
37
38
  static VALUE cA_ads_connection;
38
39
  static VALUE cA_ads_data_value;
39
- static VALUE cA_ads_stmt;
40
40
  static VALUE cA_ads_bind_param;
41
41
  static VALUE cA_ads_bind_param_info;
42
42
 
43
43
  // This function is called when the module is first loaded by ruby.
44
44
  // The name of this function MUST match be Init_<modulename>.
45
- void Init_advantage();
45
+ void Init_advantage( );
46
46
 
47
47
  // Wrapper functions for the DBICAPI functions
48
48
 
49
49
  static VALUE
50
- static_API_ads_initialize_interface(VALUE module, VALUE imp_drh);
50
+ static_API_ads_initialize_interface( VALUE module, VALUE imp_drh );
51
51
 
52
52
  static VALUE
53
- static_API_ads_finalize_interface(VALUE module, VALUE imp_drh);
53
+ static_API_ads_finalize_interface( VALUE module, VALUE imp_drh );
54
54
 
55
55
  static VALUE
56
- static_AdvantageInterface_alloc(VALUE class);
56
+ static_AdvantageInterface_alloc( VALUE class );
57
57
 
58
58
  static VALUE
59
- static_AdvantageInterface_ads_init(VALUE class);
59
+ static_AdvantageInterface_ads_init( VALUE class );
60
60
 
61
61
  static VALUE
62
- static_AdvantageInterface_ads_new_connection(VALUE class);
62
+ static_AdvantageInterface_ads_new_connection( VALUE class );
63
63
 
64
64
  static VALUE
65
- static_AdvantageInterface_ads_client_version(VALUE imp_drh);
65
+ static_AdvantageInterface_ads_client_version( VALUE imp_drh );
66
66
 
67
67
  static VALUE
68
- static_AdvantageInterface_ads_connect(VALUE imp_drh, VALUE ads_conn, VALUE str);
68
+ static_AdvantageInterface_ads_connect( VALUE imp_drh, VALUE ads_conn, VALUE str );
69
69
 
70
70
  static VALUE
71
- static_AdvantageInterface_ads_disconnect(VALUE imp_drh, VALUE ads_conn);
71
+ static_AdvantageInterface_ads_disconnect( VALUE imp_drh, VALUE ads_conn );
72
72
 
73
73
  static VALUE
74
- static_AdvantageInterface_ads_free_connection(VALUE imp_drh, VALUE ads_conn);
74
+ static_AdvantageInterface_ads_free_connection( VALUE imp_drh, VALUE ads_conn );
75
75
 
76
76
  static VALUE
77
- static_AdvantageInterface_ads_fini(VALUE imp_drh);
77
+ static_AdvantageInterface_ads_fini( VALUE imp_drh );
78
78
 
79
79
  static VALUE
80
- static_AdvantageInterface_ads_error(VALUE imp_drh, VALUE ads_conn);
80
+ static_AdvantageInterface_ads_error( VALUE imp_drh, VALUE ads_conn );
81
81
 
82
82
  static VALUE
83
- static_AdvantageInterface_ads_execute_immediate(VALUE imp_drh, VALUE ads_conn, VALUE sql);
83
+ static_AdvantageInterface_ads_execute_immediate( VALUE imp_drh, VALUE ads_conn, VALUE sql );
84
84
 
85
85
  static VALUE
86
- static_AdvantageInterface_ads_execute_direct(VALUE imp_drh, VALUE ads_conn, VALUE sql);
86
+ static_AdvantageInterface_ads_execute_direct( VALUE imp_drh, VALUE ads_conn, VALUE sql );
87
87
 
88
88
  static VALUE
89
- static_AdvantageInterface_ads_num_cols(VALUE imp_drh, VALUE ads_stmt);
89
+ static_AdvantageInterface_ads_num_cols( VALUE imp_drh, VALUE ads_stmt );
90
90
 
91
91
  static VALUE
92
- static_AdvantageInterface_ads_num_rows(VALUE imp_drh, VALUE ads_stmt);
92
+ static_AdvantageInterface_ads_num_rows( VALUE imp_drh, VALUE ads_stmt );
93
93
 
94
94
  static VALUE
95
- static_AdvantageInterface_ads_get_column(VALUE imp_drh, VALUE ads_stmt, VALUE col_num);
95
+ static_AdvantageInterface_ads_get_column( VALUE imp_drh, VALUE ads_stmt, VALUE col_num );
96
96
 
97
97
  static VALUE
98
- static_AdvantageInterface_ads_fetch_next(VALUE imp_drh, VALUE ads_stmt);
98
+ static_AdvantageInterface_ads_fetch_next( VALUE imp_drh, VALUE ads_stmt );
99
99
 
100
100
  static VALUE
101
- static_AdvantageInterface_ads_get_column_info(VALUE imp_drh, VALUE ads_stmt, VALUE col_num);
101
+ static_AdvantageInterface_ads_get_column_info( VALUE imp_drh, VALUE ads_stmt, VALUE col_num );
102
102
 
103
103
  static VALUE
104
- static_AdvantageInterface_AdsBeginTransaction(VALUE imp_drh, VALUE ads_conn);
104
+ static_AdvantageInterface_AdsBeginTransaction( VALUE imp_drh, VALUE ads_conn );
105
105
 
106
106
  static VALUE
107
- static_AdvantageInterface_ads_commit(VALUE imp_drh, VALUE ads_conn);
107
+ static_AdvantageInterface_ads_commit( VALUE imp_drh, VALUE ads_conn );
108
108
 
109
109
  static VALUE
110
- static_AdvantageInterface_ads_rollback(VALUE imp_drh, VALUE ads_conn);
110
+ static_AdvantageInterface_ads_rollback( VALUE imp_drh, VALUE ads_conn );
111
111
 
112
112
  static VALUE
113
- static_AdvantageInterface_ads_prepare(VALUE imp_drh, VALUE ads_conn, VALUE sql);
113
+ static_AdvantageInterface_ads_prepare( VALUE imp_drh, VALUE ads_conn, VALUE sql );
114
114
 
115
115
  static VALUE
116
- static_AdvantageInterface_ads_free_stmt(VALUE imp_drh, VALUE ads_stmt);
116
+ static_AdvantageInterface_ads_free_stmt( VALUE imp_drh, VALUE ads_stmt );
117
117
 
118
118
  static VALUE
119
- static_AdvantageInterface_ads_reset(VALUE imp_drh, VALUE ads_stmt);
119
+ static_AdvantageInterface_ads_reset( VALUE imp_drh, VALUE ads_stmt );
120
120
 
121
121
  static VALUE
122
- static_AdvantageInterface_ads_execute(VALUE imp_drh, VALUE ads_stmt);
122
+ static_AdvantageInterface_ads_execute( VALUE imp_drh, VALUE ads_stmt );
123
123
 
124
124
  static VALUE
125
- static_AdvantageInterface_ads_affected_rows(VALUE imp_drh, VALUE ads_stmt);
125
+ static_AdvantageInterface_ads_affected_rows( VALUE imp_drh, VALUE ads_stmt );
126
126
 
127
127
  static VALUE
128
- static_AdvantageInterface_ads_describe_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index);
128
+ static_AdvantageInterface_ads_describe_bind_param( VALUE imp_drh, VALUE ads_stmt, VALUE index );
129
129
 
130
130
  /*
131
131
  * C to Ruby Data conversion function to convert DBCAPI column type into the correct Ruby type
132
132
  */
133
- static VALUE C2RB(a_ads_data_value* value)
134
- {
133
+ static VALUE C2RB( a_ads_data_value* value )
134
+ {
135
135
  VALUE tdata;
136
136
 
137
- if( value == NULL || value->buffer == NULL || value->is_null == NULL ) {
138
- rb_raise(rb_eTypeError, "Operation not allowed. Has no value.");
139
- }
140
- else if ( *value->is_null ) {
137
+ if( value == NULL || value->buffer == NULL || value->is_null == NULL )
138
+ {
139
+ rb_raise( rb_eTypeError, "Operation not allowed. Has no value." );
140
+ }
141
+ else if( *value->is_null )
142
+ {
141
143
  tdata = Qnil;
142
- }
143
- else {
144
- switch( value->type ) {
145
- case A_BINARY:
146
- tdata = rb_str_new(value->buffer, *value->length);
147
- break;
148
- case A_STRING:
149
- case A_DATE:
150
- case A_TIME:
151
- case A_TIMESTAMP:
152
- case A_NCHAR:
153
- case A_DECIMAL:
154
- tdata = rb_str_new(value->buffer, *value->length);
155
- break;
156
- case A_DOUBLE:
157
- tdata = rb_float_new(*(double*) value->buffer);
158
- break;
159
- case A_VAL64:
160
- tdata = LL2NUM(*(LONG_LONG*)value->buffer);
161
- break;
162
- case A_UVAL64:
163
- tdata = ULL2NUM(*(unsigned LONG_LONG*)value->buffer);
164
- break;
165
- case A_VAL32:
166
- tdata = INT2NUM(*(int *)value->buffer);
167
- break;
168
- case A_UVAL32:
169
- tdata = UINT2NUM(*(unsigned int *)value->buffer);
170
- break;
171
- case A_VAL16:
172
- tdata = INT2NUM(*(short *)value->buffer);
173
- break;
174
- case A_UVAL16:
175
- tdata = UINT2NUM(*( unsigned short *)value->buffer);
176
- break;
177
- case A_VAL8:
178
- tdata = CHR2FIX(*(unsigned char *)value->buffer);
179
- break;
180
- case A_UVAL8:
181
- tdata = CHR2FIX(*(unsigned char *)value->buffer);
182
- break;
183
- default:
184
- rb_raise(rb_eTypeError, "Invalid Data Type");
185
- tdata = Qnil;
186
- break;
187
144
  }
188
- }
145
+ else
146
+ {
147
+ switch( value->type )
148
+ {
149
+ case A_BINARY:
150
+ tdata = rb_str_new( ( char* )value->buffer, *value->length );
151
+ break;
152
+ case A_STRING:
153
+ case A_DATE:
154
+ case A_TIME:
155
+ case A_TIMESTAMP:
156
+ case A_NCHAR:
157
+ case A_DECIMAL:
158
+ tdata = rb_str_new( ( char* )value->buffer, *value->length );
159
+ break;
160
+ case A_DOUBLE:
161
+ tdata = rb_float_new( *( double* ) value->buffer );
162
+ break;
163
+ case A_VAL64:
164
+ tdata = LL2NUM( *( LONG_LONG* )value->buffer );
165
+ break;
166
+ case A_UVAL64:
167
+ tdata = ULL2NUM( *( unsigned LONG_LONG* )value->buffer );
168
+ break;
169
+ case A_VAL32:
170
+ tdata = INT2NUM( *( int * )value->buffer );
171
+ break;
172
+ case A_UVAL32:
173
+ tdata = UINT2NUM( *( unsigned int * )value->buffer );
174
+ break;
175
+ case A_VAL16:
176
+ tdata = INT2NUM( *( short * )value->buffer );
177
+ break;
178
+ case A_UVAL16:
179
+ tdata = UINT2NUM( *( unsigned short * )value->buffer );
180
+ break;
181
+ case A_VAL8:
182
+ tdata = CHR2FIX( *( unsigned char * )value->buffer );
183
+ break;
184
+ case A_UVAL8:
185
+ tdata = CHR2FIX( *( unsigned char * )value->buffer );
186
+ break;
187
+ default:
188
+ rb_raise( rb_eTypeError, "Invalid Data Type" );
189
+ tdata = Qnil;
190
+ break;
191
+ }
192
+ }
189
193
 
190
- return tdata;
191
- }
194
+ return tdata;
195
+ }
192
196
 
193
197
  /*
194
198
  * call-seq:
195
- * ads_initialize_interface(VALUE imp_drh) -> int result
199
+ * ads_initialize_interface( VALUE imp_drh ) -> int result
196
200
  *
197
201
  * Initializes the AdvantageInterface object and loads the DLL dynamically.
198
202
  *
@@ -207,21 +211,21 @@ static VALUE C2RB(a_ads_data_value* value)
207
211
  *
208
212
  */
209
213
  static VALUE
210
- static_API_ads_initialize_interface(VALUE module, VALUE imp_drh)
211
- {
212
- imp_drh_st* s_imp_drh;
213
- int result;
214
+ static_API_ads_initialize_interface( VALUE module, VALUE imp_drh )
215
+ {
216
+ imp_drh_st* s_imp_drh;
217
+ int result;
214
218
 
215
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
219
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
216
220
 
217
- result = ads_initialize_interface( &(s_imp_drh->api), NULL );
221
+ result = ads_initialize_interface( &( s_imp_drh->api ), NULL );
218
222
 
219
- return( INT2NUM(result) );
220
- }
223
+ return( INT2NUM( result ) );
224
+ }
221
225
 
222
226
  /*
223
227
  * call-seq:
224
- * ads_finalize_interface(VALUE imp_drh) -> nil
228
+ * ads_finalize_interface( VALUE imp_drh ) -> nil
225
229
  *
226
230
  * Finalize and free resources associated with the Advantage C API DLL.
227
231
  *
@@ -236,35 +240,35 @@ static_API_ads_initialize_interface(VALUE module, VALUE imp_drh)
236
240
  *
237
241
  */
238
242
  static VALUE
239
- static_API_ads_finalize_interface(VALUE module, VALUE imp_drh)
240
- {
241
- imp_drh_st* s_imp_drh;
243
+ static_API_ads_finalize_interface( VALUE module, VALUE imp_drh )
244
+ {
245
+ imp_drh_st* s_imp_drh;
242
246
 
243
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
247
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
244
248
 
245
- ads_finalize_interface(&(s_imp_drh->api));
249
+ ads_finalize_interface( &( s_imp_drh->api ) );
246
250
 
247
- free(&(s_imp_drh->api));
251
+ free( &( s_imp_drh->api ) );
248
252
 
249
- return( Qnil );
250
- }
253
+ return( Qnil );
254
+ }
251
255
 
252
256
  static VALUE
253
- static_AdvantageInterface_alloc(VALUE class)
254
- {
255
- imp_drh_st *imp_drh = NULL;
256
- VALUE tdata;
257
+ static_AdvantageInterface_alloc( VALUE class )
258
+ {
259
+ imp_drh_st *imp_drh = NULL;
260
+ VALUE tdata;
257
261
 
258
- imp_drh = malloc( sizeof(imp_drh_st) );
259
- memset( imp_drh, 0, sizeof(imp_drh_st));
262
+ imp_drh = malloc( sizeof( imp_drh_st ) );
263
+ memset( imp_drh, 0, sizeof( imp_drh_st ) );
260
264
 
261
- tdata = Data_Wrap_Struct(class, 0, 0, imp_drh);
262
- return tdata;
263
- }
265
+ tdata = Data_Wrap_Struct( class, 0, 0, imp_drh );
266
+ return tdata;
267
+ }
264
268
 
265
269
  /*
266
270
  * call-seq:
267
- * ads_init(VALUE imp_drh) -> [VALUE result, VALUE version]
271
+ * ads_init( VALUE imp_drh ) -> [VALUE result, VALUE version]
268
272
  *
269
273
  * Initializes the interface.
270
274
  *
@@ -277,32 +281,35 @@ static_AdvantageInterface_alloc(VALUE class)
277
281
  *
278
282
  */
279
283
  static VALUE
280
- static_AdvantageInterface_ads_init(VALUE imp_drh)
281
- {
282
- imp_drh_st* s_imp_drh;
283
- UNSIGNED32 result;
284
- UNSIGNED32 s_version_available;
285
- VALUE multi_result;
284
+ static_AdvantageInterface_ads_init( VALUE imp_drh )
285
+ {
286
+ imp_drh_st* s_imp_drh;
287
+ UNSIGNED32 result;
288
+ UNSIGNED32 s_version_available;
289
+ VALUE multi_result;
286
290
 
287
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
291
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
288
292
 
289
- multi_result = rb_ary_new();
293
+ multi_result = rb_ary_new( );
290
294
 
291
- if( &(s_imp_drh->api) == NULL ) {
292
- rb_ary_push(multi_result, INT2NUM(0));
293
- rb_ary_push(multi_result, Qnil );
294
- } else {
295
- result = s_imp_drh->api.ads_init((UNSIGNED8*)"RUBY", 1 , &s_version_available );
296
- rb_ary_push(multi_result, INT2NUM(result));
297
- rb_ary_push(multi_result, INT2NUM(s_version_available));
295
+ if( &( s_imp_drh->api ) == NULL )
296
+ {
297
+ rb_ary_push( multi_result, INT2NUM( 0 ) );
298
+ rb_ary_push( multi_result, Qnil );
299
+ }
300
+ else
301
+ {
302
+ result = s_imp_drh->api.ads_init( ( UNSIGNED8* )"RUBY", 1 , &s_version_available );
303
+ rb_ary_push( multi_result, INT2NUM( result ) );
304
+ rb_ary_push( multi_result, INT2NUM( s_version_available ) );
298
305
  }
299
306
 
300
- return( multi_result );
301
- }
307
+ return( multi_result );
308
+ }
302
309
 
303
310
  /*
304
311
  * call-seq:
305
- * ads_new_connection(VALUE imp_drh) -> VALUE connection
312
+ * ads_new_connection( VALUE imp_drh ) -> VALUE connection
306
313
  *
307
314
  * Creates a connection object.
308
315
  *
@@ -318,23 +325,23 @@ static_AdvantageInterface_ads_init(VALUE imp_drh)
318
325
  *
319
326
  */
320
327
  static VALUE
321
- static_AdvantageInterface_ads_new_connection(VALUE imp_drh)
322
- {
323
- imp_drh_st* s_imp_drh;
324
- a_ads_connection* ptr;
325
- VALUE tdata;
328
+ static_AdvantageInterface_ads_new_connection( VALUE imp_drh )
329
+ {
330
+ imp_drh_st* s_imp_drh;
331
+ a_ads_connection* ptr;
332
+ VALUE tdata;
326
333
 
327
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
328
- ptr = s_imp_drh->api.ads_new_connection();
334
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
335
+ ptr = s_imp_drh->api.ads_new_connection( );
329
336
 
330
- tdata = Data_Wrap_Struct(cA_ads_connection, 0, 0, ptr);
337
+ tdata = Data_Wrap_Struct( cA_ads_connection, 0, 0, ptr );
331
338
 
332
- return (tdata);
333
- }
339
+ return( tdata );
340
+ }
334
341
 
335
342
  /*
336
343
  * call-seq:
337
- * ads_client_version(VALUE imp_drh) -> [VALUE verstr]
344
+ * ads_client_version( VALUE imp_drh ) -> [VALUE verstr]
338
345
  *
339
346
  * Retrieves the client version as a string.
340
347
  *
@@ -349,22 +356,21 @@ static_AdvantageInterface_ads_new_connection(VALUE imp_drh)
349
356
  */
350
357
 
351
358
  static VALUE
352
- static_AdvantageInterface_ads_client_version(VALUE imp_drh)
353
- {
354
- imp_drh_st* s_imp_drh;
355
- size_t s_size;
356
- char s_buffer[255];
359
+ static_AdvantageInterface_ads_client_version( VALUE imp_drh )
360
+ {
361
+ imp_drh_st* s_imp_drh;
362
+ char s_buffer[255];
357
363
 
358
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
364
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
359
365
 
360
- s_imp_drh->api.ads_client_version(s_buffer, 255);
366
+ s_imp_drh->api.ads_client_version( ( UNSIGNED8* )s_buffer, 255 );
361
367
 
362
- return (rb_str_new2(s_buffer));
363
- }
368
+ return( rb_str_new2( s_buffer ) );
369
+ }
364
370
 
365
371
  /*
366
372
  * call-seq:
367
- * ads_connect(VALUE imp_drh, VALUE ads_conn, VALUE str) -> VALUE result
373
+ * ads_connect( VALUE imp_drh, VALUE ads_conn, VALUE str ) -> VALUE result
368
374
  *
369
375
  * Creates a connection object.
370
376
  *
@@ -374,7 +380,7 @@ static_AdvantageInterface_ads_client_version(VALUE imp_drh)
374
380
  *
375
381
  * <b>Parameters</b>:
376
382
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
377
- * - <tt>VALUE ads_conn</tt> -- A connection object that was created by ads_new_connection().
383
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was created by ads_new_connection( ).
378
384
  * - <tt>VALUE str</tt> -- A connection string.
379
385
  *
380
386
  * <b>Returns</b>:
@@ -382,26 +388,26 @@ static_AdvantageInterface_ads_client_version(VALUE imp_drh)
382
388
  *
383
389
  */
384
390
  static VALUE
385
- static_AdvantageInterface_ads_connect(VALUE imp_drh, VALUE ads_conn, VALUE str)
386
- {
387
- imp_drh_st* s_imp_drh;
388
- a_ads_connection* s_ads_conn;
389
- char* s_str;
390
- UNSIGNED32 result;
391
+ static_AdvantageInterface_ads_connect( VALUE imp_drh, VALUE ads_conn, VALUE str )
392
+ {
393
+ imp_drh_st* s_imp_drh;
394
+ a_ads_connection* s_ads_conn;
395
+ char* s_str;
396
+ UNSIGNED32 result;
391
397
 
392
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
393
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
398
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
399
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
394
400
 
395
- s_str = StringValueCStr( str );
401
+ s_str = StringValueCStr( str );
396
402
 
397
- result = s_imp_drh->api.ads_connect( s_ads_conn, s_str );
403
+ result = s_imp_drh->api.ads_connect( s_ads_conn, ( UNSIGNED8* )s_str );
398
404
 
399
- return( INT2NUM(result) );
400
- }
405
+ return( INT2NUM( result ) );
406
+ }
401
407
 
402
408
  /*
403
409
  * call-seq:
404
- * ads_disconnect(VALUE imp_drh, VALUE ads_conn) -> nil
410
+ * ads_disconnect( VALUE imp_drh, VALUE ads_conn ) -> nil
405
411
  *
406
412
  * Disconnect an already established connection.
407
413
  *
@@ -410,59 +416,59 @@ static_AdvantageInterface_ads_connect(VALUE imp_drh, VALUE ads_conn, VALUE str)
410
416
  *
411
417
  * <b>Parameters</b>:
412
418
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
413
- * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
419
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
414
420
  *
415
421
  * <b>Returns</b>:
416
422
  * - <tt>nil</tt>.
417
423
  *
418
424
  */
419
425
  static VALUE
420
- static_AdvantageInterface_ads_disconnect(VALUE imp_drh, VALUE ads_conn)
421
- {
422
- imp_drh_st* s_imp_drh;
423
- a_ads_connection* s_ads_conn;
426
+ static_AdvantageInterface_ads_disconnect( VALUE imp_drh, VALUE ads_conn )
427
+ {
428
+ imp_drh_st* s_imp_drh;
429
+ a_ads_connection* s_ads_conn;
424
430
 
425
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
426
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
431
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
432
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
427
433
 
428
434
 
429
- s_imp_drh->api.ads_disconnect( s_ads_conn );
435
+ s_imp_drh->api.ads_disconnect( s_ads_conn );
430
436
 
431
- return( Qnil );
432
- }
437
+ return( Qnil );
438
+ }
433
439
 
434
440
  /*
435
441
  * call-seq:
436
- * ads_free_connection(VALUE imp_drh, VALUE ads_conn) -> nil
442
+ * ads_free_connection( VALUE imp_drh, VALUE ads_conn ) -> nil
437
443
  *
438
444
  * Frees the resources associated with a connection object.
439
445
  *
440
446
  * <b>Parameters</b>:
441
447
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
442
- * - <tt>VALUE ads_conn</tt> -- A connection object that was disconnected by ads_disconnect().
448
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was disconnected by ads_disconnect( ).
443
449
  *
444
450
  * <b>Returns</b>:
445
451
  * - <tt>nil</tt>.
446
452
  *
447
453
  */
448
454
  static VALUE
449
- static_AdvantageInterface_ads_free_connection(VALUE imp_drh, VALUE ads_conn)
450
- {
451
- imp_drh_st* s_imp_drh;
452
- a_ads_connection* s_ads_conn;
455
+ static_AdvantageInterface_ads_free_connection( VALUE imp_drh, VALUE ads_conn )
456
+ {
457
+ imp_drh_st* s_imp_drh;
458
+ a_ads_connection* s_ads_conn;
453
459
 
454
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
455
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
460
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
461
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
456
462
 
457
463
 
458
- s_imp_drh->api.ads_free_connection( s_ads_conn );
464
+ s_imp_drh->api.ads_free_connection( s_ads_conn );
459
465
 
460
- return( Qnil );
461
- }
466
+ return( Qnil );
467
+ }
462
468
 
463
469
  /*
464
470
  * call-seq:
465
- * ads_fini(VALUE imp_drh) -> nil
471
+ * ads_fini( VALUE imp_drh ) -> nil
466
472
  *
467
473
  * Finalizes the interface.
468
474
  *
@@ -476,20 +482,20 @@ static_AdvantageInterface_ads_free_connection(VALUE imp_drh, VALUE ads_conn)
476
482
  *
477
483
  */
478
484
  static VALUE
479
- static_AdvantageInterface_ads_fini(VALUE imp_drh)
480
- {
481
- imp_drh_st* s_imp_drh;
485
+ static_AdvantageInterface_ads_fini( VALUE imp_drh )
486
+ {
487
+ imp_drh_st* s_imp_drh;
482
488
 
483
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
489
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
484
490
 
485
- s_imp_drh->api.ads_fini();
491
+ s_imp_drh->api.ads_fini( );
486
492
 
487
- return( Qnil );
488
- }
493
+ return( Qnil );
494
+ }
489
495
 
490
496
  /*
491
497
  * call-seq:
492
- * ads_error(VALUE imp_drh, VALUE ads_conn) -> [VALUE result, VALUE errstr]
498
+ * ads_error( VALUE imp_drh, VALUE ads_conn ) -> [VALUE result, VALUE errstr]
493
499
  *
494
500
  * Retrieves the last error code and message.
495
501
  *
@@ -498,7 +504,7 @@ static_AdvantageInterface_ads_fini(VALUE imp_drh)
498
504
  *
499
505
  * <b>Parameters</b>:
500
506
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
501
- * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
507
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
502
508
  *
503
509
  * <b>Returns</b>:
504
510
  * - <tt>VALUE result</tt>: The last error code. Positive values are warnings, negative values are errors, and <tt>0</tt> is success.
@@ -507,31 +513,30 @@ static_AdvantageInterface_ads_fini(VALUE imp_drh)
507
513
  */
508
514
 
509
515
  static VALUE
510
- static_AdvantageInterface_ads_error(VALUE imp_drh, VALUE ads_conn)
511
- {
512
- imp_drh_st* s_imp_drh;
513
- a_ads_connection* s_ads_conn;
514
- size_t s_size;
515
- char s_buffer[255];
516
- UNSIGNED32 result;
517
- VALUE multi_result;
516
+ static_AdvantageInterface_ads_error( VALUE imp_drh, VALUE ads_conn )
517
+ {
518
+ imp_drh_st* s_imp_drh;
519
+ a_ads_connection* s_ads_conn;
520
+ char s_buffer[255];
521
+ UNSIGNED32 result;
522
+ VALUE multi_result;
518
523
 
519
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
520
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
524
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
525
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
521
526
 
522
- result = s_imp_drh->api.ads_error(s_ads_conn, s_buffer, 255);
527
+ result = s_imp_drh->api.ads_error( s_ads_conn, ( UNSIGNED8* )s_buffer, 255 );
523
528
 
524
- multi_result = rb_ary_new();
529
+ multi_result = rb_ary_new( );
525
530
 
526
- rb_ary_push(multi_result, INT2NUM(result));
527
- rb_ary_push(multi_result, rb_str_new2(s_buffer));
531
+ rb_ary_push( multi_result, INT2NUM( result ) );
532
+ rb_ary_push( multi_result, rb_str_new2( s_buffer ) );
528
533
 
529
- return( multi_result );
530
- }
534
+ return( multi_result );
535
+ }
531
536
 
532
537
  /*
533
538
  * call-seq:
534
- * ads_execute_immediate(VALUE imp_drh, VALUE ads_conn, VALUE sql) -> VALUE result
539
+ * ads_execute_immediate( VALUE imp_drh, VALUE ads_conn, VALUE sql ) -> VALUE result
535
540
  *
536
541
  * Executes a SQL statement immediately without returning a result set.
537
542
  *
@@ -541,7 +546,7 @@ static_AdvantageInterface_ads_error(VALUE imp_drh, VALUE ads_conn)
541
546
  *
542
547
  * <b>Parameters</b>:
543
548
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
544
- * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
549
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
545
550
  * - <tt>VALUE sql</tt> -- A SQL query string.
546
551
  *
547
552
  * <b>Returns</b>:
@@ -549,40 +554,40 @@ static_AdvantageInterface_ads_error(VALUE imp_drh, VALUE ads_conn)
549
554
  *
550
555
  */
551
556
  static VALUE
552
- static_AdvantageInterface_ads_execute_immediate(VALUE imp_drh, VALUE ads_conn, VALUE sql)
553
- {
554
- imp_drh_st* s_imp_drh;
555
- a_ads_connection* s_ads_conn;
556
- char* s_sql;
557
- UNSIGNED32 result;
557
+ static_AdvantageInterface_ads_execute_immediate( VALUE imp_drh, VALUE ads_conn, VALUE sql )
558
+ {
559
+ imp_drh_st* s_imp_drh;
560
+ a_ads_connection* s_ads_conn;
561
+ char* s_sql;
562
+ UNSIGNED32 result;
558
563
 
559
- s_sql = StringValueCStr( sql );
564
+ s_sql = StringValueCStr( sql );
560
565
 
561
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
562
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
566
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
567
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
563
568
 
564
- result = s_imp_drh->api.ads_execute_immediate(s_ads_conn, s_sql);
569
+ result = s_imp_drh->api.ads_execute_immediate( s_ads_conn, ( UNSIGNED8* )s_sql );
565
570
 
566
- return( INT2NUM(result) );
567
- }
571
+ return( INT2NUM( result ) );
572
+ }
568
573
 
569
574
  /*
570
575
  * call-seq:
571
- * ads_execute_direct(VALUE imp_drh, VALUE ads_conn, VALUE sql) -> VALUE resultset
576
+ * ads_execute_direct( VALUE imp_drh, VALUE ads_conn, VALUE sql ) -> VALUE resultset
572
577
  *
573
578
  * Executes a SQL statement and possibly returns a result set.
574
579
  *
575
580
  * This function executes the SQL statement specified by the string argument.
576
581
  * This function is suitable if you want to prepare and then execute a
577
- * statement, and can be used instead of calling ads_prepare() followed
578
- * by ads_execute().
582
+ * statement, and can be used instead of calling ads_prepare( ) followed
583
+ * by ads_execute( ).
579
584
  *
580
585
  * This function cannot be used for executing a SQL statement with
581
586
  * parameters.
582
587
  *
583
588
  * <b>Parameters</b>:
584
589
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
585
- * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
590
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
586
591
  * - <tt>VALUE sql</tt> -- A SQL query string.
587
592
  *
588
593
  * <b>Returns</b>:
@@ -590,198 +595,199 @@ static_AdvantageInterface_ads_execute_immediate(VALUE imp_drh, VALUE ads_conn, V
590
595
  *
591
596
  */
592
597
  static VALUE
593
- static_AdvantageInterface_ads_execute_direct(VALUE imp_drh, VALUE ads_conn, VALUE sql)
594
- {
595
- imp_drh_st* s_imp_drh;
596
- a_ads_connection* s_ads_conn;
597
- ADSHANDLE resultset = 0;
598
- char* s_sql;
599
- VALUE tdata;
598
+ static_AdvantageInterface_ads_execute_direct( VALUE imp_drh, VALUE ads_conn, VALUE sql )
599
+ {
600
+ imp_drh_st* s_imp_drh;
601
+ a_ads_connection* s_ads_conn;
602
+ ADSHANDLE resultset = 0;
603
+ char* s_sql;
604
+ VALUE tdata;
600
605
 
601
- s_sql = StringValueCStr( sql );
606
+ s_sql = StringValueCStr( sql );
602
607
 
603
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
604
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
608
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
609
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
605
610
 
606
- resultset = s_imp_drh->api.ads_execute_direct(s_ads_conn, s_sql);
611
+ resultset = s_imp_drh->api.ads_execute_direct( s_ads_conn, ( UNSIGNED8* )s_sql );
607
612
 
608
- if (resultset)
609
- {
610
- tdata = INT2NUM(resultset);
611
- }
612
- else
613
- {
614
- tdata = Qnil;
615
- }
613
+ if( resultset )
614
+ {
615
+ tdata = INT2NUM( resultset );
616
+ }
617
+ else
618
+ {
619
+ tdata = Qnil;
620
+ }
616
621
 
617
- return (tdata);
618
- }
622
+ return( tdata );
623
+ }
619
624
 
620
625
  /*
621
626
  * call-seq:
622
- * ads_num_cols(VALUE imp_drh, VALUE ads_stmt) -> VALUE num_cols
627
+ * ads_num_cols( VALUE imp_drh, VALUE ads_stmt ) -> VALUE num_cols
623
628
  *
624
629
  * Returns number of columns in the result set.
625
630
  *
626
631
  * <b>Parameters</b>:
627
632
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
628
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
633
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
629
634
  *
630
635
  * <b>Returns</b>:
631
636
  * - <tt>VALUE num_cols</tt>: The number of columns in the result set or <tt>-1</tt> on a failure.
632
637
  *
633
638
  */
634
639
  static VALUE
635
- static_AdvantageInterface_ads_num_cols(VALUE imp_drh, VALUE ads_stmt)
636
- {
637
- imp_drh_st* s_imp_drh;
638
- ADSHANDLE s_stmt;
639
- UNSIGNED32 result;
640
+ static_AdvantageInterface_ads_num_cols( VALUE imp_drh, VALUE ads_stmt )
641
+ {
642
+ imp_drh_st* s_imp_drh;
643
+ ADSHANDLE s_stmt;
644
+ UNSIGNED32 result;
640
645
 
641
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
642
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_stmt);
643
- s_stmt = NUM2ULONG(ads_stmt);
646
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
647
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_stmt );
648
+ s_stmt = NUM2ULONG( ads_stmt );
644
649
 
645
- result = s_imp_drh->api.ads_num_cols(s_stmt);
650
+ result = s_imp_drh->api.ads_num_cols( s_stmt );
646
651
 
647
- return( INT2NUM(result) );
648
- }
652
+ return( INT2NUM( result ) );
653
+ }
649
654
 
650
655
  /*
651
656
  * call-seq:
652
- * ads_num_rows(VALUE imp_drh, VALUE ads_stmt) -> VALUE num_rows
657
+ * ads_num_rows( VALUE imp_drh, VALUE ads_stmt ) -> VALUE num_rows
653
658
  *
654
659
  * Returns number of rows in the result set.
655
660
  *
656
661
  * <b>Parameters</b>:
657
662
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
658
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
663
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
659
664
  *
660
665
  * <b>Returns</b>:
661
666
  * - <tt>VALUE num_rows</tt>: The number of rows in the result set or <tt>-1</tt> on a failure.
662
667
  *
663
668
  */
664
669
  static VALUE
665
- static_AdvantageInterface_ads_num_rows(VALUE imp_drh, VALUE ads_stmt)
666
- {
667
- imp_drh_st* s_imp_drh;
668
- ADSHANDLE s_stmt;
669
- UNSIGNED32 result;
670
+ static_AdvantageInterface_ads_num_rows( VALUE imp_drh, VALUE ads_stmt )
671
+ {
672
+ imp_drh_st* s_imp_drh;
673
+ ADSHANDLE s_stmt;
674
+ UNSIGNED32 result;
670
675
 
671
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
672
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_stmt);
673
- s_stmt = NUM2ULONG(ads_stmt);
676
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
677
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_stmt );
678
+ s_stmt = NUM2ULONG( ads_stmt );
674
679
 
675
- result = s_imp_drh->api.ads_num_rows(s_stmt);
680
+ result = s_imp_drh->api.ads_num_rows( s_stmt );
676
681
 
677
- return( INT2NUM(result) );
678
- }
682
+ return( INT2NUM( result ) );
683
+ }
679
684
 
680
685
  /*
681
686
  * call-seq:
682
- * ads_get_column(VALUE imp_drh, VALUE ads_stmt, VALUE col_num) -> [VALUE result, VALUE column_value]
687
+ * ads_get_column( VALUE imp_drh, VALUE ads_stmt, VALUE col_num ) -> [VALUE result, VALUE column_value]
683
688
  *
684
689
  * Retrieves the data fetched for the specified column.
685
690
  *
686
691
  * <b>Parameters</b>:
687
692
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
688
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
689
- * - <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and ads_num_cols() - 1.
693
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
694
+ * - <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and ads_num_cols( ) - 1.
690
695
  *
691
696
  * <b>Returns</b>:
692
697
  * - <tt>VALUE column_value</tt>: The value of the column. nil is returned if the value was NULL.
693
698
  *
694
699
  */
695
700
  static VALUE
696
- static_AdvantageInterface_ads_get_column(VALUE imp_drh, VALUE ads_stmt, VALUE col_num)
697
- {
698
- imp_drh_st* s_imp_drh;
699
- ADSHANDLE s_stmt;
700
- UNSIGNED32 s_col_num;
701
- a_ads_data_value value;
702
- UNSIGNED32 result;
703
- VALUE multi_result;
704
-
705
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
706
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_stmt);
707
- s_stmt = NUM2ULONG(ads_stmt);
708
- s_col_num = NUM2INT(col_num);
709
-
710
- result = s_imp_drh->api.ads_get_column(s_stmt, s_col_num, &value );
711
-
712
- multi_result = rb_ary_new();
713
- rb_ary_push(multi_result, INT2NUM(result));
714
-
715
- if( !result ) {
716
- rb_ary_push(multi_result, Qnil);
717
- }
718
- else
719
- {
720
- if( *value.is_null )
721
- {
722
- rb_ary_push(multi_result, Qnil);
723
- }
724
- else
725
- {
726
- rb_ary_push(multi_result, C2RB(&value));
727
- }
728
- }
729
-
730
- return( multi_result );
731
- }
701
+ static_AdvantageInterface_ads_get_column( VALUE imp_drh, VALUE ads_stmt, VALUE col_num )
702
+ {
703
+ imp_drh_st* s_imp_drh;
704
+ ADSHANDLE s_stmt;
705
+ UNSIGNED32 s_col_num;
706
+ a_ads_data_value value;
707
+ UNSIGNED32 result;
708
+ VALUE multi_result;
709
+
710
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
711
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_stmt );
712
+ s_stmt = NUM2ULONG( ads_stmt );
713
+ s_col_num = NUM2INT( col_num );
714
+
715
+ result = s_imp_drh->api.ads_get_column( s_stmt, s_col_num, &value );
716
+
717
+ multi_result = rb_ary_new( );
718
+ rb_ary_push( multi_result, INT2NUM( result ) );
719
+
720
+ if( !result )
721
+ {
722
+ rb_ary_push( multi_result, Qnil );
723
+ }
724
+ else
725
+ {
726
+ if( *value.is_null )
727
+ {
728
+ rb_ary_push( multi_result, Qnil );
729
+ }
730
+ else
731
+ {
732
+ rb_ary_push( multi_result, C2RB( &value ) );
733
+ }
734
+ }
735
+
736
+ return( multi_result );
737
+ }
732
738
 
733
739
  /*
734
740
  * call-seq:
735
- * ads_fetch_next(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
741
+ * ads_fetch_next( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
736
742
  *
737
743
  * Fetches the next row from the result set.
738
744
  *
739
745
  * This function fetches the next row from the result set. When the result
740
746
  * object is first created, the current row pointer is set to point before
741
- * the first row (that is, row 0).
747
+ * the first row ( that is, row 0 ).
742
748
  * This function advances the row pointer first and then fetches the data
743
749
  * at the new row.
744
750
  *
745
751
  * <b>Parameters</b>:
746
752
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
747
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
753
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
748
754
  *
749
755
  * <b>Returns</b>:
750
756
  * - <tt>VALUE result</tt>: <tt>1</tt> on successful fetch, <tt>0</tt> otherwise.
751
757
  *
752
758
  */
753
759
  static VALUE
754
- static_AdvantageInterface_ads_fetch_next(VALUE imp_drh, VALUE ads_stmt)
755
- {
756
- imp_drh_st* s_imp_drh;
757
- ADSHANDLE s_stmt;
758
- UNSIGNED32 result;
760
+ static_AdvantageInterface_ads_fetch_next( VALUE imp_drh, VALUE ads_stmt )
761
+ {
762
+ imp_drh_st* s_imp_drh;
763
+ ADSHANDLE s_stmt;
764
+ UNSIGNED32 result;
759
765
 
760
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
761
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_stmt);
762
- s_stmt = NUM2ULONG(ads_stmt);
766
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
767
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_stmt );
768
+ s_stmt = NUM2ULONG( ads_stmt );
763
769
 
764
- result = s_imp_drh->api.ads_fetch_next(s_stmt);
770
+ result = s_imp_drh->api.ads_fetch_next( s_stmt );
765
771
 
766
- return( INT2NUM(result) );
767
- }
772
+ return( INT2NUM( result ) );
773
+ }
768
774
 
769
775
  /*
770
776
  * call-seq:
771
- * ads_get_column_info(VALUE imp_drh, VALUE ads_stmt, VALUE col_num) -> [VALUE result, VALUE col_num, VALUE name, VALUE type, VALUE max_size]
777
+ * ads_get_column_info( VALUE imp_drh, VALUE ads_stmt, VALUE col_num ) -> [VALUE result, VALUE col_num, VALUE name, VALUE type, VALUE max_size]
772
778
  *
773
779
  * Fetches the next row from the result set.
774
780
  *
775
781
  * This function fetches the next row from the result set. When the result
776
782
  * object is first created, the current row pointer is set to point before
777
- * the first row (that is, row 0).
783
+ * the first row ( that is, row 0 ).
778
784
  * This function advances the row pointer first and then fetches the data
779
785
  * at the new row.
780
786
  *
781
787
  * <b>Parameters</b>:
782
788
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
783
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
784
- * - <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and ads_num_cols() - 1.
789
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
790
+ * - <tt>VALUE col_num</tt> -- The number of the column to be retrieved. A column number is between 0 and ads_num_cols( ) - 1.
785
791
  *
786
792
  * <b>Returns</b>:
787
793
  * - <tt>VALUE result</tt>: <tt>1</tt> on success. Returns <tt>0</tt> if the column index is out of range, or if the statement does not return a result set.
@@ -796,179 +802,178 @@ static_AdvantageInterface_ads_fetch_next(VALUE imp_drh, VALUE ads_stmt)
796
802
  *
797
803
  */
798
804
  static VALUE
799
- static_AdvantageInterface_ads_get_column_info(VALUE imp_drh, VALUE ads_stmt, VALUE col_num)
800
- {
801
- imp_drh_st* s_imp_drh;
802
- ADSHANDLE s_stmt;
803
- UNSIGNED32 s_col_num;
804
- a_ads_column_info info;
805
- UNSIGNED32 result;
806
- VALUE multi_result;
807
-
808
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
809
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_stmt);
810
- s_stmt = NUM2ULONG(ads_stmt);
811
- s_col_num = NUM2INT(col_num);
812
-
813
- result = s_imp_drh->api.ads_get_column_info(s_stmt, s_col_num, &info );
814
-
815
- multi_result = rb_ary_new();
816
- rb_ary_push(multi_result, INT2NUM(result));
817
- rb_ary_push(multi_result, col_num );
818
- rb_ary_push(multi_result, rb_str_new2(info.name));
819
- rb_ary_push(multi_result, INT2NUM(info.type));
820
- rb_ary_push(multi_result, INT2NUM(info.native_type));
821
- rb_ary_push(multi_result, INT2NUM(info.precision));
822
- rb_ary_push(multi_result, INT2NUM(info.scale));
823
- rb_ary_push(multi_result, INT2NUM(info.max_size));
824
- rb_ary_push(multi_result, INT2NUM(info.nullable));
825
-
826
- return( multi_result );
827
- }
805
+ static_AdvantageInterface_ads_get_column_info( VALUE imp_drh, VALUE ads_stmt, VALUE col_num )
806
+ {
807
+ imp_drh_st* s_imp_drh;
808
+ ADSHANDLE s_stmt;
809
+ UNSIGNED32 s_col_num;
810
+ a_ads_column_info info;
811
+ UNSIGNED32 result;
812
+ VALUE multi_result;
813
+
814
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
815
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_stmt );
816
+ s_stmt = NUM2ULONG( ads_stmt );
817
+ s_col_num = NUM2INT( col_num );
818
+
819
+ result = s_imp_drh->api.ads_get_column_info( s_stmt, s_col_num, &info );
820
+
821
+ multi_result = rb_ary_new( );
822
+ rb_ary_push( multi_result, INT2NUM( result ) );
823
+ rb_ary_push( multi_result, col_num );
824
+ rb_ary_push( multi_result, rb_str_new2( ( char* )info.name ) );
825
+ rb_ary_push( multi_result, INT2NUM( info.type ) );
826
+ rb_ary_push( multi_result, INT2NUM( info.native_type ) );
827
+ rb_ary_push( multi_result, INT2NUM( info.precision ) );
828
+ rb_ary_push( multi_result, INT2NUM( info.scale ) );
829
+ rb_ary_push( multi_result, INT2NUM( info.max_size ) );
830
+ rb_ary_push( multi_result, INT2NUM( info.nullable ) );
831
+
832
+ return( multi_result );
833
+ }
828
834
 
829
835
  /*
830
836
  * call-seq:
831
- * AdsBeginTransaction(VALUE imp_drh, VALUE ads_conn) -> VALUE result
837
+ * AdsBeginTransaction( VALUE imp_drh, VALUE ads_conn ) -> VALUE result
832
838
  *
833
839
  * Starts a transaction on the current connection.
834
840
  *
835
841
  * <b>Parameters</b>:
836
842
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
837
- * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
843
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
838
844
  *
839
845
  * <b>Returns</b>:
840
846
  * - <tt>VALUE result</tt>: <tt>1</tt> on successful begining a transaction, <tt>0</tt> otherwise.
841
847
  *
842
848
  */
843
849
  static VALUE
844
- static_AdvantageInterface_AdsBeginTransaction(VALUE imp_drh, VALUE ads_conn)
845
- {
846
- imp_drh_st* s_imp_drh;
847
- a_ads_connection* s_ads_conn;
848
- UNSIGNED32 result;
850
+ static_AdvantageInterface_AdsBeginTransaction( VALUE imp_drh, VALUE ads_conn )
851
+ {
852
+ imp_drh_st* s_imp_drh;
853
+ a_ads_connection* s_ads_conn;
854
+ UNSIGNED32 result;
849
855
 
850
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
851
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
856
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
857
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
852
858
 
853
- result = s_imp_drh->api.AdsBeginTransaction(s_ads_conn->hConnect);
854
- if ( result == 0 )
855
- return( INT2NUM(1) );
856
- else
857
- return( INT2NUM(0) );
858
- }
859
+ result = s_imp_drh->api.AdsBeginTransaction( s_ads_conn->hConnect );
860
+ if( result == 0 )
861
+ return( INT2NUM( 1 ) );
862
+ else
863
+ return( INT2NUM( 0 ) );
864
+ }
859
865
 
860
866
  /*
861
867
  * call-seq:
862
- * ads_commit(VALUE imp_drh, VALUE ads_conn) -> VALUE result
868
+ * ads_commit( VALUE imp_drh, VALUE ads_conn ) -> VALUE result
863
869
  *
864
870
  * Commits the current transaction.
865
871
  *
866
872
  * <b>Parameters</b>:
867
873
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
868
- * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
874
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
869
875
  *
870
876
  * <b>Returns</b>:
871
877
  * - <tt>VALUE result</tt>: <tt>1</tt> on successful commit, <tt>0</tt> otherwise.
872
878
  *
873
879
  */
874
880
  static VALUE
875
- static_AdvantageInterface_ads_commit(VALUE imp_drh, VALUE ads_conn)
876
- {
877
- imp_drh_st* s_imp_drh;
878
- a_ads_connection* s_ads_conn;
879
- UNSIGNED32 result;
881
+ static_AdvantageInterface_ads_commit( VALUE imp_drh, VALUE ads_conn )
882
+ {
883
+ imp_drh_st* s_imp_drh;
884
+ a_ads_connection* s_ads_conn;
885
+ UNSIGNED32 result;
880
886
 
881
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
882
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
887
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
888
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
883
889
 
884
- result = s_imp_drh->api.ads_commit(s_ads_conn);
890
+ result = s_imp_drh->api.ads_commit( s_ads_conn );
885
891
 
886
- return( INT2NUM(result) );
887
- }
892
+ return( INT2NUM( result ) );
893
+ }
888
894
 
889
895
 
890
896
  /*
891
897
  * call-seq:
892
- * ads_rollback(VALUE imp_drh, VALUE ads_conn) -> VALUE result
898
+ * ads_rollback( VALUE imp_drh, VALUE ads_conn ) -> VALUE result
893
899
  *
894
900
  * Rolls back the current transaction.
895
901
  *
896
902
  * <b>Parameters</b>:
897
903
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
898
- * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
904
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
899
905
  *
900
906
  * <b>Returns</b>:
901
907
  * - <tt>VALUE result</tt>: <tt>1</tt> on successful rollback, <tt>0</tt> otherwise.
902
908
  *
903
909
  */
904
910
  static VALUE
905
- static_AdvantageInterface_ads_rollback(VALUE imp_drh, VALUE ads_conn)
906
- {
907
- imp_drh_st* s_imp_drh;
908
- a_ads_connection* s_ads_conn;
909
- UNSIGNED32 result;
911
+ static_AdvantageInterface_ads_rollback( VALUE imp_drh, VALUE ads_conn )
912
+ {
913
+ imp_drh_st* s_imp_drh;
914
+ a_ads_connection* s_ads_conn;
915
+ UNSIGNED32 result;
910
916
 
911
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
912
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
917
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
918
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
913
919
 
914
- result = s_imp_drh->api.ads_rollback(s_ads_conn);
920
+ result = s_imp_drh->api.ads_rollback( s_ads_conn );
915
921
 
916
- return( INT2NUM(result) );
917
- }
922
+ return( INT2NUM( result ) );
923
+ }
918
924
 
919
925
  /*
920
926
  * call-seq:
921
- * ads_prepare(VALUE imp_drh, VALUE ads_conn, VALUE sql) -> VALUE stmt
927
+ * ads_prepare( VALUE imp_drh, VALUE ads_conn, VALUE sql ) -> VALUE stmt
922
928
  *
923
929
  * Prepares a SQL statement.
924
930
  *
925
931
  * This function prepares the supplied SQL string. Execution does not
926
- * happen until ads_execute() is called. The returned statement object
927
- * should be freed using ads_free_stmt().
932
+ * happen until ads_execute( ) is called. The returned statement object
933
+ * should be freed using ads_free_stmt( ).
928
934
  *
929
935
  *
930
936
  * <b>Parameters</b>:
931
937
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
932
- * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
938
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
933
939
  * - <tt>VALUE sql</tt> -- SQL query to prepare.
934
940
  *
935
941
  * <b>Returns</b>:
936
- * - <tt>VALUE stmt</tt>: A statement object, or nil on failure. The statement object can be used by ads_execute() to execute the statement.
942
+ * - <tt>VALUE stmt</tt>: A statement object, or nil on failure. The statement object can be used by ads_execute( ) to execute the statement.
937
943
  *
938
944
  */
939
945
  static VALUE
940
- static_AdvantageInterface_ads_prepare(VALUE imp_drh, VALUE ads_conn, VALUE sql)
941
- {
942
- imp_drh_st* s_imp_drh;
943
- a_ads_connection* s_ads_conn;
944
- ADSHANDLE s_stmt = 0;
945
- char* s_sql;
946
- int result;
947
- VALUE tdata;
946
+ static_AdvantageInterface_ads_prepare( VALUE imp_drh, VALUE ads_conn, VALUE sql )
947
+ {
948
+ imp_drh_st* s_imp_drh;
949
+ a_ads_connection* s_ads_conn;
950
+ ADSHANDLE s_stmt = 0;
951
+ char* s_sql;
952
+ VALUE tdata;
948
953
 
949
- s_sql = StringValueCStr( sql );
954
+ s_sql = StringValueCStr( sql );
950
955
 
951
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
952
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
956
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
957
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
953
958
 
954
- //EJS Passing FALSE for isUnicode
955
- s_stmt = s_imp_drh->api.ads_prepare(s_ads_conn, s_sql, '\0');
959
+ //EJS Passing FALSE for isUnicode
960
+ s_stmt = s_imp_drh->api.ads_prepare( s_ads_conn, ( UNSIGNED8* )s_sql, '\0' );
956
961
 
957
- if (s_stmt)
958
- {
959
- tdata = INT2NUM( s_stmt );
960
- }
961
- else
962
- {
963
- tdata = Qnil;
964
- }
962
+ if( s_stmt )
963
+ {
964
+ tdata = INT2NUM( s_stmt );
965
+ }
966
+ else
967
+ {
968
+ tdata = Qnil;
969
+ }
965
970
 
966
- return (tdata);
967
- }
971
+ return( tdata );
972
+ }
968
973
 
969
974
  /*
970
975
  * call-seq:
971
- * ads_free_stmt(VALUE imp_drh, VALUE ads_stmt) -> nil
976
+ * ads_free_stmt( VALUE imp_drh, VALUE ads_stmt ) -> nil
972
977
  *
973
978
  * Frees resources associated with a prepared statement object.
974
979
  *
@@ -977,116 +982,134 @@ static_AdvantageInterface_ads_prepare(VALUE imp_drh, VALUE ads_conn, VALUE sql)
977
982
  *
978
983
  * <b>Parameters</b>:
979
984
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
980
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
985
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
981
986
  *
982
987
  * <b>Returns</b>:
983
988
  * - <tt>nil</tt>.
984
989
  *
985
990
  */
986
991
  static VALUE
987
- static_AdvantageInterface_ads_free_stmt(VALUE imp_drh, VALUE ads_stmt)
988
- {
989
- imp_drh_st* s_imp_drh;
990
- ADSHANDLE s_stmt;
991
- int i;
992
- int number_of_params = 0;
993
- a_ads_bind_param_info bind_info;
992
+ static_AdvantageInterface_ads_free_stmt( VALUE imp_drh, VALUE ads_stmt )
993
+ {
994
+ imp_drh_st* s_imp_drh;
995
+ ADSHANDLE s_stmt;
996
+ int i;
997
+ int number_of_params = 0;
998
+ a_ads_bind_param_info bind_info;
994
999
 
995
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
996
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
997
- s_stmt = NUM2ULONG(ads_stmt);
1000
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1001
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
1002
+ s_stmt = NUM2ULONG( ads_stmt );
998
1003
 
999
- number_of_params = s_imp_drh->api.ads_num_params(s_stmt);
1004
+ number_of_params = s_imp_drh->api.ads_num_params( s_stmt );
1000
1005
 
1001
- for (i = 0; i < number_of_params; i++)
1002
- {
1003
- if( s_imp_drh->api.ads_get_bind_param_info(s_stmt, i, &bind_info) )
1004
- {
1005
- // We don't free bind_info.name as it's not allocated
1006
- // if (bind_info.name) {free (bind_info.name);}
1007
-
1008
- if (bind_info.input_value.is_null) {free(bind_info.input_value.is_null); }
1009
- if (bind_info.input_value.length) {free(bind_info.input_value.length); }
1010
- if (bind_info.input_value.buffer) {free(bind_info.input_value.buffer); }
1011
-
1012
- if (bind_info.output_value.is_null) {free(bind_info.output_value.is_null); }
1013
- if (bind_info.output_value.length) {free(bind_info.output_value.length); }
1014
- if (bind_info.output_value.buffer) {free(bind_info.output_value.buffer); }
1015
- }
1016
- }
1006
+ for( i = 0; i < number_of_params; i++ )
1007
+ {
1008
+ if( s_imp_drh->api.ads_get_bind_param_info( s_stmt, i, &bind_info ) )
1009
+ {
1010
+ // We don't free bind_info.name as it's not allocated
1011
+ // if ( bind_info.name ) {free ( bind_info.name );}
1012
+
1013
+ if( bind_info.input_value.is_null )
1014
+ {
1015
+ free( bind_info.input_value.is_null );
1016
+ }
1017
+ if( bind_info.input_value.length )
1018
+ {
1019
+ free( bind_info.input_value.length );
1020
+ }
1021
+ if( bind_info.input_value.buffer )
1022
+ {
1023
+ free( bind_info.input_value.buffer );
1024
+ }
1025
+
1026
+ if( bind_info.output_value.is_null )
1027
+ {
1028
+ free( bind_info.output_value.is_null );
1029
+ }
1030
+ if( bind_info.output_value.length )
1031
+ {
1032
+ free( bind_info.output_value.length );
1033
+ }
1034
+ if( bind_info.output_value.buffer )
1035
+ {
1036
+ free( bind_info.output_value.buffer );
1037
+ }
1038
+ }
1039
+ }
1017
1040
 
1018
- s_imp_drh->api.ads_free_stmt(s_stmt);
1041
+ s_imp_drh->api.ads_free_stmt( s_stmt );
1019
1042
 
1020
- return ( Qnil );
1021
- }
1043
+ return( Qnil );
1044
+ }
1022
1045
 
1023
1046
  /*
1024
1047
  * call-seq:
1025
- * ads_reset(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
1048
+ * ads_reset( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
1026
1049
  *
1027
1050
  *
1028
1051
  * <b>Parameters</b>:
1029
1052
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1030
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
1053
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
1031
1054
  *
1032
1055
  * <b>Returns</b>:
1033
1056
  * - <tt>VALUE result</tt>: <tt>1</tt> on successful execution, <tt>0</tt> otherwise.
1034
1057
  *
1035
1058
  */
1036
1059
  static VALUE
1037
- static_AdvantageInterface_ads_reset(VALUE imp_drh, VALUE ads_stmt)
1038
- {
1039
- imp_drh_st* s_imp_drh;
1040
- ADSHANDLE s_stmt;
1041
- UNSIGNED32 result;
1060
+ static_AdvantageInterface_ads_reset( VALUE imp_drh, VALUE ads_stmt )
1061
+ {
1062
+ imp_drh_st* s_imp_drh;
1063
+ ADSHANDLE s_stmt;
1064
+ UNSIGNED32 result;
1042
1065
 
1043
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1044
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
1045
- s_stmt = NUM2ULONG(ads_stmt);
1066
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1067
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
1068
+ s_stmt = NUM2ULONG( ads_stmt );
1046
1069
 
1047
- result = s_imp_drh->api.ads_reset(s_stmt);
1070
+ result = s_imp_drh->api.ads_reset( s_stmt );
1048
1071
 
1049
- return (INT2NUM(result));
1050
- }
1072
+ return( INT2NUM( result ) );
1073
+ }
1051
1074
 
1052
1075
 
1053
1076
  /*
1054
1077
  * call-seq:
1055
- * ads_execute(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
1078
+ * ads_execute( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
1056
1079
  *
1057
1080
  * Executes a prepared statement.
1058
1081
  *
1059
1082
  * <b>Parameters</b>:
1060
1083
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1061
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare() or ads_execute_direct().
1084
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was created by ads_prepare( ) or ads_execute_direct( ).
1062
1085
  *
1063
1086
  * <b>Returns</b>:
1064
1087
  * - <tt>VALUE result</tt>: <tt>1</tt> on successful execution, <tt>0</tt> otherwise.
1065
1088
  *
1066
1089
  */
1067
1090
  static VALUE
1068
- static_AdvantageInterface_ads_execute(VALUE imp_drh, VALUE ads_stmt)
1069
- {
1070
- imp_drh_st* s_imp_drh;
1071
- ADSHANDLE s_stmt;
1072
- UNSIGNED32 result;
1073
-
1074
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1075
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
1076
- s_stmt = NUM2ULONG(ads_stmt);
1077
-
1078
- //printf( "CEXT s_ads_stmt: %d \n", s_stmt);
1079
- result = s_imp_drh->api.ads_execute(s_stmt);
1080
- /*if ( result != AE_SUCCESS )
1081
- return (0);
1082
- else
1083
- return (1);*/
1084
- return (INT2NUM(result));
1085
- }
1091
+ static_AdvantageInterface_ads_execute( VALUE imp_drh, VALUE ads_stmt )
1092
+ {
1093
+ imp_drh_st* s_imp_drh;
1094
+ ADSHANDLE s_stmt;
1095
+ UNSIGNED32 result;
1096
+
1097
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1098
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
1099
+ s_stmt = NUM2ULONG( ads_stmt );
1100
+
1101
+ //printf( "CEXT s_ads_stmt: %d \n", s_stmt );
1102
+ result = s_imp_drh->api.ads_execute( s_stmt );
1103
+ /*if ( result != AE_SUCCESS )
1104
+ return ( 0 );
1105
+ else
1106
+ return ( 1 );*/
1107
+ return( INT2NUM( result ) );
1108
+ }
1086
1109
 
1087
1110
  /*
1088
1111
  * call-seq:
1089
- * ads_affected_rows(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
1112
+ * ads_affected_rows( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
1090
1113
  *
1091
1114
  * Returns the number of rows affected by execution of the prepared
1092
1115
  * statement.
@@ -1100,37 +1123,37 @@ static_AdvantageInterface_ads_execute(VALUE imp_drh, VALUE ads_stmt)
1100
1123
  *
1101
1124
  */
1102
1125
  static VALUE
1103
- static_AdvantageInterface_ads_affected_rows(VALUE imp_drh, VALUE ads_stmt)
1104
- {
1105
- imp_drh_st* s_imp_drh;
1106
- ADSHANDLE s_stmt;
1107
- UNSIGNED32 result;
1126
+ static_AdvantageInterface_ads_affected_rows( VALUE imp_drh, VALUE ads_stmt )
1127
+ {
1128
+ imp_drh_st* s_imp_drh;
1129
+ ADSHANDLE s_stmt;
1130
+ UNSIGNED32 result;
1108
1131
 
1109
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1110
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
1111
- s_stmt = NUM2ULONG(ads_stmt);
1132
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1133
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
1134
+ s_stmt = NUM2ULONG( ads_stmt );
1112
1135
 
1113
- result = s_imp_drh->api.ads_affected_rows(s_stmt);
1136
+ result = s_imp_drh->api.ads_affected_rows( s_stmt );
1114
1137
 
1115
- return ( INT2NUM(result) );
1116
- }
1138
+ return( INT2NUM( result ) );
1139
+ }
1117
1140
 
1118
1141
  /*
1119
1142
  * call-seq:
1120
- * ads_describe_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index) -> [VALUE result, VALUE bind_param]
1143
+ * ads_describe_bind_param( VALUE imp_drh, VALUE ads_stmt, VALUE index ) -> [VALUE result, VALUE bind_param]
1121
1144
  *
1122
1145
  * Describes the bind parameters of a prepared statement.
1123
1146
  *
1124
1147
  * This function allows the caller to determine information about parameters
1125
1148
  * to a prepared statement. Depending on the type of the prepared statement
1126
- * (call to stored procedure or a DML), only some information will be
1149
+ * ( call to stored procedure or a DML ), only some information will be
1127
1150
  * provided. The information that will always be provided is the direction
1128
- * of the parameters (input, output, or input-output).
1151
+ * of the parameters ( input, output, or input-output ).
1129
1152
  *
1130
1153
  * <b>Parameters</b>:
1131
1154
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1132
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
1133
- * - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params()- 1.
1155
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare( ).
1156
+ * - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params( )- 1.
1134
1157
  *
1135
1158
  * <b>Returns</b>:
1136
1159
  * - <tt>VALUE result</tt>: <tt>1</tt> on success or <tt>0</tt> on failure.
@@ -1138,86 +1161,86 @@ static_AdvantageInterface_ads_affected_rows(VALUE imp_drh, VALUE ads_stmt)
1138
1161
  *
1139
1162
  */
1140
1163
  static VALUE
1141
- static_AdvantageInterface_ads_describe_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index)
1142
- {
1143
- imp_drh_st* s_imp_drh;
1144
- ADSHANDLE s_stmt;
1145
- a_ads_bind_param* s_ads_bind_param;
1146
- UNSIGNED32 result;
1147
- UNSIGNED32 s_index;
1148
- VALUE tdata;
1149
- VALUE multi_result;
1164
+ static_AdvantageInterface_ads_describe_bind_param( VALUE imp_drh, VALUE ads_stmt, VALUE index )
1165
+ {
1166
+ imp_drh_st* s_imp_drh;
1167
+ ADSHANDLE s_stmt;
1168
+ a_ads_bind_param* s_ads_bind_param;
1169
+ UNSIGNED32 result;
1170
+ UNSIGNED32 s_index;
1171
+ VALUE tdata;
1172
+ VALUE multi_result;
1150
1173
 
1151
- s_ads_bind_param = malloc(sizeof(a_ads_bind_param));
1152
- memset( s_ads_bind_param, 0, sizeof(a_ads_bind_param) );
1174
+ s_ads_bind_param = malloc( sizeof( a_ads_bind_param ) );
1175
+ memset( s_ads_bind_param, 0, sizeof( a_ads_bind_param ) );
1153
1176
 
1154
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1155
- s_stmt = NUM2ULONG(ads_stmt);
1156
- s_index = NUM2INT(index);
1177
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1178
+ s_stmt = NUM2ULONG( ads_stmt );
1179
+ s_index = NUM2INT( index );
1157
1180
 
1158
- result = s_imp_drh->api.ads_describe_bind_param(s_stmt, s_index, s_ads_bind_param);
1181
+ result = s_imp_drh->api.ads_describe_bind_param( s_stmt, s_index, s_ads_bind_param );
1159
1182
 
1160
- //FIXME handle failed result
1183
+ //FIXME handle failed result
1161
1184
 
1162
- multi_result = rb_ary_new();
1185
+ multi_result = rb_ary_new( );
1163
1186
 
1164
- rb_ary_push(multi_result, INT2NUM(result));
1187
+ rb_ary_push( multi_result, INT2NUM( result ) );
1165
1188
 
1166
- tdata = Data_Wrap_Struct(cA_ads_bind_param, 0, 0, s_ads_bind_param);
1167
- rb_ary_push(multi_result, tdata);
1189
+ tdata = Data_Wrap_Struct( cA_ads_bind_param, 0, 0, s_ads_bind_param );
1190
+ rb_ary_push( multi_result, tdata );
1168
1191
 
1169
- return( multi_result );
1170
- }
1192
+ return( multi_result );
1193
+ }
1171
1194
 
1172
1195
  /*
1173
1196
  * call-seq:
1174
- * ads_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index, VALUE ads_bind_param) -> VALUE result
1197
+ * ads_bind_param( VALUE imp_drh, VALUE ads_stmt, VALUE index, VALUE ads_bind_param ) -> VALUE result
1175
1198
  *
1176
1199
  * Binds a user supplied buffer as a parameter to the prepared statement.
1177
1200
  *
1178
1201
  * <b>Parameters</b>:
1179
1202
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1180
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
1181
- * - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params() - 1.
1182
- * - <tt>VALUE ads_bind_param</tt> -- A filled bind object retrieved from ads_describe_bind_param().
1203
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare( ).
1204
+ * - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params( ) - 1.
1205
+ * - <tt>VALUE ads_bind_param</tt> -- A filled bind object retrieved from ads_describe_bind_param( ).
1183
1206
  *
1184
1207
  * <b>Returns</b>:
1185
1208
  * - <tt>VALUE result</tt>: <tt>1</tt> on success or <tt>0</tt> on failure.
1186
1209
  *
1187
1210
  */
1188
1211
  static VALUE
1189
- static_AdvantageInterface_ads_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE index, VALUE ads_bind_param )
1190
- {
1191
- imp_drh_st* s_imp_drh;
1192
- ADSHANDLE s_stmt;
1193
- a_ads_bind_param* s_ads_bind_param;
1194
- UNSIGNED32 result;
1195
- UNSIGNED32 s_index;
1212
+ static_AdvantageInterface_ads_bind_param( VALUE imp_drh, VALUE ads_stmt, VALUE index, VALUE ads_bind_param )
1213
+ {
1214
+ imp_drh_st* s_imp_drh;
1215
+ ADSHANDLE s_stmt;
1216
+ a_ads_bind_param* s_ads_bind_param;
1217
+ UNSIGNED32 result;
1218
+ UNSIGNED32 s_index;
1196
1219
 
1197
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1198
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
1199
- s_stmt = NUM2ULONG(ads_stmt);
1200
- Data_Get_Struct(ads_bind_param, a_ads_bind_param, s_ads_bind_param);
1201
- s_index = NUM2INT(index);
1220
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1221
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
1222
+ s_stmt = NUM2ULONG( ads_stmt );
1223
+ Data_Get_Struct( ads_bind_param, a_ads_bind_param, s_ads_bind_param );
1224
+ s_index = NUM2INT( index );
1202
1225
 
1203
- result = s_imp_drh->api.ads_bind_param(s_stmt, s_index, s_ads_bind_param);
1226
+ result = s_imp_drh->api.ads_bind_param( s_stmt, s_index, s_ads_bind_param );
1204
1227
 
1205
- return( INT2NUM(result) );
1206
- }
1228
+ return( INT2NUM( result ) );
1229
+ }
1207
1230
 
1208
1231
  /*
1209
1232
  * call-seq:
1210
- * ads_get_bind_param_info(VALUE imp_drh, VALUE ads_stmt, VALUE index) -> [VALUE result, VALUE bind_param]
1233
+ * ads_get_bind_param_info( VALUE imp_drh, VALUE ads_stmt, VALUE index ) -> [VALUE result, VALUE bind_param]
1211
1234
  *
1212
1235
  * Gets bound parameter info.
1213
1236
  *
1214
1237
  * This function retrieves information about the parameters that were
1215
- * bound using ads_bind_param().
1238
+ * bound using ads_bind_param( ).
1216
1239
  *
1217
1240
  * <b>Parameters</b>:
1218
1241
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1219
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
1220
- * - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params() - 1.
1242
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare( ).
1243
+ * - <tt>VALUE index</tt> -- The index of the parameter. This should be a number between 0 and ads_num_params( ) - 1.
1221
1244
  *
1222
1245
  * <b>Returns</b>:
1223
1246
  * - <tt>VALUE result</tt>: <tt>1</tt> on success or <tt>0</tt> on failure.
@@ -1225,105 +1248,105 @@ static_AdvantageInterface_ads_bind_param(VALUE imp_drh, VALUE ads_stmt, VALUE in
1225
1248
  *
1226
1249
  */
1227
1250
  static VALUE
1228
- static_AdvantageInterface_ads_get_bind_param_info(VALUE imp_drh, VALUE ads_stmt, VALUE index)
1229
- {
1230
- imp_drh_st* s_imp_drh;
1231
- ADSHANDLE s_stmt;
1232
- a_ads_bind_param_info s_ads_bind_param_info;
1233
- UNSIGNED32 result;
1234
- UNSIGNED32 s_index;
1235
- VALUE tdata;
1236
- VALUE multi_result;
1251
+ static_AdvantageInterface_ads_get_bind_param_info( VALUE imp_drh, VALUE ads_stmt, VALUE index )
1252
+ {
1253
+ imp_drh_st* s_imp_drh;
1254
+ ADSHANDLE s_stmt;
1255
+ a_ads_bind_param_info s_ads_bind_param_info;
1256
+ UNSIGNED32 result;
1257
+ UNSIGNED32 s_index;
1258
+ VALUE tdata;
1259
+ VALUE multi_result;
1237
1260
 
1238
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1239
- s_stmt = NUM2ULONG(ads_stmt);
1240
- s_index = NUM2INT(index);
1261
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1262
+ s_stmt = NUM2ULONG( ads_stmt );
1263
+ s_index = NUM2INT( index );
1241
1264
 
1242
- result = s_imp_drh->api.ads_get_bind_param_info(s_stmt, s_index, &s_ads_bind_param_info);
1265
+ result = s_imp_drh->api.ads_get_bind_param_info( s_stmt, s_index, &s_ads_bind_param_info );
1243
1266
 
1244
- //FIXME handle failed result
1245
- multi_result = rb_ary_new();
1267
+ //FIXME handle failed result
1268
+ multi_result = rb_ary_new( );
1246
1269
 
1247
- rb_ary_push(multi_result, INT2NUM(result));
1270
+ rb_ary_push( multi_result, INT2NUM( result ) );
1248
1271
 
1249
- // FIXME: Is this safe to be on the stack?
1250
- tdata = Data_Wrap_Struct(cA_ads_bind_param_info, 0, 0, &s_ads_bind_param_info);
1251
- rb_ary_push(multi_result, tdata);
1272
+ // FIXME: Is this safe to be on the stack?
1273
+ tdata = Data_Wrap_Struct( cA_ads_bind_param_info, 0, 0, &s_ads_bind_param_info );
1274
+ rb_ary_push( multi_result, tdata );
1252
1275
 
1253
- return( multi_result );
1254
- }
1276
+ return( multi_result );
1277
+ }
1255
1278
 
1256
1279
  /*
1257
1280
  * call-seq:
1258
- * ads_num_params(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
1281
+ * ads_num_params( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
1259
1282
  *
1260
1283
  * Returns the number of parameters that are expected for a prepared
1261
1284
  * statement.
1262
1285
  *
1263
1286
  * This function retrieves information about the parameters that were bound
1264
- * using ads_bind_param().
1287
+ * using ads_bind_param( ).
1265
1288
  *
1266
1289
  * <b>Parameters</b>:
1267
1290
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1268
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare().
1291
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was returned from ads_prepare( ).
1269
1292
  *
1270
1293
  * <b>Returns</b>:
1271
1294
  * - <tt>VALUE result</tt>: The number of parameters that are expected. <tt>-1</tt> if the ads_stmt object is not valid.
1272
1295
  *
1273
1296
  */
1274
1297
  static VALUE
1275
- static_AdvantageInterface_ads_num_params(VALUE imp_drh, VALUE ads_stmt)
1276
- {
1277
- imp_drh_st* s_imp_drh;
1278
- ADSHANDLE s_stmt;
1279
- UNSIGNED32 result;
1298
+ static_AdvantageInterface_ads_num_params( VALUE imp_drh, VALUE ads_stmt )
1299
+ {
1300
+ imp_drh_st* s_imp_drh;
1301
+ ADSHANDLE s_stmt;
1302
+ UNSIGNED32 result;
1280
1303
 
1281
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1282
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
1283
- s_stmt = NUM2ULONG(ads_stmt);
1304
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1305
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
1306
+ s_stmt = NUM2ULONG( ads_stmt );
1284
1307
 
1285
- result = s_imp_drh->api.ads_num_params(s_stmt);
1308
+ result = s_imp_drh->api.ads_num_params( s_stmt );
1286
1309
 
1287
- return( INT2NUM(result) );
1288
- }
1310
+ return( INT2NUM( result ) );
1311
+ }
1289
1312
 
1290
1313
  /*
1291
1314
  * call-seq:
1292
- * ads_get_next_result(VALUE imp_drh, VALUE ads_stmt) -> VALUE result
1315
+ * ads_get_next_result( VALUE imp_drh, VALUE ads_stmt ) -> VALUE result
1293
1316
  *
1294
1317
  * Advances to the next result set in a multiple result set query.
1295
1318
  *
1296
- * If a query (such as a call to a stored procedure) returns multiple result
1319
+ * If a query ( such as a call to a stored procedure ) returns multiple result
1297
1320
  * sets, then this function advances from the current result set to the next.
1298
1321
  *
1299
1322
  *
1300
1323
  * <b>Parameters</b>:
1301
1324
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1302
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was executed by ads_execute() or ads_execute_direct().
1325
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was executed by ads_execute( ) or ads_execute_direct( ).
1303
1326
  *
1304
1327
  * <b>Returns</b>:
1305
1328
  * - <tt>VALUE result</tt>: <tt>1</tt> if was successfully able to advance to the next result set, <tt>0</tt> otherwise.
1306
1329
  *
1307
1330
  */
1308
1331
  static VALUE
1309
- static_AdvantageInterface_ads_get_next_result(VALUE imp_drh, VALUE ads_stmt)
1310
- {
1311
- imp_drh_st* s_imp_drh;
1312
- ADSHANDLE s_stmt;
1313
- UNSIGNED32 result;
1332
+ static_AdvantageInterface_ads_get_next_result( VALUE imp_drh, VALUE ads_stmt )
1333
+ {
1334
+ imp_drh_st* s_imp_drh;
1335
+ ADSHANDLE s_stmt;
1336
+ UNSIGNED32 result;
1314
1337
 
1315
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1316
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
1317
- s_stmt = NUM2ULONG(ads_stmt);
1338
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1339
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
1340
+ s_stmt = NUM2ULONG( ads_stmt );
1318
1341
 
1319
- result = s_imp_drh->api.ads_get_next_result(s_stmt);
1342
+ result = s_imp_drh->api.ads_get_next_result( s_stmt );
1320
1343
 
1321
- return( INT2NUM(result) );
1322
- }
1344
+ return( INT2NUM( result ) );
1345
+ }
1323
1346
 
1324
1347
  /*
1325
1348
  * call-seq:
1326
- * ads_fetch_absolute(VALUE imp_drh, VALUE ads_stmt, VALUE offset) -> VALUE result
1349
+ * ads_fetch_absolute( VALUE imp_drh, VALUE ads_stmt, VALUE offset ) -> VALUE result
1327
1350
  *
1328
1351
  * Fetches data at a specific row number in the result set.
1329
1352
  *
@@ -1332,7 +1355,7 @@ static_AdvantageInterface_ads_get_next_result(VALUE imp_drh, VALUE ads_stmt)
1332
1355
  *
1333
1356
  * <b>Parameters</b>:
1334
1357
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1335
- * - <tt>VALUE ads_stmt</tt> -- A statement object that was executed by ads_execute() or ads_execute_direct().
1358
+ * - <tt>VALUE ads_stmt</tt> -- A statement object that was executed by ads_execute( ) or ads_execute_direct( ).
1336
1359
  * - <tt>VALUE offset</tt> -- The row number to be fetched. The first row is <tt>1</tt>, the last row is <tt>-1</tt>.
1337
1360
  *
1338
1361
  * <b>Returns</b>:
@@ -1340,108 +1363,107 @@ static_AdvantageInterface_ads_get_next_result(VALUE imp_drh, VALUE ads_stmt)
1340
1363
  *
1341
1364
  */
1342
1365
  static VALUE
1343
- static_AdvantageInterface_ads_fetch_absolute(VALUE imp_drh, VALUE ads_stmt, VALUE offset)
1344
- {
1345
- imp_drh_st* s_imp_drh;
1346
- ADSHANDLE s_stmt;
1347
- UNSIGNED32 s_offset;
1348
- UNSIGNED32 result;
1366
+ static_AdvantageInterface_ads_fetch_absolute( VALUE imp_drh, VALUE ads_stmt, VALUE offset )
1367
+ {
1368
+ imp_drh_st* s_imp_drh;
1369
+ ADSHANDLE s_stmt;
1370
+ UNSIGNED32 s_offset;
1371
+ UNSIGNED32 result;
1349
1372
 
1350
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1351
- //Data_Get_Struct(ads_stmt, ADSHANDLE, s_ads_stmt);
1352
- s_stmt = NUM2ULONG(ads_stmt);
1353
- s_offset = NUM2INT(offset);
1354
- result = s_imp_drh->api.ads_fetch_absolute(s_stmt, s_offset);
1373
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1374
+ //Data_Get_Struct( ads_stmt, ADSHANDLE, s_ads_stmt );
1375
+ s_stmt = NUM2ULONG( ads_stmt );
1376
+ s_offset = NUM2INT( offset );
1377
+ result = s_imp_drh->api.ads_fetch_absolute( s_stmt, s_offset );
1355
1378
 
1356
- return( INT2NUM(result) );
1357
- }
1379
+ return( INT2NUM( result ) );
1380
+ }
1358
1381
 
1359
1382
  /*
1360
1383
  * call-seq:
1361
- * ads_sqlstate(VALUE imp_drh, VALUE ads_conn) -> VALUE sqlstate_str
1384
+ * ads_sqlstate( VALUE imp_drh, VALUE ads_conn ) -> VALUE sqlstate_str
1362
1385
  *
1363
1386
  * Retrieves the current SQL state.
1364
1387
  *
1365
1388
  * <b>Parameters</b>:
1366
1389
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1367
- * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
1390
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
1368
1391
  *
1369
1392
  * <b>Returns</b>:
1370
1393
  * - <tt>VALUE sqlstate_str</tt>: The SQL State.
1371
1394
  *
1372
1395
  */
1373
1396
  static VALUE
1374
- static_AdvantageInterface_ads_sqlstate(VALUE imp_drh, VALUE ads_conn)
1375
- {
1376
- imp_drh_st* s_imp_drh;
1377
- a_ads_connection* s_ads_conn;
1378
- UNSIGNED32 result;
1379
- size_t s_size;
1380
- char s_buffer[255];
1397
+ static_AdvantageInterface_ads_sqlstate( VALUE imp_drh, VALUE ads_conn )
1398
+ {
1399
+ imp_drh_st* s_imp_drh;
1400
+ a_ads_connection* s_ads_conn;
1401
+ UNSIGNED32 result;
1402
+ char s_buffer[255];
1381
1403
 
1382
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1383
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
1404
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1405
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
1384
1406
 
1385
- result = s_imp_drh->api.ads_sqlstate(s_ads_conn, s_buffer, sizeof(s_buffer));
1407
+ result = s_imp_drh->api.ads_sqlstate( s_ads_conn, ( UNSIGNED8* )s_buffer, sizeof( s_buffer ) );
1386
1408
 
1387
- if ( result )
1388
- return( rb_str_new(s_buffer, strlen(s_buffer)));
1389
- else
1390
- return Qnil;
1391
- }
1409
+ if( result )
1410
+ return( rb_str_new( s_buffer, strlen( s_buffer ) ) );
1411
+ else
1412
+ return Qnil;
1413
+ }
1392
1414
 
1393
1415
  /*
1394
1416
  * call-seq:
1395
- * ads_clear_error(VALUE imp_drh, VALUE ads_conn) -> nil
1417
+ * ads_clear_error( VALUE imp_drh, VALUE ads_conn ) -> nil
1396
1418
  *
1397
1419
  * Clears the last stored error code.
1398
1420
  *
1399
1421
  * <b>Parameters</b>:
1400
1422
  * - <tt>VALUE imp_drh</tt> -- An initialized API structure to finalize.
1401
- * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect().
1423
+ * - <tt>VALUE ads_conn</tt> -- A connection object that was connected by ads_connect( ).
1402
1424
  *
1403
1425
  * <b>Returns</b>:
1404
1426
  * - <tt>nil</tt>:.
1405
1427
  *
1406
1428
  */
1407
1429
  static VALUE
1408
- static_AdvantageInterface_ads_clear_error(VALUE imp_drh, VALUE ads_conn)
1409
- {
1410
- imp_drh_st* s_imp_drh;
1411
- a_ads_connection* s_ads_conn;
1430
+ static_AdvantageInterface_ads_clear_error( VALUE imp_drh, VALUE ads_conn )
1431
+ {
1432
+ imp_drh_st* s_imp_drh;
1433
+ a_ads_connection* s_ads_conn;
1412
1434
 
1413
- Data_Get_Struct(imp_drh, imp_drh_st, s_imp_drh);
1414
- Data_Get_Struct(ads_conn, a_ads_connection, s_ads_conn);
1435
+ Data_Get_Struct( imp_drh, imp_drh_st, s_imp_drh );
1436
+ Data_Get_Struct( ads_conn, a_ads_connection, s_ads_conn );
1415
1437
 
1416
- s_imp_drh->api.ads_clear_error(s_ads_conn);
1438
+ s_imp_drh->api.ads_clear_error( s_ads_conn );
1417
1439
 
1418
- return( Qnil );
1419
- }
1440
+ return( Qnil );
1441
+ }
1420
1442
 
1421
1443
  /*
1422
1444
  * call-seq:
1423
- * get_name(VALUE bind) -> VALUE name
1445
+ * get_name( VALUE bind ) -> VALUE name
1424
1446
  *
1425
1447
  * Gets the name of the bound parameter.
1426
1448
  *
1427
1449
  * <b>Parameters</b>:
1428
- * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
1450
+ * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
1429
1451
  *
1430
1452
  * <b>Returns</b>:
1431
1453
  * - <tt>VALUE name</tt>: The bound variable's name.
1432
1454
  *
1433
1455
  */
1434
1456
  static VALUE
1435
- static_Bind_get_name(VALUE bind)
1436
- {
1437
- a_ads_bind_param* s_bind;
1438
- Data_Get_Struct(bind, a_ads_bind_param, s_bind);
1439
- return (rb_str_new2(s_bind->name));
1440
- }
1457
+ static_Bind_get_name( VALUE bind )
1458
+ {
1459
+ a_ads_bind_param* s_bind;
1460
+ Data_Get_Struct( bind, a_ads_bind_param, s_bind );
1461
+ return( rb_str_new2( ( char* )s_bind->name ) );
1462
+ }
1441
1463
 
1442
1464
  /*
1443
1465
  * call-seq:
1444
- * set_value(VALUE bind, VALUE val) -> nil
1466
+ * set_value( VALUE bind, VALUE val ) -> nil
1445
1467
  *
1446
1468
  * Sets the value of a bind parameter.
1447
1469
  *
@@ -1467,124 +1489,143 @@ static_Bind_get_name(VALUE bind)
1467
1489
  * method twice, once to bind the INPUT, and once to bind the OUTPUT.
1468
1490
  *
1469
1491
  * <b>Parameters</b>:
1470
- * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
1492
+ * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
1471
1493
  * - <tt>VALUE val</tt> -- The value to bind into the bound variable.
1472
1494
  *
1473
1495
  * <b>Returns</b>:
1474
1496
  * - <tt>nil</tt>.
1475
1497
  */
1476
1498
  static VALUE
1477
- static_Bind_set_value(VALUE bind, VALUE val)
1478
- {
1479
- a_ads_bind_param* s_bind;
1480
- int length;
1481
-
1482
- Data_Get_Struct(bind, a_ads_bind_param, s_bind);
1483
-
1484
- // FIXME: use Ruby's allocation routines?
1485
- s_bind->value.is_null = malloc(sizeof(UNSIGNED32));
1486
- *s_bind->value.is_null = 0;
1487
-
1488
- if (s_bind->direction == DD_INPUT)
1489
- {
1490
- switch(TYPE(val))
1491
- {
1492
- case T_STRING:
1493
- s_bind->value.length = malloc(sizeof(size_t));
1494
- length = RSTRING_LEN(val);
1495
- *s_bind->value.length = length;
1496
- s_bind->value.buffer = malloc(length);
1497
- memcpy(s_bind->value.buffer, RSTRING_PTR(val), length);
1498
- s_bind->value.type = A_STRING;
1499
- break;
1500
- case T_FIXNUM:
1501
- if(sizeof(void*) == 4){ //32-bit
1502
- s_bind->value.length = malloc(sizeof(size_t));
1503
- s_bind->value.buffer = malloc(sizeof(int));
1504
- *((int*)s_bind->value.buffer) = FIX2INT(val);
1505
- s_bind->value.type = A_VAL32;
1506
- length = 1;
1507
- *s_bind->value.length = length;
1508
- }else{ //64-bit
1509
- s_bind->value.length = malloc(sizeof(size_t));
1510
- s_bind->value.buffer = malloc(sizeof(long));
1511
- *((long*)s_bind->value.buffer) = FIX2LONG(val);
1499
+ static_Bind_set_value( VALUE bind, VALUE val )
1500
+ {
1501
+ a_ads_bind_param* s_bind;
1502
+ int length;
1503
+
1504
+ Data_Get_Struct( bind, a_ads_bind_param, s_bind );
1505
+
1506
+ // FIXME: use Ruby's allocation routines?
1507
+ s_bind->value.is_null = malloc( sizeof( UNSIGNED32 ) );
1508
+ *s_bind->value.is_null = 0;
1509
+
1510
+ if( s_bind->direction == DD_INPUT )
1511
+ {
1512
+ switch( TYPE( val ) )
1513
+ {
1514
+ case T_STRING:
1515
+ s_bind->value.length = malloc( sizeof( size_t ) );
1516
+ length = RSTRING_LEN( val );
1517
+ *s_bind->value.length = length;
1518
+ s_bind->value.buffer = malloc( length );
1519
+ memcpy( s_bind->value.buffer, RSTRING_PTR( val ), length );
1520
+ s_bind->value.type = A_STRING;
1521
+ break;
1522
+ case T_FIXNUM:
1523
+ if( sizeof( void* ) == 4 ) //32-bit
1524
+ {
1525
+ s_bind->value.length = malloc( sizeof( size_t ) );
1526
+ s_bind->value.buffer = malloc( sizeof( int ) );
1527
+ *( ( int* )s_bind->value.buffer ) = FIX2INT( val );
1528
+ s_bind->value.type = A_VAL32;
1529
+ length = 1;
1530
+ *s_bind->value.length = length;
1531
+ }
1532
+ else //64-bit
1533
+ {
1534
+ s_bind->value.length = malloc( sizeof( size_t ) );
1535
+ s_bind->value.buffer = malloc( sizeof( long ) );
1536
+ *( ( long* )s_bind->value.buffer ) = FIX2LONG( val );
1537
+ s_bind->value.type = A_VAL64;
1538
+ length = 1;
1539
+ *s_bind->value.length = length;
1540
+ }
1541
+ break;
1542
+ case T_BIGNUM:
1543
+ s_bind->value.length = malloc( sizeof( size_t ) );
1544
+ s_bind->value.buffer = malloc( sizeof( LONG_LONG ) );
1545
+ *( ( LONG_LONG* )s_bind->value.buffer ) = rb_num2ll( val );
1512
1546
  s_bind->value.type = A_VAL64;
1513
1547
  length = 1;
1514
1548
  *s_bind->value.length = length;
1515
- }
1516
- break;
1517
- case T_BIGNUM:
1518
- s_bind->value.length = malloc(sizeof(size_t));
1519
- s_bind->value.buffer = malloc(sizeof(LONG_LONG));
1520
- *((LONG_LONG*)s_bind->value.buffer) = rb_num2ll(val);
1521
- s_bind->value.type = A_VAL64;
1522
- length = 1;
1523
- *s_bind->value.length = length;
1524
- break;
1525
- case T_FLOAT:
1526
- s_bind->value.length = malloc(sizeof(size_t));
1527
- s_bind->value.buffer = malloc(sizeof(double));
1528
- *((double*)s_bind->value.buffer) = NUM2DBL(val);
1529
- s_bind->value.type = A_DOUBLE;
1530
- length = 1;
1531
- *s_bind->value.length = length;
1532
- break;
1533
- case T_NIL:
1534
- s_bind->value.length = malloc(sizeof(size_t));
1535
- *s_bind->value.is_null = 1;
1536
- s_bind->value.buffer = malloc(sizeof(int));
1537
- s_bind->value.type = A_VAL32;
1538
- length = 1;
1539
- *s_bind->value.length = length;
1540
- break;
1541
- default:
1542
- rb_raise(rb_eTypeError, "Cannot convert type. Must be STRING, FIXNUM, BIGNUM, FLOAT, or NIL");
1543
- break;
1544
- }
1545
- }
1546
- else
1547
- {
1548
- switch (s_bind->value.type)
1549
+ break;
1550
+ case T_FLOAT:
1551
+ s_bind->value.length = malloc( sizeof( size_t ) );
1552
+ s_bind->value.buffer = malloc( sizeof( double ) );
1553
+ *( ( double* )s_bind->value.buffer ) = NUM2DBL( val );
1554
+ s_bind->value.type = A_DOUBLE;
1555
+ length = 1;
1556
+ *s_bind->value.length = length;
1557
+ break;
1558
+ case T_FALSE:
1559
+ s_bind->value.length = malloc( sizeof( size_t ) );
1560
+ s_bind->value.buffer = malloc( sizeof( short ) );
1561
+ *( ( int* )s_bind->value.buffer ) = ADS_FALSE;
1562
+ s_bind->value.type = A_UVAL16;
1563
+ length = 1;
1564
+ *s_bind->value.length = length;
1565
+ break;
1566
+ case T_TRUE:
1567
+ s_bind->value.length = malloc( sizeof( size_t ) );
1568
+ s_bind->value.buffer = malloc( sizeof( short ) );
1569
+ *( ( int* )s_bind->value.buffer ) = ADS_TRUE;
1570
+ s_bind->value.type = A_UVAL16;
1571
+ length = 1;
1572
+ *s_bind->value.length = length;
1573
+ break;
1574
+ case T_NIL:
1575
+ s_bind->value.length = malloc( sizeof( size_t ) );
1576
+ *s_bind->value.is_null = 1;
1577
+ s_bind->value.buffer = malloc( sizeof( int ) );
1578
+ s_bind->value.type = A_VAL32;
1579
+ length = 1;
1580
+ *s_bind->value.length = length;
1581
+ break;
1582
+ default:
1583
+ rb_raise( rb_eTypeError, "Cannot convert type. Must be STRING, FIXNUM, BIGNUM, FLOAT, or NIL" );
1584
+ break;
1585
+ }
1586
+ }
1587
+ else
1549
1588
  {
1550
- case A_STRING:
1551
- s_bind->value.buffer = malloc(s_bind->value.buffer_size);
1552
- break;
1553
- case A_DOUBLE:
1554
- s_bind->value.buffer = malloc(sizeof(float));
1555
- break;
1556
- case A_VAL64:
1557
- case A_UVAL64:
1558
- s_bind->value.buffer = malloc(sizeof(LONG_LONG));
1559
- break;
1589
+ switch( s_bind->value.type )
1590
+ {
1591
+ case A_STRING:
1592
+ s_bind->value.buffer = malloc( s_bind->value.buffer_size );
1593
+ break;
1594
+ case A_DOUBLE:
1595
+ s_bind->value.buffer = malloc( sizeof( float ) );
1596
+ break;
1597
+ case A_VAL64:
1598
+ case A_UVAL64:
1599
+ s_bind->value.buffer = malloc( sizeof( LONG_LONG ) );
1600
+ break;
1560
1601
  case A_VAL32:
1561
1602
  case A_UVAL32:
1562
- s_bind->value.buffer = malloc(sizeof(int));
1563
- break;
1564
- case A_VAL16:
1565
- case A_UVAL16:
1566
- s_bind->value.buffer = malloc(sizeof(short));
1567
- break;
1568
- case A_VAL8:
1569
- case A_UVAL8:
1570
- s_bind->value.buffer = malloc(sizeof(char));
1571
- break;
1572
- default:
1573
- rb_raise(rb_eTypeError, "Type unknown");
1574
- break;
1603
+ s_bind->value.buffer = malloc( sizeof( int ) );
1604
+ break;
1605
+ case A_VAL16:
1606
+ case A_UVAL16:
1607
+ s_bind->value.buffer = malloc( sizeof( short ) );
1608
+ break;
1609
+ case A_VAL8:
1610
+ case A_UVAL8:
1611
+ s_bind->value.buffer = malloc( sizeof( char ) );
1612
+ break;
1613
+ default:
1614
+ rb_raise( rb_eTypeError, "Type unknown" );
1615
+ break;
1616
+ }
1575
1617
  }
1576
- }
1577
- return (Qnil);
1578
- }
1618
+ return( Qnil );
1619
+ }
1579
1620
 
1580
1621
  /*
1581
1622
  * call-seq:
1582
- * set_direction(VALUE bind, VALUE direction) -> nil
1623
+ * set_direction( VALUE bind, VALUE direction ) -> nil
1583
1624
  *
1584
1625
  * Sets the direction of the bound parameter before binding.
1585
1626
  *
1586
1627
  * <b>Parameters</b>:
1587
- * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
1628
+ * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
1588
1629
  * - <tt>VALUE direction</tt> -- The direction of the binding variable.
1589
1630
  *
1590
1631
  * <b>Returns</b>:
@@ -1592,26 +1633,26 @@ static_Bind_set_value(VALUE bind, VALUE val)
1592
1633
  *
1593
1634
  */
1594
1635
  static VALUE
1595
- static_Bind_set_direction(VALUE bind, VALUE direction)
1596
- {
1597
- a_ads_bind_param* s_bind;
1636
+ static_Bind_set_direction( VALUE bind, VALUE direction )
1637
+ {
1638
+ a_ads_bind_param* s_bind;
1598
1639
 
1599
- Data_Get_Struct(bind, a_ads_bind_param, s_bind);
1640
+ Data_Get_Struct( bind, a_ads_bind_param, s_bind );
1600
1641
 
1601
- s_bind->direction = NUM2CHR(direction);
1642
+ s_bind->direction = NUM2CHR( direction );
1602
1643
 
1603
- return (Qnil);
1604
- }
1644
+ return( Qnil );
1645
+ }
1605
1646
 
1606
1647
  /*
1607
1648
  * call-seq:
1608
- * set_buffer_size(VALUE bind, VALUE size) -> nil
1649
+ * set_buffer_size( VALUE bind, VALUE size ) -> nil
1609
1650
  *
1610
1651
  * Sets the buffer size of INOUT and OUT parameters for string and binary
1611
1652
  * data.
1612
1653
  *
1613
1654
  * <b>Parameters</b>:
1614
- * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
1655
+ * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
1615
1656
  * - <tt>VALUE size</tt> -- The size of the buffer to hold the INOUT or OUT parameter.
1616
1657
  *
1617
1658
  * <b>Returns</b>:
@@ -1619,182 +1660,185 @@ static_Bind_set_direction(VALUE bind, VALUE direction)
1619
1660
  *
1620
1661
  */
1621
1662
  static VALUE
1622
- static_Bind_set_buffer_size(VALUE bind, VALUE size)
1623
- {
1624
- a_ads_bind_param* s_bind;
1663
+ static_Bind_set_buffer_size( VALUE bind, VALUE size )
1664
+ {
1665
+ a_ads_bind_param* s_bind;
1625
1666
 
1626
- Data_Get_Struct(bind, a_ads_bind_param, s_bind);
1667
+ Data_Get_Struct( bind, a_ads_bind_param, s_bind );
1627
1668
 
1628
- s_bind->value.buffer_size = NUM2INT(size);
1669
+ s_bind->value.buffer_size = NUM2INT( size );
1629
1670
 
1630
- return (Qnil);
1631
- }
1671
+ return( Qnil );
1672
+ }
1632
1673
 
1633
1674
  /*
1634
1675
  * call-seq:
1635
- * get_direction(VALUE bind) -> VALUE direction
1676
+ * get_direction( VALUE bind ) -> VALUE direction
1636
1677
  *
1637
1678
  * Gets the direction of the bound parameter.
1638
1679
  *
1639
1680
  * <b>Parameters</b>:
1640
- * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
1681
+ * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
1641
1682
  *
1642
1683
  * <b>Returns</b>:
1643
1684
  * - <tt>VALUE name</tt>: The direction of the bound parameter.
1644
1685
  *
1645
1686
  */
1646
1687
  static VALUE
1647
- static_Bind_get_direction(VALUE bind)
1648
- {
1649
- a_ads_bind_param* s_bind;
1650
- Data_Get_Struct(bind, a_ads_bind_param, s_bind);
1688
+ static_Bind_get_direction( VALUE bind )
1689
+ {
1690
+ a_ads_bind_param* s_bind;
1691
+ Data_Get_Struct( bind, a_ads_bind_param, s_bind );
1651
1692
 
1652
- return (CHR2FIX(s_bind->direction));
1653
- }
1693
+ return( CHR2FIX( s_bind->direction ) );
1694
+ }
1654
1695
 
1655
1696
  /*
1656
1697
  * call-seq:
1657
- * finish(VALUE bind) -> nil
1698
+ * finish( VALUE bind ) -> nil
1658
1699
  *
1659
1700
  * Frees the resources associated with the bound parameter.
1660
1701
  *
1661
1702
  * <b>Parameters</b>:
1662
- * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
1703
+ * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
1663
1704
  *
1664
1705
  * <b>Returns</b>:
1665
1706
  * - <tt>nil</tt>.
1666
1707
  *
1667
1708
  */
1668
1709
  static VALUE
1669
- static_Bind_finish(VALUE bind)
1670
- {
1671
- a_ads_bind_param* s_bind;
1710
+ static_Bind_finish( VALUE bind )
1711
+ {
1712
+ a_ads_bind_param* s_bind;
1672
1713
 
1673
- Data_Get_Struct(bind, a_ads_bind_param, s_bind);
1714
+ Data_Get_Struct( bind, a_ads_bind_param, s_bind );
1674
1715
 
1675
- // FIXME: use Ruby's allocation routines?
1676
- if (s_bind) { free(s_bind);};
1716
+ // FIXME: use Ruby's allocation routines?
1717
+ if( s_bind )
1718
+ {
1719
+ free( s_bind );
1720
+ };
1677
1721
 
1678
- return (Qnil);
1679
- }
1722
+ return( Qnil );
1723
+ }
1680
1724
 
1681
1725
  /*
1682
1726
  * call-seq:
1683
- * get_info_direction(VALUE bind) -> VALUE direction
1727
+ * get_info_direction( VALUE bind ) -> VALUE direction
1684
1728
  *
1685
1729
  * Gets the name of the bound parameter info object.
1686
1730
  *
1687
1731
  * <b>Parameters</b>:
1688
- * - <tt>VALUE bind</tt> -- Bound parameter info retrieved from ads_describe_bind_param_info().
1732
+ * - <tt>VALUE bind</tt> -- Bound parameter info retrieved from ads_describe_bind_param_info( ).
1689
1733
  *
1690
1734
  * <b>Returns</b>:
1691
1735
  * - <tt>VALUE direction</tt>: The bound variable's direction.
1692
1736
  *
1693
1737
  */
1694
1738
  static VALUE
1695
- static_Bind_get_info_direction(VALUE bind)
1696
- {
1697
- a_ads_bind_param_info* s_bind;
1698
- Data_Get_Struct(bind, a_ads_bind_param_info, s_bind);
1739
+ static_Bind_get_info_direction( VALUE bind )
1740
+ {
1741
+ a_ads_bind_param_info* s_bind;
1742
+ Data_Get_Struct( bind, a_ads_bind_param_info, s_bind );
1699
1743
 
1700
- return (CHR2FIX(s_bind->direction));
1701
- }
1744
+ return( CHR2FIX( s_bind->direction ) );
1745
+ }
1702
1746
 
1703
1747
  /*
1704
1748
  * call-seq:
1705
- * get_info_output(VALUE bind) -> VALUE name
1749
+ * get_info_output( VALUE bind ) -> VALUE name
1706
1750
  *
1707
1751
  * Gets the value of a bound parameter after execution.
1708
1752
  *
1709
1753
  * <b>Parameters</b>:
1710
- * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param().
1754
+ * - <tt>VALUE bind</tt> -- Bound parameter retrieved from ads_describe_bind_param( ).
1711
1755
  *
1712
1756
  * <b>Returns</b>:
1713
1757
  * - <tt>VALUE name</tt>: The bound variable value.
1714
1758
  *
1715
1759
  */
1716
1760
  static VALUE
1717
- static_Bind_get_info_output(VALUE bind)
1718
- {
1719
- a_ads_bind_param_info* s_bind;
1720
- Data_Get_Struct(bind, a_ads_bind_param_info, s_bind);
1721
- return(C2RB(&s_bind->output_value));
1722
- }
1761
+ static_Bind_get_info_output( VALUE bind )
1762
+ {
1763
+ a_ads_bind_param_info* s_bind;
1764
+ Data_Get_Struct( bind, a_ads_bind_param_info, s_bind );
1765
+ return( C2RB( &s_bind->output_value ) );
1766
+ }
1723
1767
 
1724
1768
  /*
1725
1769
  *
1726
1770
  */
1727
- void Init_advantage()
1728
- {
1729
- // Define top leve 'Advantage' module
1730
- mAdvantage = rb_define_module( "Advantage" );
1731
-
1732
- // Define a sub-module name 'API' under Advantage.
1733
- // In Ruby, this is accessed as Advantage::API
1734
- mAPI = rb_define_module_under( mAdvantage, "API" );
1735
-
1736
- // Define ads interface functions
1737
- rb_define_module_function( mAPI, "ads_initialize_interface", static_API_ads_initialize_interface, 1 );
1738
- rb_define_module_function( mAPI, "ads_finalize_interface", static_API_ads_finalize_interface, 1 );
1739
- rb_define_const(mAPI, "VERSION", rb_str_new2(VERSION));
1740
-
1741
-
1742
- // Define interface classes under the Advantage module
1743
- cAdvantageInterface = rb_define_class_under( mAdvantage, "AdvantageInterface", rb_cObject);
1744
- rb_define_alloc_func(cAdvantageInterface, static_AdvantageInterface_alloc);
1745
-
1746
- // Define all of the DBCAPI functions as methods under an interface instance
1747
- rb_define_method(cAdvantageInterface, "ads_init", static_AdvantageInterface_ads_init, 0);
1748
- rb_define_method(cAdvantageInterface, "ads_new_connection", static_AdvantageInterface_ads_new_connection, 0);
1749
- rb_define_method(cAdvantageInterface, "ads_client_version", static_AdvantageInterface_ads_client_version, 0);
1750
- rb_define_method(cAdvantageInterface, "ads_connect", static_AdvantageInterface_ads_connect, 2);
1751
- rb_define_method(cAdvantageInterface, "ads_disconnect", static_AdvantageInterface_ads_disconnect, 1);
1752
- rb_define_method(cAdvantageInterface, "ads_free_connection", static_AdvantageInterface_ads_free_connection, 1);
1753
- rb_define_method(cAdvantageInterface, "ads_fini", static_AdvantageInterface_ads_fini, 0);
1754
- rb_define_method(cAdvantageInterface, "ads_error", static_AdvantageInterface_ads_error, 1);
1755
- rb_define_method(cAdvantageInterface, "ads_execute_immediate", static_AdvantageInterface_ads_execute_immediate, 2);
1756
- rb_define_method(cAdvantageInterface, "ads_execute_direct", static_AdvantageInterface_ads_execute_direct, 2);
1757
- rb_define_method(cAdvantageInterface, "ads_num_cols", static_AdvantageInterface_ads_num_cols, 1);
1758
- rb_define_method(cAdvantageInterface, "ads_num_rows", static_AdvantageInterface_ads_num_rows, 1);
1759
- rb_define_method(cAdvantageInterface, "ads_get_column", static_AdvantageInterface_ads_get_column, 2);
1760
- rb_define_method(cAdvantageInterface, "ads_fetch_next", static_AdvantageInterface_ads_fetch_next, 1);
1761
- rb_define_method(cAdvantageInterface, "ads_get_column_info", static_AdvantageInterface_ads_get_column_info, 2);
1762
- rb_define_method(cAdvantageInterface, "AdsBeginTransaction", static_AdvantageInterface_AdsBeginTransaction, 1);
1763
- rb_define_method(cAdvantageInterface, "ads_commit", static_AdvantageInterface_ads_commit, 1);
1764
- rb_define_method(cAdvantageInterface, "ads_rollback", static_AdvantageInterface_ads_rollback, 1);
1765
- rb_define_method(cAdvantageInterface, "ads_prepare", static_AdvantageInterface_ads_prepare, 2);
1766
- rb_define_method(cAdvantageInterface, "ads_free_stmt", static_AdvantageInterface_ads_free_stmt, 1);
1767
- rb_define_method(cAdvantageInterface, "ads_reset", static_AdvantageInterface_ads_reset, 1);
1768
- rb_define_method(cAdvantageInterface, "ads_execute", static_AdvantageInterface_ads_execute, 1);
1769
- rb_define_method(cAdvantageInterface, "ads_affected_rows", static_AdvantageInterface_ads_affected_rows, 1);
1770
- rb_define_method(cAdvantageInterface, "ads_describe_bind_param", static_AdvantageInterface_ads_describe_bind_param, 2);
1771
- rb_define_method(cAdvantageInterface, "ads_bind_param", static_AdvantageInterface_ads_bind_param, 3);
1772
- rb_define_method(cAdvantageInterface, "ads_get_bind_param_info", static_AdvantageInterface_ads_get_bind_param_info, 2);
1773
- rb_define_method(cAdvantageInterface, "ads_num_params", static_AdvantageInterface_ads_num_params, 1);
1774
- rb_define_method(cAdvantageInterface, "ads_get_next_result", static_AdvantageInterface_ads_get_next_result, 1);
1775
- rb_define_method(cAdvantageInterface, "ads_fetch_absolute", static_AdvantageInterface_ads_fetch_absolute, 2);
1776
- rb_define_method(cAdvantageInterface, "ads_sqlstate", static_AdvantageInterface_ads_sqlstate, 1);
1777
- rb_define_method(cAdvantageInterface, "ads_clear_error", static_AdvantageInterface_ads_clear_error, 1);
1778
-
1779
- // Define classes for accessing structures under Advantage module
1780
- cA_ads_connection = rb_define_class_under (mAdvantage, "a_ads_connection", rb_cObject);
1781
- cA_ads_data_value = rb_define_class_under (mAdvantage, "a_ads_data_value", rb_cObject);
1782
- //cA_ads_stmt = rb_define_class_under (mAdvantage, "ADSHANDLE", rb_cObject);
1783
- cA_ads_bind_param = rb_define_class_under (mAdvantage, "a_ads_bind_param", rb_cObject);
1784
- cA_ads_bind_param_info = rb_define_class_under (mAdvantage, "a_ads_bind_param_info", rb_cObject);
1785
-
1786
-
1787
- // Define methods for obtaining bind_parameter fields
1788
- rb_define_method(cA_ads_bind_param, "get_name", static_Bind_get_name, 0);
1789
- rb_define_method(cA_ads_bind_param, "set_value", static_Bind_set_value, 1);
1790
- rb_define_method(cA_ads_bind_param, "get_direction", static_Bind_get_direction, 0);
1791
- rb_define_method(cA_ads_bind_param, "set_direction", static_Bind_set_direction, 1);
1792
- rb_define_method(cA_ads_bind_param, "set_buffer_size", static_Bind_set_buffer_size, 1);
1793
- rb_define_method(cA_ads_bind_param, "finish", static_Bind_finish, 0);
1794
-
1795
- // Define methods for obtaining bind_parameter_info fields
1796
- rb_define_method(cA_ads_bind_param_info, "get_direction", static_Bind_get_info_direction, 0);
1797
- rb_define_method(cA_ads_bind_param_info, "get_output", static_Bind_get_info_output, 0);
1798
- }
1771
+ void Init_advantage( )
1772
+ {
1773
+ // Define top leve 'Advantage' module
1774
+ mAdvantage = rb_define_module( "Advantage" );
1775
+
1776
+ // Define a sub-module name 'API' under Advantage.
1777
+ // In Ruby, this is accessed as Advantage::API
1778
+ mAPI = rb_define_module_under( mAdvantage, "API" );
1779
+
1780
+ // Define ads interface functions
1781
+ rb_define_module_function( mAPI, "ads_initialize_interface", static_API_ads_initialize_interface, 1 );
1782
+ rb_define_module_function( mAPI, "ads_finalize_interface", static_API_ads_finalize_interface, 1 );
1783
+ rb_define_const( mAPI, "VERSION", rb_str_new2( VERSION ) );
1784
+
1785
+
1786
+ // Define interface classes under the Advantage module
1787
+ cAdvantageInterface = rb_define_class_under( mAdvantage, "AdvantageInterface", rb_cObject );
1788
+ rb_define_alloc_func( cAdvantageInterface, static_AdvantageInterface_alloc );
1789
+
1790
+ // Define all of the DBCAPI functions as methods under an interface instance
1791
+ rb_define_method( cAdvantageInterface, "ads_init", static_AdvantageInterface_ads_init, 0 );
1792
+ rb_define_method( cAdvantageInterface, "ads_new_connection", static_AdvantageInterface_ads_new_connection, 0 );
1793
+ rb_define_method( cAdvantageInterface, "ads_client_version", static_AdvantageInterface_ads_client_version, 0 );
1794
+ rb_define_method( cAdvantageInterface, "ads_connect", static_AdvantageInterface_ads_connect, 2 );
1795
+ rb_define_method( cAdvantageInterface, "ads_disconnect", static_AdvantageInterface_ads_disconnect, 1 );
1796
+ rb_define_method( cAdvantageInterface, "ads_free_connection", static_AdvantageInterface_ads_free_connection, 1 );
1797
+ rb_define_method( cAdvantageInterface, "ads_fini", static_AdvantageInterface_ads_fini, 0 );
1798
+ rb_define_method( cAdvantageInterface, "ads_error", static_AdvantageInterface_ads_error, 1 );
1799
+ rb_define_method( cAdvantageInterface, "ads_execute_immediate", static_AdvantageInterface_ads_execute_immediate, 2 );
1800
+ rb_define_method( cAdvantageInterface, "ads_execute_direct", static_AdvantageInterface_ads_execute_direct, 2 );
1801
+ rb_define_method( cAdvantageInterface, "ads_num_cols", static_AdvantageInterface_ads_num_cols, 1 );
1802
+ rb_define_method( cAdvantageInterface, "ads_num_rows", static_AdvantageInterface_ads_num_rows, 1 );
1803
+ rb_define_method( cAdvantageInterface, "ads_get_column", static_AdvantageInterface_ads_get_column, 2 );
1804
+ rb_define_method( cAdvantageInterface, "ads_fetch_next", static_AdvantageInterface_ads_fetch_next, 1 );
1805
+ rb_define_method( cAdvantageInterface, "ads_get_column_info", static_AdvantageInterface_ads_get_column_info, 2 );
1806
+ rb_define_method( cAdvantageInterface, "AdsBeginTransaction", static_AdvantageInterface_AdsBeginTransaction, 1 );
1807
+ rb_define_method( cAdvantageInterface, "ads_commit", static_AdvantageInterface_ads_commit, 1 );
1808
+ rb_define_method( cAdvantageInterface, "ads_rollback", static_AdvantageInterface_ads_rollback, 1 );
1809
+ rb_define_method( cAdvantageInterface, "ads_prepare", static_AdvantageInterface_ads_prepare, 2 );
1810
+ rb_define_method( cAdvantageInterface, "ads_free_stmt", static_AdvantageInterface_ads_free_stmt, 1 );
1811
+ rb_define_method( cAdvantageInterface, "ads_reset", static_AdvantageInterface_ads_reset, 1 );
1812
+ rb_define_method( cAdvantageInterface, "ads_execute", static_AdvantageInterface_ads_execute, 1 );
1813
+ rb_define_method( cAdvantageInterface, "ads_affected_rows", static_AdvantageInterface_ads_affected_rows, 1 );
1814
+ rb_define_method( cAdvantageInterface, "ads_describe_bind_param", static_AdvantageInterface_ads_describe_bind_param, 2 );
1815
+ rb_define_method( cAdvantageInterface, "ads_bind_param", static_AdvantageInterface_ads_bind_param, 3 );
1816
+ rb_define_method( cAdvantageInterface, "ads_get_bind_param_info", static_AdvantageInterface_ads_get_bind_param_info, 2 );
1817
+ rb_define_method( cAdvantageInterface, "ads_num_params", static_AdvantageInterface_ads_num_params, 1 );
1818
+ rb_define_method( cAdvantageInterface, "ads_get_next_result", static_AdvantageInterface_ads_get_next_result, 1 );
1819
+ rb_define_method( cAdvantageInterface, "ads_fetch_absolute", static_AdvantageInterface_ads_fetch_absolute, 2 );
1820
+ rb_define_method( cAdvantageInterface, "ads_sqlstate", static_AdvantageInterface_ads_sqlstate, 1 );
1821
+ rb_define_method( cAdvantageInterface, "ads_clear_error", static_AdvantageInterface_ads_clear_error, 1 );
1822
+
1823
+ // Define classes for accessing structures under Advantage module
1824
+ cA_ads_connection = rb_define_class_under ( mAdvantage, "a_ads_connection", rb_cObject );
1825
+ cA_ads_data_value = rb_define_class_under ( mAdvantage, "a_ads_data_value", rb_cObject );
1826
+ //cA_ads_stmt = rb_define_class_under ( mAdvantage, "ADSHANDLE", rb_cObject );
1827
+ cA_ads_bind_param = rb_define_class_under ( mAdvantage, "a_ads_bind_param", rb_cObject );
1828
+ cA_ads_bind_param_info = rb_define_class_under ( mAdvantage, "a_ads_bind_param_info", rb_cObject );
1829
+
1830
+
1831
+ // Define methods for obtaining bind_parameter fields
1832
+ rb_define_method( cA_ads_bind_param, "get_name", static_Bind_get_name, 0 );
1833
+ rb_define_method( cA_ads_bind_param, "set_value", static_Bind_set_value, 1 );
1834
+ rb_define_method( cA_ads_bind_param, "get_direction", static_Bind_get_direction, 0 );
1835
+ rb_define_method( cA_ads_bind_param, "set_direction", static_Bind_set_direction, 1 );
1836
+ rb_define_method( cA_ads_bind_param, "set_buffer_size", static_Bind_set_buffer_size, 1 );
1837
+ rb_define_method( cA_ads_bind_param, "finish", static_Bind_finish, 0 );
1838
+
1839
+ // Define methods for obtaining bind_parameter_info fields
1840
+ rb_define_method( cA_ads_bind_param_info, "get_direction", static_Bind_get_info_direction, 0 );
1841
+ rb_define_method( cA_ads_bind_param_info, "get_output", static_Bind_get_info_output, 0 );
1842
+ }
1799
1843
 
1800
1844