rino 0.1.0 → 0.2.0

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.
Files changed (104) hide show
  1. data/Rakefile +1 -1
  2. data/ext/extconf.rb +1 -24
  3. data/ext/libinchi.so +0 -0
  4. data/ext/src/aux2atom.h +120 -39
  5. data/ext/src/comdef.h +3 -3
  6. data/ext/src/dispstru.c +2547 -0
  7. data/ext/src/dispstru.h +73 -0
  8. data/ext/src/extr_ct.h +5 -2
  9. data/ext/src/ichi.h +27 -11
  10. data/ext/src/ichi_bns.c +1800 -254
  11. data/ext/src/ichi_bns.h +205 -4
  12. data/ext/src/ichican2.c +197 -86
  13. data/ext/src/ichicano.c +8 -13
  14. data/ext/src/ichicano.h +2 -2
  15. data/ext/src/ichicans.c +11 -6
  16. data/ext/src/ichicant.h +2 -2
  17. data/ext/src/ichicomn.h +2 -2
  18. data/ext/src/ichicomp.h +19 -4
  19. data/ext/src/ichidrp.h +9 -5
  20. data/ext/src/ichierr.h +5 -3
  21. data/ext/src/ichiisot.c +2 -2
  22. data/ext/src/ichimain.c +461 -0
  23. data/ext/src/ichimain.h +23 -15
  24. data/ext/src/ichimak2.c +6 -6
  25. data/ext/src/ichimake.c +843 -42
  26. data/ext/src/ichimake.h +4 -2
  27. data/ext/src/ichimap1.c +5 -5
  28. data/ext/src/ichimap2.c +2 -2
  29. data/ext/src/ichimap4.c +34 -21
  30. data/ext/src/ichinorm.c +11 -5
  31. data/ext/src/ichinorm.h +3 -2
  32. data/ext/src/ichiparm.c +2 -2
  33. data/ext/src/ichiparm.h +232 -30
  34. data/ext/src/ichiprt1.c +35 -11
  35. data/ext/src/ichiprt2.c +78 -7
  36. data/ext/src/ichiprt3.c +300 -120
  37. data/ext/src/ichiqueu.c +17 -2
  38. data/ext/src/ichiread.c +6932 -0
  39. data/ext/src/ichiring.c +3 -2
  40. data/ext/src/ichiring.h +2 -2
  41. data/ext/src/ichirvr1.c +4891 -0
  42. data/ext/src/ichirvr2.c +6344 -0
  43. data/ext/src/ichirvr3.c +5499 -0
  44. data/ext/src/ichirvr4.c +3177 -0
  45. data/ext/src/ichirvr5.c +1166 -0
  46. data/ext/src/ichirvr6.c +1287 -0
  47. data/ext/src/ichirvr7.c +2319 -0
  48. data/ext/src/ichirvrs.h +882 -0
  49. data/ext/src/ichisize.h +2 -2
  50. data/ext/src/ichisort.c +5 -5
  51. data/ext/src/ichister.c +281 -86
  52. data/ext/src/ichister.h +9 -3
  53. data/ext/src/ichitaut.c +208 -9
  54. data/ext/src/ichitaut.h +13 -11
  55. data/ext/src/ichitime.h +16 -2
  56. data/ext/src/inchicmp.h +107 -0
  57. data/ext/src/inpdef.h +6 -3
  58. data/ext/src/libinchi_wrap.c +912 -0
  59. data/ext/src/lreadmol.h +34 -31
  60. data/ext/src/mode.h +244 -7
  61. data/ext/src/mol2atom.c +1060 -0
  62. data/ext/src/mol2atom.h +31 -0
  63. data/ext/src/readinch.c +239 -0
  64. data/ext/src/readmol.c +28 -0
  65. data/ext/src/{e_readmol.h → readmol.h} +7 -9
  66. data/ext/src/runichi.c +251 -177
  67. data/ext/src/strutil.c +444 -238
  68. data/ext/src/strutil.h +150 -11
  69. data/ext/src/util.c +176 -118
  70. data/ext/src/util.h +15 -3
  71. data/lib/rino.rb +71 -3
  72. data/test/test.rb +33 -4
  73. metadata +22 -34
  74. data/ext/ruby_inchi_main.so +0 -0
  75. data/ext/src/e_0dstereo.c +0 -3014
  76. data/ext/src/e_0dstereo.h +0 -31
  77. data/ext/src/e_comdef.h +0 -57
  78. data/ext/src/e_ctl_data.h +0 -147
  79. data/ext/src/e_ichi_io.c +0 -498
  80. data/ext/src/e_ichi_io.h +0 -40
  81. data/ext/src/e_ichi_parms.c +0 -37
  82. data/ext/src/e_ichi_parms.h +0 -41
  83. data/ext/src/e_ichicomp.h +0 -50
  84. data/ext/src/e_ichierr.h +0 -40
  85. data/ext/src/e_ichimain.c +0 -593
  86. data/ext/src/e_ichisize.h +0 -43
  87. data/ext/src/e_inchi_atom.c +0 -75
  88. data/ext/src/e_inchi_atom.h +0 -33
  89. data/ext/src/e_inpdef.h +0 -41
  90. data/ext/src/e_mode.h +0 -706
  91. data/ext/src/e_mol2atom.c +0 -649
  92. data/ext/src/e_readinch.c +0 -58
  93. data/ext/src/e_readmol.c +0 -54
  94. data/ext/src/e_readstru.c +0 -251
  95. data/ext/src/e_readstru.h +0 -33
  96. data/ext/src/e_util.c +0 -284
  97. data/ext/src/e_util.h +0 -61
  98. data/ext/src/ichilnct.c +0 -286
  99. data/ext/src/inchi_api.h +0 -670
  100. data/ext/src/inchi_dll.c +0 -1480
  101. data/ext/src/inchi_dll.h +0 -34
  102. data/ext/src/inchi_dll_main.c +0 -23
  103. data/ext/src/inchi_dll_main.h +0 -31
  104. data/ext/src/ruby_inchi_main.c +0 -558
@@ -2,8 +2,8 @@
2
2
  * International Union of Pure and Applied Chemistry (IUPAC)
3
3
  * International Chemical Identifier (InChI)
4
4
  * Version 1
5
- * Software version 1.00
6
- * April 13, 2005
5
+ * Software version 1.01
6
+ * July 21, 2006
7
7
  * Developed at NIST
8
8
  */
9
9
 
@@ -274,7 +274,8 @@ int DisconnectSalts( ORIG_ATOM_DATA *orig_inp_data, int bDisconnect );
274
274
  int DisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, int bCheckMetalValence, INCHI_MODE *bTautFlagsDone );
275
275
  int bMayDisconnectMetals( ORIG_ATOM_DATA *orig_inp_data, int bCheckMetalValence, INCHI_MODE *bTautFlagsDone );
276
276
  int bHasMetalAtom( ORIG_ATOM_DATA *orig_inp_data );
277
- int fix_odd_things( int num_atoms, inp_ATOM *at );
277
+ int FixAdjacentRadicals( int num_inp_atoms, inp_ATOM *at ); /* FIX_ADJ_RAD == 1 */
278
+ int fix_odd_things( int num_atoms, inp_ATOM *at, int bFixBug );
278
279
  int post_fix_odd_things( int num_atoms, inp_ATOM *at );
279
280
  int remove_ion_pairs( int num_atoms, inp_ATOM *at );
280
281
 
@@ -288,6 +289,8 @@ void FreeInpAtomData( INP_ATOM_DATA *inp_at_data );
288
289
  void FreeCompAtomData( COMP_ATOM_DATA *inp_at_data );
289
290
  void FreeInfoAtomData( INF_ATOM_DATA *inf_at_data );
290
291
 
292
+ int FixUnkn0DStereoBonds(inp_ATOM *at, int num_at);
293
+
291
294
  inf_ATOM *CreateInfAtom( int num_atoms );
292
295
  inp_ATOM *CreateInpAtom( int num_atoms );
293
296
 
@@ -0,0 +1,912 @@
1
+ /* ----------------------------------------------------------------------------
2
+ * This file was automatically generated by SWIG (http://www.swig.org).
3
+ * Version 1.3.24
4
+ *
5
+ * This file is not intended to be easily readable and contains a number of
6
+ * coding conventions designed to improve portability and efficiency. Do not make
7
+ * changes to this file unless you know what you are doing--modify the SWIG
8
+ * interface file instead.
9
+ * ----------------------------------------------------------------------------- */
10
+
11
+
12
+ #ifndef SWIG_TEMPLATE_DISAMBIGUATOR
13
+ # if defined(__SUNPRO_CC)
14
+ # define SWIG_TEMPLATE_DISAMBIGUATOR template
15
+ # else
16
+ # define SWIG_TEMPLATE_DISAMBIGUATOR
17
+ # endif
18
+ #endif
19
+
20
+ /* ruby.swg */
21
+ /* Implementation : RUBY */
22
+ #define SWIGRUBY 1
23
+
24
+ #include "ruby.h"
25
+
26
+ /* Flags for pointer conversion */
27
+ #define SWIG_POINTER_EXCEPTION 0x1
28
+ #define SWIG_POINTER_DISOWN 0x2
29
+
30
+ #define NUM2USHRT(n) (\
31
+ (0 <= NUM2UINT(n) && NUM2UINT(n) <= USHRT_MAX)\
32
+ ? (unsigned short) NUM2UINT(n) \
33
+ : (rb_raise(rb_eArgError, "integer %d out of range of `unsigned short'",\
34
+ NUM2UINT(n)), (short)0)\
35
+ )
36
+
37
+ #define NUM2SHRT(n) (\
38
+ (SHRT_MIN <= NUM2INT(n) && NUM2INT(n) <= SHRT_MAX)\
39
+ ? (short)NUM2INT(n)\
40
+ : (rb_raise(rb_eArgError, "integer %d out of range of `short'",\
41
+ NUM2INT(n)), (short)0)\
42
+ )
43
+
44
+ /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */
45
+ #ifndef NUM2LL
46
+ #define NUM2LL(x) NUM2LONG((x))
47
+ #endif
48
+ #ifndef LL2NUM
49
+ #define LL2NUM(x) INT2NUM((long) (x))
50
+ #endif
51
+ #ifndef ULL2NUM
52
+ #define ULL2NUM(x) UINT2NUM((unsigned long) (x))
53
+ #endif
54
+
55
+ /* Ruby 1.7 doesn't (yet) define NUM2ULL() */
56
+ #ifndef NUM2ULL
57
+ #ifdef HAVE_LONG_LONG
58
+ #define NUM2ULL(x) rb_num2ull((x))
59
+ #else
60
+ #define NUM2ULL(x) NUM2ULONG(x)
61
+ #endif
62
+ #endif
63
+
64
+ /*
65
+ * Need to be very careful about how these macros are defined, especially
66
+ * when compiling C++ code or C code with an ANSI C compiler.
67
+ *
68
+ * VALUEFUNC(f) is a macro used to typecast a C function that implements
69
+ * a Ruby method so that it can be passed as an argument to API functions
70
+ * like rb_define_method() and rb_define_singleton_method().
71
+ *
72
+ * VOIDFUNC(f) is a macro used to typecast a C function that implements
73
+ * either the "mark" or "free" stuff for a Ruby Data object, so that it
74
+ * can be passed as an argument to API functions like Data_Wrap_Struct()
75
+ * and Data_Make_Struct().
76
+ */
77
+
78
+ #ifdef __cplusplus
79
+ # ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */
80
+ # define PROTECTFUNC(f) ((VALUE (*)()) f)
81
+ # define VALUEFUNC(f) ((VALUE (*)()) f)
82
+ # define VOIDFUNC(f) ((void (*)()) f)
83
+ # else
84
+ # ifndef ANYARGS /* These definitions should work for Ruby 1.6 */
85
+ # define PROTECTFUNC(f) ((VALUE (*)()) f)
86
+ # define VALUEFUNC(f) ((VALUE (*)()) f)
87
+ # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
88
+ # else /* These definitions should work for Ruby 1.7+ */
89
+ # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
90
+ # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
91
+ # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
92
+ # endif
93
+ # endif
94
+ #else
95
+ # define VALUEFUNC(f) (f)
96
+ # define VOIDFUNC(f) (f)
97
+ #endif
98
+
99
+ typedef struct {
100
+ VALUE klass;
101
+ VALUE mImpl;
102
+ void (*mark)(void *);
103
+ void (*destroy)(void *);
104
+ } swig_class;
105
+
106
+ /* Don't use for expressions have side effect */
107
+ #ifndef RB_STRING_VALUE
108
+ #define RB_STRING_VALUE(s) (TYPE(s) == T_STRING ? (s) : (*(volatile VALUE *)&(s) = rb_str_to_str(s)))
109
+ #endif
110
+ #ifndef StringValue
111
+ #define StringValue(s) RB_STRING_VALUE(s)
112
+ #endif
113
+ #ifndef StringValuePtr
114
+ #define StringValuePtr(s) RSTRING(RB_STRING_VALUE(s))->ptr
115
+ #endif
116
+ #ifndef StringValueLen
117
+ #define StringValueLen(s) RSTRING(RB_STRING_VALUE(s))->len
118
+ #endif
119
+ #ifndef SafeStringValue
120
+ #define SafeStringValue(v) do {\
121
+ StringValue(v);\
122
+ rb_check_safe_str(v);\
123
+ } while (0)
124
+ #endif
125
+
126
+ #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
127
+ #define rb_define_alloc_func(klass, func) rb_define_singleton_method((klass), "new", VALUEFUNC((func)), -1)
128
+ #define rb_undef_alloc_func(klass) rb_undef_method(CLASS_OF((klass)), "new")
129
+ #endif
130
+
131
+ /* Contract support */
132
+
133
+ #define SWIG_contract_assert(expr, msg) if (!(expr)) { rb_raise(rb_eRuntimeError, (char *) msg ); } else
134
+
135
+
136
+ /***********************************************************************
137
+ * swigrun.swg
138
+ *
139
+ * This file contains generic CAPI SWIG runtime support for pointer
140
+ * type checking.
141
+ *
142
+ ************************************************************************/
143
+
144
+ /* This should only be incremented when either the layout of swig_type_info changes,
145
+ or for whatever reason, the runtime changes incompatibly */
146
+ #define SWIG_RUNTIME_VERSION "1"
147
+
148
+ /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
149
+ #ifdef SWIG_TYPE_TABLE
150
+ #define SWIG_QUOTE_STRING(x) #x
151
+ #define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
152
+ #define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
153
+ #else
154
+ #define SWIG_TYPE_TABLE_NAME
155
+ #endif
156
+
157
+ #include <string.h>
158
+
159
+ #ifndef SWIGINLINE
160
+ #if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
161
+ # define SWIGINLINE inline
162
+ #else
163
+ # define SWIGINLINE
164
+ #endif
165
+ #endif
166
+
167
+ /*
168
+ You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
169
+ creating a static or dynamic library from the swig runtime code.
170
+ In 99.9% of the cases, swig just needs to declare them as 'static'.
171
+
172
+ But only do this if is strictly necessary, ie, if you have problems
173
+ with your compiler or so.
174
+ */
175
+ #ifndef SWIGRUNTIME
176
+ #define SWIGRUNTIME static
177
+ #endif
178
+ #ifndef SWIGRUNTIMEINLINE
179
+ #define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
180
+ #endif
181
+
182
+ #ifdef __cplusplus
183
+ extern "C" {
184
+ #endif
185
+
186
+ typedef void *(*swig_converter_func)(void *);
187
+ typedef struct swig_type_info *(*swig_dycast_func)(void **);
188
+
189
+ typedef struct swig_type_info {
190
+ const char *name;
191
+ swig_converter_func converter;
192
+ const char *str;
193
+ void *clientdata;
194
+ swig_dycast_func dcast;
195
+ struct swig_type_info *next;
196
+ struct swig_type_info *prev;
197
+ } swig_type_info;
198
+
199
+ /*
200
+ Compare two type names skipping the space characters, therefore
201
+ "char*" == "char *" and "Class<int>" == "Class<int >", etc.
202
+
203
+ Return 0 when the two name types are equivalent, as in
204
+ strncmp, but skipping ' '.
205
+ */
206
+ SWIGRUNTIME int
207
+ SWIG_TypeNameComp(const char *f1, const char *l1,
208
+ const char *f2, const char *l2) {
209
+ for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
210
+ while ((*f1 == ' ') && (f1 != l1)) ++f1;
211
+ while ((*f2 == ' ') && (f2 != l2)) ++f2;
212
+ if (*f1 != *f2) return *f1 - *f2;
213
+ }
214
+ return (l1 - f1) - (l2 - f2);
215
+ }
216
+
217
+ /*
218
+ Check type equivalence in a name list like <name1>|<name2>|...
219
+ */
220
+ SWIGRUNTIME int
221
+ SWIG_TypeEquiv(const char *nb, const char *tb) {
222
+ int equiv = 0;
223
+ const char* te = tb + strlen(tb);
224
+ const char* ne = nb;
225
+ while (!equiv && *ne) {
226
+ for (nb = ne; *ne; ++ne) {
227
+ if (*ne == '|') break;
228
+ }
229
+ equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0;
230
+ if (*ne) ++ne;
231
+ }
232
+ return equiv;
233
+ }
234
+
235
+ /*
236
+ Register a type mapping with the type-checking
237
+ */
238
+ SWIGRUNTIME swig_type_info *
239
+ SWIG_TypeRegisterTL(swig_type_info **tl, swig_type_info *ti) {
240
+ swig_type_info *tc, *head, *ret, *next;
241
+ /* Check to see if this type has already been registered */
242
+ tc = *tl;
243
+ while (tc) {
244
+ /* check simple type equivalence */
245
+ int typeequiv = (strcmp(tc->name, ti->name) == 0);
246
+ /* check full type equivalence, resolving typedefs */
247
+ if (!typeequiv) {
248
+ /* only if tc is not a typedef (no '|' on it) */
249
+ if (tc->str && ti->str && !strstr(tc->str,"|")) {
250
+ typeequiv = SWIG_TypeEquiv(ti->str,tc->str);
251
+ }
252
+ }
253
+ if (typeequiv) {
254
+ /* Already exists in the table. Just add additional types to the list */
255
+ if (ti->clientdata) tc->clientdata = ti->clientdata;
256
+ head = tc;
257
+ next = tc->next;
258
+ goto l1;
259
+ }
260
+ tc = tc->prev;
261
+ }
262
+ head = ti;
263
+ next = 0;
264
+
265
+ /* Place in list */
266
+ ti->prev = *tl;
267
+ *tl = ti;
268
+
269
+ /* Build linked lists */
270
+ l1:
271
+ ret = head;
272
+ tc = ti + 1;
273
+ /* Patch up the rest of the links */
274
+ while (tc->name) {
275
+ head->next = tc;
276
+ tc->prev = head;
277
+ head = tc;
278
+ tc++;
279
+ }
280
+ if (next) next->prev = head;
281
+ head->next = next;
282
+
283
+ return ret;
284
+ }
285
+
286
+ /*
287
+ Check the typename
288
+ */
289
+ SWIGRUNTIME swig_type_info *
290
+ SWIG_TypeCheck(const char *c, swig_type_info *ty) {
291
+ swig_type_info *s;
292
+ if (!ty) return 0; /* Void pointer */
293
+ s = ty->next; /* First element always just a name */
294
+ do {
295
+ if (strcmp(s->name,c) == 0) {
296
+ if (s == ty->next) return s;
297
+ /* Move s to the top of the linked list */
298
+ s->prev->next = s->next;
299
+ if (s->next) {
300
+ s->next->prev = s->prev;
301
+ }
302
+ /* Insert s as second element in the list */
303
+ s->next = ty->next;
304
+ if (ty->next) ty->next->prev = s;
305
+ ty->next = s;
306
+ s->prev = ty;
307
+ return s;
308
+ }
309
+ s = s->next;
310
+ } while (s && (s != ty->next));
311
+ return 0;
312
+ }
313
+
314
+ /*
315
+ Cast a pointer up an inheritance hierarchy
316
+ */
317
+ SWIGRUNTIMEINLINE void *
318
+ SWIG_TypeCast(swig_type_info *ty, void *ptr) {
319
+ return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
320
+ }
321
+
322
+ /*
323
+ Dynamic pointer casting. Down an inheritance hierarchy
324
+ */
325
+ SWIGRUNTIME swig_type_info *
326
+ SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
327
+ swig_type_info *lastty = ty;
328
+ if (!ty || !ty->dcast) return ty;
329
+ while (ty && (ty->dcast)) {
330
+ ty = (*ty->dcast)(ptr);
331
+ if (ty) lastty = ty;
332
+ }
333
+ return lastty;
334
+ }
335
+
336
+ /*
337
+ Return the name associated with this type
338
+ */
339
+ SWIGRUNTIMEINLINE const char *
340
+ SWIG_TypeName(const swig_type_info *ty) {
341
+ return ty->name;
342
+ }
343
+
344
+ /*
345
+ Return the pretty name associated with this type,
346
+ that is an unmangled type name in a form presentable to the user.
347
+ */
348
+ SWIGRUNTIME const char *
349
+ SWIG_TypePrettyName(const swig_type_info *type) {
350
+ /* The "str" field contains the equivalent pretty names of the
351
+ type, separated by vertical-bar characters. We choose
352
+ to print the last name, as it is often (?) the most
353
+ specific. */
354
+ if (type->str != NULL) {
355
+ const char *last_name = type->str;
356
+ const char *s;
357
+ for (s = type->str; *s; s++)
358
+ if (*s == '|') last_name = s+1;
359
+ return last_name;
360
+ }
361
+ else
362
+ return type->name;
363
+ }
364
+
365
+ /*
366
+ Search for a swig_type_info structure
367
+ */
368
+ SWIGRUNTIME swig_type_info *
369
+ SWIG_TypeQueryTL(swig_type_info *tl, const char *name) {
370
+ swig_type_info *ty = tl;
371
+ while (ty) {
372
+ if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty;
373
+ if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
374
+ ty = ty->prev;
375
+ }
376
+ return 0;
377
+ }
378
+
379
+ /*
380
+ Set the clientdata field for a type
381
+ */
382
+ SWIGRUNTIME void
383
+ SWIG_TypeClientDataTL(swig_type_info *tl, swig_type_info *ti, void *clientdata) {
384
+ swig_type_info *tc, *equiv;
385
+ if (ti->clientdata) return;
386
+ /* if (ti->clientdata == clientdata) return; */
387
+ ti->clientdata = clientdata;
388
+ equiv = ti->next;
389
+ while (equiv) {
390
+ if (!equiv->converter) {
391
+ tc = tl;
392
+ while (tc) {
393
+ if ((strcmp(tc->name, equiv->name) == 0))
394
+ SWIG_TypeClientDataTL(tl,tc,clientdata);
395
+ tc = tc->prev;
396
+ }
397
+ }
398
+ equiv = equiv->next;
399
+ }
400
+ }
401
+
402
+ /*
403
+ Pack binary data into a string
404
+ */
405
+ SWIGRUNTIME char *
406
+ SWIG_PackData(char *c, void *ptr, size_t sz) {
407
+ static char hex[17] = "0123456789abcdef";
408
+ unsigned char *u = (unsigned char *) ptr;
409
+ const unsigned char *eu = u + sz;
410
+ register unsigned char uu;
411
+ for (; u != eu; ++u) {
412
+ uu = *u;
413
+ *(c++) = hex[(uu & 0xf0) >> 4];
414
+ *(c++) = hex[uu & 0xf];
415
+ }
416
+ return c;
417
+ }
418
+
419
+ /*
420
+ Unpack binary data from a string
421
+ */
422
+ SWIGRUNTIME const char *
423
+ SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
424
+ register unsigned char *u = (unsigned char *) ptr;
425
+ register const unsigned char *eu = u + sz;
426
+ for (; u != eu; ++u) {
427
+ register int d = *(c++);
428
+ register unsigned char uu = 0;
429
+ if ((d >= '0') && (d <= '9'))
430
+ uu = ((d - '0') << 4);
431
+ else if ((d >= 'a') && (d <= 'f'))
432
+ uu = ((d - ('a'-10)) << 4);
433
+ else
434
+ return (char *) 0;
435
+ d = *(c++);
436
+ if ((d >= '0') && (d <= '9'))
437
+ uu |= (d - '0');
438
+ else if ((d >= 'a') && (d <= 'f'))
439
+ uu |= (d - ('a'-10));
440
+ else
441
+ return (char *) 0;
442
+ *u = uu;
443
+ }
444
+ return c;
445
+ }
446
+
447
+ /*
448
+ This function will propagate the clientdata field of type to any new
449
+ swig_type_info structures that have been added into the list of
450
+ equivalent types. It is like calling SWIG_TypeClientData(type,
451
+ clientdata) a second time.
452
+ */
453
+ SWIGRUNTIME void
454
+ SWIG_PropagateClientDataTL(swig_type_info *tl, swig_type_info *type) {
455
+ swig_type_info *equiv = type->next;
456
+ swig_type_info *tc;
457
+ if (!type->clientdata) return;
458
+ while (equiv) {
459
+ if (!equiv->converter) {
460
+ tc = tl;
461
+ while (tc) {
462
+ if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata)
463
+ SWIG_TypeClientDataTL(tl,tc, type->clientdata);
464
+ tc = tc->prev;
465
+ }
466
+ }
467
+ equiv = equiv->next;
468
+ }
469
+ }
470
+
471
+ /*
472
+ Pack 'void *' into a string buffer.
473
+ */
474
+ SWIGRUNTIME char *
475
+ SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
476
+ char *r = buff;
477
+ if ((2*sizeof(void *) + 2) > bsz) return 0;
478
+ *(r++) = '_';
479
+ r = SWIG_PackData(r,&ptr,sizeof(void *));
480
+ if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
481
+ strcpy(r,name);
482
+ return buff;
483
+ }
484
+
485
+ SWIGRUNTIME const char *
486
+ SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
487
+ if (*c != '_') {
488
+ if (strcmp(c,"NULL") == 0) {
489
+ *ptr = (void *) 0;
490
+ return name;
491
+ } else {
492
+ return 0;
493
+ }
494
+ }
495
+ return SWIG_UnpackData(++c,ptr,sizeof(void *));
496
+ }
497
+
498
+ SWIGRUNTIME char *
499
+ SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
500
+ char *r = buff;
501
+ size_t lname = (name ? strlen(name) : 0);
502
+ if ((2*sz + 2 + lname) > bsz) return 0;
503
+ *(r++) = '_';
504
+ r = SWIG_PackData(r,ptr,sz);
505
+ if (lname) {
506
+ strncpy(r,name,lname+1);
507
+ } else {
508
+ *r = 0;
509
+ }
510
+ return buff;
511
+ }
512
+
513
+ SWIGRUNTIME const char *
514
+ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
515
+ if (*c != '_') {
516
+ if (strcmp(c,"NULL") == 0) {
517
+ memset(ptr,0,sz);
518
+ return name;
519
+ } else {
520
+ return 0;
521
+ }
522
+ }
523
+ return SWIG_UnpackData(++c,ptr,sz);
524
+ }
525
+
526
+ #ifdef __cplusplus
527
+ }
528
+ #endif
529
+
530
+ /***********************************************************************
531
+ * common.swg
532
+ *
533
+ * This file contains generic SWIG runtime support for pointer
534
+ * type checking as well as a few commonly used macros to control
535
+ * external linkage.
536
+ *
537
+ * Author : David Beazley (beazley@cs.uchicago.edu)
538
+ *
539
+ * Copyright (c) 1999-2000, The University of Chicago
540
+ *
541
+ * This file may be freely redistributed without license or fee provided
542
+ * this copyright message remains intact.
543
+ ************************************************************************/
544
+
545
+
546
+ #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
547
+ # if !defined(STATIC_LINKED)
548
+ # define SWIGEXPORT(a) __declspec(dllexport) a
549
+ # else
550
+ # define SWIGEXPORT(a) a
551
+ # endif
552
+ #else
553
+ # define SWIGEXPORT(a) a
554
+ #endif
555
+
556
+ #ifdef __cplusplus
557
+ extern "C" {
558
+ #endif
559
+
560
+
561
+ /*************************************************************************/
562
+
563
+
564
+ /* The static type info list */
565
+
566
+ static swig_type_info *swig_type_list = 0;
567
+ static swig_type_info **swig_type_list_handle = &swig_type_list;
568
+
569
+
570
+ /* Register a type mapping with the type-checking */
571
+ static swig_type_info *
572
+ SWIG_TypeRegister(swig_type_info *ti) {
573
+ return SWIG_TypeRegisterTL(swig_type_list_handle, ti);
574
+ }
575
+
576
+ /* Search for a swig_type_info structure */
577
+ static swig_type_info *
578
+ SWIG_TypeQuery(const char *name) {
579
+ return SWIG_TypeQueryTL(*swig_type_list_handle, name);
580
+ }
581
+
582
+ /* Set the clientdata field for a type */
583
+ static void
584
+ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
585
+ SWIG_TypeClientDataTL(*swig_type_list_handle, ti, clientdata);
586
+ }
587
+
588
+ /* This function will propagate the clientdata field of type to
589
+ * any new swig_type_info structures that have been added into the list
590
+ * of equivalent types. It is like calling
591
+ * SWIG_TypeClientData(type, clientdata) a second time.
592
+ */
593
+ static void
594
+ SWIG_PropagateClientData(swig_type_info *type) {
595
+ SWIG_PropagateClientDataTL(*swig_type_list_handle, type);
596
+ }
597
+
598
+ #ifdef __cplusplus
599
+ }
600
+ #endif
601
+
602
+ /* Common SWIG API */
603
+ #define SWIG_ConvertPtr(obj, pp, type, flags) \
604
+ SWIG_Ruby_ConvertPtr(obj, pp, type, flags)
605
+ #define SWIG_NewPointerObj(p, type, flags) \
606
+ SWIG_Ruby_NewPointerObj(p, type, flags)
607
+ #define SWIG_MustGetPtr(p, type, argnum, flags) \
608
+ SWIG_Ruby_MustGetPtr(p, type, argnum, flags)
609
+
610
+ /* Ruby-specific SWIG API */
611
+
612
+ #define SWIG_InitRuntime() \
613
+ SWIG_Ruby_InitRuntime()
614
+ #define SWIG_define_class(ty) \
615
+ SWIG_Ruby_define_class(ty)
616
+ #define SWIG_NewClassInstance(value, ty) \
617
+ SWIG_Ruby_NewClassInstance(value, ty)
618
+ #define SWIG_MangleStr(value) \
619
+ SWIG_Ruby_MangleStr(value)
620
+ #define SWIG_CheckConvert(value, ty) \
621
+ SWIG_Ruby_CheckConvert(value, ty)
622
+ #define SWIG_NewPackedObj(ptr, sz, ty) \
623
+ SWIG_Ruby_NewPackedObj(ptr, sz, ty)
624
+ #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) \
625
+ SWIG_Ruby_ConvertPacked(obj, ptr, sz, ty, flags)
626
+
627
+ /* rubydef.swg */
628
+ #ifdef __cplusplus
629
+ extern "C" {
630
+ #endif
631
+
632
+ static VALUE _mSWIG = Qnil;
633
+ static VALUE _cSWIG_Pointer = Qnil;
634
+ static VALUE swig_runtime_data_type_pointer = Qnil;
635
+
636
+ /* Initialize Ruby runtime support */
637
+ static void
638
+ SWIG_Ruby_InitRuntime(void)
639
+ {
640
+ VALUE pointer;
641
+
642
+ if (_mSWIG == Qnil) {
643
+ _mSWIG = rb_define_module("SWIG");
644
+ }
645
+
646
+ /* first check if pointer already created */
647
+ pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
648
+ if (pointer != Qnil) {
649
+ Data_Get_Struct(pointer, swig_type_info *, swig_type_list_handle);
650
+ } else {
651
+ /* register a new class */
652
+ VALUE cl = rb_define_class("swig_runtime_data", rb_cObject);
653
+ /* create and store the structure pointer to a global variable */
654
+ swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, swig_type_list_handle);
655
+ rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
656
+ }
657
+ }
658
+
659
+ /* Define Ruby class for C type */
660
+ static void
661
+ SWIG_Ruby_define_class(swig_type_info *type)
662
+ {
663
+ VALUE klass;
664
+ char *klass_name = (char *) malloc(4 + strlen(type->name) + 1);
665
+ sprintf(klass_name, "TYPE%s", type->name);
666
+ if (NIL_P(_cSWIG_Pointer)) {
667
+ _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
668
+ rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
669
+ }
670
+ klass = rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
671
+ free((void *) klass_name);
672
+ }
673
+
674
+ /* Create a new pointer object */
675
+ static VALUE
676
+ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int own)
677
+ {
678
+ char *klass_name;
679
+ swig_class *sklass;
680
+ VALUE klass;
681
+ VALUE obj;
682
+
683
+ if (!ptr)
684
+ return Qnil;
685
+
686
+ if (type->clientdata) {
687
+ sklass = (swig_class *) type->clientdata;
688
+ obj = Data_Wrap_Struct(sklass->klass, VOIDFUNC(sklass->mark), (own ? VOIDFUNC(sklass->destroy) : 0), ptr);
689
+ } else {
690
+ klass_name = (char *) malloc(4 + strlen(type->name) + 1);
691
+ sprintf(klass_name, "TYPE%s", type->name);
692
+ klass = rb_const_get(_mSWIG, rb_intern(klass_name));
693
+ free((void *) klass_name);
694
+ obj = Data_Wrap_Struct(klass, 0, 0, ptr);
695
+ }
696
+ rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name));
697
+ return obj;
698
+ }
699
+
700
+ /* Create a new class instance (always owned) */
701
+ static VALUE
702
+ SWIG_Ruby_NewClassInstance(VALUE klass, swig_type_info *type)
703
+ {
704
+ VALUE obj;
705
+ swig_class *sklass = (swig_class *) type->clientdata;
706
+ obj = Data_Wrap_Struct(klass, VOIDFUNC(sklass->mark), VOIDFUNC(sklass->destroy), 0);
707
+ rb_iv_set(obj, "__swigtype__", rb_str_new2(type->name));
708
+ return obj;
709
+ }
710
+
711
+ /* Get type mangle from class name */
712
+ static SWIGINLINE char *
713
+ SWIG_Ruby_MangleStr(VALUE obj)
714
+ {
715
+ VALUE stype = rb_iv_get(obj, "__swigtype__");
716
+ return StringValuePtr(stype);
717
+ }
718
+
719
+ /* Convert a pointer value */
720
+ static int
721
+ SWIG_Ruby_ConvertPtr(VALUE obj, void **ptr, swig_type_info *ty, int flags)
722
+ {
723
+ char *c;
724
+ swig_type_info *tc;
725
+
726
+ /* Grab the pointer */
727
+ if (NIL_P(obj)) {
728
+ *ptr = 0;
729
+ return 0;
730
+ } else {
731
+ Data_Get_Struct(obj, void, *ptr);
732
+ }
733
+
734
+ /* Do type-checking if type info was provided */
735
+ if (ty) {
736
+ if (ty->clientdata) {
737
+ if (rb_obj_is_kind_of(obj, ((swig_class *) (ty->clientdata))->klass)) {
738
+ if (*ptr == 0)
739
+ rb_raise(rb_eRuntimeError, "This %s already released", ty->str);
740
+ return 0;
741
+ }
742
+ }
743
+ if ((c = SWIG_MangleStr(obj)) == NULL) {
744
+ if (flags & SWIG_POINTER_EXCEPTION)
745
+ rb_raise(rb_eTypeError, "Expected %s", ty->str);
746
+ else
747
+ return -1;
748
+ }
749
+ tc = SWIG_TypeCheck(c, ty);
750
+ if (!tc) {
751
+ if (flags & SWIG_POINTER_EXCEPTION)
752
+ rb_raise(rb_eTypeError, "Expected %s", ty->str);
753
+ else
754
+ return -1;
755
+ }
756
+ *ptr = SWIG_TypeCast(tc, *ptr);
757
+ }
758
+ return 0;
759
+ }
760
+
761
+ /* Convert a pointer value, signal an exception on a type mismatch */
762
+ static SWIGINLINE void *
763
+ SWIG_Ruby_MustGetPtr(VALUE obj, swig_type_info *ty, int argnum, int flags)
764
+ {
765
+ void *result;
766
+ SWIG_ConvertPtr(obj, &result, ty, flags | SWIG_POINTER_EXCEPTION);
767
+ return result;
768
+ }
769
+
770
+ /* Check convert */
771
+ static SWIGINLINE int
772
+ SWIG_Ruby_CheckConvert(VALUE obj, swig_type_info *ty)
773
+ {
774
+ char *c = SWIG_MangleStr(obj);
775
+ if (!c)
776
+ return 0;
777
+ return SWIG_TypeCheck(c,ty) != 0;
778
+ }
779
+
780
+ static VALUE
781
+ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
782
+ char result[1024];
783
+ char *r = result;
784
+ if ((2*sz + 1 + strlen(type->name)) > 1000) return 0;
785
+ *(r++) = '_';
786
+ r = SWIG_PackData(r, ptr, sz);
787
+ strcpy(r, type->name);
788
+ return rb_str_new2(result);
789
+ }
790
+
791
+ /* Convert a packed value value */
792
+ static void
793
+ SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty, int flags) {
794
+ swig_type_info *tc;
795
+ const char *c;
796
+
797
+ if (TYPE(obj) != T_STRING) goto type_error;
798
+ c = StringValuePtr(obj);
799
+ /* Pointer values must start with leading underscore */
800
+ if (*c != '_') goto type_error;
801
+ c++;
802
+ c = SWIG_UnpackData(c, ptr, sz);
803
+ if (ty) {
804
+ tc = SWIG_TypeCheck(c, ty);
805
+ if (!tc) goto type_error;
806
+ }
807
+ return;
808
+
809
+ type_error:
810
+
811
+ if (flags) {
812
+ if (ty) {
813
+ rb_raise(rb_eTypeError, "Type error. Expected %s", ty->name);
814
+ } else {
815
+ rb_raise(rb_eTypeError, "Expected a pointer");
816
+ }
817
+ }
818
+ }
819
+
820
+ #ifdef __cplusplus
821
+ }
822
+ #endif
823
+
824
+
825
+
826
+ /* -------- TYPES TABLE (BEGIN) -------- */
827
+
828
+ #define SWIGTYPE_p_unsigned_long swig_types[0]
829
+ #define SWIGTYPE_p_p_char swig_types[1]
830
+ static swig_type_info *swig_types[3];
831
+
832
+ /* -------- TYPES TABLE (END) -------- */
833
+
834
+ #define SWIG_init Init_libinchi
835
+ #define SWIG_name "Libinchi"
836
+
837
+ static VALUE mLibinchi;
838
+ static VALUE mRino;
839
+
840
+ static void SWIG_AsVal(VALUE obj, int *val)
841
+ {
842
+ *val = (int) NUM2INT(obj);
843
+ }
844
+
845
+ int run(int,char **);
846
+ static VALUE
847
+ _wrap_run(int argc, VALUE *argv, VALUE self) {
848
+ int arg1 ;
849
+ char **arg2 = (char **) 0 ;
850
+ int result;
851
+ VALUE vresult = Qnil;
852
+
853
+ if ((argc < 1) || (argc > 1))
854
+ rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc);
855
+ {
856
+ /* Get the length of the array */
857
+ int size = RARRAY(argv[0])->len;
858
+ int i;
859
+ arg1 = (int) size;
860
+ arg2 = (char **) malloc((size+1)*sizeof(char *));
861
+ /* Get the first element in memory */
862
+ VALUE *ptr = RARRAY(argv[0])->ptr;
863
+ for (i=0; i < size; i++, ptr++)
864
+ /* Convert Ruby Object String to char* */
865
+ arg2[i]= STR2CSTR(*ptr);
866
+ arg2[i]=NULL; /* End of list */
867
+ }
868
+ result = (int)run(arg1,arg2);
869
+
870
+ vresult = INT2NUM(result);
871
+ {
872
+ free((char *) arg2);
873
+ }
874
+ return vresult;
875
+ }
876
+
877
+
878
+
879
+ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
880
+
881
+ static swig_type_info _swigt__p_unsigned_long[] = {{"_p_unsigned_long", 0, "unsigned long *|VALUE *", 0, 0, 0, 0},{"_p_unsigned_long", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
882
+ static swig_type_info _swigt__p_p_char[] = {{"_p_p_char", 0, "char **", 0, 0, 0, 0},{"_p_p_char", 0, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0}};
883
+
884
+ static swig_type_info *swig_types_initial[] = {
885
+ _swigt__p_unsigned_long,
886
+ _swigt__p_p_char,
887
+ 0
888
+ };
889
+
890
+
891
+ /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
892
+
893
+
894
+ #ifdef __cplusplus
895
+ extern "C"
896
+ #endif
897
+ SWIGEXPORT(void) Init_libinchi(void) {
898
+ int i;
899
+
900
+ SWIG_InitRuntime();
901
+
902
+ mRino = rb_define_module("Rino");
903
+ mLibinchi = rb_define_module_under(mRino, "InChI");
904
+
905
+ for (i = 0; swig_types_initial[i]; i++) {
906
+ swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
907
+ SWIG_define_class(swig_types[i]);
908
+ }
909
+
910
+ rb_define_module_function(mLibinchi, "run", _wrap_run, -1);
911
+ }
912
+