LCOV - code coverage report
Current view: top level - src - ichiparm.c (source / functions) Coverage Total Hit
Test: InChI Unit Test Coverage Lines: 35.9 % 1144 411
Test Date: 2026-12-03 11:58:49 Functions: 75.0 % 4 3
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25.2 % 972 245

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

Generated by: LCOV version 2.0-1