-- File:  Answer.Mesa  - edited by
-- Karlton, December 2, 1980  1:28 PM


Answer: DEFINITIONS =
  BEGIN
  
  Block: TYPE = RECORD [
    buffer: LONG POINTER TO PACKED ARRAY [0..0) OF CHARACTER,
    length: CARDINAL];
  -- This is used exclusively with the putBlock procedure passed to the MakeHeader
  -- procedure described below.  The client is expected to make up the header
  -- of the new message from the Blocks given back to the client by successive
  -- calls on the putBlock procedure.  There will only be a single CR terminating
  -- the last Buffer.  If the client wishes to add more lines to the constructed
  -- header, this may be done.
  
  MakeHeader: PROCEDURE [
    getChar: PROCEDURE [CARDINAL] RETURNS [CHARACTER], getLength: CARDINAL,
    putBlock: PROCEDURE [Block],
    getPages: PROCEDURE [CARDINAL] RETURNS [LONG POINTER],
    freePages: PROCEDURE [LONG POINTER],
    userName, userRegistry: STRING,
    arpaGatewayHostNames: DESCRIPTOR FOR ARRAY OF STRING,
    cForCopies: BOOLEAN ← FALSE]
    RETURNS [answerError: BOOLEAN];
  -- Causes an answering header for a message that the client currently has.
  -- 'getChar' procedure is used to get characters from the old message header.
  -- The argument to 'getChar' is which character from the old header is needed.
  -- The same character may be asked for more than once.  'getLength' is the length
  -- of the old message being parsed; 'getChar' will always be called with the
  -- argument in the range [0..getLength).  'putBlock' is called by MakeHeader
  -- successively with pieces of the new header under construction.  'getPages'
  -- and 'freePages' are called by MakeHeader as it needs temporary storage while
  -- constructing the new header.  If MakeHeader is not unwound, all storage will
  -- be released before it returns.  If being used in the Alto/Mesa world, the high
  -- order word of the pointers must be zero.  'userName' and 'userRegistry' may not
  -- be NIL, and are used to eliminate some "redundant" information from the constructed
  -- header.  'arpaGatewayHostNames' should be an array of strings representing the
  -- local host, e.g. ["PARC-MAXC"L, "PARC"L, "MAXC"L].  'cForCopies causes the
  -- constructed header to have "c:  <recipient list>" instead of "cc: <recipient list>".
  -- If the parse of the old message failed, then MakeHeader returns TRUE.
    
  END.  -- Answer --