-- Copyright (C) 1986  by Xerox Corporation. All rights reserved. 
--  CEnvUtil.mesa
--  NFS   29-May-86 11:53:11

--  Absorbs environment dependencies of CEnv.
--  A different implementation is needed for each environment
--  in which CEnvironment runs.

DIRECTORY
  CString USING [CString],
  Stream USING [Handle, Object],
  TTY USING [Handle];
  
CEnvUtil:DEFINITIONS = {

  FileHandle:TYPE[2];
  LoadHandle:TYPE[2];
  Data:TYPE;    -- data for each window or exec instance
  DataHandle:TYPE = LONG POINTER TO Data;
  ArgSeq:TYPE = LONG POINTER TO StringSeq;
  ToolType:TYPE = {ctool, cexec, temp};
  StringSeq:TYPE = RECORD[
    length:CARDINAL,
    argVSeq:SEQUENCE maxlength:CARDINAL OF CString.CString];
  StandardStream:TYPE = {stdin,stdout,stderr};
  StdinHandle:TYPE = LONG POINTER TO StdinObject;
  StdinObject:TYPE = RECORD[
      object:Stream.Object,
      mode:INTEGER];
  Outcome:TYPE = INTEGER;
  normal:Outcome = 0;
  error:Outcome = -1;
  AppendCmdProc:TYPE = PROCEDURE[
    buffer:LONG POINTER TO LONG STRING] RETURNS[lineDeleted:BOOLEAN];
  
  
  FileError:ERROR[message:LONG STRING];
  StdStreamError:ERROR[whichStream:StandardStream];
  SystemCall:SIGNAL[string:LONG STRING] RETURNS[INTEGER];
  
  
  zone:UNCOUNTED ZONE;
  
  
  ReadAndRun:PROCEDURE[
    data:DataHandle,tH:TTY.Handle,appendCmd:AppendCmdProc]
    RETURNS[outcome: Outcome];
  ParseLine:PROCEDURE[buffer:LONG STRING]
      RETURNS[name:LONG STRING ← NIL,argC:CARDINAL ← 0,argV:ArgSeq ← NIL];
  Print:PROCEDURE[msg:LONG STRING,data:DataHandle];
  Blink:PROCEDURE;
  AcquireFile:PROCEDURE[name:LONG STRING] RETURNS[fh:FileHandle];
  ReleaseFile:PROCEDURE[fh:FileHandle];
  UniqueFilePrefix:PROCEDURE[fileName:LONG STRING] RETURNS[matches: CARDINAL];
  GetFileInputStream:PROCEDURE[buffer:LONG STRING] RETURNS[sH:Stream.Handle];
  AppendLine:PROCEDURE[
    line:LONG POINTER TO LONG STRING,getChar:PROC RETURNS[c:CHAR]];
  GetStdStreams:PROCEDURE[
    data:DataHandle,defaultStdin,defaultStdout,defaultStderr:Stream.Handle]
    RETURNS[stdin,stdout,stderr:Stream.Handle];
  ChangeStandardStreams:PROCEDURE[buffer:LONG STRING,data:DataHandle];
  ChangeSwitches:PROCEDURE[buffer:LONG STRING,data:DataHandle];
  PrintStatus:PROCEDURE[data:DataHandle,tty:TTY.Handle];
  Debugging:PROCEDURE[data:DataHandle] RETURNS[BOOLEAN];
  StopOnError:PROCEDURE[data:DataHandle] RETURNS[BOOLEAN];
  EndingToolInstance:PROCEDURE[data:DataHandle] RETURNS[BOOLEAN];
  RegisterItems:PROCEDURE; -- for registering commands or menu items
  IsItDefaultStdin:PROCEDURE[sH:Stream.Handle] RETURNS[BOOLEAN];
  MakeDataForSystemCall:PROCEDURE RETURNS[newData:DataHandle];
  StopIfCExec:PROCEDURE[data:DataHandle];
  GetFirstWord:PROCEDURE[buffer:LONG STRING] RETURNS[firstWord:LONG STRING];
  Unload:PROCEDURE[cmdLine:LONG STRING,tty:TTY.Handle]
    RETURNS[outcome:Outcome];
  ShowHandles:PROCEDURE[cmdLine:LONG STRING,tty:TTY.Handle]
    RETURNS[outcome:Outcome];
  GetPrompt:PROCEDURE RETURNS[prompt:LONG STRING ← NIL];
  UpdateLogReadLength:PROCEDURE[data:DataHandle];
  FreeData:PROCEDURE[h: DataHandle];
  SetOutputMode: PROCEDURE [h: DataHandle, iomode: INTEGER];

}.