third_party/inchi/INCHI_BASE/src/ichiread.c
int extract_from_inchi_string(char *sinchi, InpInChI *OneInput)
{
    int ret = _IS_OKAY;

    char    *strHdr = NULL;
    SEGM_LINE Line;
    SEGM_LINE *pLine = &Line;
    int  pState, nErr;
    const int bInChI2Structure = 1, bReadCoord = 1;
    int input_is_stdinchi, input_has_save_opt;
    unsigned char input_save_opt_bits;
    int end_of_data_reached, read_inchi_ok;
    INCHI_IOSTREAM tmpinputstream;
    INCHI_IOSTREAM *pInp = &tmpinputstream;
    INCHI_MODE nMode = 0;
    nMode |= (REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_STEREO | REQ_MODE_ISO_STEREO | REQ_MODE_ISO);

    nMode = (INCHI_MODE)530462;

    memset(OneInput, 0, sizeof(*OneInput));
    memset(pLine, 0, sizeof(pLine[0]));
    OneInput->polymer = NULL;    /* v. 1.05 added */
    OneInput->v3000 = NULL;
    inchi_ios_init(pInp, INCHI_IOS_TYPE_STRING, NULL);
    inchi_ios_print(pInp, "%-s", sinchi);

    ret = DetectAndExposePolymerInternals(pInp);
    if (ret)
    {
        ret = _IS_ERROR;
        goto exit_function;
    }
    /*strcpy(pInp->s.pStr, "InChI=1B/C4H4N4.2Zz/c1-5-2-7-4-8-3-6-1;;/h1-4H;;/z101-1-8(9,10-8,3,1,6,2,5,2,7,3,6,1,5,4,7,4,8)/b5-1-,5-2+,6-1+,6-3-,7-2+,7-4+,8-3+,8-4+;;");*/
    ret = InChILine2Data(pInp,
        pLine,
        &strHdr,
        &pState,
        &nErr,
        OneInput->pInpInChI,
        OneInput->nNumComponents,
        OneInput->nNumProtons,
        OneInput->s,
        bReadCoord,
        bInChI2Structure,
        nMode,
        &input_is_stdinchi,
        &input_has_save_opt,
        &input_save_opt_bits,
        &OneInput->polymer,
        &OneInput->v3000);

    end_of_data_reached = ret == RI_ERR_EOL || ret == RI_ERR_EOF;
    read_inchi_ok = end_of_data_reached && !nErr;
    if (!read_inchi_ok)
    {
        ret = _IS_ERROR;
        goto exit_function;
    }
    else
    {
        ret = _IS_OKAY;
    }


exit_function:
    if (strHdr)
    {
        inchi_free(strHdr);
        strHdr = NULL;
    }
    if (pLine->str)
    {
        inchi_free(pLine->str);
    }
    inchi_ios_close(pInp);

    return ret;
}
/* Internal: a generic parser/extractor interface */
a generic parser/extractor interface
a generic parser / extractor interface
int extract_from_inchi_string(char *sinchi, InpInChI *OneInput)
{
    int ret = _IS_OKAY;
    char    *strHdr = NULL;
    SEGM_LINE Line;
    SEGM_LINE *pLine = &Line;
    int  pState, nErr;
    const int bInChI2Structure = 1, bReadCoord = 1;
    int input_is_stdinchi, input_has_save_opt;
    unsigned char input_save_opt_bits;
    int end_of_data_reached, read_inchi_ok;
    INCHI_IOSTREAM tmpinputstream;
    INCHI_IOSTREAM *pInp = &tmpinputstream;
    INCHI_MODE nMode = 0;
    nMode |= (REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_STEREO | REQ_MODE_ISO_STEREO | REQ_MODE_ISO);
    nMode = (INCHI_MODE)530462;
    memset(OneInput, 0, sizeof(*OneInput));
    memset(pLine, 0, sizeof(pLine[0]));
    OneInput->polymer = NULL;    
    OneInput->v3000 = NULL;
    inchi_ios_init(pInp, INCHI_IOS_TYPE_STRING, NULL);
    inchi_ios_print(pInp, "%-s", sinchi);
    ret = DetectAndExposePolymerInternals(pInp);
    if (ret)
    {
        ret = _IS_ERROR;
        goto exit_function;
    }
    ret = InChILine2Data(pInp,
        pLine,
        &strHdr,
        &pState,
        &nErr,
        OneInput->pInpInChI,
        OneInput->nNumComponents,
        OneInput->nNumProtons,
        OneInput->s,
        bReadCoord,
        bInChI2Structure,
        nMode,
        &input_is_stdinchi,
        &input_has_save_opt,
        &input_save_opt_bits,
        &OneInput->polymer,
        &OneInput->v3000);
    end_of_data_reached = ret == RI_ERR_EOL || ret == RI_ERR_EOF;
    read_inchi_ok = end_of_data_reached && !nErr;
    if (!read_inchi_ok)
    {
        ret = _IS_ERROR;
        goto exit_function;
    }
    else
    {
        ret = _IS_OKAY;
    }
exit_function:
    if (strHdr)
    {
        inchi_free(strHdr);
        strHdr = NULL;
    }
    if (pLine->str)
    {
        inchi_free(pLine->str);
    }
    inchi_ios_close(pInp);
    return ret;
}
int extract_from_inchi_string ( char * sinchi , InpInChI * OneInput ) { int ret = _IS_OKAY ; char * strHdr = NULL ; SEGM_LINE Line ; SEGM_LINE * pLine = & Line ; int pState , nErr ; const int bInChI2Structure = 1 , bReadCoord = 1 ; int input_is_stdinchi , input_has_save_opt ; unsigned char input_save_opt_bits ; int end_of_data_reached , read_inchi_ok ; INCHI_IOSTREAM tmpinputstream ; INCHI_IOSTREAM * pInp = & tmpinputstream ; INCHI_MODE nMode = 0 ; nMode |= ( REQ_MODE_BASIC | REQ_MODE_TAUT | REQ_MODE_STEREO | REQ_MODE_ISO_STEREO | REQ_MODE_ISO ) ; nMode = ( INCHI_MODE ) 530462 ; memset ( OneInput , 0 , sizeof ( * OneInput ) ) ; memset ( pLine , 0 , sizeof ( pLine [ 0 ] ) ) ; OneInput -> polymer = NULL ; OneInput -> v3000 = NULL ; inchi_ios_init ( pInp , INCHI_IOS_TYPE_STRING , NULL ) ; inchi_ios_print ( pInp , " " , sinchi ) ; ret = DetectAndExposePolymerInternals ( pInp ) ; if ( ret ) { ret = _IS_ERROR ; goto exit_function ; } ret = InChILine2Data ( pInp , pLine , & strHdr , & pState , & nErr , OneInput -> pInpInChI , OneInput -> nNumComponents , OneInput -> nNumProtons , OneInput -> s , bReadCoord , bInChI2Structure , nMode , & input_is_stdinchi , & input_has_save_opt , & input_save_opt_bits , & OneInput -> polymer , & OneInput -> v3000 ) ; end_of_data_reached = ret == RI_ERR_EOL || ret == RI_ERR_EOF ; read_inchi_ok = end_of_data_reached && ! nErr ; if ( ! read_inchi_ok ) { ret = _IS_ERROR ; goto exit_function ; } else { ret = _IS_OKAY ; } exit_function : if ( strHdr ) { inchi_free ( strHdr ) ; strHdr = NULL ; } if ( pLine -> str ) { inchi_free ( pLine -> str ) ; } inchi_ios_close ( pInp ) ; return ret ; }
Internal: a generic parser/extractor interface
Internal : a generic parser / extractor interface
/* v. 1.05 added */ /*strcpy(pInp->s.pStr, "InChI=1B/C4H4N4.2Zz/c1-5-2-7-4-8-3-6-1;;/h1-4H;;/z101-1-8(9,10-8,3,1,6,2,5,2,7,3,6,1,5,4,7,4,8)/b5-1-,5-2+,6-1+,6-3-,7-2+,7-4+,8-3+,8-4+;;");*/