home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Inc&AD1.3 / Includes / libraries / dos.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-12  |  6.9 KB  |  186 lines

  1. #ifndef LIBRARIES_DOS_H
  2. #define LIBRARIES_DOS_H
  3. /*
  4. **    $Filename: libraries/dos.h $
  5. **    $Release: 1.3 $
  6. **
  7. **    Standard C header for AmigaDOS 
  8. **
  9. **    (C) Copyright 1985,1986,1987,1988 Commodore-Amiga, Inc.
  10. **        All Rights Reserved
  11. */
  12.  
  13. #ifndef EXEC_TYPES_H
  14. #include "exec/types.h"
  15. #endif
  16.  
  17. #define     DOSNAME  "dos.library"
  18.  
  19. /* Predefined Amiga DOS global constants */
  20.  
  21. #define DOSTRUE (-1L)
  22. #define DOSFALSE (0L)
  23.  
  24. /* Mode parameter to Open() */
  25. #define MODE_OLDFILE         1005   /* Open existing file read/write 
  26.                      * positioned at beginning of file. */
  27. #define MODE_NEWFILE         1006   /* Open freshly created file (delete 
  28.                      * old file) read/write           */
  29. #define MODE_READWRITE         1004   /* Open old file w/exclusive lock */
  30. /* Relative position to Seek() */
  31. #define OFFSET_BEGINNING    -1        /* relative to Begining Of File */
  32. #define OFFSET_CURRENT         0        /* relative to Current file position */
  33. #define OFFSET_END         1        /* relative to End Of File      */
  34.  
  35. #define OFFSET_BEGINING        OFFSET_BEGINNING  /* ancient compatibility */
  36.  
  37. #define BITSPERBYTE         8
  38. #define BYTESPERLONG         4
  39. #define BITSPERLONG         32
  40. #define MAXINT             0x7FFFFFFF
  41. #define MININT             0x80000000
  42.  
  43. /* Passed as type to Lock() */
  44. #define SHARED_LOCK         -2        /* File is readable by others */
  45. #define ACCESS_READ         -2        /* Synonym */
  46. #define EXCLUSIVE_LOCK         -1        /* No other access allowed      */
  47. #define ACCESS_WRITE         -1        /* Synonym */
  48.  
  49. struct DateStamp {
  50.    LONG     ds_Days;          /* Number of days since Jan. 1, 1978 */
  51.    LONG     ds_Minute;          /* Number of minutes past midnight */
  52.    LONG     ds_Tick;          /* Number of ticks past minute */
  53. }; /* DateStamp */
  54. #define TICKS_PER_SECOND      50   /* Number of ticks in one second */
  55.  
  56. /* Returned by Examine() and ExInfo(), must be on a 4 byte boundary */
  57. struct FileInfoBlock {
  58.    LONG      fib_DiskKey;
  59.    LONG      fib_DirEntryType;  /* Type of Directory. If < 0, then a plain file.
  60.                   * If > 0 a directory */
  61.    char      fib_FileName[108]; /* Null terminated. Max 30 chars used for now */
  62.    LONG      fib_Protection;    /* bit mask of protection, rwxd are 3-0.       */
  63.    LONG      fib_EntryType;
  64.    LONG      fib_Size;         /* Number of bytes in file */
  65.    LONG      fib_NumBlocks;     /* Number of blocks in file */
  66.    struct DateStamp fib_Date;/* Date file last changed */
  67.    char      fib_Comment[80];  /* Null terminated comment associated with file */
  68.    char      fib_Reserved[36];
  69. }; /* FileInfoBlock */
  70.  
  71. /* FIB stands for FileInfoBlock */
  72.  
  73. /* FIBB are bit definitions, FIBF are field definitions */
  74. #define FIBB_SCRIPT    6    /* program is a script (execute) file */
  75. #define FIBB_PURE      5    /* program is reentrant and rexecutable*/
  76. #define FIBB_ARCHIVE   4        /* cleared whenever file is changed */
  77. #define FIBB_READ      3        /* ignored by old filesystem */
  78. #define FIBB_WRITE     2        /* ignored by old filesystem */
  79. #define FIBB_EXECUTE   1        /* ignored by system, used by Shell */
  80. #define FIBB_DELETE    0        /* prevent file from being deleted */
  81. #define FIBF_SCRIPT    (1<<FIBB_SCRIPT)
  82. #define FIBF_PURE      (1<<FIBB_PURE)
  83. #define FIBF_ARCHIVE   (1<<FIBB_ARCHIVE)
  84. #define FIBF_READ      (1<<FIBB_READ)
  85. #define FIBF_WRITE     (1<<FIBB_WRITE)
  86. #define FIBF_EXECUTE   (1<<FIBB_EXECUTE)
  87. #define FIBF_DELETE    (1<<FIBB_DELETE)
  88.  
  89.  
  90. /* All BCPL data must be long word aligned.  BCPL pointers are the long word
  91.  *  address (i.e byte address divided by 4 (>>2)) */
  92. typedef long  BPTR;            /* Long word pointer */
  93. typedef long  BSTR;            /* Long word pointer to BCPL string     */
  94.  
  95. /* Convert BPTR to typical C pointer */
  96. #ifdef OBSOLETE_LIBRARIES_DOS_H
  97. #define BADDR( bptr )    (((ULONG)bptr) << 2)
  98. #else
  99. /* This one has no problems with CASTing */
  100. #define BADDR(x)    ((APTR)((ULONG)x << 2))
  101. #endif
  102.  
  103. /* BCPL strings have a length in the first byte and then the characters.
  104.  * For example:     s[0]=3 s[1]=S s[2]=Y s[3]=S                 */
  105.  
  106. /* returned by Info(), must be on a 4 byte boundary */
  107. struct InfoData { 
  108.    LONG      id_NumSoftErrors;    /* number of soft errors on disk */
  109.    LONG      id_UnitNumber;    /* Which unit disk is (was) mounted on */
  110.    LONG      id_DiskState;        /* See defines below */
  111.    LONG      id_NumBlocks;        /* Number of blocks on disk */
  112.    LONG      id_NumBlocksUsed;    /* Number of block in use */
  113.    LONG      id_BytesPerBlock;   
  114.    LONG      id_DiskType;        /* Disk Type code */
  115.    BPTR      id_VolumeNode;    /* BCPL pointer to volume node */
  116.    LONG      id_InUse;        /* Flag, zero if not in use */
  117. }; /* InfoData */
  118.  
  119. /* ID stands for InfoData */
  120.     /* Disk states */
  121. #define ID_WRITE_PROTECTED 80     /* Disk is write protected */
  122. #define ID_VALIDATING       81     /* Disk is currently being validated */
  123. #define ID_VALIDATED       82     /* Disk is consistent and writeable */
  124.  
  125.     /* Disk types */
  126. #define ID_NO_DISK_PRESENT    (-1)
  127. #define ID_UNREADABLE_DISK    (('B'<<24) | ('A'<<16) | ('D'<<8))
  128. #define ID_DOS_DISK        (('D'<<24) | ('O'<<16) | ('S'<<8))
  129. #define ID_NOT_REALLY_DOS    (('N'<<24) | ('D'<<16) | ('O'<<8) | ('S'))
  130. #define ID_KICKSTART_DISK    (('K'<<24) | ('I'<<16) | ('C'<<8) | ('K'))
  131.  
  132. /* Errors from IoErr(), etc. */
  133. #define ERROR_NO_FREE_STORE          103
  134. #define ERROR_TASK_TABLE_FULL          105
  135. #define ERROR_LINE_TOO_LONG          120
  136. #define ERROR_FILE_NOT_OBJECT          121
  137. #define ERROR_INVALID_RESIDENT_LIBRARY      122
  138. #define ERROR_NO_DEFAULT_DIR          201
  139. #define ERROR_OBJECT_IN_USE          202
  140. #define ERROR_OBJECT_EXISTS          203
  141. #define ERROR_DIR_NOT_FOUND          204
  142. #define ERROR_OBJECT_NOT_FOUND          205
  143. #define ERROR_BAD_STREAM_NAME          206
  144. #define ERROR_OBJECT_TOO_LARGE          207
  145. #define ERROR_ACTION_NOT_KNOWN          209
  146. #define ERROR_INVALID_COMPONENT_NAME      210
  147. #define ERROR_INVALID_LOCK          211
  148. #define ERROR_OBJECT_WRONG_TYPE          212
  149. #define ERROR_DISK_NOT_VALIDATED      213
  150. #define ERROR_DISK_WRITE_PROTECTED      214
  151. #define ERROR_RENAME_ACROSS_DEVICES      215
  152. #define ERROR_DIRECTORY_NOT_EMPTY      216
  153. #define ERROR_TOO_MANY_LEVELS          217
  154. #define ERROR_DEVICE_NOT_MOUNTED      218
  155. #define ERROR_SEEK_ERROR          219
  156. #define ERROR_COMMENT_TOO_BIG          220    
  157. #define ERROR_DISK_FULL              221
  158. #define ERROR_DELETE_PROTECTED          222
  159. #define ERROR_WRITE_PROTECTED          223 
  160. #define ERROR_READ_PROTECTED          224
  161. #define ERROR_NOT_A_DOS_DISK          225
  162. #define ERROR_NO_DISK              226
  163. #define ERROR_NO_MORE_ENTRIES          232
  164.  
  165. /* These are the return codes used by convention by AmigaDOS commands */
  166. /* See FAILAT and IF for relvance to EXECUTE files              */
  167. #define RETURN_OK                0  /* No problems, success */
  168. #define RETURN_WARN                5  /* A warning only */
  169. #define RETURN_ERROR               10  /* Something wrong */
  170. #define RETURN_FAIL               20  /* Complete or severe failure*/
  171.  
  172. /* Bit numbers that signal you that a user has issued a break */
  173. #define SIGBREAKB_CTRL_C   12
  174. #define SIGBREAKB_CTRL_D   13
  175. #define SIGBREAKB_CTRL_E   14
  176. #define SIGBREAKB_CTRL_F   15
  177.  
  178. /* Bit fields that signal you that a user has issued a break */
  179. /* for example:     if (SetSignal(0,0) & BREAK_CTRL_CF) cleanup_and_exit(); */
  180. #define SIGBREAKF_CTRL_C   (1<<SIGBREAKB_CTRL_C)
  181. #define SIGBREAKF_CTRL_D   (1<<SIGBREAKB_CTRL_D)
  182. #define SIGBREAKF_CTRL_E   (1<<SIGBREAKB_CTRL_E)
  183. #define SIGBREAKF_CTRL_F   (1<<SIGBREAKB_CTRL_F)
  184.  
  185. #endif    /* LIBRARIES_DOS_H */
  186.