Rewrite FTP-BUILD-PORT-STRING in terms of FORMAT-INTERNET-HOST-ADDRESS

and FORMAT-PORT.
This commit is contained in:
sperber 2003-01-16 09:23:05 +00:00
parent 30f6f2a0a6
commit 045ded0d30
2 changed files with 7 additions and 16 deletions

View File

@ -392,22 +392,12 @@
(define (ftp-build-PORT-string sockaddr)
(let* ((hst-info (host-info (system-name)))
(ip-address (car (host-info:addresses hst-info))))
(receive (hst-address srvc-port)
(socket-address->internet-address sockaddr)
(let* ((num32 ip-address)
(num24 (arithmetic-shift num32 -8))
(num16 (arithmetic-shift num24 -8))
(num08 (arithmetic-shift num16 -8))
(byte0 (bitwise-and #b11111111 num08))
(byte1 (bitwise-and #b11111111 num16))
(byte2 (bitwise-and #b11111111 num24))
(byte3 (bitwise-and #b11111111 num32)))
(format #f "PORT ~a,~a,~a,~a,~a,~a"
byte0 byte1 byte2 byte3
(arithmetic-shift srvc-port -8) ; high order byte
(bitwise-and #b11111111 srvc-port) ; lower order byte
)))))
(receive (hst-address srvc-port)
(socket-address->internet-address sockaddr)
(string-append "PORT "
(format-internet-host-address ip-address ",")
","
(format-port srvc-port)))))
(define (ftp-send-command connection command . maybe-expected)
(let-optionals* maybe-expected ((expected "2.."))

View File

@ -412,6 +412,7 @@
(subset srfi-13 (string-join))
let-opt
sunet-utilities
format-net
crlf-io)
(files (lib ftp)))