-- File: ArpaTelnetConstantsImpl.mesa - last edit:
-- JAV                  3-Sep-87 16:19:19

-- Copyright (C) 1987 by Xerox Corporation. All rights reserved.

DIRECTORY
  ArpaTelnetConstants,
  ArpaTerminalTable,
  Runtime,
  String;

ArpaTelnetConstantsImpl: PROGRAM
  IMPORTS ArpaTerminalTable, Runtime, String
  EXPORTS ArpaTelnetConstants =
  BEGIN
  
  CSRptr: TYPE = LONG BASE POINTER TO CompStrRecord;
  CompStrDesc: TYPE = RECORD [offset, length: CARDINAL];
  
  CompStrRecord: TYPE = RECORD [
    stringOffset: CSRptr RELATIVE POINTER TO StringBody,
    Terminals: PUBLIC ARRAY ArpaTelnetConstants.TerminalTypes OF CompStrDesc];
  
  termTable: CSRptr ← NIL;

  GetTerminalString: PUBLIC PROCEDURE [terminalType: ArpaTelnetConstants.TerminalTypes, zone: UNCOUNTED ZONE] RETURNS [terminal: LONG STRING] =
  BEGIN
    subString: String.SubStringDescriptor ← [
      base: @termTable[termTable.stringOffset],
      offset: termTable.Terminals[terminalType].offset,
      length: termTable.Terminals[terminalType].length];
    
    terminal ← String.MakeString[zone, termTable.Terminals[terminalType].length];
    String.AppendSubString[terminal, @subString];
  END;
  
  termTable ← Runtime.GetTableBase[ArpaTerminalTable.ArpaTelnetTerminalTable];
  
END..