Synch to No Gnus 200503230048.
[elisp/gnus.git-] / lisp / hashcash.el
index c0a799d..8172590 100644 (file)
@@ -1,8 +1,8 @@
 ;;; hashcash.el --- Add hashcash payments to email
 
-;; Copyright (C) 2003, 2004 Free Software Foundation
-;; Copyright (C) 1997--2002 Paul E. Foley
+;; Copyright (C) 2003, 2004, 2005 Free Software Foundation
 
+;; Written by: Paul Foley <mycroft@actrix.gen.nz> (1997-2002)
 ;; Maintainer: Paul Foley <mycroft@actrix.gen.nz>
 ;; Keywords: mail, hashcash
 
@@ -63,7 +63,14 @@ See `hashcash-payment-alist'."
 Elements may consist of (ADDR AMOUNT) or (ADDR STRING AMOUNT), where
 ADDR is the email address of the intended recipient and AMOUNT is
 the value of hashcash payment to be made to that user.  STRING, if
-present, is the string to be hashed; if not present ADDR will be used.")
+present, is the string to be hashed; if not present ADDR will be used."
+  :type '(repeat (choice (list :tag "Normal"
+                              (string :name "Address")
+                              (integer :name "Amount"))
+                        (list :tag "Replace hash input"
+                              (string :name "Address")
+                              (string :name "Hash input")
+                              (integer :name "Amount")))))
 
 (defcustom hashcash-default-accept-payment 20
   "*The default minimum number of bits to accept on incoming payments."
@@ -78,6 +85,11 @@ is used instead.")
 (defcustom hashcash-path (executable-find "hashcash")
   "*The path to the hashcash binary.")
 
+(defcustom hashcash-extra-generate-parameters nil
+  "*A list of parameter strings passed to `hashcash-path' when minting.
+For example, you may want to set this to '(\"-Z2\") to reduce header length."
+  :type '(repeat string))
+
 (defcustom hashcash-double-spend-database "hashcash.db"
   "*The path to the double-spending database.")
 
@@ -133,8 +145,9 @@ is used instead.")
       (save-excursion
        (set-buffer (get-buffer-create " *hashcash*"))
        (erase-buffer)
-       (call-process hashcash-path nil t nil
-                     "-m" "-q" "-b" (number-to-string val) str)
+       (apply 'call-process hashcash-path nil t nil
+              "-m" "-q" "-b" (number-to-string val) str
+              hashcash-extra-generate-parameters)
        (goto-char (point-min))
        (hashcash-token-substring))
     (error "No `hashcash' binary found")))
@@ -143,8 +156,10 @@ is used instead.")
   "Generate a hashcash payment by finding a VAL-bit collison on STR.
 Return immediately.  Call CALLBACK with process and result when ready."
   (if (> val 0)
-      (let ((process (start-process "hashcash" nil
-                                   hashcash-path "-m" "-q" "-b" (number-to-string val) str)))
+      (let ((process (apply 'start-process "hashcash" nil
+                           hashcash-path "-m" "-q"
+                           "-b" (number-to-string val) str
+                           hashcash-extra-generate-parameters)))
        (setq hashcash-process-alist (cons
                                      (cons process (current-buffer))
                                      hashcash-process-alist))