Mercurial > emacs
annotate lisp/net/netrc.el @ 110372:8e1e2c124dec
(c-forward-<>-arglist-recur): Correct the indentation.
author | Alan Mackenzie <acm@muc.de> |
---|---|
date | Wed, 15 Sep 2010 17:51:15 +0000 |
parents | 838fb634d1b0 |
children | f2e111723c3a |
rev | line source |
---|---|
44810 | 1 ;;; netrc.el --- .netrc parsing functionality |
64701
34bd8e434dd7
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
106815 | 3 ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
44810 | 4 |
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | |
6 ;; Keywords: news | |
107390 | 7 ;; |
44810 | 8 ;; Modularized by Ted Zlatanov <tzz@lifelogs.com> |
9 ;; when it was part of Gnus. | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
44810 | 14 ;; it under the terms of the GNU General Public License as published by |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
16 ;; (at your option) any later version. |
44810 | 17 |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
44810 | 21 ;; GNU General Public License for more details. |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
94677
91e5880a36c1
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
44810 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; Just the .netrc parsing functionality, abstracted so other packages | |
29 ;; besides Gnus can use it. | |
30 | |
31 ;;; Code: | |
32 | |
33 ;;; | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
34 ;;; .netrc and .authinfo rc parsing |
44810 | 35 ;;; |
36 | |
87454 | 37 ;; use encrypt if loaded (encrypt-file-alist has to be set as well) |
95624
164c226d4a0d
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95193
diff
changeset
|
38 (autoload 'encrypt-find-model "encrypt") |
164c226d4a0d
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95193
diff
changeset
|
39 (autoload 'encrypt-insert-file-contents "encrypt") |
44810 | 40 (defalias 'netrc-point-at-eol |
41 (if (fboundp 'point-at-eol) | |
42 'point-at-eol | |
43 'line-end-position)) | |
95624
164c226d4a0d
Remove unnecessary eval-when-compiles and eval-and-compiles.
Glenn Morris <rgm@gnu.org>
parents:
95193
diff
changeset
|
44 (defvar encrypt-file-alist) |
87454 | 45 (eval-when-compile |
46 ;; This is unnecessary in the compiled version as it is a macro. | |
47 (if (fboundp 'bound-and-true-p) | |
48 (defalias 'netrc-bound-and-true-p 'bound-and-true-p) | |
49 (defmacro netrc-bound-and-true-p (var) | |
50 "Return the value of symbol VAR if it is bound, else nil." | |
51 `(and (boundp (quote ,var)) ,var)))) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
52 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
53 (defgroup netrc nil |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
54 "Netrc configuration." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
55 :group 'comm) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
56 |
110306
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
57 (defcustom netrc-file "~/.authinfo" |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
58 "File where user credentials are stored." |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
59 :type 'file |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
60 :group 'netrc) |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
61 |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
62 (defvar netrc-services-file "/etc/services" |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
63 "The name of the services file.") |
44810 | 64 |
110306
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
65 (defun netrc-parse (&optional file) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
66 (interactive "fFile to Parse: ") |
92694 | 67 "Parse FILE and return a list of all entries in the file." |
110306
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
68 (unless file |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
69 (setq file netrc-file)) |
99506 | 70 (if (listp file) |
71 file | |
72 (when (file-exists-p file) | |
73 (with-temp-buffer | |
74 (let ((tokens '("machine" "default" "login" | |
75 "password" "account" "macdef" "force" | |
76 "port")) | |
77 (encryption-model (when (netrc-bound-and-true-p encrypt-file-alist) | |
78 (encrypt-find-model file))) | |
79 alist elem result pair) | |
80 (if encryption-model | |
81 (encrypt-insert-file-contents file encryption-model) | |
82 (insert-file-contents file)) | |
83 (goto-char (point-min)) | |
84 ;; Go through the file, line by line. | |
44810 | 85 (while (not (eobp)) |
99506 | 86 (narrow-to-region (point) (point-at-eol)) |
87 ;; For each line, get the tokens and values. | |
88 (while (not (eobp)) | |
89 (skip-chars-forward "\t ") | |
90 ;; Skip lines that begin with a "#". | |
91 (if (eq (char-after) ?#) | |
92 (goto-char (point-max)) | |
93 (unless (eobp) | |
94 (setq elem | |
95 (if (= (following-char) ?\") | |
96 (read (current-buffer)) | |
97 (buffer-substring | |
98 (point) (progn (skip-chars-forward "^\t ") | |
99 (point))))) | |
100 (cond | |
101 ((equal elem "macdef") | |
102 ;; We skip past the macro definition. | |
103 (widen) | |
104 (while (and (zerop (forward-line 1)) | |
105 (looking-at "$"))) | |
106 (narrow-to-region (point) (point))) | |
107 ((member elem tokens) | |
108 ;; Tokens that don't have a following value are ignored, | |
109 ;; except "default". | |
110 (when (and pair (or (cdr pair) | |
111 (equal (car pair) "default"))) | |
112 (push pair alist)) | |
113 (setq pair (list elem))) | |
114 (t | |
115 ;; Values that haven't got a preceding token are ignored. | |
116 (when pair | |
117 (setcdr pair elem) | |
118 (push pair alist) | |
119 (setq pair nil))))))) | |
120 (when alist | |
121 (push (nreverse alist) result)) | |
122 (setq alist nil | |
123 pair nil) | |
124 (widen) | |
125 (forward-line 1)) | |
126 (nreverse result)))))) | |
44810 | 127 |
128 (defun netrc-machine (list machine &optional port defaultport) | |
129 "Return the netrc values from LIST for MACHINE or for the default entry. | |
130 If PORT specified, only return entries with matching port tokens. | |
131 Entries without port tokens default to DEFAULTPORT." | |
132 (let ((rest list) | |
133 result) | |
134 (while list | |
135 (when (equal (cdr (assoc "machine" (car list))) machine) | |
136 (push (car list) result)) | |
137 (pop list)) | |
138 (unless result | |
139 ;; No machine name matches, so we look for default entries. | |
140 (while rest | |
141 (when (assoc "default" (car rest)) | |
142 (push (car rest) result)) | |
143 (pop rest))) | |
144 (when result | |
145 (setq result (nreverse result)) | |
146 (while (and result | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
147 (not (netrc-port-equal |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
148 (or port defaultport "nntp") |
95193 | 149 ;; when port is not given in the netrc file, |
150 ;; it should mean "any port" | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
151 (or (netrc-get (car result) "port") |
95193 | 152 defaultport port)))) |
44810 | 153 (pop result)) |
154 (car result)))) | |
155 | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
156 (defun netrc-machine-user-or-password (mode authinfo-file-or-list machines ports defaults) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
157 "Get the user name or password according to MODE from AUTHINFO-FILE-OR-LIST. |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
158 Matches a machine from MACHINES and a port from PORTS, giving |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
159 default ports DEFAULTS to `netrc-machine'. |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
160 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
161 MODE can be \"login\" or \"password\", suitable for passing to |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
162 `netrc-get'." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
163 (let ((authinfo-list (if (stringp authinfo-file-or-list) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
164 (netrc-parse authinfo-file-or-list) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
165 authinfo-file-or-list)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
166 (ports (or ports '(nil))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
167 (defaults (or defaults '(nil))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
168 info) |
101804 | 169 (if (listp mode) |
110111
5b9f64b04a04
Delete all trailing white space.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110102
diff
changeset
|
170 (setq info |
5b9f64b04a04
Delete all trailing white space.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110102
diff
changeset
|
171 (mapcar |
5b9f64b04a04
Delete all trailing white space.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110102
diff
changeset
|
172 (lambda (mode-element) |
101804 | 173 (netrc-machine-user-or-password |
174 mode-element | |
175 authinfo-list | |
176 machines | |
177 ports | |
178 defaults)) | |
179 mode)) | |
180 (dolist (machine machines) | |
181 (dolist (default defaults) | |
182 (dolist (port ports) | |
183 (let ((alist (netrc-machine authinfo-list machine port default))) | |
184 (setq info (or (netrc-get alist mode) info))))))) | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
185 info)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
186 |
44810 | 187 (defun netrc-get (alist type) |
188 "Return the value of token TYPE from ALIST." | |
189 (cdr (assoc type alist))) | |
190 | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
191 (defun netrc-port-equal (port1 port2) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
192 (when (numberp port1) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
193 (setq port1 (or (netrc-find-service-name port1) port1))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
194 (when (numberp port2) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
195 (setq port2 (or (netrc-find-service-name port2) port2))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
196 (equal port1 port2)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
197 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
198 (defun netrc-parse-services () |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
199 (when (file-exists-p netrc-services-file) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
200 (let ((services nil)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
201 (with-temp-buffer |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
202 (insert-file-contents netrc-services-file) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
203 (while (search-forward "#" nil t) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
204 (delete-region (1- (point)) (point-at-eol))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
205 (goto-char (point-min)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
206 (while (re-search-forward |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
207 "^ *\\([^ \n\t]+\\)[ \t]+\\([0-9]+\\)/\\([^ \t\n]+\\)" nil t) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
208 (push (list (match-string 1) (string-to-number (match-string 2)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
209 (intern (downcase (match-string 3)))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
210 services)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
211 (nreverse services))))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
212 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
213 (defun netrc-find-service-name (number &optional type) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
214 (let ((services (netrc-parse-services)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
215 service) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
216 (setq type (or type 'tcp)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
217 (while (and (setq service (pop services)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
218 (not (and (= number (cadr service)) |
86963
d549ccffa35b
(top-level): Don't load `encrypt' features.
Glenn Morris <rgm@gnu.org>
parents:
85712
diff
changeset
|
219 (eq type (car (cddr service))))))) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
220 (car service))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
221 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
222 (defun netrc-find-service-number (name &optional type) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
223 (let ((services (netrc-parse-services)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
224 service) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
225 (setq type (or type 'tcp)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
226 (while (and (setq service (pop services)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
227 (not (and (string= name (car service)) |
86963
d549ccffa35b
(top-level): Don't load `encrypt' features.
Glenn Morris <rgm@gnu.org>
parents:
85712
diff
changeset
|
228 (eq type (car (cddr service))))))) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
229 (cadr service))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78230
diff
changeset
|
230 |
110306
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
231 (defun netrc-credentials (machine &rest ports) |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
232 "Return a user name/password pair. |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
233 Port specifications will be prioritised in the order they are |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
234 listed in the PORTS list." |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
235 (let ((list (netrc-parse)) |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
236 found) |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
237 (while (and ports |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
238 (not found)) |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
239 (setq found (netrc-machine list machine (pop ports)))) |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
240 (when found |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
241 (list (cdr (assoc "login" found)) |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
242 (cdr (assoc "password" found)))))) |
838fb634d1b0
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110111
diff
changeset
|
243 |
44810 | 244 (provide 'netrc) |
245 | |
246 ;;; netrc.el ends here |