Branch data Line data Source code
1 : : /*
2 : : * SPDX-License-Identifier: MIT
3 : : * Copyright (c) 2024 IUPAC and InChI Trust
4 : : */
5 : :
6 : : /* djb-rwth: used for strdup function */
7 : : #ifndef _WIN32
8 : : #if defined(__STDC_ALLOC_LIB__)
9 : : #define __STDC_WANT_LIB_EXT2__ 1
10 : : #else
11 : : #define _POSIX_C_SOURCE 200809L
12 : : #endif
13 : : #endif
14 : :
15 : : #include <stdlib.h>
16 : : #include <string.h>
17 : : #include <ctype.h>
18 : : /* #include <varargs.h> */
19 : : #include <errno.h>
20 : : #include <limits.h>
21 : :
22 : : #include "mode.h"
23 : : #ifndef COMPILE_ANSI_ONLY
24 : : #include <conio.h>
25 : : #endif
26 : :
27 : : #include "incomdef.h"
28 : : #include "ichidrp.h"
29 : : #include "inpdef.h"
30 : : #include "ichi.h"
31 : : #include "strutil.h"
32 : : #include "util.h"
33 : : #include "ichidrp.h"
34 : : #include "ichierr.h"
35 : : #include "ichimain.h"
36 : : #include "extr_ct.h"
37 : : #ifdef TARGET_LIB_FOR_WINCHI
38 : : #include "../../../IChI_lib/src/ichi_lib.h"
39 : : #endif
40 : : #include "ichicomp.h"
41 : :
42 : : #include "ichi_io.h"
43 : : #include "util.h"
44 : :
45 : : #include "bcf_s.h"
46 : :
47 : : #define VER103_DEFAULT_MODE (REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_STEREO |\
48 : : REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)
49 : :
50 : :
51 : : int DetectInputINChIFileType(FILE** inp_file, INPUT_PARMS* ip, const char* fmode);
52 : :
53 : : int set_common_options_by_parg(const char* pArg,
54 : : int developer_options,
55 : : INPUT_PARMS* ip,
56 : : INCHI_MODE* pbVer1DefaultMode,
57 : : int* pnMode,
58 : : int* pbINChIOutputOptions,
59 : : int* pbINChIOutputOptions2,
60 : : int* pbStdFormat,
61 : : int* pbHashKey,
62 : : int* pbHashXtra1,
63 : : int* pbHashXtra2,
64 : : int* pbFixSp3bug,
65 : : int* pbFixFB2,
66 : : int* pbAddPhosphineStereo,
67 : : int* pbAddArsineStereo,
68 : : int* pbNoStructLabels,
69 : : int* pbPointedEdgeStereo,
70 : : int* pbDoNotAddH,
71 : : int* pbForcedChiralFlag,
72 : : int* pbReconnectCoord,
73 : : int* pbKetoEnolTaut,
74 : : int* pb15TautNonRing,
75 : : int* pbPT_06_00_Taut,
76 : : int* pbPT_13_00_Taut,
77 : : int* pbPT_16_00_Taut,
78 : : int* pbPT_18_00_Taut,
79 : : int* pbPT_22_00_Taut,
80 : : int* pbPT_39_00_Taut,
81 : : int* pbLooseTSACheck,
82 : : int* pbLargeMolecules,
83 : : int* pbPolymers,
84 : : int* pbFoldPolymerSRU,
85 : : int* pbFrameShiftScheme,
86 : : int* pbStereoAtZz,
87 : : int* pbNPZz,
88 : : int* pbNoWarnings,
89 : : int* pbMergeHash,
90 : : int* pbHideInChI,
91 : : int* pbMolecularInorganics, /* @nnuk */
92 : : int* pbEnhancedStereochemistry);
93 : :
94 : :
95 : : /****************************************************************************
96 : : Returns 1 if pArg recognized and treated, 0 otherwise
97 : : ****************************************************************************/
98 : 75 : int set_common_options_by_parg(const char* pArg,
99 : : int developer_options,
100 : : INPUT_PARMS* ip,
101 : : INCHI_MODE* pbVer1DefaultMode,
102 : : int* pnMode,
103 : : int* pbINChIOutputOptions,
104 : : int* pbINChIOutputOptions2,
105 : : int* pbStdFormat,
106 : : int* pbHashKey,
107 : : int* pbHashXtra1,
108 : : int* pbHashXtra2,
109 : : int* pbFixSp3bug,
110 : : int* pbFixFB2,
111 : : int* pbAddPhosphineStereo,
112 : : int* pbAddArsineStereo,
113 : : int* pbNoStructLabels,
114 : : int* pbPointedEdgeStereo,
115 : : int* pbDoNotAddH,
116 : : int* pbForcedChiralFlag,
117 : : int* pbReconnectCoord,
118 : : int* pbKetoEnolTaut,
119 : : int* pb15TautNonRing,
120 : : int* pbPT_06_00_Taut,
121 : : int* pbPT_13_00_Taut,
122 : : int* pbPT_16_00_Taut,
123 : : int* pbPT_18_00_Taut,
124 : : int* pbPT_22_00_Taut,
125 : : int* pbPT_39_00_Taut,
126 : : int* pbLooseTSACheck,
127 : : int* pbLargeMolecules,
128 : : int* pbPolymers,
129 : : int* pbFoldPolymerSRU,
130 : : int* pbFrameShiftScheme,
131 : : int* pbStereoAtZz,
132 : : int* pbNPZz,
133 : : int* pbNoWarnings,
134 : : int* pbMergeHash,
135 : : int* pbHideInChI,
136 : : int* pbMolecularInorganics, /*@nnuk*/
137 : : int* pbEnhancedStereochemistry
138 : : )
139 : : {
140 : 75 : int got = 0;
141 : :
142 : : /* Input */
143 [ - + ]: 75 : if ( !inchi_stricmp(pArg, "INPAUX") )
144 : : {
145 [ # # ]: 0 : if ( INPUT_NONE == ip->nInputType )
146 : : {
147 : 0 : ip->nInputType = INPUT_INCHI_PLAIN;
148 : : }
149 : 0 : got = 1;
150 : : }
151 [ - + ]: 75 : else if ( !inchi_memicmp(pArg, "START:", 6) )
152 : : {
153 : 0 : ip->first_struct_number = strtol(pArg + 6, NULL, 10);
154 : 0 : got = 1;
155 : : }
156 [ - + ]: 75 : else if ( !inchi_memicmp(pArg, "END:", 4) )
157 : : {
158 : 0 : ip->last_struct_number = strtol(pArg + 4, NULL, 10);
159 : 0 : got = 1;
160 : : }
161 [ - + ]: 75 : else if ( !inchi_memicmp(pArg, "RECORD:", 7) )
162 : : {
163 : 0 : long num = strtol(pArg + 7, NULL, 10);
164 : : /* djb-rwth: removing redundant code */
165 : 0 : ip->first_struct_number = num;
166 : 0 : ip->last_struct_number = num;
167 : 0 : got = 1;
168 : : }
169 [ - + ]: 75 : else if ( !inchi_stricmp(pArg, "NOLABELS") )
170 : : {
171 : 0 : *pbNoStructLabels = 1;
172 : 0 : got = 1;
173 : : }
174 [ - + ]: 75 : else if ( !inchi_stricmp(pArg, "SAVEOPT") )
175 : : {
176 : 0 : (*pbINChIOutputOptions) |= INCHI_OUT_SAVEOPT;
177 : 0 : got = 1;
178 : : }
179 : : /* Generation */
180 [ - + ]: 75 : else if ( !inchi_stricmp(pArg, "AUXNONE") )
181 : : {
182 : : /* no aux. info */
183 : 0 : (*pbINChIOutputOptions) |= INCHI_OUT_NO_AUX_INFO; /* no aux info */
184 : 0 : (*pbINChIOutputOptions) &= ~INCHI_OUT_SHORT_AUX_INFO;
185 : 0 : got = 1;
186 : : }
187 [ - + ]: 75 : else if ( !inchi_stricmp(pArg, "MISMATCHISERROR") )
188 : : {
189 : : /* Consider InChI conversion "problem/mismatch" as error */
190 : 0 : (*pbINChIOutputOptions2) |= INCHI_OUT_MISMATCH_AS_ERROR;
191 : 0 : got = 1;
192 : : }
193 [ - + ]: 75 : else if ( !inchi_stricmp(pArg, "OUTERRINCHI") )
194 : : {
195 : : /* Signify InChI error generation on InChI strings output, not only report to log file */
196 : 0 : (*pbINChIOutputOptions2) |= INCHI_OUT_INCHI_GEN_ERROR;
197 : 0 : got = 1;
198 : : }
199 : : /* InChIKey/InChI hash */
200 [ - + ]: 75 : else if ( !inchi_stricmp(pArg, "Key") )
201 : : {
202 : 0 : *pbHashKey = 1;
203 : 0 : got = 1;
204 : : }
205 [ - + ]: 75 : else if ( !inchi_stricmp(pArg, "XHash1") )
206 : : {
207 : 0 : *pbHashXtra1 = 1;
208 : 0 : got = 1;
209 : : }
210 [ - + ]: 75 : else if ( !inchi_stricmp(pArg, "XHash2") )
211 : : {
212 : 0 : *pbHashXtra2 = 1;
213 : 0 : got = 1;
214 : : }
215 : : /* All modes (std and non-std InChI) structure perception options */
216 : : /* These options DO NOT TURN OFF Std flag */
217 [ - + ]: 75 : else if ( !inchi_stricmp(pArg, "SNON") )
218 : : {
219 : 0 : (*pbVer1DefaultMode) &= ~REQ_MODE_STEREO; /* no stereo */
220 : 0 : (*pnMode) &= ~(REQ_MODE_RACEMIC_STEREO | REQ_MODE_RELATIVE_STEREO | REQ_MODE_CHIR_FLG_STEREO);
221 : 0 : got = 1;
222 : : }
223 [ - + ]: 75 : else if ( !inchi_stricmp(pArg, "NEWPSOFF") )
224 : : {
225 : 0 : *pbPointedEdgeStereo = 0;
226 : 0 : got = 1;
227 : : }
228 [ + + ]: 75 : else if ( !inchi_stricmp(pArg, "DONOTADDH") )
229 : : {
230 : 2 : *pbDoNotAddH = 1;
231 : 2 : got = 1;
232 : : }
233 [ - + ]: 73 : else if ( !inchi_stricmp(pArg, "LooseTSACheck") )
234 : : {
235 : 0 : (*pbLooseTSACheck) = 1;
236 : 0 : got = 1;
237 : : }
238 [ + + ]: 73 : else if (!inchi_stricmp(pArg, "EnhancedStereochemistry"))
239 : : {
240 : 47 : *pbEnhancedStereochemistry = 1;
241 : 47 : got = 1;
242 : : }
243 : :
244 : : #ifndef USE_STDINCHI_API
245 : : /* These options DO TURN OFF Std flag */
246 [ - + ]: 26 : else if ( !inchi_stricmp(pArg, "SREL") )
247 : : {
248 [ # # ]: 0 : if ( (*pnMode) & REQ_MODE_RACEMIC_STEREO )
249 : : {
250 : 0 : (*pnMode) ^= REQ_MODE_RACEMIC_STEREO;
251 : : }
252 [ # # ]: 0 : if ( (*pnMode) & REQ_MODE_CHIR_FLG_STEREO )
253 : : {
254 : 0 : (*pnMode) ^= REQ_MODE_CHIR_FLG_STEREO;
255 : : }
256 : 0 : (*pnMode) |= REQ_MODE_RELATIVE_STEREO;
257 : 0 : (*pnMode) |= REQ_MODE_STEREO;
258 : 0 : *pbStdFormat = 0;
259 : 0 : got = 1;
260 : : }
261 [ - + ]: 26 : else if ( !inchi_stricmp(pArg, "SRAC") )
262 : : {
263 [ # # ]: 0 : if ( (*pnMode) & REQ_MODE_RELATIVE_STEREO )
264 : : {
265 : 0 : (*pnMode) ^= REQ_MODE_RELATIVE_STEREO;
266 : : }
267 [ # # ]: 0 : if ( (*pnMode) & REQ_MODE_CHIR_FLG_STEREO )
268 : : {
269 : 0 : (*pnMode) ^= REQ_MODE_CHIR_FLG_STEREO;
270 : : }
271 : 0 : (*pnMode) |= REQ_MODE_RACEMIC_STEREO;
272 : 0 : (*pnMode) |= REQ_MODE_STEREO;
273 : 0 : *pbStdFormat = 0;
274 : 0 : got = 1;
275 : : }
276 [ - + ]: 26 : else if ( !inchi_stricmp(pArg, "SUCF") )
277 : : {
278 [ # # ]: 0 : if ( (*pnMode) & REQ_MODE_RELATIVE_STEREO )
279 : : {
280 : 0 : (*pnMode) ^= REQ_MODE_RELATIVE_STEREO;
281 : : }
282 [ # # ]: 0 : if ( (*pnMode) & REQ_MODE_RACEMIC_STEREO )
283 : : {
284 : 0 : (*pnMode) ^= REQ_MODE_RACEMIC_STEREO;
285 : : }
286 : 0 : (*pnMode) |= REQ_MODE_CHIR_FLG_STEREO; /* stereo defined by the Chiral flag */
287 : 0 : (*pnMode) |= REQ_MODE_STEREO;
288 : 0 : *pbStdFormat = 0;
289 : 0 : got = 1;
290 : : }
291 [ - + ]: 26 : else if ( !inchi_stricmp(pArg, "ChiralFlagON") )
292 : : {
293 : : /* used only with /SUCF */
294 : : /* NB: do not toggle off bStdFormat! (if necessary SUCF will do) */
295 : 0 : (*pbForcedChiralFlag) &= ~FLAG_SET_INP_AT_NONCHIRAL;
296 : 0 : (*pbForcedChiralFlag) |= FLAG_SET_INP_AT_CHIRAL;
297 : 0 : got = 1;
298 : : }
299 [ - + ]: 26 : else if ( !inchi_stricmp(pArg, "ChiralFlagOFF") )
300 : : {
301 : : /* used only with /SUCF */
302 : : /* NB: do not toggle off bStdFormat! (if necessary SUCF will do) */
303 : 0 : (*pbForcedChiralFlag) &= ~FLAG_SET_INP_AT_CHIRAL;
304 : 0 : (*pbForcedChiralFlag) |= FLAG_SET_INP_AT_NONCHIRAL;
305 : 0 : got = 1;
306 : : }
307 : :
308 : : /*--- Non-std InChI creation options ---*/
309 : : /* These options DO TURN OFF Std flag */
310 [ - + ]: 26 : else if ( !inchi_stricmp(pArg, "SUU") )
311 : : {
312 : : /* include omitted undef/unknown stereo */
313 : 0 : (*pbVer1DefaultMode) &= ~(REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU);
314 : 0 : *pbStdFormat = 0;
315 : 0 : got = 1;
316 : : }
317 : : /* (@nnuk :: NaumanUllahKhan)
318 : : * Parameter option that deals with Molecular Inorganics
319 : : */
320 [ + + ]: 26 : else if ( !inchi_stricmp(pArg, "MolecularInorganics") )
321 : : {
322 : 22 : *pbMolecularInorganics = 1;
323 : 22 : *pbNPZz = 1;
324 : 22 : *pbStdFormat = 0;
325 : 22 : got = 1;
326 : : }
327 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "SLUUD") )
328 : : {
329 : : /* make labels for unknown and undefined stereo different */
330 : 0 : (*pbVer1DefaultMode) |= REQ_MODE_DIFF_UU_STEREO;
331 : 0 : *pbStdFormat = 0;
332 : 0 : got = 1;
333 : : }
334 : : /* FixedH */
335 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "FIXEDH") )
336 : : {
337 : 0 : (*pbVer1DefaultMode) |= REQ_MODE_BASIC; /* tautomeric */
338 : 0 : *pbStdFormat = 0;
339 : 0 : got = 1;
340 : : }
341 : : /* RecMet */
342 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "RECMET") )
343 : : {
344 : : /* reconnect metals */
345 : 0 : *pbReconnectCoord = 1;
346 : 0 : *pbStdFormat = 0;
347 : 0 : got = 1;
348 : : }
349 : : #if ( KETO_ENOL_TAUT == 1 )
350 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "KET") )
351 : : {
352 : 0 : *pbKetoEnolTaut = 1;
353 : 0 : *pbStdFormat = 0;
354 : 0 : got = 1;
355 : : }
356 : : #endif
357 : : #if ( TAUT_15_NON_RING == 1 )
358 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "15T") )
359 : : {
360 : 0 : *pb15TautNonRing = 1;
361 : 0 : *pbStdFormat = 0;
362 : 0 : got = 1;
363 : : }
364 : : #endif
365 : :
366 : : #if ( TAUT_PT_22_00 == 1 )
367 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "PT_22_00") )
368 : : {
369 : 0 : *pbPT_22_00_Taut = 1;
370 : 0 : *pbStdFormat = 0;
371 : : }
372 : : #endif
373 : :
374 : : #if ( TAUT_PT_16_00 == 1 )
375 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "PT_16_00") )
376 : : {
377 : 0 : *pbPT_16_00_Taut = 1;
378 : 0 : *pbStdFormat = 0;
379 : : }
380 : : #endif
381 : :
382 : : #if ( TAUT_PT_06_00 == 1 )
383 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "PT_06_00") )
384 : : {
385 : 0 : *pbPT_06_00_Taut = 1;
386 : 0 : *pbStdFormat = 0;
387 : : }
388 : : #endif
389 : :
390 : : #if ( TAUT_PT_39_00 == 1 )
391 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "PT_39_00") )
392 : : {
393 : 0 : *pbPT_39_00_Taut = 1;
394 : 0 : *pbStdFormat = 0;
395 : : }
396 : : #endif
397 : :
398 : : #if ( TAUT_PT_13_00 == 1 )
399 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "PT_13_00") )
400 : : {
401 : 0 : *pbPT_13_00_Taut = 1;
402 : 0 : *pbStdFormat = 0;
403 : : }
404 : : #endif
405 : :
406 : : #if ( TAUT_PT_18_00 == 1 )
407 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "PT_18_00") )
408 : : {
409 : 0 : *pbPT_18_00_Taut = 1;
410 : 0 : *pbStdFormat = 0;
411 : : }
412 : : #endif
413 : :
414 [ - + ]: 4 : else if ( !inchi_stricmp(pArg, "LargeMolecules") )
415 : : {
416 : 0 : *pbLargeMolecules = 1;
417 : 0 : got = 1;
418 : : }
419 [ + + ]: 4 : else if ( !inchi_stricmp(pArg, "Polymers") )
420 : : {
421 : 1 : *pbPolymers = POLYMERS_MODERN;
422 : 1 : got = 1;
423 : : }
424 [ - + ]: 3 : else if ( !inchi_stricmp(pArg, "Polymers105") )
425 : : {
426 : 0 : *pbPolymers = POLYMERS_LEGACY;
427 : 0 : got = 1;
428 : : }
429 [ + + ]: 3 : else if ( !inchi_stricmp(pArg, "NPZz") )
430 : : {
431 : 1 : *pbNPZz = 1;
432 : 1 : *pbMolecularInorganics = 1;
433 : 1 : got = 1;
434 : : }
435 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "NoWarnings") )
436 : : {
437 : 0 : *pbNoWarnings = 1;
438 : 0 : got = 1;
439 : : }
440 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "MergeHash") )
441 : : {
442 : 0 : *pbMergeHash = 1;
443 : 0 : got = 1;
444 : : }
445 [ + - - + ]: 2 : else if ( !inchi_stricmp(pArg, "NoInChI") || !inchi_stricmp(pArg, "HideInChI") )
446 : : {
447 : 0 : *pbHideInChI = 1;
448 : 0 : got = 1;
449 : : }
450 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "FoldCRU") ) /* v. 1.06 */
451 : : {
452 : 0 : *pbFoldPolymerSRU = 1;
453 : 0 : got = 1;
454 : : }
455 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "FoldSRU") ) /* v. 1.06 */
456 : : {
457 : 0 : *pbFoldPolymerSRU = 1;
458 : 0 : got = 1;
459 : : }
460 [ - + ]: 2 : else if ( !inchi_memicmp(pArg, "FrameShift:", 11) )
461 : : {
462 : : int k;
463 : : char wrd[256];
464 : 0 : k = 0;
465 : 0 : mystrncpy(wrd, pArg + 11, 256);
466 : 0 : lrtrim(wrd, &k);
467 [ # # ]: 0 : if ( k )
468 : : {
469 [ # # ]: 0 : if ( !inchi_stricmp(wrd, "None") )
470 : : {
471 : 0 : *pbFrameShiftScheme = FSS_NONE;
472 : : }
473 [ # # ]: 0 : else if ( !inchi_stricmp(wrd, "Cyclize") )
474 : : {
475 : 0 : *pbFrameShiftScheme = FSS_STARS_CYCLED;
476 : : }
477 [ # # ]: 0 : else if ( !inchi_stricmp(wrd, "MoveStars") )
478 : : {
479 : 0 : *pbFrameShiftScheme = FSS_STARS_OPENED;
480 : : }
481 [ # # ]: 0 : else if ( !inchi_stricmp(wrd, "MoveBrackets") )
482 : : {
483 : 0 : *pbFrameShiftScheme = FSS_STARS_ENDS_OPENED;
484 : : }
485 : : }
486 : : else
487 : : {
488 : 0 : *pbFrameShiftScheme = FSS_STARS_CYCLED;
489 : : }
490 : 0 : got = 1;
491 : : }
492 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "NoFrameShift") )
493 : : {
494 : 0 : *pbFrameShiftScheme = FSS_NONE;
495 : 0 : got = 1;
496 : : }
497 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "NoEdits") )
498 : : {
499 : 0 : *pbFoldPolymerSRU = 0;
500 : 0 : *pbFrameShiftScheme = FSS_NONE;
501 : 0 : got = 1;
502 : : }
503 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "SATZZ") )
504 : : {
505 : 0 : *pbStereoAtZz = 1;
506 : 0 : got = 1;
507 : : }
508 : :
509 : :
510 : : #endif /* ifndef USE_STDINCHI_API */
511 : :
512 [ + + - + ]: 75 : if ( !got && developer_options )
513 : : {
514 : :
515 [ # # ]: 0 : if ( !inchi_stricmp(pArg, "PGO") )
516 : : {
517 : : /* PGO : extract all good MOLfiles into the problem file */
518 : 0 : ip->bSaveAllGoodStructsAsProblem = 1;
519 : 0 : got = 1;
520 : : }
521 : : #if ( ALLOW_SUBSTRUCTURE_FILTERING== 1 )
522 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "FilterSS") )
523 : : {
524 : 0 : ip->bFilterSS = 1;
525 : 0 : got = 1;
526 : : }
527 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "InvFilterSS") )
528 : : {
529 : 0 : ip->bFilterSS = -1;
530 : 0 : got = 1;
531 : : }
532 : : #endif
533 : : /* Options below DO TURN OFF Std flag */
534 [ # # ]: 0 : if ( !inchi_stricmp(pArg, "FNUDOFF") )
535 : : {
536 : 0 : ip->bFixNonUniformDraw = 0;
537 : 0 : *pbStdFormat = 0;
538 : 0 : got = 1;
539 : : }
540 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "FixSp3bugOFF") )
541 : : {
542 : 0 : *pbFixSp3bug = 0;
543 : 0 : *pbStdFormat = 0;
544 : 0 : got = 1;
545 : : }
546 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "FBOFF") )
547 : : {
548 : 0 : *pbFixSp3bug = 0;
549 : 0 : *pbStdFormat = 0;
550 : 0 : got = 1;
551 : : }
552 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "FB2OFF") )
553 : : {
554 : 0 : *pbFixFB2 = 0;
555 : 0 : *pbStdFormat = 0;
556 : 0 : got = 1;
557 : : }
558 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "SPXYZOFF") )
559 : : {
560 : 0 : *pbAddPhosphineStereo = 0;
561 : 0 : *pbStdFormat = 0;
562 : 0 : got = 1;
563 : : }
564 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "SASXYZOFF") )
565 : : {
566 : 0 : *pbAddArsineStereo = 0;
567 : 0 : *pbStdFormat = 0;
568 : 0 : got = 1;
569 : : }
570 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "Polymers105+") )
571 : : {
572 : 0 : *pbPolymers = POLYMERS_LEGACY_PLUS;
573 : 0 : *pbStdFormat = 0;
574 : 0 : got = 1;
575 : : }
576 : :
577 : :
578 : : }
579 : :
580 : 75 : return got;
581 : : }
582 : :
583 : :
584 : : /****************************************************************************
585 : : Parse command line and set processing options
586 : : ****************************************************************************/
587 : 123 : int ReadCommandLineParms(int argc,
588 : : const char* argv[],
589 : : INPUT_PARMS* ip,
590 : : char* szSdfDataValue,
591 : : unsigned long* ulDisplTime,
592 : : int bReleaseVersion,
593 : : INCHI_IOSTREAM* log_file)
594 : : {
595 : : #if (BUILD_WITH_ENG_OPTIONS==1)
596 : : const int developer_options = 1;
597 : : #else
598 : 123 : const int developer_options = 0;
599 : : #endif
600 : : const char* q;
601 : : const char* ext[MAX_NUM_PATHS + 1];
602 : : const char* pArg;
603 : : char szNameSuffix[32], szOutputPath[512];
604 : :
605 : : unsigned long ul;
606 : :
607 : 123 : double t = 0;
608 : :
609 : 123 : int bVer1Options = 1;
610 : 123 : int nMode = 0;
611 : 123 : int nReleaseMode = nMode | (REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_STEREO);
612 : 123 : INCHI_MODE bVer1DefaultMode = VER103_DEFAULT_MODE;
613 : :
614 : : int bNameSuffix;
615 : : int bOutputPath;
616 : : int bMergeAllInputStructures;
617 : 123 : int bForcedChiralFlag = 0;
618 : :
619 : 123 : int bDisconnectSalts = (DISCONNECT_SALTS == 1);
620 : 123 : int bDoNotAddH = 0;
621 : : int bRecognizedOption;
622 : 123 : int bTgFlagVariableProtons = 1;
623 : 123 : int bTgFlagHardAddRenProtons = 1;
624 : 123 : int bReconnectCoord = (RECONNECT_METALS == 1);
625 : 123 : int bDisconnectCoord = (DISCONNECT_METALS == 1);
626 : 123 : int bDisconnectCoordChkVal = (CHECK_METAL_VALENCE == 1);
627 : 123 : int bMovePositiveCharges = (MOVE_CHARGES == 1);
628 : 123 : int bAcidTautomerism = (DISCONNECT_SALTS == 1) ? (TEST_REMOVE_S_ATOMS == 1 ? 2 : 1) : 0;
629 : 123 : int bUnchargedAcidTaut = (CHARGED_SALTS_ONLY == 0);
630 : 123 : int bMergeSaltTGroups = (DISCONNECT_SALTS == 1);
631 : 123 : int bEnhancedStereochemistry = 0;
632 : : #if ( MIN_SB_RING_SIZE > 0 )
633 : 123 : int nMinDbRinSize = MIN_SB_RING_SIZE, mdbr = 0;
634 : : #endif
635 : : #ifdef STEREO_WEDGE_ONLY
636 : 123 : int bPointedEdgeStereo = STEREO_WEDGE_ONLY; /* NEWPS TG_FLAG_POINTED_EDGE_STEREO */
637 : : #endif
638 : : #if ( FIX_ADJ_RAD == 1 )
639 : : int bFixAdjacentRad = 0;
640 : : #endif
641 : 123 : int bAddPhosphineStereo = 1;
642 : 123 : int bAddArsineStereo = 1;
643 : 123 : int bFixSp3bug = 1;
644 : 123 : int bFixFB2 = 1;
645 : 123 : int bKetoEnolTaut = 0;
646 : 123 : int b15TautNonRing = 0;
647 : 123 : int bPT_22_00_Taut = 0;
648 : 123 : int bPT_16_00_Taut = 0;
649 : 123 : int bPT_06_00_Taut = 0;
650 : 123 : int bPT_39_00_Taut = 0;
651 : 123 : int bPT_13_00_Taut = 0;
652 : 123 : int bPT_18_00_Taut = 0;
653 : 123 : int bStdFormat = 1;
654 : 123 : int bHashKey = 0;
655 : 123 : int bHashXtra1 = 0;
656 : 123 : int bHashXtra2 = 0;
657 : 123 : int bLargeMolecules = 0;
658 : 123 : int bPolymers = POLYMERS_NO;
659 : : #ifdef TARGET_LIB_FOR_WINCHI
660 : : int bFoldPolymerSRU = 0;
661 : : int bFrameShiftScheme = FSS_STARS_CYCLED;
662 : : #else
663 : 123 : int bFoldPolymerSRU = 0;
664 : 123 : int bFrameShiftScheme = FSS_STARS_CYCLED;
665 : : #endif
666 : 123 : int bLooseTSACheck = 0;
667 : 123 : int bStereoAtZz = 0;
668 : 123 : int bNPZz = 0;
669 : 123 : int bNoWarnings = 0;
670 : 123 : int bMergeHash = 0;
671 : 123 : int bHideInChI = 0;
672 : 123 : int bMolecularInorganics = 0; /* @nnuk */
673 : 123 : int bOutputStyle = INCHI_OUT_PLAIN_TEXT;
674 : 123 : int bDisplay = 0;
675 : 123 : int bNoStructLabels = 0;
676 : 123 : int bOutputMolfileOnly = 0;
677 : 123 : int bOutputMolfileDT = 0;
678 : 123 : int bOutputMolfileSplit = 0;
679 : 123 : int bDisplayCompositeResults = 0; /* djb-rwth: ignoring LLVM warning: variable used */
680 : 123 : int nFontSize = -9; /* djb-rwth: ignoring LLVM warning: variable used */
681 : 123 : int bINChIOutputOptions2 = 0;
682 : : #ifdef TARGET_LIB_FOR_WINCHI
683 : : int is_gui = 1;
684 : : int bINChIOutputOptions = INCHI_OUT_EMBED_REC; /* embed reconnected & output full aux info */
685 : : int bCompareComponents = CMP_COMPONENTS;
686 : : #else
687 : 123 : int is_gui = 0;
688 : 123 : int bINChIOutputOptions = ((EMBED_REC_METALS_INCHI == 1) ? INCHI_OUT_EMBED_REC : 0);
689 : 123 : int bCompareComponents = 0;
690 : : #endif
691 : : #if ( READ_INCHI_STRING == 1 )
692 : 123 : int bDisplayIfRestoreWarnings = 0;
693 : : #endif
694 : : #if ( BUILD_WITH_AMI == 1 ) && ( OUTPUT_FILE_EXT == 1 )
695 : : int numOutNameExt;
696 : : char szOutNameExt[3][128];
697 : : #endif
698 : :
699 : : int i, k, c, got;
700 : 123 : int timeout_set_warning = 0;
701 : 123 : int timeout_set_error = 0;
702 : :
703 : 123 : ext[0] = ".mol";
704 [ + - ]: 123 : ext[1] = bVer1Options ? ".txt" : ".ich";
705 : 123 : ext[2] = ".log";
706 : 123 : ext[3] = ".prb";
707 : 123 : ext[4] = "";
708 : :
709 : : /* Init table of parameters */
710 : 123 : memset(ip, 0, sizeof(*ip)); /* djb-rwth: memset_s C11/Annex K variant? */
711 : :
712 : : /* Default are StdInChI generation options */
713 : 123 : bVer1DefaultMode &= ~REQ_MODE_BASIC; /* "FIXEDH - OFF" */
714 : 123 : bReconnectCoord = 0; /* "RECMET - OFF" */
715 : 123 : bPointedEdgeStereo = 1; /* "NEWPS" */
716 : 123 : ip->bFixNonUniformDraw = 1; /* "FNUD" */
717 : :
718 : : #ifndef COMPILE_ANSI_ONLY
719 : : strcpy(ip->tdp.ReqShownFoundTxt[ilSHOWN], "Shown");
720 : : ip->dp.sdp.tdp = &ip->tdp;
721 : : ip->dp.pdp = &ip->pdp;
722 : : #endif
723 : 123 : memset(szNameSuffix, 0, sizeof(szNameSuffix)); /* djb-rwth: memset_s C11/Annex K variant? */
724 : 123 : bNameSuffix = 0;
725 : 123 : memset(szOutputPath, 0, sizeof(szOutputPath)); /* djb-rwth: memset_s C11/Annex K variant? */
726 : 123 : bOutputPath = 0;
727 : : #if( OUTPUT_FILE_EXT == 1 )
728 : : memset(szOutNameExt, 0, sizeof(szOutNameExt)); /* djb-rwth: memset_s C11/Annex K variant? */
729 : : numOutNameExt = 0;
730 : : #endif
731 : 123 : bMergeAllInputStructures = 0;
732 : : #ifdef TARGET_API_LIB
733 : 123 : ip->msec_MaxTime = 0; /* milliseconds, default in libinchi: unlimited */
734 : : #else
735 : : ip->msec_MaxTime = 60000; /* milliseconds, default: 60 sec */
736 : : #endif
737 : 123 : * ulDisplTime = 0;
738 : :
739 [ + - ]: 123 : if ( bReleaseVersion )
740 : : {
741 : : /* normal */
742 : 123 : ip->bAbcNumbers = 0;
743 : 123 : ip->bCtPredecessors = 0;
744 : : }
745 : : else
746 : : {
747 : 0 : nReleaseMode = 0;
748 : : }
749 [ + - ]: 123 : if ( bVer1Options )
750 : : {
751 : 123 : bNameSuffix = 1;
752 : 123 : szNameSuffix[0] = '\0';
753 : : }
754 : :
755 : : #if ( ALLOW_SUBSTRUCTURE_FILTERING== 1 )
756 : 123 : ip->bFilterSS = 0;
757 : : #endif
758 : :
759 : :
760 : :
761 : : /* Analyze command line switches */
762 [ + + ]: 198 : for ( i = 1; i < argc; i++ )
763 : : {
764 : :
765 [ - + - - : 75 : if ( is_gui && INCHI_OPTION_PREFX == argv[i][0] && INCHI_OPTION_PREFX != argv[i][1] )
- - ]
766 : : {
767 : : /* Parsing TARGET_LIB_FOR_WINCHI GUI options (and v. 0.9xx Beta as well) */
768 : 0 : pArg = argv[i] + 1;
769 : 0 : got = set_common_options_by_parg(pArg, developer_options, ip, &bVer1DefaultMode, &nMode,
770 : : &bINChIOutputOptions, &bINChIOutputOptions2,
771 : : &bStdFormat, &bHashKey, &bHashXtra1, &bHashXtra2,
772 : : &bFixSp3bug, &bFixFB2,
773 : : &bAddPhosphineStereo, &bAddArsineStereo,
774 : : &bNoStructLabels, &bPointedEdgeStereo,
775 : : &bDoNotAddH, &bForcedChiralFlag, &bReconnectCoord,
776 : : &bKetoEnolTaut,
777 : : &b15TautNonRing,
778 : : &bPT_06_00_Taut, &bPT_13_00_Taut, &bPT_16_00_Taut,
779 : : &bPT_18_00_Taut, &bPT_22_00_Taut, &bPT_39_00_Taut,
780 : : &bLooseTSACheck,
781 : : &bLargeMolecules, &bPolymers,
782 : : &bFoldPolymerSRU, &bFrameShiftScheme,
783 : : &bStereoAtZz, &bNPZz,
784 : : &bNoWarnings, &bMergeHash, &bHideInChI, &bMolecularInorganics, &bEnhancedStereochemistry);
785 [ # # ]: 0 : if (got)
786 : : {
787 : : ;
788 : : }
789 [ # # # # ]: 0 : else if ( INPUT_NONE == ip->nInputType &&
790 : 0 : (!inchi_memicmp(pArg, "SDF", 3)) &&
791 [ # # ]: 0 : (pArg[3] == ':') )
792 : : {
793 : 0 : k = 0;
794 : 0 : mystrncpy(ip->szSdfDataHeader, pArg + 4, MAX_SDF_HEADER + 1);
795 : 0 : lrtrim(ip->szSdfDataHeader, &k);
796 [ # # ]: 0 : if ( k )
797 : : {
798 : 0 : ip->pSdfLabel = ip->szSdfDataHeader;
799 : 0 : ip->pSdfValue = szSdfDataValue;
800 : 0 : ip->nInputType = INPUT_SDFILE;
801 : : }
802 : : else
803 : : {
804 : 0 : ip->pSdfLabel = NULL;
805 : 0 : ip->pSdfValue = NULL;
806 : 0 : ip->nInputType = INPUT_MOLFILE;
807 : : }
808 : : }
809 [ # # # # ]: 0 : else if ( INPUT_NONE == ip->nInputType && !inchi_stricmp(pArg, "MOL") )
810 : : {
811 : 0 : ip->nInputType = INPUT_MOLFILE;
812 : : }
813 [ # # # # ]: 0 : else if ( INPUT_NONE == ip->nInputType && !inchi_stricmp(pArg, "SDF") )
814 : : {
815 : 0 : ip->nInputType = INPUT_MOLFILE;
816 : : }
817 : : /*--- Output options ---*/
818 : : #if ( !defined(TARGET_API_LIB) && !defined(TARGET_LIB_FOR_WINCHI) )
819 : : else if ( !inchi_stricmp(pArg, "Tabbed") || !inchi_stricmp(pArg, "Tab") )
820 : : {
821 : : bOutputStyle |= INCHI_OUT_TABBED_OUTPUT;
822 : : }
823 : : #endif
824 : :
825 : : /* Removed condition
826 : : #if ( defined(BUILD_WITH_ENG_OPTIONS) || defined(TARGET_LIB_FOR_WINCHI) )
827 : : which is always true, as we already are under condition
828 : : 'if ( is_gui && ...)' and is_gui==1 means TARGET_LIB_FOR_WINCHI
829 : : */
830 : : /* #if ( defined(BUILD_WITH_ENG_OPTIONS) || defined(TARGET_LIB_FOR_WINCHI) ) */
831 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "SDFID") )
832 : : {
833 : 0 : ip->bGetSdfileId = 1;
834 : : }
835 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "PLAIN") )
836 : : {
837 : 0 : bOutputStyle |= INCHI_OUT_PLAIN_TEXT;
838 : : }
839 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "ANNPLAIN") )
840 : : {
841 : 0 : bOutputStyle |= INCHI_OUT_PLAIN_TEXT_COMMENTS;
842 : : }
843 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "AUXINFO:", 8) && isdigit(UCINT pArg[8]) )
844 : : {
845 : 0 : k = strtol(pArg + 8, NULL, 10);
846 [ # # ]: 0 : if ( k == 0 )
847 : : {
848 : 0 : bINChIOutputOptions |= INCHI_OUT_NO_AUX_INFO; /* no aux info */
849 : 0 : bINChIOutputOptions &= ~INCHI_OUT_SHORT_AUX_INFO;
850 : : }
851 [ # # ]: 0 : else if ( k == 1 )
852 : : {
853 : 0 : bINChIOutputOptions &= ~(INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO); /* include full aux info */
854 : : }
855 [ # # ]: 0 : else if ( k == 2 )
856 : : {
857 : 0 : bINChIOutputOptions &= ~INCHI_OUT_NO_AUX_INFO; /* include short aux info */
858 : 0 : bINChIOutputOptions |= INCHI_OUT_SHORT_AUX_INFO;
859 : : }
860 : : else
861 : : {
862 : 0 : bINChIOutputOptions = k; /* override everything */
863 : : }
864 : : }
865 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "MERGE") )
866 : : {
867 : 0 : bMergeAllInputStructures = 1;
868 : : }
869 : :
870 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "PGO") )
871 : : {
872 : 0 : ip->bSaveAllGoodStructsAsProblem = 1;
873 : : }
874 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "DCR") )
875 : : {
876 : 0 : bDisplayCompositeResults = 1;
877 : : }
878 : :
879 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "DSB") )
880 : : {
881 : 0 : nMode |= REQ_MODE_NO_ALT_SBONDS;
882 : : }
883 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "NOHDR") )
884 : : {
885 : 0 : bNoStructLabels = 1;
886 : : }
887 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "NoVarH") )
888 : : {
889 : 0 : bTgFlagVariableProtons = 0;
890 : : }
891 : : /*--- (hidden) Old structure-perception and InChI creation options ---*/
892 : : /*--- (engineering) Old structure-perception and InChI creation options ---*/
893 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "NOUUSB") )
894 : : {
895 : 0 : nMode |= REQ_MODE_SB_IGN_ALL_UU;
896 : 0 : bStdFormat = 0;
897 : : }
898 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "NOUUSC") )
899 : : {
900 : 0 : nMode |= REQ_MODE_SC_IGN_ALL_UU;
901 : 0 : bStdFormat = 0;
902 : : }
903 : : #if ( FIX_ADJ_RAD == 1 )
904 : : else if ( !inchi_stricmp(pArg, "FixRad") )
905 : : {
906 : : bFixAdjacentRad = 1;
907 : : bStdFormat = 0;
908 : : }
909 : : #endif
910 : :
911 : : #if ( RENUMBER_ATOMS_AND_RECALC_V106 == 1 )
912 : : else if ( !inchi_stricmp(pArg, "TestRenum") && developer_options )
913 : : {
914 : : ip->bRenumber = 1;
915 : : }
916 : : #endif
917 : :
918 : : #if ( UNDERIVATIZE == 1 )
919 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "DoDRV") )
920 : : {
921 : 0 : ip->bUnderivatize = 1;
922 : 0 : bStdFormat = 0;
923 : : }
924 : : #if( UNDERIVATIZE_REPORT == 1 )
925 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "DoDrvReport") )
926 : : {
927 : 0 : ip->bUnderivatize = 3;
928 : 0 : bStdFormat = 0;
929 : : }
930 : : #endif
931 : : #endif
932 : : #if ( RING2CHAIN == 1 )
933 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "DoR2C") )
934 : : {
935 : 0 : ip->bRing2Chain = 1;
936 : 0 : bStdFormat = 0;
937 : : }
938 : : #endif
939 : : #if ( RING2CHAIN == 1 || UNDERIVATIZE == 1 )
940 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "DoneOnly") )
941 : : {
942 : 0 : ip->bIgnoreUnchanged = 1;
943 : 0 : bStdFormat = 0;
944 : : }
945 : : #endif
946 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "NoADP") )
947 : : {
948 : 0 : bTgFlagHardAddRenProtons = 0;
949 : 0 : bStdFormat = 0;
950 : : }
951 [ # # ]: 0 : else if ( !inchi_memicmp(pArg, "DISCONSALT:", 11) )
952 : : {
953 : 0 : bDisconnectSalts = (0 != strtol(pArg + 11, NULL, 10));
954 : 0 : bStdFormat = 0;
955 : : }
956 [ # # ]: 0 : else if ( !inchi_memicmp(pArg, "DISCONMETAL:", 12) )
957 : : {
958 : 0 : bDisconnectCoord = (0 != strtol(pArg + 12, NULL, 10));
959 : 0 : bStdFormat = 0;
960 : : }
961 [ # # ]: 0 : else if ( !inchi_memicmp(pArg, "RECONMETAL:", 11) )
962 : : {
963 : 0 : bReconnectCoord = (0 != strtol(pArg + 11, NULL, 10));
964 : 0 : bStdFormat = 0;
965 : : }
966 [ # # ]: 0 : else if ( !inchi_memicmp(pArg, "DISCONMETALCHKVAL:", 18) )
967 : : {
968 : 0 : bDisconnectCoordChkVal = (0 != strtol(pArg + 18, NULL, 10));
969 : 0 : bStdFormat = 0;
970 : : }
971 [ # # ]: 0 : else if ( !inchi_memicmp(pArg, "MOVEPOS:", 8) )
972 : : {
973 : 0 : bMovePositiveCharges = (0 != strtol(pArg + 8, NULL, 10));
974 : 0 : bStdFormat = 0;
975 : : }
976 [ # # ]: 0 : else if ( !inchi_memicmp(pArg, "MERGESALTTG:", 12) )
977 : : {
978 : 0 : bMergeSaltTGroups = (0 != strtol(pArg + 12, NULL, 10));
979 : 0 : bStdFormat = 0;
980 : : }
981 [ # # ]: 0 : else if ( !inchi_memicmp(pArg, "UNCHARGEDACIDS:", 15) )
982 : : {
983 : 0 : bUnchargedAcidTaut = (0 != strtol(pArg + 15, NULL, 16));
984 : 0 : bStdFormat = 0;
985 : : }
986 [ # # ]: 0 : else if ( !inchi_memicmp(pArg, "ACIDTAUT:", 9) )
987 : : {
988 : 0 : bAcidTautomerism = c = (int)strtol(pArg + 9, NULL, 10);
989 [ # # # # ]: 0 : if ( 0 <= c && c <= 2 ) bAcidTautomerism = c;
990 : : /*else bNotRecognized = 2*bReleaseVersion;*/
991 : 0 : bStdFormat = 0;
992 : : }
993 : : /*--- (hidden) Old output and other options ---*/
994 [ # # ]: 0 : else if ( !inchi_memicmp(pArg, "O:", 2) )
995 : : {
996 : 0 : bNameSuffix = 1;
997 : 0 : strncpy(szNameSuffix, pArg + 2, sizeof(szNameSuffix) - 1);
998 : : }
999 [ # # ]: 0 : else if ( !inchi_memicmp(pArg, "OP:", 3) )
1000 : : {
1001 : 0 : bOutputPath = 1;
1002 : 0 : strncpy(szOutputPath, pArg + 3, sizeof(szOutputPath) - 1);
1003 : : }
1004 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "ALT") )
1005 : : {
1006 : 0 : ip->bAbcNumbers = 1;
1007 : 0 : bStdFormat = 0;
1008 : : }
1009 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "SCT") )
1010 : : {
1011 : 0 : ip->bCtPredecessors = 1;
1012 : 0 : bStdFormat = 0;
1013 : : }
1014 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "CMP") )
1015 : : {
1016 : 0 : bCompareComponents = CMP_COMPONENTS;
1017 : : }
1018 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "CMPNONISO") )
1019 : : {
1020 : 0 : bCompareComponents = CMP_COMPONENTS | CMP_COMPONENTS_NONISO;
1021 : : }
1022 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "PW") )
1023 : : {
1024 : 0 : ip->bSaveWarningStructsAsProblem = 1;
1025 : : }
1026 : :
1027 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "RSB:", 4) && developer_options )
1028 : : {
1029 : 0 : mdbr = (int)strtol(pArg + 4, NULL, 10);
1030 : : }
1031 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "DISCONSALT:", 11) && developer_options )
1032 : : {
1033 : 0 : bDisconnectSalts = (0 != strtol(pArg + 11, NULL, 10));
1034 : : }
1035 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "DISCONMETAL:", 12) && developer_options )
1036 : : {
1037 : 0 : bDisconnectCoord = (0 != strtol(pArg + 12, NULL, 10));
1038 : : }
1039 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "RECONMETAL:", 11) && developer_options )
1040 : : {
1041 : 0 : bReconnectCoord = (0 != strtol(pArg + 11, NULL, 10));
1042 : : }
1043 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "DISCONMETALCHKVAL:", 18) && developer_options )
1044 : : {
1045 : 0 : bDisconnectCoordChkVal = (0 != strtol(pArg + 18, NULL, 10));
1046 : : }
1047 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "MOVEPOS:", 8) && developer_options )
1048 : : {
1049 : 0 : bMovePositiveCharges = (0 != strtol(pArg + 8, NULL, 10));
1050 : : }
1051 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "MERGESALTTG:", 12) && developer_options )
1052 : : {
1053 : 0 : bMergeSaltTGroups = (0 != strtol(pArg + 12, NULL, 10));
1054 : : }
1055 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "UNCHARGEDACIDS:", 15) && developer_options )
1056 : : {
1057 : 0 : bUnchargedAcidTaut = (0 != strtol(pArg + 15, NULL, 16));;
1058 : : }
1059 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "ACIDTAUT:", 9) && developer_options )
1060 : : {
1061 : 0 : bAcidTautomerism = c = (int)strtol(pArg + 9, NULL, 10);
1062 [ # # # # ]: 0 : if ( 0 <= c && c <= 2 )
1063 : : {
1064 : 0 : bAcidTautomerism = c;
1065 : : }
1066 : : /*else bNotRecognized = 2*bReleaseVersion;*/
1067 : : }
1068 : :
1069 : : else
1070 : : {
1071 : : /*for ( k = 0; c=pArg[k]; k ++ )*/
1072 : 0 : k = 0;
1073 : 0 : c = pArg[k]; /* prohibit multiple option concatenations, strict syntax check 2008-11-05 DT */
1074 : : {
1075 : 0 : c = toupper(c);
1076 [ # # # # ]: 0 : switch ( c )
1077 : : {
1078 : 0 : case 'D':
1079 : 0 : bDisplay |= 1;
1080 [ # # # # : 0 : if ( (pArg[k + 1] == 'C' || pArg[k + 1] == 'c') && !pArg[k + 2] )
# # ]
1081 : : {
1082 : 0 : bDisplay |= 1;
1083 : 0 : k++;
1084 : 0 : ip->bDisplayEachComponentINChI = 1;
1085 : : }
1086 [ # # ]: 0 : else if ( !pArg[k + 1] )
1087 : : {
1088 : 0 : bDisplay |= 1;
1089 : : }
1090 : 0 : break;
1091 : 0 : case 'W':
1092 [ # # ]: 0 : if ( pArg[k + 1] == 'D' )
1093 : : {
1094 : : /* restore Display Time functionality */
1095 : 0 : c = 'D';
1096 : 0 : k++;
1097 : : }
1098 : 0 : t = strtod(pArg + k + 1, (char**)&q); /* cast deliberately discards 'const' qualifier */
1099 [ # # # # : 0 : if ( (q > pArg + k + 1 && errno == ERANGE) || t < 0.0 || t * 1000.0 >(double)ULONG_MAX ) /* djb-rwth: addressing LLVM warning */
# # # # ]
1100 : : {
1101 : 0 : ul = 0;
1102 : : }
1103 : : else
1104 : : {
1105 : 0 : ul = (unsigned long)(t * 1000.0);
1106 : : }
1107 [ # # ]: 0 : if ( /*q > pArg+k &&*/ !*q )
1108 : : {
1109 : 0 : k = q - pArg - 1; /* k will be incremented by the for() cycle */
1110 [ # # # ]: 0 : switch ( c )
1111 : : {
1112 : 0 : case 'D':
1113 : 0 : *ulDisplTime = ul;
1114 : 0 : break;
1115 : 0 : case 'W':
1116 : 0 : ip->msec_MaxTime = ul;
1117 : 0 : break;
1118 : : }
1119 : : }
1120 : 0 : break;
1121 : 0 : case 'F':
1122 : 0 : c = (int)strtol(pArg + k + 1, (char**)&q, 10); /* cast deliberately discards 'const' qualifier */
1123 [ # # # # ]: 0 : if ( q > pArg + k && !*q )
1124 : : {
1125 : 0 : k = q - pArg - 1;
1126 [ # # ]: 0 : if ( abs(c) > 5 )
1127 : : {
1128 : 0 : nFontSize = -c; /* font size 5 or less is too small */
1129 : : }
1130 : : }
1131 : 0 : break;
1132 : 0 : default:
1133 [ # # ]: 0 : if ( !pArg[k + 1] )
1134 : : {
1135 [ # # # # : 0 : switch ( c )
# # # ]
1136 : : {
1137 : 0 : case 'B':
1138 : 0 : nMode |= REQ_MODE_BASIC;
1139 : 0 : nReleaseMode = 0;
1140 : : /*bNotRecognized = bReleaseVersion;*/
1141 : 0 : bStdFormat = 0;
1142 : 0 : break;
1143 : 0 : case 'T':
1144 : 0 : nMode |= REQ_MODE_TAUT;
1145 : 0 : nReleaseMode = 0;
1146 : : /*bNotRecognized = bReleaseVersion;*/
1147 : 0 : break;
1148 : 0 : case 'I':
1149 : 0 : nMode |= REQ_MODE_ISO;
1150 : 0 : nReleaseMode = 0;
1151 : : /*bNotRecognized = bReleaseVersion;*/
1152 : 0 : break;
1153 : 0 : case 'N':
1154 : 0 : nMode |= REQ_MODE_NON_ISO;
1155 : 0 : nReleaseMode = 0;
1156 : 0 : bStdFormat = 0;
1157 : : /*bNotRecognized = bReleaseVersion;*/
1158 : 0 : break;
1159 : 0 : case 'S':
1160 : 0 : nMode |= REQ_MODE_STEREO;
1161 : 0 : nReleaseMode = 0;
1162 : : /*bNotRecognized = bReleaseVersion;*/
1163 : 0 : break;
1164 : 0 : case 'E':
1165 [ # # ]: 0 : if ( nReleaseMode & REQ_MODE_STEREO )
1166 : : {
1167 : 0 : nReleaseMode ^= REQ_MODE_STEREO;
1168 : 0 : bStdFormat = 0;
1169 : : }
1170 : 0 : break;
1171 : :
1172 : : #ifndef TARGET_LIB_FOR_WINCHI
1173 : 0 : default:
1174 : 0 : inchi_ios_eprint(log_file, "Unrecognized optionQ1: \"%c\".\n", c);
1175 : :
1176 : : #endif
1177 : : }
1178 : : }
1179 : :
1180 : :
1181 : : #ifndef TARGET_LIB_FOR_WINCHI
1182 : : else
1183 : : {
1184 : 0 : inchi_ios_eprint(log_file, "Unrecognized optionQ2: \"%c\".\n", c);
1185 : : }
1186 : : #endif
1187 : : }
1188 : : /*
1189 : : if ( bNotRecognized && bNotRecognized == bReleaseVersion ) {
1190 : : inchi_ios_eprint(stderr, "Unrecognized option: \"%c\".\n", c);
1191 : : bNotRecognized = 0;
1192 : : }
1193 : : */
1194 : : }
1195 : : }
1196 : :
1197 : : /*
1198 : : if ( bNotRecognized && bNotRecognized == 2*bReleaseVersion )
1199 : : {
1200 : : inchi_ios_eprint(stderr, "Unrecognized option: \"%s\".\n", argv[i]);
1201 : : bNotRecognized = 0;
1202 : : }
1203 : : */
1204 : :
1205 : : } /* eof Parsing TARGET_LIB_FOR_WINCHI GUI options (and v. 0.9xx Beta as well) */
1206 : :
1207 [ + - + - : 75 : else if ( (bVer1Options & 1) && INCHI_OPTION_PREFX == argv[i][0] && argv[i][1] )
+ - ]
1208 : : {
1209 : : /* Parsing stand-alone executable/libinchi options */
1210 : :
1211 : 75 : pArg = argv[i] + 1;
1212 : :
1213 : 75 : bRecognizedOption = 2;
1214 : 75 : bVer1Options += 2;
1215 : : /* always on: REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_STEREO */
1216 : :
1217 : 75 : got = set_common_options_by_parg(pArg, developer_options, ip, &bVer1DefaultMode, &nMode,
1218 : : &bINChIOutputOptions, &bINChIOutputOptions2,
1219 : : &bStdFormat, &bHashKey, &bHashXtra1, &bHashXtra2,
1220 : : &bFixSp3bug, &bFixFB2,
1221 : : &bAddPhosphineStereo, &bAddArsineStereo,
1222 : : &bNoStructLabels, &bPointedEdgeStereo,
1223 : : &bDoNotAddH, &bForcedChiralFlag, &bReconnectCoord,
1224 : : &bKetoEnolTaut,
1225 : : &b15TautNonRing,
1226 : : &bPT_06_00_Taut, &bPT_13_00_Taut, &bPT_16_00_Taut,
1227 : : &bPT_18_00_Taut, &bPT_22_00_Taut, &bPT_39_00_Taut,
1228 : : &bLooseTSACheck,
1229 : : &bLargeMolecules, &bPolymers,
1230 : : &bFoldPolymerSRU, &bFrameShiftScheme,
1231 : : &bStereoAtZz, &bNPZz,
1232 : : &bNoWarnings, &bMergeHash, &bHideInChI, &bMolecularInorganics, &bEnhancedStereochemistry);
1233 : :
1234 [ + + ]: 75 : if ( got )
1235 : : {
1236 : : ;
1237 : : }
1238 : : /* Input */
1239 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "STDIO") )
1240 : : {
1241 : 0 : bNameSuffix = 0;
1242 : : }
1243 [ - + ]: 2 : else if ( /* INPUT_NONE == ip->nInputType &&*/
1244 : 2 : !inchi_memicmp(pArg, "SDF:", 4) )
1245 : : {
1246 : : /* SDfile label */
1247 : 0 : k = 0;
1248 : 0 : mystrncpy(ip->szSdfDataHeader, pArg + 4, MAX_SDF_HEADER + 1);
1249 : 0 : lrtrim(ip->szSdfDataHeader, &k);
1250 [ # # ]: 0 : if ( k )
1251 : : {
1252 : 0 : ip->pSdfLabel = ip->szSdfDataHeader;
1253 : 0 : ip->pSdfValue = szSdfDataValue;
1254 [ # # ]: 0 : if ( INPUT_NONE == ip->nInputType )
1255 : : {
1256 : 0 : ip->nInputType = INPUT_SDFILE;
1257 : : }
1258 : : }
1259 : : else
1260 : : {
1261 : 0 : ip->pSdfLabel = NULL;
1262 : 0 : ip->pSdfValue = NULL;
1263 [ # # ]: 0 : if ( INPUT_NONE == ip->nInputType )
1264 : : {
1265 : 0 : ip->nInputType = INPUT_MOLFILE;
1266 : : }
1267 : : }
1268 : : }
1269 : :
1270 [ - + - - ]: 2 : else if ( !inchi_memicmp(pArg, "RSB:", 4) && developer_options )
1271 : : {
1272 : 0 : mdbr = (int)strtol(pArg + 4, NULL, 10);
1273 : : }
1274 : :
1275 : : /* Output */
1276 : : #if ( !defined(TARGET_API_LIB) && !defined(TARGET_LIB_FOR_WINCHI) )
1277 : : else if ( !inchi_stricmp(pArg, "Tabbed") || !inchi_stricmp(pArg, "Tab") )
1278 : : {
1279 : : bOutputStyle |= INCHI_OUT_TABBED_OUTPUT;
1280 : : }
1281 : : #endif
1282 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "OUTPUTSDF") )
1283 : : {
1284 : : /* output SDfile */
1285 : 0 : bOutputMolfileOnly = 1;
1286 : : }
1287 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "SdfAtomsDT") )
1288 : : {
1289 : : /* output isotopes H as D and T in SDfile */
1290 : 0 : bOutputMolfileDT = 1;
1291 : : }
1292 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "D") )
1293 : : {
1294 : : /* display the structures */
1295 : 0 : bDisplay |= 1;
1296 : : }
1297 [ - + - - ]: 2 : else if ( !inchi_memicmp(pArg, "F", 1) && (c = (int)strtol(pArg + 1, (char**)&q, 10), q > pArg + 1) )
1298 : : {
1299 : 0 : nFontSize = -c; /* struct. display font size */
1300 : : }
1301 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "EQU") )
1302 : : {
1303 : 0 : bCompareComponents = CMP_COMPONENTS;
1304 : : }
1305 : : #if( OUTPUT_FILE_EXT == 1 )
1306 : : else if ( pArg[0] == '.' && numOutNameExt < (int)(sizeof(szOutNameExt) / sizeof(szOutNameExt[0])) )
1307 : : {
1308 : : strncpy(szOutNameExt[numOutNameExt], pArg, sizeof(szOutNameExt[0]) - 1);
1309 : : numOutNameExt++;
1310 : : if ( ip->path[numOutNameExt] )
1311 : : {
1312 : : ip->path[numOutNameExt] = ""; /*strcpy( ip->path[numOutNameExt], "");*/
1313 : : }
1314 : : }
1315 : : #endif
1316 : : /* djb-rwth: avoiding Error 98 for empty .mol files -- GH issue #25, thanks to @wijnand1 */
1317 [ - + ]: 2 : else if ( !inchi_stricmp(pArg, "WarnOnEmptyStructure") )
1318 : : {
1319 : 0 : ip->bAllowEmptyStructure = 1;
1320 : : }
1321 : :
1322 : : /* Generation options */
1323 [ - + ]: 2 : else if ( !inchi_memicmp(pArg, "W", 1) )
1324 : : {
1325 : : long timeout_value;
1326 : 0 : const char c1 = *(pArg + 1);
1327 [ # # # # : 0 : if ( c1 && (c1 == 'M' || c1 == 'm') )
# # ]
1328 : : {
1329 : : /* "WMnumber", milliseconds */
1330 : 0 : timeout_value = strtol(pArg + 2, (char**)&q, 10);
1331 [ # # # # : 0 : if ( timeout_value && q > pArg + 2 && *q == '\0' )
# # ]
1332 : : {
1333 [ # # # # ]: 0 : if (errno == ERANGE || timeout_value < 0.0 || timeout_value>LONG_MAX) /* djb-rwth: addressing coverity ID #499550 -- the condition takes into account all possible overflows/errors */
1334 : : {
1335 : 0 : timeout_value = 0;
1336 : 0 : timeout_set_warning = 1;
1337 : : }
1338 : 0 : timeout_set_error = 0;
1339 : : }
1340 : : else
1341 : : {
1342 : 0 : timeout_set_error = 1;
1343 : : }
1344 : : }
1345 : : else
1346 : : {
1347 : : /* expect "Wnumber", seconds */
1348 : 0 : t = strtod(pArg + 1, (char**)&q);
1349 [ # # # # ]: 0 : if ( t && q > pArg + 1 )
1350 : : {
1351 [ # # ]: 0 : if ( *q != '\0' )
1352 : : {
1353 : 0 : timeout_set_warning = 1;
1354 : : }
1355 [ # # # # : 0 : if ( errno == ERANGE || t < 0.0 || t * 1000.0 >(double)LONG_MAX )
# # ]
1356 : : {
1357 : 0 : timeout_value = 0;
1358 : 0 : timeout_set_warning = 1;
1359 : : }
1360 : : else
1361 : : {
1362 : 0 : timeout_value = (long)(t * 1000.0); /* max. time per structure */
1363 : : }
1364 : 0 : timeout_set_error = 0;
1365 : : }
1366 : : else
1367 : : {
1368 : 0 : timeout_set_error = 1;
1369 : : }
1370 : : }
1371 [ # # ]: 0 : if ( timeout_set_error == 0 )
1372 : : {
1373 : 0 : ip->msec_MaxTime = timeout_value;
1374 : : }
1375 : : }
1376 : :
1377 : : /*--- Conversion modes ---*/
1378 : : #if ( READ_INCHI_STRING == 1 )
1379 : :
1380 : : /*#if (BUILD_WITH_ENG_OPTIONS==1)*/
1381 [ + + ]: 2 : else if ( !inchi_stricmp(pArg, "InChI2InChI") )
1382 : : {
1383 : : /* Read InChI Identifiers and output InChI Identifiers */
1384 : 1 : ip->nInputType = INPUT_INCHI;
1385 : 1 : ip->bReadInChIOptions |= READ_INCHI_OUTPUT_INCHI;
1386 : 1 : ip->bReadInChIOptions &= ~READ_INCHI_TO_STRUCTURE;
1387 : : }
1388 : : /*#endif*/
1389 : :
1390 [ + - ]: 1 : else if ( !inchi_stricmp(pArg, "InChI2Struct") )
1391 : : {
1392 : : /* Split InChI Identifiers into components */
1393 : 1 : ip->bReadInChIOptions |= READ_INCHI_TO_STRUCTURE;
1394 : 1 : ip->bReadInChIOptions &= ~READ_INCHI_OUTPUT_INCHI;
1395 : 1 : ip->nInputType = INPUT_INCHI;
1396 : : }
1397 : :
1398 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "KeepBalanceP") && developer_options )
1399 : : {
1400 : : /* When spliting InChI Identifiers into components: */
1401 : : /* If MobileH output then add p to each component; */
1402 : : /* Otherwise add one more component containing balance */
1403 : : /* of protons and exchangeable isotopic H */
1404 : 0 : ip->bReadInChIOptions |= READ_INCHI_KEEP_BALANCE_P;
1405 : 0 : bStdFormat = 0;
1406 : : }
1407 : : #endif
1408 : :
1409 : : /*--- (engineering) Undo bug/draw fixes options ---*/
1410 : :
1411 : : /* (developer_options) Old structure-perception and InChI creation options */
1412 : : #if ( FIX_ADJ_RAD == 1 )
1413 : : else if ( !inchi_stricmp(pArg, "FixRad") && developer_options )
1414 : : {
1415 : : bFixAdjacentRad = 1;
1416 : : bStdFormat = 0;
1417 : : }
1418 : : #endif
1419 : :
1420 : :
1421 : : #if ( RENUMBER_ATOMS_AND_RECALC_V106 == 1 )
1422 : : else if ( !inchi_stricmp(pArg, "TestRenum") && developer_options )
1423 : : {
1424 : : ip->bRenumber = 1;
1425 : : }
1426 : : #endif
1427 : :
1428 : : #if ( UNDERIVATIZE == 1 )
1429 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "DoDRV") && developer_options )
1430 : : {
1431 : 0 : ip->bUnderivatize = 1;
1432 : 0 : bStdFormat = 0;
1433 : : }
1434 : : #if( UNDERIVATIZE_REPORT == 1 )
1435 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "DoDrvReport") )
1436 : : {
1437 : 0 : ip->bUnderivatize = 3;
1438 : 0 : bStdFormat = 0;
1439 : : }
1440 : : #endif
1441 : : #endif
1442 : : #if ( RING2CHAIN == 1 )
1443 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "DoR2C") && developer_options )
1444 : : {
1445 : 0 : ip->bRing2Chain = 1;
1446 : 0 : bStdFormat = 0;
1447 : : }
1448 : : #endif
1449 : : #if ( RING2CHAIN == 1 || UNDERIVATIZE == 1 )
1450 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "DoneOnly") && developer_options )
1451 : : {
1452 : 0 : ip->bIgnoreUnchanged = 1;
1453 : 0 : bStdFormat = 0;
1454 : : }
1455 : : #endif
1456 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "MOVEPOS:", 8) && developer_options )
1457 : : {
1458 : 0 : bMovePositiveCharges = (0 != strtol(pArg + 8, NULL, 10));
1459 : 0 : bStdFormat = 0;
1460 : : }
1461 : :
1462 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "NoADP") && developer_options )
1463 : : {
1464 : 0 : bTgFlagHardAddRenProtons = 0;
1465 : 0 : bStdFormat = 0;
1466 : : }
1467 : : /* Tautomer perception off */
1468 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "EXACT") && developer_options )
1469 : : {
1470 : 0 : bVer1DefaultMode |= REQ_MODE_BASIC;
1471 : 0 : bStdFormat = 0;
1472 : : }
1473 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "ONLYRECSALT") && developer_options )
1474 : : {
1475 : : /* do not disconnect salts */
1476 : 0 : bDisconnectSalts = 0;
1477 : 0 : bStdFormat = 0;
1478 : : }
1479 [ # # # # : 0 : else if ( (!inchi_stricmp(pArg, "ONLYEXACT") || !inchi_stricmp(pArg, "ONLYFIXEDH")) && developer_options )
# # ]
1480 : : {
1481 : 0 : bVer1DefaultMode |= REQ_MODE_BASIC;
1482 : 0 : bVer1DefaultMode &= ~REQ_MODE_TAUT;
1483 : 0 : bStdFormat = 0;
1484 : : }
1485 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "ONLYNONISO") && developer_options )
1486 : : {
1487 : 0 : bVer1DefaultMode |= REQ_MODE_NON_ISO;
1488 : 0 : bVer1DefaultMode &= ~REQ_MODE_ISO;
1489 : 0 : bStdFormat = 0;
1490 : : }
1491 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "TAUT") && developer_options )
1492 : : {
1493 : 0 : bVer1DefaultMode &= ~REQ_MODE_BASIC;
1494 : 0 : bVer1DefaultMode |= REQ_MODE_TAUT;
1495 : : }
1496 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "ONLYRECMET") && developer_options )
1497 : : {
1498 : : /* do not disconnect metals */
1499 : 0 : bDisconnectCoord = 0;
1500 : 0 : bStdFormat = 0;
1501 : : }
1502 : :
1503 : : /*--- (hidden) Old output and other options ---*/
1504 : :
1505 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "SdfSplit") && developer_options )
1506 : : {
1507 : : /* Split single Molfiles into disconnected components */
1508 : 0 : bOutputMolfileSplit = 1;
1509 : : }
1510 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "DCR") && developer_options )
1511 : : {
1512 : 0 : bDisplayCompositeResults = 1;
1513 : : }
1514 [ # # # # : 0 : else if ( (!inchi_stricmp(pArg, "AUXFULL") || !inchi_stricmp(pArg, "AUXMAX")) && developer_options )
# # ]
1515 : : {
1516 : : /* full aux info */
1517 : 0 : bINChIOutputOptions &= ~(INCHI_OUT_NO_AUX_INFO | INCHI_OUT_SHORT_AUX_INFO); /* include short aux info */
1518 : : }
1519 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "AUXMIN") && developer_options )
1520 : : {
1521 : : /* minimal aux info */
1522 : 0 : bINChIOutputOptions &= ~INCHI_OUT_NO_AUX_INFO; /* include short aux info */
1523 : 0 : bINChIOutputOptions |= INCHI_OUT_SHORT_AUX_INFO;
1524 : : }
1525 : :
1526 : : #if ( READ_INCHI_STRING == 1 )
1527 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "DDSRC") && developer_options )
1528 : : {
1529 : 0 : bDisplayIfRestoreWarnings = 1; /* InChI->Structure debugging: Display Debug Structure Restore Components */
1530 : : }
1531 : : #endif
1532 : :
1533 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "NoVarH") && developer_options )
1534 : : {
1535 : 0 : bTgFlagVariableProtons = 0;
1536 : : }
1537 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "FULL") && developer_options )
1538 : : {
1539 : 0 : bVer1DefaultMode = VER103_DEFAULT_MODE;
1540 : 0 : nMode = 0;
1541 : 0 : bReconnectCoord = 1; /* full output */
1542 : 0 : bINChIOutputOptions = ((EMBED_REC_METALS_INCHI == 1) ? INCHI_OUT_EMBED_REC : 0) | INCHI_OUT_SHORT_AUX_INFO;
1543 : 0 : ip->bCtPredecessors = 0;
1544 : 0 : ip->bAbcNumbers = 0;
1545 : 0 : bOutputStyle |= INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS;
1546 : : }
1547 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "MIN") && developer_options )
1548 : : {
1549 : 0 : bVer1DefaultMode = VER103_DEFAULT_MODE;
1550 : 0 : nMode = 0;
1551 : 0 : bReconnectCoord = 1; /* minimal output */
1552 : 0 : bINChIOutputOptions = ((EMBED_REC_METALS_INCHI == 1) ? INCHI_OUT_EMBED_REC : 0) | INCHI_OUT_NO_AUX_INFO; /* minimal compressed output */
1553 : 0 : ip->bCtPredecessors = 1;
1554 : 0 : ip->bAbcNumbers = 1;
1555 : 0 : bOutputStyle |= INCHI_OUT_PLAIN_TEXT | INCHI_OUT_PLAIN_TEXT_COMMENTS;
1556 : : }
1557 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "COMPRESS") && developer_options )
1558 : : {
1559 : 0 : ip->bAbcNumbers = 1;
1560 : 0 : ip->bCtPredecessors = 1; /* compressed output */
1561 : : }
1562 : :
1563 : : #if ( READ_INCHI_STRING == 1 )
1564 [ # # ]: 0 : else if ( !inchi_stricmp(pArg, "InChI2InChI") ) /*&& developer_options)*/
1565 : : {
1566 : : /* Read InChI Identifiers and output InChI Identifiers */
1567 : 0 : ip->nInputType = INPUT_INCHI;
1568 : 0 : ip->bReadInChIOptions |= READ_INCHI_OUTPUT_INCHI;
1569 : 0 : ip->bReadInChIOptions &= ~READ_INCHI_TO_STRUCTURE;
1570 : : }
1571 : :
1572 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "SplitInChI") && developer_options )
1573 : : {
1574 : : /* Split InChI Identifiers into components */
1575 : 0 : ip->bReadInChIOptions |= READ_INCHI_SPLIT_OUTPUT;
1576 : : }
1577 : : #endif
1578 : :
1579 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "MOLFILENUMBER") && developer_options )
1580 : : {
1581 : 0 : ip->bGetMolfileNumber |= 1;
1582 : : }
1583 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "OutputPLAIN") && developer_options )
1584 : : {
1585 : 0 : bOutputStyle |= INCHI_OUT_PLAIN_TEXT;
1586 : : }
1587 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "OutputANNPLAIN") && developer_options )
1588 : : {
1589 : 0 : bOutputStyle |= INCHI_OUT_PLAIN_TEXT_COMMENTS;
1590 : 0 : bOutputStyle |= INCHI_OUT_WINCHI_WINDOW; /* debug */
1591 : : }
1592 [ # # # # : 0 : else if ( (!inchi_stricmp(pArg, "ONLYEXACT") || !inchi_stricmp(pArg, "ONLYFIXEDH")) && developer_options )
# # ]
1593 : : {
1594 : 0 : bVer1DefaultMode |= REQ_MODE_BASIC;
1595 : 0 : bVer1DefaultMode &= ~REQ_MODE_TAUT;
1596 : : }
1597 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "ONLYNONISO") && developer_options )
1598 : : {
1599 : 0 : bVer1DefaultMode |= REQ_MODE_NON_ISO;
1600 : 0 : bVer1DefaultMode &= ~REQ_MODE_ISO;
1601 : : }
1602 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "TAUT") && developer_options )
1603 : : {
1604 : 0 : bVer1DefaultMode &= ~REQ_MODE_BASIC;
1605 : 0 : bVer1DefaultMode |= REQ_MODE_TAUT;
1606 : : }
1607 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "ONLYRECMET") && developer_options )
1608 : : { /* do not disconnect metals */
1609 : 0 : bDisconnectCoord = 0;
1610 : : }
1611 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "ONLYRECSALT") && developer_options )
1612 : : { /* do not disconnect salts */
1613 : 0 : bDisconnectSalts = 0;
1614 : : }
1615 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "MOVEPOS:", 8) && developer_options )
1616 : : { /* added -- 2010-03-01 DT */
1617 : 0 : bMovePositiveCharges = (0 != strtol(pArg + 8, NULL, 10));
1618 : : }
1619 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "RSB:", 4) && developer_options )
1620 : : {
1621 : 0 : mdbr = (int)strtol(pArg + 4, NULL, 10);
1622 : : }
1623 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "EQU") && developer_options )
1624 : : {
1625 : 0 : bCompareComponents = CMP_COMPONENTS;
1626 : : }
1627 [ # # # # ]: 0 : else if ( !inchi_stricmp(pArg, "EQUNONISO") && developer_options )
1628 : : {
1629 : 0 : bCompareComponents = CMP_COMPONENTS | CMP_COMPONENTS_NONISO;
1630 : : }
1631 [ # # # # ]: 0 : else if ( !inchi_memicmp(pArg, "OP:", 3) && developer_options )
1632 : : {
1633 : 0 : bOutputPath = 1;
1634 : 0 : strncpy(szOutputPath, pArg + 3, sizeof(szOutputPath) - 1);
1635 : : }
1636 : : /* eof developer_options */
1637 : :
1638 : : /* Display unrecognized option */
1639 : : else
1640 : : {
1641 : 0 : bRecognizedOption = 0;
1642 : :
1643 : : #ifndef TARGET_LIB_FOR_WINCHI
1644 : 0 : inchi_ios_eprint(log_file, "Unrecognized optionQ3: \"%s\".\n", pArg);
1645 : : #endif
1646 : : }
1647 : 75 : bVer1Options |= bRecognizedOption;
1648 : :
1649 : : } /* eof Parsing stand-alone executable/libinchi options */
1650 : :
1651 [ # # ]: 0 : else if ( ip->num_paths < MAX_NUM_PATHS )
1652 : : {
1653 : : char* sz;
1654 : : #if( ALLOW_EMPTY_PATHS == 1 )
1655 : : if ( argv[i] )
1656 : : #else
1657 [ # # # # ]: 0 : if ( argv[i] && argv[i][0] )
1658 : : #endif
1659 : : {
1660 [ # # ]: 0 : if ( (sz = (char*)inchi_malloc((strlen(argv[i]) + 1) * sizeof(sz[0]))) ) /* djb-rwth: addressing LLVM warning */
1661 : : {
1662 : 0 : strcpy(sz, argv[i]);
1663 : : }
1664 : :
1665 : 0 : ip->path[ip->num_paths++] = sz;
1666 : : }
1667 : : }
1668 : : } /* eof parsing argv loop */
1669 : :
1670 : :
1671 : : /* Print messages and set controil variables according to just parsed options */
1672 : :
1673 : : /* Timeout option(s) */
1674 [ - + ]: 123 : if ( timeout_set_warning )
1675 : : {
1676 : 0 : inchi_ios_eprint(log_file, "Warning: timeout value may have been modified (truncated?) due to number formatting issues;\n");
1677 : : }
1678 [ - + ]: 123 : if ( timeout_set_error )
1679 : : {
1680 : 0 : inchi_ios_eprint(log_file, "Warning: specified timeout value was ignored due to invalid number format, using the default;\n");
1681 : : }
1682 : :
1683 : : /* InChIKey option(s) */
1684 [ - + ]: 123 : if ( bHashKey != 0 )
1685 : : {
1686 : : /* Suppress InChIKey calculation if: */
1687 : : /* compressed output OR Inchi2Struct OR Inchi2Inchi */
1688 [ # # # # ]: 0 : if ( (ip->bAbcNumbers == 1) && (ip->bCtPredecessors == 1) )
1689 : : {
1690 : 0 : bHashKey = 0;
1691 : : #ifndef TARGET_LIB_FOR_WINCHI
1692 : 0 : inchi_ios_eprint(log_file, "Terminating: generation of InChIKey is not available with 'Compress' option\n");
1693 : 0 : return -1;
1694 : : #endif
1695 : : }
1696 [ # # ]: 0 : if ( ip->nInputType == INPUT_INCHI )
1697 : : {
1698 : 0 : bHashKey = 0;
1699 : : #ifndef TARGET_LIB_FOR_WINCHI
1700 : 0 : inchi_ios_eprint(log_file, "Terminating: generation of InChIKey is not available in InChI conversion mode\n");
1701 : 0 : return -1;
1702 : : #endif
1703 : : }
1704 : : else
1705 : : {
1706 [ # # ]: 0 : if ( bOutputMolfileOnly == 1 )
1707 : : {
1708 : 0 : bHashKey = 0;
1709 : : #ifndef TARGET_LIB_FOR_WINCHI
1710 : 0 : inchi_ios_eprint(log_file, "Terminating: generation of InChIKey is not available with 'OutputSDF' option\n");
1711 : 0 : return -1;
1712 : : #endif
1713 : : }
1714 : : }
1715 : : }
1716 : :
1717 [ - + - - ]: 123 : if ( bNameSuffix || bOutputPath )
1718 : : {
1719 : 123 : const char szNUL[] = "NUL";
1720 : : /* fix for AMD processor: use const char[] instead of just "NUL" constant 2008-11-5 DT */
1721 : 123 : const char* p = NULL;
1722 : 123 : char* p_prev = NULL; /* djb-rwth: avoiding use of memory after it is freed */
1723 : 123 : char* r = NULL;
1724 : : char* sz;
1725 : : int len;
1726 : : /* find the 1st path */
1727 [ + + ]: 615 : for ( i = 0; i < MAX_NUM_PATHS; i++ )
1728 : : {
1729 [ + - - + : 492 : if ( !p && ip->path[i] && ip->path[i][0] )
- - ]
1730 : : {
1731 : 0 : p = ip->path[i];
1732 : 0 : break;
1733 : : }
1734 : : }
1735 : : /* fix output path */
1736 [ - + - - : 123 : if ( bOutputPath && szOutputPath[0] && p )
- - ]
1737 : : {
1738 : : /* remove last slash */
1739 : 0 : len = (int)strlen(szOutputPath);
1740 [ # # # # ]: 0 : if ( len > 0 && szOutputPath[len - 1] != INCHI_PATH_DELIM )
1741 : : {
1742 : 0 : szOutputPath[len++] = INCHI_PATH_DELIM;
1743 : 0 : szOutputPath[len] = '\0';
1744 : : }
1745 [ # # # # : 0 : if ( len > 0 && (r = (char*)strrchr(p, INCHI_PATH_DELIM)) && r[1] )
# # ]
1746 : : {
1747 : 0 : strcat(szOutputPath, r + 1);
1748 : 0 : p = szOutputPath;
1749 : : }
1750 : : }
1751 : : /* djb-rwth: copying the value of p */
1752 : : #ifdef _WIN32
1753 : : p_prev = _strdup(p);
1754 : : #else
1755 : 123 : p_prev = inchi__strdup(p);
1756 : : #endif
1757 : : /* add missing paths */
1758 : : /* djb-rwth: this whole block had to be rewritten to avoid use of memory after it is freed */
1759 [ - + - - ]: 123 : for ( i = 0; p_prev && i < MAX_NUM_PATHS; i++ )
1760 : : {
1761 : : /* fix for AMD processor: changed order 2008-11-5 DT */
1762 [ # # # # ]: 0 : if ( !ip->path[i] || !ip->path[i][0] )
1763 : 0 : {
1764 : : #if ( BUILD_WITH_AMI == 1 ) && ( OUTPUT_FILE_EXT == 1 )
1765 : : char* pLastExt = (i && numOutNameExt >= i) ? strrchr((char*)p_prev, '.') : 0;
1766 : : char* pLastSlash = (i && numOutNameExt >= i) ? strrchr((char*)p_prev, INCHI_PATH_DELIM) : 0;
1767 : : if ( pLastExt && pLastSlash && pLastSlash > pLastExt )
1768 : : pLastExt = NULL;
1769 : : #else
1770 : 0 : char* pLastExt = NULL;
1771 : : #endif
1772 : 0 : len = (int)strlen(p_prev) + strlen(szNameSuffix) + strlen(ext[i]);
1773 [ # # ]: 0 : if ((sz = (char*)inchi_malloc(((long long)len + 1) * sizeof(sz[0])))) /* djb-rwth: cast operators added; addressing and ignoring LLVM warnings */
1774 : : {
1775 : 0 : strcpy(sz, p_prev); /* djb-rwth: fix for use of memory after being freed */
1776 : : #if ( BUILD_WITH_AMI == 1 ) && ( OUTPUT_FILE_EXT == 1 )
1777 : : if ( pLastExt )
1778 : : {
1779 : : strcpy(sz + (pLastExt - p), szOutNameExt[i - 1]);
1780 : : }
1781 : : #endif
1782 : 0 : strcat(sz, szNameSuffix);
1783 [ # # ]: 0 : if ( !pLastExt )
1784 : 0 : strcat(sz, ext[i]);
1785 : 0 : ip->num_paths++;
1786 [ # # ]: 0 : if ( ip->path[i] )
1787 : : {
1788 [ # # ]: 0 : inchi_free((char*)ip->path[i]); /* eliminate memory leak 2013-12-18 DCh */
1789 : : }
1790 : 0 : ip->path[i] = sz;
1791 : : }
1792 : : }
1793 [ # # ]: 0 : else if ( !inchi_stricmp(ip->path[i], szNUL) )
1794 : : {
1795 [ # # ]: 0 : inchi_free((char*)ip->path[i]); /* cast deliberately const qualifier */
1796 : 0 : ip->path[i] = NULL;
1797 : : }
1798 : : }
1799 : 123 : free(p_prev); /* djb-rwth: freeing memory reserved for auxiliary variable */
1800 : : }
1801 : :
1802 : : /* inchi2inchi and inchi2struct option(s) */
1803 : : #if ( READ_INCHI_STRING == 1 )
1804 [ + + ]: 123 : if ( INPUT_INCHI == ip->nInputType )
1805 : : {
1806 : 2 : bCompareComponents = 0;
1807 : : /*bDisplayCompositeResults = 0;*/
1808 : : #if ( I2S_MODIFY_OUTPUT == 1 )
1809 : : if ( !(ip->bReadInChIOptions & READ_INCHI_TO_STRUCTURE) )
1810 : : #endif
1811 : : {
1812 : 2 : bOutputMolfileOnly = 0;
1813 : 2 : bINChIOutputOptions |= INCHI_OUT_NO_AUX_INFO;
1814 : 2 : bINChIOutputOptions &= ~INCHI_OUT_SHORT_AUX_INFO;
1815 : 2 : bINChIOutputOptions &= ~INCHI_OUT_ONLY_AUX_INFO;
1816 : : /* bNoStructLabels = 1; */
1817 : : }
1818 : 2 : ip->bDisplayIfRestoreWarnings = bDisplayIfRestoreWarnings;
1819 [ + - ]: 2 : if ( !(bINChIOutputOptions &
1820 : : (INCHI_OUT_SDFILE_ONLY | /* not in bINChIOutputOptions yet */
1821 : : INCHI_OUT_PLAIN_TEXT | /* not in bINChIOutputOptions yet */
1822 : : INCHI_OUT_PLAIN_TEXT_COMMENTS /* not in bINChIOutputOptions yet */
1823 : : )
1824 : : )
1825 : : #if ( I2S_MODIFY_OUTPUT == 1 )
1826 : : && !bOutputMolfileOnly
1827 : : && !(bOutputStyle & (INCHI_OUT_PLAIN_TEXT))
1828 : : #endif
1829 : : )
1830 : : {
1831 : 2 : bINChIOutputOptions |= INCHI_OUT_PLAIN_TEXT;
1832 : : }
1833 : : }
1834 : : #endif
1835 : :
1836 [ + - ]: 123 : if ( bVer1Options )
1837 : : {
1838 : 123 : nMode |= bVer1DefaultMode;
1839 : : }
1840 [ # # ]: 0 : else if ( bReleaseVersion )
1841 : : {
1842 : 0 : nMode |= nReleaseMode;
1843 : : }
1844 : :
1845 : : #if ( defined(COMPILE_ANSI_ONLY) || defined(TARGET_LIB_FOR_WINCHI) )
1846 [ - + - - ]: 123 : if ( bCompareComponents && !(bDisplay & 1) )
1847 : : {
1848 : 0 : bCompareComponents = 0;
1849 : : }
1850 : : #endif
1851 : :
1852 : : /* Save original options */
1853 : : /* nOrigMode = nMode; */
1854 : : #ifndef COMPILE_ANSI_ONLY
1855 : : ip->dp.sdp.nFontSize = nFontSize;
1856 : : ip->dp.sdp.ulDisplTime = *ulDisplTime;
1857 : : ip->bDisplay = bDisplay;
1858 : : #ifdef TARGET_LIB_FOR_WINCHI
1859 : : ip->bDisplayCompositeResults = bDisplay;
1860 : : #else
1861 : : ip->bDisplayCompositeResults = bDisplayCompositeResults;
1862 : : #endif
1863 : : #else
1864 : 123 : ip->bDisplayEachComponentINChI = 0;
1865 : 123 : bCompareComponents = 0;
1866 : : #endif
1867 : :
1868 : 123 : ip->bMergeAllInputStructures = bMergeAllInputStructures;
1869 : 123 : ip->bDoNotAddH = bDoNotAddH;
1870 : :
1871 : : /* Set default options */
1872 [ + - - + ]: 123 : if ( !nMode || nMode == REQ_MODE_STEREO )
1873 : : {
1874 : : /* requested all output */
1875 : 0 : nMode |= (REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_ISO | REQ_MODE_NON_ISO | REQ_MODE_STEREO);
1876 : : }
1877 : : else
1878 : : {
1879 [ - + ]: 123 : if ( !(nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) )
1880 : : {
1881 : 0 : nMode |= (REQ_MODE_BASIC | REQ_MODE_TAUT);
1882 : : }
1883 [ + - - + ]: 123 : if ( (nMode & REQ_MODE_STEREO) && !(nMode & (REQ_MODE_ISO | REQ_MODE_NON_ISO)) )
1884 : : {
1885 : 0 : nMode |= (REQ_MODE_ISO | REQ_MODE_NON_ISO);
1886 : : }
1887 : : }
1888 : : /* if the user requested isotopic then unconditionally add non-isotopic output. */
1889 [ + - ]: 123 : if ( nMode & REQ_MODE_ISO )
1890 : : {
1891 : 123 : nMode |= REQ_MODE_NON_ISO;
1892 : : }
1893 : :
1894 : : #if ( MIN_SB_RING_SIZE > 0 )
1895 [ - + ]: 123 : if ( mdbr )
1896 : : {
1897 : 0 : nMinDbRinSize = mdbr;
1898 : : }
1899 : 123 : nMode |= (nMinDbRinSize << REQ_MODE_MIN_SB_RING_SHFT) & REQ_MODE_MIN_SB_RING_MASK;
1900 : : #endif
1901 : :
1902 : : /* Input file */
1903 [ + + - + ]: 123 : if ( ip->nInputType == INPUT_NONE && ip->num_paths > 0 )
1904 : : {
1905 : 0 : ip->nInputType = INPUT_MOLFILE; /* default */
1906 : : }
1907 : 123 : ip->nMode = nMode;
1908 : : /* Compare components */
1909 [ - + - - ]: 123 : if ( (bCompareComponents & CMP_COMPONENTS) && (nMode & REQ_MODE_BASIC) )
1910 : : {
1911 : 0 : bCompareComponents |= CMP_COMPONENTS_NONTAUT; /* compare non-tautomeric */
1912 : : }
1913 : 123 : ip->bCompareComponents = bCompareComponents;
1914 : : /* Output */
1915 [ - + ]: 123 : ip->bINChIOutputOptions = bINChIOutputOptions | (bOutputMolfileOnly ? INCHI_OUT_SDFILE_ONLY : 0);
1916 [ - + ]: 123 : if ( bOutputMolfileOnly )
1917 : : {
1918 : 0 : bOutputStyle &= ~(INCHI_OUT_PLAIN_TEXT |
1919 : : INCHI_OUT_PLAIN_TEXT_COMMENTS |
1920 : : INCHI_OUT_TABBED_OUTPUT);
1921 : : #if ( SDF_OUTPUT_DT == 1 )
1922 [ # # ]: 0 : ip->bINChIOutputOptions |= bOutputMolfileDT ? INCHI_OUT_SDFILE_ATOMS_DT : 0;
1923 [ # # ]: 0 : ip->bINChIOutputOptions |= bOutputMolfileSplit ? INCHI_OUT_SDFILE_SPLIT : 0;
1924 : : #endif
1925 : : }
1926 : : #ifdef TARGET_LIB_FOR_WINCHI
1927 : : if ( !(bDisplay & 1) )
1928 : : {
1929 : : bOutputStyle &= ~(INCHI_OUT_PLAIN_TEXT_COMMENTS); /* do not ouput comments in wINChI text file results */
1930 : : }
1931 : : else
1932 : : {
1933 : : bOutputStyle |= INCHI_OUT_WINCHI_WINDOW;
1934 : : }
1935 : : #endif
1936 : 123 : ip->bINChIOutputOptions |= bOutputStyle;
1937 : 123 : ip->bNoStructLabels = bNoStructLabels;
1938 : :
1939 : : /* Processing options */
1940 [ - + ]: 123 : if ( bForcedChiralFlag )
1941 : : {
1942 : 0 : ip->bChiralFlag = bForcedChiralFlag;
1943 : : }
1944 : :
1945 : : /* Tautomeric/salts options */
1946 : 123 : ip->bTautFlags = 0;
1947 : 123 : ip->bTautFlagsDone = 0;
1948 : :
1949 : : /* Find regular tautomerism */
1950 : 123 : ip->bTautFlags |= TG_FLAG_TEST_TAUT__ATOMS;
1951 : :
1952 : : /* Disconnect salts */
1953 [ + - ]: 123 : ip->bTautFlags |= bDisconnectSalts ? TG_FLAG_DISCONNECT_SALTS : 0;
1954 : :
1955 : : /* If possible, find long-range H/(-) taut. on =C-OH, >C=O */
1956 [ + - ]: 123 : ip->bTautFlags |= bAcidTautomerism ? TG_FLAG_TEST_TAUT__SALTS : 0;
1957 : :
1958 : : /* Allow long-range movement of N(+), P(+) charges */
1959 [ + - ]: 123 : ip->bTautFlags |= bMovePositiveCharges ? TG_FLAG_MOVE_POS_CHARGES : 0;
1960 : :
1961 : : /* Multi-attachement long-range H/(-) taut. on =C-OH, >C=O */
1962 [ + - ]: 123 : ip->bTautFlags |= (bAcidTautomerism > 1) ? TG_FLAG_TEST_TAUT2_SALTS : 0;
1963 : :
1964 : : /* (Debug) allow to find long-range H-only tautomerism on =C-OH, >C=O */
1965 [ - + ]: 123 : ip->bTautFlags |= (bUnchargedAcidTaut == 1) ? TG_FLAG_ALLOW_NO_NEGTV_O : 0;
1966 : :
1967 : : /* Merge =C-OH and >C=O containing t-groups and other =C-OH groups */
1968 [ + - ]: 123 : ip->bTautFlags |= bMergeSaltTGroups ? TG_FLAG_MERGE_TAUT_SALTS : 0;
1969 [ + - ]: 123 : ip->bTautFlags |= bDisconnectCoord ? TG_FLAG_DISCONNECT_COORD : 0;
1970 [ + - - + ]: 123 : ip->bTautFlags |= (bDisconnectCoord && bReconnectCoord) ? TG_FLAG_RECONNECT_COORD : 0;
1971 [ - + ]: 123 : ip->bTautFlags |= bDisconnectCoordChkVal ? TG_FLAG_CHECK_VALENCE_COORD : 0;
1972 [ + - ]: 123 : ip->bTautFlags |= bTgFlagVariableProtons ? TG_FLAG_VARIABLE_PROTONS : 0;
1973 [ + - ]: 123 : ip->bTautFlags |= bTgFlagHardAddRenProtons ? TG_FLAG_HARD_ADD_REM_PROTONS : 0;
1974 [ - + ]: 123 : ip->bTautFlags |= bKetoEnolTaut ? TG_FLAG_KETO_ENOL_TAUT : 0;
1975 [ - + ]: 123 : ip->bTautFlags |= b15TautNonRing ? TG_FLAG_1_5_TAUT : 0;
1976 : :
1977 : : /*^^^ IPl 2020-04-02 added to forcefully enable new tauto rules (in test_ixa, etc.) */
1978 : : /*^^^ IPl 2020-10-26 removed set to 1
1979 : : bPT_22_00_Taut = 1;
1980 : : bPT_16_00_Taut = 1;
1981 : : bPT_06_00_Taut = 1;
1982 : : bPT_39_00_Taut = 1;
1983 : : */
1984 : :
1985 : : /*^^^ IPl 2020-04-02 */
1986 [ - + ]: 123 : ip->bTautFlags |= bPT_22_00_Taut ? TG_FLAG_PT_22_00 : 0;
1987 [ - + ]: 123 : ip->bTautFlags |= bPT_16_00_Taut ? TG_FLAG_PT_16_00 : 0;
1988 [ - + ]: 123 : ip->bTautFlags |= bPT_06_00_Taut ? TG_FLAG_PT_06_00 : 0;
1989 [ - + ]: 123 : ip->bTautFlags |= bPT_39_00_Taut ? TG_FLAG_PT_39_00 : 0;
1990 [ - + ]: 123 : ip->bTautFlags |= bPT_13_00_Taut ? TG_FLAG_PT_13_00 : 0;
1991 [ - + ]: 123 : ip->bTautFlags |= bPT_18_00_Taut ? TG_FLAG_PT_18_00 : 0;
1992 : :
1993 : : #ifdef STEREO_WEDGE_ONLY
1994 [ + - ]: 123 : ip->bTautFlags |= bPointedEdgeStereo ? TG_FLAG_POINTED_EDGE_STEREO : 0;
1995 : : #endif
1996 : : #if ( FIX_ADJ_RAD == 1 )
1997 : : ip->bTautFlags |= bFixAdjacentRad ? TG_FLAG_FIX_ADJ_RADICALS : 0;
1998 : : #endif
1999 [ + - ]: 123 : ip->bTautFlags |= bAddPhosphineStereo ? TG_FLAG_PHOSPHINE_STEREO : 0;
2000 [ + - ]: 123 : ip->bTautFlags |= bAddArsineStereo ? TG_FLAG_ARSINE_STEREO : 0;
2001 [ + - ]: 123 : ip->bTautFlags |= bFixSp3bug ? TG_FLAG_FIX_SP3_BUG : 0;
2002 : :
2003 : : /* Bug fixes */
2004 [ + - ]: 123 : if ( bFixFB2 )
2005 : : {
2006 : : #if ( FIX_ISO_FIXEDH_BUG == 1 )
2007 : 123 : ip->bTautFlags |= TG_FLAG_FIX_ISO_FIXEDH_BUG; /* accomodate FIX_ISO_FIXEDH_BUG */
2008 : : #endif
2009 : :
2010 : : #if ( FIX_TERM_H_CHRG_BUG == 1 )
2011 : 123 : ip->bTautFlags |= TG_FLAG_FIX_TERM_H_CHRG_BUG; /* accomodate FIX_TERM_H_CHRG_BUG */
2012 : : #endif
2013 : :
2014 : : #if ( FIX_TRANSPOSITION_CHARGE_BUG == 1 )
2015 : 123 : ip->bINChIOutputOptions |= INCHI_OUT_FIX_TRANSPOSITION_CHARGE_BUG;
2016 : : #endif
2017 : : }
2018 : :
2019 [ + + ]: 123 : if ( !ip->nInputType )
2020 : : {
2021 : 121 : ip->nInputType = INPUT_MOLFILE;
2022 : : }
2023 : :
2024 : : /* Check if /SNon requested turn OFF SUU/SLUUD */
2025 [ - + ]: 123 : if ( !(ip->nMode & REQ_MODE_STEREO) )
2026 : : {
2027 : 0 : ip->nMode &= ~REQ_MODE_DIFF_UU_STEREO;
2028 : 0 : ip->nMode &= ~(REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU);
2029 : : }
2030 : :
2031 : : /* Standard InChI ? */
2032 [ + + ]: 123 : if ( bStdFormat )
2033 : : {
2034 : 101 : ip->bINChIOutputOptions |= INCHI_OUT_STDINCHI;
2035 : : }
2036 : :
2037 : : /* InChIKey ? */
2038 [ + - ]: 123 : if ( !bHashKey )
2039 : : {
2040 : 123 : ip->bCalcInChIHash = INCHIHASH_NONE;
2041 : : }
2042 : : else
2043 : : {
2044 : 0 : ip->bCalcInChIHash = INCHIHASH_KEY;
2045 : : }
2046 : : /* Extension(s) to hash (in non-std mode only) ? */
2047 [ + - ]: 123 : if ( !bHashKey )
2048 : : {
2049 [ + - - + ]: 123 : if ( (bHashXtra1 != 0) || (bHashXtra2 != 0) )
2050 : : {
2051 : 0 : inchi_ios_eprint(log_file, "Hash extension(s) not generated: InChIKey not requested");
2052 : : }
2053 : : }
2054 : : else
2055 : : {
2056 [ # # ]: 0 : if ( bHashXtra1 )
2057 : : {
2058 [ # # ]: 0 : if ( bHashXtra2 )
2059 : : {
2060 : 0 : ip->bCalcInChIHash = INCHIHASH_KEY_XTRA1_XTRA2;
2061 : : }
2062 : : else
2063 : : {
2064 : 0 : ip->bCalcInChIHash = INCHIHASH_KEY_XTRA1;
2065 : : }
2066 : : }
2067 [ # # ]: 0 : else if ( bHashXtra2 )
2068 : : {
2069 : 0 : ip->bCalcInChIHash = INCHIHASH_KEY_XTRA2;
2070 : : }
2071 : : }
2072 : :
2073 : 123 : ip->bLargeMolecules = bLargeMolecules;
2074 : 123 : ip->bLooseTSACheck = bLooseTSACheck;
2075 : :
2076 : 123 : ip->bNPZz = bNPZz;
2077 : 123 : ip->bStereoAtZz = bStereoAtZz; /*STEREO_AT_ZZ;*/
2078 : 123 : ip->bMolecularInorganics = bMolecularInorganics; /* @nnuk */
2079 : 123 : ip->bNoWarnings = bNoWarnings;
2080 : 123 : ip->bMergeHash = bMergeHash;
2081 : 123 : ip->bHideInChI = bHideInChI;
2082 : :
2083 : 123 : ip->bPolymers = bPolymers;
2084 : 123 : ip->bFoldPolymerSRU = bFoldPolymerSRU;
2085 : 123 : ip->bFrameShiftScheme = bFrameShiftScheme;
2086 : :
2087 : : #ifdef TARGET_LIB_FOR_WINCHI
2088 : : ip->bLargeMolecules = 1;
2089 : : /*ip->bPolymers = POLYMERS_MODERN; */
2090 : : /*ip->bNPZz = 1;*/
2091 : : /*ip->bFrameShiftScheme = FSS_NONE;*/
2092 : : /*ip->bFoldPolymerSRU = 1;*/
2093 : :
2094 : : #if ( UNDERIVATIZE == 1 )
2095 : : ip->bUnderivatize = 1;
2096 : : if ( ip->bUnderivatize )
2097 : : {
2098 : : ip->bINChIOutputOptions &= ~INCHI_OUT_STDINCHI;
2099 : : }
2100 : : #endif
2101 : : ip->bNoWarnings = 0;
2102 : : ip->bMergeHash = 0;
2103 : : ip->bHideInChI = 0;
2104 : :
2105 : : #endif
2106 : :
2107 : 123 : ip->bINChIOutputOptions2 = bINChIOutputOptions2;
2108 : :
2109 : 123 : ip->bEnhancedStereo = bEnhancedStereochemistry;
2110 : :
2111 : 123 : return 0;
2112 : : }
2113 : :
2114 : :
2115 : : /****************************************************************************
2116 : : Print input parameters
2117 : : ****************************************************************************/
2118 : 2 : int PrintInputParms(INCHI_IOSTREAM* log_file,
2119 : : INPUT_PARMS* ip)
2120 : : {
2121 : :
2122 : : #if (BUILD_WITH_ENG_OPTIONS==1)
2123 : : const int developer_options = 1;
2124 : : #else
2125 : 2 : const int developer_options = 0;
2126 : : #endif
2127 : : #ifdef TARGET_LIB_FOR_WINCHI
2128 : : int bInChI2Struct = 0; /* winchi-1 can not convert InChI to structure */
2129 : : #else
2130 [ + + + - ]: 2 : int bInChI2Struct = (ip->bReadInChIOptions & READ_INCHI_TO_STRUCTURE) && ip->nInputType == INPUT_INCHI;
2131 : : #endif
2132 : :
2133 : 2 : INCHI_MODE nMode = ip->nMode;
2134 : : int k;
2135 : 2 : int bStdFormat = 1;
2136 : 2 : int first = 1;
2137 : :
2138 : :
2139 [ - + ]: 2 : if ( !(ip->bINChIOutputOptions & INCHI_OUT_STDINCHI) )
2140 : : {
2141 : 0 : bStdFormat = 0;
2142 : : }
2143 : : /* Some stereo */
2144 [ - + ]: 2 : if ( !(nMode & REQ_MODE_STEREO) )
2145 : : {
2146 : 0 : inchi_ios_eprint(log_file, "Using specific structure perception features:\n");
2147 : 0 : first = 0;
2148 : 0 : inchi_ios_eprint(log_file, " Stereo OFF\n");
2149 : : }
2150 : : else
2151 : : {
2152 [ - + ]: 2 : if ( !(TG_FLAG_POINTED_EDGE_STEREO & ip->bTautFlags) )
2153 : : {
2154 [ # # ]: 0 : if ( first )
2155 : : {
2156 : 0 : inchi_ios_eprint(log_file, "Using specific structure perception features:\n");
2157 : 0 : first = 0;
2158 : : }
2159 : 0 : inchi_ios_eprint(log_file, " Both ends of wedge point to stereocenters\n");
2160 : : }
2161 : : }
2162 [ - + ]: 2 : if ( ip->bDoNotAddH )
2163 : : {
2164 [ # # ]: 0 : if ( first )
2165 : : {
2166 : 0 : inchi_ios_eprint(log_file, "Using specific structure perception features:\n");
2167 : : }
2168 : 0 : inchi_ios_eprint(log_file, " Do not add H\n");
2169 : : }
2170 : :
2171 : :
2172 : : #if ( RENUMBER_ATOMS_AND_RECALC_V106 == 1 )
2173 : : if ( ip->bRenumber == 1 )
2174 : : {
2175 : : inchi_ios_eprint(log_file, "\nGenerate InChI upon random atom renumbering\n\n");
2176 : : }
2177 : : #endif
2178 : :
2179 : : #if ( UNDERIVATIZE == 1 )
2180 [ - + ]: 2 : if ( ip->bUnderivatize == 1 )
2181 : : {
2182 : 0 : inchi_ios_eprint(log_file, "\nConvert input structure to derivative precursor before InChI calculation\n\n");
2183 : : }
2184 [ - + ]: 2 : else if ( ip->bUnderivatize == 3 )
2185 : : {
2186 : 0 : inchi_ios_eprint(log_file, "\nOutputs derivative information for the input structure\n\n");
2187 : : }
2188 : : #endif
2189 : :
2190 : :
2191 : :
2192 : : /* Generation/conversion indicator */
2193 [ + - ]: 2 : if ( bStdFormat )
2194 : : {
2195 [ + - + + ]: 2 : if ( !(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) && !bInChI2Struct )
2196 : : {
2197 : 1 : inchi_ios_eprint(log_file, "Generating standard InChI\n");
2198 : : }
2199 : :
2200 : : #if ( !defined(TARGET_API_LIB) && !defined(TARGET_LIB_FOR_WINCHI) && !defined(TARGET_EXE_USING_API) )
2201 : : /* effective only in command line program InChI or stdInChI */
2202 : : else if ( bInChI2Struct )
2203 : : {
2204 : : inchi_ios_eprint(log_file, "Converting InChI(s) to structure(s) in %s\n",
2205 : : (ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) ?
2206 : : "MOL format" : "aux. info format");
2207 : : }
2208 : : #endif
2209 : : }
2210 : : else
2211 : : {
2212 : 0 : inchi_ios_eprint(log_file, "Generating non-standard InChI with the options: \n");
2213 : : }
2214 : :
2215 : : /* SDfile output */
2216 [ - + ]: 2 : if ( ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY )
2217 : : {
2218 : 0 : inchi_ios_eprint(log_file,
2219 : : "Output SDfile only without stereochemical information and atom coordinates%s\n",
2220 [ # # ]: 0 : (ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ATOMS_DT) ?
2221 : : "\n(write H isotopes as D, T)" : "");
2222 : : }
2223 : :
2224 : : /* Fixed/Mobile H */
2225 [ - + ]: 2 : if ( !bStdFormat )
2226 : : {
2227 [ # # ]: 0 : if ( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) == (REQ_MODE_BASIC | REQ_MODE_TAUT) )
2228 : : {
2229 : 0 : inchi_ios_eprint(log_file, " Mobile H Perception OFF (include FixedH layer)\n");
2230 : : }
2231 [ # # ]: 0 : else if ( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) == (REQ_MODE_TAUT) )
2232 : : {
2233 : 0 : inchi_ios_eprint(log_file, " Mobile H Perception ON (omit FixedH layer)\n");
2234 : : }
2235 [ # # ]: 0 : else if ( (nMode & (REQ_MODE_BASIC | REQ_MODE_TAUT)) == (REQ_MODE_BASIC) )
2236 : : {
2237 : 0 : inchi_ios_eprint(log_file, " Mobile H ignored\n");
2238 : : }
2239 : : else
2240 : : {
2241 : 0 : inchi_ios_eprint(log_file, " Undefined Mobile H mode\n");
2242 : : }
2243 : :
2244 [ # # ]: 0 : if ( (ip->bTautFlags & TG_FLAG_VARIABLE_PROTONS) )
2245 : : {
2246 [ # # ]: 0 : if ( !(ip->bTautFlags & TG_FLAG_HARD_ADD_REM_PROTONS) )
2247 : : {
2248 : 0 : inchi_ios_eprint(log_file, " Disabled Aggressive (De)protonation\n");
2249 : : }
2250 : : }
2251 : :
2252 : : #if ( FIND_RING_SYSTEMS != 1 )
2253 : : inchi_ios_eprint(log_file, " %s5-, 6-, 7-memb. ring taut. ignored\n", i ? "; " : "");
2254 : : #endif
2255 : :
2256 : : /* RecMet */
2257 [ # # ]: 0 : if ( ip->bTautFlags & TG_FLAG_DISCONNECT_COORD )
2258 : : {
2259 [ # # ]: 0 : if ( ip->bTautFlags & TG_FLAG_RECONNECT_COORD )
2260 : : {
2261 : 0 : inchi_ios_eprint(log_file, " Include bonds to metals\n");
2262 : : }
2263 : : else
2264 : : {
2265 : 0 : inchi_ios_eprint(log_file, " Do not reconnect metals (omit RecMet layer)\n");
2266 : : }
2267 : : }
2268 : : else
2269 : : {
2270 : 0 : inchi_ios_eprint(log_file, " Do not disconnect metals\n");
2271 : : }
2272 : :
2273 : : /* Isotopic - always ON, output disabled. 09-17-2009*/
2274 : : /*
2275 : : if ( nMode & REQ_MODE_ISO )
2276 : : inchi_ios_eprint( log_file, " Isotopic ON\n");
2277 : : else if ( nMode & REQ_MODE_NON_ISO )
2278 : : inchi_ios_eprint( log_file, " Isotopic OFF\n");
2279 : : */
2280 : :
2281 : : #if ( FIX_ADJ_RAD == 1 )
2282 : : if ( ip->bTautFlags & TG_FLAG_FIX_ADJ_RADICALS )
2283 : : {
2284 : : inchi_ios_eprint(log_file, "Fix Adjacent Radicals\n");
2285 : : }
2286 : : #endif
2287 : :
2288 : : /* Stereo */
2289 [ # # ]: 0 : if ( nMode & REQ_MODE_STEREO )
2290 : : {
2291 : 0 : inchi_ios_eprint(log_file, " %s%s%s%sStereo ON\n",
2292 [ # # ]: 0 : (nMode & REQ_MODE_NOEQ_STEREO) ? "Slow " : "",
2293 [ # # ]: 0 : (nMode & REQ_MODE_REDNDNT_STEREO) ? "Redund. " : "",
2294 [ # # ]: 0 : (nMode & REQ_MODE_NO_ALT_SBONDS) ? "No AltBond " : "",
2295 : :
2296 [ # # ]: 0 : (nMode & REQ_MODE_RACEMIC_STEREO) ? "Racemic " :
2297 [ # # ]: 0 : (nMode & REQ_MODE_RELATIVE_STEREO) ? "Relative " :
2298 [ # # ]: 0 : (nMode & REQ_MODE_CHIR_FLG_STEREO) ? "Chiral Flag " : "Absolute ");
2299 : :
2300 [ # # ]: 0 : if ( 0 == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) )
2301 : : {
2302 : 0 : inchi_ios_eprint(log_file, " Include undefined/unknown stereogenic centers and bonds\n");
2303 : : }
2304 [ # # ]: 0 : else if ( REQ_MODE_SC_IGN_ALL_UU == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) )
2305 : : {
2306 : 0 : inchi_ios_eprint(log_file, " Omit undefined/unknown stereogenic centers\n");
2307 : : }
2308 [ # # ]: 0 : else if ( REQ_MODE_SB_IGN_ALL_UU == (nMode & (REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU)) )
2309 : : {
2310 : 0 : inchi_ios_eprint(log_file, " Omit undefined/unknown stereogenic bonds\n");
2311 : : }
2312 : : else
2313 : : {
2314 : : /*case REQ_MODE_SB_IGN_ALL_UU | REQ_MODE_SC_IGN_ALL_UU*/
2315 : 0 : inchi_ios_eprint(log_file, " Omit undefined/unknown stereogenic centers and bonds\n");
2316 : : }
2317 [ # # ]: 0 : if ( 0 != (nMode & REQ_MODE_DIFF_UU_STEREO) )
2318 : : {
2319 : 0 : inchi_ios_eprint(log_file, " Make labels for unknown and undefined stereo different\n");
2320 : : }
2321 : :
2322 : : #if ( defined(MIN_SB_RING_SIZE) && MIN_SB_RING_SIZE > 0 )
2323 : 0 : k = (ip->nMode & REQ_MODE_MIN_SB_RING_MASK) >> REQ_MODE_MIN_SB_RING_SHFT;
2324 [ # # ]: 0 : if ( bRELEASE_VERSION != 1 || k != MIN_SB_RING_SIZE )
2325 : : {
2326 [ # # ]: 0 : if ( k >= 3 )
2327 : : {
2328 : 0 : inchi_ios_eprint(log_file, " Min. stereobond ring size: %d\n", k);
2329 : : }
2330 : : else
2331 : : {
2332 : 0 : inchi_ios_eprint(log_file, " Min. stereobond ring size: NONE\n");
2333 : : }
2334 : : }
2335 : : #endif
2336 : : } /* Stereo */
2337 : : } /* !bStdFormat */
2338 : :
2339 [ - + ]: 2 : if ( !bStdFormat )
2340 : : {
2341 [ # # ]: 0 : if ( TG_FLAG_KETO_ENOL_TAUT & ip->bTautFlags )
2342 : : {
2343 : 0 : inchi_ios_eprint(log_file, " Account for keto-enol tautomerism\n");
2344 : : }
2345 : : else
2346 : : {
2347 : 0 : inchi_ios_eprint(log_file, " Do not account for keto-enol tautomerism\n");
2348 : : }
2349 [ # # ]: 0 : if ( TG_FLAG_1_5_TAUT & ip->bTautFlags )
2350 : : {
2351 : 0 : inchi_ios_eprint(log_file, " Account for 1,5-tautomerism\n");
2352 : : }
2353 : : else
2354 : : {
2355 : 0 : inchi_ios_eprint(log_file, " Do not account for 1,5-tautomerism\n");
2356 : : }
2357 : :
2358 [ # # ]: 0 : if ( TG_FLAG_PT_22_00 & ip->bTautFlags )
2359 : 0 : inchi_ios_eprint(log_file, " Account for PT_22_00 tautomerism\n");
2360 : : else
2361 : 0 : inchi_ios_eprint(log_file, " Do not account for PT_22_00 tautomerism\n");
2362 [ # # ]: 0 : if ( TG_FLAG_PT_16_00 & ip->bTautFlags )
2363 : 0 : inchi_ios_eprint(log_file, " Account for PT_16_00 tautomerism\n");
2364 : : else
2365 : 0 : inchi_ios_eprint(log_file, " Do not account for PT_16_00 tautomerism\n");
2366 [ # # ]: 0 : if ( TG_FLAG_PT_06_00 & ip->bTautFlags )
2367 : 0 : inchi_ios_eprint(log_file, " Account for PT_06_00 tautomerism\n");
2368 : : else
2369 : 0 : inchi_ios_eprint(log_file, " Do not account for PT_06_00 tautomerism\n");
2370 [ # # ]: 0 : if ( TG_FLAG_PT_39_00 & ip->bTautFlags )
2371 : 0 : inchi_ios_eprint(log_file, " Account for PT_39_00 tautomerism\n");
2372 : : else
2373 : 0 : inchi_ios_eprint(log_file, " Do not account for PT_39_00 tautomerism\n");
2374 [ # # ]: 0 : if ( TG_FLAG_PT_13_00 & ip->bTautFlags )
2375 : 0 : inchi_ios_eprint(log_file, " Account for PT_13_00 tautomerism\n");
2376 : : else
2377 : 0 : inchi_ios_eprint(log_file, " Do not account for PT_13_00 tautomerism\n");
2378 [ # # ]: 0 : if ( TG_FLAG_PT_18_00 & ip->bTautFlags )
2379 : 0 : inchi_ios_eprint(log_file, " Account for PT_18_00 tautomerism\n");
2380 : : else
2381 : 0 : inchi_ios_eprint(log_file, " Do not account for PT_18_00 tautomerism\n");
2382 : :
2383 [ # # ]: 0 : if ( developer_options )
2384 : : {
2385 [ # # ]: 0 : if ( TG_FLAG_PHOSPHINE_STEREO & ip->bTautFlags )
2386 : : {
2387 : 0 : inchi_ios_eprint(log_file, " Include phosphine stereochemistry\n");
2388 : : }
2389 : : else
2390 : : {
2391 : 0 : inchi_ios_eprint(log_file, " Do not include phosphine stereochemistry\n");
2392 : : }
2393 [ # # ]: 0 : if ( TG_FLAG_ARSINE_STEREO & ip->bTautFlags )
2394 : : {
2395 : 0 : inchi_ios_eprint(log_file, " Include arsine stereochemistry\n");
2396 : : }
2397 : : else
2398 : : {
2399 : 0 : inchi_ios_eprint(log_file, " Do not include arsine stereochemistry\n");
2400 : : }
2401 [ # # ]: 0 : if ( !(TG_FLAG_FIX_SP3_BUG & ip->bTautFlags) )
2402 : : {
2403 : 0 : inchi_ios_eprint(log_file, " Turned OFF fix of bug leading to missing or undefined sp3 parity\n");
2404 : : }
2405 [ # # ]: 0 : if ( !(TG_FLAG_FIX_ISO_FIXEDH_BUG & ip->bTautFlags) )
2406 : : {
2407 : 0 : inchi_ios_eprint(log_file, " Turned OFF bug-fixes found after v.1.02b release\n");
2408 : : }
2409 [ # # ]: 0 : if ( !(ip->bFixNonUniformDraw) )
2410 : : {
2411 : 0 : inchi_ios_eprint(log_file, " Turned OFF fixes of non-uniform drawing issues\n");
2412 : : }
2413 [ # # ]: 0 : if ( !(TG_FLAG_MOVE_POS_CHARGES & ip->bTautFlags) )
2414 : : {
2415 : 0 : inchi_ios_eprint(log_file, " MovePos turned OFF\n");
2416 : : }
2417 : : }
2418 : :
2419 : : } /* !bStdFormat */
2420 : :
2421 [ - + ]: 2 : if ( ip->bCalcInChIHash != INCHIHASH_NONE )
2422 : : {
2423 [ # # ]: 0 : if ( bStdFormat )
2424 : : {
2425 : 0 : inchi_ios_eprint(log_file, "Generating standard InChIKey\n");
2426 : : }
2427 : : else
2428 : : {
2429 : 0 : inchi_ios_eprint(log_file, "Generating InChIKey\n");
2430 : : }
2431 [ # # ]: 0 : if ( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1 )
2432 : : {
2433 : 0 : inchi_ios_eprint(log_file, "Generating hash extension (1st block)\n");
2434 : : }
2435 [ # # ]: 0 : else if ( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA2 )
2436 : : {
2437 : 0 : inchi_ios_eprint(log_file, "Generating hash extension (2nd block)\n");
2438 : : }
2439 [ # # ]: 0 : else if ( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1_XTRA2 )
2440 : : {
2441 : 0 : inchi_ios_eprint(log_file, "Generating hash extension (two blocks)\n");
2442 : : }
2443 : : }
2444 : :
2445 [ - + ]: 2 : if ( ip->bINChIOutputOptions & INCHI_OUT_SAVEOPT )
2446 : : {
2447 : 0 : inchi_ios_eprint(log_file, "Saving InChI creation options");
2448 [ # # ]: 0 : if ( bStdFormat )
2449 : : {
2450 : 0 : inchi_ios_eprint(log_file, " suppressed for standard InChI");
2451 : : /* NB: actual suppression takes place on InChI serialization */
2452 : : /* (as on e.g. Inchi2Inchi conversion it may appear that we create non-std */
2453 : : /* InChI instead of standard one) */
2454 : : }
2455 : 0 : inchi_ios_eprint(log_file, "\n");
2456 : : }
2457 : :
2458 [ - + ]: 2 : if ( ip->bAllowEmptyStructure )
2459 : : {
2460 : 0 : inchi_ios_eprint(log_file, "Issue warning on empty structure\n");
2461 : : }
2462 : :
2463 : : /* Input */
2464 [ + - ]: 2 : if ( ip->nInputType )
2465 : : {
2466 : 2 : inchi_ios_eprint(log_file, "Input format: %s",
2467 [ + - ]: 2 : ip->nInputType == INPUT_MOLFILE ? "MOLfile" :
2468 [ + - ]: 4 : ip->nInputType == INPUT_SDFILE ? "SDfile" :
2469 : : #if ( READ_INCHI_STRING == 1 )
2470 [ - + ]: 2 : ip->nInputType == INPUT_INCHI ? "InChI (plain identifier)" :
2471 : : #endif
2472 [ # # ]: 0 : ip->nInputType == INPUT_INCHI_PLAIN ? "InChI AuxInfo (plain)" : "Unknown");
2473 [ + - - + ]: 2 : if ( (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE) &&
2474 [ # # ]: 0 : ip->bGetMolfileNumber )
2475 : : {
2476 : 0 : inchi_ios_eprint(log_file, " (attempting to read Molfile number)");
2477 : : }
2478 : 2 : inchi_ios_eprint(log_file, "\n");
2479 : : }
2480 : :
2481 [ - + - - ]: 2 : if ( ip->szSdfDataHeader[0] && ip->nInputType != INPUT_SDFILE )
2482 : : {
2483 : 0 : inchi_ios_eprint(log_file, " SDfile data header: \"%s\"\n", ip->szSdfDataHeader);
2484 : : }
2485 : :
2486 : : /* Output */
2487 : 4 : inchi_ios_eprint(log_file, "Output format: %s%s\n",
2488 [ - + ]: 2 : (ip->bINChIOutputOptions & INCHI_OUT_PLAIN_TEXT) ? "Plain text" :
2489 : :
2490 [ # # # # ]: 0 : ((ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) && bInChI2Struct) ? "SDfile only (without stereochemical info and atom coordinates)" :
2491 [ # # # # ]: 0 : ((ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) && !bInChI2Struct) ? "SDfile only" : "Unknown",
2492 : :
2493 [ + - ]: 2 : ((ip->bINChIOutputOptions & INCHI_OUT_PLAIN_TEXT) &&
2494 [ - + ]: 2 : (ip->bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT)) ? ", tabbed" : "");
2495 : :
2496 : : #if ( bRELEASE_VERSION == 1 )
2497 [ + - - + ]: 2 : if ( ip->bCtPredecessors || ip->bAbcNumbers )
2498 : : {
2499 [ # # # # ]: 0 : if ( ip->bCtPredecessors && ip->bAbcNumbers )
2500 : : {
2501 : 0 : inchi_ios_eprint(log_file, "Representation: Compressed\n");
2502 : : }
2503 : : else
2504 : : {
2505 : 0 : inchi_ios_eprint(log_file, "Connection table: %s, %s\n",
2506 [ # # ]: 0 : ip->bCtPredecessors ? "Predecessor_numbers(closures)" : "Canon_numbers(branching, ring closures)",
2507 [ # # ]: 0 : ip->bAbcNumbers ? "Shorter alternative" : "Numerical");
2508 : : }
2509 : : }
2510 : : #else
2511 : : if ( (bRELEASE_VERSION != 1) || ip->bCtPredecessors || ip->bAbcNumbers )
2512 : : {
2513 : : inchi_ios_eprint(log_file, "Connection table: %s, %s\n",
2514 : : ip->bCtPredecessors ? "Predecessor_numbers(closures)" : "Canon_numbers(branching, ring closures)",
2515 : : ip->bAbcNumbers ? "Shorter alternative" : "Numerical");
2516 : : }
2517 : : else
2518 : : {
2519 : : inchi_ios_eprint(log_file, "Representation: Numerical");
2520 : : }
2521 : : #endif
2522 : :
2523 [ - + ]: 2 : if ( ip->bNoWarnings )
2524 : : {
2525 : 0 : inchi_ios_eprint(log_file, "Warnings suppressed\n");
2526 : : }
2527 : :
2528 [ - + ]: 2 : if ( ip->bHideInChI )
2529 : : {
2530 : 0 : inchi_ios_eprint(log_file, "Printing InChI string itself suppressed\n");
2531 : : }
2532 [ - + ]: 2 : if ( ip->bMergeHash )
2533 : : {
2534 : 0 : inchi_ios_eprint(log_file, "InChIKey combined with extra hash(es)\n");
2535 : : }
2536 : :
2537 : :
2538 : :
2539 [ + - ]: 2 : if ( !(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) )
2540 : : {
2541 [ + - ]: 2 : if ( ip->bINChIOutputOptions & INCHI_OUT_NO_AUX_INFO )
2542 : : {
2543 : 2 : inchi_ios_eprint(log_file, "Aux. info suppressed\n");
2544 : : }
2545 [ # # ]: 0 : else if ( ip->bINChIOutputOptions & INCHI_OUT_SHORT_AUX_INFO )
2546 : : {
2547 : 0 : inchi_ios_eprint(log_file, "Minimal Aux. info\n");
2548 : : }
2549 : : else
2550 : : {
2551 : 0 : inchi_ios_eprint(log_file, "Full Aux. info\n");
2552 : : }
2553 : : }
2554 [ - + ]: 2 : if ( ip->first_struct_number > 1 )
2555 : : {
2556 [ # # ]: 0 : inchi_ios_eprint(log_file, "Skipping %ld structure%s\n", ip->first_struct_number - 1, ip->first_struct_number == 2 ? "" : "s");
2557 : : }
2558 [ - + ]: 2 : if ( ip->last_struct_number > 0 )
2559 : : {
2560 : 0 : inchi_ios_eprint(log_file, "Terminate after structure #%ld\n", ip->last_struct_number);
2561 : : }
2562 [ - + - - : 2 : if ( ip->bSaveWarningStructsAsProblem && ip->path[3] && ip->path[3][0] )
- - ]
2563 : : {
2564 : 0 : inchi_ios_eprint(log_file, "Saving warning structures into the problem file\n");
2565 : : }
2566 [ - + - - : 2 : if ( ip->bSaveAllGoodStructsAsProblem && ip->path[3] && ip->path[3][0] )
- - ]
2567 : : {
2568 : 0 : inchi_ios_eprint(log_file, "Saving only all good structures into the problem file\n");
2569 : : }
2570 : :
2571 [ - + ]: 2 : if ( ip->bINChIOutputOptions2 & INCHI_OUT_INCHI_GEN_ERROR )
2572 : : {
2573 : 0 : inchi_ios_eprint(log_file, "Print empty InChI if generation fails\n");
2574 : : }
2575 [ - + ]: 2 : if ( ip->bINChIOutputOptions2 & INCHI_OUT_MISMATCH_AS_ERROR )
2576 : : {
2577 : 0 : inchi_ios_eprint(log_file, "Consider problem/mismatch on InChI conversion as error\n");
2578 : : }
2579 [ - + ]: 2 : if ( ip->msec_MaxTime )
2580 : : {
2581 : 0 : inchi_ios_eprint(log_file, "Timeout per structure: %ld msec\n", ip->msec_MaxTime);
2582 : : /*
2583 : : unsigned long seconds = ip->msec_MaxTime / 1000;
2584 : : unsigned long milliseconds = (ip->msec_MaxTime%1000);
2585 : : inchi_ios_eprint( log_file, "Timeout per structure: %lu/*.%03lu sec\n", seconds, milliseconds); -- djb-rwth: ignoring LLVM warning
2586 : : inchi_ios_eprint( log_file, "Timeout per structure: %lu sec\n", seconds );
2587 : : */
2588 : : }
2589 : : else
2590 : : {
2591 : 2 : inchi_ios_eprint(log_file, "No timeout\n");
2592 : : }
2593 : :
2594 [ - + ]: 2 : if ( ip->bLooseTSACheck )
2595 : : {
2596 : 0 : inchi_ios_eprint(log_file, "Relax criteria of ambiguous drawing for in-ring stereo centers\n");
2597 : : }
2598 : :
2599 : : {
2600 : 2 : int maxna = NORMALLY_ALLOWED_INP_MAX_ATOMS;
2601 [ - + ]: 2 : if ( ip->bLargeMolecules )
2602 : : {
2603 : 0 : inchi_ios_eprint(log_file, "Experimental mode: ");
2604 : 0 : maxna = MAX_ATOMS;
2605 : : }
2606 : 2 : inchi_ios_eprint(log_file, "Up to %d atoms per structure\n", maxna);
2607 : : }
2608 : :
2609 [ - + ]: 2 : if ( ip->bPolymers != POLYMERS_NO )
2610 : : {
2611 : 0 : inchi_ios_eprint(log_file, "Experimental mode: Treating polymers");
2612 : :
2613 [ # # ]: 0 : if ( ip->bPolymers == POLYMERS_MODERN )
2614 : : {
2615 : : ;
2616 : : }
2617 [ # # ]: 0 : else if ( ip->bPolymers == POLYMERS_LEGACY )
2618 : : {
2619 : 0 : inchi_ios_eprint(log_file, " (v. 1.05 legacy mode)");
2620 : : }
2621 [ # # ]: 0 : else if ( ip->bPolymers == POLYMERS_LEGACY_PLUS )
2622 : : {
2623 : 0 : inchi_ios_eprint(log_file, " (v. 1.05 legacy mode with senior link placed at start)");
2624 : : }
2625 [ # # ]: 0 : if ( ip->bFoldPolymerSRU )
2626 : : {
2627 : 0 : inchi_ios_eprint(log_file, "; CRU folding enabled");
2628 : : }
2629 : : }
2630 : 2 : inchi_ios_eprint(log_file, "\n");
2631 : :
2632 [ - + ]: 2 : if ( ip->bNPZz == 1 )
2633 : : {
2634 : 0 : inchi_ios_eprint(log_file, "Allowing non-polymer Zz pseudo atoms\n");
2635 : : }
2636 [ - + ]: 2 : if ( ip->bStereoAtZz == 1 )
2637 : : {
2638 : 0 : inchi_ios_eprint(log_file, "Allowing stereo at atoms connected to Zz\n");
2639 : : }
2640 : : /* @nnuk */
2641 [ - + ]: 2 : if (ip->bMolecularInorganics == 1)
2642 : : {
2643 : 0 : inchi_ios_eprint(log_file, "Molecular Inorganics mode enabled\n");
2644 : : }
2645 : :
2646 : : /* Report debug modes */
2647 : : #if ( bRELEASE_VERSION != 1 )
2648 : : inchi_ios_eprint(log_file, "Release version = NO\n");
2649 : : #endif
2650 : : #if ( TRACE_MEMORY_LEAKS == 1 && defined(_DEBUG) )
2651 : : inchi_ios_eprint(log_file, "Tracing memory leaks (SLOW)\n");
2652 : : #endif
2653 : :
2654 : : #if (BUILD_WITH_ENG_OPTIONS==1)
2655 : : inchi_ios_eprint(log_file, "! Working in engineering mode\n");
2656 : : #endif
2657 : 2 : inchi_ios_eprint(log_file, "\n");
2658 : :
2659 : : #if ( bRELEASE_VERSION != 1 )
2660 : : #if ( FIND_RING_SYSTEMS == 1 )
2661 : : inchi_ios_eprint(log_file, "Find ring systems=Y\nTautomers:\n");
2662 : : inchi_ios_eprint(log_file, " 4-pyridinol=%s\n", TAUT_4PYRIDINOL_RINGS == 1 ? "Y" : "N");
2663 : : inchi_ios_eprint(log_file, " pyrazole=%s\n", TAUT_PYRAZOLE_RINGS == 1 ? "Y" : "N");
2664 : : inchi_ios_eprint(log_file, " tropolone=%s\n", TAUT_TROPOLONE_7 == 1 ? "Y" : "N");
2665 : : inchi_ios_eprint(log_file, " tropolone-5=%s\n", TAUT_TROPOLONE_5 == 1 ? "Y" : "N");
2666 : : inchi_ios_eprint(log_file, "Only chain attachments to tautomeric rings=%s\n", TAUT_RINGS_ATTACH_CHAIN == 1 ? "Y" : "N");
2667 : : #endif
2668 : :
2669 : : if ( ip->bGetSdfileId )
2670 : : {
2671 : : inchi_ios_eprint(log_file, "Extracting SDfile IDs\n");
2672 : : }
2673 : : inchi_ios_eprint(log_file, "\nDbg: MOVE_CHARGES=%d\n",
2674 : : 0 != (ip->bTautFlags & TG_FLAG_MOVE_POS_CHARGES));
2675 : : inchi_ios_eprint(log_file, " REPLACE_ALT_WITH_TAUT=%d; NEUTRALIZE_ENDPOINTS=%d; BNS_PROTECT_FROM_TAUT=%d\n",
2676 : : REPLACE_ALT_WITH_TAUT, NEUTRALIZE_ENDPOINTS, BNS_PROTECT_FROM_TAUT);
2677 : : inchi_ios_eprint(log_file, " DISCONNECT_SALTS=%d; TEST_TAUT_SALTS=%d; TEST_TAUT2_SALTS=%d\n",
2678 : : 0 != (ip->bTautFlags & TG_FLAG_DISCONNECT_SALTS),
2679 : : 0 != (ip->bTautFlags & TG_FLAG_TEST_TAUT__SALTS),
2680 : : 0 != (ip->bTautFlags & TG_FLAG_TEST_TAUT2_SALTS));
2681 : : inchi_ios_eprint(log_file, " CHARGED_ACID_TAUT_ONLY=%d MERGE_TAUT_SALTS=%d\n",
2682 : : 0 == (ip->bTautFlags & TG_FLAG_ALLOW_NO_NEGTV_O),
2683 : : 0 != (ip->bTautFlags & TG_FLAG_MERGE_TAUT_SALTS));
2684 : : inchi_ios_eprint(log_file, " DISCONNECT_COORD=%d\n",
2685 : : 0 != (ip->bTautFlags & TG_FLAG_DISCONNECT_COORD));
2686 : : #endif /* ( bRELEASE_VERSION != 1 ) */
2687 : :
2688 : 2 : return 0;
2689 : : }
2690 : :
2691 : :
2692 : : /****************************************************************************/
2693 : 0 : void HelpCommandLineParms(INCHI_IOSTREAM* f)
2694 : : {
2695 [ # # ]: 0 : if ( !f )
2696 : : {
2697 : 0 : return;
2698 : : }
2699 : :
2700 : : #if ( bRELEASE_VERSION == 1 )
2701 : 0 : inchi_ios_print_nodisplay(f,
2702 : : #ifdef TARGET_EXE_USING_API
2703 : : "%s %-s\n%-s Build (%-s%-s) of %s %-s %-s\n\nUsage:\ninchi_main inputFile [outputFile [logFile [problemFile]]] [%coption[ %coption...]]\n",
2704 : : APP_DESCRIPTION, INCHI_SRC_REV,
2705 : : INCHI_BUILD_PLATFORM, INCHI_BUILD_COMPILER, INCHI_BUILD_DEBUG, __DATE__, __TIME__,
2706 : : RELEASE_IS_FINAL ? "" : " *** pre-release, for evaluation only ***",
2707 : : INCHI_OPTION_PREFX, INCHI_OPTION_PREFX);
2708 : : #else
2709 : : "%s %-s\n%-s Build (%-s%-s) of %s %-s %-s\n\nUsage:\ninchi-1 inputFile [outputFile [logFile [problemFile]]] [%coption[ %coption...]]\n",
2710 : : APP_DESCRIPTION, INCHI_SRC_REV,
2711 : : INCHI_BUILD_PLATFORM, INCHI_BUILD_COMPILER, INCHI_BUILD_DEBUG, __DATE__, __TIME__,
2712 : : RELEASE_IS_FINAL ? "" : " *** pre-release, for evaluation only ***",
2713 : : INCHI_OPTION_PREFX, INCHI_OPTION_PREFX);
2714 : :
2715 : : #if ( BUILD_WITH_AMI == 1 )
2716 : : inchi_ios_print_nodisplay(f,
2717 : : "inchi-1 inputFiles... %cAMI [%coption[ %coption...]]\n",
2718 : : INCHI_OPTION_PREFX, INCHI_OPTION_PREFX, INCHI_OPTION_PREFX);
2719 : : #endif
2720 : : #endif
2721 : :
2722 : 0 : inchi_ios_print_nodisplay(f, "\nOptions:\n");
2723 : :
2724 : 0 : inchi_ios_print_nodisplay(f, "\nInput\n");
2725 : 0 : inchi_ios_print_nodisplay(f, " STDIO Use standard input/output streams\n");
2726 : 0 : inchi_ios_print_nodisplay(f, " InpAux Input structures in %s default aux. info format\n (for use with STDIO)\n", INCHI_NAME);
2727 : 0 : inchi_ios_print_nodisplay(f, " SDF:DataHeader Read from the input SDfile the ID under this DataHeader\n");
2728 : :
2729 : 0 : inchi_ios_print_nodisplay(f, " START:n Start at n-th input structure\n");
2730 : 0 : inchi_ios_print_nodisplay(f, " END:n Stop after n-th input structure\n");
2731 : 0 : inchi_ios_print_nodisplay(f, " RECORD:n Treat only n-th input structure\n");
2732 : :
2733 : : #if ( BUILD_WITH_AMI == 1 )
2734 : : inchi_ios_print_nodisplay(f, " AMI Allow multiple input files (wildcards supported)\n");
2735 : : inchi_ios_print_nodisplay(f, " AMIOutStd Write output to stdout (in AMI mode)\n");
2736 : : inchi_ios_print_nodisplay(f, " AMILogStd Write log to stderr (in AMI mode)\n");
2737 : : inchi_ios_print_nodisplay(f, " AMIPrbNone Suppress creation of problem files (in AMI mode)\n");
2738 : : #endif
2739 : :
2740 : :
2741 : 0 : inchi_ios_print_nodisplay(f, "Output\n");
2742 : 0 : inchi_ios_print_nodisplay(f, " NoLabels Omit structure number, DataHeader and ID from %s output\n", INCHI_NAME);
2743 : 0 : inchi_ios_print_nodisplay(f, " NoWarnings Suppress all warning messages\n");
2744 : 0 : inchi_ios_print_nodisplay(f, " AuxNone Omit auxiliary information\n");
2745 : 0 : inchi_ios_print_nodisplay(f, " SaveOpt Save custom InChI creation options (non-standard InChI)\n");
2746 : 0 : inchi_ios_print_nodisplay(f, " Tabbed Separate structure number, %s, and AuxInfo with tabs\n", INCHI_NAME);
2747 : 0 : inchi_ios_print_nodisplay(f, " MergeHash Combine InChIKey with extra hash(es) if present\n");
2748 : 0 : inchi_ios_print_nodisplay(f, " NoInChI Do not print InChI string itself\n");
2749 : : #ifndef TARGET_EXE_USING_API
2750 : 0 : inchi_ios_print_nodisplay(f, " OutErrInChI On fail, print empty InChI (default: nothing)\n");
2751 : : #endif
2752 : : #if ( defined(_WIN32) && !defined(COMPILE_ANSI_ONLY) && !defined(TARGET_API_LIB) ) /* djb-rwth: check if this is working on GCC for Windows */
2753 : : inchi_ios_print_nodisplay(f, " D Display the structures\n");
2754 : : inchi_ios_print_nodisplay(f, " EQU Display sets of identical components\n");
2755 : : inchi_ios_print_nodisplay(f, " Fnumber Set display Font size in number of points\n");
2756 : : #endif
2757 : 0 : inchi_ios_print_nodisplay(f, " OutputSDF Convert %s created with default aux. info to SDfile\n", INCHI_NAME);
2758 : : #if ( SDF_OUTPUT_DT == 1 )
2759 : 0 : inchi_ios_print_nodisplay(f, " SdfAtomsDT Output Hydrogen Isotopes to SDfile as Atoms D and T\n");
2760 : : #endif
2761 : :
2762 : 0 : inchi_ios_print_nodisplay(f, "Structure perception\n");
2763 : 0 : inchi_ios_print_nodisplay(f, " MolecularInorganics Parameter deals with Molecular Inorganics (initial testing phase)\n"); /*(@nnuk : Nauman Ullah Khan) :: Parameter for Molecular Inorganics added*/
2764 : 0 : inchi_ios_print_nodisplay(f, " SNon Exclude stereo (default: include absolute stereo)\n");
2765 : 0 : inchi_ios_print_nodisplay(f, " NEWPSOFF Both ends of wedge point to stereocenters (default: a narrow end)\n");
2766 : 0 : inchi_ios_print_nodisplay(f, " LooseTSACheck Relax criteria of ambiguous drawing for in-ring tetrahedral stereo\n");
2767 : 0 : inchi_ios_print_nodisplay(f, " DoNotAddH All H are explicit (default: add H according to usual valences)\n");
2768 : : #ifndef USE_STDINCHI_API
2769 : 0 : inchi_ios_print_nodisplay(f, "Stereo perception modifiers (non-standard InChI)\n");
2770 : 0 : inchi_ios_print_nodisplay(f, " SRel Relative stereo\n");
2771 : 0 : inchi_ios_print_nodisplay(f, " SRac Racemic stereo\n");
2772 : 0 : inchi_ios_print_nodisplay(f, " SUCF Use Chiral Flag: On means Absolute stereo, Off - Relative\n");
2773 : :
2774 : 0 : inchi_ios_print_nodisplay(f, "Customizing InChI creation (non-standard InChI)\n");
2775 : 0 : inchi_ios_print_nodisplay(f, " SUU Always include omitted unknown/undefined stereo\n");
2776 : 0 : inchi_ios_print_nodisplay(f, " SLUUD Make labels for unknown and undefined stereo different\n");
2777 : 0 : inchi_ios_print_nodisplay(f, " RecMet Include reconnected metals results\n");
2778 : 0 : inchi_ios_print_nodisplay(f, " FixedH Include Fixed H layer\n");
2779 : :
2780 : 0 : inchi_ios_print_nodisplay(f, " KET Consider keto-enol tautomerism (experimental)\n");
2781 : 0 : inchi_ios_print_nodisplay(f, " 15T Consider 1,5-tautomerism (experimental)\n");
2782 : 0 : inchi_ios_print_nodisplay(f, " PT_06_00 Consider 1,3 heteroatom shift (experimental)\n");
2783 : 0 : inchi_ios_print_nodisplay(f, " PT_13_00 Consider keten-ynol exchange (experimental)\n");
2784 : 0 : inchi_ios_print_nodisplay(f, " PT_16_00 Consider nitroso-oxime tautomerism (experimental)\n");
2785 : 0 : inchi_ios_print_nodisplay(f, " PT_18_00 Consider cyanic/iso-cyanic acids (experimental)\n");
2786 : 0 : inchi_ios_print_nodisplay(f, " PT_22_00 Consider imine/imine tautomerism (experimental)\n");
2787 : 0 : inchi_ios_print_nodisplay(f, " PT_39_00 Consider nitrone/azoxy or Behrend rearrangement (experimental)\n");
2788 : :
2789 : :
2790 : 0 : inchi_ios_print_nodisplay(f, "Generation\n");
2791 : 0 : inchi_ios_print_nodisplay(f, " Wnumber Set time-out per structure in seconds; W0 means unlimited\n");
2792 : 0 : inchi_ios_print_nodisplay(f, " WMnumber Set time-out per structure in milliseconds (int); WM0 means unlimited\n");
2793 : 0 : inchi_ios_print_nodisplay(f, " LargeMolecules Treat molecules up to 32766 atoms (experimental)\n");
2794 : 0 : inchi_ios_print_nodisplay(f, " WarnOnEmptyStructure Warn and produce empty %s for empty structure\n", INCHI_NAME);
2795 : : /*inchi_ios_print_nodisplay( f, " MismatchIsError Treat problem/mismatch on inchi2struct conversion as error\n");*/
2796 : :
2797 : 0 : inchi_ios_print_nodisplay(f, " Polymers Allow processing of polymers (experimental)\n");
2798 : 0 : inchi_ios_print_nodisplay(f, " Polymers105 Allow processing of polymers (experimental, legacy mode of v. 1.05)\n");
2799 : 0 : inchi_ios_print_nodisplay(f, " FoldCRU Fold polymer CRU if inner repeats occur\n");
2800 : 0 : inchi_ios_print_nodisplay(f, " NoFrameShift Disable polymer CRU frame shift\n");
2801 : 0 : inchi_ios_print_nodisplay(f, " NoEdits Disable polymer CRU frame shift and folding\n");
2802 : 0 : inchi_ios_print_nodisplay(f, " NPZz Allow non-polymer-related Zz atoms (pseudo element placeholders)\n");
2803 : 0 : inchi_ios_print_nodisplay(f, " SAtZz Allow stereo at atoms connected to Zz(default: disabled)\n");
2804 : : #endif
2805 : :
2806 : :
2807 : 0 : inchi_ios_print_nodisplay(f, " Key Generate InChIKey\n");
2808 : 0 : inchi_ios_print_nodisplay(f, " XHash1 Generate hash extension (to 256 bits) for 1st block of InChIKey\n");
2809 : 0 : inchi_ios_print_nodisplay(f, " XHash2 Generate hash extension (to 256 bits) for 2nd block of InChIKey\n");
2810 : :
2811 : 0 : inchi_ios_print_nodisplay(f, "Conversion\n");
2812 : : #ifdef TARGET_EXE_USING_API
2813 : : inchi_ios_print_nodisplay(f, " InChI2Struct Test mode: Mol/SDfile -> %s -> Structure -> (%s+AuxInfo)\n", INCHI_NAME, INCHI_NAME);
2814 : : #else
2815 : 0 : inchi_ios_print_nodisplay(f, " InChI2Struct Convert InChI string(s) to structure(s) in InChI aux.info format\n");
2816 : 0 : inchi_ios_print_nodisplay(f, " InChI2InChI Convert Convert %s string(s) into %s string(s)\n", INCHI_NAME, INCHI_NAME);
2817 : : #endif
2818 : :
2819 : : #if (BUILD_WITH_ENG_OPTIONS==1)
2820 : : inchi_ios_print_nodisplay(f, "Engineering/hidden\n");
2821 : : #ifdef TARGET_EXE_USING_API
2822 : : inchi_ios_print_nodisplay(f, " InChI2InChI Test mode: Mol/SDfile -> %s -> %s\n", INCHI_NAME, INCHI_NAME);
2823 : : #endif
2824 : :
2825 : : /*inchi_ios_print_nodisplay( f, " Compress Compressed output\n"); */
2826 : : /*inchi_ios_print_nodisplay( f, " FULL Standard set of options for Full Verbose Output\n");*/
2827 : : /*inchi_ios_print_nodisplay( f, " MIN Standard set of options for Minimal Concise Output\n");*/
2828 : :
2829 : : #if ALLOW_SUBSTRUCTURE_FILTERING==1
2830 : : inchi_ios_print_nodisplay(f, " FilterSS Select input SDF records using (hard-coded) substructure filter\n");
2831 : : inchi_ios_print_nodisplay(f, " InvFilterSS Invert match for (hard-coded) substructure filter\n");
2832 : : #endif
2833 : :
2834 : : inchi_ios_print_nodisplay(f, " Compress Compressed output\n");
2835 : : inchi_ios_print_nodisplay(f, " MERGE Use bMergeAllInputStructures\n");
2836 : : inchi_ios_print_nodisplay(f, " PGO Use bSaveAllGoodStructsAsProblem\n");
2837 : : inchi_ios_print_nodisplay(f, " DCR Use bDisplayCompositeResults\n");
2838 : : inchi_ios_print_nodisplay(f, " DSB Use REQ_MODE_NO_ALT_SBONDS \n");
2839 : : inchi_ios_print_nodisplay(f, " NOHDR Use bNoStructLabels\n");
2840 : : inchi_ios_print_nodisplay(f, " NoVarH Set bTgFlagVariableProtons=0\n");
2841 : : inchi_ios_print_nodisplay(f, " NOUUSB Use REQ_MODE_SB_IGN_ALL_UU\n");
2842 : : inchi_ios_print_nodisplay(f, " NOUUSC Use REQ_MODE_SC_IGN_ALL_UU\n");
2843 : : inchi_ios_print_nodisplay(f, " FixRad Set bFixAdjacentRad\n");
2844 : : inchi_ios_print_nodisplay(f, " TestRenum Generate InChI upon random atom renumbering\n");
2845 : : inchi_ios_print_nodisplay(f, " DoDRV Set bUnderivatize=1\n");
2846 : : inchi_ios_print_nodisplay(f, " DoDrvReport Set bUnderivatize=3\n");
2847 : : inchi_ios_print_nodisplay(f, " DoR2C Set bRing2Chain\n");
2848 : : inchi_ios_print_nodisplay(f, " DoneOnly Set bIgnoreUnchanged\n");
2849 : : inchi_ios_print_nodisplay(f, " NoADP Set bTgFlagHardAddRenProtons=0\n");
2850 : : inchi_ios_print_nodisplay(f, " MOVEPOS:0|1 Set bMovePositiveCharges\n");
2851 : : inchi_ios_print_nodisplay(f, " RSB:n Set nMinDbRinSize\n");
2852 : : inchi_ios_print_nodisplay(f, " DISCONSALT:0|1 Set bDisconnectSalts\n");
2853 : : inchi_ios_print_nodisplay(f, " DISCONMETAL:0|1 Set bDisconnectCoord\n");
2854 : : inchi_ios_print_nodisplay(f, " DISCONMETALCHKVAL:0|1 Set bDisconnectCoordChkVal \n");
2855 : : inchi_ios_print_nodisplay(f, " RECONMETAL:0|1 Set bReconnectCoord\n");
2856 : : inchi_ios_print_nodisplay(f, " MERGESALTTG:0|1 Set bMergeSaltTGroups\n");
2857 : : inchi_ios_print_nodisplay(f, " UNCHARGEDACIDS:0|1 Set bUnchargedAcidTaut \n");
2858 : : inchi_ios_print_nodisplay(f, " ACIDTAUT:0|1|2 Set bAcidTautomerism\n");
2859 : : inchi_ios_print_nodisplay(f, " AUXINFO:0|1|2 Set AuxInfo print options\n");
2860 : : inchi_ios_print_nodisplay(f, " KeepBalanceP... \n");
2861 : : inchi_ios_print_nodisplay(f, " SDFID ...\n");
2862 : : inchi_ios_print_nodisplay(f, " PLAINP ....\n");
2863 : : inchi_ios_print_nodisplay(f, " ANNPLAIN ....\n");
2864 : :
2865 : : #endif
2866 : :
2867 : : #endif
2868 : : }
2869 : :
2870 : : #define fprintf2 inchi_fprintf
2871 : :
2872 : : #ifndef TARGET_API_LIB
2873 : : /****************************************************************************/
2874 : : int OpenFiles(FILE** inp_file,
2875 : : FILE** out_file,
2876 : : FILE** log_file,
2877 : : FILE** prb_file,
2878 : : INPUT_PARMS* ip)
2879 : : {
2880 : : /*
2881 : : -- Files --
2882 : : ip->path[0] => Input
2883 : : ip->path[1] => Output (INChI)
2884 : : ip->path[2] => Log
2885 : : ip->path[3] => Problem structures
2886 : : ip->path[4] => Errors file (ACD Labs)
2887 : :
2888 : : */
2889 : :
2890 : : /* Logfile (open as early as possible) */
2891 : : if ( !ip->path[2] || !ip->path[2][0] )
2892 : : {
2893 : : fprintf2(stderr, "%s %-s\n%-s Build (%-s%-s) of %s %s %-s\n\n",
2894 : : APP_DESCRIPTION, INCHI_SRC_REV,
2895 : : INCHI_BUILD_PLATFORM, INCHI_BUILD_COMPILER, INCHI_BUILD_DEBUG, __DATE__, __TIME__,
2896 : : RELEASE_IS_FINAL ? "" : " *** pre-release, for evaluation only ***");
2897 : : fprintf2(stderr, "Log file not specified. Using standard error output.\n");
2898 : : *log_file = stderr;
2899 : : }
2900 : : else if ( !(*log_file = fopen(ip->path[2], "w")) )
2901 : : {
2902 : : fprintf2(stderr, "%s %-s\n%-s Build (%-s%-s) of %s %s%-s\n\n",
2903 : : APP_DESCRIPTION, INCHI_SRC_REV,
2904 : : INCHI_BUILD_PLATFORM, INCHI_BUILD_COMPILER, INCHI_BUILD_DEBUG, __DATE__, __TIME__,
2905 : : RELEASE_IS_FINAL ? "" : " *** pre-release, for evaluation only ***");
2906 : : fprintf2(stderr, "Cannot open log file '%s'. Using standard error output.\n", ip->path[2]);
2907 : : *log_file = stderr;
2908 : : }
2909 : : else
2910 : : {
2911 : : fprintf2(*log_file, "%s %-s\n%-s Build (%-s%-s) of %s %s%-s\n\n",
2912 : : APP_DESCRIPTION, INCHI_SRC_REV,
2913 : : INCHI_BUILD_PLATFORM, INCHI_BUILD_COMPILER, INCHI_BUILD_DEBUG, __DATE__, __TIME__,
2914 : : RELEASE_IS_FINAL ? "" : " *** pre-release, for evaluation only ***");
2915 : : fprintf2(*log_file, "Opened log file '%s'\n", ip->path[2]);
2916 : : }
2917 : :
2918 : : /* Input file */
2919 : : if ( (ip->nInputType == INPUT_MOLFILE || ip->nInputType == INPUT_SDFILE ||
2920 : : ip->nInputType == INPUT_INCHI || ip->nInputType == INPUT_INCHI_PLAIN)
2921 : : &&
2922 : : ip->num_paths > 0 )
2923 : : {
2924 : : const char* fmode = NULL;
2925 : :
2926 : : #if ( defined(_MSC_VER)&&defined(_WIN32) || defined(__BORLANDC__)&&defined(__WIN32__) || defined(__GNUC__)&&defined(__MINGW32__)&&defined(_WIN32) )
2927 : : /* compilers that definitely allow fopen "rb" (binary read) mode */
2928 : : fmode = "rb";
2929 : : if ( !ip->path[0] || !ip->path[0][0] || !(*inp_file = fopen(ip->path[0], "rb")) )
2930 : : {
2931 : : fprintf2(*log_file, "Cannot open input file '%s'. Terminating.\n", ip->path[0] ? ip->path[0] : "<No name>");
2932 : : goto exit_function;
2933 : : }
2934 : : else
2935 : : {
2936 : : fprintf2(*log_file, "Opened input file '%s'\n", ip->path[0]);
2937 : : }
2938 : :
2939 : : #else
2940 : :
2941 : : if ( !ip->path[0] || !ip->path[0][0] || !(*inp_file = fopen(ip->path[0], "r")) )
2942 : : {
2943 : : fprintf2(*log_file, "Cannot open input file '%s'. Terminating.\n", ip->path[0] ? ip->path[0] : "<No Name>");
2944 : : goto exit_function;
2945 : : }
2946 : : else
2947 : : {
2948 : : fprintf2(*log_file, "Opened input file '%s'\n", ip->path[0]);
2949 : : }
2950 : : fmode = "r";
2951 : : #endif /* ( defined(_MSC_VER)&&defined(_WIN32) || defined(__BORLANDC__)&&defined(__WIN32__) || defined(__GNUC__)&&defined(__MINGW32__)&&defined(_WIN32) ) */
2952 : :
2953 : : DetectInputINChIFileType(inp_file, ip, fmode);
2954 : : }
2955 : :
2956 : : else if ( (ip->nInputType != INPUT_MOLFILE &&
2957 : : ip->nInputType != INPUT_SDFILE &&
2958 : : ip->nInputType != INPUT_INCHI &&
2959 : : /* post-1.02b */
2960 : : ip->nInputType != INPUT_INCHI_PLAIN) )
2961 : : {
2962 : : fprintf2(*log_file, "Input file type not specified. Terminating.\n");
2963 : : goto exit_function;
2964 : : }
2965 : : else
2966 : : {
2967 : : fprintf2(*log_file, "Input file not specified. Using standard input.\n");
2968 : : *inp_file = stdin;
2969 : : }
2970 : :
2971 : : /* Output file */
2972 : : if ( !ip->path[1] || !ip->path[1][0] )
2973 : : {
2974 : : fprintf2(*log_file, "Output file not specified. Using standard output.\n");
2975 : : *out_file = stdout;
2976 : : }
2977 : : else
2978 : : {
2979 : : if ( !(*out_file = fopen(ip->path[1], "w")) )
2980 : : {
2981 : : fprintf2(*log_file, "Cannot open output file '%s'. Terminating.\n", ip->path[1]);
2982 : : goto exit_function;
2983 : : }
2984 : : else
2985 : : {
2986 : : fprintf2(*log_file, "Opened output file '%s'\n", ip->path[1]);
2987 : : if ( (ip->bINChIOutputOptions & (INCHI_OUT_PLAIN_TEXT)) &&
2988 : : *inp_file != stdin &&
2989 : : !(ip->bINChIOutputOptions & INCHI_OUT_SDFILE_ONLY) &&
2990 : : !ip->bNoStructLabels &&
2991 : : !(ip->bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT) )
2992 : : {
2993 : : PrintFileName("* Input_File: \"%s\"\n", *out_file, ip->path[0]);
2994 : : }
2995 : : }
2996 : : }
2997 : :
2998 : : /* Problem file */
2999 : : if ( ip->path[3] && ip->path[3][0] )
3000 : : {
3001 : : const char* fmode = "w";
3002 : :
3003 : : #if ( defined(_MSC_VER)&&defined(_WIN32) || defined(__BORLANDC__)&&defined(__WIN32__) || defined(__GNUC__)&&defined(__MINGW32__)&&defined(_WIN32) )
3004 : : fmode = "wb";
3005 : : #endif
3006 : :
3007 : : if ( !(*prb_file = fopen(ip->path[3], fmode)) )
3008 : : {
3009 : : fprintf2(*log_file, "Cannot open problem file '%s'. Terminating.\n", ip->path[3]);
3010 : : goto exit_function;
3011 : : }
3012 : : else
3013 : : {
3014 : : fprintf2(*log_file, "Opened problem file '%s'\n", ip->path[3]);
3015 : : }
3016 : : }
3017 : :
3018 : : /* Success */
3019 : : return 1;
3020 : :
3021 : : exit_function:
3022 : :
3023 : : /* Failed */
3024 : : return 0;
3025 : : }
3026 : :
3027 : :
3028 : : #define NUM_VERSIONS 7
3029 : : #define LEN_VERSIONS 64
3030 : :
3031 : :
3032 : : static int bMatchOnePrefix(int len, char* str, int lenPrefix[],
3033 : : char strPrefix[][LEN_VERSIONS], int numPrefix);
3034 : :
3035 : :
3036 : : /****************************************************************************/
3037 : : static int bMatchOnePrefix(int len, char* str,
3038 : : int lenPrefix[],
3039 : : char strPrefix[][LEN_VERSIONS],
3040 : : int numPrefix)
3041 : : {
3042 : : int i;
3043 : : for ( i = 0; i < numPrefix; i++ )
3044 : : {
3045 : : if ( len >= lenPrefix[i] &&
3046 : : !memcmp(str, strPrefix[i], lenPrefix[i]) )
3047 : : {
3048 : : return 1;
3049 : : }
3050 : : }
3051 : :
3052 : : return 0;
3053 : : }
3054 : :
3055 : : /****************************************************************************/
3056 : : /**
3057 : : * @brief Auto-detect whether a named input file holds plain InChI/AuxInfo text.
3058 : : *
3059 : : * Peeks the first few lines of the input and, if at least two of them start
3060 : : * with a recognised @c InChI=/@c AuxInfo= version prefix, switches
3061 : : * @p ip->nInputType to ::INPUT_INCHI_PLAIN. Otherwise the declared input type
3062 : : * (typically a MOLfile/SDfile) is left unchanged.
3063 : : *
3064 : : * Peeking consumes those lines, so the stream must be rewound afterwards. That
3065 : : * is only possible for a seekable stream: for a non-seekable input (pipe, FIFO,
3066 : : * @c /dev/stdin, process substitution) the consumed header cannot be restored,
3067 : : * which would make the subsequent parser start mid-record. Such inputs are
3068 : : * therefore left untouched and their declared type is kept; pass an explicit
3069 : : * input-type option (e.g. @c InpAux) to read plain InChI from a pipe.
3070 : : *
3071 : : * @param[in,out] inp_file Address of the open input stream; rewound to the
3072 : : * start on return for seekable streams.
3073 : : * @param[in,out] ip Parsed input parameters; @c nInputType may be
3074 : : * promoted to ::INPUT_INCHI_PLAIN.
3075 : : * @param[in] fmode Retained for the declared signature; no longer used
3076 : : * now that rewinding is done with @c fseek().
3077 : : * @return 1 if the input was recognised as (or already declared to be) plain
3078 : : * InChI/AuxInfo, 0 otherwise.
3079 : : */
3080 : : int DetectInputINChIFileType(FILE** inp_file,
3081 : : INPUT_PARMS* ip,
3082 : : const char* fmode)
3083 : : {
3084 : : char szLine[256], ret = 0;
3085 : : static char szPlnVersion[NUM_VERSIONS][LEN_VERSIONS]; /* = "INChI:1.1Beta/";*/
3086 : : static int lenPlnVersion[NUM_VERSIONS];
3087 : : static char szPlnAuxVer[NUM_VERSIONS][LEN_VERSIONS]; /* = "AuxInfo:1.1Beta/";*/
3088 : : static int lenPlnAuxVer[NUM_VERSIONS];
3089 : : static int bInitialized = 0;
3090 : : int bINChI_plain = 0, len, i;
3091 : :
3092 : :
3093 : : if ( ip->nInputType == INPUT_INCHI_PLAIN || ip->nInputType == INPUT_INCHI )
3094 : : {
3095 : : return 1;
3096 : : }
3097 : :
3098 : : if ( !bInitialized )
3099 : : {
3100 : : lenPlnVersion[0] = sprintf(szPlnVersion[0], "%s=%s/", INCHI_NAME, INCHI_VERSION);
3101 : : lenPlnVersion[1] = sprintf(szPlnVersion[1], "INChI=1.12Beta/");
3102 : : lenPlnVersion[2] = sprintf(szPlnVersion[2], "INChI=1.0RC/");
3103 : : lenPlnVersion[3] = sprintf(szPlnVersion[3], "InChI=1.0RC/");
3104 : : lenPlnVersion[4] = sprintf(szPlnVersion[4], "InChI=1/");
3105 : : lenPlnVersion[5] = sprintf(szPlnVersion[5], "MoChI=1a/");
3106 : : lenPlnVersion[6] = sprintf(szPlnVersion[6], "InChI=1S/");
3107 : : lenPlnAuxVer[0] = sprintf(szPlnAuxVer[0], "AuxInfo=%s/", INCHI_VERSION);
3108 : : lenPlnAuxVer[1] = sprintf(szPlnAuxVer[1], "AuxInfo=1.12Beta/");
3109 : : lenPlnAuxVer[2] = sprintf(szPlnAuxVer[2], "AuxInfo=1.0RC/");
3110 : : lenPlnAuxVer[3] = sprintf(szPlnAuxVer[3], "AuxInfo=1.0RC/");
3111 : : lenPlnAuxVer[4] = sprintf(szPlnAuxVer[4], "AuxInfo=1/");
3112 : : lenPlnAuxVer[5] = sprintf(szPlnAuxVer[5], "AuxInfo=1a/");
3113 : : lenPlnAuxVer[6] = sprintf(szPlnAuxVer[6], "AuxInfo=1/");
3114 : : #if ( FIX_DALKE_BUGS == 1 )
3115 : : bInitialized = 1;
3116 : : #endif
3117 : : }
3118 : :
3119 : : /* Auto-detection peeks the first lines of the input, which consumes them
3120 : : from the stream. That is only recoverable if the stream is seekable:
3121 : : for a non-seekable input (pipe, FIFO, /dev/stdin, process substitution)
3122 : : the consumed Molfile header cannot be restored and the subsequent parser
3123 : : would start mid-record. Skip detection for such inputs and keep the
3124 : : declared (MOLFILE/SDFILE) input type. */
3125 : : (void) fmode; /* no longer reopened by path; kept for the declared signature */
3126 : : if ( fseek(*inp_file, 0L, SEEK_SET) )
3127 : : {
3128 : : return 0;
3129 : : }
3130 : :
3131 : : for ( i = 0; i < 4; i++ )
3132 : : {
3133 : : len = inchi_fgetsLfTab(szLine, sizeof(szLine) - 1, *inp_file);
3134 : : if ( len < 0 )
3135 : : {
3136 : : break;
3137 : : }
3138 : : if ( bMatchOnePrefix(len, szLine, lenPlnVersion, szPlnVersion, NUM_VERSIONS) ||
3139 : : bMatchOnePrefix(len, szLine, lenPlnAuxVer, szPlnAuxVer, NUM_VERSIONS) )
3140 : : {
3141 : : bINChI_plain++;
3142 : : }
3143 : : }
3144 : :
3145 : : if ( bINChI_plain >= 2 )
3146 : : {
3147 : : ip->nInputType = INPUT_INCHI_PLAIN;
3148 : : ret = 1;
3149 : : }
3150 : :
3151 : : /* Rewind for the actual reader. Use fseek() rather than fclose()+fopen():
3152 : : reopening by path fails for special files and only happens to work for
3153 : : regular files. */
3154 : : fseek(*inp_file, 0L, SEEK_SET);
3155 : :
3156 : : return ret;
3157 : : }
3158 : : #undef NUM_VERSIONS
3159 : : #undef LEN_VERSIONS
3160 : :
3161 : : #endif /* TARGET_API_LIB */
|