-- FTPAccessories.mesa,  Edit: HGM December 15, 1980  11:03 PM  

-- Copyright  Xerox Corporation 1979, 1980

DIRECTORY
  FTPDefs,
  FTPPrivateDefs,
  String USING [AppendString];

FTPAccessories: PROGRAM
  -- import list

  IMPORTS String, FTPPrivateDefs
  -- export list

  EXPORTS FTPPrivateDefs
  -- share list

  SHARES FTPPrivateDefs =
  BEGIN OPEN FTPDefs, FTPPrivateDefs;

  -- **********************!  Constants  !***********************

  ftpsystem: POINTER TO FTPSystem = LocateFtpSystemObject[];

  -- **********************!  Module Presence Test Procedure  !***********************

  AccessoriesLoaded: PUBLIC PROCEDURE =
    BEGIN
    -- report in
    ftpsystem.accessoriesLoaded ← TRUE;
    END;

  -- **********************!  Verbalization Primitives  !***********************

  VerbalizeFtpError: PUBLIC PROCEDURE [ftpError: FtpError, message: STRING] =
    BEGIN
    -- Note:  Appends message to string.
    -- append message to string
    SELECT ftpError FROM
      IN CommunicationError => VerbalizeCommunicationError[ftpError, message];
      IN CredentialError => VerbalizeCredentialError[ftpError, message];
      IN FileError => VerbalizeFileError[ftpError, message];
      IN DumpError => VerbalizeDumpError[ftpError, message];
      IN MailError => VerbalizeMailError[ftpError, message];
      IN ClientError => VerbalizeClientError[ftpError, message];
      IN ProtocolError => VerbalizeProtocolError[ftpError, message];
      IN InternalError => VerbalizeInternalError[ftpError, message];
      ENDCASE => VerbalizeUnidentifiedError[ftpError, message];
    -- IN UnidentifiedError

    END;

  VerbalizeCommunicationError: PROCEDURE [ftpError: FtpError, message: STRING] =
    BEGIN
    -- Note:  Appends message to string.
    -- local constants
    srcMessage: STRING =
      SELECT ftpError FROM
        noSuchHost => "No such host"L,
        connectionTimedOut => "Connection timed out"L,
        connectionRejected => "Connection rejected"L,
        connectionClosed => "Connection closed"L,
        noRouteToNetwork => "No route to network"L,
        connectionAbortedLocally => "Connection aborted locally"L,
        noNameLookupResponse => "No name lookup response"L,
        ENDCASE => "Unidentified error"L;
    -- append message to string
    String.AppendString[message, srcMessage];
    END;

  VerbalizeCredentialError: PROCEDURE [ftpError: FtpError, message: STRING] =
    BEGIN
    -- Note:  Appends message to string.
    -- local constants
    srcMessage: STRING =
      SELECT ftpError FROM
        credentialsMissing => "Credentials missing"L,
        noSuchPrimaryUser => "No such primary user"L,
        noSuchSecondaryUser => "No such secondary user"L,
        incorrectPrimaryPassword => "Incorrect primary password"L,
        incorrectSecondaryPassword => "Incorrect secondary password"L,
        requestedAccessDenied => "Requested access denied"L,
        ENDCASE => "Unidentified error"L;
    -- append message to string
    String.AppendString[message, srcMessage];
    END;

  VerbalizeFileError: PROCEDURE [ftpError: FtpError, message: STRING] =
    BEGIN
    -- Note:  Appends message to string.
    -- local constants
    srcMessage: STRING =
      SELECT ftpError FROM
        illegalFilename => "Illegal filename"L,
        noSuchFile => "No such file"L,
        fileAlreadyExists => "File already exists"L,
        fileBusy => "File busy"L,
        noRoomForFile => "No room for file"L,
        fileDataError => "File data error"L,
        ENDCASE => "Unidentified error"L;
    -- append message to string
    String.AppendString[message, srcMessage];
    END;

  VerbalizeDumpError: PROCEDURE [ftpError: FtpError, message: STRING] =
    BEGIN
    -- Note:  Appends message to string.
    -- local constants
    srcMessage: STRING =
      SELECT ftpError FROM
        errorBlockInDumpFile => "Error block in dump file"L,
        unrecognizedDumpFileBlock => "Unrecognized dump file block"L,
        dumpFileBlockTooLong => "Dump file block too long"L,
        dumpFileCheckSumInError => "Dump file checksum in error"L,
        ENDCASE => "Unidentified error"L;
    -- append message to string
    String.AppendString[message, srcMessage];
    END;

  VerbalizeMailError: PROCEDURE [ftpError: FtpError, message: STRING] =
    BEGIN
    -- Note:  Appends message to string.
    -- local constants
    srcMessage: STRING =
      SELECT ftpError FROM
        noValidRecipients => "No valid recipients"L,
        noSuchMailbox => "No such mailbox"L,
        ENDCASE => "Unidentified error"L;
    -- append message to string
    String.AppendString[message, srcMessage];
    END;

  VerbalizeClientError: PROCEDURE [ftpError: FtpError, message: STRING] =
    BEGIN
    -- Note:  Appends message to string.
    -- local constants
    srcMessage: STRING =
      SELECT ftpError FROM
        filePrimitivesNotSpecified => "File primitives not specified"L,
        mailPrimitivesNotSpecified => "Mail primitives not specified"L,
        communicationPrimitivesNotSpecified =>
          "Communication primitives not specified"L,
        filesModuleNotLoaded => "Files module not loaded"L,
        mailModuleNotLoaded => "Mail module not loaded"L,
        noConnectionEstablished => "No connection established"L,
        connectionAlreadyEstablished => "Connection already established"L,
        connectionNotOpenedForFiles => "Connection not opened for files"L,
        connectionNotOpenedForMail => "Connection not opened for mail"L,
        illegalProcedureCallSequence => "Illegal procedure call sequence"L,
        fileGroupDesignatorUnexpected => "File group designator unexpected"L,
        filenameUnexpected => "Filename unexpected"L,
        ENDCASE => "Unidentified error"L;
    -- append message to string
    String.AppendString[message, srcMessage];
    END;

  VerbalizeProtocolError: PROCEDURE [ftpError: FtpError, message: STRING] =
    BEGIN
    -- Note:  Appends message to string.
    -- local constants
    srcMessage: STRING =
      SELECT ftpError FROM
        protocolVersionMismatch => "Protocol version mismatch"L,
        functionNotImplemented => "Function not implemented"L,
        inputDiscontinuityUnexpected => "Input discontinuity unexpected"L,
        outputDiscontinuityUnexpected => "Output discontinuity unexpected"L,
        illegalProtocolSequence => "Illegal protocol sequence"L,
        protocolParameterListMissing => "Protocol parameter list missing"L,
        illegalProtocolParameterList => "Illegal protocol parameter list"L,
        unrecognizedProtocolParameter => "Unrecognized protocol parameter"L,
        missingProtocolParameter => "Missing protocol parameter"L,
        duplicateProtocolParameter => "Duplicate protocol parameter"L,
        illegalBooleanParameter => "Illegal boolean parameter"L,
        illegalFileAttribute => "Illegal file attribute"L,
        illegalFileType => "Illegal file type"L,
        unrecognizedProtocolErrorCode => "Unrecognized protocol error code"L,
        noSuchRecipientNumber => "No such recipient number"L,
        duplicateMailboxException => "Duplicate mailbox exception"L,
        unrecognizedMailboxExceptionErrorCode =>
          "Unrecognized mailbox exception error code"L,
        missingMessageLength => "Missing message length"L,
        messageLongerThanAdvertised => "Message longer than advertised"L,
        messageShorterThanAdvertised => "Message shorter than advertised"L,
        ENDCASE => "Unidentified error"L;
    -- append message to string
    String.AppendString[message, srcMessage];
    END;

  VerbalizeInternalError: PROCEDURE [ftpError: FtpError, message: STRING] =
    BEGIN
    -- Note:  Appends message to string.
    -- local constants
    srcMessage: STRING =
      SELECT ftpError FROM
        stringTooLong => "String too long"L,
        queueInconsistent => "Queue inconsistent"L,
        unexpectedEndOfFile => "Unexpected end of file"L,
        ENDCASE => "Unidentified error"L;
    -- append message to string
    String.AppendString[message, srcMessage];
    END;

  VerbalizeUnidentifiedError: PROCEDURE [ftpError: FtpError, message: STRING] =
    BEGIN
    -- Note:  Appends message to string.
    -- local constants
    srcMessage: STRING =
      SELECT ftpError FROM
        unidentifiedTransientError => "Unidentified transient error"L,
        unidentifiedPermanentError => "Unidentified permanent error"L,
        ENDCASE => "Unidentified error"L;
    -- append message to string
    String.AppendString[message, srcMessage];
    END;

  VerbalizeRecipientError: PUBLIC PROCEDURE [
    recipientError: RecipientError, message: STRING] =
    BEGIN
    -- Note:  Appends message to string.
    -- local constants
    srcMessage: STRING =
      SELECT recipientError FROM
        noSuchMailbox => "No such mailbox"L,
        noForwardingProvided => "No forwarding provided"L,
        unspecifiedTransientError => "Unspecified transient error"L,
        unspecifiedPermanentError => "Unspecified permanent error"L,
        ENDCASE => "Unidentified error"L;
    -- append message to string
    String.AppendString[message, srcMessage];
    END;

  -- **********************!  Main Program  !***********************

  -- no operation

  END. -- of FTPAccessories