iKeywordlen     = (mng_uint32)(pNull1 - pRawdata); iLanguagelen    = (mng_uint32)(pNull2 - pNull1 - 3); iTranslationlen = (mng_uint32)(pNull3 - pNull2 - 1); iCompressedsize = (mng_uint32)(iRawlen - iKeywordlen - iLanguagelen - iTranslationlen - 5);
iKeywordlen      = (mng_uint32)(pNull1 - pRawdata); iLanguagelen     = (mng_uint32)(pNull2 - pNull1 - 3); iTranslationlen  = (mng_uint32)(pNull3 - pNull2 - 1); iCompressedsize  = (mng_uint32)(iRawlen - iKeywordlen - iLanguagelen - iTranslationlen - 5); iCompressionflag = *(pNull1+1);
READ_CHUNK (read_itxt){  mng_retcode iRetcode;  mng_uint32  iKeywordlen, iTextlen, iLanguagelen, iTranslationlen;  mng_pchar   zKeyword, zLanguage, zTranslation;  mng_uint8p  pNull1, pNull2, pNull3;  mng_uint32  iCompressedsize;  mng_uint32  iBufsize;  mng_uint8p  pBuf;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_READ_ITXT, MNG_LC_START)#endif                                       /* sequence checks */#ifdef MNG_INCLUDE_JNG  if ((!pData->bHasMHDR) && (!pData->bHasIHDR) &&      (!pData->bHasBASI) && (!pData->bHasDHDR) && (!pData->bHasJHDR))#else  if ((!pData->bHasMHDR) && (!pData->bHasIHDR) &&      (!pData->bHasBASI) && (!pData->bHasDHDR)    )#endif    MNG_ERROR (pData, MNG_SEQUENCEERROR)  if (iRawlen < 6)                     /* length must be at least 6 */    MNG_ERROR (pData, MNG_INVALIDLENGTH)  pNull1 = find_null (pRawdata);       /* find the null separators */  pNull2 = find_null (pNull1+3);  pNull3 = find_null (pNull2+1);                                       /* not found inside input-data ? */  if (((pNull1 - pRawdata) > (mng_int32)iRawlen) ||      ((pNull2 - pRawdata) > (mng_int32)iRawlen) ||      ((pNull3 - pRawdata) > (mng_int32)iRawlen)    )    MNG_ERROR (pData, MNG_NULLNOTFOUND)  if (pNull1 == pRawdata)              /* there must be at least 1 char for keyword */    MNG_ERROR (pData, MNG_KEYWORDNULL)                                       /* compression or not ? */  if ((*(pNull1+1) != 0) && (*(pNull1+1) != 1))    MNG_ERROR (pData, MNG_INVALIDCOMPRESS)  if (*(pNull1+2) != 0)                /* only deflate compression-method allowed */    MNG_ERROR (pData, MNG_INVALIDCOMPRESS)  iKeywordlen     = (mng_uint32)(pNull1 - pRawdata);  iLanguagelen    = (mng_uint32)(pNull2 - pNull1 - 3);  iTranslationlen = (mng_uint32)(pNull3 - pNull2 - 1);  iCompressedsize = (mng_uint32)(iRawlen - iKeywordlen - iLanguagelen - iTranslationlen - 5);  zKeyword     = 0;                    /* no buffers acquired yet */  zLanguage    = 0;  zTranslation = 0;  pBuf         = 0;  iTextlen     = 0;  if (pData->fProcesstext)             /* inform the application ? */  {                                    /* decompress the text */    iRetcode = inflate_buffer (pData, pNull3+1, iCompressedsize,                               &pBuf, &iBufsize, &iTextlen);    if (iRetcode)                      /* on error bail out */    {                                  /* don't forget to drop the temp buffer */      MNG_FREEX (pData, pBuf, iBufsize)      return iRetcode;    }    MNG_ALLOCX (pData, zKeyword,     iKeywordlen     + 1)    MNG_ALLOCX (pData, zLanguage,    iLanguagelen    + 1)    MNG_ALLOCX (pData, zTranslation, iTranslationlen + 1)                                       /* on error bail out */    if ((!zKeyword) || (!zLanguage) || (!zTranslation))    {                                  /* don't forget to drop the temp buffers */      MNG_FREEX (pData, zTranslation, iTranslationlen + 1)      MNG_FREEX (pData, zLanguage,    iLanguagelen    + 1)      MNG_FREEX (pData, zKeyword,     iKeywordlen     + 1)      MNG_FREEX (pData, pBuf, iBufsize)      MNG_ERROR (pData, MNG_OUTOFMEMORY)    }    MNG_COPY (zKeyword,     pRawdata, iKeywordlen)    MNG_COPY (zLanguage,    pNull1+3, iLanguagelen)    MNG_COPY (zTranslation, pNull2+1, iTranslationlen)    if (!pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ZTXT, zKeyword, (mng_pchar)pBuf,                                                                zLanguage, zTranslation))    {                                  /* don't forget to drop the temp buffers */      MNG_FREEX (pData, zTranslation, iTranslationlen + 1)      MNG_FREEX (pData, zLanguage,    iLanguagelen    + 1)      MNG_FREEX (pData, zKeyword,     iKeywordlen     + 1)      MNG_FREEX (pData, pBuf,         iBufsize)            MNG_ERROR (pData, MNG_APPMISCERROR)    }  }#ifdef MNG_STORE_CHUNKS  if (pData->bStorechunks)  {                                    /* initialize storage */    iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk);    if (iRetcode)                      /* on error bail out */    {                                  /* don't forget to drop the temp buffers */      MNG_FREEX (pData, zTranslation, iTranslationlen + 1)      MNG_FREEX (pData, zLanguage,    iLanguagelen    + 1)      MNG_FREEX (pData, zKeyword,     iKeywordlen     + 1)      MNG_FREEX (pData, pBuf,         iBufsize)      return iRetcode;    }                                       /* store the fields */    ((mng_itxtp)*ppChunk)->iKeywordsize       = iKeywordlen;    ((mng_itxtp)*ppChunk)->iLanguagesize      = iLanguagelen;    ((mng_itxtp)*ppChunk)->iTranslationsize   = iTranslationlen;    ((mng_itxtp)*ppChunk)->iCompressionflag   = *(pNull1+1);    ((mng_itxtp)*ppChunk)->iCompressionmethod = *(pNull1+2);    if ((!pBuf) && (iCompressedsize))  /* did we not get a text-buffer yet ? */    {                                  /* decompress the text */      iRetcode = inflate_buffer (pData, pNull3+1, iCompressedsize,                                 &pBuf, &iBufsize, &iTextlen);      if (iRetcode)                    /* on error bail out */      {                                /* don't forget to drop the temp buffers */        MNG_FREEX (pData, zTranslation, iTranslationlen + 1)        MNG_FREEX (pData, zLanguage,    iLanguagelen    + 1)        MNG_FREEX (pData, zKeyword,     iKeywordlen     + 1)        MNG_FREEX (pData, pBuf,         iBufsize)        return iRetcode;      }    }    MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zKeyword,     iKeywordlen     + 1)    MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zLanguage,    iLanguagelen    + 1)    MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zTranslation, iTranslationlen + 1)                                       /* on error bail out */    if ((!((mng_itxtp)*ppChunk)->zKeyword    ) ||        (!((mng_itxtp)*ppChunk)->zLanguage   ) ||        (!((mng_itxtp)*ppChunk)->zTranslation)    )    {                                  /* don't forget to drop the temp buffers */      MNG_FREEX (pData, zTranslation, iTranslationlen + 1)      MNG_FREEX (pData, zLanguage,    iLanguagelen    + 1)      MNG_FREEX (pData, zKeyword,     iKeywordlen     + 1)      MNG_FREEX (pData, pBuf,         iBufsize)      MNG_ERROR (pData, MNG_OUTOFMEMORY)    }    MNG_COPY (((mng_itxtp)*ppChunk)->zKeyword,     pRawdata, iKeywordlen)    MNG_COPY (((mng_itxtp)*ppChunk)->zLanguage,    pNull1+3, iLanguagelen)    MNG_COPY (((mng_itxtp)*ppChunk)->zTranslation, pNull2+1, iTranslationlen)    ((mng_itxtp)*ppChunk)->iTextsize = iTextlen;    if (iCompressedsize)    {      MNG_ALLOCX (pData, ((mng_itxtp)*ppChunk)->zText, iTextlen + 1)      if (!((mng_itxtp)*ppChunk)->zText)      {                                /* don't forget to drop the temp buffers */        MNG_FREEX (pData, zTranslation, iTranslationlen + 1)        MNG_FREEX (pData, zLanguage,    iLanguagelen    + 1)        MNG_FREEX (pData, zKeyword,     iKeywordlen     + 1)        MNG_FREEX (pData, pBuf,         iBufsize)        MNG_ERROR (pData, MNG_OUTOFMEMORY)      }      MNG_COPY  (((mng_itxtp)*ppChunk)->zText, pBuf, iTextlen)    }  }#endif /* MNG_STORE_CHUNKS */                                       /* free the temporary buffers */  MNG_FREEX (pData, zTranslation, iTranslationlen + 1)  MNG_FREEX (pData, zLanguage,    iLanguagelen    + 1)  MNG_FREEX (pData, zKeyword,     iKeywordlen     + 1)  MNG_FREEX (pData, pBuf,         iBufsize)#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_READ_ITXT, MNG_LC_END)#endif  return MNG_NOERROR;                  /* done */}