added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / compiler / include / libraries / arp.h
blobd9051a47446a3c6280716fb9c3e6f65080e6dfc7
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #ifndef ARP_H
7 #define ARP_H
9 #include <exec/types.h>
10 #include <exec/libraries.h>
11 #include <exec/lists.h>
12 #include <exec/semaphores.h>
13 #include <dos/dos.h>
15 struct ArpBase
17 BPTR seglist;
18 UBYTE Flags;
19 UBYTE pad;
20 LONG AB_reserved;
21 APTR EnvBase;
23 struct Library * DosBase;
24 struct Library * GfxBase;
25 struct Library * IntuiBase;
26 struct MinList ResLists;
28 struct Library * ExecBase;
29 struct Library * AslBase;
30 struct Library * UtilityBase;
31 char ESCChar;
34 /*--------------- Following is here only for compatibility with MANX,
35 *--------------- don't use in new code!
37 struct EnvLib
39 APTR EnvSpace; /* access only when Forbidden! */
40 ULONG EnvSize; /* size of environment */
43 /*---------- Flags bit definitions
45 * NOTE: You can check these, but better not change them!
46 * It is currently undetermined how these will be set, but they should
47 * only be set by the user, or by the startup code. Possibly we could
48 * check for an environment variable. This is likely to be the best idea.
50 * NOTE FOR THOSE WRITING LIBRARY CODE:
51 * Routines which use these flags to decide which escape or wildcards to
52 * use default to the BCPL version if neither one is set. For consistancy,
53 * please observe the same convention in your code.
55 *-------------------------------------------------------
58 #define WILD_WORLD 0
59 #define WILD_BCPL 1
61 /*---------- Arp alert numbers, the cutesy BAD CODE one is gone.
62 *---------- We will have to get these blessed by Amiga soon, or changed, or whatever.
64 *-------- Alert Object
67 #define AO_ArpLib 0x00008036
69 /*-------- Specific Alerts you can get when opening ArpLib. -----------*
70 *------- ONLY ARPLIB can return these, you should construct your own, preferably
71 *------- NON dead end alerts, for example, if you can't open ARP:
72 *------- MYALERT AG_OpenLib!AO_ArpLib
73 *---------------------------------------------------------------------*/
75 #define AN_ArpLib EQU 0x03600000
76 #define AN_ArpNoMem EQU 0x03610000 /* Arplibrary out of memory. */
77 #define AN_ArpTaskArray 0x83610001 /* No memory for task array */
78 #define AN_ArpInputMem 0x03610002 /* No memory for input buffer. */
79 #define AN_ArpNoMakeEnv 0x83610003 /* No memory for EnvLib */
81 #define AN_ArpNoDOS 0x83630001 /* Can't open DOS library */
82 #define AN_ArpNoGfx 0x83630002 /* Can't open graphics */
83 #define AN_ArpNoIntuit 0x83630003 /* Can't open intuition */
85 #define AN_ArpObsFunc 0x03600001 /* Call of obsolete function. */
86 #define AN_ArpScattered 0x83600002 /* Scatter loading not allowed for lib. */
88 /* Return codes you can get from calling Assign: */
89 #define ASSIGN_OK 0
90 #define ASSIGN_NODEV 1
91 #define ASSIGN_FATAL 2
92 #define ASSIGN_CANCEL 3 /* Can't cancel a VOLUME */
94 /*--------- Size of buffer you need for ReadLine */
96 #define MaxInputBuf 256
98 /*--------- Input structure for File Requester */
99 #define FRB_DoWildFunc 7
100 #define FRB_DoMsgFunc 6
102 #define FCHARS 32 /* Directory name sizes */
103 #define DSIZE 33
105 /* SET ALL OTHER FLAGS TO NULL -
106 * They will be used in later revs of Arp.library.
107 * If you set them non-null, they will do something besides default.
108 * You may not be set up for it.
111 struct FR_struct
113 APTR FR_Hail; /* Hailing text */
114 APTR FR_Ddef; /* *Filename array (FCHARS+1) */
115 APTR FR_Ddir; /* *Directory array (DSIZE+1) */
116 APTR FR_Wind; /* Window requesting or NULL */
117 WORD FR_Flags; /* Control. See above. SET TO NULL. */
118 APTR FR_WildFunc; /* Func to call for wildcards */
119 APTR FR_MsgFunc; /* Func to call with IntuiMessages */
121 /*---------- Structures and constants used by the wildcard routines */
123 #define P_TAG 0x85
124 #define P_TAGEND 0x86
125 #define ERROR_INTERNAL 999
126 //#define BUFSIZ 200
127 #define DOS_TRUE 0
128 #define DOS_FALSE -1
129 #define MAXFNAME 200
132 /* This is the structure you pass to FindFirst/FindNext.
133 * In it you can set AP_BREAKBITS to be the bits you want to match
134 * for break checking while the directory is being searched.
135 * Also you may allocate a buffer at AP_BUF, the size of which is
136 * in AP_LENGTH, where the full path name of the current entry will
137 * be built. If AP_LENGTH is 0, the path name will not be built.
139 struct AP
141 APTR AP_BASE;
142 APTR AP_LAST;
143 LONG AP_BREAKBITS;
144 LONG AP_FOUNDBREAK;
145 APTR AP_LENGTH;
146 struct FileInfoBlock AP_INFO;
149 struct AN
151 APTR AN_NEXT;
152 APTR AN_PRED;
153 LONG AN_LOCK;
154 APTR AN_INFO;
155 LONG AN_STATUS; /* Text must be longword aligned for passing to dos */
156 WORD AN_TEXT; /* ;Account for */
160 /* Structure used by AddDANode, AddDADevs, FreeDAList
161 * This structure is used to create lists of names,
162 * which normally are devices, assigns, volumes, files, or directories
165 struct DirectoryEntry
167 LONG DA_Next;
168 BYTE DA_Type;
169 BYTE DA_Flags;
172 #define DLB_DEVICES 0
173 #define DLB_DISKONLY 1 ; If only DISK devices
174 #define DLB_VOLUMES 2
175 #define DLB_DIRS 3
177 #define DLX_FILE 0
178 #define DLX_DIR 8
179 #define DLX_DEVICE 16
181 #define DLX_VOLUME 24
182 #define DLX_UNMOUNTED 32
184 #define DLX_ASSIGN 40
186 /************************************************************************
188 * ResLists
189 * This list is used to track resources, normally within a Task.
190 * Each ResList has a single-linked node linking together ResLists; this
191 * list is maintained in ArpBase now but ideally would use TC_UserData,
192 * so the ResList for a task could be found more quickly. However, there
193 * must also be a link so ResLists can be maintained in ArpBase, for
194 * Resource Tracking. To facilitate this at a later data, we have
195 * added the ReservedList field, which could be used if ArpBase gets
196 * burned into ROM.
198 * NOTE: This is a DosAllocMem'd list, with length @-4
201 struct ArpResList
203 struct MinNode ARL_node; /* Links these together */
204 LONG TaskID;
205 struct MinList FirstItem;
206 APTR ARL_link; /* For temp removal from task rlist */
209 /* Tracked Items
210 * Each item in the list has a double-link node which is used to
211 * attach to the FirstItem list header in a ResList. All list items are
212 * based on a simple memory allocation; the generic node is a DosAllocMem'd
213 * memory block set to all NULL for the control fields. This makes it very
214 * easy to track the nodes themselves, in case there is a problem during
215 * allocation.
217 struct TrackedResource
219 struct MinNode TR_Node; /* Double linked pointer */
220 BYTE TR_Flags; /* See flag bits below */
221 BYTE TR_Lock; /* Used by GetAccess/FreeAccess */
222 WORD TR_ID; /* ID for this item class */
223 APTR TR_Stuff; /* Whatever the dude wants to free. */
224 LONG TR_Extra; /* Unused now, even to memchunk size*/
227 /* The function "GetTracker" will allocate a generic tracking node,
228 * which is a minimum-sized memory block passed back to the user.
229 * The pointer the user gets actually points at the TR_Stuff node,
230 * rather than at the head of the list. The user-accessible fields are
231 * below:
233 struct UserResource
235 WORD TRU_ID;
236 APTR TRU_Stuff;
237 LONG TRU_Extra;
239 /* See discussion of the TRU_Extra field below; it is always allocated
240 * because the minimum memory grain size is 8 bytes, and this extra
241 * field actually does not require any extra memory.
244 /* Tracked Item Types
245 * The id types below show the types of resources which may
246 * be tracked in a resource list.
248 #define TRAK_AAMEM 0 /* Default generic (ArpAlloc) element */
249 #define TRAK_LOCK 1 /* File Lock */
250 #define TRAK_FILE 2 /* Opened File */
251 #define TRAK_WINDOW 3 /* Window (see discussion) */
252 #define TRAK_SCREEN 4 /* Screen */
253 #define TRAK_LIBRARY 5 /* Opened library */
254 #define TRAK_DAMEM 6 /* Pointer to DosAllocMem block */
255 #define TRAK_MEMLIST 7 /* Exec Memlist */
256 #define TRAK_SEGLIST 8 /* Program Segment List */
257 #define TRAK_RESLIST 9 /* ARP (nested) ResList */
258 #define TRAK_MEM 10 /* Memory ptr/length */
259 #define TRAK_GENERIC 11 /* Generic Element */
260 #define TRAK_DALIST 12 /* DAlist ( as used by file request ) */
261 #define TRAK_ANCHOR 13 /* Anchor chain */
262 #define TRACK_MAX 13 /* Anything else is tossed. */
264 /* For TRAK_GENERIC, you set up a task function to be called when
265 * an item is freed. This is very dangerous if not used properly.
266 * PROGRAMMER BEWARE. ( If you leave a relist untracked, too bad )
269 #define TG_FuncAddr TR_Extra
270 #define TG_VALUE TR_Stuff
272 /* For TRAK_WINDOW, set the TW_OTHER field if this window shares a msgport
273 * and the msgport should not be freed
275 #define TW_WINDOW TR_Extra
277 /* NOTE - THINGS IN THIS LIST MUST NOT DEPEND ON THE TASK STILL EXISTING
278 * Thus, no DeletePort or RemTask. This is to allow a Flush executable
279 * to be created which will go throug all of the Tracked list, and for
280 * tasks that exited improperly, free the resources.
282 /* Special Considerations
283 * The TR_Lock and TR_Flags bytes have special meaning. These
284 * are internally managed fields, which should not be touched by the
285 * application.
286 * The TR_Lock field is managed by GetAccess/FreeAccess. If
287 * this field is -1, the resource being tracked may be freed at will
288 * by the
290 #define TRB_UNLINK 7 /* Bit for freeing the node */
291 #define TRB_RELOC 6 /* This element may be relocated!!!
292 ; ( This bit is not used yet ) */
293 #define TRB_MOVED 5 /* Bit set if the item moved. */
295 #define TRV_UNLINK 1<<TRB_UNLINK
296 #define TRV_RELOC 1<<TRB_RELOC
297 /**************************************************************************/
301 #endif /* ARP */