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