From: shuhei-k Date: Sat, 22 May 1999 16:52:11 +0000 (+0000) Subject: Update header. X-Git-Tag: flim-1_12_7~27 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=caa3a05356aa98b51a19be54c3255c0beeff01e9;p=elisp%2Fflim.git Update header. Don't require 'poe; it is required implicitly via 'mime-def. (base64-dl-handle): Chech whether `base64-dl-module' is string. Defalias `base64-encode-string' and `base64-decode-string' just after `dynamic-call'ing "emacs_base64_init". (base64-encode-region): Use read-only `interactive' spec. Use `base64-encode-string'. Changed order of evaluation to "encode, delete, then insert". (base64-decode-region): Renamed from `decode-base64-region'. Use read-only `interactive' spec. Use `base64-decode-string'. Changed order of evaluation to "decode, delete, then insert". (mime-encode-string): Use `base64-encode-string'. (mime-decode-string): Use `base64-decode-string'. (mime-decode-region): Use `base64-decode-region'. (encoded-text-encode-string): Use `base64-encode-string'. (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'". (mime-insert-encoded-file): Use built-in `interactive' spec. (mime-write-decoded-region in comment): Ditto. --- diff --git a/mel-b-dl.el b/mel-b-dl.el index 411fa74..a6896fd 100644 --- a/mel-b-dl.el +++ b/mel-b-dl.el @@ -1,11 +1,11 @@ -;;; mel-b-dl.el: Base64 encoder/decoder using DL module +;;; mel-b-dl.el --- Base64 encoder/decoder using DL module. ;; Copyright (C) 1998 Free Software Foundation, Inc. ;; Author: MORIOKA Tomohiko ;; Keywords: MIME, Base64 -;; This file is part of MEL (MIME Encoding Library). +;; This file is part of FLIM (Faithful Library about Internet Message). ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as @@ -18,65 +18,65 @@ ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to the +;; along with this program; see the file COPYING. If not, write to the ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Code: -(require 'poe) (require 'mime-def) (eval-and-compile (defvar base64-dl-handle - (and (file-exists-p base64-dl-module) + (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) +(defalias 'base64-decode-string 'decode-base64-string) + (defun base64-encode-region (start end) "Encode current region by base64. START and END are buffer positions." - (interactive "r") - (let ((str (buffer-substring start end))) - (delete-region start end) - (insert (encode-base64-string str)) - ) - (or (bolp) - (insert "\n")) - ) - -(defun decode-base64-region (start end) + (interactive "*r") + (insert + (prog1 + (base64-encode-string + (buffer-substring start end)) + (delete-region start end))) + (or (bolp) (insert ?\n))) + +(defun base64-decode-region (start end) "Decode current region by base64. START and END are buffer positions." - (interactive "r") - (let ((str (buffer-substring start end))) - (delete-region start end) - (condition-case err - (insert (decode-base64-string str)) - (error (message (nth 1 err))) - ))) - -(defalias 'base64-encode-string 'encode-base64-string) -(defalias 'base64-decode-string 'decode-base64-string) + (interactive "*r") + (insert + (prog1 + (base64-decode-string + (buffer-substring start end)) + (delete-region start end)))) (mel-define-method-function (mime-encode-string string (nil "base64")) - 'encode-base64-string) + 'base64-encode-string) (mel-define-method-function (mime-decode-string string (nil "base64")) - 'decode-base64-string) + 'base64-decode-string) (mel-define-method-function (mime-encode-region start end (nil "base64")) 'base64-encode-region) (mel-define-method-function (mime-decode-region start end (nil "base64")) - 'decode-base64-region) + 'base64-decode-region) (mel-define-method-function (encoded-text-encode-string string (nil "B")) - 'encode-base64-string) + 'base64-encode-string) (mel-define-method encoded-text-decode-string (string (nil "B")) - (if (and (string-match B-encoded-text-regexp string) - (string= string (match-string 0 string))) + (if (string-match (eval-when-compile + (concat "\\`" B-encoded-text-regexp "\\'")) + string) (decode-base64-string string) (error "Invalid encoded-text %s" string))) @@ -89,28 +89,23 @@ START and END are buffer positions." It calls external base64 encoder specified by `base64-external-encoder'. So you must install the program (maybe mmencode included in metamail or XEmacs package)." - (interactive (list (read-file-name "Insert encoded file: "))) - (insert (encode-base64-string + (interactive "*fInsert encoded file: ") + (insert (base64-encode-string (with-temp-buffer (set-buffer-multibyte nil) (insert-file-contents-as-binary filename) (buffer-string)))) - (or (bolp) - (insert "\n")) - ) + (or (bolp) (insert ?\n))) ;; (mel-define-method mime-write-decoded-region (start end filename ;; (nil "base64")) ;; "Decode and write current region encoded by base64 into FILENAME. ;; START and END are buffer positions." -;; (interactive -;; (list (region-beginning) (region-end) -;; (read-file-name "Write decoded region to file: "))) +;; (interactive "*r\nFWrite decoded region to file: ") ;; (let ((str (buffer-substring start end))) ;; (with-temp-buffer -;; (insert (decode-base64-string str)) -;; (write-region-as-binary (point-min) (point-max) filename) -;; ))) +;; (insert (base64-decode-string str)) +;; (write-region-as-binary (point-min)(point-max) filename)))) ;;; @ end