revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / iffparse / dosstreamhandler.c
blob4b3180006bdb7f7d9f29c5899278befc0e75cb2d
1 /*
2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
3 $Id$
5 DOS stream handler. Used in InitIFFasDOS.
6 */
8 #define DEBUG 0
9 #include <aros/debug.h>
10 #include "iffparse_intern.h"
12 /********************/
13 /* DosStreamHandler */
14 /********************/
16 #define IFFParseBase IPB(hook->h_Data)
18 ULONG DOSStreamHandler
20 struct Hook * hook,
21 struct IFFHandle * iff,
22 struct IFFStreamCmd * cmd
25 LONG error = 0;
27 DEBUG_DOSSTREAMHANDLER(dprintf("DOSStreamHandler: hook %p iff %p cmd %p\n", hook, iff, cmd));
29 switch (cmd->sc_Command)
31 case IFFCMD_READ:
32 DEBUG_BUFSTREAMHANDLER(dprintf("DOSStreamHandler: IFFCMD_READ...\n"));
33 D(bug(" Reading %ld bytes\n", cmd->sc_NBytes));
35 error = Read(
36 (BPTR)iff->iff_Stream,
37 cmd->sc_Buf,
38 cmd->sc_NBytes) != cmd->sc_NBytes;
40 break;
42 case IFFCMD_WRITE:
43 DEBUG_BUFSTREAMHANDLER(dprintf("DOSStreamHandler: IFFCMD_WRITE...\n"));
44 D(bug(" Writing %ld bytes\n", cmd->sc_NBytes));
46 error = Write(
47 (BPTR)iff->iff_Stream,
48 cmd->sc_Buf,
49 cmd->sc_NBytes) != cmd->sc_NBytes;
51 break;
53 case IFFCMD_SEEK:
54 DEBUG_BUFSTREAMHANDLER(dprintf("DOSStreamHandler: IFFCMD_SEEK...\n"));
55 D(bug(" Seeking %ld bytes\n", cmd->sc_NBytes));
57 error = Seek((BPTR)iff->iff_Stream, cmd->sc_NBytes, OFFSET_CURRENT) == -1;
59 break;
61 case IFFCMD_INIT:
63 DEBUG_BUFSTREAMHANDLER(dprintf("DOSStreamHandler: IFFCMD_INIT...\n"));
65 /* Don't need these for dos streams
67 error = 0;
68 break;
70 case IFFCMD_CLEANUP:
72 DEBUG_BUFSTREAMHANDLER(dprintf("DOSStreamHandler: IFFCMD_CLEANUP...\n"));
74 /* Force stream to beginning, some applications assume stream is at
75 beginning after failed OpenIFF()'s IFFCMD_CLEANUP. This fixed pbs
76 with multiview and certain jpeg files, for example. - Piru
78 error = Seek((BPTR)iff->iff_Stream, 0, OFFSET_BEGINNING) == -1;
79 break;
82 DEBUG_DOSSTREAMHANDLER(dprintf("DOSStreamHandler: return %ld\n", error));
83 return (error);