ctapi 0.2.2

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/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.2
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ctapi'
4
+ include CTAPI
5
+
6
+ Cardterminal.open(PORT_COM1) do |ct|
7
+ puts "Cardterminal Manufacturer: " + ct.manufacturer.to_s
8
+ if ct.card_inserted?
9
+ card = ct.card
10
+ puts "My Cardterminal object: #{ct.inspect}"
11
+ puts "Current card status is: #{ct.card_status}"
12
+ puts "Answer to Reset is #{card.atr}."
13
+ puts "ATR ok? #{card.atr_ok?}."
14
+ puts "Memory size of this card is #{card.memory_size} bytes " +
15
+ "(#{card.memory_blocks} blocks x #{card.memory_bits} bit)."
16
+ puts "Structure of this card is #{card.structure}."
17
+ puts "Supported protocol type of this card is #{card.protocol}."
18
+ puts "Trying to read(0, 16):"
19
+ data = ct.read(0, 16)
20
+ puts "Have read #{data.size} bytes:"
21
+ p data
22
+ else
23
+ puts "Please insert a card into your cardterminal!"
24
+ end
25
+ end
26
+ # vim: set et sw=2 ts=2:
data/examples/ctsh.rb ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'irb'
4
+ require 'irb/completion'
5
+ require 'ctapi'
6
+
7
+ include CTAPI
8
+ $ct = Cardterminal.new(PORT_COM1)
9
+ IRB.start
10
+ # vim: set et sw=2 ts=2:
data/ext/ctapicore.c ADDED
@@ -0,0 +1,443 @@
1
+ /*
2
+ * Document-module: CTAPICore
3
+ *
4
+ * The CTAPICore that interfaces with the shared library for your cardterminal.
5
+ * The following constants are defined in this module:
6
+ * CT
7
+ * CTBCS_CLA
8
+ * CTBCS_DATA_STATUS_CARD
9
+ * CTBCS_DATA_STATUS_CARD_CONNECT
10
+ * CTBCS_DATA_STATUS_NOCARD
11
+ * CTBCS_INS_EJECT
12
+ * CTBCS_INS_REQUEST
13
+ * CTBCS_INS_RESET
14
+ * CTBCS_INS_STATUS
15
+ * CTBCS_MIN_COMMAND_SIZE
16
+ * CTBCS_MIN_RESPONSE_SIZE
17
+ * CTBCS_P1_CT_KERNEL
18
+ * CTBCS_P1_DISPLAY
19
+ * CTBCS_P1_INTERFACE1
20
+ * CTBCS_P1_INTERFACE10
21
+ * CTBCS_P1_INTERFACE11
22
+ * CTBCS_P1_INTERFACE12
23
+ * CTBCS_P1_INTERFACE13
24
+ * CTBCS_P1_INTERFACE14
25
+ * CTBCS_P1_INTERFACE2
26
+ * CTBCS_P1_INTERFACE3
27
+ * CTBCS_P1_INTERFACE4
28
+ * CTBCS_P1_INTERFACE5
29
+ * CTBCS_P1_INTERFACE6
30
+ * CTBCS_P1_INTERFACE7
31
+ * CTBCS_P1_INTERFACE8
32
+ * CTBCS_P1_INTERFACE9
33
+ * CTBCS_P1_KEYPAD
34
+ * CTBCS_P2_REQUEST_GET_ATR
35
+ * CTBCS_P2_REQUEST_GET_HIST
36
+ * CTBCS_P2_REQUEST_NO_RESP
37
+ * CTBCS_P2_RESET_GET_ATR
38
+ * CTBCS_P2_RESET_GET_HIST
39
+ * CTBCS_P2_RESET_NO_RESP
40
+ * CTBCS_P2_STATUS_ICC
41
+ * CTBCS_P2_STATUS_MANUFACTURER
42
+ * CTBCS_SW1_COMMAND_NOT_ALLOWED
43
+ * CTBCS_SW1_EJECT_NOT_REMOVED
44
+ * CTBCS_SW1_EJECT_OK
45
+ * CTBCS_SW1_EJECT_REMOVED
46
+ * CTBCS_SW1_ICC_ERROR
47
+ * CTBCS_SW1_OK
48
+ * CTBCS_SW1_REQUEST_ASYNC_OK
49
+ * CTBCS_SW1_REQUEST_CARD_PRESENT
50
+ * CTBCS_SW1_REQUEST_ERROR
51
+ * CTBCS_SW1_REQUEST_NO_CARD
52
+ * CTBCS_SW1_REQUEST_SYNC_OK
53
+ * CTBCS_SW1_REQUEST_TIMER_ERROR
54
+ * CTBCS_SW1_RESET_ASYNC_OK
55
+ * CTBCS_SW1_RESET_CT_OK
56
+ * CTBCS_SW1_RESET_ERROR
57
+ * CTBCS_SW1_RESET_SYNC_OK
58
+ * CTBCS_SW1_WRONG_CLA
59
+ * CTBCS_SW1_WRONG_INS
60
+ * CTBCS_SW1_WRONG_LENGTH
61
+ * CTBCS_SW1_WRONG_PARAM
62
+ * CTBCS_SW2_COMMAND_NOT_ALLOWED
63
+ * CTBCS_SW2_EJECT_NOT_REMOVED
64
+ * CTBCS_SW2_EJECT_OK
65
+ * CTBCS_SW2_EJECT_REMOVED
66
+ * CTBCS_SW2_ICC_ERROR
67
+ * CTBCS_SW2_OK
68
+ * CTBCS_SW2_REQUEST_ASYNC_OK
69
+ * CTBCS_SW2_REQUEST_CARD_PRESENT
70
+ * CTBCS_SW2_REQUEST_ERROR
71
+ * CTBCS_SW2_REQUEST_NO_CARD
72
+ * CTBCS_SW2_REQUEST_SYNC_OK
73
+ * CTBCS_SW2_REQUEST_TIMER_ERROR
74
+ * CTBCS_SW2_RESET_ASYNC_OK
75
+ * CTBCS_SW2_RESET_CT_OK
76
+ * CTBCS_SW2_RESET_ERROR
77
+ * CTBCS_SW2_RESET_SYNC_OK
78
+ * CTBCS_SW2_WRONG_CLA
79
+ * CTBCS_SW2_WRONG_INS
80
+ * CTBCS_SW2_WRONG_LENGTH
81
+ * CTBCS_SW2_WRONG_PARAM
82
+ * ERR_CT
83
+ * ERR_HTSI
84
+ * ERR_INVALID
85
+ * ERR_MEMORY
86
+ * ERR_TRANS
87
+ * HOST
88
+ * HTSIError
89
+ * ICC1
90
+ * ICC10
91
+ * ICC11
92
+ * ICC12
93
+ * ICC13
94
+ * ICC14
95
+ * ICC2
96
+ * ICC3
97
+ * ICC4
98
+ * ICC5
99
+ * ICC6
100
+ * ICC7
101
+ * ICC8
102
+ * ICC9
103
+ * MAX_APDULEN
104
+ * OK
105
+ * PORT_COM1
106
+ * PORT_COM2
107
+ * PORT_COM3
108
+ * PORT_COM4
109
+ * PORT_LPT1
110
+ * PORT_LPT2
111
+ * PORT_Modem
112
+ * PORT_Printer
113
+ */
114
+
115
+ #include "ruby.h"
116
+ #include <ctapi.h>
117
+
118
+ #define NUM2USHRT(n) NUM2UINT(n)
119
+
120
+ static VALUE mCTAPICore, eCTAPIError, eInvalidError, eCardterminalError,
121
+ eTransmissionError, eMemoryError, eHTSIError, eUnknownError;
122
+
123
+ /*
124
+ * Wrap the returned errors into a nice Ruby Exception and throw it.
125
+ */
126
+ void try(char rv) {
127
+ switch (rv) {
128
+ case OK:
129
+ return;
130
+ case ERR_INVALID:
131
+ rb_raise(eInvalidError, "Invalid Data: %d", rv);
132
+ case ERR_CT:
133
+ rb_raise(eCardterminalError, "Cardterminal Error: %d", rv);
134
+ case ERR_TRANS:
135
+ rb_raise(eTransmissionError, "Transmission Error: %d", rv);
136
+ case ERR_MEMORY:
137
+ rb_raise(eMemoryError, "Memory Allocate Error: %d", rv);
138
+ case ERR_HTSI:
139
+ rb_raise(eHTSIError, "Host Transport Service Interface Error:: %d",
140
+ rv); default:
141
+ rb_raise(eUnknownError, "Unknown Error: %d", rv);
142
+ }
143
+ }
144
+
145
+ /*
146
+ * We wrap CT_init to get the exceptions right.
147
+ */
148
+ void ct_init(unsigned short Ctn, unsigned short pn) {
149
+ try(CT_init(Ctn, pn));
150
+ }
151
+
152
+ /*
153
+ * Print the buffer (of length length) as byte sequence to stderr. This
154
+ * is used for debugging.
155
+ */
156
+ void
157
+ debug_command (unsigned char * buffer, unsigned length)
158
+ {
159
+ unsigned i;
160
+
161
+ if (length > 16)
162
+ fprintf (stderr, "\n");
163
+
164
+ for (i=0; i<length; i++)
165
+ {
166
+ fprintf (stderr, "%02X ", buffer[i]);
167
+ if (i%16 == 15)
168
+ fprintf (stderr, "\n");
169
+ }
170
+
171
+ if (i%16 != 0)
172
+ fprintf (stderr, "\n");
173
+ }
174
+
175
+ /*
176
+ * We wrap CT_data to get the exceptions and debugging right.
177
+ */
178
+ char *ct_data(
179
+ unsigned short Ctn, /* Terminal Number */
180
+ unsigned char dad, /* Destination */
181
+ unsigned char sad, /* Source */
182
+ unsigned char *cmd, /* Command/Data Buffer */
183
+ unsigned short lc, /* Length of Command */
184
+ unsigned short *lr /* Length of Response */
185
+ )
186
+ {
187
+ *lr = MAX_APDULEN;
188
+ unsigned char *rsp = ALLOC_N(unsigned char, *lr); /* Response */
189
+ #if DEBUG
190
+ debug_command(cmd, lc);
191
+ #endif
192
+ try(CT_data(Ctn, &dad, &sad, lc, cmd, lr, rsp));
193
+ #if DEBUG
194
+ debug_command(rsp, *lr);
195
+ #endif
196
+ return (char *) rsp;
197
+ }
198
+
199
+ /*
200
+ * We wrap CT_close to get the exceptions right.
201
+ */
202
+ void ct_close(unsigned short Ctn) {
203
+ try(CT_close(Ctn));
204
+ }
205
+
206
+ /*
207
+ * A wrapper function for the CT API CT_init(ctn, pn) function. The first
208
+ * argument is a cardterminal number, the second argument is an identifier for
209
+ * the interface as a portnumber. See ctapi(3) for more information.
210
+ */
211
+ static VALUE
212
+ ctapi_ct_init(int argc, VALUE *argv, VALUE self) {
213
+ unsigned short arg1 ;
214
+ unsigned short arg2 ;
215
+
216
+ if ((argc < 2) || (argc > 2))
217
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)", argc);
218
+ arg1 = NUM2USHRT(argv[0]);
219
+ arg2 = NUM2USHRT(argv[1]);
220
+ ct_init(arg1, arg2);
221
+
222
+ return Qnil;
223
+ }
224
+
225
+ /*
226
+ * A wrapper function for the CT API CT_data function. This one is
227
+ * much nicer than the original CT_data because is has fewer arguments:
228
+ * ct_data(ctn, dad, sad, cmd) where ctn is the cardterminal number,
229
+ * dad is the destination address number, sad is the source address number and
230
+ * cmd is the command as a String. See ctapi(3) for more information.
231
+ */
232
+ static VALUE
233
+ ctapi_ct_data(int argc, VALUE *argv, VALUE self) {
234
+ unsigned short arg1 ;
235
+ unsigned int arg2 ;
236
+ unsigned int arg3 ;
237
+ char *arg4 ;
238
+ unsigned short length;
239
+ char *result;
240
+ unsigned short lr;
241
+ VALUE vresult = Qnil;
242
+
243
+ if ((argc < 4) || (argc > 4))
244
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 4)", argc);
245
+ arg1 = NUM2USHRT(argv[0]);
246
+ arg2 = NUM2UINT(argv[1]);
247
+ arg3 = NUM2UINT(argv[2]);
248
+ arg4 = RSTRING(argv[3])->ptr;
249
+ length = RSTRING(argv[3])->len;
250
+ result = (char *) ct_data(arg1, arg2, arg3, arg4, length, &lr);
251
+ vresult = rb_str_new(result, lr);
252
+ ruby_xfree(result);
253
+ return vresult;
254
+ }
255
+
256
+ /*
257
+ * A wrapper function for the CT API CT_close(ctn) function. It takes a
258
+ * cardterminal number as the only argument. See ctapi(3) for more information.
259
+ */
260
+ static VALUE
261
+ ctapi_ct_close(int argc, VALUE *argv, VALUE self) {
262
+ unsigned short arg1 ;
263
+
264
+ if ((argc < 1) || (argc > 1))
265
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc);
266
+ arg1 = NUM2USHRT(argv[0]);
267
+ ct_close(arg1);
268
+
269
+ return Qnil;
270
+ }
271
+
272
+ void Init_ctapicore(void) {
273
+ mCTAPICore = rb_define_module("CTAPICore");
274
+ rb_define_const(mCTAPICore, "CTBCS_MIN_COMMAND_SIZE", INT2NUM(2));
275
+ rb_define_const(mCTAPICore, "CTBCS_MIN_RESPONSE_SIZE", INT2NUM(2));
276
+ rb_define_const(mCTAPICore, "CTBCS_CLA", INT2NUM(0x20));
277
+ rb_define_const(mCTAPICore, "CTBCS_INS_RESET", INT2NUM(0x11));
278
+ rb_define_const(mCTAPICore, "CTBCS_INS_REQUEST", INT2NUM(0x12));
279
+ rb_define_const(mCTAPICore, "CTBCS_INS_STATUS", INT2NUM(0x13));
280
+ rb_define_const(mCTAPICore, "CTBCS_INS_EJECT", INT2NUM(0x15));
281
+ rb_define_const(mCTAPICore, "CTBCS_P1_CT_KERNEL", INT2NUM(0x00));
282
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE1", INT2NUM(0x01));
283
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE2", INT2NUM(0x02));
284
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE3", INT2NUM(0x03));
285
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE4", INT2NUM(0x04));
286
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE5", INT2NUM(0x05));
287
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE6", INT2NUM(0x06));
288
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE7", INT2NUM(0x07));
289
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE8", INT2NUM(0x08));
290
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE9", INT2NUM(0x09));
291
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE10", INT2NUM(0x0A));
292
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE11", INT2NUM(0x0B));
293
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE12", INT2NUM(0x0C));
294
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE13", INT2NUM(0x0D));
295
+ rb_define_const(mCTAPICore, "CTBCS_P1_INTERFACE14", INT2NUM(0x0E));
296
+ rb_define_const(mCTAPICore, "CTBCS_P1_DISPLAY", INT2NUM(0x40));
297
+ rb_define_const(mCTAPICore, "CTBCS_P1_KEYPAD", INT2NUM(0x50));
298
+ rb_define_const(mCTAPICore, "CTBCS_P2_RESET_NO_RESP", INT2NUM(0x00));
299
+ rb_define_const(mCTAPICore, "CTBCS_P2_RESET_GET_ATR", INT2NUM(0x01));
300
+ rb_define_const(mCTAPICore, "CTBCS_P2_RESET_GET_HIST", INT2NUM(0x02));
301
+ rb_define_const(mCTAPICore, "CTBCS_P2_REQUEST_NO_RESP", INT2NUM(0x00));
302
+ rb_define_const(mCTAPICore, "CTBCS_P2_REQUEST_GET_ATR", INT2NUM(0x01));
303
+ rb_define_const(mCTAPICore, "CTBCS_P2_REQUEST_GET_HIST", INT2NUM(0x02));
304
+ rb_define_const(mCTAPICore, "CTBCS_P2_STATUS_MANUFACTURER", INT2NUM(0x46));
305
+ rb_define_const(mCTAPICore, "CTBCS_P2_STATUS_ICC", INT2NUM(0x80));
306
+ rb_define_const(mCTAPICore, "CTBCS_SW1_OK", INT2NUM(0x90));
307
+ rb_define_const(mCTAPICore, "CTBCS_SW2_OK", INT2NUM(0x00));
308
+ rb_define_const(mCTAPICore, "CTBCS_SW1_WRONG_LENGTH", INT2NUM(0x67));
309
+ rb_define_const(mCTAPICore, "CTBCS_SW2_WRONG_LENGTH", INT2NUM(0x00));
310
+ rb_define_const(mCTAPICore, "CTBCS_SW1_COMMAND_NOT_ALLOWED", INT2NUM(0x69));
311
+ rb_define_const(mCTAPICore, "CTBCS_SW2_COMMAND_NOT_ALLOWED", INT2NUM(0x00));
312
+ rb_define_const(mCTAPICore, "CTBCS_SW1_WRONG_PARAM", INT2NUM(0x6A));
313
+ rb_define_const(mCTAPICore, "CTBCS_SW2_WRONG_PARAM", INT2NUM(0x00));
314
+ rb_define_const(mCTAPICore, "CTBCS_SW1_WRONG_INS", INT2NUM(0x6D));
315
+ rb_define_const(mCTAPICore, "CTBCS_SW2_WRONG_INS", INT2NUM(0x00));
316
+ rb_define_const(mCTAPICore, "CTBCS_SW1_WRONG_CLA", INT2NUM(0x6E));
317
+ rb_define_const(mCTAPICore, "CTBCS_SW2_WRONG_CLA", INT2NUM(0x00));
318
+ rb_define_const(mCTAPICore, "CTBCS_SW1_ICC_ERROR", INT2NUM(0x6F));
319
+ rb_define_const(mCTAPICore, "CTBCS_SW2_ICC_ERROR", INT2NUM(0x00));
320
+ rb_define_const(mCTAPICore, "CTBCS_SW1_RESET_CT_OK", INT2NUM(0x90));
321
+ rb_define_const(mCTAPICore, "CTBCS_SW2_RESET_CT_OK", INT2NUM(0x00));
322
+ rb_define_const(mCTAPICore, "CTBCS_SW1_RESET_SYNC_OK", INT2NUM(0x90));
323
+ rb_define_const(mCTAPICore, "CTBCS_SW2_RESET_SYNC_OK", INT2NUM(0x00));
324
+ rb_define_const(mCTAPICore, "CTBCS_SW1_RESET_ASYNC_OK", INT2NUM(0x90));
325
+ rb_define_const(mCTAPICore, "CTBCS_SW2_RESET_ASYNC_OK", INT2NUM(0x01));
326
+ rb_define_const(mCTAPICore, "CTBCS_SW1_RESET_ERROR", INT2NUM(0x64));
327
+ rb_define_const(mCTAPICore, "CTBCS_SW2_RESET_ERROR", INT2NUM(0x00));
328
+ rb_define_const(mCTAPICore, "CTBCS_SW1_REQUEST_SYNC_OK", INT2NUM(0x90));
329
+ rb_define_const(mCTAPICore, "CTBCS_SW2_REQUEST_SYNC_OK", INT2NUM(0x00));
330
+ rb_define_const(mCTAPICore, "CTBCS_SW1_REQUEST_ASYNC_OK", INT2NUM(0x90));
331
+ rb_define_const(mCTAPICore, "CTBCS_SW2_REQUEST_ASYNC_OK", INT2NUM(0x01));
332
+ rb_define_const(mCTAPICore, "CTBCS_SW1_REQUEST_NO_CARD", INT2NUM(0x62));
333
+ rb_define_const(mCTAPICore, "CTBCS_SW2_REQUEST_NO_CARD", INT2NUM(0x00));
334
+ rb_define_const(mCTAPICore, "CTBCS_SW1_REQUEST_CARD_PRESENT", INT2NUM(0x62));
335
+ rb_define_const(mCTAPICore, "CTBCS_SW2_REQUEST_CARD_PRESENT", INT2NUM(0x01));
336
+ rb_define_const(mCTAPICore, "CTBCS_SW1_REQUEST_ERROR", INT2NUM(0x64));
337
+ rb_define_const(mCTAPICore, "CTBCS_SW2_REQUEST_ERROR", INT2NUM(0x00));
338
+ rb_define_const(mCTAPICore, "CTBCS_SW1_REQUEST_TIMER_ERROR", INT2NUM(0x69));
339
+ rb_define_const(mCTAPICore, "CTBCS_SW2_REQUEST_TIMER_ERROR", INT2NUM(0x00));
340
+ rb_define_const(mCTAPICore, "CTBCS_SW1_EJECT_OK", INT2NUM(0x90));
341
+ rb_define_const(mCTAPICore, "CTBCS_SW2_EJECT_OK", INT2NUM(0x00));
342
+ rb_define_const(mCTAPICore, "CTBCS_SW1_EJECT_REMOVED", INT2NUM(0x90));
343
+ rb_define_const(mCTAPICore, "CTBCS_SW2_EJECT_REMOVED", INT2NUM(0x01));
344
+ rb_define_const(mCTAPICore, "CTBCS_SW1_EJECT_NOT_REMOVED", INT2NUM(0x62));
345
+ rb_define_const(mCTAPICore, "CTBCS_SW2_EJECT_NOT_REMOVED", INT2NUM(0x00));
346
+ rb_define_const(mCTAPICore, "CTBCS_DATA_STATUS_NOCARD", INT2NUM(0x00));
347
+ rb_define_const(mCTAPICore, "CTBCS_DATA_STATUS_CARD", INT2NUM(0x01));
348
+ rb_define_const(mCTAPICore, "CTBCS_DATA_STATUS_CARD_CONNECT", INT2NUM(0x05));
349
+ rb_define_const(mCTAPICore, "MAX_APDULEN", INT2NUM(MAX_APDULEN));
350
+ rb_define_const(mCTAPICore, "OK", INT2NUM(0));
351
+ rb_define_const(mCTAPICore, "ERR_INVALID", INT2NUM(-1));
352
+ rb_define_const(mCTAPICore, "ERR_CT", INT2NUM(-8));
353
+ rb_define_const(mCTAPICore, "ERR_TRANS", INT2NUM(-10));
354
+ rb_define_const(mCTAPICore, "ERR_MEMORY", INT2NUM(-11));
355
+ rb_define_const(mCTAPICore, "ERR_HTSI", INT2NUM(-128));
356
+ /*
357
+ * Document-class: CTAPICore::CTAPIError
358
+ *
359
+ * All error exceptions in CTAPICore are of class CTAPIError which is a
360
+ * child of StandardError.
361
+ */
362
+ eCTAPIError =
363
+ rb_define_class_under(mCTAPICore, "CTAPIError", rb_eStandardError);
364
+ /*
365
+ * Document-class: CTAPICore::InvalidError
366
+ *
367
+ * This exception is raised if an invalid parameter was used for
368
+ * CTAPICore function.
369
+ */
370
+ eInvalidError =
371
+ rb_define_class_under(mCTAPICore, "InvalidError", eCTAPIError);
372
+ /*
373
+ * Document-class: CTAPICore::CardterminalError
374
+ *
375
+ * This exception is raised if the cardterminal is temporarily not
376
+ * accessible (busy with other or internal processes). The problem can
377
+ * be solved by the application. Just retry.
378
+ */
379
+ eCardterminalError =
380
+ rb_define_class_under(mCTAPICore, "CardterminalError", eCTAPIError);
381
+ /*
382
+ * Document-class: CTAPICore::TransmissionError
383
+ *
384
+ * This exception is raised if a mechanical, electrical or protocol
385
+ * failures. Reset of the cardterminal is necessary.
386
+ */
387
+ eTransmissionError =
388
+ rb_define_class_under(mCTAPICore, "TransmissionError", eCTAPIError);
389
+ /*
390
+ * Document-class: CTAPICore::MemoryError
391
+ *
392
+ * This exception is raised if a memory error occurred (f.i. the
393
+ * allocated buffer is too small for the returned data). This should
394
+ * NOT happen. If it does, it's a bug. Please tell me.
395
+ */
396
+ eMemoryError =
397
+ rb_define_class_under(mCTAPICore, "MemoryError", eCTAPIError);
398
+ /*
399
+ * Document-class: CTAPICore::HTSIError
400
+ *
401
+ * This exception (HTSI = Host Transport Service Interface) is raised if
402
+ * the error is produced by the software layer and not in the
403
+ * communication with the hardware.
404
+ */
405
+ eHTSIError =
406
+ rb_define_class_under(mCTAPICore, "HTSIError", eCTAPIError);
407
+ /*
408
+ * Document-class: CTAPICore::UnknownError
409
+ *
410
+ * This exception is raised if an unkown error occurrs. This also should
411
+ * NOT happen. If it does, it's a bug. Please tell me.
412
+ */
413
+ eUnknownError =
414
+ rb_define_class_under(mCTAPICore, "UnknownError", eCTAPIError);
415
+ rb_define_const(mCTAPICore, "PORT_COM1", INT2NUM(0));
416
+ rb_define_const(mCTAPICore, "PORT_COM2", INT2NUM(1));
417
+ rb_define_const(mCTAPICore, "PORT_COM3", INT2NUM(2));
418
+ rb_define_const(mCTAPICore, "PORT_COM4", INT2NUM(3));
419
+ rb_define_const(mCTAPICore, "PORT_Printer", INT2NUM(4));
420
+ rb_define_const(mCTAPICore, "PORT_Modem", INT2NUM(5));
421
+ rb_define_const(mCTAPICore, "PORT_LPT1", INT2NUM(6));
422
+ rb_define_const(mCTAPICore, "PORT_LPT2", INT2NUM(7));
423
+ rb_define_const(mCTAPICore, "CT", INT2NUM(1));
424
+ rb_define_const(mCTAPICore, "HOST", INT2NUM(2));
425
+ rb_define_const(mCTAPICore, "ICC1", INT2NUM(0));
426
+ rb_define_const(mCTAPICore, "ICC2", INT2NUM(2));
427
+ rb_define_const(mCTAPICore, "ICC3", INT2NUM(3));
428
+ rb_define_const(mCTAPICore, "ICC4", INT2NUM(4));
429
+ rb_define_const(mCTAPICore, "ICC5", INT2NUM(5));
430
+ rb_define_const(mCTAPICore, "ICC6", INT2NUM(6));
431
+ rb_define_const(mCTAPICore, "ICC7", INT2NUM(7));
432
+ rb_define_const(mCTAPICore, "ICC8", INT2NUM(8));
433
+ rb_define_const(mCTAPICore, "ICC9", INT2NUM(9));
434
+ rb_define_const(mCTAPICore, "ICC10", INT2NUM(10));
435
+ rb_define_const(mCTAPICore, "ICC11", INT2NUM(11));
436
+ rb_define_const(mCTAPICore, "ICC12", INT2NUM(12));
437
+ rb_define_const(mCTAPICore, "ICC13", INT2NUM(13));
438
+ rb_define_const(mCTAPICore, "ICC14", INT2NUM(14));
439
+ rb_define_module_function(mCTAPICore, "ct_init", ctapi_ct_init, -1);
440
+ rb_define_module_function(mCTAPICore, "ct_data", ctapi_ct_data, -1);
441
+ rb_define_module_function(mCTAPICore, "ct_close", ctapi_ct_close, -1);
442
+ }
443
+