Mercurial > emacs
annotate lisp/=netunam.el @ 16407:a3bd74a05c45
(cancel-function-timers): Add autoload.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 08 Oct 1996 19:01:56 +0000 |
parents | f287613dfc28 |
children |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
1 ;;; netunam.el --- HP-UX RFA Commands |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
2 |
846
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
3 ;; Copyright (C) 1988 Free Software Foundation, Inc. |
20674ae6bf52
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
791
diff
changeset
|
5 ;; Author: Chris Hanson <cph@zurich.ai.mit.edu> |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
851
diff
changeset
|
6 ;; Keywords: comm |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
7 |
35 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
791
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
35 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
24 ;;; Commentary: |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
25 |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
26 ;; Use the Remote File Access (RFA) facility of HP-UX from Emacs. |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
27 |
791
203c23c9f22c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
28 ;;; Code: |
35 | 29 |
30 (defconst rfa-node-directory "/net/" | |
31 "Directory in which RFA network special files are stored. | |
32 By HP convention, this is \"/net/\".") | |
33 | |
34 (defvar rfa-default-node nil | |
35 "If not nil, this is the name of the default RFA network special file.") | |
36 | |
37 (defvar rfa-password-memoize-p t | |
38 "If non-nil, remember login user's passwords after they have been entered.") | |
39 | |
40 (defvar rfa-password-alist '() | |
41 "An association from node-name strings to password strings. | |
42 Used if `rfa-password-memoize-p' is non-nil.") | |
43 | |
44 (defvar rfa-password-per-node-p t | |
45 "If nil, login user uses same password on all machines. | |
46 Has no effect if `rfa-password-memoize-p' is nil.") | |
47 | |
48 (defun rfa-set-password (password &optional node user) | |
49 "Add PASSWORD to the RFA password database. | |
50 Optional second arg NODE is a string specifying a particular nodename; | |
51 if supplied and not nil, PASSWORD applies to only that node. | |
52 Optional third arg USER is a string specifying the (remote) user whose | |
53 password this is; if not supplied this defaults to (user-login-name)." | |
54 (if (not user) (setq user (user-login-name))) | |
55 (let ((node-entry (assoc node rfa-password-alist))) | |
56 (if node-entry | |
57 (let ((user-entry (assoc user (cdr node-entry)))) | |
58 (if user-entry | |
59 (rplacd user-entry password) | |
60 (rplacd node-entry | |
61 (nconc (cdr node-entry) | |
62 (list (cons user password)))))) | |
63 (setq rfa-password-alist | |
64 (nconc rfa-password-alist | |
65 (list (list node (cons user password)))))))) | |
66 | |
67 (defun rfa-open (node &optional user password) | |
68 "Open a network connection to a server using remote file access. | |
69 First argument NODE is the network node for the remote machine. | |
70 Second optional argument USER is the user name to use on that machine. | |
71 If called interactively, the user name is prompted for. | |
72 Third optional argument PASSWORD is the password string for that user. | |
73 If not given, this is filled in from the value of | |
74 `rfa-password-alist', or prompted for. A prefix argument of - will | |
75 cause the password to be prompted for even if previously memoized." | |
76 (interactive | |
77 (list (read-file-name "rfa-open: " rfa-node-directory rfa-default-node t) | |
78 (read-string "user-name: " (user-login-name)))) | |
79 (let ((node | |
80 (and (or rfa-password-per-node-p | |
81 (not (equal user (user-login-name)))) | |
82 node))) | |
83 (if (not password) | |
84 (setq password | |
85 (let ((password | |
86 (cdr (assoc user (cdr (assoc node rfa-password-alist)))))) | |
87 (or (and (not current-prefix-arg) password) | |
88 (rfa-password-read | |
89 (format "password for user %s%s: " | |
90 user | |
91 (if node (format " on node \"%s\"" node) "")) | |
92 password)))))) | |
93 (let ((result | |
94 (sysnetunam (expand-file-name node rfa-node-directory) | |
95 (concat user ":" password)))) | |
96 (if (interactive-p) | |
97 (if result | |
98 (message "Opened network connection to %s as %s" node user) | |
99 (error "Unable to open network connection"))) | |
100 (if (and rfa-password-memoize-p result) | |
101 (rfa-set-password password node user)) | |
102 result)) | |
103 | |
104 (defun rfa-close (node) | |
105 "Close a network connection to a server using remote file access. | |
106 NODE is the network node for the remote machine." | |
107 (interactive | |
108 (list (read-file-name "rfa-close: " rfa-node-directory rfa-default-node t))) | |
109 (let ((result (sysnetunam (expand-file-name node rfa-node-directory) ""))) | |
110 (cond ((not (interactive-p)) result) | |
111 ((not result) (error "Unable to close network connection")) | |
112 (t (message "Closed network connection to %s" node))))) | |
113 | |
114 (defun rfa-password-read (prompt default) | |
115 (let ((rfa-password-accumulator (or default ""))) | |
116 (read-from-minibuffer prompt | |
117 (and default | |
118 (let ((copy (concat default)) | |
119 (index 0) | |
120 (length (length default))) | |
121 (while (< index length) | |
122 (aset copy index ?.) | |
123 (setq index (1+ index))) | |
124 copy)) | |
125 rfa-password-map) | |
126 rfa-password-accumulator)) | |
127 | |
128 (defvar rfa-password-map nil) | |
129 (if (not rfa-password-map) | |
130 (let ((char ? )) | |
131 (setq rfa-password-map (make-keymap)) | |
132 (while (< char 127) | |
133 (define-key rfa-password-map (char-to-string char) | |
134 'rfa-password-self-insert) | |
135 (setq char (1+ char))) | |
136 (define-key rfa-password-map "\C-g" | |
137 'abort-recursive-edit) | |
138 (define-key rfa-password-map "\177" | |
139 'rfa-password-rubout) | |
140 (define-key rfa-password-map "\n" | |
141 'exit-minibuffer) | |
142 (define-key rfa-password-map "\r" | |
143 'exit-minibuffer))) | |
144 | |
145 (defvar rfa-password-accumulator nil) | |
146 | |
147 (defun rfa-password-self-insert () | |
148 (interactive) | |
149 (setq rfa-password-accumulator | |
150 (concat rfa-password-accumulator | |
151 (char-to-string last-command-char))) | |
152 (insert ?.)) | |
153 | |
154 (defun rfa-password-rubout () | |
155 (interactive) | |
156 (delete-char -1) | |
157 (setq rfa-password-accumulator | |
158 (substring rfa-password-accumulator 0 -1))) | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
159 |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
160 ;;; netunam.el ends here |