DEFINITION MODULE GetPSP;

  FROM SYSTEM IMPORT BYTE, ADDRESS;

  EXPORT QUALIFIED PSP, FCB, PSPptr, ENVIRptr, getarg, getenv;

  TYPE
    FCB = RECORD
        Drive: CHAR;
        FileName1: CHAR;
        FileName2: CHAR;
        FileName3: CHAR;
        FileName4: CHAR;
        FileName5: CHAR;
        FileName6: CHAR;
        FileName7: CHAR;
        FileName8: CHAR;
        Extension1: CHAR;
        Extension2: CHAR;
        Extension3: CHAR;
        CurrentBlock: CARDINAL;
        RecordSize: CARDINAL;
      END;

    PSP = RECORD                                                (* offset *)
      INT20H: ARRAY [0 .. 1] OF BYTE;                             (* 00H *)
      MemLimitSeg: CARDINAL;                                      (* 02H *)
      Reserved: BYTE;                                             (* 04H *)
      LongCall: BYTE; (* JUMP ADR(LongCall), not useful *)        (* 05H *)
      SegSize: CARDINAL; (* long call offset, not usefull *)      (* 06H *)
      LongCallSeg: CARDINAL; (* not usefull *)                    (* 08H *)
      Terminate: ADDRESS;                                         (* 0AH *)
      CTRLcExit: ADDRESS;                                         (* 0EH *)
      HardErrorExit: ADDRESS;                                     (* 12H *)
      DOS1: ARRAY [0 .. 15H] OF BYTE; (* do not use *)            (* 16H *)
      EnvironmentSeg: CARDINAL;                                   (* 2CH *)
      DOS2: ARRAY [0 .. 2DH] OF BYTE; (* do not use *)            (* 2EH *)
      FCB1: FCB;                                                  (* 5CH *)
      FCB2: FCB;                                                  (* 6CH *)
      Filler: ARRAY [0 .. 3] OF BYTE;                             (* 7CH *)
      commTail: ARRAY [0..127] OF CHAR; (* commTail[0] is size *) (* 80H *)
    END;

  VAR
    PSPptr: POINTER TO PSP;

    ENVIRptr: POINTER TO ARRAY [0 .. 7FFFH] OF CHAR;
      (* initialized from EnvironmentSeg *)

  TYPE
    argno = [0 .. 63];

  PROCEDURE getarg(argnum: argno; VAR arg: ARRAY OF CHAR);

  PROCEDURE getenv(key: ARRAY OF CHAR; VAR val: ARRAY OF CHAR);

  END GetPSP.
