Use DEFINE-RECORD-TYPES instead of DEFREC-PACKAGE in FTP.

This commit is contained in:
sperber 2002-12-03 10:44:48 +00:00
parent 6faaa49692
commit fe96c5f2b2
2 changed files with 17 additions and 15 deletions

View File

@ -228,12 +228,12 @@
(let-optionals* args (let-optionals* args
((login ((login
(netrc:lookup-login netrc-record (netrc:lookup-login netrc-record
(ftp-connection:host-name connection))) (ftp-connection-host-name connection)))
(password (password
(netrc:lookup-password netrc-record (netrc:lookup-password netrc-record
(ftp-connection:host-name connection)))) (ftp-connection-host-name connection))))
(set-ftp-connection:login connection login) (set-ftp-connection-login! connection login)
(set-ftp-connection:password connection password) (set-ftp-connection-password! connection password)
(ftp-send-command connection (format #f "USER ~a" login) "...") ; "331" (ftp-send-command connection (format #f "USER ~a" login) "...") ; "331"
(ftp-send-command connection (format #f "PASS ~a" password) "2..")))) ; "230" (ftp-send-command connection (format #f "PASS ~a" password) "2..")))) ; "230"
@ -324,7 +324,7 @@
;;: connection -> status ;;: connection -> status
(define (ftp-quit connection) (define (ftp-quit connection)
(ftp-send-command connection "QUIT" "221") (ftp-send-command connection "QUIT" "221")
(close-socket (ftp-connection:command-socket connection))) (close-socket (ftp-connection-command-socket connection)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -482,12 +482,14 @@
;; We cache the login and password to be able to relogin automatically ;; We cache the login and password to be able to relogin automatically
;; if we lose the connection (a la ange-ftp). Not implemented. ;; if we lose the connection (a la ange-ftp). Not implemented.
(define-record ftp-connection (define-record-type ftp-connection :ftp-connection
host-name (make-ftp-connection host-name command-socket logfd login password)
command-socket ftp-connection?
logfd (host-name ftp-connection-host-name)
login (command-socket ftp-connection-command-socket)
password) (logfd ftp-connection-logfd)
(login ftp-connection-login set-ftp-connection-login!)
(password ftp-connection-password set-ftp-connection-password!))
(define-condition-type 'ftp-error '(error)) (define-condition-type 'ftp-error '(error))
(define ftp-error? (condition-predicate 'ftp-error)) (define ftp-error? (condition-predicate 'ftp-error))
@ -515,7 +517,7 @@
(define (ftp-send-command connection command . maybe-expected) (define (ftp-send-command connection command . maybe-expected)
(let-optionals* maybe-expected ((expected "2..")) (let-optionals* maybe-expected ((expected "2.."))
(let* ((sock (ftp-connection:command-socket connection)) (let* ((sock (ftp-connection-command-socket connection))
(OUT (socket:outport sock))) (OUT (socket:outport sock)))
(write-string command OUT) (write-string command OUT)
(write-crlf OUT) (write-crlf OUT)
@ -536,7 +538,7 @@
;; server. ;; server.
(define (ftp-read-response connection . maybe-expected) (define (ftp-read-response connection . maybe-expected)
(let-optionals* maybe-expected ((expected "2..")) (let-optionals* maybe-expected ((expected "2.."))
(let* ((sock (ftp-connection:command-socket connection)) (let* ((sock (ftp-connection-command-socket connection))
(IN (socket:inport sock)) (IN (socket:inport sock))
(response (read-line IN))) (response (read-line IN)))
(ftp-log connection (format #f "-> ~a" response)) (ftp-log connection (format #f "-> ~a" response))
@ -559,7 +561,7 @@
str)) str))
(define (ftp-log connection line) (define (ftp-log connection line)
(let ((LOG (ftp-connection:logfd connection))) (let ((LOG (ftp-connection-logfd connection)))
(and LOG (and LOG
(write-string line LOG) (write-string line LOG)
(write-string "\n" LOG) (write-string "\n" LOG)

View File

@ -470,7 +470,7 @@
(define-structure ftp ftp-interface (define-structure ftp ftp-interface
(open scheme-with-scsh (open scheme-with-scsh
netrc netrc
defrec-package define-record-types
receiving receiving
handle handle
conditions conditions