-- Copyright (C) 1980, 1984, 1985  by Xerox Corporation. All rights reserved. 
-- ServerDefs.mesa, public DEFS for info about other servers --

-- HGM, 18-Sep-85  6:30:45
-- Andrew Birrell   4-Aug-80 18:02:03 --

DIRECTORY
  BodyDefs USING [RName],
  HeapDefs USING [WriterHandle],
  PupTypes USING [PupAddress];


ServerDefs: DEFINITIONS =
  BEGIN

  ServerName: TYPE = RECORD [
    SELECT type: * FROM
    rName => [value: BodyDefs.RName],
    connect => [value: LONG STRING],
    netAddr => [value: PupTypes.PupAddress],
    ENDCASE];

  ServerHandle: TYPE = POINTER TO ServerData;  -- Beware: Lives on disk in SLQueues

  ServerData: TYPE = MONITORED RECORD [
    next: PRIVATE ServerHandle,
    name: ServerName,
    leaf: BOOLEAN,
    up: PRIVATE BOOLEAN,
    inUse: PRIVATE BOOLEAN,
    addrKnown: PRIVATE BOOLEAN,
    addr: PRIVATE PupTypes.PupAddress,
    SL: HeapDefs.WriterHandle];
  -- The "SL" field is initialised to NIL by the
  -- "ServerAlloc" module, and is accessed and altered
  -- only by the "ReadInput" module.  All other fields are
  -- initialised, accessed and altered only by the
  -- "ServerInfo" and "ServerAlloc" modules.

  GetServer: PROCEDURE [name: ServerName] RETURNS [ServerHandle];
  GetLeafServer: PROCEDURE [name: ServerName] RETURNS [ServerHandle];
  -- creates ServerData if necessary.  The name may
  -- define the server by R-Name, by connect site,
  -- or by net address (including socket).  Several
  -- ServerHandle's, defined by different names, may map
  -- to the same net address. --

  EnumerateAll: PROCEDURE [work: PROCEDURE [ServerHandle]];
  -- enumerates all servers --

  ServerUp: PROCEDURE [handle: ServerHandle] RETURNS [BOOLEAN];
  -- known state of the server --

  UpServer: PROCEDURE [handle: ServerHandle];
  -- notification that server is believed to be up. --

  DownServer: PROCEDURE [handle: ServerHandle];
  -- notification that server is believed to be down.
  -- Also ceases to cache the server's net address. --

  ServerAddr: PROCEDURE [handle: ServerHandle] RETURNS [PupTypes.PupAddress];
  -- the probable address of the server. May signal
  -- NoSuchServer or ServerNotUp  --

  ServerIsLocal: PROCEDURE [handle: ServerHandle] RETURNS [BOOLEAN];
  -- Returns whether the present address of the server
  -- is the local host --

  NoSuchServer: ERROR;
  -- Raised by ServerAddr if the server cannot be located.
  -- The server is now believed to be down. --

  ServerNotUp: ERROR;
  -- Raised by ServerAddr if no route exists to the
  -- server.  The server is now believed to be down. --

  END.