(FILECREATED " 9-Mar-85 16:57:52" {SAFE}</C/SCHOEN/TCP>TCPCHAT.;3 4529   

      changes to:  (FNS TCPCHAT.OPEN)

      previous date: " 9-Mar-85 16:56:32" {SAFE}</C/SCHOEN/TCP>TCPCHAT.;2)


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

(PRETTYCOMPRINT TCPCHATCOMS)

(RPAQQ TCPCHATCOMS ((FNS TCPCHAT.BIN TCPCHAT.HOST.FILTER TCPCHAT.NEGOTIATE TCPCHAT.NEGOTIATE.DO 
			 TCPCHAT.NEGOTIATE.DONT TCPCHAT.NEGOTIATE.WILL TCPCHAT.NEGOTIATE.WONT 
			 TCPCHAT.OPEN)
		    (FILES (SYSLOAD FROM VALUEOF LISPUSERSDIRECTORIES)
			   TCP)
		    (ADDVARS (CHAT.PROTOCOLTYPES (TCP . TCPCHAT.HOST.FILTER)))
		    (DECLARE: DONTCOPY (EXPORT (CONSTANTS (TELNET.IAC 255)
							  (TELNET.DONT 254)
							  (TELNET.DO 253)
							  (TELNET.WONT 252)
							  (TELNET.WILL 251)
							  (TELNET.TIMING.MARK 6))))
		    (P (COND ((BOUNDP (QUOTE CHAT.PROTCOLS))
			      (ADDTOVAR CHAT.PROTOCOLS TCPCHAT.HOST.FILTER))))))
(DEFINEQ

(TCPCHAT.BIN
  (LAMBDA (STREAM)                                           (* ejs: " 9-Mar-85 16:45")
    (LET ((CHAR (\BUFFERED.BIN STREAM)))
	 (COND
	   ((NEQ CHAR TELNET.IAC)
	     CHAR)
	   (T (TCPCHAT.NEGOTIATE STREAM))))))

(TCPCHAT.HOST.FILTER
  (LAMBDA (HOST)                                             (* ejs: "12-Jan-85 18:28")
    (COND
      ((SETQ HOST (DODIP.HOSTP HOST))
	(LIST HOST (FUNCTION TCPCHAT.OPEN))))))

(TCPCHAT.NEGOTIATE
  (LAMBDA (STREAM)                                           (* ejs: " 9-Mar-85 16:48")
    (LET ((CHAR (\BUFFERED.BIN STREAM)))
	 (SELECTC CHAR
		  (TELNET.DO (TCPCHAT.NEGOTIATE.DO STREAM))
		  (TELNET.DONT (TCPCHAT.NEGOTIATE.DONT STREAM))
		  (TELNET.WILL (TCPCHAT.NEGOTIATE.WILL STREAM))
		  (TELNET.WONT (TCPCHAT.NEGOTIATE.WONT STREAM))
		  CHAR))))

(TCPCHAT.NEGOTIATE.DO
  (LAMBDA (STREAM)                                           (* ejs: " 9-Mar-85 16:51")
    (LET ((MARK (\BUFFERED.BIN STREAM))
	  (OUTSTREAM (TCP.OTHER.STREAM STREAM)))
	 (SELECTC MARK
		  (TELNET.TIMING.MARK (BOUT OUTSTREAM TELNET.IAC)
				      (BOUT OUTSTREAM TELNET.WILL)
				      (BOUT OUTSTREAM TELNET.TIMING.MARK)
				      (FORCEOUTPUT OUTSTREAM)
				      (\BUFFERED.BIN STREAM))
		  (\BUFFERED.BIN STREAM)))))

(TCPCHAT.NEGOTIATE.DONT
  (LAMBDA (STREAM)                                           (* ejs: " 9-Mar-85 16:53")
    (\BUFFERED.BIN STREAM)))

(TCPCHAT.NEGOTIATE.WILL
  (LAMBDA (STREAM)                                           (* ejs: " 9-Mar-85 16:53")
    (\BUFFERED.BIN STREAM)))

(TCPCHAT.NEGOTIATE.WONT
  (LAMBDA (STREAM)                                           (* ejs: " 9-Mar-85 16:53")
    (\BUFFERED.BIN STREAM)))

(TCPCHAT.OPEN
  (LAMBDA (HOST)                                             (* ejs: " 9-Mar-85 16:57")
    (PROG ((STREAM (TCP.OPEN HOST \TCP.TELNET.PORT NIL (QUOTE ACTIVE)
			     (QUOTE INPUT)))
	   OUTPUTSTREAM)
          (COND
	    (STREAM (replace (STREAM BINABLE) of STREAM with NIL)
                                                             (* Can't run microcoded)
		    (replace (STREAM STRMBINFN) of STREAM with (FUNCTION TCPCHAT.BIN))
		    (SETQ OUTPUTSTREAM (TCP.OTHER.STREAM STREAM))
		    (BOUT OUTPUTSTREAM TELNET.IAC)
		    (BOUT OUTPUTSTREAM TELNET.DO)
		    (BOUT OUTPUTSTREAM 1)
		    (BOUT OUTPUTSTREAM TELNET.IAC)
		    (BOUT OUTPUTSTREAM TELNET.DO)
		    (BOUT OUTPUTSTREAM 3)
		    (BOUT OUTPUTSTREAM TELNET.IAC)
		    (BOUT OUTPUTSTREAM TELNET.WILL)
		    (BOUT OUTPUTSTREAM 3)
		    (\TCP.FORCEOUTPUT OUTPUTSTREAM)
		    (RETURN (CONS STREAM OUTPUTSTREAM)))))))
)
(FILESLOAD (SYSLOAD FROM VALUEOF LISPUSERSDIRECTORIES)
	   TCP)

(ADDTOVAR CHAT.PROTOCOLTYPES (TCP . TCPCHAT.HOST.FILTER))
(DECLARE: DONTCOPY 
(* FOLLOWING DEFINITIONS EXPORTED)


(DECLARE: EVAL@COMPILE 

(RPAQQ TELNET.IAC 255)

(RPAQQ TELNET.DONT 254)

(RPAQQ TELNET.DO 253)

(RPAQQ TELNET.WONT 252)

(RPAQQ TELNET.WILL 251)

(RPAQQ TELNET.TIMING.MARK 6)

(CONSTANTS (TELNET.IAC 255)
	   (TELNET.DONT 254)
	   (TELNET.DO 253)
	   (TELNET.WONT 252)
	   (TELNET.WILL 251)
	   (TELNET.TIMING.MARK 6))
)


(* END EXPORTED DEFINITIONS)

)
(COND ((BOUNDP (QUOTE CHAT.PROTCOLS))
       (ADDTOVAR CHAT.PROTOCOLS TCPCHAT.HOST.FILTER)))
(PUTPROPS TCPCHAT COPYRIGHT ("Xerox Corporation" 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (929 3795 (TCPCHAT.BIN 939 . 1194) (TCPCHAT.HOST.FILTER 1196 . 1421) (TCPCHAT.NEGOTIATE 
1423 . 1831) (TCPCHAT.NEGOTIATE.DO 1833 . 2324) (TCPCHAT.NEGOTIATE.DONT 2326 . 2478) (
TCPCHAT.NEGOTIATE.WILL 2480 . 2632) (TCPCHAT.NEGOTIATE.WONT 2634 . 2786) (TCPCHAT.OPEN 2788 . 3793))))
)
STOP