(FILECREATED " 3-May-86 18:55:36" {ERIS}<LISPCORE>LIBRARY>NSCHAT.;14 44643  

      changes to:  (COURIERPROGRAMS GAP)
                   (FNS NSCHAT.OPEN NSCHAT.SERVICES NSCHAT.OPEN.TTYHOST NSCHAT.OPEN.DIALOUT 
                        NSCHAT.OPEN.3270 NSCHAT.3270.HOST)
                   (VARS NSCHATCOMS)
                   (RECORDS NSCHAT.SERVICE)

      previous date: "30-Mar-86 15:50:57" {ERIS}<LISPCORE>LIBRARY>NSCHAT.;13)


(* Copyright (c) 1984, 1985, 1986 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT NSCHATCOMS)

(RPAQQ NSCHATCOMS ((COURIERPROGRAMS GAP)
                   (FNS NSCHAT.3270.HOST NSCHAT.ATTENTIONFN NSCHAT.ERRORHANDLER NSCHAT.HOST.FILTER 
                        NSCHAT.OPEN NSCHAT.OPEN.3270 NSCHAT.OPEN.DIALOUT NSCHAT.OPEN.TTYHOST 
                        NSCHAT.SERVICES SPP.INPUT.EVENT)
                   (CONSTANTS (\NS.WKS.Courier 5)
                          (GAP.RemoteSystemAdministration 1)
                          (GAP.RemoteSystemExecutive 2)
                          (GAP.InteractiveTerminalService 3))
                   (ADDVARS (CHAT.PROTOCOLTYPES (NS . NSCHAT.HOST.FILTER)))
                   (INITVARS (NSCHAT.OPTIONS.MENU))
                   (GLOBALVARS NSCHAT.OPTIONS.MENU)
                   (RECORDS NSCHAT.SERVICE)))

(COURIERPROGRAM GAP (3 3)
    TYPES
      ((WaitTime CARDINAL)
       (CharLength (ENUMERATION (five 0)
                          (six 1)
                          (seven 2)
                          (eight 3)))
       (Parity (ENUMERATION (none 0)
                      (odd 1)
                      (even 2)
                      (one 3)
                      (zero 4)))
       (StopBits (ENUMERATION (one 0)
                        (two 1)))
       (FlowControl (RECORD (type (ENUMERATION (none 0)
                                         (xOnXOff 1)))
                           (xOn UNSPECIFIED)
                           (xOff UNSPECIFIED)))
       (SessionHandle (ARRAY 2 UNSPECIFIED))
       (SessionParameterObject (CHOICE (xerox800 0 NIL)
                                      (xerox850 1 UNSPECIFIED)
                                      (xerox860 2 UNSPECIFIED)
                                      (system6 3 (RECORD (sendBlockSize CARDINAL)
                                                        (receiveBlockSize CARDINAL)))
                                      (cmcll 4 (RECORD (sendBlockSize CARDINAL)
                                                      (receiveBlockSize CARDINAL)))
                                      (ibm2770 5 (RECORD (sendBlockSize CARDINAL)
                                                        (receiveBlockSize CARDINAL)))
                                      (ibm2770Host 6 (RECORD (sendBlockSize CARDINAL)
                                                            (receiveBlockSize CARDINAL)))
                                      (ibm6670 7 (RECORD (sendBlockSize CARDINAL)
                                                        (receiveBlockSize CARDINAL)))
                                      (ibm6670Host 8 (RECORD (sendBlockSize CARDINAL)
                                                            (receiveBlockSize CARDINAL)))
                                      (ibm3270 9 NIL)
                                      (ibm3270Host 10 NIL)
                                      (OldTtyHost 11 (RECORD (charLength CharLength)
                                                            (parity Parity)
                                                            (stopBits StopBits)
                                                            (frameTimeout CARDINAL)))
                                      (OldTty 12 (RECORD (charLength CharLength)
                                                        (parity Parity)
                                                        (stopBits StopBits)
                                                        (frameTimeout CARDINAL)))
                                      (other 13 NIL)
                                      (unknown 14 NIL)
                                      (ibm2780 15 (RECORD (sendBlockSize CARDINAL)
                                                         (receiveBlockSize CARDINAL)))
                                      (ibm2780Host 16 (RECORD (sendBlockSize CARDINAL)
                                                             (receiveBlockSize CARDINAL)))
                                      (ibm3780 17 (RECORD (sendBlockSize CARDINAL)
                                                         (receiveBlockSize CARDINAL)))
                                      (ibm3780Host 18 (RECORD (sendBlockSize CARDINAL)
                                                             (receiveBlockSize CARDINAL)))
                                      (siemens9750 19 NIL)
                                      (siemens9750Host 20 NIL)
                                      (ttyHost 21 (RECORD (charLength CharLength)
                                                         (parity Parity)
                                                         (stopBits StopBits)
                                                         (frameTimeout CARDINAL)
                                                         (flowControl FlowControl)))
                                      (tty 22 (RECORD (charLength CharLength)
                                                     (parity Parity)
                                                     (stopBits StopBits)
                                                     (frameTimeout CARDINAL)
                                                     (flowControl FlowControl)))))
       (TransportObject (CHOICE (rs232c 0 (RECORD (CommParams CommParamObject)
                                                 (preemptOthers ReserveType)
                                                 (preemptMe ReserveType)
                                                 (phoneNumber STRING)
                                                 (line (CHOICE (alreadyReserved 0 (RECORD
                                                                                   (resource Resource
                                                                                          )))
                                                              (reserveNeeded 1 (RECORD (lineNumber
                                                                                        CARDINAL)))))
                                                 ))
                               (bsc 1 (RECORD (localTerminalID STRING)
                                             (localSecurityID STRING)
                                             (lineControl LineControl)
                                             (authenticateProc UNSPECIFIED)))
                               (teletype 2 NIL)
                               (polledBSCController 3 (RECORD (hostControllerName STRING)
                                                             (controllerAddress ControllerAddress)
                                                             (portsOnController CARDINAL)))
                               (sdlcController 4 (RECORD (hostControllerName STRING)
                                                        (controllerAddress ControllerAddress)
                                                        (portsOnController CARDINAL)))
                               (polledBSCTerminal 5 (RECORD (hostControllerName STRING)
                                                           (terminalAddress TerminalAddress)))
                               (sdlcTerminal 6 (RECORD (hostControllerName STRING)
                                                      (terminalAddress TerminalAddress)))
                               (service 7 (RECORD (id LONGCARDINAL)))
                               (unused 8 NIL)
                               (polledBSCPrinter 9 (RECORD (hostControllerName STRING)
                                                          (printerAddress TerminalAddress)))
                               (sdlcPrinter 10 (RECORD (hostControllerName STRING)
                                                      (printerAddress TerminalAddress)))))
       (Sequence.TransportObject (SEQUENCE TransportObject))
       (BidReply (ENUMERATION (wack 0)
                        (nack 1)
                        (default 2)))
       (ExtendedBoolean (ENUMERATION (true 0)
                               (false 1)
                               (default 2)))
       (DeviceType (ENUMERATION (undefined 0)
                          (terminal 1)
                          (printer 2)))
       (AccessDetail (CHOICE (directConn 0 (RECORD (duplex (ENUMERATION (full 0)
                                                                  (half 1)))
                                                  (lineType LineType)
                                                  (lineSpeed LineSpeed)))
                            (dialConn 1 (RECORD (duplex (ENUMERATION (full 0)
                                                               (half 1)))
                                               (lineType LineType)
                                               (lineSpeed LineSpeed)
                                               (dialMode (ENUMERATION (manual 0)
                                                                (auto 1)))
                                               (dialerNumber CARDINAL)
                                               (retryCount CARDINAL)))))
       (CommParamObject (RECORD (accessDetail AccessDetail)))
       (LineType (ENUMERATION (bitSynchronous 0)
                        (byteSynchronous 1)
                        (asynchronous 2)
                        (autoRecognition 3)))
       (LineSpeed (ENUMERATION (bps50 0)
                         (bps75 1)
                         (bps110 2)
                         (bps135p5 3)
                         (bps150 4)
                         (bps300 5)
                         (bps600 6)
                         (bps1200 7)
                         (bps2400 8)
                         (bps3600 9)
                         (bps4800 10)
                         (bps7200 11)
                         (bps9600 12)
                         (bps19200 13)
                         (bps28800 14)
                         (bps38400 15)
                         (bps48000 16)
                         (bps56000 17)
                         (bps57600 18)))
       (LineControl (ENUMERATION (primary 0)
                           (secondary 1)))
       (ControllerAddress CARDINAL)
       (TerminalAddress CARDINAL)
       (credentials (AUTHENTICATION . CREDENTIALS))
       (verifier (AUTHENTICATION . VERIFIER))
       (Duplexity (ENUMERATION (full 0)
                         (half 1)))
       (PortClientType (ENUMERATION (unassigned 0)
                              (outOfService 1)
                              (its 2)
                              (irs 3)
                              (gws 4)
                              (ibm3270Host 5)
                              (ttyEmulation 6)
                              (rbs 7)
                              (fax 8)
                              (mailGateway 9)
                              (phototypesetter 10)))
       (PortDialerType (ENUMERATION (none 0)
                              (vadic 1)
                              (hayes 2)
                              (ventel 3)
                              (rs366 4)))
       (PortEchoingLocation (ENUMERATION (application 0)
                                   (ciu 1)
                                   (terminal 2)))
       (ReserveType (ENUMERATION (preemptNever 0)
                           (preemptAlways 1)
                           (preemptInactive 2)))
       (RS232CData (RECORD (cIUPort BOOLEAN)
                          (owningClientType PortClientType)
                          (preemptionAllowed BOOLEAN)
                          (lineNumber CARDINAL)
                          (dialerNumber CARDINAL)
                          (duplexity Duplexity)
                          (dialingHardware PortDialerType)
                          (charLength CharLength)
                          (echoing PortEchoingLocation)
                          (flowControl FlowControl)
                          (lineSpeed LineSpeed)
                          (parity Parity)
                          (stopBits StopBits)
                          (portActsAsDCE BOOLEAN)
                          (accessControl NSNAME)
                          (validLineSpeeds (SEQUENCE LineSpeed))))
       (RS232CBack (RECORD (owningCIU STRING)
                          (owningECS STRING)
                          (owningClient STRING)
                          (portNumber CARDINAL)))
       (IBMDeviceType (ENUMERATION (unused 0)
                             (model1 1)
                             (model2 2)
                             (model3 3)
                             (model4 4)
                             (model5 5)
                             (printer 6)
                             (other 7)))
       (IBM3270Languages (ENUMERATION (USenglish 0)
                                (Austrian 1)
                                (AustrianAlt 2)
                                (German 3)
                                (GermanAlt 4)
                                (Belgian 5)
                                (Brazilian 6)
                                (CanadianFrench 7)
                                (Danish 8)
                                (DanishAlt 9)
                                (Norwegian 10)
                                (NorwegianAlt 11)
                                (Finnish 12)
                                (FinnishAlt 13)
                                (Swedish 14)
                                (SwedishAlt 15)
                                (French 16)
                                (International 17)
                                (Italian 18)
                                (JapaneseEnglish 19)
                                (JapaneseKana 20)
                                (Portuguese 21)
                                (Spanish 22)
                                (SpanishAlt 23)
                                (SpanishSpeaking 24)
                                (UKenglish 25)
                                (unused1 26)
                                (unused2 27)
                                (unused3 28)
                                (unused4 29)
                                (unused5 30)
                                (unused6 31)))
       (ControllerLinkType (ENUMERATION (sdlc 0)
                                  (bsc 1)))
       (IBM3270Device (RECORD (model IBMDeviceType)
                             (accessControl NSNAME)))
       (IBM3270Controller (RECORD (controllerAddress CARDINAL)
                                 (portsOnController CARDINAL)
                                 (linkType ControllerLinkType)
                                 (language IBM3270Languages)
                                 (devices (SEQUENCE IBM3270Device))))
       (IBM3270HostData (SEQUENCE IBM3270Controller))
       (IBM3270HostBack (RECORD (path NSNAME))))
    PROCEDURES
      ((Reset 0)
       (Create 2 (SessionParameterObject Sequence.TransportObject WaitTime credentials verifier)
              RETURNS
              (SessionHandle)
              REPORTS
              (badAddressFormat controllerAlreadyExists controllerDoesNotExist dialingHardwareProblem 
                     illegalTransport inconsistentParams mediumConnectFailed noCommunicationHardware 
                     noDialingHardware terminalAddressInUse terminalAddressInvalid tooManyGateStreams 
                     transmissionMediumUnavailable serviceTooBusy userNotAuthenticated 
                     userNotAuthorized serviceNotFound)
              IMPLEMENTEDBY MAKE.NS.CHAT.CONNECTION))
    ERRORS
      ((unimplemented 0)
       (noCommunicationHardware 1)
       (illegalTransport 2)
       (mediumConnectFailed 3)
       (badAddressFormat 4)
       (noDialingHardware 5)
       (dialingHardwareProblem 6)
       (transmissionMediumUnavailable 7)
       (inconsistentParams 8)
       (tooManyGateStreams 9)
       (bugInGAPCode 10)
       (gapNotExported 11)
       (gapCommunicationError 12)
       (controllerAlreadyExists 13)
       (controllerDoesNotExist 14)
       (terminalAddressInUse 15)
       (terminalAddressInvalid 16)))
(DEFINEQ

(NSCHAT.3270.HOST
  (LAMBDA (IBM.VIRTUAL.HOST)                                 (* ejs: " 3-May-86 18:24")
          
          (* * Retrieves the NSNAME of the physical host on which the virtual host lives)

    (COURIER.FETCH (GAP . IBM3270HostBack)
           path
           (CADR (CH.RETRIEVE.ITEM IBM.VIRTUAL.HOST (QUOTE IBM3270.HOST.BACK)
                        (QUOTE (GAP . IBM3270HostBack)))))))

(NSCHAT.ATTENTIONFN
  (LAMBDA (STREAM ATTNBYTE)                                  (* bvm: "11-Mar-85 13:00")
    (SELECTQ ATTNBYTE
	     (208 -1)
	     (209 (NOTIFY.EVENT (STREAMPROP STREAM (QUOTE MediumUpEvent))))
	     (COND
	       ((OR XIPTRACEFLG NSWIZARDFLG)
		 (printout PROMPTWINDOW T "Attention byte: " .I1.8 ATTNBYTE))))
    T))

(NSCHAT.ERRORHANDLER
  (LAMBDA (STREAM ERRCODE)                                   (* ejs: "18-Dec-84 20:43")
    (SELECTQ ERRCODE
	     (EOM (SPP.CLEAREOM STREAM))
	     (ATTENTION (SPP.CLEARATTENTION STREAM)
			(NSCHAT.ATTENTIONFN STREAM (BIN STREAM)))
	     (END (ADD.CHAT.MESSAGE STREAM "[Connection closed by remote host]")
		  -1)
	     (COND
	       ((SPP.OPENP STREAM)                           (* non-fatal error?)
		 (ADD.CHAT.MESSAGE STREAM (CONCAT "[SPP error " ERRCODE "]"))
		 (BIN STREAM))
	       (T (\EOF.ACTION STREAM))))))

(NSCHAT.HOST.FILTER
  (LAMBDA (NAME)                                             (* lmm "15-Jan-85 22:19")

          (* * Return NSCHAT.OPEN if NAME is an NS host with a telnet server.)


    (AND \NSFLG (STRPOS ":" NAME)
	 (SETQ NAME (CH.LOOKUP.OBJECT NAME))
	 (LIST (MKATOM NAME)
	       (FUNCTION NSCHAT.OPEN)))))

(NSCHAT.OPEN
  (LAMBDA (HOST)                                             (* ejs: " 3-May-86 18:50")
          
          (* * Return a pair of SPP streams for a chat connection, or NIL.
          Add CHAT specific operations to the STREAM via STREAMPROP.)

    (PROG ((MediumUpEvent (CREATE.EVENT))
           SERVICE.OPTIONS PORT SERVICE OUTSTREAM STREAM HANDLE FAILURE)
      LP  (SETQ SERVICE.OPTIONS (NSCHAT.SERVICES HOST SERVICE))
          (COND
             ((NOT (SETQ SERVICE (COND
                                    ((EQLENGTH SERVICE.OPTIONS 1)
                                     (printout PROMPTWINDOW T "Connecting to " (CAAR SERVICE.OPTIONS)
                                            " on " HOST T)
                                     (CADAR SERVICE.OPTIONS))
                                    (T (MENU (create MENU
                                                    ITEMS ← SERVICE.OPTIONS
                                                    TITLE ←"Specific NS Service?"))))))
              (COND
                 (STREAM (CLOSEF? STREAM)))
              (RETURN))
             ((NULL (SETQ PORT (LET ((PORT (LOOKUP.NS.SERVER (APPLY* (fetch (NSCHAT.SERVICE 
                                                                                 PhysicalHostFunction
                                                                                   ) of SERVICE)
                                                                    HOST))))
                                    (COND
                                       (PORT (replace (NSADDRESS NSSOCKET) of PORT with 
                                                                                      \NS.WKS.Courier
                                                    )
                                             PORT)))))
              (SETQ FAILURE "Name not found"))
             ((NULL (SETQ STREAM (COURIER.OPEN PORT NIL T (QUOTE NSCHAT)
                                        NIL
                                        (QUOTE (EOM.ON.FORCEOUT T ERRORHANDLER NSCHAT.ERRORHANDLER 
                                                      ATTENTIONFN NSCHAT.ATTENTIONFN)))))
                                                             (* No response)
              )
             (T (STREAMPROP STREAM (QUOTE MediumUpEvent)
                       MediumUpEvent)
                (STREAMPROP STREAM (QUOTE EOFPFN)
                       (FUNCTION NSCHAT.EOFPFN))
                (SPP.DSTYPE STREAM 192)
                (COND
                   ((NLISTP (SETQ HANDLE (APPLY* (fetch (NSCHAT.SERVICE OpenFunction) of SERVICE)
                                                STREAM HOST (fetch (NSCHAT.SERVICE ServiceID)
                                                               of SERVICE)))))
                   ((EQ (CAR HANDLE)
                        (QUOTE ERROR))
                    (SETQ FAILURE (SELECTQ (CADR HANDLE)
                                      ((REJECT 20) 
                                                             (* We ought to figure out exactly what 
                                                             error 20 is. Incomplete program 
                                                             declaration)
                                           (PRINTOUT PROMPTWINDOW T "Service not supported" T)
                                           (GO LP))
                                      (SUBSTRING (CDR HANDLE)
                                             2 -2))))
                   (T (STREAMPROP STREAM (QUOTE SETDISPLAYTYPE)
                             (FUNCTION NILL))
                      (STREAMPROP STREAM (QUOTE LOGINFO)
                             (FUNCTION NILL))
                      (STREAMPROP STREAM (QUOTE FLUSH&WAIT)
                             (FUNCTION NILL))
                      (STREAMPROP STREAM (QUOTE SENDSCREENPARAMS)
                             (FUNCTION NILL))
                      (STREAMPROP STREAM (QUOTE READPEVENT)
                             (SPP.INPUT.EVENT STREAM))
                      (SETQ OUTSTREAM (SPPOUTPUTSTREAM STREAM))
                      (AWAIT.EVENT MediumUpEvent 15000)
                      (COND
                         ((NEQ SERVICE GAP.InteractiveTerminalService)
                          (SPP.SENDATTENTION OUTSTREAM 209)))
                      (RETURN (CONS STREAM OUTSTREAM))))))
          (CLOSEF? STREAM)
          (printout PROMPTWINDOW T "Could not chat to " HOST " because: " (OR FAILURE "No Response"))
     )))

(NSCHAT.OPEN.3270
  (LAMBDA (STREAM IBM3270.VIRTUAL.HOST)                      (* ejs: " 3-May-86 18:33")
    (LET ((AUTHENTICATOR (CH.GETAUTHENTICATOR T))
          (CONTROLLER (CAR (CADR (CH.RETRIEVE.ITEM IBM3270.VIRTUAL.HOST (QUOTE IBM3270HOSTDATA)
                                        (QUOTE (GAP . IBM3270HostData)))))))
         (COND
            ((AND CONTROLLER STREAM)
             (COURIER.CALL STREAM (QUOTE GAP)
                    (QUOTE Create)
                    (BQUOTE (ibm3270Host))
                    (SELECTQ (COURIER.FETCH (GAP . IBM3270Controller)
                                    linkType CONTROLLER)
                        (sdlc (BQUOTE ((sdlcTerminal (, (RESETFORM (RADIX 8)
                                                               (CONCAT (fetch (NSNAME NSOBJECT)
                                                                          of (PARSE.NSNAME 
                                                                                 IBM3270.VIRTUAL.HOST
                                                                                    ))
                                                                      "#"
                                                                      (COURIER.FETCH (GAP . IBM3270Controller
                                                                                      )
                                                                             controllerAddress 
                                                                             CONTROLLER)
                                                                      "B"))
                                                        1)))))
                        (bsc (BQUOTE ((polledBSCTerminal (, (RESETFORM (RADIX 8)
                                                                   (CONCAT (fetch (NSNAME NSOBJECT)
                                                                              of (PARSE.NSNAME 
                                                                                 IBM3270.VIRTUAL.HOST
                                                                                        ))
                                                                          "#"
                                                                          (COURIER.FETCH (GAP . IBM3270Controller
                                                                                          )
                                                                                 controllerAddress 
                                                                                 CONTROLLER)
                                                                          "B"))
                                                            5)))))
                        (ERROR "Unknown 3270 controller link type" (COURIER.FETCH (GAP . IBM3270Controller
                                                                                   )
                                                                          linkType CONTROLLER)))
                    15000
                    (CAR AUTHENTICATOR)
                    (CADR AUTHENTICATOR)
                    (QUOTE RETURNERRORS)))))))

(NSCHAT.OPEN.DIALOUT
  (LAMBDA (STREAM HOST)                                      (* ejs: " 3-May-86 18:51")
    (DECLARE (GLOBALVARS CHAT.PHONE.NUMBERS))
    (LET ((RS232CDATA (CADR (CH.RETRIEVE.ITEM HOST (QUOTE RS232CDATA)
                                   (QUOTE (GAP . RS232CData)))))
          (AUTHENTICATOR (CH.GETAUTHENTICATOR T))
          PHONENUMBER)
         (COND
            ((NULL RS232CDATA)
             (printout PROMPTWINDOW T HOST " does not appear support dialout service" T)
             (CLOSEF STREAM)
             (ERROR!))
            (T (RESETLST (RESETSAVE NIL (LIST (FUNCTION (LAMBDA (CSTREAM)
                                                          (AND RESETSTATE (CLOSEF CSTREAM))))
                                              STREAM))
                      (OR (EQ (COURIER.FETCH (GAP . RS232CData)
                                     dialingHardware of RS232CDATA)
                              (QUOTE none))
                          (SETQ PHONENUMBER (CHAT.CHOOSE.PHONE.NUMBER)))
                      (COURIER.CALL STREAM (QUOTE GAP)
                             (QUOTE Create)
                             (BQUOTE (tty , (LIST (PROGN (COURIER.FETCH (GAP . RS232CData)
                                                                charLength of RS232CDATA)
                                                         (QUOTE seven))
                                                  (PROGN (COURIER.FETCH (GAP . RS232CData)
                                                                parity of RS232CDATA)
                                                         (QUOTE even))
                                                  (COURIER.FETCH (GAP . RS232CData)
                                                         stopBits of RS232CDATA)
                                                  100
                                                  (COURIER.FETCH (GAP . RS232CData)
                                                         flowControl of RS232CDATA))))
                             (COND
                                (PHONENUMBER (BQUOTE ((rs232c (((dialConn (full asynchronous ,
                                                                                (COURIER.FETCH
                                                                                 (GAP . RS232CData)
                                                                                 lineSpeed of 
                                                                                 RS232CDATA)
                                                                                auto ,
                                                                                (COURIER.FETCH
                                                                                 (GAP . RS232CData)
                                                                                 dialerNumber of 
                                                                                 RS232CDATA)
                                                                                1)))
                                                               preemptInactive preemptInactive , 
                                                               PHONENUMBER
                                                               (reserveNeeded
                                                                (, (COURIER.FETCH (GAP . RS232CData)
                                                                          lineNumber of RS232CDATA)))
                                                               ))
                                                      (teletype))))
                                (T (BQUOTE ((rs232c (((directConn (full asynchronous ,
                                                                        (COURIER.FETCH (GAP . RS232CData
                                                                                        )
                                                                               lineSpeed of 
                                                                               RS232CDATA))))
                                                     preemptInactive preemptInactive NIL
                                                     (reserveNeeded (, (COURIER.FETCH (GAP . RS232CData
                                                                                       )
                                                                              lineNumber of 
                                                                              RS232CDATA)))))
                                            (teletype)))))
                             15000
                             (CAR AUTHENTICATOR)
                             (CADR AUTHENTICATOR)
                             (QUOTE RETURNERRORS))))))))

(NSCHAT.OPEN.TTYHOST
  (LAMBDA (STREAM HOST SERVICE)                              (* ejs: " 3-May-86 18:51")
    (LET ((AUTHENTICATOR (CH.GETAUTHENTICATOR)))
         (COURIER.CALL STREAM (QUOTE GAP)
                (QUOTE Create)
                (QUOTE (ttyHost (seven even two 100 (none 0 0))))
                (BQUOTE ((service (, SERVICE))
                         (teletype)))
                15000
                (CAR AUTHENTICATOR)
                (CADR AUTHENTICATOR)
                (QUOTE RETURNERRORS)))))

(NSCHAT.SERVICES
  (LAMBDA (HOST ALLFLG)                                      (* ejs: " 3-May-86 18:46")
    (LET* ((PROPERTIES (CADR (CH.LIST.PROPERTIES HOST)))
           (SERVICES (AND (NOT ALLFLG)
                          (APPEND (COND
                                     ((for SERVICE in (CONSTANT (LIST (CH.PROPERTY (QUOTE 
                                                                                         FILE.SERVICE
                                                                                          ))
                                                                      (CH.PROPERTY (QUOTE 
                                                                                        PRINT.SERVICE
                                                                                          ))
                                                                      (CH.PROPERTY (QUOTE 
                                                                                CLEARINGHOUSE.SERVICE
                                                                                          ))
                                                                      (CH.PROPERTY (QUOTE 
                                                                       EXTERNAL.COMMUNICATION.SERVICE
                                                                                          ))
                                                                      (CH.PROPERTY (QUOTE 
                                                                                      GATEWAY.SERVICE
                                                                                          ))
                                                                      (CH.PROPERTY (QUOTE 
                                                                             INTERNET.ROUTING.SERVICE
                                                                                          ))
                                                                      (CH.PROPERTY (QUOTE 
                                                                                         MAIL.SERVICE
                                                                                          ))
                                                                      (CH.PROPERTY (QUOTE 
                                                                                 REMOTE.BATCH.SERVICE
                                                                                          ))
                                                                      10024))
                                         thereis (FMEMB SERVICE PROPERTIES))
                                      (CONSTANT (BQUOTE (("Remote System Administration"
                                                          ,
                                                          (create NSCHAT.SERVICE
                                                                 ServiceID ← 
                                                                 GAP.RemoteSystemAdministration
                                                                 PhysicalHostFunction ←(FUNCTION 
                                                                                        IDENTITY)
                                                                 OpenFunction ←(FUNCTION 
                                                                                NSCHAT.OPEN.TTYHOST))
                                                          "Connect to a server executive"))))))
                                 (COND
                                    ((FMEMB (CONSTANT (CH.PROPERTY (QUOTE WORKSTATION)))
                                            PROPERTIES)
                                     (CONSTANT (BQUOTE (("Remote System Executive"
                                                         ,
                                                         (create NSCHAT.SERVICE
                                                                ServiceID ← GAP.RemoteSystemExecutive
                                                                PhysicalHostFunction ←(FUNCTION 
                                                                                       IDENTITY)
                                                                OpenFunction ←(FUNCTION 
                                                                               NSCHAT.OPEN.TTYHOST))
                                                         
                                                    "Connect to a remote exec on another workstation"
                                                         ))))))
                                 (COND
                                    ((FMEMB (CONSTANT (CH.PROPERTY (QUOTE 
                                                                         INTERACTIVE.TERMINAL.SERVICE
                                                                          )))
                                            PROPERTIES)
                                     (CONSTANT (BQUOTE (("Interactive Terminal Service"
                                                         ,
                                                         (create NSCHAT.SERVICE
                                                                ServiceID ← 
                                                                GAP.InteractiveTerminalService
                                                                PhysicalHostFunction ←(FUNCTION 
                                                                                       IDENTITY)
                                                                OpenFunction ←(FUNCTION 
                                                                               NSCHAT.OPEN.TTYHOST))
                                                         "Connect to a terminal-based mail reader")))
                                            )))
                                 (COND
                                    ((FMEMB (CONSTANT (CH.PROPERTY (QUOTE RS232CDATA)))
                                            PROPERTIES)
                                     (CONSTANT (BQUOTE (("RS232 Dialout"
                                                         ,
                                                         (create NSCHAT.SERVICE
                                                                ServiceID ←(QUOTE DIALOUT)
                                                                PhysicalHostFunction ←(FUNCTION 
                                                                                       IDENTITY)
                                                                OpenFunction ←(FUNCTION 
                                                                               NSCHAT.OPEN.DIALOUT))
                                                         "Connect to a dialout facility"))))))
                                 (COND
                                    ((FMEMB (CONSTANT (CH.PROPERTY (QUOTE IBM3270.HOST)))
                                            PROPERTIES)
                                     (CONSTANT (BQUOTE (("IBM3270 Emulation Service"
                                                         ,
                                                         (create NSCHAT.SERVICE
                                                                ServiceID ←(QUOTE IBM3270)
                                                                PhysicalHostFunction ←(FUNCTION 
                                                                                     NSCHAT.3270.HOST
                                                                                       )
                                                                OpenFunction ←(FUNCTION 
                                                                               NSCHAT.OPEN.3270))
                                                         "Connect to an IBM3270 Emulator Port")))))))
                          )))
          (COND
             (SERVICES)
             (T (printout PROMPTWINDOW T HOST " does not have any registered NSCHAT services." T 
                       "Please choose a service from the menu." T)
                (CONSTANT (BQUOTE (("Remote System Administration" ,
                                          (create NSCHAT.SERVICE
                                                 ServiceID ← GAP.RemoteSystemAdministration
                                                 PhysicalHostFunction ←(FUNCTION IDENTITY)
                                                 OpenFunction ←(FUNCTION NSCHAT.OPEN.TTYHOST))
                                          "Connect to a server executive")
                                   ("Remote System Executive" , (create NSCHAT.SERVICE
                                                                       ServiceID ← 
                                                                       GAP.RemoteSystemExecutive
                                                                       PhysicalHostFunction ←(
                                                                                             FUNCTION 
                                                                                             IDENTITY
                                                                                              )
                                                                       OpenFunction ←(FUNCTION 
                                                                                  NSCHAT.OPEN.TTYHOST
                                                                                      ))
                                          "Connect to a remote exec on another workstation")
                                   ("Interactive Terminal Service" ,
                                          (create NSCHAT.SERVICE
                                                 ServiceID ← GAP.InteractiveTerminalService
                                                 PhysicalHostFunction ←(FUNCTION IDENTITY)
                                                 OpenFunction ←(FUNCTION NSCHAT.OPEN.TTYHOST))
                                          "Connect to a terminal-based mail reader")
                                   ("RS232 Dialout" , (create NSCHAT.SERVICE
                                                             ServiceID ←(QUOTE DIALOUT)
                                                             PhysicalHostFunction ←(FUNCTION IDENTITY
                                                                                    )
                                                             OpenFunction ←(FUNCTION 
                                                                            NSCHAT.OPEN.DIALOUT))
                                          "Connect to a dialout facility")
                                   ("IBM3270 Emulation Service" , (create NSCHAT.SERVICE
                                                                         ServiceID ←(QUOTE IBM3270)
                                                                         PhysicalHostFunction ←(
                                                                                             FUNCTION 
                                                                                     NSCHAT.3270.HOST
                                                                                                )
                                                                         OpenFunction ←(FUNCTION 
                                                                                     NSCHAT.OPEN.3270
                                                                                        ))
                                          "Connect to an IBM3270 Emulator Port")))))))))

(SPP.INPUT.EVENT
  (LAMBDA (STREAM)                                           (* ejs: " 2-Jul-85 13:38")

          (* * Returns the SPPINPUTEVENT of the associated connection for STREAM, if STREAM is open for INPUT)


    (COND
      ((EQ (fetch (STREAM ACCESS) of STREAM)
	   (QUOTE INPUT))
	(fetch (SPPCON SPPINPUTEVENT) of (fetch (SPPSTREAM SPP.CONNECTION) of STREAM)))
      (T (ERROR "FILE NOT OPEN" STREAM)))))
)
(DECLARE: EVAL@COMPILE 

(RPAQQ \NS.WKS.Courier 5)

(RPAQQ GAP.RemoteSystemAdministration 1)

(RPAQQ GAP.RemoteSystemExecutive 2)

(RPAQQ GAP.InteractiveTerminalService 3)

(CONSTANTS (\NS.WKS.Courier 5)
       (GAP.RemoteSystemAdministration 1)
       (GAP.RemoteSystemExecutive 2)
       (GAP.InteractiveTerminalService 3))
)

(ADDTOVAR CHAT.PROTOCOLTYPES (NS . NSCHAT.HOST.FILTER))

(RPAQ? NSCHAT.OPTIONS.MENU )
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS NSCHAT.OPTIONS.MENU)
)
[DECLARE: EVAL@COMPILE 

(RECORD NSCHAT.SERVICE (ServiceID PhysicalHostFunction OpenFunction))
]
(PUTPROPS NSCHAT COPYRIGHT ("Xerox Corporation" 1984 1985 1986))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (16531 43946 (NSCHAT.3270.HOST 16541 . 16962) (NSCHAT.ATTENTIONFN 16964 . 17333) (
NSCHAT.ERRORHANDLER 17335 . 17935) (NSCHAT.HOST.FILTER 17937 . 18294) (NSCHAT.OPEN 18296 . 22896) (
NSCHAT.OPEN.3270 22898 . 26144) (NSCHAT.OPEN.DIALOUT 26146 . 31020) (NSCHAT.OPEN.TTYHOST 31022 . 31551
) (NSCHAT.SERVICES 31553 . 43473) (SPP.INPUT.EVENT 43475 . 43944)))))
STOP