if (iRetcode)                       return iRetcode;  if ((pData->bDisplaying) && (pData->bRunning) && (!pData->bFreezing)) {
if (!iRetcode)
READ_CHUNK (read_fram){  mng_uint8p pTemp;  mng_uint32 iNamelen;  mng_uint32 iRemain;  mng_uint32 iRequired = 0;#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_READ_FRAM, MNG_LC_START)#endif  if (!pData->bHasMHDR)                /* sequence checks */    MNG_ERROR (pData, MNG_SEQUENCEERROR)#ifdef MNG_INCLUDE_JNG  if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))#else  if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))#endif    MNG_ERROR (pData, MNG_SEQUENCEERROR)  if (iRawlen <= 1)                    /* only framing-mode ? */  {    iNamelen = 0;                      /* indicate so */    iRemain  = 0;    pTemp    = MNG_NULL;  }  else  {    pTemp = find_null (pRawdata+1);    /* find null-separator */                                       /* not found inside input-data ? */    if ((pTemp - pRawdata) > (mng_int32)iRawlen)      MNG_ERROR (pData, MNG_NULLNOTFOUND)    iNamelen = (mng_uint32)((pTemp - pRawdata) - 1);    iRemain  = (mng_uint32)(iRawlen - (pTemp - pRawdata) - 1);                                       /* remains must be empty or at least 4 bytes */    if ((iRemain != 0) && (iRemain < 4))      MNG_ERROR (pData, MNG_INVALIDLENGTH)    if (iRemain)    {      iRequired = 4;                   /* calculate and check required remaining length */      if (*(pTemp+1)) { iRequired += 4; }      if (*(pTemp+2)) { iRequired += 4; }      if (*(pTemp+3)) { iRequired += 17; }      if (*(pTemp+4))      {        if ((iRemain - iRequired) % 4 != 0)          MNG_ERROR (pData, MNG_INVALIDLENGTH)      }      else      {        if (iRemain != iRequired)          MNG_ERROR (pData, MNG_INVALIDLENGTH)      }    }  }#ifdef MNG_SUPPORT_DISPLAY  {    mng_uint8p  pWork           = pTemp;    mng_uint8   iFramemode      = 0;    mng_uint8   iChangedelay    = 0;    mng_uint32  iDelay          = 0;    mng_uint8   iChangetimeout  = 0;    mng_uint32  iTimeout        = 0;    mng_uint8   iChangeclipping = 0;    mng_uint8   iCliptype       = 0;    mng_int32   iClipl          = 0;    mng_int32   iClipr          = 0;    mng_int32   iClipt          = 0;    mng_int32   iClipb          = 0;    mng_retcode iRetcode;    if (iRawlen)                       /* any data specified ? */    {      if (*(pRawdata))                 /* save the new framing mode ? */      {        iFramemode = *(pRawdata);        if (pData->bPreDraft48)        /* old style input-stream ? */        {          switch (iFramemode)          {            case  0: { break; }            case  1: { iFramemode = 3; break; }            case  2: { iFramemode = 4; break; }            case  3: { iFramemode = 1; break; }            case  4: { iFramemode = 1; break; }            case  5: { iFramemode = 2; break; }            default: { iFramemode = 1; break; }          }        }      }      if (iRemain)      {        iChangedelay    = *(pWork+1);        iChangetimeout  = *(pWork+2);        iChangeclipping = *(pWork+3);        pWork += 5;        if (iChangedelay)              /* delay changed ? */        {          iDelay = mng_get_uint32 (pWork);          pWork += 4;        }        if (iChangetimeout)            /* timeout changed ? */        {          iTimeout = mng_get_uint32 (pWork);          pWork += 4;        }        if (iChangeclipping)           /* clipping changed ? */        {          iCliptype = *pWork;          iClipl    = mng_get_int32 (pWork+1);          iClipr    = mng_get_int32 (pWork+5);          iClipt    = mng_get_int32 (pWork+9);          iClipb    = mng_get_int32 (pWork+13);        }      }    }    iRetcode = create_ani_fram (pData, iFramemode, iChangedelay, iDelay,                                iChangetimeout, iTimeout,                                iChangeclipping, iCliptype,                                iClipl, iClipr, iClipt, iClipb);    if (iRetcode)                      /* on error bail out */      return iRetcode;                                       /* now go and do something */    if ((pData->bDisplaying) && (pData->bRunning) && (!pData->bFreezing))    {      iRetcode = process_display_fram (pData, iFramemode, iChangedelay, iDelay,                                       iChangetimeout, iTimeout,                                       iChangeclipping, iCliptype,                                       iClipl, iClipr, iClipt, iClipb);      if (iRetcode)                    /* on error bail out */        return iRetcode;    }  }#endif /* MNG_SUPPORT_DISPLAY */#ifdef MNG_STORE_CHUNKS  if (pData->bStorechunks)  {                                    /* initialize storage */    mng_retcode iRetcode = ((mng_chunk_headerp)pHeader)->fCreate (pData, pHeader, ppChunk);    if (iRetcode)                      /* on error bail out */      return iRetcode;                                       /* store the fields */    ((mng_framp)*ppChunk)->bEmpty              = (mng_bool)(iRawlen == 0);    if (iRawlen)    {      mng_uint8 iFramemode = *(pRawdata);      if (pData->bPreDraft48)          /* old style input-stream ? */      {        switch (iFramemode)        {          case  1: { iFramemode = 3; break; }          case  2: { iFramemode = 4; break; }          case  3: { iFramemode = 5; break; }    /* TODO: provision for mode=5 ??? */          case  4: { iFramemode = 1; break; }          case  5: { iFramemode = 2; break; }          default: { iFramemode = 1; break; }        }      }      ((mng_framp)*ppChunk)->iMode             = iFramemode;      ((mng_framp)*ppChunk)->iNamesize         = iNamelen;      if (iNamelen)      {        MNG_ALLOC (pData, ((mng_framp)*ppChunk)->zName, iNamelen+1)        MNG_COPY (((mng_framp)*ppChunk)->zName, pRawdata+1, iNamelen)      }      if (iRemain)      {        ((mng_framp)*ppChunk)->iChangedelay    = *(pTemp+1);        ((mng_framp)*ppChunk)->iChangetimeout  = *(pTemp+2);        ((mng_framp)*ppChunk)->iChangeclipping = *(pTemp+3);        ((mng_framp)*ppChunk)->iChangesyncid   = *(pTemp+4);        pTemp += 5;        if (((mng_framp)*ppChunk)->iChangedelay)        {          ((mng_framp)*ppChunk)->iDelay        = mng_get_uint32 (pTemp);          pTemp += 4;        }        if (((mng_framp)*ppChunk)->iChangetimeout)        {          ((mng_framp)*ppChunk)->iTimeout      = mng_get_uint32 (pTemp);          pTemp += 4;        }        if (((mng_framp)*ppChunk)->iChangeclipping)        {          ((mng_framp)*ppChunk)->iBoundarytype = *pTemp;          ((mng_framp)*ppChunk)->iBoundaryl    = mng_get_int32 (pTemp+1);          ((mng_framp)*ppChunk)->iBoundaryr    = mng_get_int32 (pTemp+5);          ((mng_framp)*ppChunk)->iBoundaryt    = mng_get_int32 (pTemp+9);          ((mng_framp)*ppChunk)->iBoundaryb    = mng_get_int32 (pTemp+13);          pTemp += 17;        }        if (((mng_framp)*ppChunk)->iChangesyncid)        {          ((mng_framp)*ppChunk)->iCount        = (iRemain - iRequired) / 4;          if (((mng_framp)*ppChunk)->iCount)          {            MNG_ALLOC (pData, ((mng_framp)*ppChunk)->pSyncids,                              ((mng_framp)*ppChunk)->iCount * 4);#ifndef MNG_BIGENDIAN_SUPPORTED            {              mng_uint32 iX;              mng_uint32p pOut = ((mng_framp)*ppChunk)->pSyncids;              for (iX = 0; iX < ((mng_framp)*ppChunk)->iCount; iX++)              {                *pOut++ = mng_get_uint32 (pTemp);                pTemp += 4;              }            }#else            MNG_COPY (((mng_framp)*ppChunk)->pSyncids, pTemp,                      ((mng_framp)*ppChunk)->iCount * 4)#endif /* !MNG_BIGENDIAN_SUPPORTED */          }        }      }    }  }#endif /* MNG_STORE_CHUNKS */#ifdef MNG_SUPPORT_TRACE  MNG_TRACE (pData, MNG_FN_READ_FRAM, MNG_LC_END)#endif  return MNG_NOERROR;                  /* done */}