-- Copyright (C) 1984  by Xerox Corporation. All rights reserved. 
-- NetDirDefs.Mesa, HGM, 30-Jun-84 18:30:23

DIRECTORY
  System USING [GreenwichMeanTime],
  
  PupWireFormat USING [BcplSTRING],
  PupTypes USING [PupAddress];

NetDirDefs: DEFINITIONS =
  BEGIN

  maxAddrsPerEntry: CARDINAL = 20;  -- 21 would fit in a 64 word pup
  maxAttributesPerEntry: CARDINAL = 10;
  maxNamesPerEntry: CARDINAL = 10;

  maxCharsPerName: CARDINAL = 39;  -- Host name or Attribute name
  maxCharsPerAttribute: CARDINAL = 255;

  NewHeader: TYPE = RECORD [
    version: CARDINAL,
    createDate: System.GreenwichMeanTime,
    sourceDate: System.GreenwichMeanTime,
    numberOfEntries: CARDINAL,
    spare: ARRAY [6..20) OF WORD];
  
  NewEntry: TYPE = RECORD [
    words: CARDINAL,
    numberOfNames: CARDINAL,
    numberOfAddresses: CARDINAL,
    numberOfAttributes: CARDINAL];
    -- Followed by names as Mesa STRING bodys, Addresses, and (someday Attributes)

  maxAddrsInFile: CARDINAL = LAST[CARDINAL]/SIZE[Addr];
  oldMaxAddrsInFile: CARDINAL = 5000; -- Beware: Checked in AltoGateway
  maxEntrysInFile: CARDINAL = LAST[CARDINAL]/SIZE[Entry];
  maxNamesInFile: CARDINAL = LAST[CARDINAL]/sizeOfBasicName;
  oldMaxNamesInFile: CARDINAL = 5000; -- Beware: Checked in AltoGateway
  maxStringsInFile: CARDINAL = 20000;

  oldMaxEntryBufferLength: CARDINAL = 15000; -- Beware: Checked in AltoGateway

  NameTableBase: TYPE = LONG BASE POINTER TO RECORD [WORD];
  NameBase: TYPE = LONG BASE POINTER TO RECORD [WORD];
  AddrTableBase: TYPE = LONG BASE POINTER TO RECORD [WORD];
  AddrBase: TYPE = LONG BASE POINTER TO RECORD [WORD];
  EntryBase: TYPE = LONG BASE POINTER TO RECORD [WORD];
  StringBase: TYPE = LONG BASE POINTER TO RECORD [WORD];

  last: Offset = 0;

  -- Offset: TYPE = * RELATIVE POINTER;
  Offset: TYPE = UNSPECIFIED;
  NameOffset: TYPE = NameBase RELATIVE POINTER TO Name;
  AddrOffset: TYPE = AddrBase RELATIVE POINTER TO Addr;
  EntryOffset: TYPE = EntryBase RELATIVE POINTER TO Entry;
  StringOffset: TYPE = StringBase RELATIVE POINTER TO PupWireFormat.BcplSTRING;

  Header: TYPE = RECORD [
    numberOfNames: CARDINAL,
    nameLookupTable: NameTableBase RELATIVE POINTER TO ARRAY [0..0) OF NameOffset,
    numberOfAddrs: CARDINAL,
    addrLookupTable: AddrTableBase RELATIVE POINTER TO ARRAY [0..0) OF AddrOffset,
    lengthOfEntries: CARDINAL,
    firstEntry: EntryOffset,
    version: CARDINAL];

  Attribute: TYPE = RECORD [name: StringOffset, value: StringOffset];

  Entry: TYPE = RECORD [
    name: NameOffset,
    addr: AddrOffset,
    numberOfAttributes: CARDINAL,
    attributes: ARRAY [0..0) OF Attribute];

  Name: TYPE = RECORD [
    next: NameOffset, entry: EntryOffset, string: PupWireFormat.BcplSTRING];
  -- BEWARE of SIZE
  sizeOfBasicName: CARDINAL = 2;

  Addr: TYPE = RECORD [
    next: AddrOffset,
    entry: EntryOffset,
    port: PupTypes.PupAddress,
    numberOfAttributes: CARDINAL,  -- currently not used
    attributes: ARRAY [0..0) OF Attribute];

  END.