(********************************************************************************

Name         : ExecUtil.DEF
Version      : 1.0
Purpose      : Additional NonLib Functions Provided in the C-Interface to Exec
Author       : ms
Modified     : 5.4.86  17:00 ms
Comments     : Don't know if these are all functions and if their interfaces
               are identical to the C-interfaces.
               AllocString is private function to get nul-terminated strings.
********************************************************************************)

DEFINITION MODULE ExecUtil;

FROM Exec   IMPORT MsgPortPtr, IOStdReq;
FROM SYSTEM IMPORT ADDRESS;

TYPE IOStdReqPtr = POINTER TO IOStdReq;

PROCEDURE AllocString(VAR p: ADDRESS; st: ARRAY OF CHAR);
(* Function: Allocate memory, copy the string and append a nul character.
   Inputs:   st: dynamic array of characters.
   Result:   p: Address of the string, or NIL if string was empty *)

PROCEDURE CreatePort(name: ARRAY OF CHAR; priority: INTEGER): MsgPortPtr;
(* Function: Allocate memory for a MsgPort structure,
             initialize and add it to the system's MsgPort-List.
   Inputs:   name: String; priority: [-128..127]
   Result:   pointer to the new MsgPort, or NIL if failed *)

PROCEDURE CreateStdIO(msgPort: MsgPortPtr): IOStdReqPtr;
(* Function: Allocate memory  for a IOStdReq structure and init.
   Input:    msgPort: pointer to MsgPort.
   Result:   pointer to the new IOStdReq, or NIL if failed *)

PROCEDURE DeallocString(VAR p: ADDRESS);
(* Function: Deallocate string allocated by AllocString.
   Input:    pointer to string, must be allocated by AllocString! 
   Result:   none. *)

PROCEDURE DeletePort(VAR msgPort: MsgPortPtr);
(* Function: Deallocate MsgPort allocated by CreatePort.
   Input:    pointer to MsgPort, must be allocated by CreatePort! 
   Result:   none. *)

PROCEDURE DeleteStdIO(VAR ioStdReq: IOStdReqPtr);
(* Function: Deallocate IOStdReq allocated by CreateStdIO.
   Input:    pointer to IOStdReq, must be allocated by CreateStdIO! 
   Result:   none. *)

END ExecUtil.
