rubywmq 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/examples/put1_a.rb +25 -25
- data/examples/q_to_files.rb +48 -48
- data/ext/build.sh +0 -0
- data/ext/decode_rfh.c +348 -348
- data/ext/decode_rfh.h +45 -45
- data/ext/extconf.rb +44 -44
- data/ext/generate/generate_structs.rb +97 -97
- data/ext/generate/wmq_structs.erb +1 -18
- data/ext/wmq.c +93 -93
- data/ext/wmq.h +367 -350
- data/ext/wmq_message.c +671 -682
- data/ext/wmq_mq_load.c +217 -217
- data/ext/wmq_queue.c +1411 -1411
- data/ext/wmq_queue_manager.c +1570 -1581
- data/tests/test.rb +328 -300
- metadata +46 -47
data/ext/wmq.h
CHANGED
@@ -1,350 +1,367 @@
|
|
1
|
-
/* --------------------------------------------------------------------------
|
2
|
-
* Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
* you may not use this file except in compliance with the License.
|
6
|
-
* You may obtain a copy of the License at
|
7
|
-
*
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
*
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
* See the License for the specific language governing permissions and
|
14
|
-
* limitations under the License.
|
15
|
-
* --------------------------------------------------------------------------*/
|
16
|
-
|
17
|
-
#include <ruby.h>
|
18
|
-
|
19
|
-
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
#
|
24
|
-
#
|
25
|
-
|
26
|
-
#
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
VALUE
|
55
|
-
VALUE
|
56
|
-
VALUE
|
57
|
-
VALUE
|
58
|
-
VALUE
|
59
|
-
VALUE
|
60
|
-
VALUE
|
61
|
-
VALUE
|
62
|
-
VALUE
|
63
|
-
VALUE
|
64
|
-
VALUE
|
65
|
-
VALUE
|
66
|
-
VALUE
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
void(*
|
129
|
-
void(*
|
130
|
-
void(*
|
131
|
-
void(*
|
132
|
-
void(*
|
133
|
-
void(*
|
134
|
-
void(*
|
135
|
-
|
136
|
-
void(*
|
137
|
-
void(*
|
138
|
-
void(*
|
139
|
-
|
140
|
-
|
141
|
-
void
|
142
|
-
void
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
PMQLONG
|
151
|
-
MQLONG
|
152
|
-
PMQLONG
|
153
|
-
MQLONG
|
154
|
-
|
155
|
-
|
156
|
-
};
|
157
|
-
|
158
|
-
void
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
*
|
179
|
-
*
|
180
|
-
|
181
|
-
void
|
182
|
-
|
183
|
-
|
184
|
-
void
|
185
|
-
void
|
186
|
-
|
187
|
-
void
|
188
|
-
void
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
void
|
199
|
-
void
|
200
|
-
|
201
|
-
void
|
202
|
-
void
|
203
|
-
|
204
|
-
void
|
205
|
-
void
|
206
|
-
|
207
|
-
void
|
208
|
-
void
|
209
|
-
void
|
210
|
-
void
|
211
|
-
void
|
212
|
-
void
|
213
|
-
void
|
214
|
-
void
|
215
|
-
void
|
216
|
-
void
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
void
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
*
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
{
|
310
|
-
if
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
1
|
+
/* --------------------------------------------------------------------------
|
2
|
+
* Copyright 2006 J. Reid Morrison. Dimension Solutions, Inc.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
* --------------------------------------------------------------------------*/
|
16
|
+
|
17
|
+
#include <ruby.h>
|
18
|
+
|
19
|
+
/* New with Ruby 1.9, define for prior Ruby versions */
|
20
|
+
#ifndef RSTRING_PTR
|
21
|
+
#define RSTRING_PTR(str) RSTRING(str)->ptr
|
22
|
+
#endif
|
23
|
+
#ifndef RSTRING_LEN
|
24
|
+
#define RSTRING_LEN(str) RSTRING(str)->len
|
25
|
+
#endif
|
26
|
+
#ifndef RARRAY_PTR
|
27
|
+
#define RARRAY_PTR(ary) RARRAY(ary)->ptr
|
28
|
+
#endif
|
29
|
+
#ifndef RARRAY_LEN
|
30
|
+
#define RARRAY_LEN(ary) RARRAY(ary)->len
|
31
|
+
#endif
|
32
|
+
#ifndef HAVE_RB_STR_SET_LEN
|
33
|
+
#define rb_str_set_len(str, length) (RSTRING_LEN(str) = (length))
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#include <cmqc.h>
|
37
|
+
#include <cmqxc.h>
|
38
|
+
|
39
|
+
/* Todo: Add a #ifdef here to exclude the following includes when applicable */
|
40
|
+
#include <cmqcfc.h> /* PCF */
|
41
|
+
#include <cmqbc.h> /* MQAI */
|
42
|
+
|
43
|
+
#ifdef _WIN32
|
44
|
+
#define WMQ_EXPORT __declspec(dllexport)
|
45
|
+
#else
|
46
|
+
#define WMQ_EXPORT
|
47
|
+
#endif
|
48
|
+
|
49
|
+
void QueueManager_id_init();
|
50
|
+
void QueueManager_selector_id_init();
|
51
|
+
void QueueManager_command_id_init();
|
52
|
+
VALUE QUEUE_MANAGER_alloc(VALUE klass);
|
53
|
+
VALUE QueueManager_singleton_connect(int argc, VALUE *argv, VALUE self);
|
54
|
+
VALUE QueueManager_open_queue(int argc, VALUE *argv, VALUE self);
|
55
|
+
VALUE QueueManager_initialize(VALUE self, VALUE parms);
|
56
|
+
VALUE QueueManager_connect(VALUE self);
|
57
|
+
VALUE QueueManager_disconnect(VALUE self);
|
58
|
+
VALUE QueueManager_begin(VALUE self);
|
59
|
+
VALUE QueueManager_commit(VALUE self);
|
60
|
+
VALUE QueueManager_backout(VALUE self);
|
61
|
+
VALUE QueueManager_put(VALUE self, VALUE parms);
|
62
|
+
VALUE QueueManager_reason_code(VALUE self);
|
63
|
+
VALUE QueueManager_comp_code(VALUE self);
|
64
|
+
VALUE QueueManager_reason(VALUE self);
|
65
|
+
VALUE QueueManager_exception_on_error(VALUE self);
|
66
|
+
VALUE QueueManager_connected_q(VALUE self);
|
67
|
+
VALUE QueueManager_name(VALUE self);
|
68
|
+
VALUE QueueManager_execute(VALUE self, VALUE hash);
|
69
|
+
|
70
|
+
void Queue_id_init();
|
71
|
+
VALUE QUEUE_alloc(VALUE klass);
|
72
|
+
VALUE Queue_initialize(VALUE self, VALUE parms);
|
73
|
+
VALUE Queue_singleton_open(int argc, VALUE *argv, VALUE self);
|
74
|
+
VALUE Queue_open(VALUE self);
|
75
|
+
VALUE Queue_close(VALUE self);
|
76
|
+
VALUE Queue_put(VALUE self, VALUE parms);
|
77
|
+
VALUE Queue_get(VALUE self, VALUE parms);
|
78
|
+
VALUE Queue_each(int argc, VALUE *argv, VALUE self);
|
79
|
+
VALUE Queue_name(VALUE self);
|
80
|
+
VALUE Queue_reason_code(VALUE self);
|
81
|
+
VALUE Queue_comp_code(VALUE self);
|
82
|
+
VALUE Queue_reason(VALUE self);
|
83
|
+
VALUE Queue_open_q(VALUE self);
|
84
|
+
|
85
|
+
void Queue_extract_put_message_options(VALUE hash, PMQPMO ppmo);
|
86
|
+
|
87
|
+
extern VALUE wmq_queue;
|
88
|
+
extern VALUE wmq_queue_manager;
|
89
|
+
extern VALUE wmq_message;
|
90
|
+
extern VALUE wmq_exception;
|
91
|
+
|
92
|
+
#define WMQ_EXEC_STRING_INQ_BUFFER_SIZE 32768 /* Todo: Should we make the mqai string return buffer dynamic? */
|
93
|
+
|
94
|
+
/* Internal C Structures for holding MQ data types */
|
95
|
+
typedef struct tagQUEUE_MANAGER QUEUE_MANAGER;
|
96
|
+
typedef QUEUE_MANAGER MQPOINTER PQUEUE_MANAGER;
|
97
|
+
|
98
|
+
struct tagQUEUE_MANAGER {
|
99
|
+
MQHCONN hcon; /* connection handle */
|
100
|
+
MQLONG comp_code; /* completion code */
|
101
|
+
MQLONG reason_code; /* reason code for MQCONN */
|
102
|
+
MQLONG exception_on_error; /* Non-Zero means throw exception*/
|
103
|
+
MQLONG already_connected; /* Already connected means don't disconnect */
|
104
|
+
MQLONG trace_level; /* Trace level. 0==None, 1==Info 2==Debug ..*/
|
105
|
+
MQCNO connect_options; /* MQCONNX Connection Options */
|
106
|
+
#ifdef MQCNO_VERSION_2
|
107
|
+
MQCD client_conn; /* Client Connection */
|
108
|
+
#endif
|
109
|
+
#ifdef MQCNO_VERSION_4
|
110
|
+
MQSCO ssl_config_opts; /* Security options */
|
111
|
+
#endif
|
112
|
+
#ifdef MQCD_VERSION_6
|
113
|
+
MQPTR long_remote_user_id_ptr;
|
114
|
+
#endif
|
115
|
+
#ifdef MQCD_VERSION_7
|
116
|
+
MQPTR ssl_peer_name_ptr;
|
117
|
+
#endif
|
118
|
+
#ifdef MQHB_UNUSABLE_HBAG
|
119
|
+
MQHBAG admin_bag;
|
120
|
+
MQHBAG reply_bag;
|
121
|
+
#endif
|
122
|
+
PMQBYTE p_buffer; /* message buffer */
|
123
|
+
MQLONG buffer_size; /* Allocated size of buffer */
|
124
|
+
|
125
|
+
MQLONG is_client_conn; /* Is this a Client Connection? */
|
126
|
+
void* mq_lib_handle; /* Handle to MQ library */
|
127
|
+
|
128
|
+
void(*MQCONNX)(PMQCHAR,PMQCNO,PMQHCONN,PMQLONG,PMQLONG);
|
129
|
+
void(*MQCONN) (PMQCHAR,PMQHCONN,PMQLONG,PMQLONG);
|
130
|
+
void(*MQDISC) (PMQHCONN,PMQLONG,PMQLONG);
|
131
|
+
void(*MQBEGIN)(MQHCONN,PMQVOID,PMQLONG,PMQLONG);
|
132
|
+
void(*MQBACK) (MQHCONN,PMQLONG,PMQLONG);
|
133
|
+
void(*MQCMIT) (MQHCONN,PMQLONG,PMQLONG);
|
134
|
+
void(*MQPUT1) (MQHCONN,PMQVOID,PMQVOID,PMQVOID,MQLONG,PMQVOID,PMQLONG,PMQLONG);
|
135
|
+
|
136
|
+
void(*MQOPEN) (MQHCONN,PMQVOID,MQLONG,PMQHOBJ,PMQLONG,PMQLONG);
|
137
|
+
void(*MQCLOSE)(MQHCONN,PMQHOBJ,MQLONG,PMQLONG,PMQLONG);
|
138
|
+
void(*MQGET) (MQHCONN,MQHOBJ,PMQVOID,PMQVOID,MQLONG,PMQVOID,PMQLONG,PMQLONG,PMQLONG);
|
139
|
+
void(*MQPUT) (MQHCONN,MQHOBJ,PMQVOID,PMQVOID,MQLONG,PMQVOID,PMQLONG,PMQLONG);
|
140
|
+
|
141
|
+
void(*MQINQ) (MQHCONN,MQHOBJ,MQLONG,PMQLONG,MQLONG,PMQLONG,MQLONG,PMQCHAR,PMQLONG,PMQLONG);
|
142
|
+
void(*MQSET) (MQHCONN,MQHOBJ,MQLONG,PMQLONG,MQLONG,PMQLONG,MQLONG,PMQCHAR,PMQLONG,PMQLONG);
|
143
|
+
|
144
|
+
void(*mqCreateBag)(MQLONG,PMQHBAG,PMQLONG,PMQLONG);
|
145
|
+
void(*mqDeleteBag)(PMQHBAG,PMQLONG,PMQLONG);
|
146
|
+
void(*mqClearBag)(MQHBAG,PMQLONG,PMQLONG);
|
147
|
+
void(*mqExecute)(MQHCONN,MQLONG,MQHBAG,MQHBAG,MQHBAG,MQHOBJ,MQHOBJ,PMQLONG,PMQLONG);
|
148
|
+
void(*mqCountItems)(MQHBAG,MQLONG,PMQLONG,PMQLONG,PMQLONG);
|
149
|
+
void(*mqInquireBag)(MQHBAG,MQLONG,MQLONG,PMQHBAG,PMQLONG,PMQLONG);
|
150
|
+
void(*mqInquireItemInfo)(MQHBAG,MQLONG,MQLONG,PMQLONG,PMQLONG,PMQLONG,PMQLONG);
|
151
|
+
void(*mqInquireInteger)(MQHBAG,MQLONG,MQLONG,PMQLONG,PMQLONG,PMQLONG);
|
152
|
+
void(*mqInquireString)(MQHBAG,MQLONG,MQLONG,MQLONG,PMQCHAR,PMQLONG,PMQLONG,PMQLONG,PMQLONG);
|
153
|
+
void(*mqAddInquiry)(MQHBAG,MQLONG,PMQLONG,PMQLONG);
|
154
|
+
void(*mqAddInteger)(MQHBAG,MQLONG,MQLONG,PMQLONG,PMQLONG);
|
155
|
+
void(*mqAddString)(MQHBAG,MQLONG,MQLONG,PMQCHAR,PMQLONG,PMQLONG);
|
156
|
+
};
|
157
|
+
|
158
|
+
void Queue_manager_mq_load(PQUEUE_MANAGER pqm);
|
159
|
+
void Queue_manager_mq_free(PQUEUE_MANAGER pqm);
|
160
|
+
|
161
|
+
|
162
|
+
/*
|
163
|
+
* Message
|
164
|
+
*/
|
165
|
+
struct Message_build_header_arg {
|
166
|
+
PMQBYTE* pp_buffer; /* Autosize: Pointer to start of total buffer */
|
167
|
+
PMQLONG p_buffer_size; /* Autosize: Size of total buffer */
|
168
|
+
MQLONG data_length; /* Autosize: Length of the data being written */
|
169
|
+
PMQLONG p_data_offset; /* Current offset of data portion in total buffer */
|
170
|
+
MQLONG trace_level; /* Trace level. 0==None, 1==Info 2==Debug ..*/
|
171
|
+
ID next_header_id; /* Used for setting MQ Format to next header */
|
172
|
+
PMQBYTE data_format; /* Format of data. Used when next_header_id == 0 */
|
173
|
+
};
|
174
|
+
|
175
|
+
void Message_id_init();
|
176
|
+
VALUE Message_initialize(int argc, VALUE *argv, VALUE self);
|
177
|
+
VALUE Message_clear(VALUE self);
|
178
|
+
PMQBYTE Message_autogrow_data_buffer(struct Message_build_header_arg* parg, MQLONG additional_size);
|
179
|
+
void Message_build_rf_header (VALUE hash, struct Message_build_header_arg* parg);
|
180
|
+
MQLONG Message_deblock_rf_header (VALUE hash, PMQBYTE p_data, MQLONG data_len);
|
181
|
+
void Message_build_rf_header_2 (VALUE hash, struct Message_build_header_arg* parg);
|
182
|
+
MQLONG Message_deblock_rf_header_2 (VALUE hash, PMQBYTE p_data, MQLONG data_len);
|
183
|
+
|
184
|
+
void Message_build_set_format(ID header_type, PMQBYTE p_format);
|
185
|
+
void Message_build(PMQBYTE* pq_pp_buffer, PMQLONG pq_p_buffer_size, MQLONG trace_level,
|
186
|
+
VALUE parms, PPMQVOID pp_buffer, PMQLONG p_total_length, PMQMD pmqmd);
|
187
|
+
void Message_build_mqmd(VALUE self, PMQMD pmqmd);
|
188
|
+
void Message_deblock(VALUE message, PMQMD pmqmd, PMQBYTE p_buffer, MQLONG total_length, MQLONG trace_level);
|
189
|
+
|
190
|
+
int Message_build_header(VALUE hash, struct Message_build_header_arg* parg);
|
191
|
+
|
192
|
+
/* Utility methods */
|
193
|
+
|
194
|
+
/* --------------------------------------------------
|
195
|
+
* Set internal variable based on value passed in from
|
196
|
+
* a hash
|
197
|
+
* --------------------------------------------------*/
|
198
|
+
void setFromHashString(VALUE self, VALUE hash, char* pKey, char* pAttribute, char* pDefault);
|
199
|
+
void setFromHashValue(VALUE self, VALUE hash, char* pKey, char* pAttribute, VALUE valDefault);
|
200
|
+
|
201
|
+
void to_mqmd(VALUE hash, MQMD* pmqmd);
|
202
|
+
void from_mqmd(VALUE hash, MQMD* pmqmd);
|
203
|
+
|
204
|
+
void to_mqdlh(VALUE hash, MQDLH* pmqdlh);
|
205
|
+
void from_mqdlh(VALUE hash, MQDLH* pmqdlh);
|
206
|
+
|
207
|
+
void wmq_structs_id_init();
|
208
|
+
void Message_to_mqmd(VALUE hash, MQMD* pmqmd);
|
209
|
+
void Message_to_mqmd1(VALUE hash, MQMD1* pmqmd1);
|
210
|
+
void Message_to_mqrfh2(VALUE hash, MQRFH2* pmqrfh2);
|
211
|
+
void Message_to_mqrfh(VALUE hash, MQRFH* pmqrfh);
|
212
|
+
void Message_to_mqdlh(VALUE hash, MQDLH* pmqdlh);
|
213
|
+
void Message_to_mqcih(VALUE hash, MQCIH* pmqcih);
|
214
|
+
void Message_to_mqdh(VALUE hash, MQDH* pmqdh);
|
215
|
+
void Message_to_mqiih(VALUE hash, MQIIH* pmqiih);
|
216
|
+
void Message_to_mqrmh(VALUE hash, MQRMH* pmqrmh);
|
217
|
+
void Message_to_mqtm(VALUE hash, MQTM* pmqtm);
|
218
|
+
void Message_to_mqtmc2(VALUE hash, MQTMC2* pmqtmc2);
|
219
|
+
void Message_to_mqwih(VALUE hash, MQWIH* pmqwih);
|
220
|
+
void Message_to_mqxqh(VALUE hash, MQXQH* pmqxqh);
|
221
|
+
void Message_from_mqmd(VALUE hash, MQMD* pmqmd);
|
222
|
+
void Message_from_mqmd1(VALUE hash, MQMD1* pmqmd1);
|
223
|
+
void Message_from_mqrfh2(VALUE hash, MQRFH2* pmqrfh2);
|
224
|
+
void Message_from_mqrfh(VALUE hash, MQRFH* pmqrfh);
|
225
|
+
void Message_from_mqdlh(VALUE hash, MQDLH* pmqdlh);
|
226
|
+
void Message_from_mqcih(VALUE hash, MQCIH* pmqcih);
|
227
|
+
void Message_from_mqdh(VALUE hash, MQDH* pmqdh);
|
228
|
+
void Message_from_mqiih(VALUE hash, MQIIH* pmqiih);
|
229
|
+
void Message_from_mqrmh(VALUE hash, MQRMH* pmqrmh);
|
230
|
+
void Message_from_mqtm(VALUE hash, MQTM* pmqtm);
|
231
|
+
void Message_from_mqtmc2(VALUE hash, MQTMC2* pmqtmc2);
|
232
|
+
void Message_from_mqwih(VALUE hash, MQWIH* pmqwih);
|
233
|
+
void Message_from_mqxqh(VALUE hash, MQXQH* pmqxqh);
|
234
|
+
|
235
|
+
char* wmq_reason(MQLONG reason_code);
|
236
|
+
ID wmq_selector_id(MQLONG selector);
|
237
|
+
MQLONG wmq_command_lookup(ID command_id);
|
238
|
+
void wmq_selector(ID selector_id, PMQLONG selector_type, PMQLONG selector);
|
239
|
+
|
240
|
+
/* --------------------------------------------------
|
241
|
+
* MACROS for moving data between Ruby and MQ
|
242
|
+
* --------------------------------------------------*/
|
243
|
+
#define WMQ_STR2MQLONG(STR,ELEMENT) \
|
244
|
+
ELEMENT = NUM2LONG(STR);
|
245
|
+
|
246
|
+
#define WMQ_STR2MQCHAR(STR,ELEMENT) \
|
247
|
+
ELEMENT = NUM2LONG(STR);
|
248
|
+
|
249
|
+
#define WMQ_STR2MQCHARS(STR,ELEMENT) \
|
250
|
+
str = StringValue(STR); \
|
251
|
+
length = RSTRING_LEN(STR); \
|
252
|
+
size = sizeof(ELEMENT); \
|
253
|
+
strncpy(ELEMENT, RSTRING_PTR(STR), length > size ? size : length);
|
254
|
+
|
255
|
+
#define WMQ_STR2MQBYTES(STR,ELEMENT) \
|
256
|
+
str = StringValue(STR); \
|
257
|
+
length = RSTRING_LEN(str); \
|
258
|
+
size = sizeof(ELEMENT); \
|
259
|
+
if (length >= size) \
|
260
|
+
{ \
|
261
|
+
memcpy(ELEMENT, RSTRING_PTR(str), size); \
|
262
|
+
} \
|
263
|
+
else \
|
264
|
+
{ \
|
265
|
+
memcpy(ELEMENT, RSTRING_PTR(str), length); \
|
266
|
+
memset(ELEMENT+length, 0, size-length); \
|
267
|
+
}
|
268
|
+
|
269
|
+
#define WMQ_HASH2MQLONG(HASH,KEY,ELEMENT) \
|
270
|
+
val = rb_hash_aref(HASH, ID2SYM(ID_##KEY)); \
|
271
|
+
if (!NIL_P(val)) { WMQ_STR2MQLONG(val,ELEMENT) }
|
272
|
+
|
273
|
+
#define WMQ_HASH2MQCHARS(HASH,KEY,ELEMENT) \
|
274
|
+
val = rb_hash_aref(HASH, ID2SYM(ID_##KEY)); \
|
275
|
+
if (!NIL_P(val)) \
|
276
|
+
{ \
|
277
|
+
WMQ_STR2MQCHARS(val,ELEMENT) \
|
278
|
+
}
|
279
|
+
|
280
|
+
#define WMQ_HASH2MQCHAR(HASH,KEY,ELEMENT) \
|
281
|
+
val = rb_hash_aref(HASH, ID2SYM(ID_##KEY)); \
|
282
|
+
if (!NIL_P(val)) { WMQ_STR2MQCHAR(val,ELEMENT); } \
|
283
|
+
|
284
|
+
#define WMQ_HASH2MQBYTES(HASH,KEY,ELEMENT) \
|
285
|
+
val = rb_hash_aref(HASH, ID2SYM(ID_##KEY)); \
|
286
|
+
if (!NIL_P(val)) \
|
287
|
+
{ \
|
288
|
+
WMQ_STR2MQBYTES(val,ELEMENT) \
|
289
|
+
}
|
290
|
+
|
291
|
+
#define WMQ_HASH2BOOL(HASH,KEY,ELEMENT) \
|
292
|
+
val = rb_hash_aref(hash, ID2SYM(ID_##KEY)); \
|
293
|
+
if (!NIL_P(val)) \
|
294
|
+
{ \
|
295
|
+
if(TYPE(val) == T_TRUE) ELEMENT = 1; \
|
296
|
+
else if(TYPE(val) == T_FALSE) ELEMENT = 0; \
|
297
|
+
else \
|
298
|
+
rb_raise(rb_eTypeError, ":" #KEY \
|
299
|
+
" must be true or false"); \
|
300
|
+
}
|
301
|
+
|
302
|
+
#define IF_TRUE(KEY,DEFAULT) \
|
303
|
+
val = rb_hash_aref(hash, ID2SYM(ID_##KEY)); \
|
304
|
+
if (NIL_P(val)) \
|
305
|
+
{ \
|
306
|
+
flag = DEFAULT; \
|
307
|
+
} \
|
308
|
+
else \
|
309
|
+
{ \
|
310
|
+
if(TYPE(val) == T_TRUE) flag = 1; \
|
311
|
+
else if(TYPE(val) == T_FALSE) flag = 0; \
|
312
|
+
else \
|
313
|
+
rb_raise(rb_eTypeError, ":" #KEY \
|
314
|
+
" must be true or false"); \
|
315
|
+
} \
|
316
|
+
if (flag)
|
317
|
+
|
318
|
+
/* --------------------------------------------------
|
319
|
+
* Strip trailing nulls and spaces
|
320
|
+
* --------------------------------------------------*/
|
321
|
+
#define WMQ_MQCHARS2STR(ELEMENT, TARGET) \
|
322
|
+
size = sizeof(ELEMENT); \
|
323
|
+
length = 0; \
|
324
|
+
pChar = ELEMENT + size-1; \
|
325
|
+
for (i = size; i > 0; i--) \
|
326
|
+
{ \
|
327
|
+
if (*pChar != ' ' && *pChar != 0) \
|
328
|
+
{ \
|
329
|
+
length = i; \
|
330
|
+
break; \
|
331
|
+
} \
|
332
|
+
pChar--; \
|
333
|
+
} \
|
334
|
+
TARGET = rb_str_new(ELEMENT,length);
|
335
|
+
|
336
|
+
#define WMQ_MQCHARS2HASH(HASH,KEY,ELEMENT) \
|
337
|
+
WMQ_MQCHARS2STR(ELEMENT, str) \
|
338
|
+
rb_hash_aset(HASH, ID2SYM(ID_##KEY), str);
|
339
|
+
|
340
|
+
#define WMQ_MQLONG2HASH(HASH,KEY,ELEMENT) \
|
341
|
+
rb_hash_aset(HASH, ID2SYM(ID_##KEY), LONG2NUM(ELEMENT));
|
342
|
+
|
343
|
+
#define WMQ_MQCHAR2HASH(HASH,KEY,ELEMENT) \
|
344
|
+
rb_hash_aset(HASH, ID2SYM(ID_##KEY), LONG2NUM(ELEMENT));
|
345
|
+
|
346
|
+
/* --------------------------------------------------
|
347
|
+
* Trailing Spaces are important with binary fields
|
348
|
+
* --------------------------------------------------*/
|
349
|
+
#define WMQ_MQBYTES2STR(ELEMENT,TARGET) \
|
350
|
+
size = sizeof(ELEMENT); \
|
351
|
+
length = 0; \
|
352
|
+
pChar = ELEMENT + size-1; \
|
353
|
+
for (i = size; i > 0; i--) \
|
354
|
+
{ \
|
355
|
+
if (*pChar != 0) \
|
356
|
+
{ \
|
357
|
+
length = i; \
|
358
|
+
break; \
|
359
|
+
} \
|
360
|
+
pChar--; \
|
361
|
+
} \
|
362
|
+
TARGET = rb_str_new(ELEMENT,length);
|
363
|
+
|
364
|
+
#define WMQ_MQBYTES2HASH(HASH,KEY,ELEMENT) \
|
365
|
+
WMQ_MQBYTES2STR(ELEMENT, str) \
|
366
|
+
rb_hash_aset(HASH, ID2SYM(ID_##KEY), str);
|
367
|
+
|