-- File: PupBooterSlow.mesa,  Last Edit: HGM  October 7, 1980  12:44 AM

DIRECTORY
  String USING [AppendChar, AppendString],
  Time USING [AppendCurrent],
  Put USING [Line],
  Runtime USING [IsBound],
  Window USING [Handle],
  Slosh USING [SendFile],
  BootServerDefs USING [BootFile, WhatHappened, msg, UpdatePicture],
  PupDefs USING [AppendHostName],
  PupTypes USING [PupAddress];

PupBooterSlow: PROGRAM
  IMPORTS String, Time, Put, Runtime, Slosh, BootServerDefs, PupDefs
  EXPORTS BootServerDefs =
  BEGIN OPEN BootServerDefs;

  verbose: BOOLEAN = TRUE;
  slowBooteeHost: PUBLIC STRING ← [30];
  slowBootFileName: PUBLIC STRING ← NIL;

  SlowBooter: PUBLIC PROCEDURE [
    bf: BootServerDefs.BootFile, him: PupTypes.PupAddress]
    RETURNS [what: WhatHappened] =
    BEGIN
    slowBooteeHost.length ← 0;
    PupDefs.AppendHostName[slowBooteeHost, him];
    slowBootFileName ← bf.fileName;
    FixupPicture[];
    IF verbose THEN
      BEGIN
      text: STRING = [100];
      Time.AppendCurrent[text];
      String.AppendString[text, "  Booting "L];
      String.AppendString[text, bf.fileName];
      String.AppendString[text, " to "L];
      PupDefs.AppendHostName[text, him];
      String.AppendChar[text, '.];
      LogString[msg, text];
      END;
    what ←
      SELECT Slosh.SendFile[msg, bf.fileName, bf.file, him] FROM
	ok => slow,
	neverStarted => neverStarted,
	troubles => troubles,
	ENDCASE => troubles;
    slowBooteeHost.length ← 0;
    slowBootFileName ← NIL;
    FixupPicture[];
    END;

  FixupPicture: PROCEDURE =
    BEGIN
    IF msg # NIL AND Runtime.IsBound[UpdatePicture] THEN UpdatePicture[];
    END;

  LogString: PROCEDURE [msg: Window.Handle, text: STRING] =
    BEGIN IF msg # NIL THEN Put.Line[msg, text]; Put.Line[NIL, text]; END;

  END.