third_party/inchi/INCHI_BASE/src/runichi4.c
void winchi_calc_inchikey( int            ret,
                           int            *ikflag,
                           INPUT_PARMS    *ip,
                           INCHI_IOSTREAM *out_file,
                           INCHI_IOSTREAM *log_file )
{
    char ik_string[256];    /* Resulting InChIKey string */
    int ik_ret = 0;           /* InChIKey-calc result code */
    int xhash1 = 0, xhash2 = 0;
    char szXtra1[256], szXtra2[256];
    size_t slen = out_file->s.nUsedLength;
    char *buf = NULL;

    ( *ikflag )++;
    if (*ikflag != 1)
    {
        return;
    }

    if (ret == 0)
    {
        inchi_ios_flush( out_file );
        return;
    }

    extract_inchi_substring( &buf, out_file->s.pStr, slen );

    /* Calculate and print InChIKey */
    if (NULL != buf)
    {
        xhash1 = xhash2 = 0;
        if (( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1 ) ||
            ( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1_XTRA2 ))
        {
            xhash1 = 1;
        }
        if (( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA2 ) ||
            ( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1_XTRA2 ))
        {
            xhash2 = 1;
        }
        ik_ret = GetINCHIKeyFromINCHI( buf, xhash1, xhash2, ik_string, szXtra1, szXtra2 );
        inchi_free( buf );
    }
    else
    {
        ik_ret = 3;
    }

    if (ik_ret == INCHIKEY_OK)
    {
        /* NB: correctly treat tabbed output with InChIKey & hash extensions */
        char csep = '\n';
        if (ip->bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT)
        {
            csep = '\t';
        }
        inchi_ios_print( out_file, "InChIKey=%-s", ik_string );
        if (xhash1)
        {
            inchi_ios_print( out_file, "%cXHash1=%-s", csep, szXtra1 );
        }
        if (xhash2)
        {
            inchi_ios_print( out_file, "%cXHash2=%-s", csep, szXtra2 );
        }
        inchi_ios_print( out_file, "\n" );
    }
    else
    {
        inchi_ios_print( log_file, "Warning (Could not compute InChIKey)\n" ); /*: ", num_inp);*/
    }
    /*inchi_ios_flush(out_file);*/

    return;
}
/****************************************************************************
 Specific to winchi-1 calculation of InChIKey
****************************************************************************/
Specific to winchi-1 calculation of InChIKey
Specific to winchi - 1 calculation of InChIKey
void winchi_calc_inchikey( int            ret,
                           int            *ikflag,
                           INPUT_PARMS    *ip,
                           INCHI_IOSTREAM *out_file,
                           INCHI_IOSTREAM *log_file )
{
    char ik_string[256];    
    int ik_ret = 0;           
    int xhash1 = 0, xhash2 = 0;
    char szXtra1[256], szXtra2[256];
    size_t slen = out_file->s.nUsedLength;
    char *buf = NULL;
    ( *ikflag )++;
    if (*ikflag != 1)
    {
        return;
    }
    if (ret == 0)
    {
        inchi_ios_flush( out_file );
        return;
    }
    extract_inchi_substring( &buf, out_file->s.pStr, slen );
    if (NULL != buf)
    {
        xhash1 = xhash2 = 0;
        if (( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1 ) ||
            ( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1_XTRA2 ))
        {
            xhash1 = 1;
        }
        if (( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA2 ) ||
            ( ip->bCalcInChIHash == INCHIHASH_KEY_XTRA1_XTRA2 ))
        {
            xhash2 = 1;
        }
        ik_ret = GetINCHIKeyFromINCHI( buf, xhash1, xhash2, ik_string, szXtra1, szXtra2 );
        inchi_free( buf );
    }
    else
    {
        ik_ret = 3;
    }
    if (ik_ret == INCHIKEY_OK)
    {
        char csep = '\n';
        if (ip->bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT)
        {
            csep = '\t';
        }
        inchi_ios_print( out_file, "InChIKey=%-s", ik_string );
        if (xhash1)
        {
            inchi_ios_print( out_file, "%cXHash1=%-s", csep, szXtra1 );
        }
        if (xhash2)
        {
            inchi_ios_print( out_file, "%cXHash2=%-s", csep, szXtra2 );
        }
        inchi_ios_print( out_file, "\n" );
    }
    else
    {
        inchi_ios_print( log_file, "Warning (Could not compute InChIKey)\n" ); 
    }
    return;
}
void winchi_calc_inchikey ( int ret , int * ikflag , INPUT_PARMS * ip , INCHI_IOSTREAM * out_file , INCHI_IOSTREAM * log_file ) { char ik_string [ 256 ] ; int ik_ret = 0 ; int xhash1 = 0 , xhash2 = 0 ; char szXtra1 [ 256 ] , szXtra2 [ 256 ] ; size_t slen = out_file -> s . nUsedLength ; char * buf = NULL ; ( * ikflag ) ++ ; if ( * ikflag != 1 ) { return ; } if ( ret == 0 ) { inchi_ios_flush ( out_file ) ; return ; } extract_inchi_substring ( & buf , out_file -> s . pStr , slen ) ; if ( NULL != buf ) { xhash1 = xhash2 = 0 ; if ( ( ip -> bCalcInChIHash == INCHIHASH_KEY_XTRA1 ) || ( ip -> bCalcInChIHash == INCHIHASH_KEY_XTRA1_XTRA2 ) ) { xhash1 = 1 ; } if ( ( ip -> bCalcInChIHash == INCHIHASH_KEY_XTRA2 ) || ( ip -> bCalcInChIHash == INCHIHASH_KEY_XTRA1_XTRA2 ) ) { xhash2 = 1 ; } ik_ret = GetINCHIKeyFromINCHI ( buf , xhash1 , xhash2 , ik_string , szXtra1 , szXtra2 ) ; inchi_free ( buf ) ; } else { ik_ret = 3 ; } if ( ik_ret == INCHIKEY_OK ) { char csep = ' \n ' ; if ( ip -> bINChIOutputOptions & INCHI_OUT_TABBED_OUTPUT ) { csep = ' \t ' ; } inchi_ios_print ( out_file , " " , ik_string ) ; if ( xhash1 ) { inchi_ios_print ( out_file , " " , csep , szXtra1 ) ; } if ( xhash2 ) { inchi_ios_print ( out_file , " " , csep , szXtra2 ) ; } inchi_ios_print ( out_file , " \n " ) ; } else { inchi_ios_print ( log_file , " \n " ) ; } return ; }
Specific to winchi-1 calculation of InChIKey
Specific to winchi - 1 calculation of InChIKey
/* Resulting InChIKey string */ /* InChIKey-calc result code */ /* Calculate and print InChIKey */ /* NB: correctly treat tabbed output with InChIKey & hash extensions */ /*: ", num_inp);*/ /*inchi_ios_flush(out_file);*/