1 ;;; mel.el : a MIME encoding/decoding library
3 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; modified by Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
8 ;; Version: $Id: mel.el,v 6.11 1997/09/20 15:11:26 shuhei-k Exp $
9 ;; Keywords: MIME, Base64, Quoted-Printable, uuencode, gzip64
11 ;; This file is part of MEL (MIME Encoding Library).
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
18 ;; This program is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 ;; General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
33 (defvar mime-temp-directory (or (getenv "MIME_TMP_DIR")
36 "*Directory for temporary files.")
42 (autoload 'base64-encode-region
43 "mel-b" "Encode current region by base64." t)
44 (autoload 'quoted-printable-encode-region
45 "mel-q" "Encode current region by Quoted-Printable." t)
46 (autoload 'uuencode-encode-region
47 "mel-u" "Encode current region by unofficial uuencode format." t)
48 (autoload 'gzip64-encode-region
49 "mel-g" "Encode current region by unofficial x-gzip64 format." t)
51 (defvar mime-encoding-method-alist
52 '(("base64" . base64-encode-region)
53 ("quoted-printable" . quoted-printable-encode-region)
54 ;; Not standard, their use is DISCOURAGED.
55 ;; ("x-uue" . uuencode-encode-region)
56 ;; ("x-gzip64" . gzip64-encode-region)
61 "Alist of encoding vs. corresponding method to encode region.
62 Each element looks like (STRING . FUNCTION) or (STRING . nil).
63 STRING is content-transfer-encoding.
64 FUNCTION is region encoder and nil means not to encode.")
67 (autoload 'base64-decode-region
68 "mel-b" "Decode current region by base64." t)
69 (autoload 'quoted-printable-decode-region
70 "mel-q" "Decode current region by Quoted-Printable." t)
71 (autoload 'uuencode-decode-region
72 "mel-u" "Decode current region by unofficial uuencode format." t)
73 (autoload 'gzip64-decode-region
74 "mel-g" "Decode current region by unofficial x-gzip64 format." t)
76 (defvar mime-decoding-method-alist
77 '(("base64" . base64-decode-region)
78 ("quoted-printable" . quoted-printable-decode-region)
79 ("x-uue" . uuencode-decode-region)
80 ("x-uuencode" . uuencode-decode-region)
81 ("x-gzip64" . gzip64-decode-region)
83 "Alist of encoding vs. corresponding method to decode region.
84 Each element looks like (STRING . FUNCTION).
85 STRING is content-transfer-encoding.
86 FUNCTION is region decoder.")
90 (defun mime-encode-region (start end encoding)
91 "Encode region START to END of current buffer using ENCODING."
93 (list (region-beginning) (region-end)
94 (completing-read "encoding: "
95 mime-encoding-method-alist
98 (let ((f (cdr (assoc encoding mime-encoding-method-alist))))
100 (funcall f start end)
104 (defun mime-decode-region (start end encoding)
105 "Decode region START to END of current buffer using ENCODING."
107 (list (region-beginning) (region-end)
108 (completing-read "encoding: "
109 mime-decoding-method-alist
112 (let ((f (cdr (assoc encoding mime-decoding-method-alist))))
114 (funcall f start end)
121 (autoload 'base64-insert-encoded-file "mel-b"
122 "Encode contents of file to base64, and insert the result." t)
123 (autoload 'quoted-printable-insert-encoded-file "mel-q"
124 "Encode contents of file to quoted-printable, and insert the result." t)
125 (autoload 'uuencode-insert-encoded-file
126 "mel-u" "Insert file encoded by unofficial uuencode format." t)
127 (autoload 'gzip64-insert-encoded-file
128 "mel-g" "Insert file encoded by unofficial gzip64 format." t)
130 (defvar mime-file-encoding-method-alist
131 '(("base64" . base64-insert-encoded-file)
132 ("quoted-printable" . quoted-printable-insert-encoded-file)
133 ;; Not standard, their use is DISCOURAGED.
134 ;; ("x-uue" . uuencode-insert-encoded-file)
135 ;; ("x-gzip64" . gzip64-insert-encoded-file)
136 ("7bit" . insert-binary-file-contents-literally)
137 ("8bit" . insert-binary-file-contents-literally)
138 ("binary" . insert-binary-file-contents-literally)
140 "Alist of encoding vs. corresponding method to insert encoded file.
141 Each element looks like (STRING . FUNCTION).
142 STRING is content-transfer-encoding.
143 FUNCTION is function to insert encoded file.")
146 (defun mime-insert-encoded-file (filename encoding)
147 "Insert file FILENAME encoded by ENCODING format."
149 (list (read-file-name "Insert encoded file: ")
150 (completing-read "encoding: "
151 mime-encoding-method-alist
154 (let ((f (cdr (assoc encoding mime-file-encoding-method-alist))))
163 (autoload 'base64-encode-string "mel-b"
164 "Encode STRING to base64, and return the result.")
165 (autoload 'base64-decode-string "mel-b"
166 "Decode STRING which is encoded in base64, and return the result.")
167 (autoload 'quoted-printable-encode-string "mel-q"
168 "Encode STRING to quoted-printable, and return the result.")
169 (autoload 'quoted-printable-decode-string "mel-q"
170 "Decode STRING which is encoded in quoted-printable, and return the result.")
172 (autoload 'q-encoding-encode-string "mel-q"
173 "Encode STRING to Q-encoding of encoded-word, and return the result.")
174 (autoload 'q-encoding-decode-string "mel-q"
175 "Decode STRING which is encoded in Q-encoding and return the result.")
177 (autoload 'base64-encoded-length "mel-b")
178 (autoload 'q-encoding-encoded-length "mel-q")
186 ;;; mel.el ends here.