1 {
2     This file is part of the Free Pascal run time library.
3     Copyright (c) 2014 by Free Pascal development team
4 
5     dos.library functions
6 
7     See the file COPYING.FPC, included in this distribution,
8     for details about the copyright.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 
14  **********************************************************************}
15 {
16  BSTR Funktions
17 
18  defines:
19  AROS_FAST_BPTR: BPTR is a pointer or a 2 shifted Pointer
20    -> atm its standard ABIv0, for v1 needs a ifdef
21 }
22 
23 {$define AROS_FAST_BPTR}
24 
25 unit amigados;
26 
27 interface
28 
29 uses
30   exec, utility, timer;
31 
32 {$PACKRECORDS C}
33 
34 const
35 { Predefined Amiga DOS global constants }
36   DOSTRUE     = -1;
37   DOSFALSE    =  0;
38   TICKS_PER_SECOND = 50;   { Number of ticks in one second }
39 
40   // Still to TEST
41   BITSPERBYTE         = 8;
42   BYTESPERLONG        = 4;
43   BITSPERLONG         = 32;
44 
45 type
46   FileHandle  = BPTR;
47   FileLock    = BPTR;
48 
49 {* All BCPL data must be long Integer aligned.  BCPL pointers are the long Integer
50  *  address (i.e byte address divided by 4 (>>2)) *}
51 
52 {* BCPL strings have a length in the first byte and then the characters.
53  * For example:  s[0]=3 s[1]=S s[2]=Y s[3]=S                 *}
54 
55 
56 
57 const
58 // DOS functions will return this when they reach EOF. */
59   ENDSTREAMCH = -1;
60 // Buffering types for SetVBuf().
61   BUF_LINE    = 0; // Flush at the end of lines '\n'.
62   BUF_FULL    = 1; // Flush only when buffer is full.
63   BUF_NONE    = 2; // Do not buffer, read and write immediatly.
64 
65 type
66   PDateStamp = ^TDateStamp;
67   TDateStamp = record
68     ds_Days: Longint;        { Number of days since Jan. 1, 1978 }
69     ds_Minute: Longint;      { Number of minutes past midnight }
70     ds_Tick: Longint;        { Number of ticks past minute }
71   end;
72 
73 const
74 { The maximum length of filenames in AmigaOS. You should not depend on
75   this value, as it may change in future versions.}
76   MAXFILENAMELENGTH = 108;
77 
78 { The maximum length of comments in AmigaOS. You should not depend on
79   this value, as it may change in future versions.}
80   MAXCOMMENTLENGTH = 80;
81 
82 type
83 { Returned by Examine() and ExInfo(), must be on a 4 byte boundary
84   Structure used to describe a directory entry. Note that not all fields
85   are supported by all filesystems. This structure should be allocated
86   with AllocDosObject(). }
87   PFileInfoBlock = ^TFileInfoBlock;
88   TFileInfoBlock = record
89     fib_DiskKey: IPTR;
90     fib_DirEntryType: LongInt;                              // type of Directory. If < 0, then a plain file. If > 0 a directory
91     fib_FileName: array [0..MAXFILENAMELENGTH - 1] of Char; // Null terminated. Max 30 chars used for now
92     fib_Protection: LongInt;                                // bit mask of protection, rwxd are 3-0.
93     fib_EntryType: LongInt;
94     fib_Size: LongInt;                                      // Number of bytes in file
95     fib_NumBlocks: LongInt;                                 // Number of blocks in file
96     fib_Date: TDateStamp;                                   // Date file last changed
97     fib_Comment: array [0..MAXCOMMENTLENGTH - 1] of Char;   // Null terminated comment associated with file
98     fib_OwnerUID: Word;                                     // UserID of fileowner.
99     fib_OwnerGID: Word;                                     // GroupID of fileowner.
100     fib_Reserved: array [0..31] of Char;                    // PRIVATE
101   end;
102 
103 const
104 { FIB stands for TFileInfoBlock (fib_Protection)}
105 
106 { FIBB are bit definitions, FIBF are field definitions
107   Regular RWED bits are 0 == allowed.
108   NOTE: GRP and OTR RWED permissions are 0 == not allowed!
109   Group and Other permissions are not directly handled by the filesystem}
110   FIBB_DELETE         = 0;  // prevent file from being deleted }
111   FIBB_EXECUTE        = 1;  // ignored by system, used by Shell }
112   FIBB_WRITE          = 2;  // ignored by old filesystem }
113   FIBB_READ           = 3;  // ignored by old filesystem }
114   FIBB_ARCHIVE        = 4;  // cleared whenever file is changed }
115   FIBB_PURE           = 5;  // program is reentrant and rexecutable}
116   FIBB_SCRIPT         = 6;  // program is a script (execute) file }
117 // group flags
118   FIBB_GRP_DELETE     = 8;  // Group: prevent file from being deleted *}
119   FIBB_GRP_EXECUTE    = 9;  // Group: file is executable *}
120   FIBB_GRP_WRITE      = 10; // Group: file is writable *}
121   FIBB_GRP_READ       = 11; // Group: file is readable *}
122 // other
123   FIBB_OTR_DELETE     = 12; // Other: prevent file from being deleted *}
124   FIBB_OTR_EXECUTE    = 13; // Other: file is executable *}
125   FIBB_OTR_WRITE      = 14; // Other: file is writable *}
126   FIBB_OTR_READ       = 15; // Other: file is readable *}
127 // Values
128   FIBF_DELETE         = (1 shl FIBB_DELETE);
129   FIBF_EXECUTE        = (1 shl FIBB_EXECUTE);
130   FIBF_WRITE          = (1 shl FIBB_WRITE);
131   FIBF_READ           = (1 shl FIBB_READ);
132   FIBF_ARCHIVE        = (1 shl FIBB_ARCHIVE);
133   FIBF_PURE           = (1 shl FIBB_PURE);
134   FIBF_SCRIPT         = (1 shl FIBB_SCRIPT);
135 // Group Values
136   FIBF_GRP_DELETE    = (1 shl FIBB_GRP_DELETE);
137   FIBF_GRP_EXECUTE   = (1 shl FIBB_GRP_EXECUTE);
138   FIBF_GRP_WRITE     = (1 shl FIBB_GRP_WRITE);
139   FIBF_GRP_READ      = (1 shl FIBB_GRP_READ);
140 // Other Values
141   FIBF_OTR_DELETE    = (1 shl FIBB_OTR_DELETE);
142   FIBF_OTR_EXECUTE   = (1 shl FIBB_OTR_EXECUTE);
143   FIBF_OTR_WRITE     = (1 shl FIBB_OTR_WRITE);
144   FIBF_OTR_READ      = (1 shl FIBB_OTR_READ);
145 
146 // Devices
147 type
148 { returned by Info(), must be on a 4 byte boundary }
149   PInfoData = ^TInfoData;
150   TInfoData = record
151     id_NumSoftErrors: LongInt; // Number of soft errors on disk
152     id_UnitNumber: LongInt;    // Which unit disk is (was) mounted on
153     id_DiskState: LongInt;     // Dtate of Volume See defines below
154     id_NumBlocks: LongInt;     // Number of blocks on device
155     id_NumBlocksUsed: LongInt; // Number of block in use
156     id_BytesPerBlock: LongInt; // Bytes per Block
157     id_DiskType: LongInt;      // Type of Disk
158     id_VolumeNode: BPTR;       // BCPL pointer to volume node
159     id_InUse: IPTR;            // Flag, zero if not in use
160   end;
161 
162   {$PACKRECORDS NORMAL}
163 
164 const
165   { ID stands for InfoData }
166 { Disk states }
167   ID_WRITE_PROTECTED  = 80;   // Disk is write protected
168   ID_VALIDATING       = 81;   // Disk is currently being validated
169   ID_VALIDATED        = 82;   // Disk is consistent and writeable
170 { Filesystem types as used for id_DiskType. These are multi-character
171   constants of identifier strings. They are self-descriptive.}
172   ID_NO_DISK_PRESENT     = -1;
173   ID_UNREADABLE_DISK     = $42414400; // 'BAD#0'
174   ID_DOS_DISK            = $444F5300; // 'DOS#0'
175   ID_FFS_DISK            = $444F5301; // 'DOS#1'
176   ID_INTER_DOS_DISK      = $444F5302; // 'DOS#2'
177   ID_INTER_FFS_DISK      = $444F5303; // 'DOS#3'
178   ID_FASTDIR_DOS_DISK    = $444F5304; // 'DOS#4'
179   ID_FASTDIR_FFS_DISK    = $444F5305; // 'DOS#5'
180   ID_NOT_REALLY_DOS      = $4E444F53; // 'NDOS'
181   ID_KICKSTART_DISK      = $4B49434B; // 'KICK'
182   ID_MSDOS_DISK          = $4d534400; // 'MSD#0'
183   ID_SFS_BE_DISK         = $53465300; // 'SFS#0'
184   ID_SFS_LE_DISK         = $73667300; // 'sfs#0'
185 { These are the return codes used by convention by AmigaDOS commands
186   See FAILAT and IF for relvance to EXECUTE files}
187     // No Problem, success
188   RETURN_OK              =  0;
189   { Program succeeded, but there was something not quite right.
190     This value may also be used to express a boolean state
191     (RETURN_WARN meaning TRUE, RETURN_OK meaning FALSE).}
192   RETURN_WARN            =  5;
193   { Program succeeded partly. This may be returned, if the user aborts a
194     program or some external data were wrong.}
195   RETURN_ERROR           = 10; // Something wrong
196   { Program execution failed. Normally used, if some system resources could
197     not be allocated.}
198   RETURN_FAIL            = 20; // Complete or severe failure
199 
200 { Secondary errors codes as used for IoErr(), SetIoErr() and in
201   Process^.pr_Result2. The term 'object' refers to files of all kinds
202   (ie plain files, directories, links, etc).}
203 
204   {This is used, if something went wrong, but it is unknown what exactly
205    went wrong. This is especially useful for emulation devices, when the
206    underlying system returned an error that the emulation side does not
207    know.}
208   ERROR_UNKNOWN                  = 100;
209 //General system errors
210   ERROR_NO_FREE_STORE            = 103; // Out of memory.
211   ERROR_TASK_TABLE_FULL          = 105; // Too many tasks are already running.
212 //Errors concerning ReadArgs().
213   ERROR_BAD_TEMPLATE             = 114; // Supplied template is broken
214   ERROR_BAD_NUMBER               = 115; { A supplied argument that was expected to be numeric, was not numeric.
215                                           This is also returned by some functions to expresss that a supplied
216                                           number is out of range (ie to express application internal errors).}
217   ERROR_REQUIRED_ARG_MISSING     = 116; // An argument that has to be supplied (ie signed with the '/A' flag) was not supplied.
218   ERROR_KEY_NEEDS_ARG            = 117; // Keyword was specified, but not its contents.
219   ERROR_TOO_MANY_ARGS            = 118; // There were more arguments than the template needs.
220   ERROR_UNMATCHED_QUOTES         = 119; // An odd number of quotation marks was supplied.
221   ERROR_LINE_TOO_LONG            = 120; { Either the command-line was longer than hardcoded line length limit or the
222                                           maximum number of multiple arguments (flag '/M') was exceeded. This can
223                                           also indicate that some argument is too long or a supplied buffer is too small.}
224 // Errors in files.
225   ERROR_FILE_NOT_OBJECT          = 121; // You tried to execute a file that is not an executable.
226   ERROR_INVALID_RESIDENT_LIBRARY = 122; // A library or device could not be opened or that library or device is broken.
227   ERROR_NO_DEFAULT_DIR           = 201;
228   ERROR_OBJECT_IN_USE            = 202; // The accessed object is already in use (eg locked) by another task.
229   ERROR_OBJECT_EXISTS            = 203; // You tried to overwrite an object.
230   ERROR_DIR_NOT_FOUND            = 204; // The given directory or the path of a given object does not exist.
231   ERROR_OBJECT_NOT_FOUND         = 205; // The given object does not exist.
232 // Miscellaneous errors.
233   ERROR_BAD_STREAM_NAME          = 206;
234   ERROR_OBJECT_TOO_LARGE         = 207; { The given object is too large for the operation to be made. Object is
235                                           this context are for example components of path-names.}
236   ERROR_ACTION_NOT_KNOWN         = 209; { This is usually used to indicate that a filesystem does not support a
237                                           certain action, but may generally also be used by functions.}
238   ERROR_INVALID_COMPONENT_NAME   = 210; // A path component was invalid (eg there were multiple colons in a path name
239   ERROR_INVALID_LOCK             = 211;
240   ERROR_OBJECT_WRONG_TYPE        = 212; { You tried to perform an action on an object, which this kind of object
241                                           does not support (eg makedir on a file).}
242   ERROR_DISK_NOT_VALIDATED       = 213; // Writing failed, because the volume is not validated.
243   ERROR_DISK_WRITE_PROTECTED     = 214; // Writing failed, because the volume is write-protected.
244   ERROR_RENAME_ACROSS_DEVICES    = 215; { You tried to move/rename a file across different devices. Rename does only
245                                           work on the same device, as only the inode-data has to be changed to
246                                           perform that action.}
247   ERROR_DIRECTORY_NOT_EMPTY      = 216; // You tried to delete a directory that still contains some files. Delete these files first.
248   ERROR_TOO_MANY_LEVELS          = 217; // A recursive directory search could not be performed, because the stack was too small.
249   ERROR_DEVICE_NOT_MOUNTED       = 218; // You tried to access a device that is currently not mounted.
250   ERROR_SEEK_ERROR               = 219; // An error occurred, while executing DosSeek().
251   ERROR_COMMENT_TOO_BIG          = 220; // The supplied file comment was longer than the hardcoded length limit for file comments.
252   ERROR_DISK_FULL                = 221; // A write-operation could not be performed, because the volume has no space left.
253   ERROR_DELETE_PROTECTED         = 222; // You tried to delete a delete-protected object.
254   ERROR_WRITE_PROTECTED          = 223; { You tried to write to a write-protected object. This does not mean that
255                                           the volume, you wanted to write to, is write-protected!}
256   ERROR_READ_PROTECTED           = 224; // You tried to read a read-protected object.
257   ERROR_NOT_A_DOS_DISK           = 225; // Accessed disk is unreadable.
258   ERROR_NO_DISK                  = 226; // You tried to perform an action on a device that has no volume mounted (eg. an empty disk drive).
259   ERROR_NO_MORE_ENTRIES          = 232; { This does not indicate an error, but is returned by several functions to
260                                           indicate that the last entry of a list was reached.}
261   ERROR_IS_SOFT_LINK              = 233; { Given action can not be performed on a given object, because it is a
262                                            soft-link. This is usually only used by filesystem handlers and is catched
263                                            by dos. Applications should not see this.}
264   ERROR_OBJECT_LINKED             = 234; // Given action can not be performed on a given object, because it is a link.
265   ERROR_BAD_HUNK                  = 235; // There was a bad hunk in a file that was to load.
266   ERROR_NOT_IMPLEMENTED           = 236; { Indicates that a function does not implement a certain functionality.
267                                            There are more special error conditions (ERROR_BAD_NUMBER and
268                                            ERROR_ACTION_NOT_KNOWN), which should be preferred, if applicable.}
269   ERROR_RECORD_NOT_LOCKED         = 240; // You tried to access a record that was not locked.
270   ERROR_LOCK_COLLISION            = 241; // Somebody already locked a part of the record, you wanted to lock.
271   ERROR_LOCK_TIMEOUT              = 242; // LockRecord() timed out.
272   ERROR_UNLOCK_ERROR              = 243; // An error occurred, while unlocking a record.
273 
274 { more error codes are defined in dosasl.h and filesystem.h }
275 
276 { Maximum length of strings got from Fault(). Note that they should be
277    shorter than 60 characters. }
278   FAULT_MAX  = 82;
279 
280 { Signals that are set, if the user presses the corresponding keys on
281    the controlling terminal. They may also be sent by using Signal().
282    For more information see <exec/tasks.h>. }
283   SIGBREAKB_CTRL_C   = 12; // CTRL-c, usually meaning program abortion.
284   SIGBREAKB_CTRL_D   = 13; // CTRL-d
285   SIGBREAKB_CTRL_E   = 14; // CTRL-e, usually meaning that the application should iconify itself.
286   SIGBREAKB_CTRL_F   = 15; // CTRL-f, usually meaning that the application should uniconify itself.
287 { Bit fields that signal you that a user has issued a break
288   for example:  if (SetSignal(0,0) and SIGBREAKF_CTRL_C) then cleanup_and_exit();}
289   SIGBREAKF_CTRL_C   = 1 shl SIGBREAKB_CTRL_C;
290   SIGBREAKF_CTRL_D   = 1 shl SIGBREAKB_CTRL_D;
291   SIGBREAKF_CTRL_E   = 1 shl SIGBREAKB_CTRL_E;
292   SIGBREAKF_CTRL_F   = 1 shl SIGBREAKB_CTRL_F;
293 
294 { Mode parameter to Open() }
295   MODE_OLDFILE   = 1005; // Open existing file read/write positioned at beginning of file.
296   MODE_NEWFILE   = 1006; // Open freshly created file (delete old file) read/write
297   MODE_READWRITE = 1004; // An old file is opened. If it does not exist, a new one is created.
298 
299 { Passed as type to Lock() }
300   SHARED_LOCK    = -2;             // Non-exclusive lock, other tasks may lock this file as well.
301   ACCESS_READ    = SHARED_LOCK;    //   This is used for read-only operations.
302   EXCLUSIVE_LOCK = -1;             // Exclusive lock, other tasks may not lock this file.
303   ACCESS_WRITE   = EXCLUSIVE_LOCK; // This is used for write operations.
304 
305 { Values returned by SameLock() }
306   LOCK_SAME         =  0;
307   LOCK_SAME_HANDLER =  1; // actually same volume
308   LOCK_DIFFERENT    = -1;
309 
310 { Values for MakeLink() }
311   LINK_HARD =   0;
312   LINK_SOFT =   1;
313 
314 { Relative position to Seek() }
315   OFFSET_BEGINNING = -1; // relative to Begining Of File
316   OFFSET_CURRENT   =  0; // relative to Current file position
317   OFFSET_END       =  1; // relative to End Of File
318 
319 { Limits of the "Integer" type already defined in FPC... but ok}
320   MAXINT = $7FFFFFFF;
321   MININT = $80000000;
322 
323 { types for ChangeMode() }
324   CHANGE_LOCK = 0;
325   CHANGE_FH = 1;
326 
327 { values returned by  ReadItem() }
328   ITEM_EQUAL    = -2; // '=' Symbol
329   ITEM_ERROR    = -1; // error
330   ITEM_NOTHING  =  0; // *N, ;, endstreamch
331   ITEM_UNQUOTED =  1; // unquoted item
332   ITEM_QUOTED   =  2; // quoted item
333 
334 { types for AllocDosObject/FreeDosObject }
335   DOS_FILEHANDLE   =  0; // PFileHandle
336   DOS_EXALLCONTROL =  1; // PExAllControl
337   DOS_FIB          =  2; // PFileInfoBlock
338   DOS_STDPKT       =  3; // PDosPacket
339   DOS_CLI          =  4; // PCommandLineInterface
340   DOS_RDARGS       =  5; // PRDArgs
341 
342 
343 { Data structures and equates used by the V1.4 DOS functions StrtoDate() and DatetoStr() }
344 {--------- String/Date structures etc }
345 type
346   _PDateTime = ^_TDateTime;
347   _TDateTime = record
348     dat_Stamp: TDateStamp; // DOS DateStamp
349     dat_Format,            // controls appearance of dat_StrDate
350     dat_Flags: Byte;       // see BITDEF's below
351     dat_StrDay,            // day of the week string
352     dat_StrDate,           // date string
353     dat_StrTime: STRPTR;   // time string
354   end;
355 
356 { You need this much room for each of the DateTime strings: }
357 const
358   LEN_DATSTRING =  16;
359 
360 { date format values }
361  FORMAT_DOS     = 0;          // DOS internal format, dd-mmm-yy
362  FORMAT_INT     = 1;          // International format, yy-mm-dd
363  FORMAT_USA     = 2;          // US-American format, mm-dd-yy  }
364  FORMAT_CDN     = 3;          // Canadian format, dd-mm-yy  }
365  FORMAT_MAX     = FORMAT_CDN;
366  FORMAT_DEF     = 4;          { use default format, as defined by locale; if locale not
367                                 available, use FORMAT_DOS instead }
368 
369 { flags for dat_Flags }
370 
371  DTB_SUBST      = 0; // Substitute Today, Tomorrow, etc. if possible.
372  DTF_SUBST      = 1 shl DTB_SUBST;
373  DTB_FUTURE     = 1; // Day of the week is in future.
374  DTF_FUTURE     = 1 shl DTB_FUTURE;
375 
376 {**********************************************************************
377 ************************ PATTERN MATCHING ******************************
378 ************************************************************************
379 
380 * structure expected by MatchFirst, MatchNext.
381 * Allocate this structure and initialize it as follows:
382 *
383 * Set ap_BreakBits to the signal bits (CDEF) that you want to take a
384 * break on, or NULL, if you don't want to convenience the user.
385 *
386 * If you want to have the FULL PATH NAME of the files you found,
387 * allocate a buffer at the END of this structure, and put the size of
388 * it into ap_Strlen.  If you don't want the full path name, make sure
389 * you set ap_Strlen to zero.  In this case, the name of the file, and stats
390 * are available in the ap_Info, as per usual.
391 *
392 * Then call MatchFirst() and then afterwards, MatchNext() with this structure.
393 * You should check the return value each time (see below) and take the
394 * appropriate action, ultimately calling MatchEnd() when there are
395 * no more files and you are done.  You can tell when you are done by
396 * checking for the normal AmigaDOS return code ERROR_NO_MORE_ENTRIES.
397 *
398 }
399 
400 type
401   // PRIVATE structure, which describes an anchor for matching functions.
402   PAChain = ^TAChain;
403   TAChain = record
404     an_Child,           // The next anchor
405     an_Parent: PAChain; // The last anchor
406     an_Lock: BPTR;      // Lock of this anchor
407     an_Info: TFileInfoBlock; // fib Discribing this anchor
408     an_Flags: ShortInt;      // se below
409     an_String: array[0..0] of Char;
410   end;
411 const
412 // an_Flags
413   DDB_PatternBit  = 0;
414   DDB_ExaminedBit = 1;
415   DDB_Completed   = 2;
416   DDB_AllBit      = 3;
417   DDB_Single      = 4;
418   DDF_PatternBit  = 1 shl DDB_PatternBit;
419   DDF_ExaminedBit = 1 shl DDB_ExaminedBit;
420   DDF_Completed   = 1 shl DDB_Completed;
421   DDF_AllBit      = 1 shl DDB_AllBit;
422   DDF_Single      = 1 shl DDB_Single;
423 
424 type
425   PAnchorPath = ^TAnchorPath;
426   TAnchorPath = record
427   case SmallInt of
428     0 :(
429       ap_First      : PAChain;
430       ap_Last       : PAChain;
431     );
432     1 :(
433       ap_Base,                             // pointer to first anchor
434       ap_Current    : PAChain;             // pointer to last anchor
435       ap_BreakBits,                        // Signal bits that caused the function to break.
436       ap_FoundBreak : LongInt;             // Bits we broke on. Also returns ERROR_BREAK
437       ap_Flags      : Shortint;            // see below
438       ap_Reserved   : Shortint;            // Private
439       ap_Strlen     : SmallInt;            // Size of ap_Buf (see below). This may be zero.
440       ap_Info       : TFileInfoBlock;      // describes any files found by matching-functions.
441       ap_Buf        : Array[0..0] of Char; // Buffer for path name, allocated by user!!
442     );
443   end;
444 
445 const
446   APB_DOWILD       = 0; // Please check for wildcards in supplied string.
447   APB_ITSWILD      = 1; // There is actually a wildcard in the supplied string. READ-ONLY
448   APB_DODIR        = 2; { Set, if a directory is to be entered.
449                           Applications may clear this bit to prohibit the
450                           matching-functions from entering a directory. }
451   APB_DIDDIR       = 3; // Set, if directory was already searched. READ-ONLY
452   APB_NOMEMERR     = 4; // Set, if function was out of memory. READ-ONLY
453   APB_DODOT        = 5; // '.' may refer to the current directory (unix-style).
454   APB_DirChanged   = 6; // Directory changed since last call.
455   APB_FollowHLinks = 7; // Follow hardlinks, too.
456 
457   APF_DOWILD       = 1 shl APB_DOWILD;
458   APF_ITSWILD      = 1 shl APB_ITSWILD;
459   APF_DODIR        = 1 shl APB_DODIR;
460   APF_DIDDIR       = 1 shl APB_DIDDIR;
461   APF_NOMEMERR     = 1 shl APB_NOMEMERR;
462   APF_DODOT        = 1 shl APB_DODOT;
463   APF_DirChanged   = 1 shl APB_DirChanged;
464   APF_FollowHLinks = 1 shl APB_FollowHLinks;
465 
466 { Predefined tokens for wildcards. The characters are replaced by these
467   tokens in the tokenized string returned by the ParsePattern() function
468   family.}
469   P_ANY         =  $80; // Matches everything '#?' and '*'
470   P_SINGLE      =  $81; // Any character '?'
471   P_ORSTART     =  $82; // Opening parenthesis for OR'ing '('
472   P_ORNEXT      =  $83; // Field delimiter for OR'ing '|'
473   P_OREND       =  $84; // Closing parenthesis for OR'ing ')'
474   P_NOT         =  $85; // Inversion '~'
475   P_NOTEND      =  $86; // Inversion end
476   P_NOTCLASS    =  $87; // Inversion class '^'
477   P_CLASS       =  $88; // Class '[]'
478   P_REPBEG      =  $89; // Beginning of repetition '['
479   P_REPEND      =  $8A; // End of repetition ']'
480   P_STOP        =  $8B; // token to force end of evaluation
481 
482 { Values for an_Status, NOTE: These are the actual bit numbers }
483   COMPLEX_BIT   =  1; // Parsing complex pattern
484   EXAMINE_BIT   =  2; // Searching directory
485 
486 { Returns from MatchFirst(), MatchNext() more see before}
487   ERROR_BUFFER_OVERFLOW  = 303; // User OR internal buffer overflow
488   ERROR_BREAK            = 304; // A break character was received
489   ERROR_NOT_EXECUTABLE   = 305; // A file has E bit cleared
490 
491 { hunk types }
492   HUNK_UNIT      = 999 ;
493   HUNK_NAME      = 1000;
494   HUNK_CODE      = 1001;
495   HUNK_DATA      = 1002;
496   HUNK_BSS       = 1003;
497   HUNK_RELOC32   = 1004;
498   HUNK_RELOC16   = 1005;
499   HUNK_RELOC8    = 1006;
500   HUNK_EXT       = 1007;
501   HUNK_SYMBOL    = 1008;
502   HUNK_DEBUG     = 1009;
503   HUNK_END       = 1010;
504   HUNK_HEADER    = 1011;
505   HUNK_OVERLAY   = 1013;
506   HUNK_BREAK     = 1014;
507   HUNK_DREL32    = 1015;
508   HUNK_DREL16    = 1016;
509   HUNK_DREL8     = 1017;
510   HUNK_LIB       = 1018;
511   HUNK_INDEX     = 1019;
512   HUNK_RELOC32SHORT = 1020;
513   HUNK_RELRELOC32 = 1021;
514   HUNK_ABSRELOC16 = 1022;
515 
516 { hunk_ext sub-types }
517   EXT_SYMB       = 0;   // symbol table
518   EXT_DEF        = 1;   // relocatable definition
519   EXT_ABS        = 2;   // Absolute hunks
520   EXT_REF32      = 129; // 32bit absolute reference to symbol
521   EXT_ABSREF32   = 129;
522   EXT_COMMON     = 130; // 32bit absolute reference to common block
523   EXT_ABSCOMMON  = 130;
524   EXT_REF16      = 131; // 16bit relative reference to symbol
525   EXT_RELREF16   = 131;
526   EXT_REF8       = 132; // 8bit relative reference to symbol
527   EXT_RELREF8    = 132;
528   EXT_DEXT32     = 133; // 32 bit data releative reference
529   EXT_DEXT16     = 134; // 16 bit data releative reference
530   EXT_DEXT8      = 135; // 8 bit data releative reference
531   EXT_RELREF32   = 136; // 32bit relative reference to symbol
532   EXT_RELCOMMON  = 137; // 32bit relative reference to common block
533   EXT_ABSREF16   = 138;
534   EXT_ABSREF8    = 139;
535 
536 { Hunk flags }
537   HUNKB_ADVISORY = 29; // Hunk is ignored, if unknown to loader.
538   HUNKB_CHIP     = 30;
539   HUNKB_FAST     = 31;
540   HUNKF_ADVISORY = 1 shl HUNKB_ADVISORY;
541   HUNKF_CHIP     = 1 shl HUNKB_CHIP;
542   HUNKF_FAST     = 1 shl HUNKB_FAST;
543 
544 type
545   PDosInfo = ^TDosInfo;
546   TDosInfo = record
547     di_McName: BPTR;   // Network name of this machine; currently nil
548     di_DevInfo: BPTR;  // Device List
549     di_Devices: BPTR;  // Reserved
550     di_Handlers: BPTR; // Reserved
551     di_NetHand: BPTR;  // Reserved (actually resident segment list)
552     di_DevLock,        // do NOT access directly!
553     di_EntryLock,      // do NOT access directly!
554     di_DeleteLock: TSignalSemaphore; // do NOT access directly!
555   end;
556 
557 { All DOS processes have this structure }
558 { Create and Device Proc returns pointer to the MsgPort in this structure }
559 { dev_proc = Address(SmallInt(DeviceProc()) - SizeOf(Task)) }
560 
561   TExitProcedure = procedure(Arg: IPTR); cdecl;
562 
563   PProcess = ^TProcess;
564   TProcess = record
565     pr_Task: TTask;
566     pr_MsgPort: TMsgPort;        // This is BPTR address from DOS functions
567     pr_Pad: SmallInt;            // Remaining variables on 4 byte boundaries
568     pr_SegList: BPTR;            // Array of seg lists used by this process
569     pr_StackSize: LongInt;       // Size of process stack in bytes
570     pr_GlobVec: APTR;            // Global vector for this process (BCPL)
571     pr_TaskNum: LongInt;         // CLI task number of zero if not a CLI
572     pr_StackBase: BPTR;          // Ptr to high memory end of process stack
573     pr_Result2: STRPTR;          // Value of secondary result from last call
574     pr_CurrentDir: BPTR;         // Lock associated with current directory
575     pr_CIS: BPTR;                // Current CLI Input Stream
576     pr_COS: BPTR;                // Current CLI Output Stream
577     pr_ConsoleTask: APTR;        // Console handler process for current window
578     pr_FileSystemTask: APTR;     // File handler process for current drive
579     pr_CLI: BPTR;                // pointer to ConsoleLineInterpreter
580     pr_ReturnAddr: APTR;         // pointer to previous stack frame
tonull581     pr_PktWait: APTR;            // Function to be called when awaiting msg
582     pr_WindowPtr: APTR;          // Window for error printing
583     pr_HomeDir: BPTR;            // Home directory of executing program
584     pr_Flags: LongInt;           // flags telling dos about process
585     pr_ExitCode: TExitProcedure; // code to call on exit of program OR nil
586     pr_ExitData: IPTR;           // Passed as an argument to pr_ExitCode.
587     pr_Arguments: STRPTR;        // Arguments passed to the process at start
588     pr_LocalVars: TMinList;      // Local environment variables
589     pr_ShellPrivate: ULONG;      // for the use of the current shell
590     pr_CES: BPTR;                // Error stream - IF NULL, use pr_COS
591   end;
592 
593 { Flags for pr_Flags. (all PRIVATE) They mainly descibe what happens if the process
594   exits, i.e. which resources the process should clean itself. The flags
595   are self-explaining.}
596 const
597   PRB_FREESEGLIST     = 0;
598   PRB_FREECURRDIR     = 1;
599   PRB_FREECLI         = 2;
600   PRB_CLOSEINPUT      = 3;
601   PRB_CLOSEOUTPUT     = 4;
602   PRB_FREEARGS        = 5;
603   PRB_CLOSEERROR      = 6;
604   PRB_SYNCHRONOUS     = 7;
605   PRB_WAITINGFORCHILD = 8; // This one is subject to change!
606   PRB_NOTIFYONDEATH   = 9;
607 
608   PRF_FREESEGLIST     = 1 shl PRB_FREESEGLIST;
609   PRF_FREECURRDIR     = 1 shl PRB_FREECURRDIR;
610   PRF_FREECLI         = 1 shl PRB_FREECLI;
611   PRF_CLOSEINPUT      = 1 shl PRB_CLOSEINPUT;
612   PRF_CLOSEOUTPUT     = 1 shl PRB_CLOSEOUTPUT;
613   PRF_FREEARGS        = 1 shl PRB_FREEARGS;
614   PRF_CLOSEERROR      = 1 shl PRB_CLOSEERROR;
615   PRF_SYNCHRONOUS     = 1 shl PRB_SYNCHRONOUS;
616   PRF_WAITINGFORCHILD = 1 shl PRB_WAITINGFORCHILD; // This one is subject to change!
617   PRF_NOTIFYONDEATH   = 1 shl PRB_NOTIFYONDEATH;
618 
619 { The long SmallInt address (BPTR) of this structure is returned by
620   Open() and other routines that return a file.  You need only worry
621   about this struct to do async io's via PutMsg() instead of
622   standard file system calls }
623 type
624   PFileHandle = ^TFileHandle;
625   TFileHandle = record
626     fh_Flags: ULONG;   { EXEC message        }
627     fh_Port: PMsgPort;   { Reply port for the packet }
628     fh_Type: PMsgPort;   { Port to do PutMsg() to Address is negative if a plain file }
629 
630     fh_Buf: BPTR;
631     fh_Pos: LongInt;
632     fh_End: LongInt;
633 
634     fh_Func1: LongInt;
635     fh_Func2: LongInt;
636     fh_Func3: LongInt;
637     fh_Arg1:  LongInt;
638     fh_Arg2: APTR;
639     fh_Size: ULONG; // Size of buffered io buffer
640     fh_Buf2: BPTR;  // Always the same as fh_Buf
641   end;
642 
643 { This is the extension to EXEC Messages used by DOS }
644 
645   PDosPacket = ^TDosPacket;
646   TDosPacket = record
647     dp_Link : PMessage;     // Pointer to a standard exec message.
648     dp_Port : PMsgPort;     // Reply-Port of that packet. Must be filled in each send.
649     case SmallInt of
650     0 : (
651       dp_Action : LongInt;
652       dp_Status : LongInt;
653       dp_Status2 : LongInt;
654       dp_BufAddr : LongInt;
655     );
656     1 : (
657       dp_Type : LongInt;      { See ACTION_... below and
658                               * 'R' means Read, 'W' means Write to the
659                               * file system }
660       dp_Res1 : LongInt;      { For file system calls this is the result
661                               * that would have been returned by the
662                               * function, e.g. Write ('W') returns actual
663                               * length written }
664       dp_Res2 : LongInt;      { For file system calls this is what would
665                               * have been returned by IoErr() }
666       dp_Arg1 : LongInt;
667       dp_Arg2 : LongInt;
668       dp_Arg3 : LongInt;
669       dp_Arg4 : LongInt;
670       dp_Arg5 : LongInt;
671       dp_Arg6 : LongInt;
672       dp_Arg7 : LongInt;
673     );
674   end;
675 
676 const
677 { Packet types dp_Type }
678   ACTION_NIL                  = 0;
679   ACTION_STARTUP              = 0;
680   ACTION_GET_BLOCK            = 2;    // OBSOLETE
681   ACTION_SET_MAP              = 4;
682   ACTION_DIE                  = 5;
683   ACTION_EVENT                = 6;
684   ACTION_CURRENT_VOLUME       = 7;
685   ACTION_LOCATE_OBJECT        = 8;
686   ACTION_RENAME_DISK          = 9;
687   ACTION_FREE_LOCK            = 15;
688   ACTION_DELETE_OBJECT        = 16;
689   ACTION_RENAME_OBJECT        = 17;
690   ACTION_MORE_CACHE           = 18;
691   ACTION_COPY_DIR             = 19;
692   ACTION_WAIT_CHAR            = 20;
693   ACTION_SET_PROTECT          = 21;
694   ACTION_CREATE_DIR           = 22;
695   ACTION_EXAMINE_OBJECT       = 23;
696   ACTION_EXAMINE_NEXT         = 24;
697   ACTION_DISK_INFO            = 25;
698   ACTION_INFO                 = 26;
699   ACTION_FLUSH                = 27;
700   ACTION_SET_COMMENT          = 28;
701   ACTION_PARENT               = 29;
702   ACTION_TIMER                = 30;
703   ACTION_INHIBIT              = 31;
704   ACTION_DISK_TYPE            = 32;
705   ACTION_DISK_CHANGE          = 33;
706   ACTION_SET_DATE             = 34;
707   ACTION_SAME_LOCK            = 40;
708 
709   ACTION_WRITE                = $57;  // 'W'
710   ACTION_READ                 = $52;  // 'R'
711 
712   ACTION_SCREEN_MODE          = 994;
713   ACTION_CHANGE_SIGNAL        = 995;
714   ACTION_READ_RETURN          = 1001;
715   ACTION_WRITE_RETURN         = 1002;
716   ACTION_FINDUPDATE           = 1004;
717   ACTION_FINDINPUT            = 1005;
718   ACTION_FINDOUTPUT           = 1006;
719   ACTION_END                  = 1007;
720   ACTION_SEEK                 = 1008;
721   ACTION_FORMAT               = 1020;
722   ACTION_MAKE_LINK            = 1021;
723   ACTION_SET_FILE_SIZE        = 1022;
724   ACTION_WRITE_PROTECT        = 1023;
725   ACTION_READ_LINK            = 1024;
726   ACTION_FH_FROM_LOCK         = 1026;
727   ACTION_IS_FILESYSTEM        = 1027;
728   ACTION_CHANGE_MODE          = 1028;
729   {}
730   ACTION_COPY_DIR_FH          = 1030;
731   ACTION_PARENT_FH            = 1031;
732   ACTION_EXAMINE_ALL          = 1033;
733   ACTION_EXAMINE_FH           = 1034;
734   ACTION_EXAMINE_ALL_END      = 1035;
735   ACTION_SET_OWNER            = 1036;
736 
737   ACTION_LOCK_RECORD          = 2008;
738   ACTION_FREE_RECORD          = 2009;
739 
740   ACTION_ADD_NOTIFY           = 4097;
741   ACTION_REMOVE_NOTIFY        = 4098;
742 { Tell a file system to serialize the current volume. This is typically
743   done by changing the creation date of the disk. This packet does not take
744   any arguments.}
745   ACTION_SERIALIZE_DISK       = 4200;
746 
747 type
748 { A Packet does not require the Message to be before it in memory, but
749   for convenience it is useful to associate the two.
750   Also see the function init_std_pkt for initializing this structure }
751   PStandardPacket = ^TStandardPacket;
752   TStandardPacket = record
753     sp_Msg: TMessage;
754     sp_Pkt: TDosPacket;
755   end;
756 
757 const
758 { types for initial packets to shells from run/newcli/execute/system.
759   NOTE: AROS doesn't use startup packets. This will ONLY make a difference
760          for shell writers...}
761   RUN_EXECUTE           =  -1;
762   RUN_SYSTEM            =  -2;
763   RUN_SYSTEM_ASYNCH     =  -3;
764 
765 type
766 { ONLY to be allocated by DOS! }
767   PCliProcList = ^TCliProcList;
768   TCliProcList = record
769     cpl_Node: TMinNode;
770     cpl_First: LongInt;      { number of first entry in array }
771     cpl_Array: array[0..0] of PMsgPort;
772                          { [0] is max number of CLI's in this entry (n)
773                            [1] is CPTR to process id of CLI cpl_First
774                            [n] is CPTR to process id of CLI cpl_First+n-1}
775   end;
776 
777 { structure for the Dos resident list.  Do NOT allocate these, use       }
778 { AddSegment(), and heed the warnings in the autodocs!                   }
779 type
780   PSegment = ^TSegment;
781   TSegment = record
782     seg_Next: BPTR;    // Pointer to next segment.
783     seg_UC: LongInt;   // Usage count/type
784     seg_Seg: BPTR;     // Actual Segment
785     seg_Name: array[0..3] of Char;  // actually the first 4 chars of BSTR name }
786   end;
787 
788 const
789   CMD_SYSTEM    =  -1;
790   CMD_INTERNAL  =  -2;
791   CMD_DISABLED  =  -999;
792 
793 { DOS Processes started from the CLI via RUN or NEWCLI have this additional
794  * set to data associated with them }
795 type
796   PCommandLineInterface = ^TCommandLineInterface;
797   TCommandLineInterface = record
798     cli_Result2: LongInt;      // Value of IoErr from last command
799     cli_SetName: BSTR;         // Name of current directory
800     cli_CommandDir: BPTR;      // Lock associated with command directory
801     cli_ReturnCode: LongInt;   // Return code from last command
802     cli_CommandName: BSTR;     // Name of current command
803     cli_FailLevel: LongInt;    // Fail level (set by FAILAT)
804     cli_Prompt: BSTR;          // Current prompt (set by PROMPT)
805     cli_StandardInput: BPTR;   // Default (terminal) CLI input
806     cli_CurrentInput: BPTR;    // Current CLI input
807     cli_CommandFile: BSTR;     // Name of EXECUTE command file
808     cli_Interactive: LongInt;  // Boolean; True if prompts required
809     cli_Background: LongInt;   // Boolean; True if CLI created by RUN
810     cli_CurrentOutput: BPTR;   // Current CLI output
811     cli_DefaultStack: LongInt; // Stack size to be obtained in long words
812     cli_StandardOutput: BPTR;  // Default (terminal) CLI output
813     cli_Module: BPTR;          // SegList of currently loaded command
814 {$ifdef aros}
815     cli_StandardError: BPTR;   // Standard/Default Error file. PFileLock
816 {$endif}
817   end;
818 
819 const
820 // CLI_DEFAULTSTACK_UNIT * cli_DefaultStack = stack in bytes
821   CLI_DEFAULTSTACK_UNIT = SizeOf(IPTR);
822 
823 type
824 {$ifdef aros}
825   PDosListAROSExt = ^TDosListAROSExt;
826   TDosListAROSExt = record
827     dol_DevName: STRPTR;
828     dol_Device: PDevice;
829     dol_Unit: PUnit;
830   end;
831 {$endif}
832 { This structure can take on different values depending on whether it is
833  * a device, an assigned directory, or a volume.  Below is the structure
834  * reflecting volumes only.  Following that is the structure representing
835  * only devices.
836  }
837 
838 { structure representing a volume }
839 
840   PDeviceList = ^TDeviceList;
841   TDeviceList = record
842     dl_Next: BPTR;       // bptr to next device list
843     dl_Type: LongInt;    // see DLT below
844     dl_Task: PMsgPort;   // ptr to handler task
845     dl_Lock: BPTR;       // not for volumes
846     dl_VolumeDate: TDateStamp; // creation date
847     dl_LockList: BPTR;    // outstanding locks
848     dl_DiskType: LongInt; // 'DOS', etc
849     dl_unused: BPTR;
850     dl_Name: BSTR;        // bptr to bcpl name
851   end;
852 
853 { device structure (same as the DeviceNode structure in filehandler.h) }
854   PDevInfo = ^TDevInfo;
855   TDevInfo = record
856     dvi_Next: BPTR;
857     dvi_Type: LongInt;
858     dvi_Task: PMsgPort;
859     dvi_Lock: BPTR;
860     dvi_Handler: BSTR;
861     dvi_StackSize: LongInt;
862     dvi_Priority: LongInt;
863     dvi_Startup: BPTR;
864 {$ifdef aros}
865     dvi_NoAROS4: array[0..1] of BPTR;
866 {$else}
867     dvi_SegList: BPTR;
868     dvi_GlobVec: BSTR;
869 {$endif}
870     dvi_Name: BSTR;
871   end;
872 
873 const
874 { Dos list scanning and locking modes as used in LockDosList()
875   Specify either LDF_READ, if you want a non-exclusive lock, or LDF_WRITE,
876   if you want an exclusive lock (i.e. if you want to modify the list).}
877   LDB_READ      =  0;
878   LDB_WRITE     =  1;
879 // Specify which list(s) to lock.
880   LDB_DEVICES   =  2;
881   LDB_VOLUMES   =  3;
882   LDB_ASSIGNS   =  4;
883   LDB_ENTRY     =  5;
884   LDB_DELETE    =  6;
885 
886   LDF_READ      =  1 shl LDB_READ;
887   LDF_WRITE     =  1 shl LDB_WRITE;
888   LDF_DEVICES   =  1 shl LDB_DEVICES;
889   LDF_VOLUMES   =  1 shl LDB_VOLUMES;
890   LDF_ASSIGNS   =  1 shl LDB_ASSIGNS;
891   LDF_ENTRY     =  1 shl LDB_ENTRY;
892   LDF_DELETE    =  1 shl LDB_DELETE;
893 { actually all but LDF_ENTRY (which is used for internal locking) }
894   LDF_ALL       =  (LDF_DEVICES or LDF_VOLUMES or LDF_ASSIGNS);
895 
896 type
897 { Used for assigns that point to multiple directories. }
898 
899   PAssignList = ^TAssignList;
900   TAssignList = record
901     al_Next: PAssignList; // Pointer to next assign node.
902     al_Lock: BPTR;        // (struct FileLock *) Lock of on of the directories.
903   end;
904 
905 { combined structure for devices, assigned directories, volumes }
906   PDosList = ^TDosList;
907   TDosList = record
908     dol_Next: BPTR;           {    bptr to next device on list }
909     dol_Type: LongInt;        {    see DLT below }
910     dol_Task: PMsgPort;       {    ptr to handler task }
911     dol_Lock: BPTR;
912     case SmallInt of
913       0 :(
914         dol_Handler : record
915           dol_Handler: BSTR;      {    file name to load IF seglist is null }
916           dol_StackSize,              {    stacksize to use when starting process }
917           dol_Priority: LongInt;               {    task priority when starting process }
918           dol_Startup: BPTR;   {    startup msg: FileSysStartupMsg for disks }
919           dol_SegList,                {    already loaded code for new task }
920           dol_GlobVec: BPTR;      {    BCPL global vector to use when starting }
921         end;
922       );
923       1 :(
924         dol_Volume: record
925           dol_VolumeDate: TDateStamp; {    creation date }
926           dol_LockList: BPTR;       {    outstanding locks }
927           dol_DiskType: LongInt;    {    'DOS', etc }
928           dol_Unused: BPTR
929         end;
930       );
931       2 :(
932         dol_assign:  record
933           dol_AssignName: STRPTR;        {    name for non-OR-late-binding assign }
934           dol_List: PAssignList;   {    for multi-directory assigns (regular) }
935         end;
936       );
937       3 :(
938         {$ifdef CPU64}
939         dol_Misc: array[0..39] of Byte;
940         {$else}
941         dol_Misc: array[0..23] of Byte;
942         {$endif}
943         dol_Name: BSTR;           {    bptr to bcpl name }
944       );
945     end;
946 
947 
948 const
949 
950 { definitions for dl_Type }
951   DLT_DEVICE          = 0;
952   DLT_DIRECTORY       = 1;
953   DLT_VOLUME          = 2;
954   DLT_LATE            = 3;  // late-binding assign
955   DLT_NONBINDING      = 4;  // non-binding assign
956   DLT_PRIVATE         = -1; // for internal use only
957 
958 { structure return by GetDeviceProc() }
959 type
960   PDevProc = ^TDevProc;
961   TDevProc = record
962     dvp_Port: PMsgPort;
963     dvp_Lock: BPTR;         // PFileLock
964     dvp_Flags: LongInt;     // see below (DVPF_*)
965     dvp_DevNode: PDosList;  // Private
966   end;
967 
968 const
969 { definitions for dvp_Flags }
970   DVPB_UNLOCK   =  0;
971   DVPB_ASSIGN   =  1;
972   DVPF_UNLOCK   =  1 shl DVPB_UNLOCK;
973   DVPF_ASSIGN   =  1 shl DVPB_ASSIGN;
974 
975 { Types for fib_DirEntryType.  NOTE that both USERDIR and ROOT are
976   directories, and that directory/file checks should use <0 and >=0.
977   This is not necessarily exhaustive!  Some handlers may use other
978   values as needed, though <0 and >=0 should remain as supported as
979   possible.}
980   ST_ROOT       =  1 ; // Root directory of filesystem
981   ST_USERDIR    =  2 ; // Normal directory
982   ST_SOFTLINK   =  3 ; // Soft link (may be a file or directory)
983   ST_LINKDIR    =  4 ; // Hard link to a directory
984   ST_FILE       =  -3; // Plain file
985   ST_LINKFILE   =  -4; // Hard link to a file
986   ST_PIPEFILE   =  -5; // File is a pipe
987 
988 type
989 { a lock structure, as returned by Lock() or DupLock() }
990   PFileLock = ^TFileLock;
991   TFileLock = record
992     fl_Link: BPTR;      // bcpl pointer to next lock
993     fl_Key: IPTR;       // disk block number
994     fl_Access: LongInt; // exclusive or shared
995     fl_Task: PMsgPort;  // handler task's port
996     fl_Volume: BPTR;    // bptr to a DeviceList
997   end;
998 
999 
1000 { Structure (as used in ExAll()), containing information about a file. This
1001   structure is only as long as it need to be. If is for example ED_SIZE was
1002   specified, when calling ExAll(), this structure only consists of the fields
1003   ed_Name through ed_Size. Therefore you can use the ED_ definitions below
1004   as longword offsets into this structure.}
1005 type
1006   PExAllData = ^TExAllData;
1007   TExAllData = record
1008     ed_Next: PExAllData;
1009     ed_Name: PChar;        // Name of the file
1010     ed_Type: LongInt;      // Type of File
1011     ed_Size,               // Size of File
1012     ed_Prot,               // Protection Bits
1013 { The following three fields are de facto an embedded datestamp
1014   structure (see <dos/dos.h>), which describes the last modification date.}
1015     ed_Days,
1016     ed_Mins,
1017     ed_Ticks    : ULONG;
1018 
1019     ed_Comment: PChar;     // The file comment
1020     ed_OwnerUID,           // The owner ID
1021     ed_OwnerGID : Word;    // the group-owner ID
1022   end;
1023 
1024 { Type argument for ExAll(). Each number includes the information of all
1025   lower numbers, too. If you specify for example ED_SIZE, you will get
1026   information about name, type and the size of a file. Note that all
1027   filehandlers must handle all types up to ED_OWNER. If they do not support
1028   a type, they must return ERROR_WRONG_NUMBER. Currently
1029   that means, if a value higher than ED_OWNER is specified, filehandlers
1030   must fail with this error.}
1031 const
1032   ED_NAME        = 1; // Filename.
1033   ED_TYPE        = 2; // Type of file.
1034   ED_SIZE        = 3; // Size of file.
1035   ED_PROTECTION  = 4; // Protection bits.
1036   ED_DATE        = 5; // Last modification date.
1037   ED_COMMENT     = 6; // Addtional file comment.
1038   ED_OWNER       = 7; // Owner information.
1039 
1040 { Structure as used for controlling ExAll(). Allocate this structure by using
1041   AllocDosObject(DOS_EXALLCONTROL,...) only. All fields must be initialized
1042   to 0, before using this structure. (AllocDosObject() does that for you.)
1043   After calling ExAll() the first time, this structure is READ-ONLY. }
1044 type
1045   PExAllControl = ^TExAllControl;
1046   TExAllControl = record
1047     eac_Entries: ULONG;     // number of entries returned in buffer
1048     eac_LastKey: IPTR;      // Don't touch inbetween linked ExAll calls!
1049     eac_MatchString: PChar; // wildcard string for pattern match OR nil
1050     eac_MatchFunc: PHook;   // optional private wildcard FUNCTION
endnull1051   end;
1052 
1053 { The disk "environment" is a longword array that describes the
1054  * disk geometry.  It is variable sized, with the length at the beginning.
1055  * Here are the constants for a standard geometry.}
1056 type
1057   PDosEnvec = ^TDosEnvec;
1058   TDosEnvec = record
1059     de_TableSize: IPTR;      // Size of this structure. Must be at least 11 (DE_NUMBUFFERS).
1060     de_SizeBlock: IPTR;      // Size in longwords of a block on the disk.
1061     de_SecOrg: IPTR;         // Unused. Must be 0 for now.
1062     de_Surfaces: IPTR;       // Number of heads/surfaces in drive.
1063     de_SectorPerBlock: IPTR; // Unused. Must be 1 for now.
1064     de_BlocksPerTrack: IPTR; // blocks per track. drive specific
1065     de_Reserved: IPTR;       // DOS reserved blocks at start of partition.
1066     de_PreAlloc: IPTR;       // DOS reserved blocks at end of partition
1067     de_Interleave: IPTR;     // usually 0
1068     de_LowCyl: IPTR;         // starting cylinder. typically 0
1069     de_HighCyl: IPTR;        // max cylinder. drive specific
1070     de_NumBuffers: IPTR;     // Initial # DOS of buffers.
1071     de_BufMemType: IPTR;     // type of mem to allocate for buffers
1072     de_MaxTransfer: IPTR;    // Max number of bytes to transfer at a time
1073     de_Mask: IPTR;           // Address Mask to block out certain memory
1074     de_BootPri: LongInt;     // Boot priority for autoboot
1075     de_DosType: IPTR;        // ASCII (HEX) string showing filesystem type
1076     de_Baud: IPTR;           // Baud rate for serial handler
1077     de_Control: IPTR;        // Control SmallInt for handler/filesystem
1078     de_BootBlocks: IPTR;     // Number of blocks containing boot code
1079   end;
1080 
1081 const
1082 { The following constants are longword offsets, which point into a filehandler
1083   structure (like the one above). For more information about the meaning
1084   of these constants see the structure above. }
1085   DE_TABLESIZE        = 0;    // standard value is 11 }
1086   DE_SIZEBLOCK        = 1;    // in longwords: standard value is 128 }
1087   DE_SECORG           = 2;    // not used; must be 0 }
1088   DE_NUMHEADS         = 3;    // # of heads (surfaces). drive specific }
1089   DE_SECSPERBLK       = 4;    // not used; must be 1 }
1090   DE_BLKSPERTRACK     = 5;    // blocks per track. drive specific }
1091   DE_RESERVEDBLKS     = 6;    // unavailable blocks at start.   usually 2 }
1092   DE_PREFAC           = 7;    // not used; must be 0 }
1093   DE_INTERLEAVE       = 8;    // usually 0 }
1094   DE_LOWCYL           = 9;    // starting cylinder. typically 0 }
1095   DE_UPPERCYL         = 10;   // max cylinder.  drive specific }
1096   DE_NUMBUFFERS       = 11;   // starting # of buffers.  typically 5 }
1097   DE_MEMBUFTYPE       = 12;   // type of mem to allocate for buffers. }
1098   DE_BUFMEMTYPE       = 12;   // same as above, 1 is public, 3 is chip, 5 is fast }
1099   DE_MAXTRANSFER      = 13;   // Max number bytes to transfer at a time }
1100   DE_MASK             = 14;   // Address Mask to block out certain memory }
1101   DE_BOOTPRI          = 15;   // Boot priority for autoboot }
1102   DE_DOSTYPE          = 16;   // ASCII (HEX) string showing filesystem type;
1103   DE_BAUD             = 17;   // Baud rate for serial handler }
1104   DE_CONTROL          = 18;   // Control SmallInt for handler/filesystem }
1105   DE_BOOTBLOCKS       = 19;   // Number of blocks containing boot code }
1106 
1107 
1108 { This is the message that is passed to a file handler during startup
1109   in the DeviceNode->dn_Startup field. It is not used in AROS DOS handlers
1110   as they are now Device based, and the information is passed in during
1111   OpenDevice(), however this needs to be stored for late opening
1112   handlers.}
1113 type
1114   PFileSysStartupMsg = ^TFileSysStartupMsg;
1115   TFileSysStartupMsg = record
1116     fssm_Unit: IPTR;      // exec unit number for this device
1117     fssm_Device: BSTR;    // null terminated bstring to the device name
1118     fssm_Environ: BPTR;   // ptr to environment table (see above)
1119     fssm_Flags: ULONG;    // flags for OpenDevice()
1120   end;
1121 
1122 
1123 { This is an unwound version of the DosList structure.
1124   This is the version for a DOS "device" DLT_DEVICE.
1125   It is essentially the same structure as DevInfo.
1126   For AROS this is notably different, as filehandlers are no longer
1127   DOS tasks (ie Processes), some of the fields here have no purpose
1128   and are ignored. The only fields retained are the dn_Next, dn_Type,
1129   dn_Startup and dn_Handler fields.}
1130   PDeviceNode = ^TDeviceNode;
1131   TDeviceNode = record
1132     dn_Next: BPTR;         { singly linked list }
1133     dn_Type: ULONG;        { always 0 for dos "devices" }
1134     dn_Task: PMsgPort;     { standard dos "task" field.  If this is
1135                                      * null when the node is accesses, a task
1136                                      * will be started up }
1137     dn_Lock: BPTR;         { not used for devices -- leave null }
1138     dn_Handler: BSTR;         { filename to loadseg (if seglist is null) }
1139     dn_StackSize: ULONG;        { stacksize to use when starting task }
1140     dn_Priority: LongInt;      { task priority when starting task }
1141     dn_Startup: BPTR;         { startup msg: FileSysStartupMsg for disks }
1142     dn_SegList: BPTR;         { code to run to start new task (if necessary).
1143                                      * if null then dn_Handler will be loaded. }
1144     dn_GlobalVec: BPTR; { BCPL global vector to use when starting
1145                              * a task.  -1 means that dn_SegList is not
1146                              * for a bcpl program, so the dos won't
1147                              * try and construct one.  0 tell the
1148                              * dos that you obey BCPL linkage rules,
1149                              * and that it should construct a global
1150                              * vector for you.
1151                              }
1152     dn_Name: BSTR;         { the node name, e.g. '\3','D','F','3' }
1153   end;
1154 
1155 type
1156 {  General notification structure as passed to StartNotify() and EndNotify().
1157    After passing it to StartNotify() the first time, this structure becomes
1158    READ-ONLY! }
1159 
1160   PNotifyRequest = ^TNotifyRequest;
1161   TNotifyRequest = record
1162     nr_Name: STRPTR;        // Name of the watched file.
1163     nr_FullName: STRPTR;    // Fully qualified name of the watched file. This is READ-ONLY!
1164     nr_UserData: IPTR;      // Fill in with your own data.
1165     nr_Flags: LongWord;     // Flags: (NRB_*)
1166                                 // The following case specified the way to notify the application, if
1167     nr_stuff: record            // the watched file changes. IF NRF_SEND_MESSAGE is set, nr_Msg is used,
1168     case SmallInt of            // when NRF_SEND_SIGNAL is set, nr_Signal is used.
1169        0: ( nr_Msg: record
1170             nr_Port: PMsgPort; // Port to send message to.
1171          end );
1172        1 : ( nr_Signal: record
1173             nr_Task: pTask;              // Task to notify.
1174             nr_SignalNum: Byte;          // Signal number to set.
1175             nr_pad: array[0..2] of Byte; // PRIVATE
1176          end );
1177     end;
1178     nr_Reserved: array[0..3] of LongWord; // PRIVATE! Set to 0 for now.
1179     nr_MsgCount: LongWord;                // Number of unreplied messages.
1180     nr_Handler: PMsgPort;                 // Filesystem task/device. Used by EndNotify()
1181     end;
1182 
1183    PNotifyMessage = ^TNotifyMessage;
1184    TNotifyMessage = record
1185     nm_ExecMessage: TMessage;
1186     nm_Class: LongWord;          // Class: NOTIFY_CLASS
1187     nm_Code: Word;               // Code: NOTIFY_CODE
1188     nm_NReq: PNotifyRequest;     // The notify structure that was passed to StartNotify(). Read-Only
1189     nm_DoNotTouch,               // like it says!  For use by handlers
1190     nm_DoNotTouch2 : LongWord;   // dito
1191    end;
1192 
1193 
1194 const
1195 // The two following flags specify by which means the watching task is to be notified.
1196   NRB_SEND_MESSAGE      =  0; // Send a message to the specified message port.
1197   NRB_SEND_SIGNAL       =  1; // Set a signal of the specified task.
1198   NRB_WAIT_REPLY        =  3; // Wait for a reply by the application before going on with watching?
1199   NRB_NOTIFY_INITIAL    =  4; // Notify if the file/directory exists when the notification request is posted
1200 
1201 // Flag Values for TNotifyRequest.nr_Flags
1202   NRF_SEND_MESSAGE      =  1 shl NRB_SEND_MESSAGE;
1203   NRF_SEND_SIGNAL       =  1 shl NRB_SEND_SIGNAL;
1204   NRF_WAIT_REPLY        =  1 shl NRB_WAIT_REPLY;
1205   NRF_NOTIFY_INITIAL    =  1 shl NRB_NOTIFY_INITIAL;
1206 
1207 // The following flags are for use by handlers only!
1208   NR_HANDLER_FLAGS      =  $ffff0000;
1209   NRB_MAGIC             =  31;
1210   NRF_MAGIC             =  1 shl NRB_MAGIC;
1211 
1212 // nm_Class. Do not use, yet.
1213   NOTIFY_CLASS  =  $40000000;
1214 
1215 //nm_Code. Do not use, yet.
1216    NOTIFY_CODE   =  $1234;
1217 
1218 {   *********************************************************************
1219  *
1220  * The CSource data structure defines the input source for "ReadItem()"
1221  * as well as the ReadArgs call.  It is a publicly defined structure
1222  * which may be used by applications which use code that follows the
1223  * conventions defined for access.
1224  *
1225  * When passed to the dos.library functions, the value passed as
1226  * struct *CSource is defined as follows:
1227  *      if ( CSource == 0)      Use buffered IO "ReadChar()" as data source
1228  *      else                    Use CSource for input character stream
1229  *
1230  * The following two pseudo-code routines define how the CSource structure
1231  * is used:
1232  *
1233  * long CS_ReadChar( struct CSource *CSource )
1234  *
1235  *      if ( CSource == 0 )     return ReadChar();
1236  *      if ( CSource->CurChr >= CSource->Length )       return ENDSTREAMCHAR;
1237  *      return CSource->Buffer[ CSource->CurChr++ ];
1238  *
1239  *
1240  * BOOL CS_UnReadChar( struct CSource *CSource )
1241  *
1242  *      if ( CSource == 0 )     return UnReadChar();
1243  *      if ( CSource->CurChr <= 0 )     return FALSE;
1244  *      CSource->CurChr--;
1245  *      return TRUE;
1246  *
1247  *
1248  * To initialize a struct CSource, you set CSource->CS_Buffer to
1249  * a string which is used as the data source, and set CS_Length to
1250  * the number of characters in the string.  Normally CS_CurChr should
1251  * be initialized to ZERO, or left as it was from prior use as
1252  * a CSource.
1253  *
1254  *********************************************************************}
1255 
1256 type
1257 // This structure emulates an input stream by using a buffer.
1258   PCSource = ^TCSource;
1259   TCSource = record
1260     CS_Buffer: PChar;   // The buffer, which contains the stream. In most cases this may be nil,
1261                         // in which case the current input stream is used.
1262     CS_Length,
1263     CS_CurChr: LongInt;
1264   end;
1265 
1266 {   *********************************************************************
1267  *
1268  * The RDArgs data structure is the input parameter passed to the DOS
1269  * ReadArgs() function call.
1270  *
1271  * The RDA_Source structure is a CSource as defined above;
1272  * if RDA_Source.CS_Buffer is non-null, RDA_Source is used as the input
1273  * character stream to parse, else the input comes from the buffered STDIN
1274  * calls ReadChar/UnReadChar.
1275  *
1276  * RDA_DAList is a private address which is used internally to track
1277  * allocations which are freed by FreeArgs().  This MUST be initialized
1278  * to NULL prior to the first call to ReadArgs().
1279  *
1280  * The RDA_Buffer and RDA_BufSiz fields allow the application to supply
1281  * a fixed-size buffer in which to store the parsed data.  This allows
1282  * the application to pre-allocate a buffer rather than requiring buffer
1283  * space to be allocated.  If either RDA_Buffer or RDA_BufSiz is NULL,
1284  * the application has not supplied a buffer.
1285  *
1286  * RDA_ExtHelp is a text string which will be displayed instead of the
1287  * template string, if the user is prompted for input.
1288  *
1289  * RDA_Flags bits control how ReadArgs() works.  The flag bits are
1290  * defined below.  Defaults are initialized to ZERO.
1291  *
1292  *********************************************************************}
1293 { The main structure used for ReadArgs(). It contains everything needed for
1294    ReadArgs() handling. Allocate this structure with AllocDosObject().}
1295   PRDArgs = ^TRDArgs;
1296   TRDArgs = record
1297     RDA_Source: TCSource;    // Select input source use this structure as source
1298                              // for parsing, otherwise use DosInput() as source.
1299     RDA_DAList: IPTR;        // PRIVATE. Must be initialized to 0
1300         {The next two fields allow an application to supply a buffer to be parsed
1301        to ReadArgs(). If either of these fields is 0, ReadArgs() allocates this
1302        buffer itself.}
1303     RDA_Buffer: PChar;       // Pointer to buffer. May be nil.
1304     RDA_BufSiz: LongInt;     // Size of the supplied RDA_Buffer. May be 0.
1305     RDA_ExtHelp: PChar;      // Additional help, if user requests it, by supplying '?' as argument.
1306     RDA_Flags: LongInt;      // Flags for any required control (RDAF_?)
1307   end;
1308 
1309 const
1310   RDAB_STDIN     = 0; // Use Input() instead of the supplied command line.
1311   RDAB_NOALLOC   = 1; // If set, do not allocate extra string space.
1312   RDAB_NOPROMPT  = 2; // Do not prompt for input.
1313 
1314   RDAF_STDIN     = 1 shl RDAB_STDIN;
1315   RDAF_NOALLOC   = 1 shl RDAB_NOALLOC;
1316   RDAF_NOPROMPT  = 1 shl RDAB_NOPROMPT;
1317 
1318 { Maximum number of template keywords which can be in a template passed
1319   to ReadArgs(). IMPLEMENTOR NOTE - must be a multiple of 4.}
1320   MAX_TEMPLATE_ITEMS = 100;
1321 
1322 { Maximum number of MULTIARG items (/M) returned by ReadArgs(), before
1323   an ERROR_LINE_TOO_LONG.  These two limitations are due to stack
1324   usage.  Applications should allow "a lot" of stack to use ReadArgs().
1325   This may change in the future}
1326   MAX_MULTIARGS          = 128;
1327 
1328 const
1329 {  LockRecord() and LockRecords() locking modes. EXCLUSIVE modes mean that
1330    nobody else is allowed to lock a specific record, which is allowed, when
1331    locking with SHARED mode. When using IMMED modes, the timeout is ignored. }
1332   REC_EXCLUSIVE          = 0;
1333   REC_EXCLUSIVE_IMMED    = 1;
1334   REC_SHARED             = 2;
1335   REC_SHARED_IMMED       = 3;
1336 
1337 // Structure as passed to LockRecords() and UnLockRecords().
1338 type
1339   PRecordLock = ^TRecordLock;
1340   TRecordLock = record
1341     rec_FH    : BPTR;     // PFileHandle The file to get the current record from.
1342     rec_Offset,           // The offset, the current record should start.
1343     rec_Length,           // The length of the current record.
1344     rec_Mode  : LongWord; // The mode od locking (REC_*).
1345   end;
1346 
1347 { This structure describes a local variable. The list is normally held in
1348   Process^.pr_LocalVars. Note that this structure is READ-ONLY!
1349   Allocate it with SetVar(). }
1350 type
1351   PLocalVar = ^TLocalVar;
1352   TLocalVar = record
1353     lv_Node: TNode;     // Standard node structure as defined in Exec
1354     lv_Flags: Word;
1355     lv_Value: STRPTR;   // The contents of the variable.
1356     lv_Len: LongWord;   // The length of the contents.
1357   end;
1358 
1359 { The lv_Flags bits are available to the application.  The unused
1360   lv_Node.ln_Pri bits are reserved for system use.}
1361 const
1362 // bit definitions for lv_Node.ln_Type:
1363   LV_VAR     = 0; // This is a variable.
1364   LV_ALIAS   = 1; // This is an alias.
1365 { This flag may be or'ed into lv_Node.ln_Type. It means that dos.library
1366   should ignore this entry.}
1367   LVB_IGNORE = 7;    // ignore this entry on GetVar, etc
1368   LVF_IGNORE = 1 shl LVB_IGNORE;
1369 
1370 { definitions of flags passed to GetVar()/SetVar()/DeleteVar()
1371   bit defs to be OR'ed with the type:
1372   item will be treated as a single line of text unless BINARY_VAR is used }
1373   GVB_GLOBAL_ONLY    =  8;      //The variable is not to be used locally.
1374   GVB_LOCAL_ONLY     =  9;      // The variable is not to be used globally.
1375   GVB_BINARY_VAR     = 10;     // The variable is a binary variable. lv_Value points to binary data.
1376   GVB_DONT_NULL_TERM = 11;     // lv_Value is not null-terminated. This is only allowed, if GVB_BINARY_VAR is also set.
1377   GVB_SAVE_VAR       = 12;    // This flag tells dos to save the variable to ENVARC: too.
1378   GVF_GLOBAL_ONLY    = 1 shl GVB_GLOBAL_ONLY;
1379   GVF_LOCAL_ONLY     = 1 shl GVB_LOCAL_ONLY;
1380   GVF_BINARY_VAR     = 1 shl GVB_BINARY_VAR;
1381   GVF_DONT_NULL_TERM = 1 shl GVB_DONT_NULL_TERM;
1382   GVF_SAVE_VAR       = 1 shl GVB_SAVE_VAR;
1383 
1384 const
1385 {   ***************************************************************************}
1386 {    definitions for the System() call }
1387 
1388   SYS_Dummy       = (TAG_USER + 32);
1389   SYS_Input       = (SYS_Dummy + 1); // specifies the input filehandle
1390   SYS_Output      = (SYS_Dummy + 2); // specifies the output filehandle
1391   SYS_Asynch      = (SYS_Dummy + 3); // run asynch, close input/output on exit(!)
1392   SYS_UserShell   = (SYS_Dummy + 4); // send to user shell instead of boot shell
1393   SYS_CustomShell = (SYS_Dummy + 5); // send to a specific shell (data is name)
1394 {$ifdef aros}
1395   SYS_Error       = (SYS_Dummy + 10); // (BPTR/struct FileHandle *) Output filehandle.
1396   SYS_ScriptInput = (SYS_Dummy + 11); // Filehandle to script to execute
1397   SYS_Background  = (SYS_Dummy + 12); // (BOOL) The shell is run as a "background shell
1398   SYS_CliNumPtr   = (SYS_Dummy + 13); // (LONG *) ti_Data to store the cli number
1399 
1400 { This is not a Tag its a TAG Item  Use this together with SYS_Input, SYS_Output and
1401   SYS_Error, to tell SystemTagList to *duplicate* the respective caller's streams.}
1402   SYS_DupStream   = 1;
1403 {$endif}
1404 
1405 
1406 { Tags for CreateNewProc(). All tags, where no default is stated, the default
1407   is inherited from the parent process. Additionally you may use tags for
1408   AllocDosObject(DOS_CLI, ...).}
1409   NP_Dummy       = (TAG_USER + 1000);
1410   NP_Seglist     = (NP_Dummy + 1); // seglist of code to run for the process
1411   NP_FreeSeglist = (NP_Dummy + 2); // free seglist on exit - only valid for for NP_Seglist.  Default is True.
1412   NP_Entry       = (NP_Dummy + 3); // entry point to run, mutually exclusive with NP_Seglist!
1413   NP_Input       = (NP_Dummy + 4); // filehandle - default is Open("NIL:"...)
1414   NP_Output      = (NP_Dummy + 5); // filehandle - default is Open("NIL:"...)
1415   NP_CloseInput  = (NP_Dummy + 6); // close input filehandle on exit default True
1416   NP_CloseOutput = (NP_Dummy + 7); // close output filehandle on exit default True
1417   NP_Error       = (NP_Dummy + 8); // filehandle - default is Open("NIL:"...)
1418   NP_CloseError  = (NP_Dummy + 9); // close error filehandle on exit default True
1419   NP_CurrentDir  = (NP_Dummy + 10);// lock - default is parent's current dir
1420   NP_StackSize   = (NP_Dummy + 11);// stacksize for process - default 4000
1421   NP_Name        = (NP_Dummy + 12);// name for process - default "New Process"
1422   NP_Priority    = (NP_Dummy + 13);// priority - default same as parent
1423   NP_ConsoleTask = (NP_Dummy + 14);// consoletask - default same as parent
1424   NP_WindowPtr   = (NP_Dummy + 15);// window ptr - default is same as parent
1425   NP_HomeDir     = (NP_Dummy + 16);// home directory - default curr home dir
1426   NP_CopyVars    = (NP_Dummy + 17);// boolean to copy local vars-default True
1427   NP_Cli         = (NP_Dummy + 18);// create cli structure - default FALSE
1428   NP_Path        = (NP_Dummy + 19);// path - default is copy of parents path only valid if a cli process!
1429   NP_CommandName = (NP_Dummy + 20);// commandname - valid only for CLI
1430   NP_Arguments   = (NP_Dummy + 21);// If this tag is used, NP_Input must not be NULL.
1431 //The following two tags do not work, yet.
1432   NP_NotifyOnDeath = (NP_Dummy + 22); // (BOOL) Notify parent, when process exits? (Default: FALSE)
1433   NP_Synchronous   = (NP_Dummy + 23); // (BOOL) Wait until called process returns. (Default: FALSE)
1434 
1435   NP_ExitCode      = (NP_Dummy + 24);// (APTR) Code that is to be called, when process exits. (Default: NULL)
1436   NP_ExitData      = (NP_Dummy + 25);// (APTR) Optional data for NP_ExitCode. (Default: NULL)
1437 {$ifdef aros}
1438   NP_UserData      = (NP_Dummy + 26); //(IPTR) User dependant data. Do with it, what you want to. (Default: NULL)
1439 {$endif}
1440 
1441 { Tags for AllocDosObject }
1442   ADO_Dummy        = (TAG_USER + 2000);
1443   ADO_FH_Mode      = (ADO_Dummy + 1); // Sets up FH to the specified mode.
1444   ADO_DirLen       = (ADO_Dummy + 2); // size in bytes for current dir buffer
1445   ADO_CommNameLen  = (ADO_Dummy + 3); // size in bytes for command name buffer
1446   ADO_CommFileLen  = (ADO_Dummy + 4); // size in bytes for command file buffer
1447   ADO_PromptLen    = (ADO_Dummy + 5); // size in bytes for the prompt buffer
1448 
1449 type
1450   PRootNode = ^TRootNode;
1451   TRootNode = record
1452     rn_TaskArray: BPTR;          // Pointer to the SegList for CLIs.
1453     rn_ConsoleSegment: BPTR;     // SegList for the CLI
1454     rn_Time: TDateStamp;         // Current time
1455     rn_RestartSeg: APTR;         // SegList for the disk validator process
1456     rn_Info: BPTR;               // Pointer ot the Info structure
1457     rn_FileHandlerSegment: BPTR; // segment for a file handler
1458     rn_CliList: TMinList;        // List of all CLI processe (CliProcList)
1459     rn_BootProc: PMsgPort;       // private ptr to msgport of boot fs
1460     rn_ShellSegment: BPTR;       // seglist for Shell (for NewShell)
1461     rn_Flags: LongInt;           // dos flags
1462     rn_RootLock: TSignalSemaphore; // RootNode arbitrator
1463   end;
1464 
1465 { Structure that is linked into the rootnode's rn_CliList. Completely
1466    private, of course! ... and it's not compatible to AmigaOS.}
1467   PCLIInfo = ^TCLIInfo;
1468   TCLIInfo = record
1469     ci_Node: TNode;
1470     ci_Process: PProcess;
1471   end;
1472 
1473 { A structure for holding error messages - stored as array with error == 0
1474   for the last entry.}
1475   PErrorString = ^TErrorString;
1476   TErrorString = record
1477     estr_Nums: PLongInt;
1478     estr_Strings: STRPTR;
1479   end;
1480 
1481 const
1482 { error report types for ErrorReport() }
1483   REPORT_STREAM = 0; // a stream
1484   REPORT_TASK   = 1; // a process - unused
1485   REPORT_LOCK   = 2; // a lock
1486   REPORT_VOLUME = 3; // a volume node
1487   REPORT_INSERT = 4; // please insert volume
1488 
1489 { Special error codes for ErrorReport() }
1490   ABORT_DISK_ERROR = 296; //    Read/write error
1491   ABORT_BUSY       = 288; //    You MUST replace...
1492 
1493 
1494 type
1495 // This is how the base of dos.library looks like.
1496   PDosLibrary = ^TDosLibrary;
1497   TDosLibrary = record
1498     dl_lib: TLibrary;
1499     dl_Root: PRootNode;      // Pointer to RootNode, described below }
1500 
1501     dl_GV: APTR;             // Pointer to BCPL global vector       }
1502     dl_A2: LongInt;          // Private register dump of DOS        }
1503     dl_A5: LongInt;
1504     dl_A6: LongInt;
1505 
1506     dl_Errors: PErrorString;    // pointer to array of error msgs
1507     dl_TimeReq: PTimeRequest;   // private pointer to timer request
1508     dl_UtilityBase  : PLibrary; // private ptr to utility library
1509     dl_IntuitionBase : PLibrary;
1510   end;
1511 
1512 const
1513   RNB_WILDSTAR   = 24;
1514   RNF_WILDSTAR   = 1 shl RNB_WILDSTAR;
1515   RNB_PRIVATE1   = 1;                  // private for dos
1516   RNF_PRIVATE1   = 1 shl RNB_PRIVATE1;
1517 
1518 {   ***************************************************************************}
1519 {    tags for NewLoadSeg }
1520 {    no tags are defined yet for NewLoadSeg }
1521 
1522 {$ifdef aros}
1523 
1524 type
1525 // FSA_Open, Returns a new filehandle. The file may be newly created (depending on io_FileMode)
1526   PIFS_OPEN = ^TIFS_OPEN;
1527   TIFS_OPEN = record
1528     io_FileName: STRPTR;   // File to open.
1529     io_FileMode: LongWord; // Filemode (FMF_*)
1530   end;
1531 // Reads from a filehandle into a buffer.
1532   PIFS_READ_WRITE = ^TIFS_READ_WRITE;
1533   TIFS_READ_WRITE = record
1534     io_Buffer: PChar;    // The buffer for the data to read/write.
1535     io_Length: LongInt;  // The length of the buffer. This is filled by the filesystem handler
1536   end;                   // with the number of bytes actually read/written.
1537 // This action does exactly the same as the function Seek().
1538   PIFS_SEEK = ^TIFS_SEEK;
1539   TIFS_SEEK = record
1540     io_Offset: QWord;     // Offset from position, specified as mode. This is filled by the
1541                           // filehandler with the old position in the file.
1542     io_SeekMode: LongInt; // Seek mode (OFFSET_*)
1543   end;
1544 { Waits for a character to arrive at the filehandle. This is not used for
1545    plain files, but for queues only. Optionally a maximum time to wait may be
1546    specified.}
1547   PIFS_WAIT_CHAR = ^TIFS_WAIT_CHAR;
1548   TIFS_WAIT_CHAR = record
1549     io_Timeout: LongInt;  // Maximum time (in microseconds) to wait for a character.
1550     io_Success: LongBool; // This is set to False by the filehandler if no character arrived in
1551   end;                    // time. Otherwise it is set to True.
1552 { Applies a new mode to a file. If you supply io_Mask with a value of 0,
1553    no changes are made and you can just read the resulting io_FileMode.}
1554   PIFS_FILE_MODE = ^TIFS_FILE_MODE;
1555   TIFS_FILE_MODE = record
1556     io_FileMode: LongWord; // The new mode to apply to the filehandle. See below for definitions.
1557                            //  The filehandler fills this with the old mode bits.
1558     io_Mask: LongWord;     // This mask defines which flags are to be changed.
1559   end;
1560 { This action can be used to query if a filehandle is interactive, i.e. if it
1561    is a terminal or not.}
1562   PIFS_IS_INTERACTIVE = ^TIFS_IS_INTERACTIVE;
1563   TIFS_IS_INTERACTIVE = record
1564     io_IsInteractive: LongBool; // This boolean is filled by the filehandler. It is set to TRUE if the
1565                                 //  filehandle is interactive, otherwise it is set to FALSE.
1566   end;
1567 // Compares two locks for equality.
1568   PIFS_SAME_LOCK = ^TIFS_SAME_LOCK;
1569   TIFS_SAME_LOCK = record
1570     io_Lock: array[0..1] of APTR; // The two locks to compare.
1571     io_Same: LongInt;             // This is set to one of LOCK_DIFFERENT or LOCK_SAME
1572   end;
1573 // Examines a filehandle, giving various information about it.
1574   PIFS_EXAMINE = ^TIFS_EXAMINE;
1575   TIFS_EXAMINE = record
1576     io_ead: PExAllData;  // ExAllData structure buffer to be filled by the filehandler.
1577     io_Size: LongInt;    // Size of the buffer.
1578     io_Mode: LongInt;    // With which kind of information shall the buffer be filled with?
1579   end;                   // see ED_* definitions for more information.
1580   PIFS_EXAMINE_NEXT = ^TIFS_EXAMINE_NEXT;
1581   TIFS_EXAMINE_NEXT = record
1582     io_fib: PFileInfoBlock; // FileInfoBlock structure buffer to be used and filled by the filehandler.
1583   end;
1584 { Works exactly like FSA_EXAMINE with the exeption that multiple files may be
1585    examined, i.e. the filehandle must be a directory.}
1586   PIFS_EXAMINE_ALL = ^TIFS_EXAMINE_ALL;
1587   TIFS_EXAMINE_ALL = record
1588     io_ead: PExAllData;
1589     io_eac: PExallControl;
1590     io_Size: LongInt;
1591     io_Mode: LongInt;
1592   end;
1593 { Works exactly like FSA_OPEN, but you can additionally specify protection
1594    bits to be applied to new files.}
1595   PIFS_OPEN_FILE = ^TIFS_OPEN_FILE;
1596   TIFS_OPEN_FILE = record
1597     io_Filename: STRPTR;     // File to open.
1598     io_FileMode: LongWord;   // see below.
1599     io_Protection: LongWord; // The protection bits
1600   end;
1601 // Creates a new directory. The filehandle of that new directory is returned.
1602   PIFS_CREATE_DIR = ^TIFS_CREATE_DIR;
1603   TIFS_CREATE_DIR = record
1604     io_FileName: STRPTR;     // Name of directory to create.
1605     io_Protection: LongWord; // The protection bits.
1606   end;
1607 // Creates a hard link (i.e. gives one file/directory a second name).
1608   PIFS_CREATE_HARDLINK = ^TIFS_CREATE_HARDLINK;
1609   TIFS_CREATE_HARDLINK = record
1610     io_Filename: STRPTR;  // The filename of the link to create.
1611     io_OldFile: APTR;     // Filehandle of the file to link to.
1612   end;
1613 // Creates a soft link (i.e. a file is created that references another by its name).
1614   PIFS_CREATE_SOFTLINK = ^TIFS_CREATE_SOFTLINK;
1615   TIFS_CREATE_SOFTLINK = record
1616     io_Filename: STRPTR;  // The filename of the link to create.
1617     io_Reference: STRPTR; // The name of the file to link to.
1618   end;
1619 // Renames a file. To the old and the new name, the current directory is applied to.
1620   PIFS_RENAME = ^TIFS_RENAME;
1621   TIFS_RENAME = record
1622     io_Filename: STRPTR;  // The old filename.
1623     io_NewName: STRPTR;   // The new filename.
1624   end;
1625 // Resolves the full path name of the file a softlink filehandle points to.
1626   PIFS_READ_SOFTLINK = ^TIFS_READ_SOFTLINK;
1627   TIFS_READ_SOFTLINK = record
1628     io_Filename: STRPTR; // file name which returned ERROR_IS_SOFT_LINK
1629     io_Buffer: STRPTR;   { The buffer to fill with the pathname. If this buffer is too small, the
1630                             filesystem handler is supposed to return ERROR_LINE_TOO_LONG.}
1631     io_Size: LongWord;  // The size of the buffer pointed to by io_Buffer.
1632   end;
1633 // Deletes an object on the volume.
1634   PIFS_DELETE_OBJECT = ^TIFS_DELETE_OBJECT;
1635   TIFS_DELETE_OBJECT = record
1636     io_Filename: STRPTR;  // The name of the file to delete.
1637   end;
1638 // Sets a filecomment for a file.
1639   PIFS_SET_COMMENT = ^TIFS_SET_COMMENT;
1640   TIFS_SET_COMMENT = record
1641     io_Filename: STRPTR;  // The name of the file to be commented.
1642     io_Comment: STRPTR;   // The new filecomment. May be nil, in which case the current filecomment is deleted.
1643   end;
1644 // Sets the protection bits of a file.
1645   PIFS_SET_PROTECT = ^TIFS_SET_PROTECT;
1646   TIFS_SET_PROTECT = record
1647     io_Filename: STRPTR;     // The file to change.
1648     io_Protection: LongWord; // The new protection bits.
1649   end;
1650 // Sets the ownership of a file.
1651   PIFS_SET_OWNER = ^TIFS_SET_OWNER;
1652   TIFS_SET_OWNER = record
1653     io_Filename: STRPTR; // The file to change.
1654     io_UID: Word;        // The new owner.
1655     io_GID: Word;        // The new group owner.
1656   end;
1657 { Sets the last modification date/time of the filename given as first
1658    argument. The date/time is given as standard DateStamp structure}
1659   PIFS_SET_DATE = ^TIFS_SET_DATE;
1660   TIFS_SET_DATE = record
1661     io_Filename: STRPTR;  // The file to change
1662     io_Date: TDateStamp;  // The new date
1663   end;
1664 // Check if a filesystem is in fact a FILEsystem, i.e. can contain different files.
1665   PIFS_IS_FILESYSTEM = ^TIFS_IS_FILESYSTEM;
1666   TIFS_IS_FILESYSTEM = record
1667     io_IsFilesystem: LongBool; // This is set to True by the filesystem handler if it is a filesystem
1668   end;                         // and set to False if it is not.
1669 { Changes the number of buffers for the filesystem. The current number of
1670    buffers is returned. The size of the buffers is filesystem-dependent.}
1671   PIFS_MORE_CACHE = ^TIFS_MORE_CACHE;
1672   TIFS_MORE_CACHE = record
1673     io_NumBuffers: LongInt; // Number of buffers to add. May be negative to reduce number of buffers.
1674   end;                      // This is to be set to the current number of buffers on success.
1675 // Formats a volume, i.e. erases all data on it.
1676   PIFS_FORMAT = ^TIFS_FORMAT;
1677   TIFS_FORMAT = record
1678     io_VolumeName: STRPTR; // New name for the volume.
1679     io_DosType: LongWord;  // New type for the volume. Filesystem specific.
1680   end;
1681 { Resets/reads the mount-mode of the volume passed in as io_Unit. The first
1682    and second arguments work exactly like FSA_FILE_MODE, but the third
1683    argument can contain a password, if MMF_LOCKED is set.}
1684   PIFS_MOUNT_MODE = ^TIFS_MOUNT_MODE;
1685   TIFS_MOUNT_MODE = record
1686     io_MountMode: LongWord; // The new mode to apply to the volume. See below for definitions.
1687                             // The filehandler fills this with the old mode bits.
1688     io_Mask: LongWord;      // This mask defines which flags are to be changed.
1689     io_Password: STRPTR;    // A password, which is needed if MMF_LOCKED is set.
1690   end;
1691   PIFS_INHIBIT = ^TIFS_INHIBIT;
1692   TIFS_INHIBIT = record
1693     io_Inhibit: LongBool;
1694   end;
1695   PIFS_NOTIFY = ^TIFS_NOTIFY;
1696   TIFS_NOTIFY = record
1697     io_FileName: STRPTR;    // Needed for synchronous operation
1698     io_NotificationRequest: PNotifyRequest;
1699   end;
1700   PIFS_INFO = ^TIFS_INFO;
1701   TIFS_INFO = record
1702     io_Info: PInfoData;
1703   end;
1704   PIFS_CHANGE_SIGNAL = ^TIFS_CHANGE_SIGNAL;
1705   TIFS_CHANGE_SIGNAL = record
1706     io_Task: PTask;
1707   end;
1708   PIFS_RECORD = ^TIFS_RECORD;
1709   TIFS_RECORD = record
1710     io_Offset: QWord;
1711     io_Size: LongInt;
1712     io_RecordMode: LongWord;
1713     io_Timeout: LongWord;
1714   end;
1715   PIFS_PARENT_DIR = ^TIFS_PARENT_DIR;
1716   TIFS_PARENT_DIR = record
1717     io_DirName: PChar; // This will contain the return value of the parent directory, or
1718   end;                 // nil if we are at the root directory already
1719 // Allows us to change a console between raw and cooked mode.
1720   PIFS_CONSOLE_MODE = ^TIFS_CONSOLE_MODE;
1721   TIFS_CONSOLE_MODE = record
1722     io_ConsoleMode: LongInt;  // (FCM_*)
1723   end;
1724   PIFS_RELABEL = ^TIFS_RELABEL;
1725   TIFS_RELABEL = record
1726     io_NewName: STRPTR;
1727     io_Result: LongBool;
1728   end;
1729 { FSA_PIPE: create a pair of handles connected to each other
1730   This opens a "file" (which will usually be a pipe device) and returns two
1731   handles such that writing data to the writer will result in that data
1732   appearing on the reader. Both handles must be closed for the underlying
1733   file to be closed. If a NULL/empty path is supplied, an unnamed pipe will
1734   be created, which will be destroyed once both handles are closed.
1735   The read handle is returned in io_Unit.}
1736   PIFS_PIPE = ^TIFS_PIPE;
1737   TIFS_PIPE = record
1738     io_FileName: STRPTR;
1739     io_Writer: PUnit;
1740   end;
1741 const
1742   FSA_OPEN            =  1; // Returns a new filehandle. The file may be newly created (depending on io_FileMode) TIFS_OPEN
1743   FAS_CLOSE           =  2; // Closes an opened filehandle. Takes no extra arguments.
1744   FSA_READ            =  3; // Reads from a filehandle into a buffer. TIFS_READ_WRITE
1745   FSA_WRITE           =  4; // Writes the contents of a buffer into a filehandle. Uses TIFS_READ_WRITE.
1746   FSA_SEEK            =  5; // This action does exactly the same as the function Seek(). TIFS_SEEK
1747   FSA_SET_FILE_SIZE   =  6; // Sets the size of filehandle. Uses TIFS_SEEK (see above) as argument array.
1748   FSA_WAIT_CHAR       =  7; // Waits for a character to arrive at the filehandle. (TIFS_WAIT_CHAR)
1749   FSA_FILE_MODE       =  8; // Applies a new mode to a file.
1750   FSA_IS_INTERACTIVE  =  9; // Query if a filehandle is interactive
1751   FSA_SAME_LOCK       = 10; // Compares two locks for equality.
1752   FSA_EXAMINE         = 11; // Examines a filehandle, giving various information about it.
1753   FSA_EXAMINE_NEXT    = 12; // Examine next file
1754   FSA_EXAMINE_ALL     = 13; // Works exactly like FSA_EXAMINE on directories
1755   FSA_EXAMINE_ALL_END = 14; { This has to be called if FSA_EXAMINE_ALL is stopped before all examined
1756                               files were returned. It takes no arguments except the filehandle in io_Unit.}
1757   FSA_OPEN_FILE       = 15; // Works exactly like FSA_OPEN but with special protection bits
1758   FSA_CREATE_DIR      = 16; // Creates a new directory. The filehandle of that new directory is returned.
1759   FSA_CREATE_HARDLINK = 17; // Creates a hard link (i.e. gives one file/directory a second name).
1760   FSA_CREATE_SOFTLINK = 18; // Creates a soft link (i.e. a file is created that references another by its name).
1761   FSA_RENAME          = 19; // Renames a file. To the old and the new name, the current directory is applied to.
1762   FSA_READ_SOFTLINK   = 20; // Resolves the full path name of the file a softlink filehandle points to.
1763   FSA_DELETE_OBJECT   = 21; // Deletes an object on the volume.
1764   FSA_SET_COMMENT     = 22; // Sets a filecomment for a file.
1765   FSA_SET_PROTECT     = 23; // Sets the ownership of a file.
1766   FSA_SET_OWNER       = 24; // Sets the last modification date/time
1767   FSA_SET_DATE        = 25; // Set file date
1768   FSA_IS_FILESYSTEM   = 26; // Check if a filesystem is in fact a FILEsystem, i.e. can contain different files.
1769   FSA_MORE_CACHE      = 27; // Changes the number of buffers for the filesystem.
1770   FSA_FORMAT          = 28; // Formats a volume, i.e. erases all data on it.
1771   FSA_MOUNT_MODE      = 29; // Resets/reads the mount-mode
1772   //FSA_SERIALIZE_DISK = 30; // currently not supported
1773   // FSA_FLUSH         = 31; // currently not supported
1774   FSA_INHIBIT         = 32;
1775   //FSA_WRITE_PROTECT   = 33; // currently not supported
1776   //FSA_DISK_CHANGE     = 34; // currently not supported
1777   FSA_ADD_NOTIFY      = 35;
1778   FSA_REMOVE_NOTIFY   = 36;
1779   FSA_DISK_INFO       = 37;
1780   FSA_CHANGE_SIGNAL   = 38;
1781   FSA_LOCK_RECORD     = 39;
1782   FSA_UNLOCK_RECORD   = 40;
1783   FSA_PARENT_DIR      = 41;
1784   FSA_PARENT_DIR_POST = 42;
1785   FSA_CONSOLE_MODE    = 43; // Allows us to change a console between raw and cooked mode.
1786   FSA_RELABEL         = 44;
1787   FSA_PIPE            = 45; // create a pair of handles connected to each other
1788 // io_ConsoleMode
1789   FCM_COOKED = 0;
1790   FCM_RAW    = 1 shl 0;
1791   FCM_NOECHO = 1 shl 1;
1792 { io_FileMode for FSA_OPEN, FSA_OPEN_FILE and FSA_FILE_MODE. These are flags
1793    and may be OR'ed. Note that not all filesystems support all flags.}
1794   FMF_LOCK     = 1 shl 0; // Lock exclusively.
1795   FMF_EXECUTE  = 1 shl 1; // Open for executing.
1796 // At least one of the following two flags must be specified. Otherwise expect strange things to happen.
1797   FMF_WRITE    = 1 shl 2; // Open for writing.
1798   FMF_READ     = 1 shl 3; // Open for reading.
1799   FMF_CREATE   = 1 shl 4; // Create file if it doesn't exist.
1800   FMF_CLEAR    = 1 shl 5; // Truncate file on open.
1801   FMF_RAW      = 1 shl 6; // Switch cooked to raw and vice versa.
1802   FMF_NONBLOCK = 1 shl 7; // Don't block Open() in case it would and return an error in case Write()/Read()  would block
1803   FMF_APPEND   = 1 shl 8; // Every write will happen always at the end of the file
1804   FMF_AMIGADOS = (1 shl 9) or (1 shl 31); // Identifies the old AmigaDOS modes:
1805                                           // - bit 9 is the first bit set in the MODE_#? modes
1806                                           // - bit 31 is the first bit set in ACCESS_#? modes
1807   FMF_MODE_OLDFILE   = FMF_AMIGADOS or FMF_WRITE or FMF_READ;
1808   FMF_MODE_READWRITE = FMF_MODE_OLDFILE or FMF_CREATE;
1809   FMF_MODE_NEWFILE   = FMF_MODE_READWRITE or FMF_LOCK or FMF_CLEAR;
1810 // io_MountMode for FSA_MOUNT_MODE. These are flags and may be OR'ed.
1811   MMF_READ        = 1 shl 0; // Mounted for reading.
1812   MMF_WRITE       = 1 shl 1; // Mounted for writing.
1813   MMF_READ_CACHE  = 1 shl 2; // Read cache enabled.
1814   MMF_WRITE_CACHE = 1 shl 3; // Write cache enabled.
1815   MMF_OFFLINE     = 1 shl 4; // Filesystem currently does not use the device.
1816   MMF_LOCKED      = 1 shl 5; // Mount mode is password protected.
1817 { This structure is an extended TIORequest. It is used for
1818    requesting actions from AROS filesystem handlers.
1819    Note that this structure may grow in the future. Do not depend on its size!
1820    You may use sizeof(TIOFileSys) nevertheless if you are reserving
1821    memory for a TIOFileSys as the size of it will never shrink.}
1822 type
1823   PIOFileSys = ^TIOFileSys;
1824   TIOFileSys = record
1825     IOFS: TIORequest; // Standard I/O request.
1826     io_DosError: LongInt; // Dos error code.
1827     io_PacketEmulation: PDosPacket; // Private
1828     io_DirPos: IPTR; // Handler-private key to current directory position
1829     //* This union contains all the data needed for the various actions. */
1830     io_Union: record
1831       case Smallint of
1832         0: (io_OpenDevice : record
1833             io_DeviceName: STRPTR; // Name of the device to open. */
1834             io_Unit: IPTR;         // Number of unit to open. */
1835             io_Environ: ^IPTR;     // Pointer to environment array.
1836             io_DosName: STRPTR;    // The name with which the
1837                                    //    filesystem is being mounted
1838                                    //    (the mount point, one might
1839                                    //    say)
1840             io_DeviceNode: PDeviceNode; // The DOS entry for this
1841                                         // filesystem. Packet-based
1842                                         // filesystems expect to receive
1843                                         // this along with the
1844                                         // startup message
1845             end;
1846         );
1847         1: (io_NamedFile: record
1848           io_Filename: STRPTR;
1849           end;
1850          );
1851         2: (
1852           io_OPEN: TIFS_OPEN;                       // FSA_OPEN
1853           io_READ_WRITE: TIFS_READ_WRITE;           // FSA_READ, FSA_WRITE
1854           io_SEEK: TIFS_SEEK;                       // FSA_SEEK
1855           io_WAIT_CHAR: TIFS_WAIT_CHAR;             // FSA_WAIT_CHAR
1856           io_FILE_MODE: TIFS_FILE_MODE;             // FSA_FILE_MODE */
1857           io_IS_INTERACTIVE: TIFS_IS_INTERACTIVE;   // FSA_IS_INTERACTIVE */
1858           io_SAME_LOCK: TIFS_SAME_LOCK;             // FSA_SAME_LOCK */
1859           io_EXAMINE: TIFS_EXAMINE;                 // FSA_EXAMINE */
1860           io_EXAMINE_ALL: TIFS_EXAMINE_ALL;         // FSA_EXAMINE_ALL */
1861           io_EXAMINE_NEXT: TIFS_EXAMINE_NEXT;       // FSA_EXAMINE_NEXT */
1862           io_OPEN_FILE: TIFS_OPEN_FILE;             // FSA_OPEN_FILE */
1863           io_CREATE_DIR: TIFS_CREATE_DIR;           // FSA_CREATE_DIR */
1864           io_CREATE_HARDLINK: TIFS_CREATE_HARDLINK; // FSA_CREATE_HARDLINK */
1865           io_CREATE_SOFTLINK: TIFS_CREATE_SOFTLINK; // FSA_CREATE_SOFTLINK */
1866           io_RENAME: TIFS_RENAME;                   // FSA_RENAME */
1867           io_READ_SOFTLINK: TIFS_READ_SOFTLINK;     // FSA_READ_SOFTLINK */
1868           io_DELETE_OBJECT: TIFS_DELETE_OBJECT;     // FSA_DELETE_OBJECT */
1869           io_SET_COMMENT: TIFS_SET_COMMENT;         // FSA_SET_COMMENT */
1870           io_SET_PROTECT: TIFS_SET_PROTECT;         // FSA_SET_PROTECT */
1871           io_SET_OWNER: TIFS_SET_OWNER;             // FSA_SET_OWNER */
1872           io_SET_DATE: TIFS_SET_DATE;               // FSA_SET_DATE */
1873           io_IS_FILESYSTEM: TIFS_IS_FILESYSTEM;     // FSA_IS_FILESYSTEM */
1874           io_MORE_CACHE: TIFS_MORE_CACHE;           // FSA_MORE_CACHE */
1875           io_FORMAT: TIFS_FORMAT;                   // FSA_FORMAT */
1876           io_MOUNT_MODE: TIFS_MOUNT_MODE;           // FSA_MOUNT_MODE */
1877           io_INHIBIT: TIFS_INHIBIT;                 // FSA_INHIBIT */
1878           io_PARENT_DIR: TIFS_PARENT_DIR;           // FSA_PARENT_DIR */
1879           io_CONSOLE_MODE: TIFS_CONSOLE_MODE;       // FSA_CONSOLE_MODE */
1880           io_RELABEL: TIFS_RELABEL;                 // FSA_RELABEL */
1881           io_NOTIFY: TIFS_NOTIFY;                   // FSA_ADD_NOTIFY
1882           io_INFO: TIFS_INFO;                       // FSA_INFO
1883           io_RECORD: TIFS_RECORD;                   // FSA_LOCK_RECORD
1884           io_CHANGE_SIGNAL: TIFS_CHANGE_SIGNAL;     // FSA_CHANGE_SIGNAL
1885           io_PIPE: TIFS_PIPE;                       // FSA_PIPE
1886     );
1887     end;
1888 end;
1889 
1890 const
1891   ERROR_BROKEN_PIPE = 400;  // An attempt to write on a pipe without any reader has been made
1892   ERROR_WOULD_BLOCK = 401;  // A Read() or a Write() on a file opened with the FMF_NONBLOCK flag would block
1893   ERROR_INTERRUPTED = 402;  // The I/O file operation has been interrupted for some reason
1894 
1895 // elf.h
1896 
1897 type
1898   //*
1899   //* Define one of ELF_64BIT or ELF_32BIT in your code if you want to enforce specific
1900   //* version of ELF structures. Otherwize it fails back to your native machine's size.
1901   //*
1902   {$IFDEF ELF_64BIT}
1903   {$define elf_ptr_t}
1904   elf_ptr_t             = UQUAD;
1905   elf_uintptr_t         = UQUAD;
1906   elf_intptr_t          = QUAD;
1907   {$ENDIF}
1908 
1909   {$IFDEF ELF_32BIT}
1910   {$define elf_ptr_t}
1911   elf_ptr_t             = ULONG;
1912   elf_uintptr_t         = ULONG;
1913   elf_intptr_t          = LONG;
1914   {$ENDIF}
1915 
1916   {$IFNDEF elf_ptr_t}
1917   elf_ptr_t             = APTR;
1918   elf_uintptr_t         = IPTR;
1919   elf_intptr_t          = SIPTR;
1920   {$ENDIF}
1921 
1922 
1923 Const
1924   SHT_PROGBITS          =  1;
1925   SHT_SYMTAB            =  2;
1926   SHT_STRTAB            =  3;
1927   SHT_RELA              =  4;
1928   SHT_NOBITS            =  8;
1929   SHT_REL               =  9;
1930   SHT_SYMTAB_SHNDX      = 18;
1931   SHT_ARM_ATTRIBUTES    = $70000003;
1932 
1933   ET_REL                =  1;
1934   ET_EXEC               =  2;
1935 
1936   EM_386                =  3;
1937   EM_68K                =  4;
1938   EM_PPC                = 20;
1939   EM_ARM                = 40;
1940   EM_X86_64             = 62;     //* AMD x86-64 */
1941 
1942   R_386_NONE            = 0;
1943   R_386_32              = 1;
1944   R_386_PC32            = 2;
1945 
1946   //* AMD x86-64 relocations.  */
1947   R_X86_64_NONE         =  0;      //* No reloc */
1948   R_X86_64_64           =  1;      //* Direct 64 bit  */
1949   R_X86_64_PC32         =  2;      //* PC relative 32 bit signed */
1950   R_X86_64_32           = 10;
1951   R_X86_64_32S          = 11;
1952 
1953   R_68K_NONE            = 0;
1954   R_68K_32              = 1;
1955   R_68K_16              = 2;
1956   R_68K_8               = 3;
1957   R_68K_PC32            = 4;
1958   R_68K_PC16            = 5;
1959   R_68K_PC8             = 6;
1960 
1961   R_PPC_NONE            =   0;
1962   R_PPC_ADDR32          =   1;
1963   R_PPC_ADDR16_LO       =   4;
1964   R_PPC_ADDR16_HA       =   6;
1965   R_PPC_REL24           =  10;
1966   R_PPC_REL32           =  26;
1967   R_PPC_REL16_LO        = 250;
1968   R_PPC_REL16_HA        = 252;
1969 
1970   R_ARM_NONE            =  0;
1971   R_ARM_PC24            =  1;
1972   R_ARM_ABS32           =  2;
1973   R_ARM_CALL            = 28;
1974   R_ARM_JUMP24          = 29;
1975   R_ARM_TARGET1         = 38;
1976   R_ARM_V4BX            = 40;
1977   R_ARM_TARGET2         = 41;
1978   R_ARM_PREL31          = 42;
1979   R_ARM_MOVW_ABS_NC     = 43;
1980   R_ARM_MOVT_ABS        = 44;
1981   R_ARM_THM_CALL        = 10;
1982   R_ARM_THM_JUMP24      = 30;
1983   R_ARM_THM_MOVW_ABS_NC = 47;
1984   R_ARM_THM_MOVT_ABS    = 48;
1985 
1986   STT_NOTYPE            =  0;
1987   STT_OBJECT            =  1;
1988   STT_FUNC              =  2;
1989   STT_SECTION           =  3;
1990   STT_FILE              =  4;
1991   STT_LOPROC            = 13;
1992   STT_HIPROC            = 15;
1993 
1994   STB_LOCAL             =  0;
1995   STB_GLOBAL            =  1;
1996   STB_WEAK              =  2;
1997   STB_LOOS              = 10;
1998   STB_GNU_UNIQUE        = 10;
1999   STB_HIOS              = 12;
2000   STB_LOPROC            = 13;
2001   STB_HIPROC            = 15;
2002 
2003   SHN_UNDEF             = 0;
2004   SHN_LORESERVE         = $ff00;
2005   SHN_ABS               = $fff1;
2006   SHN_COMMON            = $fff2;
2007   SHN_XINDEX            = $ffff;
2008   SHN_HIRESERVE         = $ffff;
2009 
2010   SHF_WRITE             = (1 shl 0);
2011   SHF_ALLOC             = (1 shl 1);
2012   SHF_EXECINSTR         = (1 shl 2);
2013 
2014   //  ELF_ST_TYPE(i)    ((i) & 0x0F)
2015 
2016   EI_VERSION            =  6;
2017   EV_CURRENT            =  1;
2018 
2019   EI_DATA               =  5;
2020   ELFDATA2LSB           =  1;
2021   ELFDATA2MSB           =  2;
2022 
2023   EI_CLASS              =  4;
2024   ELFCLASS32            =  1;
2025   ELFCLASS64            =  2;             //* 64-bit objects */
2026 
2027   EI_OSABI              =  7;
2028   EI_ABIVERSION         =  8;
2029 
2030   ELFOSABI_AROS         = 15;
2031 
2032   PF_X                  = (1 shl 0);
2033 
2034   ATTR_VERSION_CURRENT  = $41;
2035 
2036 type
2037   PElfHeader = ^TELFHeader;
2038   TElfHeader = record
2039     Ident:     array [0..16-1] of Byte;
2040     Type_:     Word;
2041     Machine:   Word;
2042     Version:   LongWord;
2043     Entry:     elf_ptr_t;
2044     PhOff:     elf_uintptr_t;
2045     ShOff:     elf_uintptr_t;
2046     Flags:     LongWord;
2047     EhSize:    Word;
2048     PhentSize: Word;
2049     PhNum:     Word;
2050     ShentSize: Word;
2051     ShNum:     Word;
2052     ShStrndx:  Word;
2053   end;
2054 
2055   PSHeader  = ^TSHeader;
2056   TSHeader = record
2057     Name:      LongWord;
2058     Type_:     LongWord;
2059     Flags:     elf_uintptr_t ;
2060     Addr:      elf_ptr_t     ;
2061     Offset:    elf_uintptr_t ;
2062     Size:      elf_uintptr_t ;
2063     Link:      LongWord;
2064     Info:      LongWord;
2065     AddrAlign: elf_uintptr_t ;
2066     EntSize:   elf_uintptr_t ;
2067   end;
2068 
2069   {$DEFINE PT_LOAD}
2070 
2071 {$IFDEF ELF_64BIT}
2072   TPHeader = record
2073     Type_:  LongWord;
2074     Flags:  LongWord;
2075     Offset: elf_uintptr_t;
2076     VAddr:  elf_ptr_t;
2077     PAddr:  elf_ptr_t;
2078     Filesz: elf_uintptr_t;
2079     Memsz:  elf_uintptr_t;
2080     Align:  elf_uintptr_t;
2081   end;
2082 
2083   TSymbol = record
2084     Name:    LongWord; // Offset of the name string in the string table
2085     Info:    Byte;     // What kind of symbol is this ? (global, variable, etc)
2086     Other:   Byte;     // undefined
2087     ShIndex: Word;     // In which section is the symbol defined ?
2088     Value:   elf_uintptr_t ; // Varies; eg. the offset of the symbol in its hunk
2089     Size:    elf_uintptr_t ; // How much memory does the symbol occupy
2090   end;
2091 
2092   // 209 #define ELF_R_SYM(i)          (ULONG)((i) >> 32)
2093   // 210 #define ELF_R_TYPE(i)         (ULONG)((i) & 0xffffffffULL)
2094   // 211 #define ELF_R_INFO(sym, type) (((UQUAD)(sym) << 32) + (type))
2095 
2096 {$ELSE ELF_64BIT}
2097   TPHeader = record
2098     Type_:  LongWord;
2099     Offset: LongWord;
2100     VAddr:  elf_ptr_t;
2101     PAddr:  elf_ptr_t;
2102     Filesz: LongWord;
2103     Memsz:  LongWord;
2104     Flags:  LongWord;
2105     Align:  LongWord;
2106   end;
2107 
2108   TSymbol = record
2109     Name:    LongWord;       // Offset of the name string in the string table
2110     Value:   elf_uintptr_t;  // Varies; eg. the offset of the symbol in its hunk
2111     Size:    elf_uintptr_t;  // How much memory does the symbol occupy
2112     Info:    Byte;           // What kind of symbol is this ? (global, variable, etc)
2113     Other:   Byte;           // undefined
2114     ShIndex: Word;           // In which section is the symbol defined?
2115   end;
2116 
2117   // 237 #define ELF_R_SYM(val)        ((val) >> 8)
2118   // 238 #define ELF_R_TYPE(val)       ((val) & 0xff)
2119   // 239 #define ELF_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
2120 {$ENDIF}
2121 
2122 
2123   // 243 #define ELF_S_BIND(val)         ((val) >> 4)
2124   // 244 #define ELF_S_TYPE(val)         ((val) & 0xF)
2125   // 245 #define ELF_S_INFO(bind, type)  (((bind) << 4) + ((type) & 0xF))
2126 
2127   TRel = record
2128     Offset: elf_uintptr_t;     // Address of the relocation relative to the section it refers to
2129     Info:   elf_uintptr_t;     // Type of the relocation
2130   end;
2131 
2132   TRelA = record
2133     Offset: elf_uintptr_t;     // Address of the relocation relative to the section it refers to
2134     Info:   elf_uintptr_t;     // Type of the relocation
2135     Addend: elf_uintptr_t;     // Constant addend used to compute value
2136   end;
2137 
2138 
2139   (*
2140  260 /* Note: the conversion below is not in line with ELF specification and is fixed in GNU binutils since 2008
2141  261  * See: https://sourceware.org/bugzilla/show_bug.cgi?id=5900
2142  262  */
2143  263 /* convert section header number to array index */
2144  264 /*#define SHINDEX(n) \
2145  265     ((n) < SHN_LORESERVE ? (n) : ((n) <= SHN_HIRESERVE ? 0 : (n) - (SHN_HIRESERVE + 1 - SHN_LORESERVE)))*/
2146  266
2147  267 /* convert section header array index to section number */
2148  268 /*#define SHNUM(i) \
2149  269     ((i) < SHN_LORESERVE ? (i) : (i) + (SHN_HIRESERVE + 1 - SHN_LORESERVE))*/
2150  270
2151  271 /* ARM-specific attributes section definitions follow */
2152  272
2153  273 #define
2154   *)
2155 
2156   TAttrs_Section = record
2157     Size:   LongWord;
2158     Vendor: array[0..0] of char;   // NULL-terminated name
2159   end;                             // Vendor-specific subsections follow
2160 
2161   TAttrs_SubSection = packed record
2162     Tag: Byte;
2163     Size: LongWord;
2164   end;
2165 
2166 const
2167   Tag_File                 = 1;
2168   Tag_Section              = 2;
2169   Tag_Symbol               = 3;
2170   Tag_CPU_raw_name         = 4;
2171   Tag_CPU_name             = 5;
2172   Tag_CPU_arch             = 6;
2173   Tag_FP_arch              = 10;
2174   Tag_compatibility        = 32;
2175   Tag_also_compatible_with = 65;
2176   Tag_conformance          = 67;
2177 
2178   // Tag_CPU_arch values
2179   ELF_CPU_PREv4    = 0;
2180   ELF_CPU_ARMv4    = 1;
2181   ELF_CPU_ARMv4T   = 2;
2182   ELF_CPU_ARMv5T   = 3;
2183   ELF_CPU_ARMv5TE  = 4;
2184   ELF_CPU_ARMv5TEJ = 5;
2185   ELF_CPU_ARMv6    = 6;
2186   ELF_CPU_ARMv6KZ  = 7;
2187   ELF_CPU_ARMv6T2  = 8;
2188   ELF_CPU_ARMv6K   = 9;
2189   ELF_CPU_ARMv7    = 10;
2190   ELF_CPU_ARM_v6M  = 11;
2191   ELF_CPU_ARMv6SM  = 12;
2192   ELF_CPU_ARMv7EM  = 13;
2193 
2194   //* Tag_FP_arch values */
2195   ELF_FP_None     = 0;
2196   ELF_FP_v1       = 1;
2197   ELF_FP_v2       = 2;
2198   ELF_FP_v3       = 3;
2199   ELF_FP_v3_Short = 4;
2200   ELF_FP_v4       = 5;
2201   ELF_FP_v4_Short = 6;
2202 
2203 {$endif}
2204 
DOSOpennull2205 function DOSOpen(const Name: STRPTR; AccessMode: LongInt): BPTR; syscall AOS_DOSBase 5;
DOSClosenull2206 function DOSClose(File_: BPTR): LongBool; syscall AOS_DOSBase 6;
DOSReadnull2207 function DOSRead(File_: BPTR; Buffer: APTR; Length: LongInt): LongInt; syscall AOS_DOSBase 7;
DOSWritenull2208 function DOSWrite(File_: BPTR; Buffer: APTR; Length: LongInt): LongInt;  syscall AOS_DOSBase 8;
DOSInputnull2209 function DOSInput: BPTR; syscall AOS_DOSBase 9;
DOSOutputnull2210 function DOSOutput : BPTR; syscall AOS_DOSBase 10;
DOSSeeknull2211 function DOSSeek(File_: BPTR; Position: LongInt; Mode: LongInt): LongInt; syscall AOS_DOSBase 11;
DOSDeleteFilenull2212 function DOSDeleteFile(const Name: STRPTR): LongBool; syscall AOS_DOSBase 12;
DOSRenamenull2213 function DOSRename(const OldName: STRPTR; const NewName: STRPTR): LongInt; syscall AOS_DOSBase 13;
Locknull2214 function Lock(const Name: STRPTR; AccessMode: LongInt): BPTR; syscall AOS_DOSBase 14;
UnLocknull2215 function UnLock(Lock: BPTR): LongBool; syscall AOS_DOSBase 15;
DupLocknull2216 function DupLock(Lock: BPTR): BPTR; syscall AOS_DOSBase 16;
Examinenull2217 function Examine(Lock: BPTR; FileInfoBlock: PFileInfoBlock): LongInt; syscall AOS_DOSBase 17;
ExNextnull2218 function ExNext(Lock: BPTR; FileInfoBlock: PFileInfoBlock): LongInt; syscall AOS_DOSBase 18;
Infonull2219 function Info(Lock: BPTR; ParameterBlock: PInfoData): LongInt; syscall AOS_DOSBase 19;
DOSCreateDirnull2220 function DOSCreateDir(const Name: STRPTR): BPTR; syscall AOS_DOSBase 20;
CurrentDirnull2221 function CurrentDir(Lock: BPTR): BPTR; syscall AOS_DOSBase 21;
IoErrnull2222 function IoErr: LongInt; syscall AOS_DOSBase 22;
CreateProcnull2223 function CreateProc(const Name: STRPTR; Pri: LongInt; SegList: BPTR; StackSize: LongInt): PMsgPort; syscall AOS_DOSBase 23;
2224 procedure DOSExit(ReturnCode: LongInt); syscall AOS_DOSBase 24;
LoadSegnull2225 function LoadSeg(const Name: STRPTR): BPTR; syscall AOS_DOSBase 25;
2226 procedure UnLoadSeg(Seglist: BPTR); syscall AOS_DOSBase 26;
DeviceProcnull2227 function DeviceProc(const Name: STRPTR): PMsgPort; syscall AOS_DOSBase 29;
SetCommentnull2228 function SetComment(const Name: STRPTR; const Comment: STRPTR): LongInt; syscall AOS_DOSBase 30;
SetProtectionnull2229 function SetProtection(const Name: STRPTR; Protect: LongWord): LongInt; syscall AOS_DOSBase 31;
DateStampnull2230 function DateStamp(Date: PDateStamp): PDateStamp; syscall AOS_DOSBase 32;
2231 procedure DOSDelay(TimeOut: LongWord); syscall AOS_DOSBase 33;
WaitForCharnull2232 function WaitForChar(File_: BPTR; TimeOut: LongInt): LongInt; syscall AOS_DOSBase 34;
ParentDirnull2233 function ParentDir(Lock: BPTR): BPTR; syscall AOS_DOSBase 35;
IsInteractivenull2234 function IsInteractive(File_: BPTR): LongInt; syscall AOS_DOSBase 36;
Executenull2235 function Execute(const String_: STRPTR; Input: BPTR; Output: BPTR): LongInt; syscall AOS_DOSBase 37;
AllocDosObjectnull2236 function AllocDosObject(Type_: LongWord; const Tags: PTagItem): APTR; syscall AOS_DOSBase 38;
AllocDosObjectTagListnull2237 function AllocDosObjectTagList(Type_: LongWord; const Tags: PTagItem): APTR; syscall AOS_DOSBase 38;
2238 procedure FreeDosObject(Type_: LongWord; Ptr: APTR); syscall AOS_DOSBase 39;
DoPktnull2239 function DoPkt(Port: PMsgPort; Action: LongInt; Arg1, Arg2, Arg3, Arg4, Arg5: LongInt): LongInt; syscall AOS_DOSBase 40;
2240 procedure SendPkt(Dp: PDosPacket; Port: PMsgPort; ReplyPort: PMsgPort); syscall AOS_DOSBase 41;
WaitPktnull2241 function WaitPkt: PDosPacket; syscall AOS_DOSBase 42;
2242 procedure ReplyPkt(Dp: PDosPacket; Res1: LongInt; Res2: LongInt); syscall AOS_DOSBase 43;
2243 procedure AbortPkt(Port: PMsgPort; Pkt: PDosPacket); syscall AOS_DOSBase 44;
LockRecordnull2244 function LockRecord(Fh: BPTR; Offset: LongWord; Length: LongWord; Mode: LongWord; Timeout: LongWord): LongBool; syscall AOS_DOSBase 45;
LockRecordsnull2245 function LockRecords(RecArray: PRecordLock; TimeOut: LongWord): LongBool; syscall AOS_DOSBase 46;
UnLockRecordnull2246 function UnLockRecord(Fh: BPTR; Offset: LongWord; Length: LongWord): LongBool; syscall AOS_DOSBase 47;
UnLockRecordsnull2247 function UnLockRecords(RecArray: PRecordLock): LongBool; syscall AOS_DOSBase 48;
SelectInputnull2248 function SelectInput(Fh: BPTR): BPTR; syscall AOS_DOSBase 49;
SelectOutputnull2249 function SelectOutput(Fh: BPTR): BPTR; syscall AOS_DOSBase 50;
FGetCnull2250 function FGetC(File_: BPTR): LongInt; syscall AOS_DOSBase 51;
FPutCnull2251 function FPutC(File_: BPTR; Character: LongInt): LongInt; syscall AOS_DOSBase 52;
UnGetCnull2252 function UnGetC(File_: BPTR; Character: LongInt): LongInt; syscall AOS_DOSBase 53;
FReadnull2253 function FRead(Fh: BPTR; Block: APTR; Blocklen: LongWord; Number: LongWord): LongInt; syscall AOS_DOSBase 54;
FWritenull2254 function FWrite(Fh: BPTR; Block: APTR; Blocklen: LongWord; NumBlocks: LongWord): LongInt; syscall AOS_DOSBase 55;
FGetsnull2255 function FGets(Fh: BPTR; Buf: STRPTR; BufLen: LongWord): STRPTR; syscall AOS_DOSBase 56;
FPutsnull2256 function FPuts(File_: BPTR; const String_: STRPTR): LongInt; syscall AOS_DOSBase 57;
VFWritefnull2257 function VFWritef(Fh: BPTR; const Fmt: STRPTR; const ArgArray: PLongInt): LongInt; syscall AOS_DOSBase 58;
VFPrintfnull2258 function VFPrintf(Fh: BPTR; const format: STRPTR; const ArgArray: PLongInt): LongInt; syscall AOS_DOSBase 59;
DOSFlushnull2259 function DOSFlush(File_: BPTR): LongInt; syscall AOS_DOSBase 60;
SetVBufnull2260 function SetVBuf(File_: BPTR; Buff: STRPTR; Type_: LongInt; Size: LongInt): LongInt; syscall AOS_DOSBase 61;
DupLockFromFHnull2261 function DupLockFromFH(Lock: BPTR): BPTR; syscall AOS_DOSBase 62;
OpenFromLocknull2262 function OpenFromLock(Lock: BPTR): BPTR; syscall AOS_DOSBase 63;
ParentOfFHnull2263 function ParentOfFH(Fh: BPTR): BPTR; syscall AOS_DOSBase 64;
ExamineFHnull2264 function ExamineFH(Fh: BPTR; Fib: PFileInfoBlock): LongBool; syscall AOS_DOSBase 65;
SetFileDatenull2265 function SetFileDate(const Name: STRPTR; Date: PDateStamp): LongBool; syscall AOS_DOSBase 66;
NameFromLocknull2266 function NameFromLock(Lock: BPTR; Buffer: STRPTR; Length: LongInt): LongBool; syscall AOS_DOSBase 67;
NameFromFHnull2267 function NameFromFH(Fh: BPTR; Buffer: STRPTR; Length: LongInt): LongBool; syscall AOS_DOSBase 68;
SplitNamenull2268 function SplitName(const Name: STRPTR; Seperator: LongWord; Buf: STRPTR; OldPos: LongInt; Size: LongInt): LongInt; syscall AOS_DOSBase 69;
SameLocknull2269 function SameLock(Lock1: BPTR; Lock2: BPTR): LongInt; syscall AOS_DOSBase 70;
SetModenull2270 function SetMode(Fh: BPTR; Mode: LongInt): LongBool; syscall AOS_DOSBase 71;
ExAllnull2271 function ExAll(Lock: BPTR; Buffer: PExAllData; Size: LongInt; Data: LongInt; Control: PExAllControl): LongBool; syscall AOS_DOSBase 72;
ReadLinknull2272 function ReadLink(Port: PMsgPort; Lock: LongInt; const Path: STRPTR; Buffer: STRPTR; Size: LongWord): LongInt; syscall AOS_DOSBase 73;
MakeLinknull2273 function MakeLink(const Name: STRPTR; Dest: APTR; Soft: LongInt): LongInt; syscall AOS_DOSBase 74;
ChangeModenull2274 function ChangeMode(Type_: LongWord; Object_: BPTR; NewMode: LongWord): LongBool; syscall AOS_DOSBase 75;
SetFileSizenull2275 function SetFileSize(File_: BPTR; Offset: LongInt; Mode: LongInt): LongInt; syscall AOS_DOSBase 76;
SetIoErrnull2276 function SetIoErr(Result_: LongInt): LongInt; syscall AOS_DOSBase 77;
Faultnull2277 function Fault(Code: LongInt; Header: STRPTR; Buffer: STRPTR; Len: LongInt): LongBool; syscall AOS_DOSBase 78;
PrintFaultnull2278 function PrintFault(Code: LongInt; const Header: STRPTR): LongBool; syscall AOS_DOSBase 79;
ErrorReportnull2279 function ErrorReport(Code: LongInt; Type_: LongInt; Arg1: IPTR; Device: PMsgPort): LongBool; syscall AOS_DOSBase 80;
DisplayErrornull2280 function DisplayError(FormstStr: STRPTR; Flags: LongWord; Args: APTR): LongInt; syscall AOS_DOSBase 81;
Clinull2281 function Cli: PCommandLineInterface; syscall AOS_DOSBase 82;
CreateNewProcnull2282 function CreateNewProc(const Tags: PTagItem): PProcess; syscall AOS_DOSBase 83;
CreateNewProcTagListnull2283 function CreateNewProcTagList(const Tags: PTagItem): PProcess; syscall AOS_DOSBase 83;
RunCommandnull2284 function RunCommand(SegList: BPTR; StackSize: LongWord; const ArgPtr: STRPTR; ArgSize: LongWord): LongInt; syscall AOS_DOSBase 84;
GetConsoleTasknull2285 function GetConsoleTask: PMsgPort; syscall AOS_DOSBase 85;
SetConsoleTasknull2286 function SetConsoleTask(const Handler: PMsgPort): PMsgPort; syscall AOS_DOSBase 86;
GetFileSysTasknull2287 function GetFileSysTask: PMsgPort; syscall AOS_DOSBase 87;
SetFileSysTasknull2288 function SetFileSysTask(const Task: PMsgPort): PMsgPort; syscall AOS_DOSBase 88;
GetArgStrnull2289 function GetArgStr: STRPTR; syscall AOS_DOSBase 89;
SetArgStrnull2290 function SetArgStr(const String_: STRPTR): STRPTR; syscall AOS_DOSBase 90;
FindCliProcnull2291 function FindCliProc(Num: LongWord): PProcess; syscall AOS_DOSBase 91;
MaxClinull2292 function MaxCli: LongWord; syscall AOS_DOSBase 92;
SetCurrentDirNamenull2293 function SetCurrentDirName(const Name: STRPTR): LongBool; syscall AOS_DOSBase 93;
GetCurrentDirNamenull2294 function GetCurrentDirName(Buf: STRPTR; Len: LongInt): LongBool; syscall AOS_DOSBase 94;
SetProgramNamenull2295 function SetProgramName(const Name: STRPTR): LongBool; syscall AOS_DOSBase 95;
GetProgramNamenull2296 function GetProgramName(Buf: STRPTR; Len: LongInt): LongBool; syscall AOS_DOSBase 96;
SetPromptnull2297 function SetPrompt(const Name: STRPTR): LongBool; syscall AOS_DOSBase 97;
GetPromptnull2298 function GetPrompt(Buf: STRPTR; Len: LongInt): LongBool; syscall AOS_DOSBase 98;
SetProgramDirnull2299 function SetProgramDir(Lock: BPTR): BPTR; syscall AOS_DOSBase 99;
GetProgramDirnull2300 function GetProgramDir: BPTR; syscall AOS_DOSBase 100;
SystemTagListnull2301 function SystemTagList(const Command: STRPTR; const Tags: PTagItem): LongInt; syscall AOS_DOSBase 101;
DOSSystemnull2302 function DOSSystem(const Command: STRPTR; const Tags: PTagItem): LongInt; syscall AOS_DOSBase 101;
AssignLocknull2303 function AssignLock(const Name: STRPTR; Lock: BPTR): LongInt; syscall AOS_DOSBase 102;
AssignLatenull2304 function AssignLate(const Name: STRPTR; const Path: STRPTR): LongBool; syscall AOS_DOSBase 103;
AssignPathnull2305 function AssignPath(const Name: STRPTR; const Path: STRPTR): LongBool; syscall AOS_DOSBase 104;
AssignAddnull2306 function AssignAdd(const Name: STRPTR; Lock: BPTR): LongBool; syscall AOS_DOSBase 105;
RemAssignListnull2307 function RemAssignList(const Name: STRPTR; Lock: BPTR): LongInt; syscall AOS_DOSBase 106;
GetDeviceProcnull2308 function GetDeviceProc(const Name: STRPTR; Dp: PDevProc): PDevProc; syscall AOS_DOSBase 107;
2309 procedure FreeDeviceProc(Dp: PDevProc); syscall AOS_DOSBase 108;
LockDosListnull2310 function LockDosList(Flags: LongWord): PDosList; syscall AOS_DOSBase 109;
2311 procedure UnLockDosList(Flags: LongWord); syscall AOS_DOSBase 110;
AttemptLockDosListnull2312 function AttemptLockDosList(Flags: LongWord): PDosList; syscall AOS_DOSBase 111;
RemDosEntrynull2313 function RemDosEntry(DList: PDosList): LongInt; syscall AOS_DOSBase 112;
AddDosEntrynull2314 function AddDosEntry(DList: PDosList): LongInt; syscall AOS_DOSBase 113;
FindDosEntrynull2315 function FindDosEntry(const DList: PDosList; const Name: STRPTR; Flags: LongWord): PDosList; syscall AOS_DOSBase 114;
NextDosEntrynull2316 function NextDosEntry(const DList: PDosList; Flags: LongWord): PDosList; syscall AOS_DOSBase 115;
MakeDosEntrynull2317 function MakeDosEntry(const Name: STRPTR; Type_: LongInt): PDosList; syscall AOS_DOSBase 116;
2318 procedure FreeDosEntry(DList: PDosList); syscall AOS_DOSBase 117;
IsFileSystemnull2319 function IsFileSystem(const Name: STRPTR): LongBool; syscall AOS_DOSBase 118;
DosFormatnull2320 function DosFormat(const DeviceName: STRPTR; const VolumeName: STRPTR; DosType: LongWord): LongBool; syscall AOS_DOSBase 119;
Relabelnull2321 function Relabel(const Drive: STRPTR; const NewName: STRPTR): LongInt; syscall AOS_DOSBase 120;
Inhibitnull2322 function Inhibit(const Name: STRPTR; OnOff: LongInt): LongInt; syscall AOS_DOSBase 121;
AddBuffersnull2323 function AddBuffers(const DeviceName: STRPTR; NumbBuffers: LongInt): LongBool; syscall AOS_DOSBase 122;
CompareDatesnull2324 function CompareDates(const Date1: PDateStamp; const Date2: PDateStamp): LongInt; syscall AOS_DOSBase 123;
DOSDateToStrnull2325 function DOSDateToStr(Datetime: _PDateTime): LongBool; syscall AOS_DOSBase 124;
DOSStrToDatenull2326 function DOSStrToDate(DateTime: _PDateTime): LongBool; syscall AOS_DOSBase 125;
InternalLoadSegnull2327 function InternalLoadSeg(Fh: BPTR; Table: BPTR; const FuncArray: PLongInt; var Stack: LongInt): BPTR; syscall AOS_DOSBase 126;
InternalUnLoadSegnull2328 function InternalUnLoadSeg(SegList: BPTR; FreeFunc: TProcedure): LongBool; syscall AOS_DOSBase 127;
NewLoadSegnull2329 function NewLoadSeg(const File_: STRPTR; const Tags: PTagItem): BPTR; syscall AOS_DOSBase 128;
NewLoadSegTagListnull2330 function NewLoadSegTagList(const File_: STRPTR; const Tags: PTagItem): BPTR; syscall AOS_DOSBase 128;
AddSegmentnull2331 function AddSegment(const Name: STRPTR; Seg: BPTR; Type_: LongInt): LongBool; syscall AOS_DOSBase 129;
FindSegmentnull2332 function FindSegment(const Name: STRPTR; const Seg: PSegment; System: LongBool): PSegment; syscall AOS_DOSBase 130;
RemSegmentnull2333 function RemSegment(Seg: PSegment): LongInt; syscall AOS_DOSBase 131;
CheckSignalnull2334 function CheckSignal(Mask: LongInt): LongInt; syscall AOS_DOSBase 132;
ReadArgsnull2335 function ReadArgs(const Template: STRPTR; Array_: PIPTR; RdArgs: PRDArgs): PRDArgs; syscall AOS_DOSBase 133;
FindArgnull2336 function FindArg(const Template: STRPTR; const KeyWord: STRPTR): LongInt; syscall AOS_DOSBase 134;
ReadItemnull2337 function ReadItem(const Buffer: STRPTR; MaxChars: LongInt; CSource: PCSource): LongInt; syscall AOS_DOSBase 135;
StrToLongnull2338 function StrToLong(const String_: STRPTR; var Value: LongInt): LongInt; syscall AOS_DOSBase 136;
MatchFirstnull2339 function MatchFirst(const Pat: STRPTR; AP: PAnchorPath): LongInt; syscall AOS_DOSBase 137;
MatchNextnull2340 function MatchNext(AP: PAnchorPath): LongInt; syscall AOS_DOSBase 138;
2341 procedure MatchEnd(AP: PAnchorPath); syscall AOS_DOSBase 139;
ParsePatternnull2342 function ParsePattern(const Source: STRPTR; Dest: STRPTR; DestLength: LongInt): LongInt; syscall AOS_DOSBase 140;
MatchPatternnull2343 function MatchPattern(const Pat: STRPTR; Str: STRPTR): LongBool; syscall AOS_DOSBase 141;
2344 procedure FreeArgs(Args: PRDArgs); syscall AOS_DOSBase 143;
FilePartnull2345 function FilePart(const Path: STRPTR): STRPTR; syscall AOS_DOSBase 145;
PathPartnull2346 function PathPart(const Path: STRPTR): STRPTR; syscall AOS_DOSBase 146;
AddPartnull2347 function AddPart(DirName: STRPTR; const FileName: STRPTR; Size: LongWord): LongBool; syscall AOS_DOSBase 147;
StartNotifynull2348 function StartNotify(Notify: PNotifyRequest): LongBool; syscall AOS_DOSBase 148;
2349 procedure EndNotify(Notify: PNotifyRequest); syscall AOS_DOSBase 149;
SetVarnull2350 function SetVar(const Name: STRPTR; Buffer: PChar; Size: LongInt; Flags: LongInt): LongBool;  syscall AOS_DOSBase 150;
GetVarnull2351 function GetVar(const Name: STRPTR; Buffer: STRPTR; Size: LongInt; Flags: LongInt): LongInt; syscall AOS_DOSBase 151;
DeleteVarnull2352 function DeleteVar(const Name: STRPTR; Flags: LongWord): LongInt; syscall AOS_DOSBase 152;
FindVarnull2353 function FindVar(const Name: STRPTR; Type_: LongWord): PLocalVar; syscall AOS_DOSBase 153;
CliInitnull2354 function CliInit(Dp: PDosPacket): IPTR; syscall AOS_DOSBase 154;
CliInitNewclinull2355 function CliInitNewcli(Dp: PDosPacket): IPTR; syscall AOS_DOSBase 155;
CliInitRunnull2356 function CliInitRun(Dp: PDosPacket): IPTR; syscall AOS_DOSBase 156;
WriteCharsnull2357 function WriteChars(const Buf: STRPTR; BufLen: LongWord): LongInt; syscall AOS_DOSBase 157;
PutStrnull2358 function PutStr(const String_: STRPTR): LongInt; syscall AOS_DOSBase 158;
VPrintfnull2359 function VPrintf(const Format: STRPTR; var ArgArray: IPTR): LongInt; syscall AOS_DOSBase 159;
ParsePatternNoCasenull2360 function ParsePatternNoCase(const Source: STRPTR; Dest: STRPTR; DestLen: LongInt): LongInt; syscall AOS_DOSBase 161;
MatchPatternNoCasenull2361 function MatchPatternNoCase(const Pat: STRPTR; Str: STRPTR): LongBool; syscall AOS_DOSBase 162;
DosGetStringnull2362 function DosGetString(StringNum: LongInt): STRPTR; syscall AOS_DOSBase 163;
SameDevicenull2363 function SameDevice(Lock1: BPTR; Lock2: BPTR): LongBool; syscall AOS_DOSBase 164;
2364 procedure ExAllEnd(Lock: BPTR; Buffer: PExAllData; Size: LongInt; Data: LongInt; Control: PExAllControl); syscall AOS_DOSBase 165;
SetOwnernull2365 function SetOwner(const Name: STRPTR; Owner_Info: LongWord): LongBool; syscall AOS_DOSBase 166;
ScanVarsnull2366 function ScanVars(Hook: PHook; Flags: LongWord; UserData: APTR): LongInt; syscall AOS_DOSBase 167;
2367 
2368 {$ifdef AROS_ABIv0}
RunHandlernull2369 function RunHandler(DevNode: PDeviceNode; Path: PChar): PMsgPort; syscall AOS_DOSBase 27;
DosErrornull2370 function DosError(): BPTR; syscall AOS_DOSBase 142;
SelectErrornull2371 function SelectError(Fh: BPTR): BPTR; syscall AOS_DOSBase 144;
Pipenull2372 function Pipe(const Name: STRPTR; var Reader: BPTR; var Writer: BPTR): LongInt; syscall AOS_DOSBase 160;
2373 {$endif}
2374 
2375 {$ifdef AROS_ABIv1}
DosErrornull2376 function DosError(): BPTR;
2377 {$endif}
2378 
ReadCharnull2379 function ReadChar(): LongInt;
WriteCharnull2380 function WriteChar(c: LongInt): LongInt;
UnReadCharnull2381 function UnReadChar(c: LongInt): LongInt;
2382 
2383 // Special functions for var args
AllocDosObjectTagsnull2384 function AllocDosObjectTags(const Type_: LongWord; const Tags: array of PtrUInt): APTR;
CreateNewProcTagsnull2385 function CreateNewProcTags(const Tags: array of PtrUInt): PProcess;
NewLoadSegTagsnull2386 function NewLoadSegTags(const File_: STRPTR; const Tags: array of PtrUInt): BPTR;
SystemTagsnull2387 function SystemTags(const Command: STRPTR; const Tags: array of PtrUInt): LongInt;
2388 
2389 // elf.h
2390 
ELF_ST_TYPEnull2391 function ELF_ST_TYPE(i: LongWord): LongWord;
2392 {$ifdef ELF_64BIT}
ELF_R_SYMnull2393 function ELF_R_SYM(i: QWord): QWord;
ELF_R_TYPEnull2394 function ELF_R_TYPE(i: QWord): QWord;
ELF_R_INFOnull2395 function ELF_R_INFO(Sym: QWord; Type_: QWord): QWord;
2396 {$else}
ELF_R_SYMnull2397 function ELF_R_SYM(i: LongWord): LongWord;
ELF_R_TYPEnull2398 function ELF_R_TYPE(i: LongWord): LongWord;
ELF_R_INFOnull2399 function ELF_R_INFO(Sym: LongWord; Type_: LongWord): LongWord;
2400 {$endif}
2401 
2402 const
2403   BNULL = nil;
2404 
MKBADDRnull2405 function MKBADDR(a: APTR): BPTR;
BADDRnull2406 function BADDR(a: BPTR): APTR;
2407 
2408 implementation
2409 
ELF_ST_TYPEnull2410 function ELF_ST_TYPE(i: LongWord): LongWord; inline;
2411 begin
2412   ELF_ST_TYPE := i and $0F;
2413 end;
2414 
2415 {$ifdef ELF_64BIT}
ELF_R_SYMnull2416   function ELF_R_SYM(i: QWord): QWord; inline;
2417   begin
2418     ELF_R_SYM := i shr 32;
2419   end;
2420 
ELF_R_TYPEnull2421   function ELF_R_TYPE(i: QWord): QWord; inline;
2422   begin
2423     ELF_R_TYPE := i and $ffffffff;
2424   end;
2425 
ELF_R_INFOnull2426   function ELF_R_INFO(Sym: QWord; Type_: QWord): QWord; inline;
2427   begin
2428     ELF_R_INFO := Sym shl 32 + Type_;
2429   end;
2430 {$else}
ELF_R_SYMnull2431   function ELF_R_SYM(i: LongWord): LongWord; inline;
2432   begin
2433     ELF_R_SYM := i shr 8;
2434   end;
2435 
ELF_R_TYPEnull2436   function ELF_R_TYPE(i: LongWord): LongWord; inline;
2437   begin
2438     ELF_R_TYPE := i and $ff;
2439   end;
2440 
ELF_R_INFOnull2441   function ELF_R_INFO(Sym: LongWord; Type_: LongWord): LongWord; inline;
2442   begin
2443     ELF_R_INFO := Sym shl 8 + (Type_ and $ff);
2444   end;
2445 {$endif}
2446 
AllocDosObjectTagsnull2447 function AllocDosObjectTags(const Type_: LongWord; const Tags: array of PtrUInt): APTR; inline;
2448 begin
2449   AllocDosObjectTags := AllocDosObject(Type_, @Tags);
2450 end;
2451 
CreateNewProcTagsnull2452 function CreateNewProcTags(const Tags: array of PtrUInt): PProcess; inline;
2453 begin
2454   CreateNewProcTags := CreateNewProc(@Tags);
2455 end;
2456 
NewLoadSegTagsnull2457 function NewLoadSegTags(const File_: STRPTR; const Tags: array of PtrUInt): BPTR; inline;
2458 begin
2459   NewLoadSegTags := NewLoadSeg(File_, @Tags);
2460 end;
2461 
SystemTagsnull2462 function SystemTags(const Command: STRPTR; const Tags: array of PtrUInt): LongInt; inline;
2463 begin
2464   SystemTags := SystemTagList(Command, @Tags);
2465 end;
2466 
MKBADDRnull2467 function MKBADDR(a: APTR): BPTR; inline;
2468 begin
2469   {$ifdef AROS_FAST_BPTR}
2470   MKBADDR := a;
2471   {$else}
2472   MKBADDR := APTR((IPTR(a)) shr 2);
2473   {$endif}
2474 end;
2475 
BADDRnull2476 function BADDR(a: BPTR): APTR; inline;
2477 begin
2478   {$ifdef AROS_FAST_BPTR}
2479   BADDR := a;
2480   {$else}
2481   BADDR := BPTR((IPTR(a)) shl 2);
2482   {$endif}
2483 end;
2484 
ReadCharnull2485 function ReadChar(): LongInt; inline;
2486 begin
2487   ReadChar := FGetC(DosInput());
2488 end;
2489 
WriteCharnull2490 function WriteChar(c: LongInt): LongInt; inline;
2491 begin
2492   WriteChar := FPutC(DosOutput(), c);
2493 end;
2494 
UnReadCharnull2495 function UnReadChar(c: LongInt): LongInt; inline;
2496 begin
2497   UnReadChar := UnGetC(DosInput(),c);
2498 end;
2499 
2500 {$ifdef AROS_ABIv1}
DosErrornull2501 function DosError(): BPTR;
2502 var
2503   P: PProcess;
2504 begin
2505   DosError := nil;
2506   P := PProcess(FindTask(nil));
2507   if Assigned(P) then
2508     DosError := P^.pr_CES;
2509   if DosError = nil then
2510     DosError := DosOutput();
2511 end;
2512 {$endif}
2513 
2514 end. (* UNIT DOS *)
2515 
2516 
2517