1999-05-25 MORIOKA Tomohiko <tomo@m17n.org>
- * README.ja (install): Fixed
-
-1999-05-25 MORIOKA Tomohiko <tomo@m17n.org>
-
* mmbuffer.el (mime-entity-body-end-point): New method.
(mime-goto-header-start-point): New method.
(mime-goto-body-start-point): New method.
* mel.el (Q-encoded-text-length): Fixed.
-1999-05-25 Yoshiki Hayashi <g740685@komaba.ecc.u-tokyo.ac.jp>
-
- * README.ja: Sync up with the latest README.en of flim-1_12
- branch.
-
1999-05-24 MORIOKA Tomohiko <tomo@m17n.org>
* mmbuffer.el (mime-parse-multipart): Refer body-start instead of
* luna.el: New module.
\f
+1999-05-31 MORIOKA Tomohiko <tomo@m17n.org>
+
+ * FLIM: Version 1.12.7 (Y\e-Dþzaki)\e-A released.
+
+1999-05-31 MORIOKA Tomohiko <tomo@m17n.org>
+
+ * mime-en.sgml (Network representation of header): Translate.
+
+1999-05-27 Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
+
+ * mel-b-el.el (pack-sequence): Eliminate local variable `i'.
+ (base64-encode-1): Avoid concat.
+ (base64-encode-string): Fixed last change; extra padding.
+
+1999-05-26 MORIOKA Tomohiko <tomo@m17n.org>
+
+ * smtpmail.el (smtpmail-default-smtp-server): Define obsolete
+ variable alias for XEmacs.
+ (smtpmail-smtp-server): Likewise.
+ (smtpmail-smtp-service): Likewise.
+ (smtpmail-local-domain): Likewise.
+ (smtpmail-debug-info): Likewise.
+ (smtpmail-send-it): Check function `expand-mail-aliases' is
+ defined.
+
+1999-05-26 MORIOKA Tomohiko <tomo@m17n.org>
+
+ * smtp.el (smtp-debug-info): Now a user option.
+
+1999-05-25 Yoshiki Hayashi <g740685@komaba.ecc.u-tokyo.ac.jp>
+
+ * README.ja: Modify URL and required version of APEL.
+
+1999-05-24 Tanaka Akira <akr@jaist.ac.jp>
+
+ * mel-b-ccl.el (base64-encode-string): New alias.
+ (base64-encode-region): Ditto.
+ (base64-decode-string): Ditto.
+ (base64-decode-region): Ditto.
+
+1999-05-24 Tanaka Akira <akr@jaist.ac.jp>
+
+ * mel-b-ccl.el, mel-q-ccl.el: Sync up with doodle-1.12.5.
+
+1999-05-24 MORIOKA Tomohiko <tomo@m17n.org>
+
+ * eword-encode.el (ew-space-process): Renamed from
+ `tm-eword::space-process'.
+
+1999-05-24 MORIOKA Tomohiko <tomo@m17n.org>
+
+ * eword-encode.el (tm-eword::space-process): Don't concatenate
+ `special's.
+ (ew-encode-rword-1): Renamed from `tm-eword::encode-string-1'; add
+ new optional argument `must-output'; return nil if it can't encode
+ literally.
+ (eword-encode-rword-list): Fold SPACE or TAB in the encoded string
+ if `ew-encode-rword-1' can't encode literally and it is possible
+ to encode the rest literally with the folding.
+ (eword-encode-phrase-to-rword-list): Add `special' flag to
+ brackets of comments.
+
+1999-05-22 Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
+
+ * smtpmail.el: Require 'poe and 'pcustom.
+
+1999-05-22 Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
+
+ * mel.el: Update header.
+ Require 'path-util and don't require 'poem.
+ (mel-use-module): Eliminate local variable `encoding'.
+ (mime-insert-encoded-file for mel-b-builtin):
+ Use built-in `interactive' spec.
+ (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'".
+ (mime-encode-region): Capitalize prompt string.
+ (mime-decode-region): Ditto.
+ (mime-insert-encoded-file): Ditto.
+ (mime-write-decoded-region): Ditto.
+
+ * mel-b-ccl.el: Update header.
+ (base64-ccl-encode-region): Use read-only `interactive' spec.
+ (base64-ccl-decode-region): Ditto.
+ (base64-ccl-insert-encoded-file): Use built-in `interactive' spec.
+ (base64-ccl-write-decoded-region): Ditto.
+ (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'".
+
+ * mel-b-dl.el: 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.
+
+ * mel-b-el.el: Update header.
+ Don't require 'poe; it is required implicitly via 'mime-def.
+ (pack-sequence): Moved to top of the function definitions.
+ (base64-encode-string): Calculate padding first.
+ (base64-internal-encode-region): Changed order of evaluation to
+ "encode, delete, then insert".
+ (base64-internal-decode-string): Changed order of evaluation to
+ "decode, delete, then insert".
+ (base64-encode-region): Use read-only `interactive' spec.
+ (base64-decode-region): Ditto.
+ (base64-decode-string): Not interactive.
+ (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'".
+ (base64-insert-encoded-file): Use built-in `interactive' spec.
+ (base64-write-decoded-region): Ditto.
+
+ * mel-g.el: Update header.
+ Require 'mime-def instead of 'poem and 'mel.
+ (mime-insert-encoded-file): Use built-in `interactive' spec.
+ (mime-write-decoded-region): Ditto.
+
+ * mel-q-ccl.el: Update header.
+ (quoted-printable-ccl-encode-region):
+ Use read-only `interactive' spec.
+ (quoted-printable-ccl-decode-region): Ditto.
+ (quoted-printable-ccl-insert-encoded-file):
+ Use built-in `interactive' spec.
+ (quoted-printable-ccl-write-decoded-region): Ditto.
+ (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'".
+
+ * mel-q.el: Update header.
+ Require 'path-util instead of 'emu.
+ (quoted-printable-internal-encode-region): Rewrite without regexp.
+ (quoted-printable-internal-decode-region): Ditto.
+ (quoted-printable-encode-region): Use read-only `interactive' spec.
+ (quoted-printable-decode-region): Ditto.
+ (mime-insert-encoded-file): Use built-in `interactive' spec.
+ (mime-write-decoded-region): Ditto.
+ (encoded-text-decode-string): Anchor regexp with "\\`" and "\\'".
+
+ * mel-u.el: Update header.
+ Require 'path-util instead of 'emu.
+ (mime-insert-encoded-file): Use built-in `interactive' spec.
+ (mime-write-decoded-region): Ditto.
+
+1999-05-22 Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
+
+ * mime-def.el: Require 'poe, 'poem, and 'pcustom.
+ (mime): Declare `default-mime-charset' as an initial member.
+
+ * mime-parse.el: Don't require 'cl at compile-time.
+
+ * mailcap.el (mailcap-look-at-qchar): Use `char-after'.
+
+ * std11.el: Require 'poe, 'poem, and 'pcustom.
+
+ * smtp.el: Update header.
+ Require 'poe, 'poem, and 'pcustom.
+ Require 'cl at compile-time.
+
+1999-05-21 MORIOKA Tomohiko <tomo@m17n.org>
+
+ * README.en (Installation): Modify URL and required version of
+ APEL.
+
+ * eword-encode.el (ew-find-charset-rule): Renamed from
+ `tm-eword::find-charset-rule'; use
+ `find-mime-charset-by-charsets'.
+
+\f
1999-05-11 MORIOKA Tomohiko <tomo@m17n.org>
* FLIM: Version 1.12.6 (Family-K\e-Dòenmae)\e-A released.
# Makefile for FLIM.
#
-PACKAGE = flim
-API = 1.12
-RELEASE = 6
+PACKAGE = chao
+API = 1.13
+RELEASE = 0
TAR = tar
RM = /bin/rm -f
Installation
============
-(0) before installing it, please install APEL (9.12 or later) package.
+(0) before installing it, please install APEL (9.19 or later) package.
APEL package is available at:
- ftp://ftp.jaist.ac.jp/pub/GNU/elisp/apel/
+ ftp://ftp.etl.go.jp/pub/mule/apel/
(1-a) run in expanded place
\e$BF3F~\e(B (install)
==============
-(0) \e$BF3F~\e(B (install) \e$B$9$kA0$K!"\e(BAPEL (9.12 \e$B0J9_\e(B) \e$B$rF3F~$7$F$/$@$5$$!#\e(BAPEL
+(0) \e$BF3F~\e(B (install) \e$B$9$kA0$K!"\e(BAPEL (9.19 \e$B0J9_\e(B) \e$B$rF3F~$7$F$/$@$5$$!#\e(BAPEL
\e$B$O0J2<$N$H$3$m$G<hF@$G$-$^$9\e(B:
ftp://ftp.etl.go.jp/pub/mule/apel/
1.12.4 Tsutsui \e$(BE{0f\e(B
1.12.5 Hirahata \e$(BJ?C<\e(B ; = \e$(B6aE4\e(B \e$(BE7M}@~\e(B
1.12.6 Family-K\e-Dòenmae\e-A \e$(B%U%!%_%j!<8x1`A0\e(B
------- Y\e-Dþzaki\e-A \e$(B7k:j\e(B
+1.12.7 Y\e-Dþzaki\e-A \e$(B7k:j\e(B
------ Iwami \e$(B@P8+\e(B
------ Tawaramoto \e$(BED86K\\e(B ; <=> \e$(B6aE4\e(B \e$(B@>ED86K\\e(B
------ Kasanui \e$(B3^K%\e(B
;;; Code:
-(require 'std11)
-(require 'mel)
(require 'mime-def)
+(require 'mel)
+(require 'std11)
-(eval-when-compile (require 'cl))
+(eval-when-compile (require 'cl)) ; list*, pop
(defgroup eword-decode nil
"Encoded-word decoding"
;;; Code:
-(require 'poem)
+(require 'mime-def)
(require 'mel)
(require 'std11)
-(require 'mime-def)
(require 'eword-decode)
(defmacro ew-rword-type (rword)
(` (car (cdr (cdr (cdr (, rword)))))))
-(defun tm-eword::find-charset-rule (charsets)
+(defun ew-find-charset-rule (charsets)
(if charsets
- (let* ((charset (charsets-to-mime-charset charsets))
- (encoding (cdr (assq charset eword-charset-encoding-alist)))
- )
+ (let* ((charset (find-mime-charset-by-charsets charsets))
+ (encoding (cdr (or (assq charset eword-charset-encoding-alist)
+ '(nil . "Q")))))
(list charset encoding)
)))
(defun tm-eword::words-to-ruled-words (wl &optional mode)
(mapcar (function
(lambda (word)
- (let ((ret (tm-eword::find-charset-rule (car word))))
+ (let ((ret (ew-find-charset-rule (car word))))
(make-ew-rword (cdr word) (car ret)(nth 1 ret) mode)
)))
wl))
-(defun tm-eword::space-process (seq)
+(defun ew-space-process (seq)
(let (prev a ac b c cc)
(while seq
(setq b (car seq))
(setq seq (cdr seq))
(setq c (car seq))
(setq cc (ew-rword-charset c))
- (if (null (ew-rword-charset b))
+ (if (and (null (ew-rword-charset b))
+ (not (eq (ew-rword-type b) 'special)))
(progn
(setq a (car prev))
(setq ac (ew-rword-charset a))
))
(defun eword-encode-split-string (str &optional mode)
- (tm-eword::space-process
+ (ew-space-process
(tm-eword::words-to-ruled-words
(eword-encode-charset-words-to-words
(eword-encode-divide-into-charset-words str))
;;; @ encode-string
;;;
-(defun tm-eword::encode-string-1 (column rwl)
- (let* ((rword (car rwl))
- (ret (tm-eword::encoded-word-length rword))
- string len)
- (if (null ret)
- (cond ((and (setq string (car rword))
- (or (<= (setq len (+ (length string) column)) 76)
- (<= column 1))
+(defun ew-encode-rword-1 (column rwl &optional must-output)
+ (catch 'can-not-output
+ (let* ((rword (car rwl))
+ (ret (tm-eword::encoded-word-length rword))
+ string len)
+ (if (null ret)
+ (cond ((and (setq string (car rword))
+ (or (<= (setq len (+ (length string) column)) 76)
+ (<= column 1))
+ )
+ (setq rwl (cdr rwl))
+ )
+ ((memq (aref string 0) '(? ?\t))
+ (setq string (concat "\n" string)
+ len (length string)
+ rwl (cdr rwl))
+ )
+ (must-output
+ (setq string "\n "
+ len 1)
+ )
+ (t
+ (throw 'can-not-output nil)
+ ))
+ (cond ((and (setq len (car ret))
+ (<= (+ column len) 76)
)
+ (setq string
+ (eword-encode-text
+ (ew-rword-charset rword)
+ (ew-rword-encoding rword)
+ (cdr ret)
+ (ew-rword-type rword)
+ ))
+ (setq len (+ (length string) column))
(setq rwl (cdr rwl))
)
(t
- (setq string "\n ")
- (setq len 1)
- ))
- (cond ((and (setq len (car ret))
- (<= (+ column len) 76)
- )
- (setq string
- (eword-encode-text
- (ew-rword-charset rword)
- (ew-rword-encoding rword)
- (cdr ret)
- (ew-rword-type rword)
- ))
- (setq len (+ (length string) column))
- (setq rwl (cdr rwl))
- )
- (t
- (setq string (car rword))
- (let* ((p 0) np
- (str "") nstr)
- (while (and (< p len)
- (progn
- (setq np (char-next-index (sref string p) p))
- (setq nstr (substring string 0 np))
- (setq ret (tm-eword::encoded-word-length
- (cons nstr (cdr rword))
- ))
- (setq nstr (cdr ret))
- (setq len (+ (car ret) column))
- (<= len 76)
- ))
- (setq str nstr
- p np))
- (if (string-equal str "")
- (setq string "\n "
- len 1)
- (setq rwl (cons (cons (substring string p) (cdr rword))
- (cdr rwl)))
- (setq string
- (eword-encode-text
- (ew-rword-charset rword)
- (ew-rword-encoding rword)
- str
- (ew-rword-type rword)))
- (setq len (+ (length string) column))
- )
- )))
- )
- (list string len rwl)
- ))
+ (setq string (car rword))
+ (let* ((p 0) np
+ (str "") nstr)
+ (while (and (< p len)
+ (progn
+ (setq np (char-next-index (sref string p) p))
+ (setq nstr (substring string 0 np))
+ (setq ret (tm-eword::encoded-word-length
+ (cons nstr (cdr rword))
+ ))
+ (setq nstr (cdr ret))
+ (setq len (+ (car ret) column))
+ (<= len 76)
+ ))
+ (setq str nstr
+ p np))
+ (if (string-equal str "")
+ (if must-output
+ (setq string "\n "
+ len 1)
+ (throw 'can-not-output nil))
+ (setq rwl (cons (cons (substring string p) (cdr rword))
+ (cdr rwl)))
+ (setq string
+ (eword-encode-text
+ (ew-rword-charset rword)
+ (ew-rword-encoding rword)
+ str
+ (ew-rword-type rword)))
+ (setq len (+ (length string) column))
+ )
+ )))
+ )
+ (list string len rwl)
+ )))
(defun eword-encode-rword-list (column rwl)
- (let (ret dest ps special str ew-f pew-f bew)
+ (let (ret dest str ew-f pew-f folded-points)
(while rwl
(setq ew-f (nth 2 (car rwl)))
(if (and pew-f ew-f)
(setq rwl (cons '(" ") rwl)
- bew t
pew-f nil)
- (setq pew-f ew-f
- bew nil)
+ (setq pew-f ew-f)
)
- (setq ret (tm-eword::encode-string-1 column rwl))
+ (if (null (setq ret (ew-encode-rword-1 column rwl)))
+ (let ((i (1- (length dest)))
+ c s r-dest r-column)
+ (catch 'success
+ (while (catch 'found
+ (while (>= i 0)
+ (cond ((memq (setq c (aref dest i)) '(? ?\t))
+ (if (memq i folded-points)
+ (throw 'found nil)
+ (setq folded-points (cons i folded-points))
+ (throw 'found i))
+ )
+ ((eq c ?\n)
+ (throw 'found nil)
+ ))
+ (setq i (1- i))))
+ (setq s (substring dest i)
+ r-column (length s)
+ r-dest (concat (substring dest 0 i) "\n" s))
+ (when (setq ret (ew-encode-rword-1 r-column rwl))
+ (setq dest r-dest
+ column r-column)
+ (throw 'success t)
+ ))
+ (setq ret (ew-encode-rword-1 column rwl 'must-output))
+ )))
(setq str (car ret))
- (if (eq (elt str 0) ?\n)
- (cond
- ((eq special ?\()
- (setq dest (concat dest "\n ("))
- (setq ret (tm-eword::encode-string-1 2 rwl))
- (setq str (car ret)))
- ((eq bew t)
- (setq dest (concat dest "\n "))
- (setq ret (tm-eword::encode-string-1 1 (cdr rwl)))
- (setq str (car ret))))
- (cond ((eq special ? )
- (if (string= str "(")
- (setq ps t)
- (setq dest (concat dest " "))
- (setq ps nil)
- ))
- ((eq special ?\()
- (if ps
- (progn
- (setq dest (concat dest " ("))
- (setq ps nil)
- )
- (setq dest (concat dest "("))
- )
- )))
- (cond ((string= str " ")
- (setq special ? )
- )
- ((string= str "(")
- (setq special ?\()
- )
- (t
- (setq special nil)
- (setq dest (concat dest str))
- ))
+ (setq dest (concat dest str))
(setq column (nth 1 ret)
rwl (nth 2 ret))
)
(setq dest
(append dest
(list
- (let ((ret (tm-eword::find-charset-rule
+ (let ((ret (ew-find-charset-rule
(find-non-ascii-charset-string str))))
(make-ew-rword
str (car ret)(nth 1 ret) 'phrase)
((eq type 'comment)
(setq dest
(append dest
- '(("(" nil nil))
+ '(("(" nil nil special))
(tm-eword::words-to-ruled-words
(eword-encode-charset-words-to-words
(eword-encode-divide-into-charset-words
(cdr token)))
'comment)
- '((")" nil nil))
+ '((")" nil nil special))
))
)
(t
))
(setq phrase (cdr phrase))
)
- (tm-eword::space-process dest)
+ (ew-space-process dest)
))
(defun eword-encode-addr-seq-to-rword-list (seq)
(forward-char)))))
(defsubst mailcap-look-at-qchar ()
- (let ((chr (char-after (point))))
- (when (eq chr ?\\)
- (forward-char 2)
- (char-before (point))
- )))
+ (when (eq (char-after (point)) ?\\)
+ (prog2
+ (forward-char)
+ (char-after (point))
+ (forward-char))))
(defsubst mailcap-look-at-mtext ()
(let ((beg (point)))
-;;; mel-b-ccl.el: CCL based encoder/decoder of Base64
+;;; mel-b-ccl.el --- Base64 encoder/decoder using CCL.
-;; Copyright (C) 1998 Tanaka Akira
+;; Copyright (C) 1998,1999 Tanaka Akira
;; Author: Tanaka Akira <akr@jaist.ac.jp>
;; Created: 1998/9/17
;; 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.
(&optional quantums-per-line output-crlf terminate-with-newline)
`(2
((r3 = 0)
+ (r2 = 0)
+ (read r1)
(loop
- (r2 = 0)
- (read-branch
+ (branch
r1
,@(mapcar
(lambda (r1)
(nth r1 mel-ccl-64-to-256-table))
mel-ccl-64-table)))
(r3 += 1)
+ (r2 = 0)
+ (read r1)
,@(when quantums-per-line
`((if (r3 == ,quantums-per-line)
((write ,(if output-crlf "\r\n" "\n"))
(unless-broken ccl-execute-eof-block-on-decoding-some
- (defun base64-ccl-encode-string (string)
+ (defun base64-ccl-encode-string (string &optional no-line-break)
"Encode STRING with base64 encoding."
- (decode-coding-string string 'mel-ccl-base64-lf-rev))
+ (if no-line-break
+ (decode-coding-string string 'mel-ccl-b-rev)
+ (decode-coding-string string 'mel-ccl-base64-lf-rev)))
+ (defalias-maybe 'base64-encode-string 'base64-ccl-encode-string)
- (defun base64-ccl-encode-region (start end)
+ (defun base64-ccl-encode-region (start end &optional no-line-break)
"Encode region from START to END with base64 encoding."
- (interactive "r")
- (decode-coding-region start end 'mel-ccl-base64-lf-rev))
+ (interactive "*r")
+ (if no-line-break
+ (decode-coding-region start end 'mel-ccl-b-rev)
+ (decode-coding-region start end 'mel-ccl-base64-lf-rev)))
+ (defalias-maybe 'base64-encode-region 'base64-ccl-encode-region)
(defun base64-ccl-insert-encoded-file (filename)
"Encode contents of file FILENAME to base64, and insert the result."
- (interactive (list (read-file-name "Insert encoded file: ")))
+ (interactive "*fInsert encoded file: ")
(insert-file-contents-as-coding-system 'mel-ccl-base64-lf-rev filename))
(mel-define-method-function (mime-encode-string string (nil "base64"))
(defun base64-ccl-decode-string (string)
"Decode base64 encoded STRING"
(encode-coding-string string 'mel-ccl-b-rev))
+(defalias-maybe 'base64-decode-string 'base64-ccl-decode-string)
(defun base64-ccl-decode-region (start end)
"Decode base64 encoded the region from START to END."
- (interactive "r")
+ (interactive "*r")
(encode-coding-region start end 'mel-ccl-b-rev))
+(defalias-maybe 'base64-decode-region 'base64-ccl-decode-region)
(defun base64-ccl-write-decoded-region (start end filename)
"Decode the region from START to END and write out to FILENAME."
- (interactive
- (list (region-beginning) (region-end)
- (read-file-name "Write decoded region to file: ")))
+ (interactive "*r\nFWrite decoded region to file: ")
(write-region-as-coding-system 'mel-ccl-b-rev start end filename))
(mel-define-method-function (mime-decode-string string (nil "base64"))
'base64-ccl-write-decoded-region)
(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)
(base64-ccl-decode-string string)
(error "Invalid encoded-text %s" string)))
(provide 'mel-b-ccl)
-;;; mel-b-ccl.el ends here
+;;; mel-b-ccl.el ends here.
-;;; 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.
+;; Copyright (C) 1998,1999 Free Software Foundation, Inc.
-;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
;; 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
;; 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)))
- (decode-base64-string string)
+ (if (string-match (eval-when-compile
+ (concat "\\`" B-encoded-text-regexp "\\'"))
+ string)
+ (base64-decode-string string)
(error "Invalid encoded-text %s" string)))
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
-;;; mel-b-el.el: Base64 encoder/decoder for GNU Emacs
+;;; mel-b-el.el --- Base64 encoder/decoder.
-;; Copyright (C) 1992,1995,1996,1997,1998 Free Software Foundation, Inc.
+;; Copyright (C) 1992,1995,1996,1997,1998,1999 Free Software Foundation, Inc.
;; Author: ENAMI Tsugutomo <enami@sys.ptg.sony.co.jp>
-;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; MORIOKA Tomohiko <tomo@m17n.org>
;; Created: 1995/6/24
;; 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
;; 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)
(integer :tag "Size")))
+;;; @ utility function
+;;;
+
+(defun pack-sequence (seq size)
+ "Split sequence SEQ into SIZE elements packs, and return list of packs.
+\[mel-b-el; tl-seq function]"
+ (let ((len (length seq))
+ (p 0)
+ dest unit)
+ (while (< p len)
+ (setq unit (cons (elt seq p) unit))
+ (setq p (1+ p))
+ (when (zerop (mod p size))
+ (setq dest (cons (nreverse unit) dest))
+ (setq unit nil)))
+ (if unit
+ (nreverse (cons (nreverse unit) dest))
+ (nreverse dest))))
+
+
;;; @ internal base64 encoder
;;; based on base64 decoder by Enami Tsugutomo
`(aref base64-characters ,n))
(defun base64-encode-1 (pack)
- (let ((a (car pack))
- (b (nth 1 pack))
- (c (nth 2 pack)))
- (concat
- (char-to-string (base64-num-to-char (ash a -2)))
- (if b
- (concat
- (char-to-string
- (base64-num-to-char (logior (ash (logand a 3) 4) (ash b -4))))
- (if c
- (concat
- (char-to-string
- (base64-num-to-char (logior (ash (logand b 15) 2) (ash c -6))))
- (char-to-string (base64-num-to-char (logand c 63)))
- )
- (concat (char-to-string
- (base64-num-to-char (ash (logand b 15) 2))) "=")
- ))
- (concat (char-to-string
- (base64-num-to-char (ash (logand a 3) 4))) "==")
- ))))
+ (let ((buf (make-string 4 ?=)))
+ (aset buf 0 (base64-num-to-char (ash (car pack) -2)))
+ (if (nth 1 pack)
+ (progn
+ (aset buf 1 (base64-num-to-char
+ (logior (ash (logand (car pack) 3) 4)
+ (ash (nth 1 pack) -4))))
+ (if (nth 2 pack)
+ (progn
+ (aset buf 2 (base64-num-to-char
+ (logior (ash (logand (nth 1 pack) 15) 2)
+ (ash (nth 2 pack) -6))))
+ (aset buf 3 (base64-num-to-char
+ (logand (nth 2 pack) 63))))
+ (aset buf 2 (base64-num-to-char
+ (ash (logand (nth 1 pack) 15) 2)))))
+ (aset buf 1 (base64-num-to-char
+ (ash (logand (car pack) 3) 4))))
+ buf))
(defun-maybe base64-encode-string (string)
"Encode STRING to base64, and return the result."
- (let ((len (length string))
- (b 0)(e 57)
- dest)
+ (let* ((len (length string))
+ (b 0)(e 57)
+ (dest ""))
(while (< e len)
(setq dest
(concat dest
"")
"\n"))
(setq b e
- e (+ e 57)
- )
- )
- (let* ((es (mapconcat
- (function base64-encode-1)
- (pack-sequence (substring string b) 3)
- ""))
- (m (mod (length es) 4))
- )
- (concat dest es (cond ((= m 3) "=")
- ((= m 2) "==")
- ))
- )))
+ e (+ e 57)))
+ (concat dest
+ (mapconcat
+ (function base64-encode-1)
+ (pack-sequence (substring string b) 3)
+ ""))))
(defun base64-internal-encode-region (beg end)
(save-excursion
(save-restriction
(narrow-to-region beg end)
- (let ((str (buffer-substring beg end)))
- (delete-region beg end)
- (insert (base64-encode-string str))
- )
- (or (bolp)
- (insert "\n")
- )
- )))
+ (insert
+ (prog1
+ (base64-encode-string
+ (buffer-substring beg end))
+ (delete-region beg end)))
+ (or (bolp) (insert ?\n)))))
;;; @ internal base64 decoder
(defsubst base64-internal-decode (string buffer)
(let* ((len (length string))
- (i 0)
- (j 0)
+ (i 0)(j 0)
v1 v2 v3)
(catch 'tag
(while (< i len)
(if v4
(aset buffer (prog1 j (setq j (1+ j)))
(logior (lsh (logand v3 3) 6) v4))
- (throw 'tag nil)
- ))
- (throw 'tag nil)
- ))))
- (substring buffer 0 j)
- ))
+ (throw 'tag nil)))
+ (throw 'tag nil)))))
+ (substring buffer 0 j)))
(defun base64-internal-decode-string (string)
(base64-internal-decode string (make-string (length string) 0)))
(defun base64-internal-decode-region (beg end)
(save-excursion
(let ((str (string-as-unibyte (buffer-substring beg end))))
- (delete-region beg end)
- (goto-char beg)
- (insert (base64-internal-decode str str)))))
+ (insert
+ (prog1
+ (base64-internal-decode str str)
+ (delete-region beg end))))))
;; (defun base64-internal-decode-region2 (beg end)
;; (save-excursion
(as-binary-process
(apply (function call-process-region)
beg end (car base64-external-encoder)
- t t nil (cdr base64-external-encoder)))
+ t t nil
+ (cdr base64-external-encoder)))
;; for OS/2
;; regularize line break code
(goto-char (point-min))
(while (re-search-forward "\r$" nil t)
- (replace-match ""))
- )))
+ (replace-match "")))))
(defun base64-external-decode-region (beg end)
(save-excursion
(as-binary-process
(apply (function call-process-region)
beg end (car base64-external-decoder)
- t t nil (cdr base64-external-decoder)))
- ))
+ t t nil
+ (cdr base64-external-decoder)))))
(defun base64-external-decode-string (string)
(with-temp-buffer
(insert string)
(as-binary-process
(apply (function call-process-region)
- (point-min) (point-max)
- (car base64-external-decoder)
- t t nil (cdr base64-external-decoder)))
+ (point-min)(point-max) (car base64-external-decoder)
+ t t nil
+ (cdr base64-external-decoder)))
(buffer-string)))
external base64 encoder specified by `base64-external-encoder'. In
this case, you must install the program (maybe mmencode included in
metamail or XEmacs package)."
- (interactive "r")
+ (interactive "*r")
(if (and base64-internal-encoding-limit
(> (- end start) base64-internal-encoding-limit))
(base64-external-encode-region start end)
external base64 decoder specified by `base64-external-decoder'. In
this case, you must install the program (maybe mmencode included in
metamail or XEmacs package)."
- (interactive "r")
+ (interactive "*r")
(if (and base64-internal-decoding-limit
(> (- end start) base64-internal-decoding-limit))
(base64-external-decode-region start end)
external base64 decoder specified by `base64-external-decoder'. In
this case, you must install the program (maybe mmencode included in
metamail or XEmacs package)."
- (interactive "r")
(if (and base64-internal-decoding-limit
(> (length string) base64-internal-decoding-limit))
(base64-external-decode-string 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)
(base64-decode-string string)
(error "Invalid encoded-text %s" string)))
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: ")))
+ (interactive "*fInsert encoded file: ")
(if (and base64-internal-encoding-limit
(> (nth 7 (file-attributes filename))
base64-internal-encoding-limit))
- (apply (function call-process) (car base64-external-encoder)
- filename t nil (cdr base64-external-encoder))
+ (apply (function call-process)
+ (car base64-external-encoder)
+ filename t nil
+ (cdr base64-external-encoder))
(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-function (mime-insert-encoded-file filename (nil "base64"))
'base64-insert-encoded-file)
(defun base64-write-decoded-region (start end filename)
"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: ")
(if (and base64-internal-decoding-limit
(> (- end start) base64-internal-decoding-limit))
(as-binary-process
(let ((str (buffer-substring start end)))
(with-temp-buffer
(insert (base64-internal-decode-string str))
- (write-region-as-binary (point-min) (point-max) filename)
- ))))
+ (write-region-as-binary (point-min) (point-max) filename)))))
(mel-define-method-function
(mime-write-decoded-region start end filename (nil "base64"))
'base64-write-decoded-region)
-;;; @ etc
-;;;
-
-(defun pack-sequence (seq size)
- "Split sequence SEQ into SIZE elements packs,
-and return list of packs. [mel-b-el; tl-seq function]"
- (let ((len (length seq)) (p 0) obj
- unit (i 0)
- dest)
- (while (< p len)
- (setq obj (elt seq p))
- (setq unit (cons obj unit))
- (setq i (1+ i))
- (if (= i size)
- (progn
- (setq dest (cons (reverse unit) dest))
- (setq unit nil)
- (setq i 0)
- ))
- (setq p (1+ p))
- )
- (if unit
- (setq dest (cons (reverse unit) dest))
- )
- (reverse dest)
- ))
-
-
;;; @ end
;;;
-;;; mel-g.el: Gzip64 encoder/decoder for GNU Emacs
+;;; mel-g.el --- Gzip64 encoder/decoder.
;; Copyright (C) 1995,1996,1997,1998 MORIOKA Tomohiko
-;; Copyright (C) 1996,1997 Shuhei KOBAYASHI
+;; Copyright (C) 1996,1997,1999 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>
+;; Author: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
+;; MORIOKA Tomohiko <tomo@m17n.org>
+;; Maintainer: Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
;; Created: 1995/10/25
;; Keywords: Gzip64, base64, gzip, MIME
-;; 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
;; 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 'poem)
+(require 'mime-def)
(require 'path-util)
-(require 'mel)
;;; @ variables
(defvar gzip64-external-encoder
(let ((file (exec-installed-p "mmencode")))
(and file
- (` ("sh" "-c" (, (concat "gzip -c | " file))))
- ))
+ (` ("sh" "-c" (, (concat "gzip -c | " file))))))
"*list of gzip64 encoder program name and its arguments.")
(defvar gzip64-external-decoder
(let ((file (exec-installed-p "mmencode")))
(and file
- (` ("sh" "-c" (, (concat file " -u | gzip -dc"))))
- ))
+ (` ("sh" "-c" (, (concat file " -u | gzip -dc"))))))
"*list of gzip64 decoder program name and its arguments.")
(defun gzip64-external-encode-region (beg end)
(interactive "*r")
(save-excursion
- (as-binary-process (apply (function call-process-region)
- beg end (car gzip64-external-encoder)
- t t nil (cdr gzip64-external-encoder))
- )
+ (as-binary-process
+ (apply (function call-process-region)
+ beg end (car gzip64-external-encoder)
+ t t nil
+ (cdr gzip64-external-encoder)))
;; for OS/2
;; regularize line break code
(goto-char (point-min))
(while (re-search-forward "\r$" nil t)
- (replace-match "")
- )
- ))
+ (replace-match ""))))
(defun gzip64-external-decode-region (beg end)
(interactive "*r")
(save-excursion
- (as-binary-process (apply (function call-process-region)
- beg end (car gzip64-external-decoder)
- t t nil (cdr gzip64-external-decoder))
- )
- ))
+ (as-binary-process
+ (apply (function call-process-region)
+ beg end (car gzip64-external-decoder)
+ t t nil
+ (cdr gzip64-external-decoder)))))
(mel-define-method-function (mime-encode-region start end (nil "x-gzip64"))
'gzip64-external-encode-region)
;;;
(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)
+ (interactive "*fInsert encoded file: ")
+ (apply (function call-process)
+ (car gzip64-external-encoder)
filename t nil
- (cdr gzip64-external-encoder))
- )
+ (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: ")))
+ (interactive "*r\nFWrite 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))))
- )))
+ (list (concat (car (last args)) ">" filename)))))))
;;; @ end
-;;; mel-ccl.el: CCL based encoder/decoder of Quoted-Printable
-;;; and Q-encoding
+;;; mel-q-ccl.el --- Quoted-Printable encoder/decoder using CCL.
-;; Copyright (C) 1998 Tanaka Akira
+;; Copyright (C) 1998,1999 Tanaka Akira
;; Author: Tanaka Akira <akr@jaist.ac.jp>
;; Created: 1998/9/17
;; 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.
(eval-when-compile
-(defun mel-ccl-try-to-read-crlf (input-crlf reg eof-reg cr-eof lf-eof crlf-eof succ fail-cr fail-lf fail-crlf)
+(defvar eof-block-branches)
+(defvar eof-block-reg)
+(defun mel-ccl-set-eof-block (branch)
+ (let ((p (assoc branch eof-block-branches)))
+ (unless p
+ (setq p (cons branch (length eof-block-branches))
+ eof-block-branches (cons p eof-block-branches)))
+ `(,eof-block-reg = ,(cdr p))))
+
+)
+
+(eval-when-compile
+
+(defun mel-ccl-try-to-read-crlf (input-crlf reg
+ succ
+ cr-eof cr-fail
+ lf-eof lf-fail
+ crlf-eof crlf-fail)
(if input-crlf
- `((,eof-reg = ,cr-eof) (read-if (,reg == ?\r)
- ((,eof-reg = ,lf-eof) (read-if (,reg == ?\n)
- ,succ
- ,fail-lf))
- ,fail-cr))
- `((,eof-reg = ,crlf-eof) (read-if (,reg == ?\n)
- ,succ
- ,fail-crlf))))
+ `(,(mel-ccl-set-eof-block cr-eof)
+ (read-if (,reg == ?\r)
+ (,(mel-ccl-set-eof-block lf-eof)
+ (read-if (,reg == ?\n)
+ ,succ
+ ,lf-fail))
+ ,cr-fail))
+ `(,(mel-ccl-set-eof-block crlf-eof)
+ (read-if (,reg == ?\n)
+ ,succ
+ ,crlf-fail))))
)
;; Generated CCL program works not properly on 20.2 because CCL_EOF_BLOCK
;; is not executed.
(defun mel-ccl-encode-quoted-printable-generic (input-crlf output-crlf)
- `(4
- ((r6 = 0) ; column
- (r5 = 0) ; previous character is white space
- (r4 = 0)
- (read r0)
- (loop ; r6 <= 75
- (loop
- (loop
- (branch
- r0
- ,@(mapcar
- (lambda (r0)
- (let ((tmp (aref mel-ccl-qp-table r0)))
- (cond
- ((eq r0 (char-int ?F))
- `(if (r6 == 0)
- ((r4 = 15) (read-if (r0 == ?r)
- ((r4 = 16) (read-if (r0 == ?o)
- ((r4 = 17) (read-if (r0 == ?m)
- ((r4 = 18) (read-if (r0 == ? )
- ((r6 = 7)
- (r5 = 1)
- (write "=46rom ")
- (r4 = 19)
- (read r0)
- (repeat))
- ((r6 = 4)
- (write-repeat "From"))))
- ((r6 = 3)
- (write-repeat "Fro"))))
- ((r6 = 2)
- (write-repeat "Fr"))))
- ((r6 = 1)
- (write-repeat "F"))))
- ((r3 = 0) (break)) ; RAW
- ))
- ((eq r0 (char-int ?.))
- `(if (r6 == 0)
- ,(mel-ccl-try-to-read-crlf
- input-crlf
- 'r0 'r4 20 21 22
- `((write ,(if output-crlf "=2E\r\n" "=2E\n"))
- (r4 = 23)
- (read r0)
- (repeat))
- '((r6 = 1)
- (write-repeat "."))
- '((r6 = 4)
- (write-repeat ".=0D"))
- '((r6 = 1)
- (write-repeat ".")))
- ((r3 = 0) (break)) ; RAW
- ))
- ((eq tmp 'raw) '((r3 = 0) (break))) ; RAW
- ((eq tmp 'enc) '((r3 = 1) (break))) ; ENC
- ((eq tmp 'wsp) '((r3 = 2) (break))) ; WSP
- ((eq tmp 'cr) (if input-crlf
- '((r3 = 3) (break)) ; CR
- '((r3 = 1) (break)))) ; ENC
- ((eq tmp 'lf) (if input-crlf
- '((r3 = 1) (break)) ; ENC
- '((r3 = 3) (break)))) ; CRLF
- )))
- mel-ccl-256-table)))
- (branch
- r3
- ;; r0:r3=RAW
- (if (r6 < 75)
- ((r6 += 1)
- (r5 = 0)
- (r4 = 1)
- (write-read-repeat r0))
- (break))
- ;; r0:r3=ENC
- ((r5 = 0)
- (if (r6 < 73)
- ((r6 += 3)
- (write "=")
- (write r0 ,mel-ccl-high-table)
- (r4 = 2)
- (write-read-repeat r0 ,mel-ccl-low-table))
- (if (r6 > 73)
- ((r6 = 3)
- (write ,(if output-crlf "=\r\n=" "=\n="))
- (write r0 ,mel-ccl-high-table)
- (r4 = 3)
- (write-read-repeat r0 ,mel-ccl-low-table))
- (break))))
- ;; r0:r3=WSP
- ((r5 = 1)
- (if (r6 < 75)
- ((r6 += 1)
- (r4 = 4)
- (write-read-repeat r0))
- ((r6 = 1)
- (write ,(if output-crlf "=\r\n" "=\n"))
- (r4 = 5)
- (write-read-repeat r0))))
- ;; r0:r3=CR/CRLF
- ,(if input-crlf
- ;; r0:r3=CR
- `((if ((r6 > 73) & r5)
- ((r6 = 0)
- (r5 = 0)
- (write ,(if output-crlf "=\r\n" "=\n"))))
- (break))
- ;; r0:r3=CRLF
- `(if r5
- ;; WSP ; r0:r3=CRLF
- ((r5 = 0)
- (r6 = 0)
- (write ,(if output-crlf "=\r\n" "=\n"))
- ,@(if output-crlf '((write ?\r)) '())
- (r4 = 0)
- (write-read-repeat r0))
- ;; noWSP ; r0:r3=CRLF
- ((r5 = 0)
- (r6 = 0)
- ,@(if output-crlf '((write ?\r)) '())
- (r4 = 0)
- (write-read-repeat r0)))
- )))
- ;; r0:r3={RAW,ENC,CR}
- (loop
- ,(funcall
- (lambda (after-cr after-raw-enc)
- (if input-crlf
- `(if (r0 == ?\r)
- ,after-cr
- ,after-raw-enc)
- after-raw-enc))
- ;; r0=\r:r3=CR
- `((r4 = 6)
- (read r0)
- ;; CR:r3=CR r0
- (if (r0 == ?\n)
- ;; CR:r3=CR r0=LF
- (if r5
- ;; r5=WSP ; CR:r3=CR r0=LF
- ((r6 = 0)
- (r5 = 0)
- (write ,(if output-crlf "=\r\n\r\n" "=\n\n"))
- (r4 = 7)
- (read r0)
- (break))
- ;; r5=noWSP ; CR:r3=CR r0=LF
- ((r6 = 0)
- (r5 = 0)
- (write ,(if output-crlf "\r\n" "\n"))
- (r4 = 8)
- (read r0)
- (break)))
- ;; CR:r3=CR r0=noLF
- (if (r6 < 73)
- ((r6 += 3)
- (r5 = 0)
- (write "=0D")
- (break))
- (if (r6 == 73)
- (if (r0 == ?\r)
- ;; CR:r3=CR r0=CR
- ((r4 = 9)
- (read r0)
- ;; CR:r3=CR CR r0
- (if (r0 == ?\n)
- ;; CR:r3=CR CR LF
- ((r6 = 0)
- (r5 = 0)
- (write ,(if output-crlf "=0D\r\n" "=0D\n"))
- (r4 = 10)
- (read r0)
- (break))
- ;; CR:r3=CR CR noLF
- ((r6 = 6)
- (r5 = 0)
- (write ,(if output-crlf "=\r\n=0D=0D" "=\n=0D=0D"))
- (break))))
- ;; CR:r3=CR r0=noLFnorCR
- ((r6 = 3)
- (r5 = 0)
- (write ,(if output-crlf "=\r\n=0D" "=\n=0D"))
- (break)))
- ((r6 = 3)
- (r5 = 0)
- (write ,(if output-crlf "=\r\n=0D" "=\n=0D"))
- (break))))))
- (funcall
- (lambda (after-newline after-cr-nolf after-nonewline)
- (if input-crlf
- ;; r0:r3={RAW,ENC}
- `((r4 = 11)
- (read r1)
- ;; r0:r3={RAW,ENC} r1
- (if (r1 == ?\r)
- ;; r0:r3={RAW,ENC} r1=CR
- ((r4 = 12)
- (read r1)
- ;; r0:r3={RAW,ENC} CR r1
- (if (r1 == ?\n)
- ;; r0:r3=RAW CR r1=LF
- ,after-newline
- ;; r0:r3=RAW CR r1=noLF
- ,after-cr-nolf))
- ;; r0:r3={RAW,ENC} r1:noCR
- ,after-nonewline))
- ;; r0:r3={RAW,ENC}
- `((r4 = 11)
- (read r1)
- ;; r0:r3={RAW,ENC} r1
- (if (r1 == ?\n)
- ;; r0:r3={RAW,ENC} r1=CRLF
- ,after-newline
- ;; r0:r3={RAW,ENC} r1:noCRLF
- ,after-nonewline))))
- ;; r0:r3={RAW,ENC} CR r1=LF
- ;; r0:r3={RAW,ENC} r1=CRLF
- `((r6 = 0)
- (r5 = 0)
- (branch
- r3
- ;; r0:r3=RAW CR r1=LF
- ;; r0:r3=RAW r1=CRLF
- ((write r0)
- (write ,(if output-crlf "\r\n" "\n"))
- (r4 = 13)
- (read r0)
- (break))
- ;; r0:r3=ENC CR r1=LF
- ;; r0:r3=ENC r1=CRLF
- ((write ?=)
- (write r0 ,mel-ccl-high-table)
- (write r0 ,mel-ccl-low-table)
- (write ,(if output-crlf "\r\n" "\n"))
- (r4 = 14)
- (read r0)
- (break))))
- ;; r0:r3={RAW,ENC} CR r1=noLF
- `((branch
- r3
- ;; r0:r3=RAW CR r1:noLF
- ((r6 = 4)
- (r5 = 0)
- (write ,(if output-crlf "=\r\n" "=\n"))
- (write r0)
- (write "=0D")
- (r0 = (r1 + 0)) ; "+ 0" is workaround for mule 2.3@19.34.
- (break))
- ;; r0:r3=ENC CR r1:noLF
- ((r6 = 6)
- (r5 = 0)
- (write ,(if output-crlf "=\r\n=" "=\n="))
- (write r0 ,mel-ccl-high-table)
- (write r0 ,mel-ccl-low-table)
- (write "=0D")
- (r0 = (r1 + 0))
- (break))))
- ;; r0:r3={RAW,ENC} r1:noCR
- ;; r0:r3={RAW,ENC} r1:noCRLF
- `((branch
- r3
- ;; r0:r3=RAW r1:noCR
- ;; r0:r3=RAW r1:noCRLF
- ((r6 = 1)
- (r5 = 0)
- (write ,(if output-crlf "=\r\n" "=\n"))
- (write r0)
- (r0 = (r1 + 0))
- (break))
- ;; r0:r3=ENC r1:noCR
- ;; r0:r3=ENC r1:noCRLF
- ((r6 = 3)
- (r5 = 0)
- (write ,(if output-crlf "=\r\n=" "=\n="))
- (write r0 ,mel-ccl-high-table)
- (write r0 ,mel-ccl-low-table)
- (r0 = (r1 + 0))
- (break)))))))
- (repeat)))
- ;; EOF
- ( ;(write "[EOF:") (write r4 ,mel-ccl-high-table) (write r4 ,mel-ccl-low-table) (write "]")
- (branch
- r4
- ;; 0: (start) ;
- (end)
- ;; 1: RAW ;
- (end)
- ;; 2: r0:r3=ENC ;
- (end)
- ;; 3: SOFTBREAK r0:r3=ENC ;
- (end)
- ;; 4: r0:r3=WSP ;
- ((write ,(if output-crlf "=\r\n" "=\n")) (end))
- ;; 5: SOFTBREAK r0:r3=WSP ;
- ((write ,(if output-crlf "=\r\n" "=\n")) (end))
- ;; 6: ; r0=\r:r3=CR
- (if (r6 <= 73)
- ((write "=0D") (end))
- ((write ,(if output-crlf "=\r\n=0D" "=\n=0D")) (end)))
- ;; 7: r5=WSP SOFTBREAK CR:r3=CR r0=LF ;
- (end)
- ;; 8: r5=noWSP CR:r3=CR r0=LF ;
- (end)
- ;; 9: (r6=73) ; CR:r3=CR r0=CR
- ((write ,(if output-crlf "=\r\n=0D=0D" "=\n=0D=0D")) (end))
- ;; 10: (r6=73) CR:r3=CR CR LF ;
- (end)
- ;; 11: ; r0:r3={RAW,ENC}
- (branch
- r3
- ((write r0) (end))
- ((write "=")
- (write r0 ,mel-ccl-high-table)
- (write r0 ,mel-ccl-low-table)
- (end)))
- ;; 12: ; r0:r3={RAW,ENC} r1=CR
+ (let ((hard (if output-crlf "\r\n" "\n"))
+ (soft (if output-crlf "=\r\n" "=\n"))
+ (eof-block-branches nil)
+ (eof-block-reg 'r4)
+ (after-wsp 'r5)
+ (column 'r6)
+ (type 'r3)
+ (current 'r0)
+ (type-raw 0)
+ (type-enc 1)
+ (type-wsp 2)
+ (type-brk 3)
+ )
+ `(4
+ ((,column = 0)
+ (,after-wsp = 0)
+ ,(mel-ccl-set-eof-block '(end))
+ (read r0)
+ (loop ; invariant: column <= 75
+ (loop
+ (loop
+ (branch
+ r0
+ ,@(mapcar
+ (lambda (r0)
+ (let ((tmp (aref mel-ccl-qp-table r0)))
+ (cond
+ ((eq r0 (char-int ?F))
+ `(if (,column == 0)
+ (,(mel-ccl-set-eof-block '((write "F") (end)))
+ (read-if (r0 == ?r)
+ (,(mel-ccl-set-eof-block '((write "Fr") (end)))
+ (read-if (r0 == ?o)
+ (,(mel-ccl-set-eof-block '((write "Fro") (end)))
+ (read-if (r0 == ?m)
+ (,(mel-ccl-set-eof-block '((write "From") (end)))
+ (read-if (r0 == ? )
+ ((,column = 7)
+ (,after-wsp = 1)
+ ,(mel-ccl-set-eof-block '((write "From=20") (end)))
+ (read r0)
+ (write-repeat "=46rom "))
+ ((,column = 4)
+ (write-repeat "From"))))
+ ((,column = 3)
+ (write-repeat "Fro"))))
+ ((,column = 2)
+ (write-repeat "Fr"))))
+ ((,column = 1)
+ (write-repeat "F"))))
+ ((,type = ,type-raw) (break)) ; RAW
+ ))
+ ((eq r0 (char-int ?.))
+ `(if (,column == 0)
+ ,(mel-ccl-try-to-read-crlf
+ input-crlf 'r0
+ ;; "." CR LF (input-crlf: t)
+ ;; "." LF (input-crlf: nil)
+ `((write ,(concat "=2E" hard))
+ ,(mel-ccl-set-eof-block '(end))
+ (read r0)
+ (repeat))
+ ;; "." <EOF>
+ '((write ".") (end))
+ ;; "." noCR (input-crlf: t)
+ `((,column = 1)
+ (write-repeat "."))
+ ;; "." CR <EOF> (input-crlf: t)
+ '((write ".=0D") (end))
+ ;; "." CR noLF (input-crlf: t)
+ `((,column = 4)
+ (write-repeat ".=0D"))
+ ;; "." <EOF> (input-crlf: nil)
+ '((write ".") (end))
+ ;; "." noLF (input-crlf: nil)
+ `((,column = 1)
+ (write-repeat ".")))
+ ((,type = ,type-raw) (break)) ; RAW
+ ))
+ ((eq tmp 'raw) `((,type = ,type-raw) (break)))
+ ((eq tmp 'enc) `((,type = ,type-enc) (break)))
+ ((eq tmp 'wsp) `((,type = ,type-wsp) (break)))
+ ((eq tmp 'cr) `((,type = ,(if input-crlf type-brk type-enc))
+ (break)))
+ ((eq tmp 'lf) `((,type = ,(if input-crlf type-enc type-brk))
+ (break)))
+ )))
+ mel-ccl-256-table)))
+ ;; r0:type{raw,enc,wsp,brk}
+ (branch
+ ,type
+ ;; r0:type-raw
+ (if (,column < 75)
+ ((,column += 1)
+ (,after-wsp = 0)
+ ,(mel-ccl-set-eof-block '(end))
+ (write-read-repeat r0))
+ ((r1 = (r0 + 0))
+ (,after-wsp = 0)
+ ,@(mel-ccl-try-to-read-crlf
+ input-crlf 'r0
+ `((,column = 0)
+ (write r1)
+ ,(mel-ccl-set-eof-block `((write ,hard) (end)))
+ (read r0)
+ (write-repeat ,hard))
+ '((write r1) (end))
+ `((,column = 1)
+ (write ,soft) (write-repeat r1))
+ `((write ,soft) (write r1) (write "=0D") (end))
+ `((,column = 4)
+ (write ,soft) (write r1) (write-repeat "=0D"))
+ '((write r1) (end))
+ `((,column = 1)
+ (write ,soft) (write-repeat r1)))))
+ ;; r0:type-enc
+ ((,after-wsp = 0)
+ (if (,column < 73)
+ ((,column += 3)
+ (write "=")
+ (write r0 ,mel-ccl-high-table)
+ ,(mel-ccl-set-eof-block '(end))
+ (write-read-repeat r0 ,mel-ccl-low-table))
+ (if (,column < 74)
+ ((r1 = (r0 + 0))
+ (,after-wsp = 0)
+ ,@(mel-ccl-try-to-read-crlf
+ input-crlf 'r0
+ `((,column = 0)
+ (write "=")
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (write ,hard)
+ ,(mel-ccl-set-eof-block '(end))
+ (read r0)
+ (repeat))
+ `((write "=")
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (end))
+ `((,column = 3)
+ (write ,(concat soft "="))
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (repeat))
+ `((write ,(concat soft "="))
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (write "=0D")
+ (end))
+ `((,column = 6)
+ (write ,(concat soft "="))
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (write-repeat "=0D"))
+ `((write "=")
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (end))
+ `((,column = 3)
+ (write ,(concat soft "="))
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (repeat))))
+ ((,column = 3)
+ (write ,(concat soft "="))
+ (write r0 ,mel-ccl-high-table)
+ ,(mel-ccl-set-eof-block '(end))
+ (write-read-repeat r0 ,mel-ccl-low-table)))))
+ ;; r0:type-wsp
+ (if (,column < 73)
+ ((r1 = (r0 + 0))
+ ,@(mel-ccl-try-to-read-crlf
+ input-crlf 'r0
+ `((,column = 0)
+ (,after-wsp = 0)
+ (write "=")
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (write ,hard)
+ ,(mel-ccl-set-eof-block `(end))
+ (read r0)
+ (repeat))
+ `((write "=")
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (end))
+ `((,column += 1)
+ (,after-wsp = 1)
+ (write-repeat r1))
+ `((write r1)
+ (write "=0D")
+ (end))
+ `((,column += 4)
+ (,after-wsp = 0)
+ (write r1)
+ (write-repeat "=0D"))
+ `((write "=")
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (end))
+ `((,column += 1)
+ (,after-wsp = 1)
+ (write-repeat r1))))
+ (if (,column < 74)
+ ((r1 = (r0 + 0))
+ ,@(mel-ccl-try-to-read-crlf
+ input-crlf 'r0
+ `((,column = 0)
+ (,after-wsp = 0)
+ (write "=")
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (write ,hard)
+ ,(mel-ccl-set-eof-block `(end))
+ (read r0)
+ (repeat))
+ `((write "=")
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (end))
+ `((,column += 1)
+ (,after-wsp = 1)
+ (write-repeat r1))
+ `((write r1)
+ (write ,(concat soft "=0D"))
+ (end))
+ `((,column = 3)
+ (,after-wsp = 0)
+ (write r1)
+ (write-repeat ,(concat soft "=0D")))
+ `((write "=")
+ (write r1 ,mel-ccl-high-table)
+ (write r1 ,mel-ccl-low-table)
+ (end))
+ `((,column += 1)
+ (,after-wsp = 1)
+ (write-repeat r1))))
+ (if (,column < 75)
+ ((,column += 1)
+ (,after-wsp = 1)
+ ,(mel-ccl-set-eof-block `((write ,soft) (end)))
+ (write-read-repeat r0))
+ ((write ,soft)
+ (,column = 0)
+ (,after-wsp = 0)
+ (repeat)))))
+ ;; r0:type-brk
+ ,(if input-crlf
+ ;; r0{CR}:type-brk
+ `((if ((,column > 73) & ,after-wsp)
+ ((,column = 0)
+ (,after-wsp = 0)
+ (write ,soft)))
+ ,(mel-ccl-set-eof-block `((if (,column > 73) (write ,soft))
+ (write "=0D") (end)))
+ (read-if (r0 == ?\n)
+ (if ,after-wsp
+ ((,after-wsp = 0)
+ (,column = 0)
+ (write ,(concat soft hard))
+ ,(mel-ccl-set-eof-block '(end))
+ (read r0)
+ (repeat))
+ ((,after-wsp = 0)
+ (,column = 0)
+ (write ,hard)
+ ,(mel-ccl-set-eof-block '(end))
+ (read r0)
+ (repeat)))
+ (if (,column < 73)
+ ((,after-wsp = 0)
+ (,column += 3)
+ (write-repeat "=0D"))
+ (if (,column < 74)
+ (if (r0 == ?\r)
+ ((,after-wsp = 0)
+ ,(mel-ccl-set-eof-block
+ `((write ,(concat soft "=0D=0D")) (end)))
+ (read-if (r0 == ?\n)
+ ((,column = 0)
+ ,(mel-ccl-set-eof-block
+ `((write ,(concat "=0D" hard)) (end)))
+ (read r0)
+ (write-repeat ,(concat "=0D" hard)))
+ ((,column = 6)
+ (write-repeat ,(concat soft "=0D=0D")))))
+ ((,after-wsp = 0)
+ (,column = 3)
+ (write-repeat ,(concat soft "=0D"))))
+ ((,after-wsp = 0)
+ (,column = 3)
+ (write-repeat ,(concat soft "=0D")))))))
+ ;; r0{LF}:type-brk
+ `(if ,after-wsp
+ ;; WSP ; r0{LF}:type-brk
+ ((,after-wsp = 0)
+ (,column = 0)
+ (write ,(concat soft (if output-crlf "\r" "")))
+ ,(mel-ccl-set-eof-block `(end))
+ (write-read-repeat r0))
+ ;; noWSP ; r0{LF}:type-brk
+ ((,after-wsp = 0)
+ (,column = 0)
+ ,@(if output-crlf '((write ?\r)) '())
+ ,(mel-ccl-set-eof-block `(end))
+ (write-read-repeat r0)))
+ )))))
(branch
- r3
- ;; ; r0:r3=RAW r1=CR
- ((write ,(if output-crlf "=\r\n" "=\n"))
- (write r0)
- (write "=0D")
- (end))
- ;; ; r0:r3=ENC r1=CR
- ((write ,(if output-crlf "=\r\n=" "=\n="))
- (write r0 ,mel-ccl-high-table)
- (write r0 ,mel-ccl-low-table)
- (write "=0D")
- (end)))
- ;; 13: r0:r3=RAW CR LF ;
- ;; 13: r0:r3=RAW CRLF ;
- (end)
- ;; 14: r0:r3=ENC CR LF ;
- ;; 14: r0:r3=ENC CRLF ;
- (end)
- ;; 15: r6=0 ; "F"
- ((write "F") (end))
- ;; 16: r6=0 ; "Fr"
- ((write "Fr") (end))
- ;; 17: r6=0 ; "Fro"
- ((write "Fro") (end))
- ;; 18: r6=0 ; "From"
- ((write "From") (end))
- ;; 19: r6=0 "From " ;
- (end)
- ;; 20: r6=0 ; "."
- ((write ".") (end))
- ;; 21: r6=0 ; ".\r"
- ((write ".=0D") (end))
- ;; 22: r6=0 ; "."
- ((write ".") (end))
- ;; 23: r6=0 ".\r\n" ;
- (end)
- ))
- ))
+ ,eof-block-reg
+ ,@(reverse (mapcar 'car eof-block-branches))))))
(defun mel-ccl-decode-quoted-printable-generic (input-crlf output-crlf)
`(1
(defun quoted-printable-ccl-encode-region (start end)
"Encode the region from START to END with quoted-printable encoding."
- (interactive "r")
+ (interactive "*r")
(decode-coding-region start end 'mel-ccl-quoted-printable-lf-lf-rev))
(defun quoted-printable-ccl-insert-encoded-file (filename)
"Encode contents of the file named as FILENAME, and insert it."
- (interactive (list (read-file-name "Insert encoded file: ")))
+ (interactive "*fInsert encoded file: ")
(insert-file-contents-as-coding-system
'mel-ccl-quoted-printable-lf-lf-rev filename))
(defun quoted-printable-ccl-decode-region (start end)
"Decode the region from START to END with quoted-printable
encoding."
- (interactive "r")
+ (interactive "*r")
(encode-coding-region start end 'mel-ccl-quoted-printable-lf-lf-rev))
-(defun quoted-printable-ccl-write-decoded-region
- (start end filename)
+(defun quoted-printable-ccl-write-decoded-region (start end filename)
"Decode quoted-printable encoded current region and write out to FILENAME."
- (interactive
- (list (region-beginning) (region-end)
- (read-file-name "Write decoded region to file: ")))
+ (interactive "*r\nFWrite decoded region to file: ")
(write-region-as-coding-system 'mel-ccl-quoted-printable-lf-lf-rev
start end filename))
(unless (featurep 'xemacs)
(defun q-encoding-ccl-encoded-length (string &optional mode)
(let ((status [nil nil nil nil nil nil nil nil nil]))
- (fillarray status nil)
+ (fillarray status nil) ; XXX: Is this necessary?
(ccl-execute-on-string
(cond
((eq mode 'text) 'mel-ccl-count-uq)
'q-encoding-ccl-encode-string)
(mel-define-method encoded-text-decode-string (string (nil "Q"))
- (if (and (string-match Q-encoded-text-regexp string)
- (string= string (match-string 0 string)))
+ (if (string-match (eval-when-compile
+ (concat "\\`" Q-encoded-text-regexp "\\'"))
+ string)
(q-encoding-ccl-decode-string string)
(error "Invalid encoded-text %s" string)))
(provide 'mel-q-ccl)
-;;; mel-q-ccl.el ends here
+;;; mel-q-ccl.el ends here.
-;;; mel-q.el: Quoted-Printable and Q-encoding encoder/decoder for GNU Emacs
+;;; mel-q.el --- Quoted-Printable encoder/decoder.
-;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
+;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
-;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
;; Created: 1995/6/25
;; Keywords: MIME, Quoted-Printable, Q-encoding
-;; 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
;; 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 'emu)
(require 'mime-def)
+(require 'path-util)
;;; @ Quoted-Printable encoder
(concat
"="
(char-to-string (aref quoted-printable-hex-chars (ash character -4)))
- (char-to-string (aref quoted-printable-hex-chars (logand character 15)))
- ))
+ (char-to-string (aref quoted-printable-hex-chars (logand character 15)))))
(defun quoted-printable-internal-encode-region (start end)
(save-excursion
(save-restriction
- (narrow-to-region start end)
- (goto-char start)
- (let ((col 0))
- (while (< (point)(point-max))
- (cond ((>= col 75)
- (insert "=\n")
- (setq col 0)
- )
- ((looking-at-as-unibyte "^From ")
- (replace-match "=46rom ")
- (backward-char 1)
- (setq col (+ col 6))
- )
- ((looking-at-as-unibyte "[ \t]\n")
- (forward-char 1)
- (insert "=\n")
- (forward-char 1)
- (setq col 0)
- )
- (t
- (let ((chr (char-after (point))))
- (cond ((= chr ?\n)
- (forward-char 1)
- (setq col 0)
- )
- ((or (= chr ?\t)
- (and (<= 32 chr)(/= chr ?=)(< chr 127))
- )
- (forward-char 1)
- (setq col (1+ col))
- )
- ((>= col 73)
- (insert "=\n")
- (setq col 0)
- )
- (t
- (delete-char 1)
- (insert (quoted-printable-quote-char chr))
- (setq col (+ col 3))
- ))
- )))
- )))))
+ (narrow-to-region (goto-char start) end)
+ (let ((col 0)
+ chr)
+ (while (not (eobp))
+ (cond
+ ((>= col 75) ; soft line break.
+ (insert "=\n")
+ (setq col 0))
+ ((eolp) ; end of line.
+ (forward-char)
+ (setq col 0))
+ (t
+ (setq chr (char-after (point)))
+ (cond
+ ((and (memq chr '(? ?\t)) ; encode WSP char before CRLF.
+ (eq (char-after (1+ (point))) ?\n))
+ (forward-char)
+ (insert "=\n")
+ (forward-char)
+ (setq col 0))
+ ((and (bolp) ; "^From " is not safe.
+ (eq chr ?F)
+ (eq (char-after (1+ (point))) ?r)
+ (eq (char-after (+ 2 (point))) ?o)
+ (eq (char-after (+ 3 (point))) ?m)
+ (eq (char-after (+ 4 (point))) ? ))
+ (delete-region (point)(1+ (point)))
+ (insert "=46") ; moved to ?r.
+ (forward-char 4) ; skip "rom ".
+ (setq col 7))
+ ((or (= chr ?\t) ; skip safe char.
+ (and (<= 32 chr)(/= chr ?=)(< chr 127)))
+ (forward-char)
+ (setq col (1+ col)))
+ ((>= col 73) ; soft line break.
+ (insert "=\n")
+ (setq col 0))
+ (t ; encode unsafe char.
+ (delete-region (point)(1+ (point)))
+ ;; (insert (quoted-printable-quote-char chr))
+ (insert
+ ?=
+ (aref quoted-printable-hex-chars (ash chr -4))
+ (aref quoted-printable-hex-chars (logand chr 15)))
+ (setq col (+ col 3)))))))))))
(defvar quoted-printable-external-encoder '("mmencode" "-q")
(as-binary-process
(apply (function call-process-region)
start end (car quoted-printable-external-encoder)
- t t nil (cdr quoted-printable-external-encoder))
- )
+ t t nil
+ (cdr quoted-printable-external-encoder)))
;; for OS/2
;; regularize line break code
(goto-char (point-min))
(while (re-search-forward "\r$" nil t)
- (replace-match "")
- )
- )))
+ (replace-match "")))))
(defvar quoted-printable-internal-encoding-limit
(require 'path-util)
(if (exec-installed-p "mmencode")
1000
- (message "Don't found external encoder for Quoted-Printable!")
+ ;; XXX: Fix this message, or simply remove it.
+ ;; (message "Don't found external encoder for Quoted-Printable!")
nil))
"*limit size to use internal quoted-printable encoder.
If size of input to encode is larger than this limit,
otherwise it calls external quoted-printable encoder specified by
`quoted-printable-external-encoder'. In this case, you must install
the program (maybe mmencode included in metamail or XEmacs package)."
- (interactive "r")
+ (interactive "*r")
(if (and quoted-printable-internal-encoding-limit
(> (- end start) quoted-printable-internal-encoding-limit))
(quoted-printable-external-encode-region start end)
- (quoted-printable-internal-encode-region start end)
- ))
-
+ (quoted-printable-internal-encode-region start end)))
(defun quoted-printable-encode-string (string)
"Encode STRING to quoted-printable, and return the result."
(with-temp-buffer
(insert string)
(quoted-printable-encode-region (point-min)(point-max))
- (buffer-string)
- ))
+ (buffer-string)))
(mel-define-method-function
(mime-encode-region start end (nil "quoted-printable"))
'quoted-printable-encode-region)
-(mel-define-method mime-insert-encoded-file (filename
- (nil "quoted-printable"))
+(mel-define-method mime-insert-encoded-file (filename (nil "quoted-printable"))
"Encode contents of file FILENAME to quoted-printable, and insert the result.
It calls external quoted-printable encoder specified by
`quoted-printable-external-encoder'. So you must install the program
\(maybe mmencode included in metamail or XEmacs package)."
- (interactive (list (read-file-name "Insert encoded file: ")))
- (apply (function call-process) (car quoted-printable-external-encoder)
- filename t nil (cdr quoted-printable-external-encoder))
- )
+ (interactive "*fInsert encoded file: ")
+ (apply (function call-process)
+ (car quoted-printable-external-encoder)
+ filename t nil
+ (cdr quoted-printable-external-encoder)))
;;; @ Quoted-Printable decoder
(narrow-to-region start end)
(goto-char (point-min))
(while (search-forward "=" nil t)
- (let ((beg (match-beginning 0)))
- (cond ((looking-at "\n")
- (delete-region beg (match-end 0))
- )
- ((looking-at
- `,(concat "[" quoted-printable-hex-chars
- "][" quoted-printable-hex-chars "]"))
- (let* ((end (match-end 0))
- (hex (buffer-substring (match-beginning 0) end)))
- (delete-region beg end)
- (insert
- (logior
- (ash (quoted-printable-hex-char-to-num (aref hex 0)) 4)
- (quoted-printable-hex-char-to-num (aref hex 1))))
- ))
- (t
- ;; invalid
- ))
- )))))
+ (cond
+ ((eolp)
+ ;; unfold soft line break.
+ (delete-region (1- (point))(1+ (point))))
+ ((and (memq (char-after (point))
+ (eval-when-compile
+ ;; XXX: should provide char-list instead.
+ (string-to-char-list quoted-printable-hex-chars)))
+ (memq (char-after (1+ (point)))
+ (eval-when-compile
+ ;; XXX: should provide char-list instead.
+ (string-to-char-list quoted-printable-hex-chars))))
+ ;; encoded char.
+ (insert
+ (prog1
+ (logior
+ (ash (quoted-printable-hex-char-to-num (char-after (point))) 4)
+ (quoted-printable-hex-char-to-num (char-after (1+ (point)))))
+ (delete-region (1- (point))(+ 2 (point))))))
+ (t
+ ;; invalid encoding.
+ ))))))
(defvar quoted-printable-external-decoder '("mmencode" "-q" "-u")
"*list of quoted-printable decoder program name and its arguments.")
(as-binary-process
(apply (function call-process-region)
start end (car quoted-printable-external-decoder)
- t t nil (cdr quoted-printable-external-decoder))
- )))
+ t t nil
+ (cdr quoted-printable-external-decoder)))))
(defvar quoted-printable-internal-decoding-limit nil
otherwise it calls external quoted-printable decoder specified by
`quoted-printable-external-decoder'. In this case, you must install
the program (maybe mmencode included in metamail or XEmacs package)."
- (interactive "r")
+ (interactive "*r")
(if (and quoted-printable-internal-decoding-limit
(> (- end start) quoted-printable-internal-decoding-limit))
(quoted-printable-external-decode-region start end)
- (quoted-printable-internal-decode-region start end)
- ))
+ (quoted-printable-internal-decode-region start end)))
(defun quoted-printable-decode-string (string)
"Decode STRING which is encoded in quoted-printable, and return the result."
(nil "quoted-printable"))
"Decode and write current region encoded by quoted-printable 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: ")
(as-binary-process
(apply (function call-process-region)
start end (car quoted-printable-external-decoder)
nil nil nil
(append (cdr quoted-printable-external-decoder)
quoted-printable-external-decoder-option-to-specify-file
- (list filename))
- )))
+ (list filename)))))
\f
;;; @ Q-encoding encode/decode string
MODE allows `text', `comment', `phrase' or nil. Default value is
`phrase'."
(let ((specials (cdr (or (assq mode q-encoding-special-chars-alist)
- (assq 'phrase q-encoding-special-chars-alist)
- ))))
+ (assq 'phrase q-encoding-special-chars-alist)))))
(mapconcat (function
(lambda (chr)
(cond ((eq chr ? ) "_")
((or (< chr 32) (< 126 chr)
- (memq chr specials)
- )
- (quoted-printable-quote-char chr)
- )
+ (memq chr specials))
+ (quoted-printable-quote-char chr))
(t
- (char-to-string chr)
- ))
- ))
- string "")
- ))
+ (char-to-string chr)))))
+ string "")))
(defun q-encoding-decode-string (string)
"Decode STRING which is encoded in Q-encoding and return the result."
(h (setq l (quoted-printable-hex-char-to-num chr))
(prog1
(char-to-string (logior (ash h 4) l))
- (setq h nil)
- )
- )
- (t (char-to-string chr))
- )))
+ (setq h nil)))
+ (t (char-to-string chr)))))
string "")))
(mel-define-method-function (encoded-text-encode-string string (nil "Q"))
'q-encoding-encode-string)
(mel-define-method encoded-text-decode-string (string (nil "Q"))
- (if (and (string-match Q-encoded-text-regexp string)
- (string= string (match-string 0 string)))
+ (if (string-match (eval-when-compile
+ (concat "\\`" Q-encoded-text-regexp "\\'"))
+ string)
(q-encoding-decode-string string)
(error "Invalid encoded-text %s" string)))
(provide 'mel-q)
-;;; mel-q.el ends here
+;;; mel-q.el ends here.
-;;; mel-u.el: uuencode encoder/decoder for GNU Emacs
+;;; mel-u.el --- uuencode encoder/decoder.
-;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc.
+;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
-;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
+;; Author: MORIOKA Tomohiko <tomo@m17n.org>
;; Created: 1995/10/25
;; Keywords: uuencode
;; 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 'emu)
(require 'mime-def)
+(require 'path-util)
(mel-define-backend "x-uue")
variable `uuencode-external-encoder'."
(interactive "*r")
(save-excursion
- (as-binary-process (apply (function call-process-region)
- start end (car uuencode-external-encoder)
- t t nil (cdr uuencode-external-encoder))
- )
+ (as-binary-process
+ (apply (function call-process-region)
+ start end (car uuencode-external-encoder)
+ t t nil
+ (cdr uuencode-external-encoder)))
;; for OS/2
;; regularize line break code
(goto-char (point-min))
(while (re-search-forward "\r$" nil t)
- (replace-match "")
- )
- ))
+ (replace-match ""))))
(defun uuencode-external-decode-region (start end)
"Decode current region by unofficial uuencode format.
(if (re-search-forward "^begin [0-9]+ " nil t)
(if (looking-at ".+$")
(buffer-substring (match-beginning 0)
- (match-end 0))
- )))))
+ (match-end 0)))))))
(default-directory temporary-file-directory))
(if filename
(as-binary-process
(apply (function call-process-region)
start end (car uuencode-external-decoder)
- t nil nil (cdr uuencode-external-decoder))
+ t nil nil
+ (cdr uuencode-external-decoder))
(as-binary-input-file (insert-file-contents filename))
;; The previous line causes the buffer to be made read-only, I
;; do not pretend to understand the control flow leading to this
;; Use `inhibit-read-only' to avoid to force
;; buffer-read-only nil. - tomo.
(let ((inhibit-read-only t))
- (delete-file filename)
- )
- ))
- )))
+ (delete-file filename)))))))
(mel-define-method-function (mime-encode-region start end (nil "x-uue"))
'uuencode-external-encode-region)
"Insert file encoded by unofficial uuencode format.
This function uses external uuencode encoder which is specified by
variable `uuencode-external-encoder'."
- (interactive (list (read-file-name "Insert encoded file: ")))
- (call-process (car uuencode-external-encoder) filename t nil
- (file-name-nondirectory filename))
- )
+ (interactive "*fInsert encoded file: ")
+ (call-process (car uuencode-external-encoder)
+ filename t nil
+ (file-name-nondirectory filename)))
(mel-define-method mime-write-decoded-region (start end filename
(nil "x-uue"))
"Decode and write current region encoded by uuencode 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: ")
(save-excursion
(let ((file (save-excursion
(save-restriction
(if (re-search-forward "^begin [0-9]+ " nil t)
(if (looking-at ".+$")
(buffer-substring (match-beginning 0)
- (match-end 0))
- )))))
+ (match-end 0)))))))
(default-directory temporary-file-directory))
(if file
(as-binary-process
(apply (function call-process-region)
start end (car uuencode-external-decoder)
- nil nil nil (cdr uuencode-external-decoder))
- (rename-file file filename 'overwrites)
- )))))
+ nil nil nil
+ (cdr uuencode-external-decoder))
+ (rename-file file filename 'overwrites))))))
;;; @ end
(mel-define-backend "x-uuencode" ("x-uue"))
-;;; mel-u.el ends here
+;;; mel-u.el ends here.
-;;; mel.el : a MIME encoding/decoding library
+;;; mel.el --- A MIME encoding/decoding library.
;; Copyright (C) 1995,1996,1997,1998,1999 Free Software Foundation, Inc.
;; 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.
(require 'mime-def)
(require 'poem)
(require 'alist)
+(require 'path-util)
(defcustom mime-encoding-list
'("7bit" "8bit" "binary" "base64" "quoted-printable")
(defun mime-encoding-alist (&optional service)
"Return table of Content-Transfer-Encoding for completion."
- (mapcar #'list (mime-encoding-list service))
- )
+ (mapcar #'list (mime-encoding-list service)))
(defsubst mel-use-module (name encodings)
- (let (encoding)
- (while (setq encoding (car encodings))
- (set-alist 'mel-encoding-module-alist
- encoding
- (cons name (cdr (assoc encoding mel-encoding-module-alist))))
- (setq encodings (cdr encodings))
- )))
+ (while encodings
+ (set-alist 'mel-encoding-module-alist
+ (car encodings)
+ (cons name (cdr (assoc (car encodings)
+ mel-encoding-module-alist))))
+ (setq encodings (cdr encodings))))
(defsubst mel-find-function (service encoding)
(mel-find-function-from-obarray
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: ")))
+ (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-function (encoded-text-encode-string string (nil "B"))
'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)
(base64-decode-string string)
(error "Invalid encoded-text %s" string)))
)
(and (featurep 'mule)
(progn
(require 'path-util)
- (module-installed-p 'mel-b-ccl)
- )))
+ (module-installed-p 'mel-b-ccl))))
(defvar mel-q-ccl-module
(and (featurep 'mule)
(progn
(require 'path-util)
- (module-installed-p 'mel-q-ccl)
- )))
+ (module-installed-p 'mel-q-ccl))))
-(if mel-b-ccl-module
- (mel-use-module 'mel-b-ccl '("base64" "B"))
- )
+(when mel-b-ccl-module
+ (mel-use-module 'mel-b-ccl '("base64" "B")))
-(if mel-q-ccl-module
- (mel-use-module 'mel-q-ccl '("quoted-printable" "Q"))
- )
+(when mel-q-ccl-module
+ (mel-use-module 'mel-q-ccl '("quoted-printable" "Q")))
-(if base64-dl-module
- (mel-use-module 'mel-b-dl '("base64" "B"))
- )
+(when base64-dl-module
+ (mel-use-module 'mel-b-dl '("base64" "B")))
;;; @ region
"Encode region START to END of current buffer using ENCODING.
ENCODING must be string."
(interactive
- (list (region-beginning) (region-end)
- (completing-read "encoding: "
+ (list (region-beginning)(region-end)
+ (completing-read "Encoding: "
(mime-encoding-alist)
nil t "base64")))
- (funcall (mel-find-function 'mime-encode-region encoding) start end)
- )
+ (funcall (mel-find-function 'mime-encode-region encoding) start end))
;;;###autoload
"Decode region START to END of current buffer using ENCODING.
ENCODING must be string."
(interactive
- (list (region-beginning) (region-end)
- (completing-read "encoding: "
+ (list (region-beginning)(region-end)
+ (completing-read "Encoding: "
(mime-encoding-alist 'mime-decode-region)
nil t "base64")))
(funcall (mel-find-function 'mime-decode-region encoding)
(mel-define-service encoded-text-encode-string (string encoding)
- "Encode STRING as encoded-text using ENCODING.
-ENCODING must be string.")
+ "Encode STRING as encoded-text using ENCODING. ENCODING must be string.")
(mel-define-service encoded-text-decode-string (string encoding)
- "Decode STRING as encoded-text using ENCODING.
-ENCODING must be string.")
+ "Decode STRING as encoded-text using ENCODING. ENCODING must be string.")
(defun base64-encoded-length (string)
(* (/ (+ (length string) 2) 3) 4))
(defsubst Q-encoding-printable-char-p (chr mode)
(and (not (memq chr '(?= ?? ?_)))
- (<= ?\ chr)(<= chr ?~)
+ (<= ?\ chr)(<= chr ?~)
(cond ((eq mode 'text) t)
((eq mode 'comment)
- (not (memq chr '(?\( ?\) ?\\)))
- )
+ (not (memq chr '(?\( ?\) ?\\))))
(t
- (string-match "[A-Za-z0-9!*+/=_---]" (char-to-string chr))
- ))))
+ (string-match "[A-Za-z0-9!*+/=_---]" (char-to-string chr))))))
(defun Q-encoded-text-length (string &optional mode)
(let ((l 0)(i 0)(len (length string)) chr)
(if (or (Q-encoding-printable-char-p chr mode)
(eq chr ? ))
(setq l (+ l 1))
- (setq l (+ l 3))
- )
- (setq i (+ i 1)) )
+ (setq l (+ l 3)))
+ (setq i (+ i 1)))
l))
"Insert file FILENAME encoded by ENCODING format."
(interactive
(list (read-file-name "Insert encoded file: ")
- (completing-read "encoding: "
+ (completing-read "Encoding: "
(mime-encoding-alist)
nil t "base64")))
(funcall (mel-find-function 'mime-insert-encoded-file encoding)
"Decode and write current region encoded by ENCODING into FILENAME.
START and END are buffer positions."
(interactive
- (list (region-beginning) (region-end)
+ (list (region-beginning)(region-end)
(read-file-name "Write decoded region to file: ")
- (completing-read "encoding: "
+ (completing-read "Encoding: "
(mime-encoding-alist 'mime-write-decoded-region)
nil t "base64")))
(funcall (mel-find-function 'mime-write-decoded-region encoding)
;;; Code:
+(require 'poe)
+(require 'poem)
+(require 'pcustom)
(require 'mcharset)
+(require 'alist)
+
+(eval-when-compile (require 'cl)) ; list*
(eval-and-compile
(defconst mime-library-product ["Chao" (1 13 0) "JR Fujinomori"]
(require 'custom)
-(eval-when-compile (require 'cl))
-
-(defgroup mime nil
+(defgroup mime '((default-mime-charset custom-variable))
"Emacs MIME Interfaces"
:group 'news
:group 'mail)
-(custom-handle-keyword 'default-mime-charset :group 'mime
- 'custom-variable)
-
(defcustom mime-uuencode-encoding-name-list '("x-uue" "x-uuencode")
"*List of encoding names for uuencode format."
:group 'mime
(make-variable-buffer-local 'mime-message-structure)
+
+;;; @ for mm-backend
+;;;
+
+(defvar mime-entity-implementation-alist nil)
+
+(defmacro mm-define-backend (type &optional parents)
+ "Define TYPE as a mm-backend.
+If PARENTS is specified, TYPE inherits PARENTS.
+Each parent must be backend name (symbol)."
+ (if parents
+ `(let ((rest ',(reverse parents)))
+ (while rest
+ (set-alist 'mime-entity-implementation-alist
+ ',type
+ (copy-alist
+ (cdr (assq (car rest)
+ mime-entity-implementation-alist))))
+ (setq rest (cdr rest))
+ ))))
+
+(defmacro mm-define-method (name args &rest body)
+ "Define NAME as a method function of (nth 1 (car ARGS)) backend.
+
+ARGS is like an argument list of lambda, but (car ARGS) must be
+specialized parameter. (car (car ARGS)) is name of variable and (nth
+1 (car ARGS)) is name of backend."
+ (let* ((specializer (car args))
+ (class (nth 1 specializer))
+ (self (car specializer)))
+ `(let ((imps (cdr (assq ',class mime-entity-implementation-alist)))
+ (func (lambda ,(if self
+ (cons self (cdr args))
+ (cdr args))
+ ,@body)))
+ (if imps
+ (set-alist 'mime-entity-implementation-alist
+ ',class (put-alist ',name func imps))
+ (set-alist 'mime-entity-implementation-alist
+ ',class
+ (list (cons ',name func)))
+ ))))
+
+(put 'mm-define-method 'lisp-indent-function 'defun)
+
+(eval-when-compile
+ (defmacro eval-module-depended-macro (module definition)
+ (condition-case nil
+ (progn
+ (require (eval module))
+ definition)
+ (error `(eval-after-load ,(symbol-name (eval module)) ',definition))
+ ))
+ )
+
(make-obsolete-variable 'mime-message-structure "should not use it.")
<h1> Network representation of header
<node> encoded-word
<p>
-encoded-word \e$B$O\e(B header \e$B$GHs\e(B <dref>ASCII</dref> \e$BJ8;z$rI=8=$9$k$?$a$N7A\e(B
-\e$B<0$G!"\e(B<concept>RFC 2047</concept> \e$B$GDj5A$5$l$F$$$^$9!#\e(B
+<concept>RFC 2047</concept> defines the
+<concept>encoded-word</concept> which is a format to represent
+non-<dref>ASCII</dref> characters in a header.
<p>
<rfc number="2047" type="Standards Track" author="K. Moore"
title="MIME (Multipurpose Internet Mail Extensions) Part
Three: Message Header Extensions for Non-ASCII Text"
date="November 1996" obsolete="1521,1522,1590">
<p>
-\e$B$^$?!"9T57$N0-$$$3$H$@$H8@$($^$9$,!"\e(Bencoded-word \e$B$rMQ$$$:$KHs\e(B
-<dref>ASCII</dref> \e$BJ8;z$r\e(B header \e$B$KF~$l$?5-;v$bB8:_$7$^$9!#\e(B
+The encoded-word is the only valid format to represent
+non-<dref>ASCII</dref> characters in a header, but there are also
+invalid styles. Such kinds of evil messages represent
+non-<dref>ASCII</dref> characters in headers without encoded-words (it
+is called "raw" non-<dref>ASCII</dref> characters).
<p>
-FLIM \e$B$O$3$l$i$rId9f2=!&I|9f2=$9$k5!G=$rDs6!$7$^$9!#\e(B
+FLIM provides encoding/decoding features of both encoded-word and
+invalid "raw" non-<dref>ASCII</dref> characters.
<h2> Header encoding/decoding
@chapter Network representation of header
@cindex RFC 2047
@cindex Standards Track
+@cindex encoded-word
@cindex RFC 2047
-encoded-word \e$B$O\e(B header \e$B$GHs\e(B ASCII (@ref{ASCII}) \e$BJ8;z$rI=8=$9$k$?$a$N7A<0\e(B
-\e$B$G!"\e(B@strong{RFC 2047} \e$B$GDj5A$5$l$F$$$^$9!#\e(B@refill
+@strong{RFC 2047} defines the @strong{encoded-word} which is a format to
+represent non-ASCII (@ref{ASCII}) characters in a header.@refill
@noindent
Track (obsolete RFC 1521,1522,1590).
@end quotation
-\e$B$^$?!"9T57$N0-$$$3$H$@$H8@$($^$9$,!"\e(Bencoded-word \e$B$rMQ$$$:$KHs\e(B ASCII
-(@ref{ASCII}) \e$BJ8;z$r\e(B header \e$B$KF~$l$?5-;v$bB8:_$7$^$9!#\e(B@refill
+The encoded-word is the only valid format to represent non-ASCII
+(@ref{ASCII}) characters in a header, but there are also invalid styles.
+Such kinds of evil messages represent non-ASCII (@ref{ASCII}) characters
+in headers without encoded-words (it is called "raw" non-ASCII
+(@ref{ASCII}) characters).@refill
-FLIM \e$B$O$3$l$i$rId9f2=!&I|9f2=$9$k5!G=$rDs6!$7$^$9!#\e(B
+FLIM provides encoding/decoding features of both encoded-word and
+invalid "raw" non-ASCII (@ref{ASCII}) characters.
@menu
;;; Code:
-(require 'std11)
(require 'mime-def)
-
-(eval-when-compile (require 'cl))
+(require 'std11)
;;; @ lexical analyzer
;;; smtp.el --- basic functions to send mail with SMTP server
-;; Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1998, 1999 Free Software Foundation, Inc.
;; Author: Tomoji Kagatani <kagatani@rbc.ncl.omron.co.jp>
;; Simon Leinen <simon@switch.ch> (ESMTP support)
-;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
+;; Shuhei KOBAYASHI <shuhei@aqua.ocn.ne.jp>
;; Keywords: SMTP, mail
;; This file is part of FLIM (Faithful Library about Internet Message).
;; 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 'mail-utils) ; pick up mail-strip-quoted-names
+(require 'poe)
+(require 'poem)
+(require 'pcustom)
+(require 'mail-utils) ; mail-strip-quoted-names
+
+(eval-when-compile (require 'cl)) ; push
(defgroup smtp nil
"SMTP protocol for sending mail."
:type '(choice (const nil) string)
:group 'smtp)
-(defvar smtp-debug-info nil)
+(defcustom smtp-debug-info nil
+ "*smtp debug info printout. messages and process buffer."
+ :type 'boolean
+ :group 'smtp)
+
(defvar smtp-read-point nil)
(defun smtp-make-fqdn ()
;;; smtpmail.el --- SMTP interface for mail-mode
-;; Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1996, 1998, 1999 Free Software Foundation, Inc.
;; Author: Tomoji Kagatani <kagatani@rbc.ncl.omron.co.jp>
;; Keywords: mail
;; 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
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; 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.
;;; Commentary:
;;; Code:
+(require 'poe)
+(require 'pcustom)
(require 'smtp)
(require 'sendmail)
(require 'time-stamp)
+(eval-when-compile (require 'static))
+
+(static-when (featurep 'xemacs)
+ (define-obsolete-variable-alias 'smtpmail-default-smtp-server
+ 'smtp-default-server)
+ (define-obsolete-variable-alias 'smtpmail-smtp-server 'smtp-server)
+ (define-obsolete-variable-alias 'smtpmail-smtp-service 'smtp-service)
+ (define-obsolete-variable-alias 'smtpmail-local-domain 'smtp-local-domain)
+ (define-obsolete-variable-alias 'smtpmail-debug-info 'smtp-debug-info)
+ )
+
;;;
(defcustom smtpmail-queue-mail nil
(backward-char 1)
(setq delimline (point-marker))
;; (sendmail-synch-aliases)
- (if mail-aliases
+ (if (and mail-aliases (fboundp 'expand-mail-aliases)) ; XEmacs
(expand-mail-aliases (point-min) delimline))
(goto-char (point-min))
;; ignore any blank lines in the header
;;; Code:
-(or (fboundp 'buffer-substring-no-properties)
- (require 'poe))
-
-(require 'custom)
+(require 'poe)
+(require 'poem) ; find-non-ascii-charset-string
+(require 'pcustom) ; std11-lexical-analyzer
;;; @ fetch