X-Git-Url: http://cgit.sxemacs.org/?p=gnus;a=blobdiff_plain;f=lisp%2Fnetrc.el;h=0f8f4d33291be3a625fb11064251ef75bd01f3c5;hp=0a407a86fc7e8f34781f468a5f6843b398d99a2b;hb=786d05e27f23ae1e1254d90a50f61487e168c616;hpb=653e993dac37e97b7f1b33ae2534e17eb1a13fb6 diff --git a/lisp/netrc.el b/lisp/netrc.el index 0a407a86f..0f8f4d332 100644 --- a/lisp/netrc.el +++ b/lisp/netrc.el @@ -1,6 +1,6 @@ ;;; netrc.el --- .netrc parsing functionality -;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 -;; Free Software Foundation, Inc. +;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +;; 2005 Free Software Foundation, Inc. ;; Author: Lars Magne Ingebrigtsen ;; Modularizer: Ted Zlatanov @@ -20,8 +20,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -34,13 +34,14 @@ ;;; .netrc and .authinfo rc parsing ;;; -;; autoload gnus-encrypt +;; autoload encrypt (eval-and-compile - (autoload 'gnus-encrypt-find-model "gnus-encrypt") - (autoload 'gnus-encrypt-insert-file-contents "gnus-encrypt")) + (autoload 'encrypt-find-model "encrypt") + (autoload 'encrypt-insert-file-contents "encrypt")) (defgroup netrc nil - "Netrc configuration.") + "Netrc configuration." + :group 'comm) (defvar netrc-services-file "/etc/services" "The name of the services file.") @@ -53,11 +54,11 @@ (let ((tokens '("machine" "default" "login" "password" "account" "macdef" "force" "port")) - (encryption-model (gnus-encrypt-find-model file)) + (encryption-model (encrypt-find-model file)) alist elem result pair) (if encryption-model - (gnus-encrypt-insert-file-contents file encryption-model) + (encrypt-insert-file-contents file encryption-model) (insert-file-contents file)) (goto-char (point-min)) @@ -131,6 +132,26 @@ Entries without port tokens default to DEFAULTPORT." (pop result)) (car result)))) +(defun netrc-machine-user-or-password (mode authinfo-file-or-list machines ports defaults) + "Get the user name or password according to MODE from AUTHINFO-FILE-OR-LIST. +Matches a machine from MACHINES and a port from PORTS, giving +default ports DEFAULTS to `netrc-machine'. + +MODE can be \"login\" or \"password\", suitable for passing to +`netrc-get'." + (let ((authinfo-list (if (stringp authinfo-file-or-list) + (netrc-parse authinfo-file-or-list) + authinfo-file-or-list)) + (ports (or ports '(nil))) + (defaults (or defaults '(nil))) + info) + (dolist (machine machines) + (dolist (default defaults) + (dolist (port ports) + (let ((alist (netrc-machine authinfo-list machine port default))) + (setq info (or (netrc-get alist mode) info)))))) + info)) + (defun netrc-get (alist type) "Return the value of token TYPE from ALIST." (cdr (assoc type alist)))