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/decode_rfh.h
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2007 Edwin M. Fine, Fine Computer Consultants, Inc.
|
3
|
-
*
|
4
|
-
* Licensed under the Apache License, Version 2.0
|
5
|
-
* (the "License"); you may not use this file except
|
6
|
-
* in compliance with the License. You may obtain a copy
|
7
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
* Unless required by applicable law or agreed to in writing,
|
9
|
-
* software distributed under the License is distributed on an
|
10
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
11
|
-
* either express or implied. See the License for the specific
|
12
|
-
* language governing permissions and limitations under the License.
|
13
|
-
*/
|
14
|
-
#if !defined(DECODE_RFH_INCLUDED)
|
15
|
-
#define DECODE_RFH_INCLUDED
|
16
|
-
|
17
|
-
#include <stdlib.h> /* For size_t */
|
18
|
-
|
19
|
-
typedef void (*CALLBACK_FN)(const char *name, const char *value, void *user_data);
|
20
|
-
|
21
|
-
typedef enum {
|
22
|
-
TT_TOKEN,
|
23
|
-
TT_UNESCAPED_QUOTE, /* '"' not followed by '"' in quoted string */
|
24
|
-
TT_ILLEGAL_QUOTE, /* '"' in unquoted string */
|
25
|
-
TT_UNEXPECTED_EOS,
|
26
|
-
TT_TOKEN_TRUNCATED, /* Token buffer too short to receive full token */
|
27
|
-
TT_INTERNAL_ERROR,
|
28
|
-
TT_ALLOC_FAILURE,
|
29
|
-
TT_END
|
30
|
-
} rfh_toktype_t;
|
31
|
-
|
32
|
-
/* Returns TT_END on success, other on error */
|
33
|
-
rfh_toktype_t
|
34
|
-
rfh_decode_name_val_str(const char *nvstr,
|
35
|
-
size_t len,
|
36
|
-
CALLBACK_FN callback,
|
37
|
-
void *user_data);
|
38
|
-
|
39
|
-
/* Translates toktype_t to string */
|
40
|
-
const char *rfh_toktype_to_s(rfh_toktype_t toktype);
|
41
|
-
|
42
|
-
int rfh_in_debug_mode(void);
|
43
|
-
void rfh_set_debug_mode(int on_if_true);
|
44
|
-
|
45
|
-
#endif
|
1
|
+
/*
|
2
|
+
* Copyright 2007 Edwin M. Fine, Fine Computer Consultants, Inc.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0
|
5
|
+
* (the "License"); you may not use this file except
|
6
|
+
* in compliance with the License. You may obtain a copy
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
* Unless required by applicable law or agreed to in writing,
|
9
|
+
* software distributed under the License is distributed on an
|
10
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
11
|
+
* either express or implied. See the License for the specific
|
12
|
+
* language governing permissions and limitations under the License.
|
13
|
+
*/
|
14
|
+
#if !defined(DECODE_RFH_INCLUDED)
|
15
|
+
#define DECODE_RFH_INCLUDED
|
16
|
+
|
17
|
+
#include <stdlib.h> /* For size_t */
|
18
|
+
|
19
|
+
typedef void (*CALLBACK_FN)(const char *name, const char *value, void *user_data);
|
20
|
+
|
21
|
+
typedef enum {
|
22
|
+
TT_TOKEN,
|
23
|
+
TT_UNESCAPED_QUOTE, /* '"' not followed by '"' in quoted string */
|
24
|
+
TT_ILLEGAL_QUOTE, /* '"' in unquoted string */
|
25
|
+
TT_UNEXPECTED_EOS,
|
26
|
+
TT_TOKEN_TRUNCATED, /* Token buffer too short to receive full token */
|
27
|
+
TT_INTERNAL_ERROR,
|
28
|
+
TT_ALLOC_FAILURE,
|
29
|
+
TT_END
|
30
|
+
} rfh_toktype_t;
|
31
|
+
|
32
|
+
/* Returns TT_END on success, other on error */
|
33
|
+
rfh_toktype_t
|
34
|
+
rfh_decode_name_val_str(const char *nvstr,
|
35
|
+
size_t len,
|
36
|
+
CALLBACK_FN callback,
|
37
|
+
void *user_data);
|
38
|
+
|
39
|
+
/* Translates toktype_t to string */
|
40
|
+
const char *rfh_toktype_to_s(rfh_toktype_t toktype);
|
41
|
+
|
42
|
+
int rfh_in_debug_mode(void);
|
43
|
+
void rfh_set_debug_mode(int on_if_true);
|
44
|
+
|
45
|
+
#endif
|
data/ext/extconf.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
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
|
-
require 'mkmf'
|
18
|
-
require 'generate/generate_reason'
|
19
|
-
require 'generate/generate_const'
|
20
|
-
require 'generate/generate_structs'
|
21
|
-
|
22
|
-
include_path = ''
|
23
|
-
if RUBY_PLATFORM =~ /mswin32/
|
24
|
-
include_path = 'C:\Program Files\IBM\WebSphere MQ\Tools\c\include'
|
25
|
-
dir_config('mqm', include_path, '.')
|
26
|
-
else
|
27
|
-
include_path = '/opt/mqm/inc'
|
28
|
-
#dir_config('mqm', include_path, '/opt/mqm/lib')
|
29
|
-
end
|
30
|
-
|
31
|
-
have_header('cmqc.h')
|
32
|
-
|
33
|
-
# Check for WebSphere MQ Server library
|
34
|
-
unless (RUBY_PLATFORM =~ /win/i) || (RUBY_PLATFORM =~ /solaris/i) || (RUBY_PLATFORM =~ /linux/i)
|
35
|
-
have_library('mqm')
|
36
|
-
end
|
37
|
-
|
38
|
-
# Generate Source Files
|
39
|
-
GenerateReason.generate(include_path+'/')
|
40
|
-
GenerateConst.generate(include_path+'/', 'lib')
|
41
|
-
GenerateStructs.new(include_path+'/', 'generate').generate
|
42
|
-
|
43
|
-
# Generate Makefile
|
44
|
-
create_makefile('wmq/wmq')
|
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
|
+
require 'mkmf'
|
18
|
+
require './generate/generate_reason'
|
19
|
+
require './generate/generate_const'
|
20
|
+
require './generate/generate_structs'
|
21
|
+
|
22
|
+
include_path = ''
|
23
|
+
if RUBY_PLATFORM =~ /mswin32/
|
24
|
+
include_path = 'C:\Program Files\IBM\WebSphere MQ\Tools\c\include'
|
25
|
+
dir_config('mqm', include_path, '.')
|
26
|
+
else
|
27
|
+
include_path = '/opt/mqm/inc'
|
28
|
+
#dir_config('mqm', include_path, '/opt/mqm/lib')
|
29
|
+
end
|
30
|
+
|
31
|
+
have_header('cmqc.h')
|
32
|
+
|
33
|
+
# Check for WebSphere MQ Server library
|
34
|
+
unless (RUBY_PLATFORM =~ /win/i) || (RUBY_PLATFORM =~ /solaris/i) || (RUBY_PLATFORM =~ /linux/i)
|
35
|
+
have_library('mqm')
|
36
|
+
end
|
37
|
+
|
38
|
+
# Generate Source Files
|
39
|
+
GenerateReason.generate(include_path+'/')
|
40
|
+
GenerateConst.generate(include_path+'/', 'lib')
|
41
|
+
GenerateStructs.new(include_path+'/', 'generate').generate
|
42
|
+
|
43
|
+
# Generate Makefile
|
44
|
+
create_makefile('wmq/wmq')
|
@@ -1,97 +1,97 @@
|
|
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
|
-
require 'erb'
|
17
|
-
|
18
|
-
class GenerateStructs
|
19
|
-
|
20
|
-
@@field_ignore_list = [ 'StrucId', 'Version' , 'StrucLength']
|
21
|
-
|
22
|
-
# Store path to WebSphere MQ Structures
|
23
|
-
def initialize(wmq_includepath, templates_path='.')
|
24
|
-
@path = wmq_includepath
|
25
|
-
@templates_path = templates_path
|
26
|
-
end
|
27
|
-
|
28
|
-
def extract_struct (filename, struct_name)
|
29
|
-
properties_list = []
|
30
|
-
line_number = 0
|
31
|
-
found = false
|
32
|
-
File.open(filename) do |file|
|
33
|
-
file.each do |line|
|
34
|
-
line_number += 1
|
35
|
-
line.rstrip!
|
36
|
-
# Skip empty and comment lines
|
37
|
-
if line.length > 0 && line !~ /^\s*\/\*/
|
38
|
-
if !found
|
39
|
-
found = true if line =~ /^\s*struct\s*tag#{struct_name}/
|
40
|
-
else
|
41
|
-
return(properties_list) if line =~ /^\s*\};/
|
42
|
-
match = /\s*(MQ\w+)\s+(\w+);/.match(line)
|
43
|
-
if match
|
44
|
-
type = match[1]
|
45
|
-
element = match[2]
|
46
|
-
properties_list.push([type, element])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
properties_list
|
53
|
-
end
|
54
|
-
|
55
|
-
def rubyize_name(name)
|
56
|
-
name.gsub(/::/, '/').
|
57
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
58
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
59
|
-
tr("-", "_").
|
60
|
-
downcase
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.test_rubyize_name
|
64
|
-
test = self.new
|
65
|
-
[['a', 'a'],
|
66
|
-
['A', 'a'],
|
67
|
-
['Aa', 'aa'],
|
68
|
-
['AA', 'aa'],
|
69
|
-
['AaA', 'aa_a'],
|
70
|
-
['MyFieldName', 'my_field_name'],
|
71
|
-
['MMyFieldNName', 'm_my_field_n_name'],
|
72
|
-
['ABCdefGHIjKlMnOPQrSTuvwxYz', 'ab_cdef_gh_ij_kl_mn_op_qr_s_tuvwx_yz']
|
73
|
-
].each do |item|
|
74
|
-
str = test.rubyize_name(item[0])
|
75
|
-
raise("rubyize_name('#{item[0]}') == #{str} != '#{item[1]})") if str != item[1]
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def generate_structs(erb)
|
80
|
-
erb.result(binding)
|
81
|
-
end
|
82
|
-
|
83
|
-
def generate(target_filename = 'wmq_structs.c')
|
84
|
-
erb = nil
|
85
|
-
File.open(@templates_path+'/wmq_structs.erb') { |file| erb = ERB.new(file.read) }
|
86
|
-
File.open(target_filename, 'w') {|file| file.write(generate_structs(erb)) }
|
87
|
-
puts "Generated #{target_filename}"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
# TODO Auto Daisy-Chain Headers: Format, CodedCharSetId, Encoding
|
92
|
-
# TODO During Deblock validate that data size left at least matches struct size
|
93
|
-
if $0 == __FILE__
|
94
|
-
path = ARGV[0] || raise("Mandatory parameter: 'WebSphere MQ Include path' is missing")
|
95
|
-
path = path + '/'
|
96
|
-
GenerateStructs.new(path, 'generate').generate
|
97
|
-
end
|
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
|
+
require 'erb'
|
17
|
+
|
18
|
+
class GenerateStructs
|
19
|
+
|
20
|
+
@@field_ignore_list = [ 'StrucId', 'Version' , 'StrucLength']
|
21
|
+
|
22
|
+
# Store path to WebSphere MQ Structures
|
23
|
+
def initialize(wmq_includepath, templates_path='.')
|
24
|
+
@path = wmq_includepath
|
25
|
+
@templates_path = templates_path
|
26
|
+
end
|
27
|
+
|
28
|
+
def extract_struct (filename, struct_name)
|
29
|
+
properties_list = []
|
30
|
+
line_number = 0
|
31
|
+
found = false
|
32
|
+
File.open(filename) do |file|
|
33
|
+
file.each do |line|
|
34
|
+
line_number += 1
|
35
|
+
line.rstrip!
|
36
|
+
# Skip empty and comment lines
|
37
|
+
if line.length > 0 && line !~ /^\s*\/\*/
|
38
|
+
if !found
|
39
|
+
found = true if line =~ /^\s*struct\s*tag#{struct_name}/
|
40
|
+
else
|
41
|
+
return(properties_list) if line =~ /^\s*\};/
|
42
|
+
match = /\s*(MQ\w+)\s+(\w+);/.match(line)
|
43
|
+
if match
|
44
|
+
type = match[1]
|
45
|
+
element = match[2]
|
46
|
+
properties_list.push([type, element])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
properties_list
|
53
|
+
end
|
54
|
+
|
55
|
+
def rubyize_name(name)
|
56
|
+
name.gsub(/::/, '/').
|
57
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
58
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
59
|
+
tr("-", "_").
|
60
|
+
downcase
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.test_rubyize_name
|
64
|
+
test = self.new
|
65
|
+
[['a', 'a'],
|
66
|
+
['A', 'a'],
|
67
|
+
['Aa', 'aa'],
|
68
|
+
['AA', 'aa'],
|
69
|
+
['AaA', 'aa_a'],
|
70
|
+
['MyFieldName', 'my_field_name'],
|
71
|
+
['MMyFieldNName', 'm_my_field_n_name'],
|
72
|
+
['ABCdefGHIjKlMnOPQrSTuvwxYz', 'ab_cdef_gh_ij_kl_mn_op_qr_s_tuvwx_yz']
|
73
|
+
].each do |item|
|
74
|
+
str = test.rubyize_name(item[0])
|
75
|
+
raise("rubyize_name('#{item[0]}') == #{str} != '#{item[1]})") if str != item[1]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def generate_structs(erb)
|
80
|
+
erb.result(binding)
|
81
|
+
end
|
82
|
+
|
83
|
+
def generate(target_filename = 'wmq_structs.c')
|
84
|
+
erb = nil
|
85
|
+
File.open(@templates_path+'/wmq_structs.erb') { |file| erb = ERB.new(file.read) }
|
86
|
+
File.open(target_filename, 'w') {|file| file.write(generate_structs(erb)) }
|
87
|
+
puts "Generated #{target_filename}"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# TODO Auto Daisy-Chain Headers: Format, CodedCharSetId, Encoding
|
92
|
+
# TODO During Deblock validate that data size left at least matches struct size
|
93
|
+
if $0 == __FILE__
|
94
|
+
path = ARGV[0] || raise("Mandatory parameter: 'WebSphere MQ Include path' is missing")
|
95
|
+
path = path + '/'
|
96
|
+
GenerateStructs.new(path, 'generate').generate
|
97
|
+
end
|
@@ -167,15 +167,8 @@ void Message_from_<%=struct_name.downcase%>(VALUE hash, <%=struct_name%>* <%=var
|
|
167
167
|
end
|
168
168
|
%>}
|
169
169
|
|
170
|
-
#if RUBY_VERSION_CODE > 183
|
171
170
|
static int Message_to_<%=struct_name.downcase%>_each (VALUE key, VALUE value, <%=struct_name%>* p<%=struct_name.downcase%>)
|
172
171
|
{
|
173
|
-
#else
|
174
|
-
static int Message_to_<%=struct_name.downcase%>_each (VALUE array, <%=struct_name%>* p<%=struct_name.downcase%>)
|
175
|
-
{
|
176
|
-
VALUE key = rb_ary_shift(array);
|
177
|
-
VALUE value = rb_ary_shift(array);
|
178
|
-
#endif
|
179
172
|
VALUE str;
|
180
173
|
size_t size;
|
181
174
|
size_t length;
|
@@ -207,18 +200,12 @@ static int Message_to_<%=struct_name.downcase%>_each (VALUE array, <%=struct_nam
|
|
207
200
|
%><%=struct[:header]?" if(id != ID_header_type)":""%><%
|
208
201
|
if contains
|
209
202
|
%> {
|
210
|
-
#if RUBY_VERSION_CODE > 183
|
211
203
|
Message_to_<%= contains%>_each(key, value, &pmqxqh->MsgDesc);
|
212
|
-
#else
|
213
|
-
rb_ary_push(array, key);
|
214
|
-
rb_ary_push(array, value);
|
215
|
-
Message_to_<%= contains%>_each(array, &pmqxqh->MsgDesc);
|
216
|
-
#endif
|
217
204
|
}<%
|
218
205
|
else%>
|
219
206
|
{
|
220
207
|
val = rb_funcall(key, ID_to_s, 0);
|
221
|
-
rb_raise(rb_eArgError, "WMQ::Message#to_<%=struct_name.downcase%> Unknown symbol :%s supplied",
|
208
|
+
rb_raise(rb_eArgError, "WMQ::Message#to_<%=struct_name.downcase%> Unknown symbol :%s supplied", RSTRING_PTR(val));
|
222
209
|
}
|
223
210
|
<% end%>
|
224
211
|
return 0;
|
@@ -226,11 +213,7 @@ static int Message_to_<%=struct_name.downcase%>_each (VALUE array, <%=struct_nam
|
|
226
213
|
|
227
214
|
void Message_to_<%=struct_name.downcase%>(VALUE hash, <%=struct_name%>* p<%=struct_name.downcase%>)
|
228
215
|
{
|
229
|
-
#if RUBY_VERSION_CODE > 183
|
230
216
|
rb_hash_foreach(hash, Message_to_<%=struct_name.downcase%>_each, (VALUE)p<%=struct_name.downcase%>);
|
231
|
-
#else
|
232
|
-
rb_iterate (rb_each, hash, Message_to_<%=struct_name.downcase%>_each, (VALUE)p<%=struct_name.downcase%>);
|
233
|
-
#endif
|
234
217
|
}
|
235
218
|
<% end # wmq_structs.each
|
236
219
|
%>
|
data/ext/wmq.c
CHANGED
@@ -1,93 +1,93 @@
|
|
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 "wmq.h"
|
18
|
-
|
19
|
-
VALUE wmq_queue;
|
20
|
-
VALUE wmq_queue_manager;
|
21
|
-
VALUE wmq_message;
|
22
|
-
VALUE wmq_exception;
|
23
|
-
|
24
|
-
void Init_wmq() {
|
25
|
-
VALUE wmq;
|
26
|
-
|
27
|
-
wmq = rb_define_module("WMQ");
|
28
|
-
|
29
|
-
wmq_queue_manager = rb_define_class_under(wmq, "QueueManager", rb_cObject);
|
30
|
-
rb_define_alloc_func(wmq_queue_manager, QUEUE_MANAGER_alloc);
|
31
|
-
rb_define_singleton_method(wmq_queue_manager, "connect", QueueManager_singleton_connect, -1); /* in wmq_queue_manager.c */
|
32
|
-
rb_define_method(wmq_queue_manager, "initialize", QueueManager_initialize, 1); /* in wmq_queue_manager.c */
|
33
|
-
rb_define_method(wmq_queue_manager, "connect", QueueManager_connect, 0); /* in wmq_queue_manager.c */
|
34
|
-
rb_define_method(wmq_queue_manager, "disconnect", QueueManager_disconnect, 0); /* in wmq_queue_manager.c */
|
35
|
-
rb_define_method(wmq_queue_manager, "open_queue", QueueManager_open_queue, -1); /* in wmq_queue_manager.c */
|
36
|
-
rb_define_method(wmq_queue_manager, "access_queue", QueueManager_open_queue, -1); /* in wmq_queue_manager.c */
|
37
|
-
rb_define_method(wmq_queue_manager, "begin", QueueManager_begin, 0); /* in wmq_queue_manager.c */
|
38
|
-
rb_define_method(wmq_queue_manager, "commit", QueueManager_commit, 0); /* in wmq_queue_manager.c */
|
39
|
-
rb_define_method(wmq_queue_manager, "backout", QueueManager_backout, 0); /* in wmq_queue_manager.c */
|
40
|
-
rb_define_method(wmq_queue_manager, "put", QueueManager_put, 1); /* in wmq_queue_manager.c */
|
41
|
-
rb_define_method(wmq_queue_manager, "comp_code", QueueManager_comp_code, 0); /* in wmq_queue_manager.c */
|
42
|
-
rb_define_method(wmq_queue_manager, "reason_code", QueueManager_reason_code, 0); /* in wmq_queue_manager.c */
|
43
|
-
rb_define_method(wmq_queue_manager, "reason", QueueManager_reason, 0); /* in wmq_queue_manager.c */
|
44
|
-
rb_define_method(wmq_queue_manager, "exception_on_error", QueueManager_exception_on_error, 0); /* in wmq_queue_manager.c */
|
45
|
-
rb_define_method(wmq_queue_manager, "connected?", QueueManager_connected_q, 0); /* in wmq_queue_manager.c */
|
46
|
-
rb_define_method(wmq_queue_manager, "name", QueueManager_name, 0); /* in wmq_queue_manager.c */
|
47
|
-
rb_define_method(wmq_queue_manager, "execute", QueueManager_execute, 1); /* in wmq_queue_manager.c */
|
48
|
-
|
49
|
-
wmq_queue = rb_define_class_under(wmq, "Queue", rb_cObject);
|
50
|
-
rb_define_alloc_func(wmq_queue, QUEUE_alloc);
|
51
|
-
rb_define_singleton_method(wmq_queue, "open", Queue_singleton_open, -1); /* in wmq_queue.c */
|
52
|
-
rb_define_method(wmq_queue, "initialize", Queue_initialize, 1); /* in wmq_queue.c */
|
53
|
-
rb_define_method(wmq_queue, "open", Queue_open, 0); /* in wmq_queue.c */
|
54
|
-
rb_define_method(wmq_queue, "close", Queue_close, 0); /* in wmq_queue.c */
|
55
|
-
rb_define_method(wmq_queue, "put", Queue_put, 1); /* in wmq_queue.c */
|
56
|
-
rb_define_method(wmq_queue, "get", Queue_get, 1); /* in wmq_queue.c */
|
57
|
-
rb_define_method(wmq_queue, "each", Queue_each, -1); /* in wmq_queue.c */
|
58
|
-
rb_define_method(wmq_queue, "name", Queue_name, 0); /* in wmq_queue.c */
|
59
|
-
rb_define_method(wmq_queue, "comp_code", Queue_comp_code, 0); /* in wmq_queue.c */
|
60
|
-
rb_define_method(wmq_queue, "reason_code", Queue_reason_code, 0); /* in wmq_queue.c */
|
61
|
-
rb_define_method(wmq_queue, "reason", Queue_reason, 0); /* in wmq_queue.c */
|
62
|
-
rb_define_method(wmq_queue, "open?", Queue_open_q, 0); /* in wmq_queue.c */
|
63
|
-
|
64
|
-
wmq_message = rb_define_class_under(wmq, "Message", rb_cObject);
|
65
|
-
rb_define_method(wmq_message, "initialize", Message_initialize, -1); /* in wmq_message.c */
|
66
|
-
rb_define_method(wmq_message, "clear", Message_clear, 0); /* in wmq_message.c */
|
67
|
-
|
68
|
-
/*
|
69
|
-
* WMQException is thrown whenever an MQ operation fails and
|
70
|
-
* exception_on_error is true
|
71
|
-
*/
|
72
|
-
wmq_exception = rb_define_class_under(wmq, "WMQException", rb_eRuntimeError);
|
73
|
-
|
74
|
-
/*
|
75
|
-
* Initialize id fields
|
76
|
-
*/
|
77
|
-
Message_id_init();
|
78
|
-
Queue_id_init();
|
79
|
-
QueueManager_id_init();
|
80
|
-
QueueManager_selector_id_init();
|
81
|
-
QueueManager_command_id_init();
|
82
|
-
wmq_structs_id_init();
|
83
|
-
|
84
|
-
rb_require("wmq/wmq_temp");
|
85
|
-
rb_require("wmq/wmq_const");
|
86
|
-
}
|
87
|
-
|
88
|
-
/*
|
89
|
-
* For client build when dynamic loading is not being used E.g. Not Windows or Solaris ...
|
90
|
-
*/
|
91
|
-
void Init_wmq_client() {
|
92
|
-
Init_wmq();
|
93
|
-
}
|
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 "wmq.h"
|
18
|
+
|
19
|
+
VALUE wmq_queue;
|
20
|
+
VALUE wmq_queue_manager;
|
21
|
+
VALUE wmq_message;
|
22
|
+
VALUE wmq_exception;
|
23
|
+
|
24
|
+
void Init_wmq() {
|
25
|
+
VALUE wmq;
|
26
|
+
|
27
|
+
wmq = rb_define_module("WMQ");
|
28
|
+
|
29
|
+
wmq_queue_manager = rb_define_class_under(wmq, "QueueManager", rb_cObject);
|
30
|
+
rb_define_alloc_func(wmq_queue_manager, QUEUE_MANAGER_alloc);
|
31
|
+
rb_define_singleton_method(wmq_queue_manager, "connect", QueueManager_singleton_connect, -1); /* in wmq_queue_manager.c */
|
32
|
+
rb_define_method(wmq_queue_manager, "initialize", QueueManager_initialize, 1); /* in wmq_queue_manager.c */
|
33
|
+
rb_define_method(wmq_queue_manager, "connect", QueueManager_connect, 0); /* in wmq_queue_manager.c */
|
34
|
+
rb_define_method(wmq_queue_manager, "disconnect", QueueManager_disconnect, 0); /* in wmq_queue_manager.c */
|
35
|
+
rb_define_method(wmq_queue_manager, "open_queue", QueueManager_open_queue, -1); /* in wmq_queue_manager.c */
|
36
|
+
rb_define_method(wmq_queue_manager, "access_queue", QueueManager_open_queue, -1); /* in wmq_queue_manager.c */
|
37
|
+
rb_define_method(wmq_queue_manager, "begin", QueueManager_begin, 0); /* in wmq_queue_manager.c */
|
38
|
+
rb_define_method(wmq_queue_manager, "commit", QueueManager_commit, 0); /* in wmq_queue_manager.c */
|
39
|
+
rb_define_method(wmq_queue_manager, "backout", QueueManager_backout, 0); /* in wmq_queue_manager.c */
|
40
|
+
rb_define_method(wmq_queue_manager, "put", QueueManager_put, 1); /* in wmq_queue_manager.c */
|
41
|
+
rb_define_method(wmq_queue_manager, "comp_code", QueueManager_comp_code, 0); /* in wmq_queue_manager.c */
|
42
|
+
rb_define_method(wmq_queue_manager, "reason_code", QueueManager_reason_code, 0); /* in wmq_queue_manager.c */
|
43
|
+
rb_define_method(wmq_queue_manager, "reason", QueueManager_reason, 0); /* in wmq_queue_manager.c */
|
44
|
+
rb_define_method(wmq_queue_manager, "exception_on_error", QueueManager_exception_on_error, 0); /* in wmq_queue_manager.c */
|
45
|
+
rb_define_method(wmq_queue_manager, "connected?", QueueManager_connected_q, 0); /* in wmq_queue_manager.c */
|
46
|
+
rb_define_method(wmq_queue_manager, "name", QueueManager_name, 0); /* in wmq_queue_manager.c */
|
47
|
+
rb_define_method(wmq_queue_manager, "execute", QueueManager_execute, 1); /* in wmq_queue_manager.c */
|
48
|
+
|
49
|
+
wmq_queue = rb_define_class_under(wmq, "Queue", rb_cObject);
|
50
|
+
rb_define_alloc_func(wmq_queue, QUEUE_alloc);
|
51
|
+
rb_define_singleton_method(wmq_queue, "open", Queue_singleton_open, -1); /* in wmq_queue.c */
|
52
|
+
rb_define_method(wmq_queue, "initialize", Queue_initialize, 1); /* in wmq_queue.c */
|
53
|
+
rb_define_method(wmq_queue, "open", Queue_open, 0); /* in wmq_queue.c */
|
54
|
+
rb_define_method(wmq_queue, "close", Queue_close, 0); /* in wmq_queue.c */
|
55
|
+
rb_define_method(wmq_queue, "put", Queue_put, 1); /* in wmq_queue.c */
|
56
|
+
rb_define_method(wmq_queue, "get", Queue_get, 1); /* in wmq_queue.c */
|
57
|
+
rb_define_method(wmq_queue, "each", Queue_each, -1); /* in wmq_queue.c */
|
58
|
+
rb_define_method(wmq_queue, "name", Queue_name, 0); /* in wmq_queue.c */
|
59
|
+
rb_define_method(wmq_queue, "comp_code", Queue_comp_code, 0); /* in wmq_queue.c */
|
60
|
+
rb_define_method(wmq_queue, "reason_code", Queue_reason_code, 0); /* in wmq_queue.c */
|
61
|
+
rb_define_method(wmq_queue, "reason", Queue_reason, 0); /* in wmq_queue.c */
|
62
|
+
rb_define_method(wmq_queue, "open?", Queue_open_q, 0); /* in wmq_queue.c */
|
63
|
+
|
64
|
+
wmq_message = rb_define_class_under(wmq, "Message", rb_cObject);
|
65
|
+
rb_define_method(wmq_message, "initialize", Message_initialize, -1); /* in wmq_message.c */
|
66
|
+
rb_define_method(wmq_message, "clear", Message_clear, 0); /* in wmq_message.c */
|
67
|
+
|
68
|
+
/*
|
69
|
+
* WMQException is thrown whenever an MQ operation fails and
|
70
|
+
* exception_on_error is true
|
71
|
+
*/
|
72
|
+
wmq_exception = rb_define_class_under(wmq, "WMQException", rb_eRuntimeError);
|
73
|
+
|
74
|
+
/*
|
75
|
+
* Initialize id fields
|
76
|
+
*/
|
77
|
+
Message_id_init();
|
78
|
+
Queue_id_init();
|
79
|
+
QueueManager_id_init();
|
80
|
+
QueueManager_selector_id_init();
|
81
|
+
QueueManager_command_id_init();
|
82
|
+
wmq_structs_id_init();
|
83
|
+
|
84
|
+
rb_require("wmq/wmq_temp");
|
85
|
+
rb_require("wmq/wmq_const");
|
86
|
+
}
|
87
|
+
|
88
|
+
/*
|
89
|
+
* For client build when dynamic loading is not being used E.g. Not Windows or Solaris ...
|
90
|
+
*/
|
91
|
+
void Init_wmq_client() {
|
92
|
+
Init_wmq();
|
93
|
+
}
|