-- File: NetDirDefs.Mesa,  Last Edit: HGM  March 12, 1981  3:31 PM

DIRECTORY
  StringDefs USING [BcplSTRING],
  PupTypes USING [PupAddress];

NetDirDefs: DEFINITIONS SHARES StringDefs =
  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;

  maxAddrsInFile: CARDINAL = 5000;
  maxEntrysInFile: CARDINAL = 5000;
  maxNamesInFile: CARDINAL = 5000;
  maxStringsInFile: CARDINAL = 5000;

  maxAddrBufferLength: CARDINAL = 15000;
  maxEntryBufferLength: CARDINAL = 15000;
  maxNameBufferLength: CARDINAL = 15000;
  maxStringBufferLength: CARDINAL = 10000;

  NameTableBase: TYPE = BASE POINTER TO RECORD [WORD];
  NameBase: TYPE = BASE POINTER TO RECORD [WORD];
  AddrTableBase: TYPE = BASE POINTER TO RECORD [WORD];
  AddrBase: TYPE = BASE POINTER TO RECORD [WORD];
  EntryBase: TYPE = BASE POINTER TO RECORD [WORD];
  StringBase: TYPE = 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 StringDefs.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: StringDefs.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.