1 ;;; mel-g.el: Gzip64 encoder/decoder for GNU Emacs
3 ;; Copyright (C) 1995,1996,1997,1998 MORIOKA Tomohiko
4 ;; Copyright (C) 1996,1997 Shuhei KOBAYASHI
6 ;; Author: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
7 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Maintainer: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
10 ;; Keywords: Gzip64, base64, gzip, MIME
12 ;; This file is part of MEL (MIME Encoding Library).
14 ;; This program is free software; you can redistribute it and/or
15 ;; modify it under the terms of the GNU General Public License as
16 ;; published by the Free Software Foundation; either version 2, or (at
17 ;; your option) any later version.
19 ;; This program is distributed in the hope that it will be useful, but
20 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 ;; General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
31 ;;; NOTE: Gzip64 is an experimental Content-Transfer-Encoding and its
32 ;;; use is STRONGLY DISCOURAGED except for private communication.
43 (defvar gzip64-external-encoder
44 (let ((file (exec-installed-p "mmencode")))
46 (` ("sh" "-c" (, (concat "gzip -c | " file))))
48 "*list of gzip64 encoder program name and its arguments.")
50 (defvar gzip64-external-decoder
51 (let ((file (exec-installed-p "mmencode")))
53 (` ("sh" "-c" (, (concat file " -u | gzip -dc"))))
55 "*list of gzip64 decoder program name and its arguments.")
58 ;;; @ encoder/decoder for region
61 (defun gzip64-external-encode-region (beg end)
64 (as-binary-process (apply (function call-process-region)
65 beg end (car gzip64-external-encoder)
66 t t nil (cdr gzip64-external-encoder))
69 ;; regularize line break code
70 (goto-char (point-min))
71 (while (re-search-forward "\r$" nil t)
76 (defun gzip64-external-decode-region (beg end)
79 (as-binary-process (apply (function call-process-region)
80 beg end (car gzip64-external-decoder)
81 t t nil (cdr gzip64-external-decoder))
85 (defalias 'gzip64-encode-region 'gzip64-external-encode-region)
86 (defalias 'gzip64-decode-region 'gzip64-external-decode-region)
89 ;;; @ encoder/decoder for file
92 (defun gzip64-insert-encoded-file (filename)
93 (interactive (list (read-file-name "Insert encoded file: ")))
94 (apply (function call-process) (car gzip64-external-encoder)
96 (cdr gzip64-external-encoder))
99 (defun gzip64-write-decoded-region (start end filename)
100 "Decode and write current region encoded by gzip64 into FILENAME.
101 START and END are buffer positions."
103 (list (region-beginning) (region-end)
104 (read-file-name "Write decoded region to file: ")))
106 (apply (function call-process-region)
107 start end (car gzip64-external-decoder)
109 (let ((args (cdr gzip64-external-decoder)))
110 (append (butlast args)
111 (list (concat (car (last args)) ">" filename))))
120 ;;; mel-g.el ends here.