2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Internal types and stuff for dos
11 #include <aros/system.h>
14 #include <dos/exall.h>
15 #include <dos/dosextens.h>
16 #include <dos/dosasl.h>
17 #include <dos/filehandler.h>
18 #include <utility/tagitem.h>
19 #include <proto/exec.h>
20 #include <proto/utility.h>
22 #include "fs_driver.h"
25 * These bases are historically placed in public portion of DOSBase.
26 * We won't change this.
29 #define TimerBase (DOSBase->dl_TimeReq->tr_node.io_Device)
31 #define UtilityBase (DOSBase->dl_UtilityBase)
33 /* Needed for close() */
35 AROS_LC0(BPTR, expunge, struct DosLibrary *, DOSBase, 3, Dos)
37 #define RDAF_ALLOCATED_BY_READARGS (1L << 31)
41 struct DosLibrary pub
;
42 struct Library
*debugBase
;
43 struct RootNode rootNode
;
44 struct ErrorString errors
;
47 #define DebugBase ((struct IntDosBase *)DOSBase)->debugBase
61 #define IOBUFSIZE 4096
68 struct DosLibrary
*DOSBase
;
71 /* fh_Flags. The flags are AROS specific and therefore PRIVATE.. */
72 #define FHF_WRITE 0x80000000
80 (((struct FileHandle *)BADDR(f))->fh_Flags&FHF_WRITE&& \
81 ((struct FileHandle *)BADDR(f))->fh_Pos<((struct FileHandle *)BADDR(f))->fh_End? \
82 *((struct FileHandle *)BADDR(f))->fh_Pos++=c,0:FPutC(f,c))
84 /* Softlink handling */
85 STRPTR
ResolveSoftlink(BPTR cur
, struct DevProc
*dvp
, CONST_STRPTR name
, struct DosLibrary
*DOSBase
);
86 LONG
RootDir(struct DevProc
*dvp
, struct DosLibrary
*DOSBase
);
89 struct DosPacket
*allocdospacket(void);
90 void freedospacket(struct DosPacket
*dp
);
91 SIPTR
dopacket(SIPTR
*res2
, struct MsgPort
*port
, LONG action
, SIPTR arg1
, SIPTR arg2
, SIPTR arg3
, SIPTR arg4
, SIPTR arg5
);
92 void internal_SendPkt(struct DosPacket
*dp
, struct MsgPort
*port
, struct MsgPort
*replyport
);
93 struct DosPacket
*internal_WaitPkt(struct MsgPort
*msgPort
);
94 void internal_ReplyPkt(struct DosPacket
*dp
, struct MsgPort
*replyPort
, SIPTR res1
, LONG res2
);
96 #define dopacket5(base, res2, port, action, arg1, arg2, arg3, arg4, arg5) dopacket(res2, port, action, (SIPTR)(arg1), (SIPTR)(arg2), (SIPTR)(arg3), (SIPTR)(arg4), (SIPTR)(arg5))
97 #define dopacket4(base, res2, port, action, arg1, arg2, arg3, arg4) dopacket(res2, port, action, (SIPTR)(arg1), (SIPTR)(arg2), (SIPTR)(arg3), (SIPTR)(arg4), 0)
98 #define dopacket3(base, res2, port, action, arg1, arg2, arg3) dopacket(res2, port, action, (SIPTR)(arg1), (SIPTR)(arg2), (SIPTR)(arg3), 0, 0)
99 #define dopacket2(base, res2, port, action, arg1, arg2) dopacket(res2, port, action, (SIPTR)(arg1), (SIPTR)(arg2), 0, 0, 0)
100 #define dopacket1(base, res2, port, action, arg1) dopacket(res2, port, action, (SIPTR)(arg1), 0, 0, 0, 0)
101 #define dopacket0(base, res2, port, action) dopacket(res2, port, action, 0, 0, 0, 0, 0)
103 extern APTR
BCPL_Setup(struct Process
*me
, BPTR segList
, APTR entry
, APTR DOSBase
);
104 extern void BCPL_Cleanup(struct Process
*me
);
105 ULONG
CallEntry(STRPTR argptr
, ULONG argsize
, LONG_FUNC entry
, struct Process
*me
);
107 struct MsgPort
*RunHandler(struct DeviceNode
*deviceNode
, const char *path
, struct DosLibrary
*DOSBase
);
108 BOOL
namefrom_internal(struct DosLibrary
*DOSBase
, BPTR lock
, STRPTR buffer
, LONG length
);
110 /* Cli dependent SetProgramName() for use in CreateNewProc() */
111 BOOL
internal_SetProgramName(struct CommandLineInterface
*cli
,
112 CONST_STRPTR name
, struct DosLibrary
*DOSBase
);
115 /* Pattern matching function used by MatchPattern() and MatchPatternNoCase() */
116 BOOL
patternMatch(CONST_STRPTR pat
, CONST_STRPTR str
, BOOL useCase
,
117 struct DosLibrary
*DOSBase
);
119 /* Pattern parsing function used by ParsePattern() and ParsePatternNoCase() */
120 LONG
patternParse(CONST_STRPTR Source
, STRPTR Dest
, LONG DestLength
,
121 BOOL useCase
, struct DosLibrary
*DOSBase
);
126 struct FileHandle
*fh
,
129 struct DosLibrary
*DOSBase
131 LONG
InternalFlush( struct FileHandle
*fh
, struct DosLibrary
*DOSBase
);
136 struct AChain
*Match_AllocAChain(LONG extrasize
, struct DosLibrary
*DOSBase
);
137 void Match_FreeAChain(struct AChain
*ac
, struct DosLibrary
*DOSBase
);
138 LONG
Match_BuildAChainList(CONST_STRPTR pattern
, struct AnchorPath
*ap
,
139 struct AChain
**retac
, struct DosLibrary
*DOSBase
);
140 LONG
Match_MakeResult(struct AnchorPath
*ap
, struct DosLibrary
*DOSBase
);
142 void addprocesstoroot(struct Process
* , struct DosLibrary
*);
143 void removefromrootnode(struct Process
*, struct DosLibrary
*);
147 UBYTE type
; /* 0: Split 1: MP_NOT */
148 CONST_STRPTR pat
; /* Pointer into pattern */
149 CONST_STRPTR str
; /* Pointer into string */
154 struct markerarray
*next
;
155 struct markerarray
*prev
;
156 struct marker marker
[128];
159 #define PUSH(t,p,s) \
163 if(macur->next==NULL) \
165 macur->next=AllocMem(sizeof(struct markerarray),MEMF_ANY); \
166 if(macur->next==NULL) \
167 ERROR(ERROR_NO_FREE_STORE); \
168 macur->next->prev=macur; \
173 macur->marker[macnt].type=(t); \
174 macur->marker[macnt].pat=(p); \
175 macur->marker[macnt].str=(s); \
189 (t)=macur->marker[macnt].type; \
190 (p)=macur->marker[macnt].pat; \
191 (s)=macur->marker[macnt].str; \
194 #define MP_ESCAPE 0x81 /* Before characters in [0x81;0x8a] */
195 #define MP_MULT 0x82 /* _#(_a) */
196 #define MP_MULT_END 0x83 /* #(a_)_ */
197 #define MP_NOT 0x84 /* _~(_a) */
198 #define MP_NOT_END 0x85 /* ~(a_)_ */
199 #define MP_OR 0x86 /* _(_a|b) */
200 #define MP_OR_NEXT 0x87 /* (a_|_b) */
201 #define MP_OR_END 0x88 /* (a|b_)_ */
202 #define MP_SINGLE 0x89 /* ? */
203 #define MP_ALL 0x8a /* #? or * */
204 #define MP_SET 0x8b /* _[_ad-g] */
205 #define MP_NOT_SET 0x8c /* _[~_ad-g] */
206 #define MP_DASH 0x8d /* [ad_-g_] */
207 #define MP_SET_END 0x8e /* [ad-g_]_ */
209 /* Whether MatchFirst/MatchNext/MatchEnd in case of the base
210 AChain should just take the currentdir lock pointer, or
211 make a real duplicate with DupLock() */
213 #define MATCHFUNCS_NO_DUPLOCK 0
215 #include "dos_commanderrors.h"
217 #define __is_task(task) (((struct Task *)task)->tc_Node.ln_Type == NT_TASK)
218 #define __is_process(task) (((struct Task *)task)->tc_Node.ln_Type == NT_PROCESS)
232 IPTR start_address
; // start address of loaded executable segment
233 struct MinList seginfos
;
236 struct InternalExAllControl
238 struct ExAllControl eac
;
239 /* Used for ExAll emulation. If non null, it means
240 ExAll emulation is being performed. */
241 struct FileInfoBlock
*fib
;
245 typedef struct FileHandle
* FileHandlePtr
;
247 void vbuf_free(FileHandlePtr fh
);
248 APTR
vbuf_alloc(FileHandlePtr fh
, STRPTR buf
, ULONG size
);
249 void vbuf_inject(BPTR fh
, CONST_STRPTR argptr
, ULONG argsize
, struct DosLibrary
*DOSBase
);
251 LONG
FWriteChars(BPTR file
, CONST UBYTE
* buffer
, ULONG length
, struct DosLibrary
*DOSBase
);
254 #ifdef AROS_FAST_BSTR
256 #define CMPBSTR(x, y) Stricmp(BADDR(x), BADDR(y))
257 #define CMPNICBSTR(x, y, n) Strnicmp(x, BADDR(y), n)
258 #define BSTR2C(s) ((STRPTR)BADDR(s))
263 BOOL
CMPBSTR(BSTR
, BSTR
);
264 BOOL
CMPNICBSTR(CONST_STRPTR
, BSTR
, UBYTE
);
267 #define FreeCSTR(s) FreeVec(s)
271 #ifdef AROS_FAST_BSTR
272 #define C2BSTR(x) ((char *)(x))
273 #define FREEC2BSTR(x) do { } while (0)
274 #define CMPCBSTR(a,b) strcmp(a,b)
275 #define CMPICBSTR(a,b) Stricmp(a,b)
277 BSTR
C2BSTR(CONST_STRPTR
);
278 #define FREEC2BSTR(bstr) FreeVec(BADDR(bstr))
279 BOOL
CMPCBSTR(CONST_STRPTR
, BSTR
);
280 BOOL
CMPICBSTR(CONST_STRPTR
, BSTR
);
283 void fixfib(struct FileInfoBlock
*);
285 struct PacketHelperStruct
288 struct MsgPort
*port
;
293 BOOL
getpacketinfo(struct DosLibrary
*DOSBase
, CONST_STRPTR
, struct PacketHelperStruct
*);
294 BOOL
getdevpacketinfo(struct DosLibrary
*DOSBase
, CONST_STRPTR devname
, CONST_STRPTR name
, struct PacketHelperStruct
*phs
);
295 void freepacketinfo(struct DosLibrary
*DOSBase
, struct PacketHelperStruct
*);
297 #define ASSERT_VALID_FILELOCK(lock) do { \
298 struct FileLock *fl = BADDR(lock); \
299 if (fl && fl->fl_Access != SHARED_LOCK && fl->fl_Access != EXCLUSIVE_LOCK) { \
300 bug("%s() called with a bogus FileLock! Lock=%x FL=%x Access %d %s/%s/%d\n", __FUNCTION__, lock, fl, fl->fl_Access, __FILE__,__FUNCTION__,__LINE__); \
304 #endif /* DOS_INTERN_H */