source: trunk/src/3rdparty/libmng/libmng_hlapi.c

Last change on this file was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 67.6 KB
Line 
1/* ************************************************************************** */
2/* * For conditions of distribution and use, * */
3/* * see copyright notice in libmng.h * */
4/* ************************************************************************** */
5/* * * */
6/* * project : libmng * */
7/* * file : libmng_hlapi.c copyright (c) 2000 G.Juyn * */
8/* * version : 1.0.2 * */
9/* * * */
10/* * purpose : high-level application API (implementation) * */
11/* * * */
12/* * author : G.Juyn * */
13/* * web : http://www.3-t.com * */
14/* * email : mailto:info@3-t.com * */
15/* * * */
16/* * comment : implementation of the high-level function interface * */
17/* * for applications. * */
18/* * * */
19/* * changes : 0.5.1 - 05/06/2000 - G.Juyn * */
20/* * - added init of iPLTEcount * */
21/* * 0.5.1 - 05/08/2000 - G.Juyn * */
22/* * - changed calling-convention definition * */
23/* * - changed status-handling of display-routines * */
24/* * - added versioning-control routines * */
25/* * - filled the write routine * */
26/* * - changed strict-ANSI stuff * */
27/* * 0.5.1 - 05/11/2000 - G.Juyn * */
28/* * - added callback error-reporting support * */
29/* * 0.5.1 - 05/12/2000 - G.Juyn * */
30/* * - changed trace to macro for callback error-reporting * */
31/* * 0.5.1 - 05/13/2000 - G.Juyn * */
32/* * - added eMNGma hack (will be removed in 1.0.0 !!!) * */
33/* * - added TERM animation object pointer (easier reference) * */
34/* * 0.5.1 - 05/14/2000 - G.Juyn * */
35/* * - added cleanup of saved-data (SAVE/SEEK processing) * */
36/* * 0.5.1 - 05/16/2000 - G.Juyn * */
37/* * - moved the actual write_graphic functionality from here * */
38/* * to it's appropriate function in the mng_write module * */
39/* * * */
40/* * 0.5.2 - 05/19/2000 - G.Juyn * */
41/* * - cleaned up some code regarding mixed support * */
42/* * - added JNG support * */
43/* * 0.5.2 - 05/24/2000 - G.Juyn * */
44/* * - moved init of default zlib parms here from "mng_zlib.c" * */
45/* * - added init of default IJG parms * */
46/* * 0.5.2 - 05/29/2000 - G.Juyn * */
47/* * - fixed inconsistancy with freeing global iCCP profile * */
48/* * 0.5.2 - 05/30/2000 - G.Juyn * */
49/* * - added delta-image field initialization * */
50/* * 0.5.2 - 06/06/2000 - G.Juyn * */
51/* * - added initialization of the buffer-suspend parameter * */
52/* * * */
53/* * 0.5.3 - 06/16/2000 - G.Juyn * */
54/* * - added initialization of update-region for refresh * */
55/* * - added initialization of Needrefresh parameter * */
56/* * 0.5.3 - 06/17/2000 - G.Juyn * */
57/* * - added initialization of Deltaimmediate * */
58/* * 0.5.3 - 06/21/2000 - G.Juyn * */
59/* * - added initialization of Speed * */
60/* * - added initialization of Imagelevel * */
61/* * 0.5.3 - 06/26/2000 - G.Juyn * */
62/* * - changed userdata variable to mng_ptr * */
63/* * 0.5.3 - 06/29/2000 - G.Juyn * */
64/* * - fixed initialization routine for new mng_handle type * */
65/* * * */
66/* * 0.9.1 - 07/06/2000 - G.Juyn * */
67/* * - changed mng_display_resume to allow to be called after * */
68/* * a suspension return with MNG_NEEDMOREDATA * */
69/* * - added returncode MNG_NEEDTIMERWAIT for timer breaks * */
70/* * 0.9.1 - 07/07/2000 - G.Juyn * */
71/* * - implemented support for freeze/reset/resume & go_xxxx * */
72/* * 0.9.1 - 07/08/2000 - G.Juyn * */
73/* * - added support for improved timing * */
74/* * - added support for improved I/O-suspension * */
75/* * 0.9.1 - 07/14/2000 - G.Juyn * */
76/* * - changed EOF processing behavior * */
77/* * 0.9.1 - 07/15/2000 - G.Juyn * */
78/* * - added callbacks for SAVE/SEEK processing * */
79/* * - added variable for NEEDSECTIONWAIT breaks * */
80/* * - added variable for freeze & reset processing * */
81/* * 0.9.1 - 07/17/2000 - G.Juyn * */
82/* * - added error cleanup processing * */
83/* * - fixed support for mng_display_reset() * */
84/* * - fixed suspension-buffering for 32K+ chunks * */
85/* * * */
86/* * 0.9.2 - 07/29/2000 - G.Juyn * */
87/* * - fixed small bugs in display processing * */
88/* * 0.9.2 - 07/31/2000 - G.Juyn * */
89/* * - fixed wrapping of suspension parameters * */
90/* * 0.9.2 - 08/04/2000 - G.Juyn * */
91/* * - B111096 - fixed large-buffer read-suspension * */
92/* * 0.9.2 - 08/05/2000 - G.Juyn * */
93/* * - changed file-prefixes * */
94/* * * */
95/* * 0.9.3 - 09/07/2000 - G.Juyn * */
96/* * - added support for new filter_types * */
97/* * 0.9.3 - 09/10/2000 - G.Juyn * */
98/* * - fixed DEFI behavior * */
99/* * 0.9.3 - 10/11/2000 - G.Juyn * */
100/* * - added support for nEED * */
101/* * 0.9.3 - 10/16/2000 - G.Juyn * */
102/* * - added optional support for bKGD for PNG images * */
103/* * - raised initial maximum canvas size * */
104/* * - added support for JDAA * */
105/* * 0.9.3 - 10/17/2000 - G.Juyn * */
106/* * - added callback to process non-critical unknown chunks * */
107/* * - fixed support for delta-images during read() / display() * */
108/* * 0.9.3 - 10/18/2000 - G.Juyn * */
109/* * - added closestream() processing for mng_cleanup() * */
110/* * 0.9.3 - 10/27/2000 - G.Juyn * */
111/* * - fixed seperate read() & display() processing * */
112/* * * */
113/* * 0.9.4 - 11/20/2000 - G.Juyn * */
114/* * - fixed unwanted repetition in mng_readdisplay() * */
115/* * 0.9.4 - 11/24/2000 - G.Juyn * */
116/* * - moved restore of object 0 to libmng_display * */
117/* * * */
118/* * 1.0.1 - 02/08/2001 - G.Juyn * */
119/* * - added MEND processing callback * */
120/* * 1.0.1 - 02/13/2001 - G.Juyn * */
121/* * - fixed first FRAM_MODE=4 timing problem * */
122/* * 1.0.1 - 04/21/2001 - G.Juyn * */
123/* * - fixed bug with display_reset/display_resume (Thanks G!) * */
124/* * 1.0.1 - 04/22/2001 - G.Juyn * */
125/* * - fixed memory-leak (Thanks Gregg!) * */
126/* * 1.0.1 - 04/23/2001 - G.Juyn * */
127/* * - fixed reset_rundata to drop all objects * */
128/* * 1.0.1 - 04/25/2001 - G.Juyn * */
129/* * - moved mng_clear_cms to libmng_cms * */
130/* * * */
131/* * 1.0.2 - 06/23/2001 - G.Juyn * */
132/* * - added optimization option for MNG-video playback * */
133/* * - added processterm callback * */
134/* * 1.0.2 - 06/25/2001 - G.Juyn * */
135/* * - added option to turn off progressive refresh * */
136/* * * */
137/* ************************************************************************** */
138
139#include "libmng.h"
140#include "libmng_data.h"
141#include "libmng_error.h"
142#include "libmng_trace.h"
143#ifdef __BORLANDC__
144#pragma hdrstop
145#endif
146#include "libmng_objects.h"
147#include "libmng_object_prc.h"
148#include "libmng_chunks.h"
149#include "libmng_memory.h"
150#include "libmng_read.h"
151#include "libmng_write.h"
152#include "libmng_display.h"
153#include "libmng_zlib.h"
154#include "libmng_jpeg.h"
155#include "libmng_cms.h"
156#include "libmng_pixels.h"
157
158#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
159#pragma option -A /* force ANSI-C */
160#endif
161
162/* ************************************************************************** */
163/* * * */
164/* * local routines * */
165/* * * */
166/* ************************************************************************** */
167
168#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
169mng_retcode mng_drop_chunks (mng_datap pData)
170{
171 mng_chunkp pChunk;
172 mng_chunkp pNext;
173 mng_cleanupchunk fCleanup;
174
175#ifdef MNG_SUPPORT_TRACE
176 MNG_TRACE (pData, MNG_FN_DROP_CHUNKS, MNG_LC_START)
177#endif
178
179 pChunk = pData->pFirstchunk; /* and get first stored chunk (if any) */
180
181 while (pChunk) /* more chunks to discard ? */
182 {
183 pNext = ((mng_chunk_headerp)pChunk)->pNext;
184 /* call appropriate cleanup */
185 fCleanup = ((mng_chunk_headerp)pChunk)->fCleanup;
186 fCleanup (pData, pChunk);
187
188 pChunk = pNext; /* neeeext */
189 }
190
191#ifdef MNG_SUPPORT_TRACE
192 MNG_TRACE (pData, MNG_FN_DROP_CHUNKS, MNG_LC_END)
193#endif
194
195 return MNG_NOERROR;
196}
197#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
198
199/* ************************************************************************** */
200
201#ifdef MNG_SUPPORT_DISPLAY
202mng_retcode mng_drop_objects (mng_datap pData,
203 mng_bool bDropaniobj)
204{
205 mng_objectp pObject;
206 mng_objectp pNext;
207 mng_cleanupobject fCleanup;
208
209#ifdef MNG_SUPPORT_TRACE
210 MNG_TRACE (pData, MNG_FN_DROP_OBJECTS, MNG_LC_START)
211#endif
212
213 pObject = pData->pFirstimgobj; /* get first stored image-object (if any) */
214
215 while (pObject) /* more objects to discard ? */
216 {
217 pNext = ((mng_object_headerp)pObject)->pNext;
218 /* call appropriate cleanup */
219 fCleanup = ((mng_object_headerp)pObject)->fCleanup;
220 fCleanup (pData, pObject);
221
222 pObject = pNext; /* neeeext */
223 }
224
225 pData->pFirstimgobj = MNG_NULL; /* clean this up!!! */
226
227 if (bDropaniobj) /* drop animation objects ? */
228 {
229 pObject = pData->pFirstaniobj; /* get first stored animation-object (if any) */
230
231 while (pObject) /* more objects to discard ? */
232 {
233 pNext = ((mng_object_headerp)pObject)->pNext;
234 /* call appropriate cleanup */
235 fCleanup = ((mng_object_headerp)pObject)->fCleanup;
236 fCleanup (pData, pObject);
237
238 pObject = pNext; /* neeeext */
239 }
240
241 pData->pFirstaniobj = MNG_NULL; /* clean this up!!! */
242 }
243
244#ifdef MNG_SUPPORT_TRACE
245 MNG_TRACE (pData, MNG_FN_DROP_OBJECTS, MNG_LC_END)
246#endif
247
248 return MNG_NOERROR;
249}
250#endif /* MNG_SUPPORT_DISPLAY */
251
252/* ************************************************************************** */
253
254#ifdef MNG_SUPPORT_DISPLAY
255mng_retcode mng_drop_savedata (mng_datap pData)
256{
257#ifdef MNG_SUPPORT_TRACE
258 MNG_TRACE (pData, MNG_FN_DROP_SAVEDATA, MNG_LC_START)
259#endif
260
261 if (pData->pSavedata) /* sanity check */
262 { /* address it more directly */
263 mng_savedatap pSave = pData->pSavedata;
264
265 if (pSave->iGlobalProfilesize) /* cleanup the profile ? */
266 MNG_FREEX (pData, pSave->pGlobalProfile, pSave->iGlobalProfilesize)
267 /* cleanup the save structure */
268 MNG_FREE (pData, pData->pSavedata, sizeof (mng_savedata))
269 }
270
271#ifdef MNG_SUPPORT_TRACE
272 MNG_TRACE (pData, MNG_FN_DROP_SAVEDATA, MNG_LC_END)
273#endif
274
275 return MNG_NOERROR;
276}
277#endif /* MNG_SUPPORT_DISPLAY */
278
279/* ************************************************************************** */
280
281#ifdef MNG_SUPPORT_DISPLAY
282mng_retcode mng_reset_rundata (mng_datap pData)
283{
284 drop_invalid_objects (pData); /* drop invalidly stored objects */
285 mng_drop_savedata (pData); /* drop stored savedata */
286 mng_reset_objzero (pData); /* reset object 0 */
287 /* drop stored objects (if any) */
288 mng_drop_objects (pData, MNG_FALSE);
289
290 pData->bFramedone = MNG_FALSE;
291 pData->iFrameseq = 0; /* reset counters & stuff */
292 pData->iLayerseq = 0;
293 pData->iFrametime = 0;
294 pData->iRequestframe = 0;
295 pData->iRequestlayer = 0;
296 pData->iRequesttime = 0;
297 pData->bSearching = MNG_FALSE;
298
299 pData->iRuntime = 0;
300 pData->iSynctime = 0;
301 pData->iStarttime = 0;
302 pData->iEndtime = 0;
303 pData->bRunning = MNG_FALSE;
304 pData->bTimerset = MNG_FALSE;
305 pData->iBreakpoint = 0;
306 pData->bSectionwait = MNG_FALSE;
307 pData->bFreezing = MNG_FALSE;
308 pData->bResetting = MNG_FALSE;
309 pData->bNeedrefresh = MNG_FALSE;
310
311 pData->iIterations = 0;
312 /* start of animation objects! */
313 pData->pCurraniobj = MNG_NULL;
314
315 pData->iUpdateleft = 0; /* reset region */
316 pData->iUpdateright = 0;
317 pData->iUpdatetop = 0;
318 pData->iUpdatebottom = 0;
319 pData->iPLTEcount = 0; /* reset PLTE data */
320
321 pData->iDEFIobjectid = 0; /* reset DEFI data */
322 pData->bDEFIhasdonotshow = MNG_FALSE;
323 pData->iDEFIdonotshow = 0;
324 pData->bDEFIhasconcrete = MNG_FALSE;
325 pData->iDEFIconcrete = 0;
326 pData->bDEFIhasloca = MNG_FALSE;
327 pData->iDEFIlocax = 0;
328 pData->iDEFIlocay = 0;
329 pData->bDEFIhasclip = MNG_FALSE;
330 pData->iDEFIclipl = 0;
331 pData->iDEFIclipr = 0;
332 pData->iDEFIclipt = 0;
333 pData->iDEFIclipb = 0;
334
335 pData->iBACKred = 0; /* reset BACK data */
336 pData->iBACKgreen = 0;
337 pData->iBACKblue = 0;
338 pData->iBACKmandatory = 0;
339 pData->iBACKimageid = 0;
340 pData->iBACKtile = 0;
341
342 pData->iFRAMmode = 1; /* default global FRAM variables */
343 pData->iFRAMdelay = 1;
344 pData->iFRAMtimeout = 0x7fffffffl;
345 pData->bFRAMclipping = MNG_FALSE;
346 pData->iFRAMclipl = 0;
347 pData->iFRAMclipr = 0;
348 pData->iFRAMclipt = 0;
349 pData->iFRAMclipb = 0;
350
351 pData->iFramemode = 1; /* again for the current frame */
352 pData->iFramedelay = 1;
353 pData->iFrametimeout = 0x7fffffffl;
354 pData->bFrameclipping = MNG_FALSE;
355 pData->iFrameclipl = 0;
356 pData->iFrameclipr = 0;
357 pData->iFrameclipt = 0;
358 pData->iFrameclipb = 0;
359
360 pData->iNextdelay = 1;
361
362 pData->iSHOWmode = 0; /* reset SHOW data */
363 pData->iSHOWfromid = 0;
364 pData->iSHOWtoid = 0;
365 pData->iSHOWnextid = 0;
366 pData->iSHOWskip = 0;
367
368 pData->iGlobalPLTEcount = 0; /* reset global PLTE data */
369
370 pData->iGlobalTRNSrawlen = 0; /* reset global tRNS data */
371
372 pData->iGlobalGamma = 0; /* reset global gAMA data */
373
374 pData->iGlobalWhitepointx = 0; /* reset global cHRM data */
375 pData->iGlobalWhitepointy = 0;
376 pData->iGlobalPrimaryredx = 0;
377 pData->iGlobalPrimaryredy = 0;
378 pData->iGlobalPrimarygreenx = 0;
379 pData->iGlobalPrimarygreeny = 0;
380 pData->iGlobalPrimarybluex = 0;
381 pData->iGlobalPrimarybluey = 0;
382
383 pData->iGlobalRendintent = 0; /* reset global sRGB data */
384
385 if (pData->iGlobalProfilesize) /* drop global profile (if any) */
386 MNG_FREE (pData, pData->pGlobalProfile, pData->iGlobalProfilesize)
387
388 pData->iGlobalProfilesize = 0;
389
390 pData->iGlobalBKGDred = 0; /* reset global bKGD data */
391 pData->iGlobalBKGDgreen = 0;
392 pData->iGlobalBKGDblue = 0;
393 /* reset delta-image */
394 pData->pDeltaImage = MNG_NULL;
395 pData->iDeltaImagetype = 0;
396 pData->iDeltatype = 0;
397 pData->iDeltaBlockwidth = 0;
398 pData->iDeltaBlockheight = 0;
399 pData->iDeltaBlockx = 0;
400 pData->iDeltaBlocky = 0;
401 pData->bDeltaimmediate = MNG_FALSE;
402
403 return MNG_NOERROR;
404}
405#endif /* MNG_SUPPORT_DISPLAY */
406
407/* ************************************************************************** */
408
409void cleanup_errors (mng_datap pData)
410{
411 pData->iErrorcode = MNG_NOERROR;
412 pData->iSeverity = 0;
413 pData->iErrorx1 = 0;
414 pData->iErrorx2 = 0;
415 pData->zErrortext = MNG_NULL;
416
417 return;
418}
419
420/* ************************************************************************** */
421/* * * */
422/* * Versioning control * */
423/* * * */
424/* ************************************************************************** */
425
426mng_pchar MNG_DECL mng_version_text (void)
427{
428 return MNG_VERSION_TEXT;
429}
430
431/* ************************************************************************** */
432
433mng_uint8 MNG_DECL mng_version_so (void)
434{
435 return MNG_VERSION_SO;
436}
437
438/* ************************************************************************** */
439
440mng_uint8 MNG_DECL mng_version_dll (void)
441{
442 return MNG_VERSION_DLL;
443}
444
445/* ************************************************************************** */
446
447mng_uint8 MNG_DECL mng_version_major (void)
448{
449 return MNG_VERSION_MAJOR;
450}
451
452/* ************************************************************************** */
453
454mng_uint8 MNG_DECL mng_version_minor (void)
455{
456 return MNG_VERSION_MINOR;
457}
458
459/* ************************************************************************** */
460
461mng_uint8 MNG_DECL mng_version_release (void)
462{
463 return MNG_VERSION_RELEASE;
464}
465
466/* ************************************************************************** */
467/* * * */
468/* * HLAPI routines * */
469/* * * */
470/* ************************************************************************** */
471
472mng_handle MNG_DECL mng_initialize (mng_ptr pUserdata,
473 mng_memalloc fMemalloc,
474 mng_memfree fMemfree,
475 mng_traceproc fTraceproc)
476{
477 mng_datap pData;
478#ifdef MNG_SUPPORT_DISPLAY
479 mng_retcode iRetcode;
480 mng_imagep pImage;
481#endif
482
483#ifdef MNG_INTERNAL_MEMMNGMT /* allocate the main datastruc */
484 pData = (mng_datap)calloc (1, sizeof (mng_data));
485#else
486 pData = (mng_datap)fMemalloc (sizeof (mng_data));
487#endif
488
489 if (!pData)
490 return MNG_NULL; /* error: out of memory?? */
491 /* validate the structure */
492 pData->iMagic = MNG_MAGIC;
493 /* save userdata field */
494 pData->pUserdata = pUserdata;
495 /* remember trace callback */
496 pData->fTraceproc = fTraceproc;
497
498#ifdef MNG_SUPPORT_TRACE
499 if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_INITIALIZE))
500 {
501 MNG_FREEX (pData, pData, sizeof (mng_data))
502 return MNG_NULL;
503 }
504#endif
505 /* default canvas styles are 8-bit RGB */
506 pData->iCanvasstyle = MNG_CANVAS_RGB8;
507 pData->iBkgdstyle = MNG_CANVAS_RGB8;
508
509 pData->iBGred = 0; /* black */
510 pData->iBGgreen = 0;
511 pData->iBGblue = 0;
512
513 pData->bUseBKGD = MNG_TRUE;
514
515#ifdef MNG_FULL_CMS
516 pData->bIssRGB = MNG_TRUE;
517 pData->hProf1 = 0; /* no profiles yet */
518 pData->hProf2 = 0;
519 pData->hProf3 = 0;
520 pData->hTrans = 0;
521#endif
522
523 pData->dViewgamma = 1.0;
524 pData->dDisplaygamma = 2.2;
525 pData->dDfltimggamma = 0.45455;
526 /* initially remember chunks */
527 pData->bStorechunks = MNG_TRUE;
528 /* no breaks at section-borders */
529 pData->bSectionbreaks = MNG_FALSE;
530 /* initially cache playback info */
531 pData->bCacheplayback = MNG_TRUE;
532 /* progressive refresh for large images */
533 pData->bDoProgressive = MNG_TRUE;
534 /* normal animation-speed ! */
535 pData->iSpeed = mng_st_normal;
536 /* initial image limits */
537 pData->iMaxwidth = 10000;
538 pData->iMaxheight = 10000;
539
540#ifdef MNG_INTERNAL_MEMMNGMT /* internal management */
541 pData->fMemalloc = MNG_NULL;
542 pData->fMemfree = MNG_NULL;
543#else /* keep callbacks */
544 pData->fMemalloc = fMemalloc;
545 pData->fMemfree = fMemfree;
546#endif
547 /* no value (yet) */
548 pData->fOpenstream = MNG_NULL;
549 pData->fClosestream = MNG_NULL;
550 pData->fReaddata = MNG_NULL;
551 pData->fWritedata = MNG_NULL;
552 pData->fErrorproc = MNG_NULL;
553 pData->fProcessheader = MNG_NULL;
554 pData->fProcesstext = MNG_NULL;
555 pData->fProcesssave = MNG_NULL;
556 pData->fProcessseek = MNG_NULL;
557 pData->fProcessneed = MNG_NULL;
558 pData->fProcessmend = MNG_NULL;
559 pData->fProcessunknown = MNG_NULL;
560 pData->fProcessterm = MNG_NULL;
561 pData->fGetcanvasline = MNG_NULL;
562 pData->fGetbkgdline = MNG_NULL;
563 pData->fGetalphaline = MNG_NULL;
564 pData->fRefresh = MNG_NULL;
565 pData->fGettickcount = MNG_NULL;
566 pData->fSettimer = MNG_NULL;
567 pData->fProcessgamma = MNG_NULL;
568 pData->fProcesschroma = MNG_NULL;
569 pData->fProcesssrgb = MNG_NULL;
570 pData->fProcessiccp = MNG_NULL;
571 pData->fProcessarow = MNG_NULL;
572
573#if defined(MNG_SUPPORT_DISPLAY) && (defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS))
574 pData->dLastgamma = 0; /* lookup table needs first-time calc */
575#endif
576
577#ifdef MNG_SUPPORT_DISPLAY /* create object 0 */
578 iRetcode = create_imageobject (pData, 0, MNG_TRUE, MNG_TRUE, MNG_TRUE,
579 0, 0, 0, 0, 0, 0, 0, 0, 0, MNG_FALSE,
580 0, 0, 0, 0, &pImage);
581
582 if (iRetcode) /* on error drop out */
583 {
584 MNG_FREEX (pData, pData, sizeof (mng_data))
585 return MNG_NULL;
586 }
587
588 pData->pObjzero = pImage;
589#endif
590
591#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_INCLUDE_LCMS)
592 mnglcms_initlibrary (); /* init lcms particulairs */
593#endif
594
595#ifdef MNG_SUPPORT_READ
596 pData->bSuspensionmode = MNG_FALSE;
597 pData->iSuspendbufsize = 0;
598 pData->pSuspendbuf = MNG_NULL;
599 pData->pSuspendbufnext = MNG_NULL;
600 pData->iSuspendbufleft = 0;
601 pData->iChunklen = 0;
602 pData->pReadbufnext = MNG_NULL;
603#endif
604
605#ifdef MNG_INCLUDE_ZLIB
606 mngzlib_initialize (pData); /* initialize zlib structures and such */
607 /* default zlib compression parameters */
608 pData->iZlevel = MNG_ZLIB_LEVEL;
609 pData->iZmethod = MNG_ZLIB_METHOD;
610 pData->iZwindowbits = MNG_ZLIB_WINDOWBITS;
611 pData->iZmemlevel = MNG_ZLIB_MEMLEVEL;
612 pData->iZstrategy = MNG_ZLIB_STRATEGY;
613 /* default maximum IDAT data size */
614 pData->iMaxIDAT = MNG_MAX_IDAT_SIZE;
615#endif
616
617#ifdef MNG_INCLUDE_JNG /* default IJG compression parameters */
618 pData->eJPEGdctmethod = MNG_JPEG_DCT;
619 pData->iJPEGquality = MNG_JPEG_QUALITY;
620 pData->iJPEGsmoothing = MNG_JPEG_SMOOTHING;
621 pData->bJPEGcompressprogr = MNG_JPEG_PROGRESSIVE;
622 pData->bJPEGcompressopt = MNG_JPEG_OPTIMIZED;
623 /* default maximum JDAT data size */
624 pData->iMaxJDAT = MNG_MAX_JDAT_SIZE;
625#endif
626
627 mng_reset ((mng_handle)pData);
628
629#ifdef MNG_SUPPORT_TRACE
630 if (mng_trace (pData, MNG_FN_INITIALIZE, MNG_LC_END))
631 {
632 MNG_FREEX (pData, pData, sizeof (mng_data))
633 return MNG_NULL;
634 }
635#endif
636
637 return (mng_handle)pData; /* if we get here, we're in business */
638}
639
640/* ************************************************************************** */
641
642mng_retcode MNG_DECL mng_reset (mng_handle hHandle)
643{
644 mng_datap pData;
645
646#ifdef MNG_SUPPORT_TRACE
647 MNG_TRACE (((mng_datap)hHandle), MNG_FN_RESET, MNG_LC_START)
648#endif
649
650 MNG_VALIDHANDLE (hHandle) /* check validity handle */
651 pData = ((mng_datap)(hHandle)); /* address main structure */
652
653#ifdef MNG_SUPPORT_DISPLAY
654 mng_drop_savedata (pData); /* cleanup saved-data from SAVE/SEEK */
655#endif
656
657#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_FULL_CMS)
658 mng_clear_cms (pData); /* cleanup left-over cms stuff if any */
659#endif
660
661#ifdef MNG_INCLUDE_JNG
662 mngjpeg_cleanup (pData); /* cleanup jpeg stuff */
663#endif
664
665#ifdef MNG_INCLUDE_ZLIB
666 if (pData->bInflating) /* if we've been inflating */
667 {
668#ifdef MNG_INCLUDE_DISPLAY_PROCS
669 cleanup_rowproc (pData); /* cleanup row-processing, */
670#endif
671 mngzlib_inflatefree (pData); /* cleanup inflate! */
672 }
673#endif /* MNG_INCLUDE_ZLIB */
674
675#ifdef MNG_SUPPORT_READ
676 if ((pData->bReading) && (!pData->bEOF))
677 process_eof (pData); /* cleanup app streaming */
678 /* cleanup default read buffers */
679 MNG_FREE (pData, pData->pReadbuf, pData->iReadbufsize)
680 MNG_FREE (pData, pData->pLargebuf, pData->iLargebufsize)
681 MNG_FREE (pData, pData->pSuspendbuf, pData->iSuspendbufsize)
682#endif
683
684#ifdef MNG_SUPPORT_WRITE /* cleanup default write buffer */
685 MNG_FREE (pData, pData->pWritebuf, pData->iWritebufsize)
686#endif
687
688#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
689 mng_drop_chunks (pData); /* drop stored chunks (if any) */
690#endif
691
692#ifdef MNG_SUPPORT_DISPLAY
693 mng_drop_objects (pData, MNG_TRUE); /* drop stored objects (if any) */
694
695 if (pData->iGlobalProfilesize) /* drop global profile (if any) */
696 MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize)
697#endif
698
699 pData->eSigtype = mng_it_unknown;
700 pData->eImagetype = mng_it_unknown;
701 pData->iWidth = 0; /* these are unknown yet */
702 pData->iHeight = 0;
703 pData->iTicks = 0;
704 pData->iLayercount = 0;
705 pData->iFramecount = 0;
706 pData->iPlaytime = 0;
707 pData->iSimplicity = 0;
708 pData->iAlphadepth = 16; /* assume the worst! */
709
710 pData->iImagelevel = 0; /* no image encountered */
711
712 pData->iMagnify = 0; /* 1-to-1 display */
713 pData->iOffsetx = 0; /* no offsets */
714 pData->iOffsety = 0;
715 pData->iCanvaswidth = 0; /* let the app decide during processheader */
716 pData->iCanvasheight = 0;
717 /* so far, so good */
718 pData->iErrorcode = MNG_NOERROR;
719 pData->iSeverity = 0;
720 pData->iErrorx1 = 0;
721 pData->iErrorx2 = 0;
722 pData->zErrortext = MNG_NULL;
723
724#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
725 /* let's assume the best scenario */
726 pData->bPreDraft48 = MNG_FALSE;
727 /* the unknown chunk */
728 pData->iChunkname = MNG_UINT_HUH;
729 pData->iChunkseq = 0;
730 pData->pFirstchunk = MNG_NULL;
731 pData->pLastchunk = MNG_NULL;
732 /* nothing processed yet */
733 pData->bHasheader = MNG_FALSE;
734 pData->bHasMHDR = MNG_FALSE;
735 pData->bHasIHDR = MNG_FALSE;
736 pData->bHasBASI = MNG_FALSE;
737 pData->bHasDHDR = MNG_FALSE;
738#ifdef MNG_INCLUDE_JNG
739 pData->bHasJHDR = MNG_FALSE;
740 pData->bHasJSEP = MNG_FALSE;
741 pData->bHasJDAA = MNG_FALSE;
742 pData->bHasJDAT = MNG_FALSE;
743#endif
744 pData->bHasPLTE = MNG_FALSE;
745 pData->bHasTRNS = MNG_FALSE;
746 pData->bHasGAMA = MNG_FALSE;
747 pData->bHasCHRM = MNG_FALSE;
748 pData->bHasSRGB = MNG_FALSE;
749 pData->bHasICCP = MNG_FALSE;
750 pData->bHasBKGD = MNG_FALSE;
751 pData->bHasIDAT = MNG_FALSE;
752
753 pData->bHasSAVE = MNG_FALSE;
754 pData->bHasBACK = MNG_FALSE;
755 pData->bHasFRAM = MNG_FALSE;
756 pData->bHasTERM = MNG_FALSE;
757 pData->bHasLOOP = MNG_FALSE;
758 /* there's no global stuff yet either */
759 pData->bHasglobalPLTE = MNG_FALSE;
760 pData->bHasglobalTRNS = MNG_FALSE;
761 pData->bHasglobalGAMA = MNG_FALSE;
762 pData->bHasglobalCHRM = MNG_FALSE;
763 pData->bHasglobalSRGB = MNG_FALSE;
764 pData->bHasglobalICCP = MNG_FALSE;
765
766 pData->iDatawidth = 0; /* no IHDR/BASI/DHDR done yet */
767 pData->iDataheight = 0;
768 pData->iBitdepth = 0;
769 pData->iColortype = 0;
770 pData->iCompression = 0;
771 pData->iFilter = 0;
772 pData->iInterlace = 0;
773
774#ifdef MNG_INCLUDE_JNG
775 pData->iJHDRcolortype = 0; /* no JHDR data */
776 pData->iJHDRimgbitdepth = 0;
777 pData->iJHDRimgcompression = 0;
778 pData->iJHDRimginterlace = 0;
779 pData->iJHDRalphabitdepth = 0;
780 pData->iJHDRalphacompression = 0;
781 pData->iJHDRalphafilter = 0;
782 pData->iJHDRalphainterlace = 0;
783#endif
784
785#endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
786
787#ifdef MNG_SUPPORT_READ /* no reading done */
788 pData->bReading = MNG_FALSE;
789 pData->bHavesig = MNG_FALSE;
790 pData->bEOF = MNG_FALSE;
791 pData->iReadbufsize = 0;
792 pData->pReadbuf = MNG_NULL;
793
794 pData->iLargebufsize = 0;
795 pData->pLargebuf = MNG_NULL;
796
797 pData->iSuspendtime = 0;
798 pData->bSuspended = MNG_FALSE;
799 pData->iSuspendpoint = 0;
800
801 pData->pSuspendbufnext = pData->pSuspendbuf;
802 pData->iSuspendbufleft = 0;
803#endif /* MNG_SUPPORT_READ */
804
805#ifdef MNG_SUPPORT_WRITE /* no creating/writing done */
806 pData->bCreating = MNG_FALSE;
807 pData->bWriting = MNG_FALSE;
808 pData->iFirstchunkadded = 0;
809 pData->iWritebufsize = 0;
810 pData->pWritebuf = MNG_NULL;
811#endif /* MNG_SUPPORT_WRITE */
812
813#ifdef MNG_SUPPORT_DISPLAY /* done nuttin' yet */
814 pData->bDisplaying = MNG_FALSE;
815 pData->iFrameseq = 0;
816 pData->iLayerseq = 0;
817 pData->iFrametime = 0;
818
819 pData->iRequestframe = 0;
820 pData->iRequestlayer = 0;
821 pData->iRequesttime = 0;
822 pData->bSearching = MNG_FALSE;
823
824 pData->bRestorebkgd = MNG_FALSE;
825
826 pData->iRuntime = 0;
827 pData->iSynctime = 0;
828 pData->iStarttime = 0;
829 pData->iEndtime = 0;
830 pData->bRunning = MNG_FALSE;
831 pData->bTimerset = MNG_FALSE;
832 pData->iBreakpoint = 0;
833 pData->bSectionwait = MNG_FALSE;
834 pData->bFreezing = MNG_FALSE;
835 pData->bResetting = MNG_FALSE;
836 pData->bNeedrefresh = MNG_FALSE;
837 /* these don't exist yet */
838 pData->pCurrentobj = MNG_NULL;
839 pData->pCurraniobj = MNG_NULL;
840 pData->pTermaniobj = MNG_NULL;
841 pData->pLastclone = MNG_NULL;
842 pData->pStoreobj = MNG_NULL;
843 pData->pStorebuf = MNG_NULL;
844 pData->pRetrieveobj = MNG_NULL;
845 /* no saved data ! */
846 pData->pSavedata = MNG_NULL;
847 /* TODO: remove in 1.0.0 !!! */
848 pData->bEMNGMAhack = MNG_FALSE;
849
850 pData->iUpdateleft = 0; /* no region updated yet */
851 pData->iUpdateright = 0;
852 pData->iUpdatetop = 0;
853 pData->iUpdatebottom = 0;
854
855 pData->iPass = -1; /* interlacing stuff and temp buffers */
856 pData->iRow = 0;
857 pData->iRowinc = 1;
858 pData->iCol = 0;
859 pData->iColinc = 1;
860 pData->iRowsamples = 0;
861 pData->iSamplemul = 0;
862 pData->iSampleofs = 0;
863 pData->iSamplediv = 0;
864 pData->iRowsize = 0;
865 pData->iRowmax = 0;
866 pData->iFilterofs = 0;
867 pData->iPixelofs = 1;
868 pData->iLevel0 = 0;
869 pData->iLevel1 = 0;
870 pData->iLevel2 = 0;
871 pData->iLevel3 = 0;
872 pData->pWorkrow = MNG_NULL;
873 pData->pPrevrow = MNG_NULL;
874 pData->pRGBArow = 0;
875 pData->bIsRGBA16 = MNG_TRUE;
876 pData->bIsOpaque = MNG_TRUE;
877 pData->iFilterbpp = 1;
878
879 pData->iSourcel = 0; /* always initialized just before */
880 pData->iSourcer = 0; /* compositing the next layer */
881 pData->iSourcet = 0;
882 pData->iSourceb = 0;
883 pData->iDestl = 0;
884 pData->iDestr = 0;
885 pData->iDestt = 0;
886 pData->iDestb = 0;
887 /* lists are empty */
888 pData->pFirstimgobj = MNG_NULL;
889 pData->pLastimgobj = MNG_NULL;
890 pData->pFirstaniobj = MNG_NULL;
891 pData->pLastaniobj = MNG_NULL;
892 /* no processing callbacks */
893 pData->fDisplayrow = MNG_NULL;
894 pData->fRestbkgdrow = MNG_NULL;
895 pData->fCorrectrow = MNG_NULL;
896 pData->fRetrieverow = MNG_NULL;
897 pData->fStorerow = MNG_NULL;
898 pData->fProcessrow = MNG_NULL;
899 pData->fDifferrow = MNG_NULL;
900 pData->fInitrowproc = MNG_NULL;
901
902 pData->iPLTEcount = 0; /* no PLTE data */
903
904 pData->iDEFIobjectid = 0; /* no DEFI data */
905 pData->bDEFIhasdonotshow = MNG_FALSE;
906 pData->iDEFIdonotshow = 0;
907 pData->bDEFIhasconcrete = MNG_FALSE;
908 pData->iDEFIconcrete = 0;
909 pData->bDEFIhasloca = MNG_FALSE;
910 pData->iDEFIlocax = 0;
911 pData->iDEFIlocay = 0;
912 pData->bDEFIhasclip = MNG_FALSE;
913 pData->iDEFIclipl = 0;
914 pData->iDEFIclipr = 0;
915 pData->iDEFIclipt = 0;
916 pData->iDEFIclipb = 0;
917
918 pData->iBACKred = 0; /* no BACK data */
919 pData->iBACKgreen = 0;
920 pData->iBACKblue = 0;
921 pData->iBACKmandatory = 0;
922 pData->iBACKimageid = 0;
923 pData->iBACKtile = 0;
924
925 pData->iFRAMmode = 1; /* default global FRAM variables */
926 pData->iFRAMdelay = 1;
927 pData->iFRAMtimeout = 0x7fffffffl;
928 pData->bFRAMclipping = MNG_FALSE;
929 pData->iFRAMclipl = 0;
930 pData->iFRAMclipr = 0;
931 pData->iFRAMclipt = 0;
932 pData->iFRAMclipb = 0;
933
934 pData->iFramemode = 1; /* again for the current frame */
935 pData->iFramedelay = 1;
936 pData->iFrametimeout = 0x7fffffffl;
937 pData->bFrameclipping = MNG_FALSE;
938 pData->iFrameclipl = 0;
939 pData->iFrameclipr = 0;
940 pData->iFrameclipt = 0;
941 pData->iFrameclipb = 0;
942
943 pData->iNextdelay = 1;
944
945 pData->iSHOWmode = 0; /* no SHOW data */
946 pData->iSHOWfromid = 0;
947 pData->iSHOWtoid = 0;
948 pData->iSHOWnextid = 0;
949 pData->iSHOWskip = 0;
950
951 pData->iGlobalPLTEcount = 0; /* no global PLTE data */
952
953 pData->iGlobalTRNSrawlen = 0; /* no global tRNS data */
954
955 pData->iGlobalGamma = 0; /* no global gAMA data */
956
957 pData->iGlobalWhitepointx = 0; /* no global cHRM data */
958 pData->iGlobalWhitepointy = 0;
959 pData->iGlobalPrimaryredx = 0;
960 pData->iGlobalPrimaryredy = 0;
961 pData->iGlobalPrimarygreenx = 0;
962 pData->iGlobalPrimarygreeny = 0;
963 pData->iGlobalPrimarybluex = 0;
964 pData->iGlobalPrimarybluey = 0;
965
966 pData->iGlobalRendintent = 0; /* no global sRGB data */
967
968 pData->iGlobalProfilesize = 0; /* no global iCCP data */
969 pData->pGlobalProfile = MNG_NULL;
970
971 pData->iGlobalBKGDred = 0; /* no global bKGD data */
972 pData->iGlobalBKGDgreen = 0;
973 pData->iGlobalBKGDblue = 0;
974 /* no delta-image */
975 pData->pDeltaImage = MNG_NULL;
976 pData->iDeltaImagetype = 0;
977 pData->iDeltatype = 0;
978 pData->iDeltaBlockwidth = 0;
979 pData->iDeltaBlockheight = 0;
980 pData->iDeltaBlockx = 0;
981 pData->iDeltaBlocky = 0;
982 pData->bDeltaimmediate = MNG_FALSE;
983#endif
984
985#ifdef MNG_INCLUDE_ZLIB
986 pData->bInflating = 0; /* no inflating or deflating */
987 pData->bDeflating = 0; /* going on at the moment */
988#endif
989
990#ifdef MNG_SUPPORT_DISPLAY /* reset object 0 */
991 mng_reset_objzero (pData);
992#endif
993
994#ifdef MNG_SUPPORT_TRACE
995 MNG_TRACE (((mng_datap)hHandle), MNG_FN_RESET, MNG_LC_END)
996#endif
997
998 return MNG_NOERROR;
999}
1000
1001/* ************************************************************************** */
1002
1003mng_retcode MNG_DECL mng_cleanup (mng_handle* hHandle)
1004{
1005 mng_datap pData; /* local vars */
1006#ifndef MNG_INTERNAL_MEMMNGMT
1007 mng_memfree fFree;
1008#endif
1009
1010#ifdef MNG_SUPPORT_TRACE
1011 MNG_TRACE (((mng_datap)*hHandle), MNG_FN_CLEANUP, MNG_LC_START)
1012#endif
1013
1014 MNG_VALIDHANDLE (*hHandle) /* check validity handle */
1015 pData = ((mng_datap)(*hHandle)); /* and address main structure */
1016
1017 mng_reset (*hHandle); /* do an implicit reset to cleanup most stuff */
1018
1019#ifdef MNG_SUPPORT_DISPLAY /* drop object 0 */
1020 free_imageobject (pData, (mng_imagep)pData->pObjzero);
1021#endif
1022
1023#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_INCLUDE_LCMS)
1024 if (pData->hProf2) /* output profile defined ? */
1025 mnglcms_freeprofile (pData->hProf2);
1026
1027 if (pData->hProf3) /* sRGB profile defined ? */
1028 mnglcms_freeprofile (pData->hProf3);
1029#endif /* MNG_SUPPORT_DISPLAY && MNG_INCLUDE_LCMS */
1030
1031#ifdef MNG_INCLUDE_ZLIB
1032 mngzlib_cleanup (pData); /* cleanup zlib stuff */
1033#endif
1034
1035#ifdef MNG_SUPPORT_TRACE
1036 MNG_TRACE (((mng_datap)*hHandle), MNG_FN_CLEANUP, MNG_LC_CLEANUP)
1037#endif
1038
1039 pData->iMagic = 0; /* invalidate the actual memory */
1040
1041#ifdef MNG_INTERNAL_MEMMNGMT
1042 free ((void *)*hHandle); /* cleanup the data-structure */
1043#else
1044 fFree = ((mng_datap)*hHandle)->fMemfree;
1045 fFree ((mng_ptr)*hHandle, sizeof (mng_data));
1046#endif
1047
1048 *hHandle = 0; /* wipe pointer to inhibit future use */
1049
1050 return MNG_NOERROR; /* and we're done */
1051}
1052
1053/* ************************************************************************** */
1054
1055#ifdef MNG_SUPPORT_READ
1056mng_retcode MNG_DECL mng_read (mng_handle hHandle)
1057{
1058 mng_datap pData; /* local vars */
1059 mng_retcode iRetcode;
1060
1061#ifdef MNG_SUPPORT_TRACE
1062 MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ, MNG_LC_START)
1063#endif
1064
1065 MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */
1066 pData = ((mng_datap)hHandle); /* and make it addressable */
1067
1068#ifndef MNG_INTERNAL_MEMMNGMT
1069 MNG_VALIDCB (hHandle, fMemalloc)
1070 MNG_VALIDCB (hHandle, fMemfree)
1071#endif
1072
1073 MNG_VALIDCB (hHandle, fOpenstream)
1074 MNG_VALIDCB (hHandle, fClosestream)
1075 MNG_VALIDCB (hHandle, fReaddata)
1076
1077#ifdef MNG_SUPPORT_DISPLAY /* valid at this point ? */
1078 if ((pData->bReading) || (pData->bDisplaying))
1079#else
1080 if (pData->bReading)
1081#endif
1082 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1083
1084#ifdef MNG_SUPPORT_WRITE
1085 if ((pData->bWriting) || (pData->bCreating))
1086 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1087#endif
1088
1089 if (!pData->bCacheplayback) /* must store playback info to work!! */
1090 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1091
1092 cleanup_errors (pData); /* cleanup previous errors */
1093
1094 pData->bReading = MNG_TRUE; /* read only! */
1095
1096 if (!pData->fOpenstream (hHandle)) /* open it and start reading */
1097 iRetcode = MNG_APPIOERROR;
1098 else
1099 iRetcode = read_graphic (pData);
1100
1101 if (pData->bEOF) /* already at EOF ? */
1102 {
1103 pData->bReading = MNG_FALSE; /* then we're no longer reading */
1104
1105#ifdef MNG_SUPPORT_DISPLAY
1106 mng_reset_rundata (pData); /* reset rundata */
1107#endif
1108 }
1109
1110 if (iRetcode) /* on error bail out */
1111 return iRetcode;
1112
1113 if (pData->bSuspended) /* read suspension ? */
1114 {
1115 iRetcode = MNG_NEEDMOREDATA;
1116 pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData);
1117 }
1118
1119#ifdef MNG_SUPPORT_TRACE
1120 MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ, MNG_LC_END)
1121#endif
1122
1123 return iRetcode;
1124}
1125#endif /* MNG_SUPPORT_READ */
1126
1127/* ************************************************************************** */
1128
1129#ifdef MNG_SUPPORT_READ
1130mng_retcode MNG_DECL mng_read_resume (mng_handle hHandle)
1131{
1132 mng_datap pData; /* local vars */
1133 mng_retcode iRetcode;
1134
1135#ifdef MNG_SUPPORT_TRACE
1136 MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_RESUME, MNG_LC_START)
1137#endif
1138
1139 MNG_VALIDHANDLE (hHandle) /* check validity handle */
1140 pData = ((mng_datap)hHandle); /* and make it addressable */
1141 /* can we expect this call ? */
1142 if ((!pData->bReading) || (!pData->bSuspended))
1143 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1144
1145 cleanup_errors (pData); /* cleanup previous errors */
1146
1147 pData->bSuspended = MNG_FALSE; /* reset the flag */
1148
1149#ifdef MNG_SUPPORT_DISPLAY /* re-synchronize ? */
1150 if ((pData->bDisplaying) && (pData->bRunning))
1151 pData->iSynctime = pData->iSynctime - pData->iSuspendtime +
1152 pData->fGettickcount (hHandle);
1153#endif
1154
1155 iRetcode = read_graphic (pData); /* continue reading now */
1156
1157 if (pData->bEOF) /* at EOF ? */
1158 {
1159 pData->bReading = MNG_FALSE; /* then we're no longer reading */
1160
1161#ifdef MNG_SUPPORT_DISPLAY
1162 mng_reset_rundata (pData); /* reset rundata */
1163#endif
1164 }
1165
1166 if (iRetcode) /* on error bail out */
1167 return iRetcode;
1168
1169 if (pData->bSuspended) /* read suspension ? */
1170 {
1171 iRetcode = MNG_NEEDMOREDATA;
1172 pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData);
1173 }
1174
1175#ifdef MNG_SUPPORT_TRACE
1176 MNG_TRACE (((mng_datap)hHandle), MNG_FN_READ_RESUME, MNG_LC_END)
1177#endif
1178
1179 return iRetcode;
1180}
1181#endif /* MNG_SUPPORT_READ */
1182
1183/* ************************************************************************** */
1184
1185#ifdef MNG_SUPPORT_WRITE
1186mng_retcode MNG_DECL mng_write (mng_handle hHandle)
1187{
1188 mng_datap pData;
1189 mng_retcode iRetcode;
1190
1191#ifdef MNG_SUPPORT_TRACE
1192 MNG_TRACE (((mng_datap)hHandle), MNG_FN_WRITE, MNG_LC_START)
1193#endif
1194
1195 MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */
1196 pData = ((mng_datap)hHandle); /* and make it addressable */
1197
1198#ifndef MNG_INTERNAL_MEMMNGMT
1199 MNG_VALIDCB (hHandle, fMemalloc)
1200 MNG_VALIDCB (hHandle, fMemfree)
1201#endif
1202
1203 MNG_VALIDCB (hHandle, fOpenstream)
1204 MNG_VALIDCB (hHandle, fClosestream)
1205 MNG_VALIDCB (hHandle, fWritedata)
1206
1207#ifdef MNG_SUPPORT_READ
1208 if (pData->bReading) /* valid at this point ? */
1209 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1210#endif
1211
1212 if (pData->bCreating) /* can't write while it's still being made! */
1213 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1214
1215 cleanup_errors (pData); /* cleanup previous errors */
1216
1217 iRetcode = write_graphic (pData); /* do the write */
1218
1219 if (iRetcode) /* on error bail out */
1220 return iRetcode;
1221
1222#ifdef MNG_SUPPORT_TRACE
1223 MNG_TRACE (((mng_datap)hHandle), MNG_FN_WRITE, MNG_LC_END)
1224#endif
1225
1226 return MNG_NOERROR;
1227}
1228#endif /* MNG_SUPPORT_WRITE */
1229
1230/* ************************************************************************** */
1231
1232#ifdef MNG_SUPPORT_WRITE
1233mng_retcode MNG_DECL mng_create (mng_handle hHandle)
1234{
1235 mng_datap pData;
1236 mng_retcode iRetcode;
1237
1238#ifdef MNG_SUPPORT_TRACE
1239 MNG_TRACE (((mng_datap)hHandle), MNG_FN_CREATE, MNG_LC_START)
1240#endif
1241
1242 MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */
1243 pData = ((mng_datap)hHandle); /* and make it addressable */
1244
1245#ifndef MNG_INTERNAL_MEMMNGMT
1246 MNG_VALIDCB (hHandle, fMemalloc)
1247 MNG_VALIDCB (hHandle, fMemfree)
1248#endif
1249
1250#ifdef MNG_SUPPORT_READ
1251 if (pData->bReading) /* valid at this point ? */
1252 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1253#endif
1254
1255 if ((pData->bWriting) || (pData->bCreating))
1256 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1257
1258 cleanup_errors (pData); /* cleanup previous errors */
1259
1260 iRetcode = mng_reset (hHandle); /* clear any previous stuff */
1261
1262 if (iRetcode) /* on error bail out */
1263 return iRetcode;
1264
1265 pData->bCreating = MNG_TRUE; /* indicate we're creating a new file */
1266
1267#ifdef MNG_SUPPORT_TRACE
1268 MNG_TRACE (((mng_datap)hHandle), MNG_FN_CREATE, MNG_LC_END)
1269#endif
1270
1271 return MNG_NOERROR;
1272}
1273#endif /* MNG_SUPPORT_WRITE */
1274
1275/* ************************************************************************** */
1276
1277#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_READ)
1278mng_retcode MNG_DECL mng_readdisplay (mng_handle hHandle)
1279{
1280 mng_datap pData; /* local vars */
1281 mng_retcode iRetcode;
1282
1283#ifdef MNG_SUPPORT_TRACE
1284 MNG_TRACE (((mng_datap)hHandle), MNG_FN_READDISPLAY, MNG_LC_START)
1285#endif
1286
1287 MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */
1288 pData = ((mng_datap)hHandle); /* and make it addressable */
1289
1290#ifndef MNG_INTERNAL_MEMMNGMT
1291 MNG_VALIDCB (hHandle, fMemalloc)
1292 MNG_VALIDCB (hHandle, fMemfree)
1293#endif
1294
1295 MNG_VALIDCB (hHandle, fReaddata)
1296 MNG_VALIDCB (hHandle, fGetcanvasline)
1297 MNG_VALIDCB (hHandle, fRefresh)
1298 MNG_VALIDCB (hHandle, fGettickcount)
1299 MNG_VALIDCB (hHandle, fSettimer)
1300 /* valid at this point ? */
1301 if ((pData->bReading) || (pData->bDisplaying))
1302 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1303
1304#ifdef MNG_SUPPORT_WRITE
1305 if ((pData->bWriting) || (pData->bCreating))
1306 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1307#endif
1308
1309 cleanup_errors (pData); /* cleanup previous errors */
1310
1311 pData->bReading = MNG_TRUE; /* read & display! */
1312 pData->bDisplaying = MNG_TRUE;
1313 pData->bRunning = MNG_TRUE;
1314 pData->iFrameseq = 0;
1315 pData->iLayerseq = 0;
1316 pData->iFrametime = 0;
1317 pData->iRequestframe = 0;
1318 pData->iRequestlayer = 0;
1319 pData->iRequesttime = 0;
1320 pData->bSearching = MNG_FALSE;
1321 pData->iRuntime = 0;
1322 pData->iSynctime = pData->fGettickcount (hHandle);
1323 pData->iSuspendtime = 0;
1324 pData->iStarttime = pData->iSynctime;
1325 pData->iEndtime = 0;
1326
1327 if (!pData->fOpenstream (hHandle)) /* open it and start reading */
1328 iRetcode = MNG_APPIOERROR;
1329 else
1330 iRetcode = read_graphic (pData);
1331
1332 if (pData->bEOF) /* already at EOF ? */
1333 {
1334 pData->bReading = MNG_FALSE; /* then we're no longer reading */
1335 drop_invalid_objects (pData); /* drop invalidly stored objects */
1336 }
1337
1338 if (iRetcode) /* on error bail out */
1339 return iRetcode;
1340
1341 if (pData->bSuspended) /* read suspension ? */
1342 {
1343 iRetcode = MNG_NEEDMOREDATA;
1344 pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData);
1345 }
1346 else
1347 if (pData->bTimerset) /* indicate timer break ? */
1348 iRetcode = MNG_NEEDTIMERWAIT;
1349 else
1350 if (pData->bSectionwait) /* indicate section break ? */
1351 iRetcode = MNG_NEEDSECTIONWAIT;
1352 else
1353 pData->bRunning = MNG_FALSE; /* no breaks = end of run */
1354
1355#ifdef MNG_SUPPORT_TRACE
1356 MNG_TRACE (((mng_datap)hHandle), MNG_FN_READDISPLAY, MNG_LC_END)
1357#endif
1358
1359 return iRetcode;
1360}
1361#endif /* MNG_SUPPORT_DISPLAY && MNG_SUPPORT_READ */
1362
1363/* ************************************************************************** */
1364
1365#ifdef MNG_SUPPORT_DISPLAY
1366mng_retcode MNG_DECL mng_display (mng_handle hHandle)
1367{
1368 mng_datap pData; /* local vars */
1369 mng_retcode iRetcode;
1370
1371#ifdef MNG_SUPPORT_TRACE
1372 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY, MNG_LC_START)
1373#endif
1374
1375 MNG_VALIDHANDLE (hHandle) /* check validity handle and callbacks */
1376 pData = ((mng_datap)hHandle); /* and make it addressable */
1377
1378#ifndef MNG_INTERNAL_MEMMNGMT
1379 MNG_VALIDCB (hHandle, fMemalloc)
1380 MNG_VALIDCB (hHandle, fMemfree)
1381#endif
1382
1383 MNG_VALIDCB (hHandle, fGetcanvasline)
1384 MNG_VALIDCB (hHandle, fRefresh)
1385 MNG_VALIDCB (hHandle, fGettickcount)
1386 MNG_VALIDCB (hHandle, fSettimer)
1387
1388 if (pData->bDisplaying) /* valid at this point ? */
1389 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1390
1391#ifdef MNG_SUPPORT_READ
1392 if (pData->bReading)
1393 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1394#endif
1395
1396#ifdef MNG_SUPPORT_WRITE
1397 if ((pData->bWriting) || (pData->bCreating))
1398 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1399#endif
1400
1401 cleanup_errors (pData); /* cleanup previous errors */
1402
1403 pData->bDisplaying = MNG_TRUE; /* display! */
1404 pData->bRunning = MNG_TRUE;
1405 pData->iFrameseq = 0;
1406 pData->iLayerseq = 0;
1407 pData->iFrametime = 0;
1408 pData->iRequestframe = 0;
1409 pData->iRequestlayer = 0;
1410 pData->iRequesttime = 0;
1411 pData->bSearching = MNG_FALSE;
1412 pData->iRuntime = 0;
1413 pData->iSynctime = pData->fGettickcount (hHandle);
1414#ifdef MNG_SUPPORT_READ
1415 pData->iSuspendtime = 0;
1416#endif
1417 pData->iStarttime = pData->iSynctime;
1418 pData->iEndtime = 0;
1419 pData->pCurraniobj = pData->pFirstaniobj;
1420
1421 iRetcode = process_display (pData); /* go do it */
1422
1423 if (iRetcode) /* on error bail out */
1424 return iRetcode;
1425
1426 if (pData->bTimerset) /* indicate timer break ? */
1427 iRetcode = MNG_NEEDTIMERWAIT;
1428 else
1429 pData->bRunning = MNG_FALSE; /* no breaks = end of run */
1430
1431#ifdef MNG_SUPPORT_TRACE
1432 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY, MNG_LC_END)
1433#endif
1434
1435 return iRetcode;
1436}
1437#endif /* MNG_SUPPORT_DISPLAY */
1438
1439/* ************************************************************************** */
1440
1441#ifdef MNG_SUPPORT_DISPLAY
1442mng_retcode MNG_DECL mng_display_resume (mng_handle hHandle)
1443{
1444 mng_datap pData; /* local vars */
1445 mng_retcode iRetcode;
1446
1447#ifdef MNG_SUPPORT_TRACE
1448 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESUME, MNG_LC_START)
1449#endif
1450
1451 MNG_VALIDHANDLE (hHandle) /* check validity handle */
1452 pData = ((mng_datap)hHandle); /* and make it addressable */
1453
1454 if (!pData->bDisplaying) /* can we expect this call ? */
1455 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1456
1457 cleanup_errors (pData); /* cleanup previous errors */
1458
1459 if (pData->bRunning) /* was it running ? */
1460 { /* are we expecting this call ? */
1461 if ((pData->bTimerset) || (pData->bSuspended) || (pData->bSectionwait))
1462 {
1463 pData->bTimerset = MNG_FALSE; /* reset the flags */
1464 pData->bSectionwait = MNG_FALSE;
1465
1466#ifdef MNG_SUPPORT_READ
1467 if (pData->bReading) /* set during read&display ? */
1468 {
1469 if (pData->bSuspended) /* calculate proper synchronization */
1470 pData->iSynctime = pData->iSynctime - pData->iSuspendtime +
1471 pData->fGettickcount (hHandle);
1472 else
1473 pData->iSynctime = pData->fGettickcount (hHandle);
1474
1475 pData->bSuspended = MNG_FALSE; /* now reset this flag */
1476 /* and continue reading */
1477 iRetcode = read_graphic (pData);
1478
1479 if (pData->bEOF) /* already at EOF ? */
1480 {
1481 pData->bReading = MNG_FALSE; /* then we're no longer reading */
1482 /* drop invalidly stored objects */
1483 drop_invalid_objects (pData);
1484 }
1485 }
1486 else
1487#endif /* MNG_SUPPORT_READ */
1488 { /* synchronize timing */
1489 pData->iSynctime = pData->fGettickcount (hHandle);
1490 /* resume display processing */
1491 iRetcode = process_display (pData);
1492 }
1493 }
1494 else
1495 {
1496 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1497 }
1498 }
1499 else
1500 { /* synchronize timing */
1501 pData->iSynctime = pData->fGettickcount (hHandle);
1502 pData->bRunning = MNG_TRUE; /* it's restarted again ! */
1503 /* resume display processing */
1504 iRetcode = process_display (pData);
1505 }
1506
1507 if (iRetcode) /* on error bail out */
1508 return iRetcode;
1509
1510 if (pData->bSuspended) /* read suspension ? */
1511 {
1512 iRetcode = MNG_NEEDMOREDATA;
1513 pData->iSuspendtime = pData->fGettickcount ((mng_handle)pData);
1514 }
1515 else
1516 if (pData->bTimerset) /* indicate timer break ? */
1517 iRetcode = MNG_NEEDTIMERWAIT;
1518 else
1519 if (pData->bSectionwait) /* indicate section break ? */
1520 iRetcode = MNG_NEEDSECTIONWAIT;
1521 else
1522 { /* no breaks = end of run */
1523 pData->bRunning = MNG_FALSE;
1524
1525 if (pData->bFreezing) /* trying to freeze ? */
1526 { /* then we're there ! */
1527 pData->bFreezing = MNG_FALSE;
1528 }
1529
1530 if (pData->bResetting) /* trying to reset as well ? */
1531 { /* full stop!!! */
1532 pData->bDisplaying = MNG_FALSE;
1533
1534 iRetcode = mng_reset_rundata (pData);
1535
1536 if (iRetcode) /* on error bail out */
1537 return iRetcode;
1538 }
1539 }
1540
1541#ifdef MNG_SUPPORT_TRACE
1542 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESUME, MNG_LC_END)
1543#endif
1544
1545 return iRetcode;
1546}
1547#endif /* MNG_SUPPORT_DISPLAY */
1548
1549/* ************************************************************************** */
1550
1551#ifdef MNG_SUPPORT_DISPLAY
1552mng_retcode MNG_DECL mng_display_freeze (mng_handle hHandle)
1553{
1554 mng_datap pData;
1555
1556#ifdef MNG_SUPPORT_TRACE
1557 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_FREEZE, MNG_LC_START)
1558#endif
1559
1560 MNG_VALIDHANDLE (hHandle) /* check validity handle */
1561 pData = ((mng_datap)hHandle); /* and make it addressable */
1562 /* can we expect this call ? */
1563 if ((!pData->bDisplaying) || (pData->bReading))
1564 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1565
1566 cleanup_errors (pData); /* cleanup previous errors */
1567
1568 if (pData->bRunning) /* is it running ? */
1569 {
1570 mng_retcode iRetcode;
1571
1572 pData->bFreezing = MNG_TRUE; /* indicate we need to freeze */
1573 /* continue "normal" processing */
1574 iRetcode = mng_display_resume (hHandle);
1575
1576 if (iRetcode) /* on error bail out */
1577 return iRetcode;
1578 }
1579
1580#ifdef MNG_SUPPORT_TRACE
1581 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_FREEZE, MNG_LC_END)
1582#endif
1583
1584 return MNG_NOERROR;
1585}
1586#endif /* MNG_SUPPORT_DISPLAY */
1587
1588/* ************************************************************************** */
1589
1590#ifdef MNG_SUPPORT_DISPLAY
1591mng_retcode MNG_DECL mng_display_reset (mng_handle hHandle)
1592{
1593 mng_datap pData;
1594 mng_retcode iRetcode;
1595
1596#ifdef MNG_SUPPORT_TRACE
1597 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESET, MNG_LC_START)
1598#endif
1599
1600 MNG_VALIDHANDLE (hHandle) /* check validity handle */
1601 pData = ((mng_datap)hHandle); /* and make it addressable */
1602 /* can we expect this call ? */
1603 if ((!pData->bDisplaying) || (pData->bReading))
1604 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1605
1606 if (!pData->bCacheplayback) /* must store playback info to work!! */
1607 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1608
1609 cleanup_errors (pData); /* cleanup previous errors */
1610
1611 if (pData->bRunning) /* is it running ? */
1612 {
1613 pData->bFreezing = MNG_TRUE; /* indicate we need to freeze */
1614 pData->bResetting = MNG_TRUE; /* indicate we're about to reset too */
1615 /* continue normal processing ? */
1616 iRetcode = mng_display_resume (hHandle);
1617
1618 if (iRetcode) /* on error bail out */
1619 return iRetcode;
1620 }
1621 else
1622 { /* full stop!!! */
1623 pData->bDisplaying = MNG_FALSE;
1624
1625 iRetcode = mng_reset_rundata (pData);
1626
1627 if (iRetcode) /* on error bail out */
1628 return iRetcode;
1629 }
1630
1631#ifdef MNG_SUPPORT_TRACE
1632 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_RESET, MNG_LC_END)
1633#endif
1634
1635 return MNG_NOERROR;
1636}
1637#endif /* MNG_SUPPORT_DISPLAY */
1638
1639/* ************************************************************************** */
1640
1641#ifdef MNG_SUPPORT_DISPLAY
1642mng_retcode MNG_DECL mng_display_goframe (mng_handle hHandle,
1643 mng_uint32 iFramenr)
1644{
1645 mng_datap pData;
1646 mng_retcode iRetcode;
1647
1648#ifdef MNG_SUPPORT_TRACE
1649 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOFRAME, MNG_LC_START)
1650#endif
1651
1652 MNG_VALIDHANDLE (hHandle) /* check validity handle */
1653 pData = ((mng_datap)hHandle); /* and make it addressable */
1654
1655 if (pData->eImagetype != mng_it_mng) /* is it an animation ? */
1656 MNG_ERROR (pData, MNG_NOTANANIMATION);
1657 /* can we expect this call ? */
1658 if ((!pData->bDisplaying) || (pData->bRunning))
1659 MNG_ERROR ((mng_datap)hHandle, MNG_FUNCTIONINVALID)
1660
1661 if (!pData->bCacheplayback) /* must store playback info to work!! */
1662 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1663
1664 if (iFramenr > pData->iFramecount) /* is the parameter within bounds ? */
1665 MNG_ERROR (pData, MNG_FRAMENRTOOHIGH);
1666
1667 cleanup_errors (pData); /* cleanup previous errors */
1668
1669 pData->iRequestframe = iFramenr; /* go find the requested frame then */
1670 iRetcode = process_display (pData);
1671
1672 if (iRetcode) /* on error bail out */
1673 return iRetcode;
1674
1675#ifdef MNG_SUPPORT_TRACE
1676 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOFRAME, MNG_LC_END)
1677#endif
1678
1679 return MNG_NOERROR;
1680}
1681#endif /* MNG_SUPPORT_DISPLAY */
1682
1683/* ************************************************************************** */
1684
1685#ifdef MNG_SUPPORT_DISPLAY
1686mng_retcode MNG_DECL mng_display_golayer (mng_handle hHandle,
1687 mng_uint32 iLayernr)
1688{
1689 mng_datap pData;
1690 mng_retcode iRetcode;
1691
1692#ifdef MNG_SUPPORT_TRACE
1693 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOLAYER, MNG_LC_START)
1694#endif
1695
1696 MNG_VALIDHANDLE (hHandle) /* check validity handle */
1697 pData = ((mng_datap)hHandle); /* and make it addressable */
1698
1699 if (pData->eImagetype != mng_it_mng) /* is it an animation ? */
1700 MNG_ERROR (pData, MNG_NOTANANIMATION)
1701 /* can we expect this call ? */
1702 if ((!pData->bDisplaying) || (pData->bRunning))
1703 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1704
1705 if (!pData->bCacheplayback) /* must store playback info to work!! */
1706 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1707
1708 if (iLayernr > pData->iLayercount) /* is the parameter within bounds ? */
1709 MNG_ERROR (pData, MNG_LAYERNRTOOHIGH)
1710
1711 cleanup_errors (pData); /* cleanup previous errors */
1712
1713 pData->iRequestlayer = iLayernr; /* go find the requested layer then */
1714 iRetcode = process_display (pData);
1715
1716 if (iRetcode) /* on error bail out */
1717 return iRetcode;
1718
1719#ifdef MNG_SUPPORT_TRACE
1720 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOLAYER, MNG_LC_END)
1721#endif
1722
1723 return MNG_NOERROR;
1724}
1725#endif /* MNG_SUPPORT_DISPLAY */
1726
1727/* ************************************************************************** */
1728
1729#ifdef MNG_SUPPORT_DISPLAY
1730mng_retcode MNG_DECL mng_display_gotime (mng_handle hHandle,
1731 mng_uint32 iPlaytime)
1732{
1733 mng_datap pData;
1734 mng_retcode iRetcode;
1735
1736#ifdef MNG_SUPPORT_TRACE
1737 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOTIME, MNG_LC_START)
1738#endif
1739
1740 MNG_VALIDHANDLE (hHandle) /* check validity handle */
1741 pData = ((mng_datap)hHandle); /* and make it addressable */
1742
1743 if (pData->eImagetype != mng_it_mng) /* is it an animation ? */
1744 MNG_ERROR (pData, MNG_NOTANANIMATION)
1745 /* can we expect this call ? */
1746 if ((!pData->bDisplaying) || (pData->bRunning))
1747 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1748
1749 if (!pData->bCacheplayback) /* must store playback info to work!! */
1750 MNG_ERROR (pData, MNG_FUNCTIONINVALID)
1751
1752 if (iPlaytime > pData->iPlaytime) /* is the parameter within bounds ? */
1753 MNG_ERROR (pData, MNG_PLAYTIMETOOHIGH)
1754
1755 cleanup_errors (pData); /* cleanup previous errors */
1756
1757 pData->iRequesttime = iPlaytime; /* go find the requested playtime then */
1758 iRetcode = process_display (pData);
1759
1760 if (iRetcode) /* on error bail out */
1761 return iRetcode;
1762
1763#ifdef MNG_SUPPORT_TRACE
1764 MNG_TRACE (((mng_datap)hHandle), MNG_FN_DISPLAY_GOTIME, MNG_LC_END)
1765#endif
1766
1767 return MNG_NOERROR;
1768}
1769#endif /* MNG_SUPPORT_DISPLAY */
1770
1771/* ************************************************************************** */
1772
1773mng_retcode MNG_DECL mng_getlasterror (mng_handle hHandle,
1774 mng_int8* iSeverity,
1775 mng_chunkid* iChunkname,
1776 mng_uint32* iChunkseq,
1777 mng_int32* iExtra1,
1778 mng_int32* iExtra2,
1779 mng_pchar* zErrortext)
1780{
1781 mng_datap pData; /* local vars */
1782
1783#ifdef MNG_SUPPORT_TRACE
1784 MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETLASTERROR, MNG_LC_START)
1785#endif
1786
1787 MNG_VALIDHANDLE (hHandle) /* check validity handle */
1788 pData = ((mng_datap)hHandle); /* and make it addressable */
1789
1790 *iSeverity = pData->iSeverity; /* return the appropriate fields */
1791
1792#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
1793 *iChunkname = pData->iChunkname;
1794 *iChunkseq = pData->iChunkseq;
1795#else
1796 *iChunkname = MNG_UINT_HUH;
1797 *iChunkseq = 0;
1798#endif
1799
1800 *iExtra1 = pData->iErrorx1;
1801 *iExtra2 = pData->iErrorx2;
1802 *zErrortext = pData->zErrortext;
1803
1804#ifdef MNG_SUPPORT_TRACE
1805 MNG_TRACE (((mng_datap)hHandle), MNG_FN_GETLASTERROR, MNG_LC_END)
1806#endif
1807
1808 return pData->iErrorcode; /* and the errorcode */
1809}
1810
1811/* ************************************************************************** */
1812/* * end of file * */
1813/* ************************************************************************** */
1814
Note: See TracBrowser for help on using the repository browser.