-- Copyright (C) 1981, 1984, 1985  by Xerox Corporation. All rights reserved. 
-- FileDefs.mesa

-- HGM: 16-Sep-85 21:58:57
-- Levin: 27-Feb-81 11:35:30


DIRECTORY
  VMDefs USING [
    defaultTime, FileTime, OpenOptions, PageNumber, Position, Problem];

FileDefs: DEFINITIONS =

  BEGIN

  -- This interface defines the common properties for file systems used at
  -- the VM level.


  -- Types --

  Operations: TYPE = LONG POINTER TO OperationsRecord;

  OperationsRecord: TYPE = RECORD [
    login: PROC [
      server, userName, password, secondaryName, secondaryPassword: LONG STRING ← NIL]
      RETURNS [FSInstance],
    logout: PROC [FSInstance],
    checkpoint: PROC [FSInstance],
    abort: PROC [FSInstance],
    open: PROC [
      instance: FSInstance, name: LONG STRING, options: OpenOptions ← oldReadOnly]
      RETURNS [FileHandle],
    close: PROC [FileHandle],
    abandon: PROC [FileHandle],
    destroy: PROC [FileHandle],
    getLength: PROC [FileHandle] RETURNS [Position],
    setLength: PROC [FileHandle, Position],
    extend: PROC [FileHandle, Position, Buffer],
    truncate: PROC [FileHandle, Position],
    startRead: PROC [FileHandle, PageNumber, Buffer, Completer, CompleterArg],
    startWrite: PROC [FileHandle, PageNumber, Buffer, Completer, CompleterArg],
    getTimes: PROC [FileHandle] RETURNS [read, write, create: FileTime],
    setCreation: PROC [FileHandle, FileTime]];

  FSInstance: TYPE = LONG POINTER TO FSObject;
  FSObject: TYPE;

  FileHandle: TYPE = LONG POINTER TO FileObject;
  FileObject: TYPE;

  OpenOptions: TYPE = VMDefs.OpenOptions;

  Buffer: TYPE = LONG POINTER;
  Position: TYPE = VMDefs.Position;
  PageNumber: TYPE = VMDefs.PageNumber;

  Completer: TYPE = PROCEDURE [arg: CompleterArg, outcome: Problem];
  CompleterArg: TYPE = LONG POINTER;
  Problem: TYPE = VMDefs.Problem;

  Comparison: TYPE = MACHINE DEPENDENT{less, equal, greater};

  FileTime: TYPE = VMDefs.FileTime;

  defaultTime: FileTime = VMDefs.defaultTime;


  -- Miscellaneous --

  bytesPerPage: CARDINAL = 512;


  -- Procedures and Signals --

  ComparePositions: PROCEDURE [pos1, pos2: Position] RETURNS [Comparison];

  IncrementPosition: PROCEDURE [pos: Position, bytes: CARDINAL]
    RETURNS [Position];

  -- ALocalto File System --

  InitializeLocal: PROCEDURE RETURNS [Operations];
  -- called from VM initialization to perform once-only initialization of the
  -- local file system.

  FinalizeLocal: PROCEDURE;
  -- called from VM finalization to shut down the local file system.

  -- IFS File System --

  InitializeIFS: PROCEDURE RETURNS [Operations];
  -- called from VM initialization to perform once-only initialization of the
  -- IFS file system.

  FinalizeIFS: PROCEDURE;
  -- called from VM finalization to shut down the IFS file system.


  END.