📄 libmng_hlapi.c
字号:
{ mng_datap pData; /* local vars */ mng_retcode iRetcode;#ifdef MNG_SUPPORT_TRACE MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ, MNG_LC_START)#endif MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ pData = ((mng_datap)hHandle); /* and make it addressable */#ifndef MNG_INTERNAL_MEMMNGMT MNG_VALIDCB (hHandle, fMemalloc) MNG_VALIDCB (hHandle, fMemfree)#endif MNG_VALIDCB (hHandle, fOpenstream) MNG_VALIDCB (hHandle, fClosestream) MNG_VALIDCB (hHandle, fReaddata)#ifdef MNG_SUPPORT_DISPLAY /* valid at this point ? */ if ((pData->bReading) || (pData->bDisplaying))#else if (pData->bReading)#endif MNG_ERROR (pData, MNG_FUNCTIONINVALID)#ifdef MNG_SUPPORT_WRITE if ((pData->bWriting) || (pData->bCreating)) MNG_ERROR (pData, MNG_FUNCTIONINVALID)#endif if (!pData->bCacheplayback) /* must store playback info to work!! */ MNG_ERROR (pData, MNG_FUNCTIONINVALID) cleanup_errors (pData); /* cleanup previous errors */ pData->bReading = MNG_TRUE; /* read only! */ if (!pData->fOpenstream (hHandle)) /* open it and start reading */ iRetcode = MNG_APPIOERROR; else iRetcode = read_graphic (pData); if (pData->bEOF) /* already at EOF ? */ { pData->bReading = MNG_FALSE; /* then we're no longer reading */ #ifdef MNG_SUPPORT_DISPLAY mng_reset_rundata (pData); /* reset rundata */#endif } if (iRetcode) /* on error bail out */ return iRetcode; if (pData->bSuspended) /* read suspension ? */ { iRetcode = MNG_NEEDMOREDATA; pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); }#ifdef MNG_SUPPORT_TRACE MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ, MNG_LC_END)#endif return iRetcode;}#endif /* MNG_SUPPORT_READ *//* ************************************************************************** */#ifdef MNG_SUPPORT_READmng_retcode MNG_DECL mng_read_resume (mng_handle hHandle){ mng_datap pData; /* local vars */ mng_retcode iRetcode;#ifdef MNG_SUPPORT_TRACE MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_RESUME, MNG_LC_START)#endif MNG_VALIDHANDLE (hHandle) /* check validity handle */ pData = ((mng_datap)hHandle); /* and make it addressable */ /* can we expect this call ? */ if ((!pData->bReading) || (!pData->bSuspended)) MNG_ERROR (pData, MNG_FUNCTIONINVALID) cleanup_errors (pData); /* cleanup previous errors */ pData->bSuspended = MNG_FALSE; /* reset the flag */#ifdef MNG_SUPPORT_DISPLAY /* re-synchronize ? */ if ((pData->bDisplaying) && (pData->bRunning)) pData->iSynctime = pData->iSynctime - pData->iSuspendtime + pData->fGettickcount (hHandle);#endif iRetcode = read_graphic (pData); /* continue reading now */ if (pData->bEOF) /* at EOF ? */ { pData->bReading = MNG_FALSE; /* then we're no longer reading */ #ifdef MNG_SUPPORT_DISPLAY mng_reset_rundata (pData); /* reset rundata */#endif } if (iRetcode) /* on error bail out */ return iRetcode; if (pData->bSuspended) /* read suspension ? */ { iRetcode = MNG_NEEDMOREDATA; pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); }#ifdef MNG_SUPPORT_TRACE MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_RESUME, MNG_LC_END)#endif return iRetcode;}#endif /* MNG_SUPPORT_READ *//* ************************************************************************** */#ifdef MNG_SUPPORT_WRITEmng_retcode MNG_DECL mng_write (mng_handle hHandle){ mng_datap pData; mng_retcode iRetcode;#ifdef MNG_SUPPORT_TRACE MNG_TRACE (((mng_datap)hHandle), MNG_FN_WRITE, MNG_LC_START)#endif MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ pData = ((mng_datap)hHandle); /* and make it addressable */#ifndef MNG_INTERNAL_MEMMNGMT MNG_VALIDCB (hHandle, fMemalloc) MNG_VALIDCB (hHandle, fMemfree)#endif MNG_VALIDCB (hHandle, fOpenstream) MNG_VALIDCB (hHandle, fClosestream) MNG_VALIDCB (hHandle, fWritedata)#ifdef MNG_SUPPORT_READ if (pData->bReading) /* valid at this point ? */ MNG_ERROR (pData, MNG_FUNCTIONINVALID)#endif if (pData->bCreating) /* can't write while it's still being made! */ MNG_ERROR (pData, MNG_FUNCTIONINVALID) cleanup_errors (pData); /* cleanup previous errors */ iRetcode = write_graphic (pData); /* do the write */ if (iRetcode) /* on error bail out */ return iRetcode;#ifdef MNG_SUPPORT_TRACE MNG_TRACE (((mng_datap)hHandle), MNG_FN_WRITE, MNG_LC_END)#endif return MNG_NOERROR;}#endif /* MNG_SUPPORT_WRITE *//* ************************************************************************** */#ifdef MNG_SUPPORT_WRITEmng_retcode MNG_DECL mng_create (mng_handle hHandle){ mng_datap pData; mng_retcode iRetcode;#ifdef MNG_SUPPORT_TRACE MNG_TRACE (((mng_datap)hHandle), MNG_FN_CREATE, MNG_LC_START)#endif MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ pData = ((mng_datap)hHandle); /* and make it addressable */#ifndef MNG_INTERNAL_MEMMNGMT MNG_VALIDCB (hHandle, fMemalloc) MNG_VALIDCB (hHandle, fMemfree)#endif#ifdef MNG_SUPPORT_READ if (pData->bReading) /* valid at this point ? */ MNG_ERROR (pData, MNG_FUNCTIONINVALID)#endif if ((pData->bWriting) || (pData->bCreating)) MNG_ERROR (pData, MNG_FUNCTIONINVALID) cleanup_errors (pData); /* cleanup previous errors */ iRetcode = mng_reset (hHandle); /* clear any previous stuff */ if (iRetcode) /* on error bail out */ return iRetcode; pData->bCreating = MNG_TRUE; /* indicate we're creating a new file */#ifdef MNG_SUPPORT_TRACE MNG_TRACE (((mng_datap)hHandle), MNG_FN_CREATE, MNG_LC_END)#endif return MNG_NOERROR;}#endif /* MNG_SUPPORT_WRITE *//* ************************************************************************** */#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_READ)mng_retcode MNG_DECL mng_readdisplay (mng_handle hHandle){ mng_datap pData; /* local vars */ mng_retcode iRetcode;#ifdef MNG_SUPPORT_TRACE MNG_TRACE (((mng_datap)hHandle), MNG_FN_READDISPLAY, MNG_LC_START)#endif MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ pData = ((mng_datap)hHandle); /* and make it addressable */#ifndef MNG_INTERNAL_MEMMNGMT MNG_VALIDCB (hHandle, fMemalloc) MNG_VALIDCB (hHandle, fMemfree)#endif MNG_VALIDCB (hHandle, fReaddata) MNG_VALIDCB (hHandle, fGetcanvasline) MNG_VALIDCB (hHandle, fRefresh) MNG_VALIDCB (hHandle, fGettickcount) MNG_VALIDCB (hHandle, fSettimer) /* valid at this point ? */ if ((pData->bReading) || (pData->bDisplaying)) MNG_ERROR (pData, MNG_FUNCTIONINVALID)#ifdef MNG_SUPPORT_WRITE if ((pData->bWriting) || (pData->bCreating)) MNG_ERROR (pData, MNG_FUNCTIONINVALID)#endif cleanup_errors (pData); /* cleanup previous errors */ pData->bReading = MNG_TRUE; /* read & display! */ pData->bDisplaying = MNG_TRUE; pData->bRunning = MNG_TRUE; pData->iFrameseq = 0; pData->iLayerseq = 0; pData->iFrametime = 0; pData->iRequestframe = 0; pData->iRequestlayer = 0; pData->iRequesttime = 0; pData->bSearching = MNG_FALSE; pData->iRuntime = 0; pData->iSynctime = pData->fGettickcount (hHandle); pData->iSuspendtime = 0; pData->iStarttime = pData->iSynctime; pData->iEndtime = 0; if (!pData->fOpenstream (hHandle)) /* open it and start reading */ iRetcode = MNG_APPIOERROR; else iRetcode = read_graphic (pData); if (pData->bEOF) /* already at EOF ? */ { pData->bReading = MNG_FALSE; /* then we're no longer reading */ drop_invalid_objects (pData); /* drop invalidly stored objects */ } if (iRetcode) /* on error bail out */ return iRetcode; if (pData->bSuspended) /* read suspension ? */ { iRetcode = MNG_NEEDMOREDATA; pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData); } else if (pData->bTimerset) /* indicate timer break ? */ iRetcode = MNG_NEEDTIMERWAIT; else if (pData->bSectionwait) /* indicate section break ? */ iRetcode = MNG_NEEDSECTIONWAIT; else pData->bRunning = MNG_FALSE; /* no breaks = end of run */#ifdef MNG_SUPPORT_TRACE MNG_TRACE (((mng_datap)hHandle), MNG_FN_READDISPLAY, MNG_LC_END)#endif return iRetcode;}#endif /* MNG_SUPPORT_DISPLAY && MNG_SUPPORT_READ *//* ************************************************************************** */#ifdef MNG_SUPPORT_DISPLAYmng_retcode MNG_DECL mng_display (mng_handle hHandle){ mng_datap pData; /* local vars */ mng_retcode iRetcode;#ifdef MNG_SUPPORT_TRACE MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY, MNG_LC_START)#endif MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */ pData = ((mng_datap)hHandle); /* and make it addressable */#ifndef MNG_INTERNAL_MEMMNGMT MNG_VALIDCB (hHandle, fMemalloc) MNG_VALIDCB (hHandle, fMemfree)#endif MNG_VALIDCB (hHandle, fGetcanvasline) MNG_VALIDCB (hHandle, fRefresh) MNG_VALIDCB (hHandle, fGettickcount) MNG_VALIDCB (hHandle, fSettimer) if (pData->bDisplaying) /* valid at this point ? */ MNG_ERROR (pData, MNG_FUNCTIONINVALID) #ifdef MNG_SUPPORT_READ if (pData->bReading) MNG_ERROR (pData, MNG_FUNCTIONINVALID)#endif#ifdef MNG_SUPPORT_WRITE if ((pData->bWriting) || (pData->bCreating)) MNG_ERROR (pData, MNG_FUNCTIONINVALID)#endif cleanup_errors (pData); /* cleanup previous errors */ pData->bDisplaying = MNG_TRUE; /* display! */ pData->bRunning = MNG_TRUE; pData->iFrameseq = 0; pData->iLayerseq = 0; pData->iFrametime = 0; pData->iRequestframe = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -