* hashcash.el (hashcash-point-at-bol):
authorSimon Josefsson <jas@extundo.com>
Fri, 21 Feb 2003 13:01:06 +0000 (13:01 +0000)
committerSimon Josefsson <jas@extundo.com>
Fri, 21 Feb 2003 13:01:06 +0000 (13:01 +0000)
(hashcash-point-at-eol): Defalias.
(hashcash-generate-payment):
(mail-check-payment): Use it.

contrib/hashcash.el

index 7d8e787..d3a63d2 100644 (file)
@@ -1,6 +1,6 @@
 ;;; hashcash.el --- Add hashcash payments to email
 
-;; $Revision: 1.4 $
+;; $Revision: 1.6 $
 ;; Copyright (C) 1997,2001 Paul E. Foley
 
 ;; Maintainer: Paul Foley <mycroft@actrix.gen.nz>
@@ -55,6 +55,16 @@ is used instead.")
 
 (require 'mail-utils)
 
+(defalias 'hashcash-point-at-bol
+  (if (fboundp 'point-at-bol)
+      'point-at-bol
+    'line-beginning-position))
+
+(defalias 'hashcash-point-at-eol
+  (if (fboundp 'point-at-eol)
+      'point-at-eol
+    'line-end-position))
+
 (defun hashcash-strip-quoted-names (addr)
   (setq addr (mail-strip-quoted-names addr))
   (if (and addr (string-match "^[^+@]+\\(\\+[^@]*\\)@" addr))
@@ -88,7 +98,7 @@ is used instead.")
        (call-process hashcash nil t nil (concat "-b " (number-to-string val))
                      str)
        (goto-char (point-min))
-       (buffer-substring (point-at-bol) (point-at-eol)))
+       (buffer-substring (hashcash-point-at-bol) (hashcash-point-at-eol)))
     nil))
 
 (defun hashcash-check-payment (token str val)
@@ -166,11 +176,11 @@ Prefix arg sets default accept amount temporarily."
        (goto-char (point-min))
        (while (and (not ok) (search-forward "X-Payment: hashcash 1.1 " end t))
          (setq ok (hashcash-verify-payment
-                   (buffer-substring (point) (point-at-eol)))))
+                   (buffer-substring (point) (hashcash-point-at-eol)))))
        (goto-char (point-min))
        (while (and (not ok) (search-forward "X-Hashcash: " end t))
          (setq ok (hashcash-verify-payment
-                   (buffer-substring (point) (point-at-eol)))))
+                   (buffer-substring (point) (hashcash-point-at-eol)))))
        (when ok
          (message "Payment valid"))
        ok))))