rino 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/README +44 -0
  2. data/Rakefile +123 -0
  3. data/ext/extconf.rb +26 -0
  4. data/ext/ruby_inchi_main.so +0 -0
  5. data/ext/src/aux2atom.h +2786 -0
  6. data/ext/src/comdef.h +148 -0
  7. data/ext/src/e_0dstereo.c +3014 -0
  8. data/ext/src/e_0dstereo.h +31 -0
  9. data/ext/src/e_comdef.h +57 -0
  10. data/ext/src/e_ctl_data.h +147 -0
  11. data/ext/src/e_ichi_io.c +498 -0
  12. data/ext/src/e_ichi_io.h +40 -0
  13. data/ext/src/e_ichi_parms.c +37 -0
  14. data/ext/src/e_ichi_parms.h +41 -0
  15. data/ext/src/e_ichicomp.h +50 -0
  16. data/ext/src/e_ichierr.h +40 -0
  17. data/ext/src/e_ichimain.c +593 -0
  18. data/ext/src/e_ichisize.h +43 -0
  19. data/ext/src/e_inchi_atom.c +75 -0
  20. data/ext/src/e_inchi_atom.h +33 -0
  21. data/ext/src/e_inpdef.h +41 -0
  22. data/ext/src/e_mode.h +706 -0
  23. data/ext/src/e_mol2atom.c +649 -0
  24. data/ext/src/e_readinch.c +58 -0
  25. data/ext/src/e_readmol.c +54 -0
  26. data/ext/src/e_readmol.h +180 -0
  27. data/ext/src/e_readstru.c +251 -0
  28. data/ext/src/e_readstru.h +33 -0
  29. data/ext/src/e_util.c +284 -0
  30. data/ext/src/e_util.h +61 -0
  31. data/ext/src/extr_ct.h +251 -0
  32. data/ext/src/ichi.h +206 -0
  33. data/ext/src/ichi_bns.c +7999 -0
  34. data/ext/src/ichi_bns.h +231 -0
  35. data/ext/src/ichican2.c +5000 -0
  36. data/ext/src/ichicano.c +2195 -0
  37. data/ext/src/ichicano.h +49 -0
  38. data/ext/src/ichicans.c +1625 -0
  39. data/ext/src/ichicant.h +379 -0
  40. data/ext/src/ichicomn.h +260 -0
  41. data/ext/src/ichicomp.h +50 -0
  42. data/ext/src/ichidrp.h +119 -0
  43. data/ext/src/ichierr.h +124 -0
  44. data/ext/src/ichiisot.c +101 -0
  45. data/ext/src/ichilnct.c +286 -0
  46. data/ext/src/ichimain.h +132 -0
  47. data/ext/src/ichimak2.c +1189 -0
  48. data/ext/src/ichimake.c +3812 -0
  49. data/ext/src/ichimake.h +205 -0
  50. data/ext/src/ichimap1.c +851 -0
  51. data/ext/src/ichimap2.c +2856 -0
  52. data/ext/src/ichimap4.c +1609 -0
  53. data/ext/src/ichinorm.c +741 -0
  54. data/ext/src/ichinorm.h +67 -0
  55. data/ext/src/ichiparm.c +45 -0
  56. data/ext/src/ichiparm.h +1441 -0
  57. data/ext/src/ichiprt1.c +3612 -0
  58. data/ext/src/ichiprt2.c +1511 -0
  59. data/ext/src/ichiprt3.c +3011 -0
  60. data/ext/src/ichiqueu.c +1003 -0
  61. data/ext/src/ichiring.c +326 -0
  62. data/ext/src/ichiring.h +49 -0
  63. data/ext/src/ichisize.h +35 -0
  64. data/ext/src/ichisort.c +539 -0
  65. data/ext/src/ichister.c +3538 -0
  66. data/ext/src/ichister.h +35 -0
  67. data/ext/src/ichitaut.c +3843 -0
  68. data/ext/src/ichitaut.h +387 -0
  69. data/ext/src/ichitime.h +74 -0
  70. data/ext/src/inchi_api.h +670 -0
  71. data/ext/src/inchi_dll.c +1480 -0
  72. data/ext/src/inchi_dll.h +34 -0
  73. data/ext/src/inchi_dll_main.c +23 -0
  74. data/ext/src/inchi_dll_main.h +31 -0
  75. data/ext/src/inpdef.h +328 -0
  76. data/ext/src/lreadmol.h +1246 -0
  77. data/ext/src/mode.h +706 -0
  78. data/ext/src/ruby_inchi_main.c +558 -0
  79. data/ext/src/runichi.c +4179 -0
  80. data/ext/src/strutil.c +3861 -0
  81. data/ext/src/strutil.h +182 -0
  82. data/ext/src/util.c +1130 -0
  83. data/ext/src/util.h +85 -0
  84. data/lib/clean_tempfile.rb +220 -0
  85. data/lib/rino.rb +111 -0
  86. data/test/test.rb +386 -0
  87. metadata +130 -0
@@ -0,0 +1,498 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.00
6
+ * April 13, 2005
7
+ * Developed at NIST
8
+ */
9
+
10
+ #include <stdio.h>
11
+ #include <stdlib.h>
12
+ #include <string.h>
13
+ #include <ctype.h>
14
+ #include <limits.h>
15
+ #include <errno.h>
16
+ #include <stdarg.h>
17
+
18
+ #include "e_mode.h"
19
+ #include "ichitime.h"
20
+ #include "inchi_api.h"
21
+ #include "e_ctl_data.h"
22
+
23
+ #include "e_comdef.h"
24
+ #include "e_ichicomp.h"
25
+ #include "e_util.h"
26
+ #include "e_ichi_io.h"
27
+ #include "e_ichi_parms.h"
28
+
29
+
30
+ #define LtrimRtrim e_LtrimRtrim
31
+
32
+ /**********************************************
33
+ * output " L=V" or " L missing" or ""
34
+ * The fprintf format string must contain %s%s%s%s
35
+ */
36
+ char e_gsMissing[] = "is missing";
37
+ char e_gsEmpty[] = "";
38
+ char e_gsSpace[] = " ";
39
+ char e_gsEqual[] = "=";
40
+
41
+
42
+ /********* from inchimain.c *****************************************/
43
+ int e_inchi_print( FILE* f, const char* lpszFormat, ... )
44
+ {
45
+ int ret=0, ret2=0;
46
+ /* char *p=NULL; */
47
+
48
+ va_list argList;
49
+
50
+ if ( f ) {
51
+ my_va_start( argList, lpszFormat );
52
+ ret = vfprintf( f, lpszFormat, argList );
53
+ va_end( argList );
54
+ } else {
55
+ /* printf( "\r" ); */
56
+ my_va_start( argList, lpszFormat );
57
+ //ret2 = vfprintf( stdout, lpszFormat, argList );
58
+ /* ret2 = vprintf( lpszFormat, argList ); */
59
+ va_end( argList );
60
+ }
61
+
62
+ #ifdef INCHI_LIB
63
+ if( FWPRINT )
64
+ {
65
+ my_va_start( argList, lpszFormat );
66
+ FWPRINT( lpszFormat, argList );
67
+ va_end( argList );
68
+ }
69
+ #endif
70
+ return ret? ret : ret2;
71
+ }
72
+
73
+ /*****************************************************************/
74
+ int e_my_fprintf( FILE* f, const char* lpszFormat, ... )
75
+ {
76
+ int ret=0, ret2=0;
77
+ va_list argList;
78
+
79
+ #ifndef INCHI_LIB
80
+ if ( f ) {
81
+ if ( f == stderr && lpszFormat && lpszFormat[0] && '\r' == lpszFormat[strlen(lpszFormat)-1] ) {
82
+ #define CONSOLE_LINE_LEN 80
83
+ #ifndef INCHI_ANSI_ONLY
84
+ char szLine[CONSOLE_LINE_LEN];
85
+ my_va_start( argList, lpszFormat );
86
+ ret = _vsnprintf( szLine, CONSOLE_LINE_LEN-1, lpszFormat, argList );
87
+ va_end( argList );
88
+ if ( ret < 0 ) {
89
+ /* output is longer than the console line */
90
+ strcpy(szLine+CONSOLE_LINE_LEN-4, "...\r");
91
+ }
92
+ fputs( szLine, f );
93
+ #else
94
+ my_va_start( argList, lpszFormat );
95
+ ret = vfprintf( f, lpszFormat, argList );
96
+ va_end( argList );
97
+ #endif
98
+ #undef CONSOLE_LINE_LEN
99
+ } else {
100
+ my_va_start( argList, lpszFormat );
101
+ ret = vfprintf( f, lpszFormat, argList );
102
+ va_end( argList );
103
+ }
104
+ }
105
+ if ( f != stderr ) {
106
+ my_va_start( argList, lpszFormat );
107
+ //ret2 = vfprintf( stderr, lpszFormat, argList );
108
+ va_end( argList );
109
+ }
110
+ #else
111
+ if ( f ) {
112
+ my_va_start( argList, lpszFormat );
113
+ ret = vfprintf( f, lpszFormat, argList );
114
+ va_end( argList );
115
+ }
116
+ #endif
117
+
118
+ return ret? ret : ret2;
119
+ }
120
+ /*******************************************************************/
121
+ void e_PrintFileName( const char *fmt, FILE *output_file, const char *szFname )
122
+ {
123
+ fprintf( output_file, fmt, szFname );
124
+ }
125
+ /************** copied from util.c *********************************/
126
+ char *e_fgetsTab( char *szLine, int len, FILE *f );
127
+ /*******************************************************************/
128
+ /* read up to len or tab or LF; if empty read next until finds non-empty line */
129
+ /* remove leading and trailing white spaces; keep zero termination */
130
+ /*******************************************************************/
131
+ char *e_fgetsTab( char *szLine, int len, FILE *f )
132
+ {
133
+ int length=0, c;
134
+ len --;
135
+ while ( length < len && EOF != (c = fgetc( f )) ) {
136
+ if ( c == '\t' )
137
+ c = '\n';
138
+ szLine[length++] = (char)c;
139
+ if ( c == '\n' )
140
+ break;
141
+ }
142
+ if ( !length && EOF == c ) {
143
+ return NULL;
144
+ }
145
+ szLine[length] = '\0';
146
+ return szLine;
147
+ }
148
+ /*******************************************************************/
149
+ /* read up to len or tab or LF; if empty read next until finds non-empty line */
150
+ /* remove leading and trailing white spaces; keep zero termination */
151
+ /*******************************************************************/
152
+ int e_my_fgetsTab( char *szLine, int len, FILE *f, int *bTooLongLine )
153
+ {
154
+ int length;
155
+ char *p;
156
+ do {
157
+ p = e_fgetsTab( szLine, len-1, f );
158
+ if ( !p ) {
159
+ *bTooLongLine = 0;
160
+ return -1; /* end of file or cannot read */
161
+ }
162
+ szLine[len-1] = '\0';
163
+ /*
164
+ *bTooLongLine = !strchr( szLine, '\n' );
165
+ */
166
+ p = strchr( szLine, '\n' );
167
+ *bTooLongLine = ( !p && ((int)strlen(szLine)) == len-2 );
168
+ LtrimRtrim( szLine, &length );
169
+ } while ( !length );
170
+ return length;
171
+ }
172
+ /*******************************************************************/
173
+ int e_my_fgetsTab1( char *szLine, int len, FILE *f, int *bTooLongLine )
174
+ {
175
+ int length;
176
+ char *p;
177
+ /*do {*/
178
+ p = e_fgetsTab( szLine, len-1, f );
179
+ if ( !p ) {
180
+ *bTooLongLine = 0;
181
+ return -1; /* end of file or cannot read */
182
+ }
183
+ szLine[len-1] = '\0';
184
+ /*
185
+ *bTooLongLine = !strchr( szLine, '\n' );
186
+ */
187
+ p = strchr( szLine, '\n' );
188
+ *bTooLongLine = ( !p && ((int)strlen(szLine)) == len-2 );
189
+ LtrimRtrim( szLine, &length );
190
+ /*} while ( !length );*/
191
+ return length;
192
+ }
193
+ /******************************************************************/
194
+ /* read not more than line_len bytes from an lf-terminated line */
195
+ /* if input line is too long quietly ignore the rest of the line */
196
+ char* fgets_up_to_lf( char* line, int line_len, FILE* inp )
197
+ {
198
+ char *p, *q;
199
+ memset( line, 0, line_len );
200
+ if ( NULL != (p = fgets( line, line_len, inp ) ) && NULL == strchr(p, '\n' ) ){
201
+ char temp[64]; /* bypass up to '\n' or up to end of file whichever comes first*/
202
+ while ( NULL != fgets( temp, sizeof(temp), inp ) && NULL == strchr(temp,'\n') )
203
+ ;
204
+ }
205
+ if ( p && (q = strchr(line, '\r')) ) { /* fix CR CR LF line terminator. */
206
+ q[0] = '\n';
207
+ q[1] = '\0';
208
+ }
209
+ return p;
210
+ }
211
+ /********************************************************************/
212
+ int my_fgetsUpToLfOrTab( char *szLine, int len, FILE *f )
213
+ {
214
+ int length;
215
+ char *p;
216
+ char szSkip[256];
217
+ int bTooLongLine = 0;
218
+ do {
219
+ p = e_fgetsTab( szLine, len-1, f );
220
+ if ( !p ) {
221
+ return -1; /* end of file or cannot read */
222
+ }
223
+ szLine[len-1] = '\0';
224
+ /*
225
+ bTooLongLine = !strchr( szLine, '\n' );
226
+ */
227
+ bTooLongLine = ( !p && ((int)strlen(szLine)) == len-2 );
228
+ LtrimRtrim( szLine, &length );
229
+ } while ( !length );
230
+ if ( bTooLongLine ) {
231
+ while ( p = e_fgetsTab( szSkip, sizeof(szSkip)-1, f ) ) {
232
+ szSkip[sizeof(szSkip)-1] = '\0';
233
+ if ( strchr( szSkip, '\n' ) )
234
+ break;
235
+ }
236
+ }
237
+ return length;
238
+ }
239
+
240
+
241
+ #ifdef INCHI_ANSI_ONLY
242
+
243
+ static clock_t InchiClock(void);
244
+
245
+ #ifdef INCHI_USETIMES
246
+ static clock_t InchiClock(void)
247
+ {
248
+ struct tms buf;
249
+ clock_t c = times( &buf );
250
+ if ( c != (clock_t)-1 ) {
251
+ return buf.tms_utime;
252
+ }
253
+ return 0;
254
+ }
255
+ #else
256
+ static clock_t InchiClock(void)
257
+ {
258
+ clock_t c = clock();
259
+ if ( c != (clock_t)-1 ) {
260
+ return c;
261
+ }
262
+ return 0;
263
+ }
264
+ #endif
265
+
266
+ #define INCHI_MSEC(X) (long)((1000.0/(double)CLOCKS_PER_SEC)*(X))
267
+ #define INCHI_CLOCK_T(X) (clock_t)( (double)(X) / 1000.0 * (double)CLOCKS_PER_SEC )
268
+ const clock_t FullMaxClock = (clock_t)(-1);
269
+ const clock_t HalfMaxClock = (clock_t)(-1) / 2;
270
+ clock_t MaxPositiveClock = 0;
271
+ clock_t MinNegativeClock = 0;
272
+ clock_t HalfMaxPositiveClock = 0;
273
+ clock_t HalfMinNegativeClock = 0;
274
+
275
+ static void FillMaxMinClock(void); /* keep compiler happy */
276
+
277
+ static void FillMaxMinClock(void)
278
+ {
279
+ if ( !MaxPositiveClock ) {
280
+ clock_t valPos, val1 = 1;
281
+ while ( 0 < ((val1 <<= 1), (val1 |= 1)) ) {
282
+ valPos = val1;
283
+ }
284
+ MaxPositiveClock = valPos;
285
+ MinNegativeClock = -valPos;
286
+ HalfMaxPositiveClock = MaxPositiveClock / 2;
287
+ HalfMinNegativeClock = MinNegativeClock / 2;
288
+ }
289
+ }
290
+
291
+
292
+ /******** get current process time ****************************************/
293
+ void InchiTimeGet( inchiTime *TickEnd )
294
+ {
295
+ TickEnd->clockTime = InchiClock();
296
+ }
297
+ /******** returns difference TickEnd - TickStart in milliseconds **********/
298
+ long InchiTimeMsecDiff( inchiTime *TickEnd, inchiTime *TickStart )
299
+ {
300
+ if ( FullMaxClock > 0 ) {
301
+ clock_t delta;
302
+ if ( !TickEnd || !TickStart )
303
+ return 0;
304
+ /* clock_t is unsigned */
305
+ if ( TickEnd->clockTime > TickStart->clockTime ) {
306
+ if ( TickEnd->clockTime > HalfMaxClock &&
307
+ TickEnd->clockTime - TickStart->clockTime > HalfMaxClock ) {
308
+ /* overflow in TickStart->clockTime, actually TickStart->clockTime was later */
309
+ delta = (FullMaxClock - TickEnd->clockTime) + TickStart->clockTime;
310
+ return -INCHI_MSEC(delta);
311
+ }
312
+ delta = TickEnd->clockTime - TickStart->clockTime;
313
+ return INCHI_MSEC(delta);
314
+ } else
315
+ if ( TickEnd->clockTime < TickStart->clockTime ) {
316
+ if ( TickStart->clockTime > HalfMaxClock &&
317
+ TickStart->clockTime - TickEnd->clockTime > HalfMaxClock ) {
318
+ /* overflow in TickEnd->clockTime, actually TickEnd->clockTime was later */
319
+ delta = (FullMaxClock - TickStart->clockTime) + TickEnd->clockTime;
320
+ return INCHI_MSEC(delta);
321
+ }
322
+ delta = TickStart->clockTime - TickEnd->clockTime;
323
+ return -INCHI_MSEC(delta);
324
+ }
325
+ return 0; /* TickEnd->clockTime == TickStart->clockTime */
326
+ } else {
327
+ /* may happen under Win32 only where clock_t is SIGNED long */
328
+ clock_t delta;
329
+ FillMaxMinClock( );
330
+ if ( !TickEnd || !TickStart )
331
+ return 0;
332
+ if ( TickEnd->clockTime >= 0 && TickStart->clockTime >= 0 ||
333
+ TickEnd->clockTime <= 0 && TickStart->clockTime <= 0) {
334
+ delta = TickEnd->clockTime - TickStart->clockTime;
335
+ } else
336
+ if ( TickEnd->clockTime >= HalfMaxPositiveClock &&
337
+ TickStart->clockTime <= HalfMinNegativeClock ) {
338
+ /* end is earlier than start */
339
+ delta = (MaxPositiveClock - TickEnd->clockTime) + (TickStart->clockTime - MinNegativeClock);
340
+ delta = -delta;
341
+ } else
342
+ if ( TickEnd->clockTime <= HalfMinNegativeClock &&
343
+ TickStart->clockTime >= HalfMaxPositiveClock ) {
344
+ /* start was earlier than end */
345
+ delta = (MaxPositiveClock - TickStart->clockTime) + (TickEnd->clockTime - MinNegativeClock);
346
+ } else {
347
+ /* there was no overflow, clock passed zero */
348
+ delta = TickEnd->clockTime - TickStart->clockTime;
349
+ }
350
+ return INCHI_MSEC(delta);
351
+ }
352
+ }
353
+ /******************* get elapsed time from TickStart ************************/
354
+ long InchiTimeElapsed( inchiTime *TickStart )
355
+ {
356
+ inchiTime TickEnd;
357
+ if ( !TickStart )
358
+ return 0;
359
+ InchiTimeGet( &TickEnd );
360
+ return InchiTimeMsecDiff( &TickEnd, TickStart );
361
+ }
362
+ /******************* add number of milliseconds to time *********************/
363
+ void InchiTimeAddMsec( inchiTime *TickEnd, unsigned long nNumMsec )
364
+ {
365
+ clock_t delta;
366
+ if ( !TickEnd )
367
+ return;
368
+ if ( FullMaxClock > 0 ) {
369
+ /* clock_t is unsigned */
370
+ delta = INCHI_CLOCK_T(nNumMsec);
371
+ TickEnd->clockTime += delta;
372
+ } else {
373
+ /* may happen under Win32 only where clock_t is SIGNED long */
374
+ /* clock_t is unsigned */
375
+ FillMaxMinClock( );
376
+ delta = INCHI_CLOCK_T(nNumMsec);
377
+ TickEnd->clockTime += delta;
378
+ }
379
+ }
380
+ /******************* check whether time has expired *********************/
381
+ int bInchiTimeIsOver( inchiTime *TickStart )
382
+ {
383
+ if ( FullMaxClock > 0 ) {
384
+ clock_t clockCurrTime;
385
+ if ( !TickStart )
386
+ return 0;
387
+ clockCurrTime = InchiClock();
388
+ /* clock_t is unsigned */
389
+ if ( TickStart->clockTime > clockCurrTime ) {
390
+ if ( TickStart->clockTime > HalfMaxClock &&
391
+ TickStart->clockTime - clockCurrTime > HalfMaxClock ) {
392
+ /* overflow in clockCurrTime, actually clockCurrTime was later */
393
+ return 1;
394
+ }
395
+ return 0;
396
+ } else
397
+ if ( TickStart->clockTime < clockCurrTime ) {
398
+ if ( clockCurrTime > HalfMaxClock &&
399
+ clockCurrTime - TickStart->clockTime > HalfMaxClock ) {
400
+ /* overflow in TickStart->clockTime, actually TickStart->clockTime was later */
401
+ return 0;
402
+ }
403
+ return 1;
404
+ }
405
+ return 0; /* TickStart->clockTime == clockCurrTime */
406
+ } else {
407
+ /* may happen under Win32 only where clock_t is SIGNED long */
408
+ clock_t clockCurrTime;
409
+ FillMaxMinClock( );
410
+ if ( !TickStart )
411
+ return 0;
412
+ clockCurrTime = InchiClock();
413
+ if ( clockCurrTime >= 0 && TickStart->clockTime >= 0 ||
414
+ clockCurrTime <= 0 && TickStart->clockTime <= 0) {
415
+ return (clockCurrTime > TickStart->clockTime);
416
+ } else
417
+ if ( clockCurrTime >= HalfMaxPositiveClock &&
418
+ TickStart->clockTime <= HalfMinNegativeClock ) {
419
+ /* curr is earlier than start */
420
+ return 0;
421
+ } else
422
+ if ( clockCurrTime <= HalfMinNegativeClock &&
423
+ TickStart->clockTime >= HalfMaxPositiveClock ) {
424
+ /* start was earlier than curr */
425
+ return 1;
426
+ } else {
427
+ /* there was no overflow, clock passed zero */
428
+ return (clockCurrTime > TickStart->clockTime);
429
+ }
430
+ }
431
+ }
432
+
433
+ #else
434
+
435
+ /******** get current process time ****************************************/
436
+ void InchiTimeGet( inchiTime *TickEnd )
437
+ {
438
+ if ( TickEnd ) {
439
+ struct _timeb timeb;
440
+ _ftime( &timeb );
441
+ TickEnd->clockTime = (unsigned long)timeb.time;
442
+ TickEnd->millitime = (long)timeb.millitm;
443
+ }
444
+ }
445
+ /******** returns difference TickEnd - TickStart in milliseconds **********/
446
+ long InchiTimeMsecDiff( inchiTime *TickEnd, inchiTime *TickStart )
447
+ {
448
+ long delta;
449
+ if ( !TickEnd || !TickStart ) {
450
+ return 0;
451
+ }
452
+ if ( TickEnd->clockTime >= TickStart->clockTime ) {
453
+ delta = (long)(TickEnd->clockTime - TickStart->clockTime);
454
+ delta *= 1000;
455
+ delta += TickEnd->millitime - TickStart->millitime;
456
+ } else {
457
+ delta = -(long)(TickStart->clockTime - TickEnd->clockTime);
458
+ delta *= 1000;
459
+ delta += TickEnd->millitime - TickStart->millitime;
460
+ }
461
+ return delta;
462
+ }
463
+ /******************* get elapsed time from TickStart ************************/
464
+ long InchiTimeElapsed( inchiTime *TickStart )
465
+ {
466
+ inchiTime TickEnd;
467
+ if ( !TickStart )
468
+ return 0;
469
+ InchiTimeGet( &TickEnd );
470
+ return InchiTimeMsecDiff( &TickEnd, TickStart );
471
+ }
472
+ /******************* add number of milliseconds to time *********************/
473
+ void InchiTimeAddMsec( inchiTime *TickEnd, unsigned long nNumMsec )
474
+ {
475
+ long delta;
476
+ if ( !TickEnd )
477
+ return;
478
+ TickEnd->clockTime += nNumMsec / 1000;
479
+ delta = nNumMsec % 1000 + TickEnd->millitime;
480
+ TickEnd->clockTime += delta / 1000;
481
+ TickEnd->millitime = delta % 1000;
482
+ }
483
+ /******************* check whether time has expired *********************/
484
+ int bInchiTimeIsOver( inchiTime *TickEnd )
485
+ {
486
+ struct _timeb timeb;
487
+ if ( !TickEnd )
488
+ return 0;
489
+ _ftime( &timeb );
490
+ if ( TickEnd->clockTime > (unsigned long)timeb.time )
491
+ return 0;
492
+ if ( TickEnd->clockTime < (unsigned long)timeb.time ||
493
+ TickEnd->millitime < (long)timeb.millitm ) {
494
+ return 1;
495
+ }
496
+ return 0;
497
+ }
498
+ #endif
@@ -0,0 +1,40 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.00
6
+ * April 13, 2005
7
+ * Developed at NIST
8
+ */
9
+
10
+ #ifndef __ICHI_IO_H__
11
+ #define __ICHI_IO_H__
12
+
13
+
14
+ #ifndef INCHI_ALL_CPP
15
+ #ifdef __cplusplus
16
+ extern "C" {
17
+ #endif
18
+ #endif
19
+
20
+
21
+ char* fgets_up_to_lf( char* line, int line_len, FILE* inp );
22
+ int my_fgetsUpToLfOrTab( char *szLine, int len, FILE *f );
23
+
24
+ int e_my_fgetsTab( char *szLine, int len, FILE *f, int *bTooLongLine );
25
+ int e_my_fgetsTab1( char *szLine, int len, FILE *f, int *bTooLongLine );
26
+
27
+ int e_inchi_print( FILE* f, const char* lpszFormat, ... );
28
+ int e_my_fprintf( FILE* f, const char* lpszFormat, ... );
29
+ void e_PrintFileName( const char *fmt, FILE *output_file, const char *szFname );
30
+ unsigned long e_ulMyGetTickCount( int bStart );
31
+ unsigned long e_ulMyTickCountDiff( unsigned long ulTickEnd, unsigned long ulTickStart );
32
+
33
+ #ifndef INCHI_ALL_CPP
34
+ #ifdef __cplusplus
35
+ }
36
+ #endif
37
+ #endif
38
+
39
+
40
+ #endif /* __ICHI_IO_H__ */
@@ -0,0 +1,37 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.00
6
+ * April 13, 2005
7
+ * Developed at NIST
8
+ */
9
+
10
+ #include <stdio.h>
11
+ #include <stdlib.h>
12
+ #include <string.h>
13
+ #include <ctype.h>
14
+ #include <errno.h>
15
+ #include <limits.h>
16
+
17
+ #include "e_mode.h"
18
+ #include "inchi_api.h"
19
+ #include "e_ctl_data.h"
20
+ #include "e_ichi_io.h"
21
+ #include "e_ichi_parms.h"
22
+ #include "e_util.h"
23
+ #include "e_ichicomp.h"
24
+
25
+ #define DetectInputINChIFileType e_DetectInputINChIFileType
26
+ #define ReadCommandLineParms e_ReadCommandLineParms
27
+ #define mystrncpy e_mystrncpy
28
+ #define my_fprintf e_my_fprintf
29
+ #define LtrimRtrim e_LtrimRtrim
30
+ #define PrintInputParms e_PrintInputParms
31
+ #define OpenFiles e_OpenFiles
32
+ #define PrintFileName e_PrintFileName
33
+ #define HelpCommandLineParms e_HelpCommandLineParms
34
+ #define inchi_print_nodisplay fprintf
35
+
36
+ #include "ichiparm.h"
37
+
@@ -0,0 +1,41 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.00
6
+ * April 13, 2005
7
+ * Developed at NIST
8
+ */
9
+
10
+ #ifndef __ICHI_PARMS_H__
11
+ #define __ICHI_PARMS_H__
12
+
13
+
14
+
15
+ #ifndef INCHI_ALL_CPP
16
+ #ifdef __cplusplus
17
+ extern "C" {
18
+ #endif
19
+ #endif
20
+
21
+
22
+ int e_ReadCommandLineParms( int argc, const char *argv[], INPUT_PARMS *ip, char *szSdfDataValue,
23
+ unsigned long *ulDisplTime, int bReleaseVersion, INCHI_FILE *log_file );
24
+
25
+ int e_PrintInputParms( INCHI_FILE *log_file, INPUT_PARMS *ip );
26
+ int e_OpenFiles( FILE **inp_file, FILE **output_file, FILE **log_file, FILE **prb_file, INPUT_PARMS *ip );
27
+ void e_HelpCommandLineParms( INCHI_FILE *f );
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+ #ifndef INCHI_ALL_CPP
36
+ #ifdef __cplusplus
37
+ }
38
+ #endif
39
+ #endif
40
+
41
+ #endif /* __ICHI_PARMS_H__ */
@@ -0,0 +1,50 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.00
6
+ * April 13, 2005
7
+ * Developed at NIST
8
+ */
9
+
10
+ #ifndef __INCHI_COMPAT_H__
11
+ #define __INCHI_COMPAT_H__
12
+
13
+ /* compatibility */
14
+
15
+ #if( defined(__GNUC__) && defined(__MINGW32__) && __GNUC__ == 3 && __GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ == 0 && defined(_WIN32) )
16
+ /* replace with the proper definition for GNU gcc & MinGW-2.0.0-3 (mingw special 20020817-1), gcc 3.2 core */
17
+ #define my_va_start(A,B) ((A)=(va_list)__builtin_next_arg(lpszFormat))
18
+ #else
19
+ #define my_va_start va_start
20
+ #endif
21
+
22
+
23
+
24
+ /* ANSI redefinitions */
25
+ #ifdef INCHI_ANSI_ONLY /* { */
26
+ #ifndef __isascii
27
+ #define __isascii(val) ((unsigned)(val) <= 0x7F)
28
+ #endif
29
+
30
+ /* #ifndef __GNUC__ */
31
+ /* these non-ANSI functions are implemented in gcc */
32
+ #include <stdio.h>
33
+ /* this #include provides size_t definition */
34
+ /* implementation is located in util.c */
35
+ #if ( !defined(_MSC_VER) || defined(__STDC__) && __STDC__ == 1 )
36
+ /* support (VC++ Language extensions) = OFF && defined(INCHI_ANSI_ONLY) */
37
+ int memicmp (const void*, const void*, size_t);
38
+ int stricmp( const char *s1, const char *s2 );
39
+ char *_strnset( char *string, int c, size_t count );
40
+ char *_strdup( const char *string );
41
+ #endif
42
+ /* #endif */
43
+
44
+ #endif /* } */
45
+
46
+ #define inchi_max(a,b) (((a)>(b))?(a):(b))
47
+ #define inchi_min(a,b) (((a)<(b))?(a):(b))
48
+
49
+
50
+ #endif /* __INCHI_COMPAT_H__ */
@@ -0,0 +1,40 @@
1
+ /*
2
+ * International Union of Pure and Applied Chemistry (IUPAC)
3
+ * International Chemical Identifier (InChI)
4
+ * Version 1
5
+ * Software version 1.00
6
+ * April 13, 2005
7
+ * Developed at NIST
8
+ */
9
+
10
+ #ifndef __INCHIERR_H__
11
+ #define __INCHIERR_H__
12
+
13
+ #define _IS_OKAY 0
14
+ #define _IS_WARNING 1
15
+ #define _IS_ERROR 2 /* Microsoft defined its own IS_ERROR() macro */
16
+ #define _IS_FATAL 3
17
+ #define _IS_UNKNOWN 4 /* unknown error: used in INChI DLL only */
18
+ #define _IS_EOF -1 /* end of file */
19
+ #define _IS_SKIP -2
20
+
21
+
22
+
23
+ #define INCHI_INP_ERROR_ERR 40
24
+ #define INCHI_INP_ERROR_RET (-1)
25
+
26
+ #define INCHI_INP_FATAL_ERR 1
27
+ #define INCHI_INP_FATAL_RET 0
28
+
29
+ #define INCHI_INP_EOF_ERR 11
30
+ #define INCHI_INP_EOF_RET 0
31
+
32
+ #define LOG_MASK_WARN 1
33
+ #define LOG_MASK_ERR 2
34
+ #define LOG_MASK_FATAL 4
35
+
36
+ #define LOG_MASK_ALL (LOG_MASK_WARN | LOG_MASK_ERR | LOG_MASK_FATAL)
37
+ #define LOG_MASK_NO_WARN (LOG_MASK_ERR | LOG_MASK_FATAL)
38
+
39
+
40
+ #endif /* __INCHIERR_H__ */