4
|
1 ;;;
|
|
2 ;;; mel-g.el: Gzip64 encoder/decoder for GNU Emacs
|
|
3 ;;;
|
|
4 ;;; Copyright (C) 1995,1996 MORIOKA Tomohiko
|
|
5 ;;; Copyright (C) 1996 Shuhei KOBAYASHI
|
|
6 ;;;
|
|
7 ;;; Author: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
|
|
8 ;;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
|
9 ;;; Maintainer: Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
|
|
10 ;;; Created: 1995/10/25
|
|
11 ;;; Version:
|
|
12 ;;; $Id: mel-g.el,v 1.1.1.1 1996/12/18 03:55:30 steve Exp $
|
|
13 ;;; Keywords: MIME, base64, gzip
|
|
14 ;;;
|
|
15 ;;; This file is not part of MEL (MIME Encoding Library) yet.
|
|
16 ;;;
|
|
17 ;;; This program is free software; you can redistribute it and/or
|
|
18 ;;; modify it under the terms of the GNU General Public License as
|
|
19 ;;; published by the Free Software Foundation; either version 2, or
|
|
20 ;;; (at your option) any later version.
|
|
21 ;;;
|
|
22 ;;; This program is distributed in the hope that it will be useful,
|
|
23 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
25 ;;; General Public License for more details.
|
|
26 ;;;
|
|
27 ;;; You should have received a copy of the GNU General Public License
|
|
28 ;;; along with This program. If not, write to the Free Software
|
|
29 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
30 ;;;
|
|
31 ;;; Code:
|
|
32
|
|
33 (require 'emu)
|
|
34
|
|
35
|
|
36 ;;; @ variables
|
|
37 ;;;
|
|
38
|
|
39 (defvar gzip64-external-encoder '("sh" "-c" "gzip -c | mmencode")
|
|
40 "*list of gzip64 encoder program name and its arguments.")
|
|
41
|
|
42 (defvar gzip64-external-decoder '("sh" "-c" "mmencode -u | gzip -dc")
|
|
43 "*list of gzip64 decoder program name and its arguments.")
|
|
44
|
|
45
|
|
46 ;;; @ encoder/decoder for region
|
|
47 ;;;
|
|
48
|
|
49 (defun gzip64-external-encode-region (beg end)
|
|
50 (interactive "*r")
|
|
51 (save-excursion
|
|
52 (as-binary-process (apply (function call-process-region)
|
|
53 beg end (car gzip64-external-encoder)
|
|
54 t t nil (cdr gzip64-external-encoder))
|
|
55 )
|
|
56 ;; for OS/2
|
|
57 ;; regularize line break code
|
|
58 (goto-char (point-min))
|
|
59 (while (re-search-forward "\r$" nil t)
|
|
60 (replace-match "")
|
|
61 )
|
|
62 ))
|
|
63
|
|
64 (defun gzip64-external-decode-region (beg end)
|
|
65 (interactive "*r")
|
|
66 (save-excursion
|
|
67 (as-binary-process (apply (function call-process-region)
|
|
68 beg end (car gzip64-external-decoder)
|
|
69 t t nil (cdr gzip64-external-decoder))
|
|
70 )
|
|
71 ))
|
|
72
|
|
73 (defalias 'gzip64-encode-region 'gzip64-external-encode-region)
|
|
74 (defalias 'gzip64-decode-region 'gzip64-external-decode-region)
|
|
75
|
|
76
|
|
77 ;;; @ encoder/decoder for file
|
|
78 ;;;
|
|
79
|
|
80 (defun gzip64-insert-encoded-file (filename)
|
|
81 (interactive (list (read-file-name "Insert encoded file: ")))
|
|
82 (apply (function call-process) (car gzip64-external-encoder)
|
|
83 filename t nil
|
|
84 (cdr gzip64-external-encoder))
|
|
85 )
|
|
86
|
|
87
|
|
88 ;;; @ end
|
|
89 ;;;
|
|
90
|
|
91 (provide 'mel-g)
|
|
92
|
|
93 ;;; mel-g.el ends here.
|