Gnus development mailing list
 help / color / mirror / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
Cc: ding@gnus.org
Subject: hashcash.el problems
Date: Thu, 29 May 2003 08:30:44 +0900	[thread overview]
Message-ID: <b9yd6i2odi3.fsf@jpl.org> (raw)

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

Hi,

I'm using hashcash.el bundled with the Gnus distribution and the
hashcash v0.25 binary under the linux system.  I've modified
hashcash.el a bit since I got the following error.  Is it
reasonable or do I need any other requirement?

Signaling: (error "Unknown hashcash format version")
  (cond ((equal ... ?:) 1.2) ((equal ... ?:) 1.1) (t (error "Unknown hashcash format version")))
  hashcash-version("hashcash token: 0:030528:yamaoka@jpl.org:8bdd14129fd11df5")
  (number-to-string (hashcash-version pay))
  (insert-before-markers "X-Payment: hashcash " (number-to-string (hashcash-version pay)) " " pay "\n")
[...]
  hashcash-insert-payment("yamaoka@jpl.org")

I think we need to use the -q option to call the hashcash binary:

sh-2.05b$ hashcash -b 1 x|cat -
hashcash token: 0:030528:x:d657059d895c6292
0:030528:x:d657059d895c6292

sh-2.05b$ hashcash -q -b 1 x|cat -
0:030528:x:50c32261071a29c0

In addition, hashcash.el uses three cl run-time functions;
subseq, mapc, and caddr, though mapc is built-in in the recent
Emacs and cl provides a compiler macro for caddr.  I made a
complete patch to hashcash.el to meet Gnus' policy that it
should never use cl run-time functions and still supports Emacs
20.  How about it?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1775 bytes --]

--- hashcash.el~	2003-04-16 22:33:29 +0000
+++ hashcash.el	2003-05-28 23:29:01 +0000
@@ -70,17 +70,15 @@
 
 (defun hashcash-strip-quoted-names (addr)
   (setq addr (mail-strip-quoted-names addr))
-  (if (and addr (string-match "^[^+@]+\\(\\+[^@]*\\)@" addr))
-      (concat (subseq addr 0 (match-beginning 1)) (subseq addr (match-end 1)))
+  (if (and addr (string-match "\\`\\([^+@]+\\)\\+[^@]*\\(@.+\\)" addr))
+      (concat (match-string 1 addr) (match-string 2 addr))
     addr))
 
 (defun hashcash-payment-required (addr)
   "Return the hashcash payment value required for the given address."
   (let ((val (assoc addr hashcash-payment-alist)))
     (if val
-	(if (cddr val)
-	    (caddr val)
-	  (cadr val))
+	(or (nth 2 val) (nth 1 val))
       hashcash-default-payment)))
 
 (defun hashcash-payment-to (addr)
@@ -99,7 +97,7 @@
 	(set-buffer (get-buffer-create " *hashcash*"))
 	(erase-buffer)
 	(call-process hashcash-path nil t nil
-		      (concat "-b " (number-to-string val)) str)
+		      "-q" "-b" (number-to-string val) str)
 	(goto-char (point-min))
 	(buffer-substring (hashcash-point-at-bol) (hashcash-point-at-eol)))
     nil))
@@ -145,7 +143,7 @@
   "Verify a hashcash payment"
   (let ((key (if (< (hashcash-version token) 1.2)
 		 (cadr (split-string token ":"))
-		 (caddr (split-string token ":")))))
+		 (nth 2 (split-string token ":")))))
     (cond ((null resource)
 	   (let ((elt (assoc key hashcash-accept-resources)))
 	     (and elt (hashcash-check-payment token (car elt)
@@ -180,7 +178,7 @@
 	  (when (and hashcash-in-news ng)
 	    (setq addrlist (nconc addrlist (split-string ng ",[ \t\n]*")))))
 	(when addrlist
-	  (mapc #'hashcash-insert-payment addrlist)))))
+	  (mapcar #'hashcash-insert-payment addrlist)))))
   t)
 
 ;;;###autoload

             reply	other threads:[~2003-05-28 23:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-28 23:30 Katsumi Yamaoka [this message]
2003-05-29  1:34 ` Paul Foley

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=b9yd6i2odi3.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=ding@gnus.org \
    /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).