add a missing section header table index conversion
[tangerine.git] / workbench / devs / zero_handler.c
blobd7de002dbc54bd6eb12621710fa49ef8fcb5c526
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: ZERO: handler
6 Lang: English
7 */
9 #include <exec/errors.h>
10 #include <exec/resident.h>
11 #include <exec/memory.h>
12 #include <proto/exec.h>
13 #include <utility/tagitem.h>
14 #include <dos/dosextens.h>
15 #include <dos/filesystem.h>
16 #include <proto/dos.h>
17 #include <aros/libcall.h>
18 #include <aros/symbolsets.h>
20 #include "zero_handler_gcc.h"
22 #include LC_LIBDEFS_FILE
24 #include <string.h>
26 static int GM_UNIQUENAME(Init)(LIBBASETYPEPTR zerobase)
28 zerobase->dosbase=(struct DosLibrary *)OpenLibrary("dos.library",39);
29 if(zerobase->dosbase!=NULL)
30 return TRUE;
32 return FALSE;
35 static int GM_UNIQUENAME(Open)
37 LIBBASETYPEPTR zerobase,
38 struct IOFileSys *iofs,
39 ULONG unitnum,
40 ULONG flags
43 ULONG *dev;
45 /* Mark Message as recently used. */
46 iofs->IOFS.io_Message.mn_Node.ln_Type=NT_REPLYMSG;
48 dev=AllocMem(sizeof(ULONG),MEMF_PUBLIC|MEMF_CLEAR);
49 if(dev!=NULL)
51 iofs->IOFS.io_Unit=(struct Unit *)dev;
52 iofs->IOFS.io_Device=&zerobase->device;
53 iofs->IOFS.io_Error=0;
54 return TRUE;
56 else
58 iofs->io_DosError=ERROR_NO_FREE_STORE;
61 iofs->IOFS.io_Error=IOERR_OPENFAIL;
63 return FALSE;
66 static int GM_UNIQUENAME(Close)
68 LIBBASETYPEPTR zerobase,
69 struct IOFileSys *iofs
72 ULONG *dev;
74 dev=(ULONG *)iofs->IOFS.io_Unit;
75 if(*dev)
77 iofs->io_DosError=ERROR_OBJECT_IN_USE;
78 return FALSE;
81 /* Let any following attemps to use the device crash hard. */
82 FreeMem(dev,sizeof(ULONG));
83 iofs->io_DosError=0;
85 return TRUE;
88 ADD2INITLIB(GM_UNIQUENAME(Init), 0)
89 ADD2OPENDEV(GM_UNIQUENAME(Open), 0)
90 ADD2CLOSEDEV(GM_UNIQUENAME(Close), 0)
92 AROS_LH1(void, beginio,
93 AROS_LHA(struct IOFileSys *, iofs, A1),
94 struct zerobase *, zerobase, 5, Zero)
96 AROS_LIBFUNC_INIT
97 LONG error=0;
98 LONG i;
101 Do everything quick no matter what. This is possible
102 because I never need to Wait().
104 switch(iofs->IOFS.io_Command)
106 case FSA_OPEN:
107 Forbid();
108 ++*(ULONG *)iofs->IOFS.io_Unit;
109 Permit();
110 break;
112 case FSA_OPEN_FILE:
113 /* No names allowed on ZERO: */
114 if (iofs->io_Union.io_NamedFile.io_Filename[0])
116 error=ERROR_OBJECT_NOT_FOUND;
117 break;
119 break;
121 case FSA_READ:
122 for ( i = iofs->io_Union.io_READ.io_Length ; i > 0 ; i-- )
123 iofs->io_Union.io_READ.io_Buffer[i-1] = 0;
124 break;
126 case FSA_WRITE:
127 break;
129 case FSA_SEEK:
130 iofs->io_Union.io_SEEK.io_Offset = 0;
131 break;
133 case FSA_CLOSE:
134 Forbid();
135 --*(ULONG *)iofs->IOFS.io_Unit;
136 Permit();
137 break;
139 case FSA_IS_INTERACTIVE:
140 iofs->io_Union.io_IS_INTERACTIVE.io_IsInteractive = TRUE;
141 break;
142 case FSA_SET_FILE_SIZE:
143 case FSA_EXAMINE:
144 case FSA_EXAMINE_NEXT:
145 case FSA_EXAMINE_ALL:
146 case FSA_CREATE_DIR:
147 case FSA_CREATE_HARDLINK:
148 case FSA_CREATE_SOFTLINK:
149 case FSA_RENAME:
150 case FSA_DELETE_OBJECT:
151 error = ERROR_NOT_IMPLEMENTED;
152 break;
154 default:
155 error = ERROR_ACTION_NOT_KNOWN;
156 break;
159 /* Set error code */
160 iofs->io_DosError=error;
162 /* If the quick bit is not set send the message to the port */
163 if(!(iofs->IOFS.io_Flags&IOF_QUICK))
164 ReplyMsg(&iofs->IOFS.io_Message);
166 AROS_LIBFUNC_EXIT
169 AROS_LH1(LONG, abortio,
170 AROS_LHA(struct IOFileSys *, iofs, A1),
171 struct zerobase *, zerobase, 6, Zero)
173 AROS_LIBFUNC_INIT
174 /* Everything already done. */
175 return 0;
176 AROS_LIBFUNC_EXIT