Gnus development mailing list
 help / color / mirror / Atom feed
From: Ted Zlatanov <teodor.zlatanov@divine.com>
Cc: ding <ding@gnus.org>, <scranefield@infoscience.otago.ac.nz>
Subject: Re: smtpmail-auth-credentials from authinfo
Date: Tue, 23 Apr 2002 11:53:56 -0400	[thread overview]
Message-ID: <m3y9fe1kdn.fsf@onyx.nimbus.northernlight.com> (raw)
In-Reply-To: <Pine.LNX.4.44.0204191752290.924-100000@yxa.extundo.com> (Simon Josefsson's message of "Fri, 19 Apr 2002 17:55:43 +0200 (CEST)")

[-- Attachment #1: Type: text/plain, Size: 1793 bytes --]

On Fri, 19 Apr 2002, jas@extundo.com wrote:
> On Fri, 19 Apr 2002, Ted Zlatanov wrote:
> 
>> Should I extract that to authinfo.el (or netrc.el?)  so it can be
>> integrated with smtpmail.el?
> 
> I think that would be a good idea.  nntp.el, imap.el and sieve.el
> would also need to be changed, and maybe more stuff.

I am attaching the netrc.el file, and the patch to gnus-util.el that
will provide backward compatibility (via defalias calls) until the
maintainers of the respective modules want to move to the netrc
function names.

I had to do

(eval-and-compile
  (defalias 'netrc-point-at-eol
    (if (fboundp 'point-at-eol)
	'point-at-eol
      'line-end-position)))

instead of 

(defalias 'netrc-point-at-eol
  (if (fboundp 'point-at-eol)
      'point-at-eol
    'line-end-position))

I'm not sure why the compilation was having problems with the
function without the eval-and-compile...  The rest was very easy
though.

>> Also smtpmail.el needs to be patched so it accepts the old-style
>> flat lists and the gnus-parse-netrc style output.
> 
> I think it would be better if smtpmail.el looked in .authinfo by
> default, and not touch the `smtpmail-auth-credentials' stuff.

When I know that the netrc.el functionality is accepted, I will try to
modify smtpmail.el further to work with the netrc interface.
smtpmail.el ships with Emacs, while netrc.el does not (yet?), so it
doesn't make sense to modify smtpmail.el to rely on the netrc
functionality only.  It should look for netrc first, and failing that
it should try the smtpmail-auth-credentials.  I would appreciate
comments from Stephen Cranefield, who's noted in the smtpmail.el
credits as the AUTH support author.  It would also be good to know the
chances of having netrc.el included in the main Emacs distro.

Thanks
Ted


[-- Attachment #2: netrc.el --]
[-- Type: application/emacs-lisp, Size: 3858 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: gnus-util-netrc.patch --]
[-- Type: text/x-patch, Size: 3414 bytes --]

--- gnus-util.el	Tue Apr 23 11:50:53 2002
+++ gnus-util.el.new	Tue Apr 23 11:39:58 2002
@@ -38,6 +38,7 @@
   (defvar nnmail-pathname-coding-system))
 (require 'nnheader)
 (require 'time-date)
+(require 'netrc)
 
 (eval-and-compile
   (autoload 'message-fetch-field "message")
@@ -62,6 +63,11 @@
 	  (setq start (- (length string) tail))))
       string))))
 
+;;; bring in the netrc functions as aliases
+(defalias 'gnus-netrc-get 'netrc-get)
+(defalias 'gnus-netrc-machine 'netrc-machine)
+(defalias 'gnus-parse-netrc 'netrc-parse)
+
 (defun gnus-boundp (variable)
   "Return non-nil if VARIABLE is bound and non-nil."
   (and (boundp variable)
@@ -899,93 +905,6 @@
     (unwind-protect
 	(apply 'run-hooks funcs)
       (set-buffer buf))))
-
-;;;
-;;; .netrc and .authinforc parsing
-;;;
-
-(defun gnus-parse-netrc (file)
-  "Parse FILE and return an list of all entries in the file."
-  (when (file-exists-p file)
-    (with-temp-buffer
-      (let ((tokens '("machine" "default" "login"
-		      "password" "account" "macdef" "force"
-		      "port"))
-	    alist elem result pair)
-	(insert-file-contents file)
-	(goto-char (point-min))
-	;; Go through the file, line by line.
-	(while (not (eobp))
-	  (narrow-to-region (point) (gnus-point-at-eol))
-	  ;; For each line, get the tokens and values.
-	  (while (not (eobp))
-	    (skip-chars-forward "\t ")
-	    ;; Skip lines that begin with a "#".
-	    (if (eq (char-after) ?#)
-		(goto-char (point-max))
-	      (unless (eobp)
-		(setq elem
-		      (if (= (following-char) ?\")
-			  (read (current-buffer))
-			(buffer-substring
-			 (point) (progn (skip-chars-forward "^\t ")
-					(point)))))
-		(cond
-		 ((equal elem "macdef")
-		  ;; We skip past the macro definition.
-		  (widen)
-		  (while (and (zerop (forward-line 1))
-			      (looking-at "$")))
-		  (narrow-to-region (point) (point)))
-		 ((member elem tokens)
-		  ;; Tokens that don't have a following value are ignored,
-		  ;; except "default".
-		  (when (and pair (or (cdr pair)
-				      (equal (car pair) "default")))
-		    (push pair alist))
-		  (setq pair (list elem)))
-		 (t
-		  ;; Values that haven't got a preceding token are ignored.
-		  (when pair
-		    (setcdr pair elem)
-		    (push pair alist)
-		    (setq pair nil)))))))
-	  (when alist
-	    (push (nreverse alist) result))
-	  (setq alist nil
-		pair nil)
-	  (widen)
-	  (forward-line 1))
-	(nreverse result)))))
-
-(defun gnus-netrc-machine (list machine &optional port defaultport)
-  "Return the netrc values from LIST for MACHINE or for the default entry.
-If PORT specified, only return entries with matching port tokens.
-Entries without port tokens default to DEFAULTPORT."
-  (let ((rest list)
-	result)
-    (while list
-      (when (equal (cdr (assoc "machine" (car list))) machine)
-	(push (car list) result))
-      (pop list))
-    (unless result
-      ;; No machine name matches, so we look for default entries.
-      (while rest
-	(when (assoc "default" (car rest))
-	  (push (car rest) result))
-	(pop rest)))
-    (when result
-      (setq result (nreverse result))
-      (while (and result
-		  (not (equal (or port defaultport "nntp")
-			      (or (gnus-netrc-get (car result) "port")
-				  defaultport "nntp"))))
-	(pop result))
-      (car result))))
-
-(defun gnus-netrc-get (alist type)
-  "Return the value of token TYPE from ALIST."
-  (cdr (assoc type alist)))
 
 ;;; Various
 

  reply	other threads:[~2002-04-23 15:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-19 14:21 Ted Zlatanov
2002-04-19 14:47 ` Simon Josefsson
2002-04-19 15:41   ` Ted Zlatanov
2002-04-19 15:55     ` Simon Josefsson
2002-04-23 15:53       ` Ted Zlatanov [this message]
2002-04-23 17:23         ` Simon Josefsson
2002-04-25 19:25           ` Ted Zlatanov
2002-04-19 15:33 ` Kai Großjohann
2002-04-23 21:51 Stephen Cranefield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3y9fe1kdn.fsf@onyx.nimbus.northernlight.com \
    --to=teodor.zlatanov@divine.com \
    --cc=ding@gnus.org \
    --cc=scranefield@infoscience.otago.ac.nz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).