Mercurial > hg > xemacs-beta
comparison lisp/efs/efs.el @ 138:6608ceec7cf8 r20-2b3
Import from CVS: tag r20-2b3
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:31:46 +0200 |
parents | 7d55a9ba150c |
children | 169c0442b401 |
comparison
equal
deleted
inserted
replaced
137:cae984061f40 | 138:6608ceec7cf8 |
---|---|
900 ;;; | 900 ;;; |
901 ;;; LCD Archive Entry: | 901 ;;; LCD Archive Entry: |
902 ;;; efs|Andy Norman and Sandy Rutherford | 902 ;;; efs|Andy Norman and Sandy Rutherford |
903 ;;; |ange@hplb.hpl.hp.com and sandy@ibm550.sissa.it | 903 ;;; |ange@hplb.hpl.hp.com and sandy@ibm550.sissa.it |
904 ;;; |transparent FTP Support for GNU Emacs | 904 ;;; |transparent FTP Support for GNU Emacs |
905 ;;; |$Date: 1997/04/05 18:07:24 $|$efs release: 1.15 beta $| | 905 ;;; |$Date: 1997/04/27 19:30:06 $|$efs release: 1.15 beta $| |
906 | 906 |
907 ;;; Host and listing type notation: | 907 ;;; Host and listing type notation: |
908 ;;; | 908 ;;; |
909 ;;; The functions efs-host-type and efs-listing-type, and the | 909 ;;; The functions efs-host-type and efs-listing-type, and the |
910 ;;; variable efs-dired-host-type follow the following conventions | 910 ;;; variable efs-dired-host-type follow the following conventions |
1595 the option to type commands at the FTP connection. Normally, the connection | 1595 the option to type commands at the FTP connection. Normally, the connection |
1596 is killed first. Note that doing this may result in the FTP process filter | 1596 is killed first. Note that doing this may result in the FTP process filter |
1597 getting out of synch with the FTP client, so using this feature routinely | 1597 getting out of synch with the FTP client, so using this feature routinely |
1598 isn't recommended.") | 1598 isn't recommended.") |
1599 | 1599 |
1600 (defvar efs-use-passive-mode nil | |
1601 "*If non-nil, the ftp client will specify passive mode for all transfers.") | |
1602 | |
1600 ;;; Hooks and crooks. | 1603 ;;; Hooks and crooks. |
1601 | 1604 |
1602 (defvar efs-ftp-startup-hook nil | 1605 (defvar efs-ftp-startup-hook nil |
1603 "Hook to run immediately after starting the FTP client. | 1606 "Hook to run immediately after starting the FTP client. |
1604 This hook is run before the FTP OPEN command is sent.") | 1607 This hook is run before the FTP OPEN command is sent.") |
1655 ;; file existence. | 1658 ;; file existence. |
1656 | 1659 |
1657 (defvar efs-cmd-ok-cmds | 1660 (defvar efs-cmd-ok-cmds |
1658 (concat | 1661 (concat |
1659 "^quote port \\|^type \\|^quote site \\|^chmod \\|^quote noop\\|" | 1662 "^quote port \\|^type \\|^quote site \\|^chmod \\|^quote noop\\|" |
1660 "^quote pasv")) | 1663 "^quote pasv\\|^passive")) |
1661 ;; Regexp to match commands for which efs-cmd-ok-msgs is a valid server | 1664 ;; Regexp to match commands for which efs-cmd-ok-msgs is a valid server |
1662 ;; response for success. | 1665 ;; response for success. |
1663 | 1666 |
1664 (defvar efs-passwd-cmds | 1667 (defvar efs-passwd-cmds |
1665 "^quote pass \\|^quote acct \\|^quote site gpass ") | 1668 "^quote pass \\|^quote acct \\|^quote site gpass ") |
1688 "^2[01345][0-7] \\|" ; 2yz = positive completion reply | 1691 "^2[01345][0-7] \\|" ; 2yz = positive completion reply |
1689 "^22[02-7] \\|" ; 221 = successful logout | 1692 "^22[02-7] \\|" ; 221 = successful logout |
1690 ; (Sometimes get this with a timeout, | 1693 ; (Sometimes get this with a timeout, |
1691 ; so treat as fatal.) | 1694 ; so treat as fatal.) |
1692 "^3[0-5][0-7] \\|" ; 3yz = positive intermediate reply | 1695 "^3[0-5][0-7] \\|" ; 3yz = positive intermediate reply |
1696 ;; passive | |
1697 "^[Pp]assive \\|" | |
1693 ;; client codes | 1698 ;; client codes |
1694 "^[Hh]ash mark ")) | 1699 "^[Hh]ash mark ")) |
1695 ;; Response to indicate that the requested action was successfully completed. | 1700 ;; Response to indicate that the requested action was successfully completed. |
1696 | 1701 |
1697 (defvar efs-failed-msgs | 1702 (defvar efs-failed-msgs |
3654 | 3659 |
3655 (progn | 3660 (progn |
3656 ;; Tell client to send back hash-marks as progress. It isn't | 3661 ;; Tell client to send back hash-marks as progress. It isn't |
3657 ;; usually fatal if this command fails. | 3662 ;; usually fatal if this command fails. |
3658 (efs-guess-hash-mark-size proc) | 3663 (efs-guess-hash-mark-size proc) |
3664 | |
3665 (if efs-use-passive-mode | |
3666 (efs-passive-mode host user)) | |
3659 | 3667 |
3660 ;; Run any user startup functions | 3668 ;; Run any user startup functions |
3661 (let ((alist efs-ftp-startup-function-alist) | 3669 (let ((alist efs-ftp-startup-function-alist) |
3662 (case-fold-search t)) | 3670 (case-fold-search t)) |
3663 (while alist | 3671 (while alist |
3694 (if (string-match "^[0-9]+$" size) | 3702 (if (string-match "^[0-9]+$" size) |
3695 (set (if gate-p | 3703 (set (if gate-p |
3696 'efs-gateway-hash-mark-size | 3704 'efs-gateway-hash-mark-size |
3697 'efs-hash-mark-size) | 3705 'efs-hash-mark-size) |
3698 (string-to-int size)))))))))) | 3706 (string-to-int size)))))))))) |
3707 | |
3708 (defun efs-passive-mode (host user) | |
3709 ;; put ftp into passive mode | |
3710 (efs-send-cmd host user '(passive))) | |
3699 | 3711 |
3700 ;;;; ------------------------------------------------------------ | 3712 ;;;; ------------------------------------------------------------ |
3701 ;;;; Simple FTP process shell support. | 3713 ;;;; Simple FTP process shell support. |
3702 ;;;; ------------------------------------------------------------ | 3714 ;;;; ------------------------------------------------------------ |
3703 | 3715 |
4076 (efs-fix-path host-type cmd1)) | 4088 (efs-fix-path host-type cmd1)) |
4077 cmd2 (efs-quote-string host-type | 4089 cmd2 (efs-quote-string host-type |
4078 (efs-fix-path host-type cmd2)) | 4090 (efs-fix-path host-type cmd2)) |
4079 cmd-string (concat "rename " cmd1 " " cmd2)))) | 4091 cmd-string (concat "rename " cmd1 " " cmd2)))) |
4080 | 4092 |
4093 ;; passive command | |
4094 ((eq cmd0 'passive) | |
4095 (setq cmd-string "passive")) | |
4096 | |
4081 (t | 4097 (t |
4082 (error "efs: Don't know how to send %s %s %s %s" | 4098 (error "efs: Don't know how to send %s %s %s %s" |
4083 cmd0 cmd1 cmd2 cmd3)))) | 4099 cmd0 cmd1 cmd2 cmd3)))) |
4084 | 4100 |
4085 ;; Actually send the resulting command. | 4101 ;; Actually send the resulting command. |
4209 (let ((gate (efs-use-gateway-p host))) | 4225 (let ((gate (efs-use-gateway-p host))) |
4210 (if (eq gate 'kerberos) | 4226 (if (eq gate 'kerberos) |
4211 (progn | 4227 (progn |
4212 (setq proc (efs-kerberos-login host user proc)) | 4228 (setq proc (efs-kerberos-login host user proc)) |
4213 (efs-login-send-user host user proc gate)) | 4229 (efs-login-send-user host user proc gate)) |
4214 (let ((to (if (memq gate '(proxy local raptor)) | 4230 (let ((to (if (memq gate '(proxy raptor)) |
4215 efs-gateway-host | 4231 efs-gateway-host |
4216 host)) | 4232 host)) |
4217 port cmd result) | 4233 port cmd result) |
4218 (if (string-match "#" to) | 4234 (if (string-match "#" to) |
4219 (setq port (substring to (match-end 0)) | 4235 (setq port (substring to (match-end 0)) |
4243 (defun efs-login-send-user (host user proc &optional gate retry) | 4259 (defun efs-login-send-user (host user proc &optional gate retry) |
4244 "Send user command to HOST and USER. PROC is the ftp client process. | 4260 "Send user command to HOST and USER. PROC is the ftp client process. |
4245 Optional argument GATE specifies which type of gateway is being used. | 4261 Optional argument GATE specifies which type of gateway is being used. |
4246 RETRY argument specifies to try twice if we get a 421 response." | 4262 RETRY argument specifies to try twice if we get a 421 response." |
4247 (let ((cmd (cond | 4263 (let ((cmd (cond |
4248 ((memq gate '(local proxy interlock)) | 4264 ((memq gate '(proxy interlock)) |
4249 (format "quote USER \"%s\"@%s" user | 4265 (format "quote USER \"%s\"@%s" user |
4250 (if (and efs-nslookup-on-connect | 4266 (if (and efs-nslookup-on-connect |
4251 (string-match "[^0-9.]" host)) | 4267 (string-match "[^0-9.]" host)) |
4252 (efs-nslookup-host host) | 4268 (efs-nslookup-host host) |
4253 host))) | 4269 host))) |
4271 (setq to (concat to "@" port)))) | 4287 (setq to (concat to "@" port)))) |
4272 (format "quote user \"%s\"@%s" user to))) | 4288 (format "quote user \"%s\"@%s" user to))) |
4273 (t | 4289 (t |
4274 (format "quote user \"%s\"" user)))) | 4290 (format "quote user \"%s\"" user)))) |
4275 (msg (format "Logging in as user %s%s..." user | 4291 (msg (format "Logging in as user %s%s..." user |
4276 (if (memq gate '(proxy local raptor kerberos)) | 4292 (if (memq gate '(proxy raptor kerberos)) |
4277 (concat "@" host) ""))) | 4293 (concat "@" host) ""))) |
4278 result code) | 4294 result code) |
4279 | 4295 |
4280 ;; Send the message by hand so that we can report on the size | 4296 ;; Send the message by hand so that we can report on the size |
4281 ;; of the MOTD. | 4297 ;; of the MOTD. |