Merge from flim-1_14-rfc2231 flim-1_14-ueno-1
authorshuhei <shuhei>
Mon, 19 Mar 2001 13:35:28 +0000 (13:35 +0000)
committershuhei <shuhei>
Mon, 19 Mar 2001 13:35:28 +0000 (13:35 +0000)
ChangeLog
hmac-md5.el
hmac-sha1.el
md5-dl.el
md5.el
mel-b-dl.el
sha1-dl.el
sha1.el

index 91d5119..5695305 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,49 @@
+2001-03-19  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+       * hmac-md5.el, hmac-sha1.el: Revert to load-time check.
+       Don't require 'poe.
+
+2001-03-18  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+       * mel-b-dl.el: Don't do `dynamic-call' at compile-time.
+       (base64-dl-handle): Don't eval at compile-time.
+
+2001-03-18  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+       * hmac-md5.el, sha1.el: Update Copyright header.
+
+2001-03-18  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+       Support for built-in `md5' of Emacs 21.
+
+       * md5.el (md5-dl-module): Moved from md5-dl.el.
+       Use it for test whether to require 'md5-dl.
+
+       * md5-dl.el: Removed hack for compiler.
+       (md5-dl-handle): Do `dynamic-link' unconditionally.
+       (md5-region): Not interactive.
+       (md5): Removed autoload cookie.
+
+       * sha1.el: Removed hack for compiler.
+       Use `sha1-dl-module' for test whether to require 'sha1-dl.
+       (sha1-encode, sha1-encode-binary): Removed compatibility code
+       for another sha1.el since it was broken.
+
+       * sha1-dl.el: Removed hack for compiler.
+       (sha1-dl-handle): Do `dynamic-link' unconditionally.
+
+2001-03-18  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
+
+       * hmac-md5.el: Require 'poe.
+       Provide 'md5 if built-in `md5' is found.
+       (md5-binary): Define with `defun-maybe-cond'.
+       (md5-binary) [v21]: Removed extra arguments.
+       (hmac-md5-96): New function.
+
+       * hmac-sha1.el: Require 'poe.
+       (sha1-binary): Define with `defun-maybe'.
+       (hmac-sha1-96): New function.
+
 2001-03-11  Shuhei KOBAYASHI  <shuhei@aqua.ocn.ne.jp>
 
        * mel-g.el: Update Copyright header.
index 946d1b1..d003b50 100644 (file)
@@ -3,8 +3,6 @@
 ;; Copyright (C) 1999, 2001  Free Software Foundation, Inc.
 
 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
-;;     Kenichi OKADA <okada@opaopa.org>
-;; Maintainer: Kenichi OKADA <okada@opaopa.org>
 ;; Keywords: HMAC, RFC 2104, HMAC-MD5, MD5, KEYED-MD5, CRAM-MD5
 
 ;; This file is part of FLIM (Faithful Library about Internet Message).
 
 (eval-when-compile (require 'hmac-def))
 (require 'hex-util)                    ; (decode-hex-string STRING)
+;; Kludge for Emacs pretest 21.0.90 - 21.0.100 !!!
+;; they have `md5' as a built-in function but do not provide 'md5.
+(eval-and-compile
+  (if (and (fboundp 'md5)
+          (subrp (symbol-function 'md5)))
+      (provide 'md5)))
 (require 'md5)                         ; expects (md5 STRING)
 
-;; We cannot define this function in md5.el because recent XEmacs provides
-;; built-in md5 function and provides feature 'md5 at startup.
-(if (and (featurep 'xemacs)
-        (fboundp 'md5)
-        (subrp (symbol-function 'md5))
-        (condition-case nil
-            ;; `md5' of XEmacs 21 takes 4th arg CODING (and 5th arg NOERROR).
-            (md5 "" nil nil 'binary)   ; => "fb5d2156096fa1f254352f3cc3fada7e"
-          (error nil)))
-    ;; XEmacs 21.
-    (defun md5-binary (string &optional start end)
-      "Return the MD5 of STRING in binary form."
-      (decode-hex-string (md5 string start end 'binary)))
-  ;; not XEmacs 21 and not DL.
-  (if (not (fboundp 'md5-binary))
-      (defun md5-binary (string)
-       "Return the MD5 of STRING in binary form."
-       (decode-hex-string (md5 string)))))
+;; To share *.elc files between Emacs w/ and w/o DL patch,
+;; this check must be done at load-time.
+(cond
+ ((fboundp 'md5-binary)
+  ;; do nothing.
+  )
+ ((condition-case nil
+       ;; `md5' of v21 takes 4th arg CODING (and 5th arg NOERROR).
+       (md5 "" nil nil 'binary)                ; => "d41d8cd98f00b204e9800998ecf8427e"
+     (wrong-number-of-arguments nil))
+  (defun md5-binary (string)
+    "Return the MD5 of STRING in binary form."
+   (decode-hex-string (md5 string nil nil 'binary))))
+ (t
+  (defun md5-binary (string)
+    "Return the MD5 of STRING in binary form."
+   (decode-hex-string (md5 string)))))
 
 (define-hmac-function hmac-md5 md5-binary 64 16) ; => (hmac-md5 TEXT KEY)
-;; (define-hmac-function hmac-md5-96 md5-binary 64 16 96)
+(define-hmac-function hmac-md5-96 md5-binary 64 16 96)
 
 (provide 'hmac-md5)
 
index ab4f109..70b665f 100644 (file)
 (require 'hex-util)                    ; (decode-hex-string STRING)
 (require 'sha1)                                ; expects (sha1 STRING)
 
-;;; For consintency with hmac-md5.el, we define this function here.
-(or (fboundp 'sha1-binary)
-    (defun sha1-binary (string)
-      "Return the SHA1 of STRING in binary form."
-      (decode-hex-string (sha1 string))))
+;; To share *.elc files between Emacs w/ and w/o DL patch,
+;; this check must be done at load-time.
+(cond
+ ((fboundp 'sha1-binary)
+  ;; do nothing.
+  )
+ (t
+  (defun sha1-binary (string)
+    "Return the SHA1 of STRING in binary form."
+    (decode-hex-string (sha1 string)))))
 
 (define-hmac-function hmac-sha1 sha1-binary 64 20) ; => (hmac-sha1 TEXT KEY)
-;; (define-hmac-function hmac-sha1-96 sha1-binary 64 20 96)
+(define-hmac-function hmac-sha1-96 sha1-binary 64 20 96)
 
 (provide 'hmac-sha1)
 
index 8473ee2..bcbf897 100644 (file)
--- a/md5-dl.el
+++ b/md5-dl.el
 
 ;;; Code:
 
-(eval-when-compile
-  (defun-maybe md5-string (a))
-  (defun-maybe dynamic-link (a))
-  (defun-maybe dynamic-call (a b)))
+(provide 'md5-dl)                      ; beware of circular dependency.
+(eval-when-compile (require 'md5))     ; md5-dl-module.
 
-(defvar md5-dl-module
-  (if (and (fboundp 'md5-string)
-          (subrp (symbol-function 'md5-string)))
-      nil
-    (if (fboundp 'dynamic-link)
-       (let ((path (expand-file-name "md5.so" exec-directory)))
-         (and (file-exists-p path)
-              path)))))
-
-(defvar md5-dl-handle
-  (and (stringp md5-dl-module)
-       (file-exists-p md5-dl-module)
-       (dynamic-link md5-dl-module)))
+;;; This file is loaded (from "md5.el") only when md5-dl-module is exists.
+(defvar md5-dl-handle (dynamic-link md5-dl-module))
 
 ;;; md5-dl-module provides `md5-string'.
 (dynamic-call "emacs_md5_init" md5-dl-handle)
 
 (defun md5-region (beg end)
-  (interactive "r")
   (md5-string (buffer-substring-no-properties beg end)))
 
-;;; Note that XEmacs built-in version takes two more args: CODING and NOERROR.
-;;;###autoload
+;;; Note that v21 `md5' takes two more args: CODING and NOERROR.
 (defun md5 (object &optional beg end)
   "Return the MD5 (a secure message digest algorithm) of an object.
 OBJECT is either a string or a buffer.
diff --git a/md5.el b/md5.el
index 168236e..8c4d7c0 100644 (file)
--- a/md5.el
+++ b/md5.el
 
 ;;; Code:
 
+(defvar md5-dl-module
+  (cond
+   ((and (fboundp 'md5)
+        (subrp (symbol-function 'md5)))
+    nil)
+   ((fboundp 'dynamic-link)
+    ;; Should we take care of `dynamic-link-path'?
+    (let ((path (expand-file-name "md5.so" exec-directory)))
+      (if (file-exists-p path)
+         path
+       nil)))
+   (t
+    nil)))
+
 (cond
  ((and (fboundp 'md5)
        (subrp (symbol-function 'md5)))
-  ;; recent XEmacs has `md5' as a built-in function.
-  ;; (and 'md5 is already provided.)
+  ;; do nothing.
   )
- ((and (fboundp 'dynamic-link)
-       (file-exists-p (expand-file-name "md5.so" exec-directory)))
-  ;; Emacs with DL patch.
+ ((and (stringp md5-dl-module)
+       (file-exists-p md5-dl-module))
   (require 'md5-dl))
  (t
   (require 'md5-el)))
index 47b1b81..c298b14 100644 (file)
 
 (require 'mime-def)
 
-(eval-and-compile
-  (defvar base64-dl-handle
-    (and (stringp base64-dl-module)
-        (file-exists-p base64-dl-module)
-        (dynamic-link base64-dl-module)))
-
-  (dynamic-call "emacs_base64_init" base64-dl-handle)
-  )
+(defvar base64-dl-handle
+  (and (stringp base64-dl-module)
+       (file-exists-p base64-dl-module)
+       (dynamic-link base64-dl-module)))
+
+(dynamic-call "emacs_base64_init" base64-dl-handle)
 
 ;; base64-dl-module provides `encode-base64-string' and `decode-base64-string'.
 (defalias 'base64-encode-string 'encode-base64-string)
index b60969a..4716d4d 100644 (file)
 ;;; Code:
 
 (provide 'sha1-dl)                     ; beware of circular dependency.
-(eval-when-compile
-  (require 'sha1)                      ; sha1-dl-module.
-  (defun-maybe dynamic-link (a))
-  (defun-maybe dynamic-call (a b)))
-
-(defvar sha1-dl-handle
-  (and (stringp sha1-dl-module)
-       (file-exists-p sha1-dl-module)
-       (dynamic-link sha1-dl-module)))
+(eval-when-compile (require 'sha1))    ; sha1-dl-module.
+
+;;; This file is loaded (from "sha1.el") only when sha1-dl-module exists.
+(defvar sha1-dl-handle (dynamic-link sha1-dl-module))
 
 ;;; sha1-dl-module provides `sha1-string' and `sha1-binary'.
 (dynamic-call "emacs_sha1_init" sha1-dl-handle)
diff --git a/sha1.el b/sha1.el
index 0e3b7ac..a9e5e9d 100644 (file)
--- a/sha1.el
+++ b/sha1.el
@@ -3,8 +3,6 @@
 ;; Copyright (C) 1999, 2001  Free Software Foundation, Inc.
 
 ;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
-;;     Kenichi OKADA <okada@opaopa.org>
-;; Maintainer: Kenichi OKADA <okada@opaopa.org>
 ;; Keywords: SHA1, FIPS 180-1
 
 ;; This file is part of FLIM (Faithful Library about Internet Message).
 
 ;;; Code:
 
-(require 'hex-util)
-
-(eval-when-compile
-  (or (fboundp 'sha1-string)
-      (defun sha1-string (a))))
-
 (defvar sha1-dl-module
-  (if (and (fboundp 'sha1-string)
-          (subrp (symbol-function 'sha1-string)))
-      nil
-    (if (fboundp 'dynamic-link)
-       (let ((path (expand-file-name "sha1.so" exec-directory)))
-         (and (file-exists-p path)
-              path)))))
+  (cond
+   ((and (fboundp 'sha1)
+        (subrp (symbol-function 'sha1)))
+    nil)
+   ((fboundp 'dynamic-link)
+    ;; Should we take care of `dynamic-link-path'?
+    (let ((path (expand-file-name "sha1.so" exec-directory)))
+      (if (file-exists-p path)
+         path
+       nil)))
+   (t
+    nil)))
 
 (cond
- (sha1-dl-module
-  ;; Emacs with DL patch.
+ ((and (stringp sha1-dl-module)
+       (file-exists-p sha1-dl-module))
   (require 'sha1-dl))
  (t
   (require 'sha1-el)))
 
-;; compatibility for another sha1.el by Keiichi Suzuki.
-(defun sha1-encode (string)
-  (decode-hex-string 
-   (sha1-string string)))
-(defun sha1-encode-binary (string)
-  (decode-hex-string
-   (sha1-string string)))
-
-(make-obsolete 'sha1-encode "It's old API.")
-(make-obsolete 'sha1-encode-binary "It's old API.")
-
 (provide 'sha1)
 
 ;;; sha1.el ends here