comparison lisp/ange-ftp.el @ 23464:7fb0a3c74e1d

(ange-ftp-read-passwd): Function deleted. (ange-ftp-set-passwd): Use read-passwd, not ange-ftp-read-passwd. (ange-ftp-get-passwd, ange-ftp-set-account): Likewise.
author Dave Love <fx@gnu.org>
date Wed, 14 Oct 1998 18:18:52 +0000
parents 3741d2ab743a
children abcdf0c8e98d
comparison
equal deleted inserted replaced
23463:ac51d834b81e 23464:7fb0a3c74e1d
1126 1126
1127 ;;;; ------------------------------------------------------------ 1127 ;;;; ------------------------------------------------------------
1128 ;;;; Password support. 1128 ;;;; Password support.
1129 ;;;; ------------------------------------------------------------ 1129 ;;;; ------------------------------------------------------------
1130 1130
1131 (defun ange-ftp-read-passwd (prompt &optional default)
1132 "Read a password, echoing `.' for each character typed.
1133 End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line.
1134 Optional DEFAULT is password to start with."
1135 (let ((pass nil)
1136 (c 0)
1137 (echo-keystrokes 0)
1138 (cursor-in-echo-area t))
1139 (while (progn (message "%s%s"
1140 prompt
1141 (make-string (length pass) ?.))
1142 (setq c (read-char))
1143 (and (/= c ?\r) (/= c ?\n) (/= c ?\e)))
1144 (if (= c ?\C-u)
1145 (setq pass "")
1146 (if (and (/= c ?\b) (/= c ?\177))
1147 (setq pass (concat pass (char-to-string c)))
1148 (if (> (length pass) 0)
1149 (setq pass (substring pass 0 -1))))))
1150 (message "")
1151 (ange-ftp-repaint-minibuffer)
1152 (or pass default "")))
1153
1154 (defmacro ange-ftp-generate-passwd-key (host user) 1131 (defmacro ange-ftp-generate-passwd-key (host user)
1155 (` (concat (downcase (, host)) "/" (, user)))) 1132 (` (concat (downcase (, host)) "/" (, user))))
1156 1133
1157 (defmacro ange-ftp-lookup-passwd (host user) 1134 (defmacro ange-ftp-lookup-passwd (host user)
1158 (` (ange-ftp-get-hash-entry (ange-ftp-generate-passwd-key (, host) (, user)) 1135 (` (ange-ftp-get-hash-entry (ange-ftp-generate-passwd-key (, host) (, user))
1160 1137
1161 (defun ange-ftp-set-passwd (host user passwd) 1138 (defun ange-ftp-set-passwd (host user passwd)
1162 "For a given HOST and USER, set or change the associated PASSWORD." 1139 "For a given HOST and USER, set or change the associated PASSWORD."
1163 (interactive (list (read-string "Host: ") 1140 (interactive (list (read-string "Host: ")
1164 (read-string "User: ") 1141 (read-string "User: ")
1165 (ange-ftp-read-passwd "Password: "))) 1142 (read-passwd "Password: ")))
1166 (ange-ftp-put-hash-entry (ange-ftp-generate-passwd-key host user) 1143 (ange-ftp-put-hash-entry (ange-ftp-generate-passwd-key host user)
1167 passwd 1144 passwd
1168 ange-ftp-passwd-hashtable)) 1145 ange-ftp-passwd-hashtable))
1169 1146
1170 (defun ange-ftp-get-host-with-passwd (user) 1147 (defun ange-ftp-get-host-with-passwd (user)
1223 (let* ((other (ange-ftp-get-host-with-passwd user)) 1200 (let* ((other (ange-ftp-get-host-with-passwd user))
1224 (passwd (if other 1201 (passwd (if other
1225 1202
1226 ;; found another machine with the same user. 1203 ;; found another machine with the same user.
1227 ;; Try that account. 1204 ;; Try that account.
1228 (ange-ftp-read-passwd 1205 (read-passwd
1229 (format "passwd for %s@%s (default same as %s@%s): " 1206 (format "passwd for %s@%s (default same as %s@%s): "
1230 user host user other) 1207 user host user other)
1208 nil
1231 (ange-ftp-lookup-passwd other user)) 1209 (ange-ftp-lookup-passwd other user))
1232 1210
1233 ;; I give up. Ask the user for the password. 1211 ;; I give up. Ask the user for the password.
1234 (ange-ftp-read-passwd 1212 (read-passwd
1235 (format "Password for %s@%s: " user host))))) 1213 (format "Password for %s@%s: " user host)))))
1236 (ange-ftp-set-passwd host user passwd) 1214 (ange-ftp-set-passwd host user passwd)
1237 passwd)))) 1215 passwd))))
1238 1216
1239 ;;;; ------------------------------------------------------------ 1217 ;;;; ------------------------------------------------------------
1247 1225
1248 (defun ange-ftp-set-account (host user account) 1226 (defun ange-ftp-set-account (host user account)
1249 "For a given HOST and USER, set or change the associated ACCOUNT password." 1227 "For a given HOST and USER, set or change the associated ACCOUNT password."
1250 (interactive (list (read-string "Host: ") 1228 (interactive (list (read-string "Host: ")
1251 (read-string "User: ") 1229 (read-string "User: ")
1252 (ange-ftp-read-passwd "Account password: "))) 1230 (read-passwd "Account password: ")))
1253 (ange-ftp-put-hash-entry (ange-ftp-generate-passwd-key host user) 1231 (ange-ftp-put-hash-entry (ange-ftp-generate-passwd-key host user)
1254 account 1232 account
1255 ange-ftp-account-hashtable)) 1233 ange-ftp-account-hashtable))
1256 1234
1257 (defun ange-ftp-get-account (host user) 1235 (defun ange-ftp-get-account (host user)