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

  1. #ifndef LIBRARIES_DOSEXTENS_H
  2. #define LIBRARIES_DOSEXTENS_H
  3. /*
  4. **    $Filename: libraries/dosextens.h $
  5. **    $Release: 1.3 $
  6. **
  7. **    DOS structures not needed for the casual AmigaDOS user 
  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. #ifndef EXEC_TASKS_H
  17. #include "exec/tasks.h"
  18. #endif
  19. #ifndef EXEC_PORTS_H
  20. #include "exec/ports.h"
  21. #endif
  22. #ifndef EXEC_LIBRARIES_H
  23. #include "exec/libraries.h"
  24. #endif
  25.  
  26. #ifndef LIBRARIES_DOS_H
  27. #include "libraries/dos.h"
  28. #endif
  29.  
  30. /* All DOS processes have this structure */
  31. /* Create and Device Proc returns pointer to the MsgPort in this structure */
  32. /* dev_proc = (struct Process *) (DeviceProc(..) - sizeof(struct Task)); */
  33.  
  34. struct Process {
  35.     struct  Task    pr_Task;         
  36.     struct  MsgPort pr_MsgPort; /* This is BPTR address from DOS functions  */
  37.     WORD    pr_Pad;        /* Remaining variables on 4 byte boundaries */
  38.     BPTR    pr_SegList;        /* Array of seg lists used by this process  */
  39.     LONG    pr_StackSize;    /* Size of process stack in bytes        */
  40.     APTR    pr_GlobVec;        /* Global vector for this process (BCPL)    */
  41.     LONG    pr_TaskNum;        /* CLI task number of zero if not a CLI        */
  42.     BPTR    pr_StackBase;    /* Ptr to high memory end of process stack  */
  43.     LONG    pr_Result2;        /* Value of secondary result from last call */
  44.     BPTR    pr_CurrentDir;    /* Lock associated with current directory   */
  45.     BPTR    pr_CIS;        /* Current CLI Input Stream            */
  46.     BPTR    pr_COS;        /* Current CLI Output Stream            */
  47.     APTR    pr_ConsoleTask;    /* Console handler process for current window*/
  48.     APTR    pr_FileSystemTask;    /* File handler process for current drive   */
  49.     BPTR    pr_CLI;        /* pointer to ConsoleLineInterpreter        */
  50.     APTR    pr_ReturnAddr;    /* pointer to previous stack frame        */
  51.     APTR    pr_PktWait;        /* Function to be called when awaiting msg  */
  52.     APTR    pr_WindowPtr;    /* Window for error printing */
  53. };  /* Process */
  54.  
  55. /* The long word address (BPTR) of this structure is returned by
  56.  * Open() and other routines that return a file.  You need only worry
  57.  * about this struct to do async io's via PutMsg() instead of
  58.  * standard file system calls */
  59.  
  60. struct FileHandle {
  61.    struct Message *fh_Link;     /* EXEC message          */   
  62.    struct MsgPort *fh_Port;     /* Reply port for the packet */
  63.    struct MsgPort *fh_Type;     /* Port to do PutMsg() to  
  64.                   * Address is negative if a plain file */
  65.    LONG fh_Buf;
  66.    LONG fh_Pos;
  67.    LONG fh_End;
  68.    LONG fh_Funcs;
  69. #define fh_Func1 fh_Funcs
  70.    LONG fh_Func2;
  71.    LONG fh_Func3;
  72.    LONG fh_Args;
  73. #define fh_Arg1 fh_Args
  74.    LONG fh_Arg2;
  75. }; /* FileHandle */
  76.  
  77. /* This is the extension to EXEC Messages used by DOS */
  78.  
  79. struct DosPacket {
  80.    struct Message *dp_Link;     /* EXEC message          */
  81.    struct MsgPort *dp_Port;     /* Reply port for the packet */
  82.                  /* Must be filled in each send. */
  83.    LONG dp_Type;         /* See ACTION_... below and 
  84.                   * 'R' means Read, 'W' means Write to the
  85.                   * file system */
  86.    LONG dp_Res1;         /* For file system calls this is the result
  87.                   * that would have been returned by the
  88.                   * function, e.g. Write ('W') returns actual
  89.                   * length written */
  90.    LONG dp_Res2;         /* For file system calls this is what would
  91.                   * have been returned by IoErr() */
  92. /*  Device packets common equivalents */
  93. #define dp_Action  dp_Type
  94. #define dp_Status  dp_Res1
  95. #define dp_Status2 dp_Res2
  96. #define dp_BufAddr dp_Arg1
  97.    LONG dp_Arg1;            
  98.    LONG dp_Arg2;
  99.    LONG dp_Arg3;
  100.    LONG dp_Arg4;
  101.    LONG dp_Arg5;
  102.    LONG dp_Arg6;
  103.    LONG dp_Arg7;
  104. }; /* DosPacket */
  105.  
  106. /* A Packet does not require the Message to be before it in memory, but
  107.  * for convenience it is useful to associate the two. 
  108.  * Also see the function init_std_pkt for initializing this structure */
  109.  
  110. struct StandardPacket {
  111.    struct Message   sp_Msg;
  112.    struct DosPacket sp_Pkt;
  113. }; /* StandardPacket */
  114.  
  115. /* Packet types */
  116. #define ACTION_NIL        0
  117. #define ACTION_GET_BLOCK    2    /* OBSOLETE */
  118. #define ACTION_SET_MAP        4
  119. #define ACTION_DIE        5
  120. #define ACTION_EVENT        6
  121. #define ACTION_CURRENT_VOLUME    7
  122. #define ACTION_LOCATE_OBJECT    8
  123. #define ACTION_RENAME_DISK    9
  124. #define ACTION_WRITE        'W'
  125. #define ACTION_READ        'R'
  126. #define ACTION_FREE_LOCK    15
  127. #define ACTION_DELETE_OBJECT    16
  128. #define ACTION_RENAME_OBJECT    17
  129. #define ACTION_MORE_CACHE    18
  130. #define ACTION_COPY_DIR        19
  131. #define ACTION_WAIT_CHAR    20
  132. #define ACTION_SET_PROTECT    21
  133. #define ACTION_CREATE_DIR    22
  134. #define ACTION_EXAMINE_OBJECT    23
  135. #define ACTION_EXAMINE_NEXT    24
  136. #define ACTION_DISK_INFO    25
  137. #define ACTION_INFO        26
  138. #define ACTION_FLUSH        27
  139. #define ACTION_SET_COMMENT    28  
  140. #define ACTION_PARENT        29
  141. #define ACTION_TIMER        30
  142. #define ACTION_INHIBIT        31
  143. #define ACTION_DISK_TYPE    32
  144. #define ACTION_DISK_CHANGE    33
  145. #define ACTION_SET_DATE        34
  146.  
  147. #define ACTION_SCREEN_MODE    994
  148.  
  149. #define ACTION_READ_RETURN    1001
  150. #define ACTION_WRITE_RETURN    1002
  151. #define ACTION_SEEK        1008
  152. #define ACTION_FINDUPDATE    1004
  153. #define ACTION_FINDINPUT    1005
  154. #define ACTION_FINDOUTPUT    1006
  155. #define ACTION_END        1007
  156. #define ACTION_TRUNCATE        1022    /* fast file system only */
  157. #define ACTION_WRITE_PROTECT    1023    /* fast file system only */
  158.  
  159. /* DOS library node structure.
  160.  * This is the data at positive offsets from the library node.
  161.  * Negative offsets from the node is the jump table to DOS functions  
  162.  * node = (struct DosLibrary *) OpenLibrary( "dos.library" .. )         */
  163.    
  164. struct DosLibrary {
  165.     struct  Library dl_lib;
  166.     APTR    dl_Root;          /* Pointer to RootNode, described below */
  167.     APTR    dl_GV;          /* Pointer to BCPL global vector          */
  168.     LONG    dl_A2;          /* Private register dump of DOS          */
  169.     LONG    dl_A5;
  170.     LONG    dl_A6;
  171. };  /*    DosLibrary */
  172.  
  173. /*                   */
  174.  
  175. struct RootNode {
  176.     BPTR    rn_TaskArray;         /* [0] is max number of CLI's
  177.                       * [1] is APTR to process id of CLI 1
  178.                       * [n] is APTR to process id of CLI n */
  179.     BPTR    rn_ConsoleSegment; /* SegList for the CLI               */ 
  180.     struct  DateStamp rn_Time; /* Current time                   */
  181.     LONG    rn_RestartSeg;     /* SegList for the disk validator process   */
  182.     BPTR    rn_Info;           /* Pointer ot the Info structure           */
  183.     BPTR    rn_FileHandlerSegment; /* segment for a file handler       */
  184. };  /* RootNode */
  185.  
  186. struct DosInfo {
  187.     BPTR    di_McName;           /* Network name of this machine; currently 0 */
  188.     BPTR    di_DevInfo;           /* Device List                    */
  189.     BPTR    di_Devices;           /* Currently zero                */
  190.     BPTR    di_Handlers;       /* Currently zero                */
  191.     APTR    di_NetHand;           /* Network handler processid; currently zero */
  192. };  /* DosInfo */
  193.  
  194. /* DOS Processes started from the CLI via RUN or NEWCLI have this additional
  195.  * set to data associated with them */
  196.  
  197. struct CommandLineInterface {
  198.     LONG   cli_Result2;           /* Value of IoErr from last command      */  
  199.     BSTR   cli_SetName;           /* Name of current directory          */
  200.     BPTR   cli_CommandDir;     /* Lock associated with command directory  */
  201.     LONG   cli_ReturnCode;     /* Return code from last command          */
  202.     BSTR   cli_CommandName;    /* Name of current command          */
  203.     LONG   cli_FailLevel;      /* Fail level (set by FAILAT)          */
  204.     BSTR   cli_Prompt;           /* Current prompt (set by PROMPT)      */
  205.     BPTR   cli_StandardInput;  /* Default (terminal) CLI input          */
  206.     BPTR   cli_CurrentInput;   /* Current CLI input              */
  207.     BSTR   cli_CommandFile;    /* Name of EXECUTE command file          */
  208.     LONG   cli_Interactive;    /* Boolean; True if prompts required      */
  209.     LONG   cli_Background;     /* Boolean; True if CLI created by RUN      */
  210.     BPTR   cli_CurrentOutput;  /* Current CLI output              */
  211.     LONG   cli_DefaultStack;   /* Stack size to be obtained in long words */
  212.     BPTR   cli_StandardOutput; /* Default (terminal) CLI output          */
  213.     BPTR   cli_Module;           /* SegList of currently loaded command      */
  214. };  /* CommandLineInterface */
  215.  
  216. /* This structure can take on different values depending on whether it is
  217.  * a device, an assigned directory, or a volume.  Below is the structure
  218.  * reflecting volumes only.  Following that is the structure representing
  219.  * only devices. Following that is the unioned structure representing all 
  220.  * the values
  221.  */
  222.  
  223. /* structure representing a volume */
  224.  
  225. struct DeviceList {
  226.     BPTR        dl_Next;    /* bptr to next device list */
  227.     LONG        dl_Type;    /* see DLT below */
  228.     struct MsgPort *    dl_Task;    /* ptr to handler task */
  229.     BPTR        dl_Lock;    /* not for volumes */
  230.     struct DateStamp    dl_VolumeDate;    /* creation date */
  231.     BPTR        dl_LockList;    /* outstanding locks */
  232.     LONG        dl_DiskType;    /* 'DOS', etc */
  233.     LONG        dl_unused;
  234.     BSTR *        dl_Name;    /* bptr to bcpl name */
  235. };
  236.  
  237. /* device structure (same as the DeviceNode structure in filehandler.h) */
  238.  
  239. struct          DevInfo {
  240.     BPTR  dvi_Next;
  241.     LONG  dvi_Type;
  242.     APTR  dvi_Task;
  243.     BPTR  dvi_Lock;
  244.     BSTR  dvi_Handler;
  245.     LONG  dvi_StackSize;
  246.     LONG  dvi_Priority;
  247.     LONG  dvi_Startup;
  248.     BPTR  dvi_SegList;
  249.     BPTR  dvi_GlobVec;
  250.     BSTR  dvi_Name;
  251. };
  252.  
  253. /* combined structure for devices, assigned directories, volumes */
  254.  
  255. struct DosList {
  256.     BPTR        dol_Next;     /* bptr to next device on list */
  257.     LONG        dol_Type;     /* see DLT below */
  258.     struct MsgPort     *dol_Task;     /* ptr to handler task */
  259.     BPTR        dol_Lock;
  260.     union {
  261.     struct {
  262.     BSTR    dol_Handler;    /* file name to load if seglist is null */
  263.     LONG    dol_StackSize;    /* stacksize to use when starting process */
  264.     LONG    dol_Priority;    /* task priority when starting process */
  265.     ULONG    dol_Startup;    /* startup msg: FileSysStartupMsg for disks */
  266.     BPTR    dol_SegList;    /* already loaded code for new task */
  267.     BPTR    dol_GlobVec;    /* BCPL global vector to use when starting
  268.                  * a process. -1 indicates a C/Assembler
  269.                  * program. */
  270.     } dol_handler;
  271.  
  272.     struct {
  273.     struct DateStamp    dol_VolumeDate;     /* creation date */
  274.     BPTR            dol_LockList;     /* outstanding locks */
  275.     LONG            dol_DiskType;     /* 'DOS', etc */
  276.     } dol_volume;
  277.  
  278.     } dol_misc;
  279.  
  280.     BSTR        dol_Name;     /* bptr to bcpl name */
  281.     };
  282.     
  283.  
  284. /* definitions for dl_Type */
  285. #define DLT_DEVICE    0
  286. #define DLT_DIRECTORY    1
  287. #define DLT_VOLUME    2
  288.  
  289. /* a lock structure, as returned by Lock() or DupLock() */
  290. struct FileLock {
  291.     BPTR        fl_Link;    /* bcpl pointer to next lock */
  292.     LONG        fl_Key;        /* disk block number */
  293.     LONG        fl_Access;    /* exclusive or shared */
  294.     struct MsgPort *    fl_Task;    /* handler task's port */
  295.     BPTR        fl_Volume;    /* bptr to a DeviceList */
  296. };
  297.  
  298. #endif    /* LIBRARIES_DOSEXTENS_H */
  299.