use for all targets
[AROS.git] / compiler / include / dos / dos.h
blob48edfec1736771862ab885217d15cb9104eff685
1 #ifndef DOS_DOS_H
2 #define DOS_DOS_H
4 /*
5 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Basic DOS structures and constants
9 Lang: english
12 #ifndef EXEC_TYPES_H
13 # include <exec/types.h>
14 #endif
15 #ifndef DOS_BPTR_H
16 # include <dos/bptr.h>
17 #endif
18 #ifndef AROS_MACROS_H
19 # include <aros/macros.h>
20 #endif
22 /* The name of the dos.library. Use this constant instead of the string. */
23 #define DOSNAME "dos.library"
25 /* These constants may be used, but preferably, you should only test for
26 (un-)equality against DOSFALSE (i.e. 0). */
27 #define DOSTRUE (-1L)
28 #define DOSFALSE ( 0L)
30 /**********************************************************************
31 ******************************* Dates ********************************
32 **********************************************************************/
34 /* Other structures and defines for handling dates and time can be found in
35 <dos/datetime.h>. */
37 /* Number of so-called "ticks" in a second. */
38 #define TICKS_PER_SECOND 50
40 /* DateStamp structure as used in different library-functions. This
41 structure sufficiently describes a system-date and -time (i.e. any
42 date since 1.1.1978). */
43 struct DateStamp
45 LONG ds_Days; /* Number of days since 1.1.1978 */
46 LONG ds_Minute; /* Number of minutes since midnight */
47 LONG ds_Tick; /* Number of ticks (1/50 second) in the current minute
48 Note that this may not be exact */
51 /**********************************************************************
52 ******************************* Files ********************************
53 **********************************************************************/
55 /* The maximum length of filenames in AmigaOS. You should not depend on
56 this value, as it may change in future versions. */
57 #define MAXFILENAMELENGTH 108
59 /* The maximum length of comments in AmigaOS. You should not depend on
60 this value, as it may change in future versions. */
61 #define MAXCOMMENTLENGTH 80
63 /* Structure used to describe a directory entry. Note that not all fields
64 are supported by all filesystems. This structure should be allocated
65 with AllocDosObject(). */
66 struct FileInfoBlock64
68 IPTR fib_DiskKey;
69 /* See <dos/dosextens.h> for definitions. Generally: if this is >= 0
70 the file described is a directory, otherwise it is a plain file. */
71 LONG fib_DirEntryType;
72 /* The filename.
74 * User applications should always treat this as ASCIIZ.
76 * NOTE: This is created as a BCPL string in the ACTION_EXAMINE_*
77 * filesystem handler code, but is converted to a C style
78 * '\0'-terminated string by the Dos/Examine???() functions.
81 UBYTE fib_FileName[MAXFILENAMELENGTH];
82 LONG fib_Protection; /* The protection bits (see below). */
83 LONG fib_EntryType;
84 UQUAD fib_Size; /* The size of the file. */
85 UQUAD fib_NumBlocks; /* Number of blocks used for file. */
86 struct DateStamp fib_Date; /* Date of last change to file. */
87 /* The filecomment. Follows the same BSTR/CSTR rules as fib_FileName */
88 UBYTE fib_Comment[MAXCOMMENTLENGTH];
89 UWORD fib_OwnerUID; /* UserID of fileowner. */
90 UWORD fib_OwnerGID; /* GroupID of fileowner. */
91 UBYTE fib_Reserved[32]; /* PRIVATE */
94 struct FileInfoBlock32
96 IPTR fib_DiskKey;
97 /* See <dos/dosextens.h> for definitions. Generally: if this is >= 0
98 the file described is a directory, otherwise it is a plain file. */
99 LONG fib_DirEntryType;
100 /* The filename.
102 * User applications should always treat this as ASCIIZ.
104 * NOTE: This is created as a BCPL string in the ACTION_EXAMINE_*
105 * filesystem handler code, but is converted to a C style
106 * '\0'-terminated string by the Dos/Examine???() functions.
109 UBYTE fib_FileName[MAXFILENAMELENGTH];
110 LONG fib_Protection; /* The protection bits (see below). */
111 LONG fib_EntryType;
112 LONG fib_Size; /* The size of the file. */
113 LONG fib_NumBlocks; /* Number of blocks used for file. */
114 struct DateStamp fib_Date; /* Date of last change to file. */
115 /* The filecomment. Follows the same BSTR/CSTR rules as fib_FileName */
116 UBYTE fib_Comment[MAXCOMMENTLENGTH];
117 UWORD fib_OwnerUID; /* UserID of fileowner. */
118 UWORD fib_OwnerGID; /* GroupID of fileowner. */
119 UBYTE fib_Reserved[32]; /* PRIVATE */
122 #if (__DOS64)
123 #define FileInfoBlock FileInfoBlock64
124 #else
125 #define FileInfoBlock FileInfoBlock32
126 #endif
128 /* Protection bits for files (fib_Protection). */
129 /* Flags for owner (they are active-low, i.e. not set means the action is
130 allowed!) */
131 #define FIBB_DELETE 0 /* File is deleteable. */
132 #define FIBB_EXECUTE 1 /* File is executable (no scripts!). */
133 #define FIBB_WRITE 2 /* File is writable. */
134 #define FIBB_READ 3 /* File is readable. */
135 /* General flags, not owner-dependant. */
136 #define FIBB_ARCHIVE 4 /* File was archived (not used by OS). */
137 #define FIBB_PURE 5 /* Make program resident on execution. */
138 #define FIBB_SCRIPT 6 /* File is a script (DOS or ARexx). */
139 /* Flag number 7 is not defined. It used to describe different conditions
140 in different revisions of AmigaOS and was also misused as hidden flag.
141 Because of this confusion, this flag should not be used! */
142 /* Flags for group (meaning see above, these are high-active!). */
143 #define FIBB_GRP_DELETE 8
144 #define FIBB_GRP_EXECUTE 9
145 #define FIBB_GRP_WRITE 10
146 #define FIBB_GRP_READ 11
147 /* Flags for other/world (meaning see above, these are high-active!). */
148 #define FIBB_OTR_DELETE 12
149 #define FIBB_OTR_EXECUTE 13
150 #define FIBB_OTR_WRITE 14
151 #define FIBB_OTR_READ 15
153 #define FIBF_DELETE (1<<FIBB_DELETE)
154 #define FIBF_EXECUTE (1<<FIBB_EXECUTE)
155 #define FIBF_WRITE (1<<FIBB_WRITE)
156 #define FIBF_READ (1<<FIBB_READ)
157 #define FIBF_ARCHIVE (1<<FIBB_ARCHIVE)
158 #define FIBF_PURE (1<<FIBB_PURE)
159 #define FIBF_SCRIPT (1<<FIBB_SCRIPT)
160 #define FIBF_GRP_DELETE (1<<FIBB_GRP_DELETE)
161 #define FIBF_GRP_EXECUTE (1<<FIBB_GRP_EXECUTE)
162 #define FIBF_GRP_WRITE (1<<FIBB_GRP_WRITE)
163 #define FIBF_GRP_READ (1<<FIBB_GRP_READ)
164 #define FIBF_OTR_DELETE (1<<FIBB_OTR_DELETE)
165 #define FIBF_OTR_EXECUTE (1<<FIBB_OTR_EXECUTE)
166 #define FIBF_OTR_WRITE (1<<FIBB_OTR_WRITE)
167 #define FIBF_OTR_READ (1<<FIBB_OTR_READ)
169 /**********************************************************************
170 ****************************** Devices *******************************
171 **********************************************************************/
173 /* Structure used in Info(). Must be longword-aligned. */
174 struct InfoData64
176 LONG id_NumSoftErrors; /* Number of soft errors on device. */
177 LONG id_UnitNumber; /* Unit number of device. */
178 LONG id_DiskState; /* State the current volume is in (see below). */
179 UQUAD id_NumBlocks; /* Number of blocks on device. */
180 UQUAD id_NumBlocksUsed; /* Number of blocks in use. */
181 LONG id_BytesPerBlock; /* Bytes per block. */
182 LONG id_DiskType; /* Type of disk (see below). */
183 BPTR id_VolumeNode;
184 IPTR id_InUse; /* Set, if device is in use. */
187 struct InfoData32
189 LONG id_NumSoftErrors; /* Number of soft errors on device. */
190 LONG id_UnitNumber; /* Unit number of device. */
191 LONG id_DiskState; /* State the current volume is in (see below). */
192 LONG id_NumBlocks; /* Number of blocks on device. */
193 LONG id_NumBlocksUsed; /* Number of blocks in use. */
194 LONG id_BytesPerBlock; /* Bytes per block. */
195 LONG id_DiskType; /* Type of disk (see below). */
196 BPTR id_VolumeNode;
197 IPTR id_InUse; /* Set, if device is in use. */
200 #if (__DOS64)
201 #define InfoData InfoData64
202 #else
203 #define InfoData InfoData32
204 #endif
206 /* id_DiskState */
207 #define ID_WRITE_PROTECTED 80 /* Volume is write-protected. */
208 #define ID_VALIDATING 81 /* Volume is currently validating. */
209 #define ID_VALIDATED 82 /* Volume is ready to be read and written. */
211 /* Filesystem types as used for id_DiskType. These are multi-character
212 constants of identifier strings. They are self-descriptive. */
213 #define ID_NO_DISK_PRESENT (-1L)
214 #define ID_UNREADABLE_DISK AROS_MAKE_ID('B','A','D',0)
215 #define ID_DOS_DISK AROS_MAKE_ID('D','O','S',0)
216 #define ID_FFS_DISK AROS_MAKE_ID('D','O','S',1)
217 #define ID_INTER_DOS_DISK AROS_MAKE_ID('D','O','S',2)
218 #define ID_INTER_FFS_DISK AROS_MAKE_ID('D','O','S',3)
219 #define ID_FASTDIR_DOS_DISK AROS_MAKE_ID('D','O','S',4)
220 #define ID_FASTDIR_FFS_DISK AROS_MAKE_ID('D','O','S',5)
221 #define ID_NOT_REALLY_DOS AROS_MAKE_ID('N','D','O','S')
222 #define ID_KICKSTART_DISK AROS_MAKE_ID('K','I','C','K')
223 #define ID_MSDOS_DISK AROS_MAKE_ID('M','S','D',0)
224 #define ID_SFS_BE_DISK AROS_MAKE_ID('S','F','S',0)
225 #define ID_SFS_LE_DISK AROS_MAKE_ID('s','f','s',0)
227 /**********************************************************************
228 **************** Program Execution and Error Handling ****************
229 **********************************************************************/
231 /* Return conditions for programs. */
232 #define RETURN_OK 0
233 /* Program succeeded. */
234 #define RETURN_WARN 5
235 /* Program succeeded, but there was something not quite right. This value
236 may also be used to express a boolean state (RETURN_WARN meaning TRUE,
237 RETURN_OK meaning FALSE). */
238 #define RETURN_ERROR 10
239 /* Program succeeded partly. This may be returned, if the user aborts a
240 program or some external data were wrong. */
241 #define RETURN_FAIL 20
242 /* Program execution failed. Normally used, if some system resources could
243 not be allocated. */
246 /* Secondary errors codes as used for IoErr(), SetIoErr() and in
247 Process->pr_Result2. The term 'object' refers to files of all kinds
248 (ie plain files, directories, links, etc). */
250 /* This is used, if something went wrong, but it is unknown what exactly
251 went wrong. This is especially useful for emulation devices, when the
252 underlying system returned an error that the emulation side does not
253 know. */
254 #define ERROR_UNKNOWN 100
257 /* General system errors */
258 /* Out of memory. */
259 #define ERROR_NO_FREE_STORE 103
260 /* Too many tasks are already running. */
261 #define ERROR_TASK_TABLE_FULL 105
263 /* Errors concerning ReadArgs(). See also <dos/rdargs.h>. */
264 /* Supplied template is broken */
265 #define ERROR_BAD_TEMPLATE 114
266 /* A supplied argument that was expected to be numeric, was not numeric.
267 This is also returned by some functions to expresss that a supplied
268 number is out of range (ie to express application internal errors). */
269 #define ERROR_BAD_NUMBER 115
270 /* An argument that has to be supplied (ie signed with the '/A' flag) was
271 not supplied. */
272 #define ERROR_REQUIRED_ARG_MISSING 116
273 /* Keyword was specified, but not its contents. */
274 #define ERROR_KEY_NEEDS_ARG 117
275 /* There were more arguments than the template needs. */
276 #define ERROR_TOO_MANY_ARGS 118
277 /* An odd number of quotation marks was supplied. */
278 #define ERROR_UNMATCHED_QUOTES 119
279 /* Either the command-line was longer than hardcoded line length limit or the
280 maximum number of multiple arguments (flag '/M') was exceeded. This can
281 also indicate that some argument is too long or a supplied buffer is too
282 small. */
283 #define ERROR_LINE_TOO_LONG 120
285 /* Errors in files. */
286 /* You tried to execute a file that is not an executable. */
287 #define ERROR_FILE_NOT_OBJECT 121
288 /* A library or device could not be opened or that library or device is
289 broken. */
290 #define ERROR_INVALID_RESIDENT_LIBRARY 122
291 #define ERROR_NO_DEFAULT_DIR 201
292 /* The accessed object is already in use (eg locked) by another task. */
293 #define ERROR_OBJECT_IN_USE 202
294 /* You tried to overwrite an object. */
295 #define ERROR_OBJECT_EXISTS 203
296 /* The given directory or the path of a given object does not exist. */
297 #define ERROR_DIR_NOT_FOUND 204
298 /* The given object does not exist. */
299 #define ERROR_OBJECT_NOT_FOUND 205
301 /* Miscellaneous errors. */
302 #define ERROR_BAD_STREAM_NAME 206
303 /* The given object is too large for the operation to be done. Object in
304 this context is for example a component of a path name. */
305 #define ERROR_OBJECT_TOO_LARGE 207
306 /* This is usually used to indicate that a filesystem does not support a
307 certain action, but may generally also be used by functions. */
308 #define ERROR_ACTION_NOT_KNOWN 209
309 /* A path component was invalid (eg there were multiple colons in a path
310 name). */
311 #define ERROR_INVALID_COMPONENT_NAME 210
312 #define ERROR_INVALID_LOCK 211
313 /* You tried to perform an action on an object, which this kind of object
314 does not support (eg makedir on a file). */
315 #define ERROR_OBJECT_WRONG_TYPE 212
316 /* Writing failed, because the volume is not validated. */
317 #define ERROR_DISK_NOT_VALIDATED 213
318 /* Writing failed, because the volume is write-protected. */
319 #define ERROR_DISK_WRITE_PROTECTED 214
320 /* You tried to move/rename a file across different devices. Rename does only
321 work on the same device, as only the inode-data has to be changed to
322 perform that action. */
323 #define ERROR_RENAME_ACROSS_DEVICES 215
324 /* You tried to delete a directory that still contains some files. Delete
325 these files first. */
326 #define ERROR_DIRECTORY_NOT_EMPTY 216
327 /* A recursive directory search could not be performed, because the stack
328 was too small. */
329 #define ERROR_TOO_MANY_LEVELS 217
330 /* You tried to access a device that is currently not mounted. */
331 #define ERROR_DEVICE_NOT_MOUNTED 218
332 /* An error occured, while executing Seek(). */
333 #define ERROR_SEEK_ERROR 219
334 /* The supplied file comment was longer than the hardcoded length limit for
335 file comments. */
336 #define ERROR_COMMENT_TOO_BIG 220
337 /* A write-operation could not be performed, because the volume has no space
338 left. */
339 #define ERROR_DISK_FULL 221
340 /* You tried to delete a delete-protected object. */
341 #define ERROR_DELETE_PROTECTED 222
342 /* You tried to write to a write-protected object. This does not mean that
343 the volume, you wanted to write to, is write-protected! */
344 #define ERROR_WRITE_PROTECTED 223
345 /* You tried to read a read-protected object. */
346 #define ERROR_READ_PROTECTED 224
347 /* Accessed disk is unreadable. */
348 #define ERROR_NOT_A_DOS_DISK 225
349 /* You tried to perform an action on a device that has no volume mounted
350 (eg. an empty disk drive). */
351 #define ERROR_NO_DISK 226
352 /* This does not indicate an error, but is returned by several functions to
353 indicate that the last entry of a list was reached. */
354 #define ERROR_NO_MORE_ENTRIES 232
355 /* Given action can not be performed on a given object, because it is a
356 soft-link. This is usually only used by filesystem handlers and is catched
357 by dos. Applications should not see this. */
358 #define ERROR_IS_SOFT_LINK 233
359 /* Given action can not be performed on a given object, because it is a link.
361 #define ERROR_OBJECT_LINKED 234
362 /* There was a bad hunk in a file that was to load. */
363 #define ERROR_BAD_HUNK 235
364 /* Indicates that a function does not implement a certain functionality.
365 There are more special error conditions (ERROR_BAD_NUMBER and
366 ERROR_ACTION_NOT_KNOWN), which should be preferred, if applicable. */
367 #define ERROR_NOT_IMPLEMENTED 236
368 /* You tried to access a record that was not locked. */
369 #define ERROR_RECORD_NOT_LOCKED 240
370 /* Somebody already locked a part of the record, you wanted to lock. */
371 #define ERROR_LOCK_COLLISION 241
372 /* LockRecord() timed out. */
373 #define ERROR_LOCK_TIMEOUT 242
374 /* An error occured, while unlocking a record. */
375 #define ERROR_UNLOCK_ERROR 243
377 /* Further errors are defined in dosasl.h amd filesystem.h as well */
379 /* Maximum length of strings got from Fault(). Note that they should be
380 shorter than 60 characters. */
381 #define FAULT_MAX 82
383 /* Signals that are set, if the user presses the corresponding keys on
384 the controlling terminal. They may also be sent by using Signal().
385 For more information see <exec/tasks.h>. */
386 #define SIGBREAKB_CTRL_C 12 /* CTRL-c, usually meaning program abortion. */
387 #define SIGBREAKB_CTRL_D 13 /* CTRL-d */
388 #define SIGBREAKB_CTRL_E 14 /* CTRL-e, usually meaning that the application
389 should iconify itself. */
390 #define SIGBREAKB_CTRL_F 15 /* CTRL-f, usually meaning that the application
391 should uniconify itself. */
393 #define SIGBREAKF_CTRL_C (1L<<SIGBREAKB_CTRL_C)
394 #define SIGBREAKF_CTRL_D (1L<<SIGBREAKB_CTRL_D)
395 #define SIGBREAKF_CTRL_E (1L<<SIGBREAKB_CTRL_E)
396 #define SIGBREAKF_CTRL_F (1L<<SIGBREAKB_CTRL_F)
398 /**********************************************************************
399 ********************** Constants for Functions ***********************
400 **********************************************************************/
402 /* Modes for Open(). */
403 /* Try to open old file. If it does not exist, Open() returns an error. */
404 #define MODE_OLDFILE 1005
405 /* A new file is created, even if a file with the supplied name does
406 already exist. */
407 #define MODE_NEWFILE 1006
408 /* An old file is opened. If it does not exist, a new one is created. */
409 #define MODE_READWRITE 1004
411 /* Locking mechanism as used in Lock() */
412 /* Non-exclusive lock, other tasks may lock this file as well. This is used
413 for read-only operations. */
414 #define SHARED_LOCK -2
415 #define ACCESS_READ -2
416 /* Exclusive lock, other tasks may not lock this file. This is used for write
417 operations. */
418 #define EXCLUSIVE_LOCK -1
419 #define ACCESS_WRITE -1
421 /* Returned by SameLock(). See autodocs for description. */
422 #define LOCK_DIFFERENT -1
423 #define LOCK_SAME 0
424 #define LOCK_SAME_VOLUME 1
426 /* Used in MakeLink() */
427 #define LINK_HARD 0
428 #define LINK_SOFT 1
430 /* Used in Seek() */
431 #define OFFSET_BEGINNING -1
432 #define OFFSET_CURRENT 0
433 #define OFFSET_END 1
435 /* Limits of the "int" type */
436 #define MAXINT ((int)(((unsigned int)~0)/2))
437 #define MININT (-MAXINT - 1)
439 /* Used in ChangeMode() */
440 #define CHANGE_LOCK 0
441 #define CHANGE_FH 1
443 /* Returned by ReadItem() */
444 #define ITEM_EQUAL -2
445 #define ITEM_ERROR -1
446 #define ITEM_NOTHING 0
447 #define ITEM_UNQUOTED 1
448 #define ITEM_QUOTED 2
450 /* The types for AllocDosObject() and FreeDosObject(). They specifiy which
451 kind of structure is to be allocated. */
452 #define DOS_FILEHANDLE 0 /* struct FileHandle <dos/dosextens.h> */
453 #define DOS_EXALLCONTROL 1 /* struct ExAllControl <dos/exall.h> */
454 #define DOS_FIB 2 /* struct FileInfoBlock (see above) */
455 #define DOS_STDPKT 3 /* struct DosPacket <dos/dosextens.h> */
456 #define DOS_CLI 4 /* struct CommandLineInterface <dos/dosextens.h> */
457 #define DOS_RDARGS 5 /* struct RDArgs <dos/rdargs.h> */
459 #endif /* DOS_DOS_H */