X-Git-Url: http://cgit.sxemacs.org/?p=gnus;a=blobdiff_plain;f=lisp%2Fhashcash.el;h=70170654f67b51fd1d724222c7d767e0745c6fc6;hp=5c6a69e68640c5903b78f269a41368c833ad6cf8;hb=56e9a957bb3eba24fb6311f88d90583de4511102;hpb=477d2d1e18caaf92a73dbbcbfb1e87d3c104a10a diff --git a/lisp/hashcash.el b/lisp/hashcash.el index 5c6a69e68..70170654f 100644 --- a/lisp/hashcash.el +++ b/lisp/hashcash.el @@ -1,6 +1,6 @@ ;;; hashcash.el --- Add hashcash payments to email -;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation +;; Copyright (C) 2003-2005, 2007-2015 Free Software Foundation, Inc. ;; Written by: Paul Foley (1997-2002) ;; Maintainer: Paul Foley @@ -47,10 +47,6 @@ ;;; Code: -;; For Emacs <22.2 and XEmacs. -(eval-and-compile - (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) - (eval-when-compile (require 'cl)) ; for case (defgroup hashcash nil @@ -58,14 +54,14 @@ :group 'mail) (defcustom hashcash-default-payment 20 - "*The default number of bits to pay to unknown users. + "The default number of bits to pay to unknown users. If this is zero, no payment header will be generated. See `hashcash-payment-alist'." :type 'integer :group 'hashcash) (defcustom hashcash-payment-alist '() - "*An association list mapping email addresses to payment amounts. + "An association list mapping email addresses to payment amounts. 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 @@ -80,33 +76,38 @@ present, is the string to be hashed; if not present ADDR will be used." :group 'hashcash) (defcustom hashcash-default-accept-payment 20 - "*The default minimum number of bits to accept on incoming payments." + "The default minimum number of bits to accept on incoming payments." :type 'integer :group 'hashcash) (defcustom hashcash-accept-resources `((,user-mail-address nil)) - "*An association list mapping hashcash resources to payment amounts. + "An association list mapping hashcash resources to payment amounts. Resources named here are to be accepted in incoming payments. If the corresponding AMOUNT is NIL, the value of `hashcash-default-accept-payment' is used instead." + :type 'alist :group 'hashcash) -(defcustom hashcash-path (executable-find "hashcash") - "*The path to the hashcash binary." +(define-obsolete-variable-alias 'hashcash-path 'hashcash-program "24.4") +(defcustom hashcash-program "hashcash" + "The name of the hashcash executable. +If this is not in your PATH, specify an absolute file name." + :type '(choice (const nil) file) :group 'hashcash) (defcustom hashcash-extra-generate-parameters nil - "*A list of parameter strings passed to `hashcash-path' when minting. + "A list of parameter strings passed to `hashcash-program' when minting. For example, you may want to set this to '(\"-Z2\") to reduce header length." :type '(repeat string) :group 'hashcash) (defcustom hashcash-double-spend-database "hashcash.db" - "*The path to the double-spending database." + "The name of the double-spending database file." + :type 'file :group 'hashcash) (defcustom hashcash-in-news nil - "*Specifies whether or not hashcash payments should be made to newsgroups." + "Specifies whether or not hashcash payments should be made to newsgroups." :type 'boolean :group 'hashcash) @@ -159,10 +160,10 @@ For example, you may want to set this to '(\"-Z2\") to reduce header length." (defun hashcash-generate-payment (str val) "Generate a hashcash payment by finding a VAL-bit collison on STR." (if (and (> val 0) - hashcash-path) + hashcash-program) (with-current-buffer (get-buffer-create " *hashcash*") (erase-buffer) - (apply 'call-process hashcash-path nil t nil + (apply 'call-process hashcash-program nil t nil "-m" "-q" "-b" (number-to-string val) str hashcash-extra-generate-parameters) (goto-char (point-min)) @@ -173,9 +174,9 @@ For example, you may want to set this to '(\"-Z2\") to reduce header length." "Generate a hashcash payment by finding a VAL-bit collison on STR. Return immediately. Call CALLBACK with process and result when ready." (if (and (> val 0) - hashcash-path) + hashcash-program) (let ((process (apply 'start-process "hashcash" nil - hashcash-path "-m" "-q" + hashcash-program "-m" "-q" "-b" (number-to-string val) str hashcash-extra-generate-parameters))) (setq hashcash-process-alist (cons @@ -187,8 +188,8 @@ Return immediately. Call CALLBACK with process and result when ready." (defun hashcash-check-payment (token str val) "Check the validity of a hashcash payment." - (if hashcash-path - (zerop (call-process hashcash-path nil nil nil "-c" + (if hashcash-program + (zerop (call-process hashcash-program nil nil nil "-c" "-d" "-f" hashcash-double-spend-database "-b" (number-to-string val) "-r" str