(mime-library-product): update.
[elisp/flim.git] / mel-g.el
index 8f25b53..8be016c 100644 (file)
--- a/mel-g.el
+++ b/mel-g.el
@@ -1,13 +1,12 @@
 ;;; mel-g.el: Gzip64 encoder/decoder for GNU Emacs
 
-;; Copyright (C) 1995,1996,1997 MORIOKA Tomohiko
+;; Copyright (C) 1995,1996,1997,1998 MORIOKA Tomohiko
 ;; Copyright (C) 1996,1997 Shuhei KOBAYASHI
 
 ;; Author: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
 ;;     modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
 ;; Maintainer: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
 ;; Created: 1995/10/25
-;; Version: $Id: mel-g.el,v 6.2 1997/09/20 15:09:36 shuhei-k Exp $
 ;; Keywords: Gzip64, base64, gzip, MIME
 
 ;; This file is part of MEL (MIME Encoding Library).
@@ -34,8 +33,9 @@
 
 ;;; Code:
 
-(require 'emu)
-(require 'file-detect)
+(require 'poem)
+(require 'path-util)
+(require 'mel)
 
 
 ;;; @ variables
                       )
     ))
 
-(defalias 'gzip64-encode-region 'gzip64-external-encode-region)
-(defalias 'gzip64-decode-region 'gzip64-external-decode-region)
+(mel-define-method-function (mime-encode-region start end (nil "x-gzip64"))
+                           'gzip64-external-encode-region)
+(mel-define-method-function (mime-decode-region start end (nil "x-gzip64"))
+                           'gzip64-external-decode-region)
+
+
+;;; @ encoder/decoder for string
+;;;
+
+(mel-define-method mime-encode-string (string (nil "x-gzip64"))
+  (with-temp-buffer
+    (insert string)
+    (gzip64-external-encode-region (point-min)(point-max))
+    (buffer-string)))
+
+(mel-define-method mime-decode-string (string (nil "x-gzip64"))
+  (with-temp-buffer
+    (insert string)
+    (gzip64-external-decode-region (point-min)(point-max))
+    (buffer-string)))
 
 
 ;;; @ encoder/decoder for file
 ;;;
 
-(defun gzip64-insert-encoded-file (filename)
+(mel-define-method mime-insert-encoded-file (filename (nil "x-gzip64"))
   (interactive (list (read-file-name "Insert encoded file: ")))
   (apply (function call-process) (car gzip64-external-encoder)
         filename t nil
         (cdr gzip64-external-encoder))
   )
 
+(mel-define-method mime-write-decoded-region (start end filename
+                                                   (nil "x-gzip64"))
+  "Decode and write current region encoded by gzip64 into FILENAME.
+START and END are buffer positions."
+  (interactive
+   (list (region-beginning) (region-end)
+        (read-file-name "Write decoded region to file: ")))
+  (as-binary-process
+   (apply (function call-process-region)
+         start end (car gzip64-external-decoder)
+         nil nil nil
+         (let ((args (cdr gzip64-external-decoder)))
+           (append (butlast args)
+                   (list (concat (car (last args)) ">" filename))))
+         )))
+
 
 ;;; @ end
 ;;;