From: morioka Date: Sat, 20 Jun 1998 19:52:15 +0000 (+0000) Subject: (base64-external-decode-string): New function. X-Git-Tag: flim-1_5_0~19 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=1045e761288ce89079ee5b3826a30e93af350d11;p=elisp%2Fflim.git (base64-external-decode-string): New function. (base64-decode-string): New function. --- diff --git a/mel-b.el b/mel-b.el index dd59d7e..287cd0a 100644 --- a/mel-b.el +++ b/mel-b.el @@ -150,7 +150,6 @@ external decoder is called.") ))) (defun base64-internal-decode-string (string) - "Decode STRING which is encoded in base64, and return the result." (let ((len (length string)) (i 0) dest) @@ -188,8 +187,6 @@ external decoder is called.") )))))))))) dest)) -(defalias 'base64-decode-string 'base64-internal-decode-string) - ;;; @ base64 encoder/decoder for region ;;; @@ -237,6 +234,16 @@ external decoder is called.") t t nil (cdr base64-external-decoder)) ))) +(defun base64-external-decode-string (string) + (with-temp-buffer + (insert string) + (as-binary-process (apply (function call-process-region) + beg end (car base64-external-decoder) + t t nil (cdr base64-external-decoder)) + ) + (buffer-string))) + + (defun base64-encode-region (start end) "Encode current region by base64. START and END are buffer positions. @@ -267,6 +274,20 @@ metamail or XEmacs package)." (base64-internal-decode-region start end) )) +(defun base64-decode-string (string) + "Decode STRING which is encoded in base64, and return the result. +This function calls internal base64 decoder if size of STRING is +smaller than `base64-internal-decoding-limit', otherwise it calls +external base64 decoder specified by `base64-external-decoder'. In +this case, you must install the program (maybe mmencode included in +metamail or XEmacs package)." + (interactive "r") + (if (and base64-internal-decoding-limit + (> (length string) base64-internal-decoding-limit)) + (base64-external-decode-string string) + (base64-internal-decode-string string) + )) + ;;; @ base64 encoder/decoder for file ;;;