;;;
-;;; $Id: mel-b.el,v 2.0 1995/10/25 02:40:49 morioka Exp $
+;;; $Id: mel-b.el,v 3.0 1995/11/02 04:14:51 morioka Exp $
;;;
;;; @ variables
;;;
(defun base64-encode-string (string)
- (let* ((es (mapconcat
- (function
- (lambda (pack)
- (mapconcat (function char-to-string)
- (apply (function base64-encode-chars) pack)
- "")
- ))
- (pack-sequence string 3)
- ""))
- (m (mod (length es) 4))
- )
- (concat es (cond ((= m 3) "=")
- ((= m 2) "==")
- ))
- ))
+ (let ((len (length string))
+ (b 0)(e 57)
+ dest)
+ (while (< e len)
+ (setq dest
+ (concat dest
+ (mapconcat
+ (function
+ (lambda (pack)
+ (mapconcat (function char-to-string)
+ (apply (function base64-encode-chars) pack)
+ "")
+ ))
+ (pack-sequence (substring string b e) 3)
+ "")
+ "\n"))
+ (setq b e
+ e (+ e 57)
+ )
+ )
+ (let* ((es (mapconcat
+ (function
+ (lambda (pack)
+ (mapconcat (function char-to-string)
+ (apply (function base64-encode-chars) pack)
+ "")
+ ))
+ (pack-sequence (substring string b) 3)
+ ""))
+ (m (mod (length es) 4))
+ )
+ (concat dest es (cond ((= m 3) "=")
+ ((= m 2) "==")
+ ))
+ )))
(defun base64-decode-string (string)
(mapconcat (function
;;; @ encode/decode base64 region
;;;
+(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")
+ )
+ )))
+
(defun base64-internal-decode-region (beg end)
(save-excursion
(save-restriction
(insert (base64-decode-string str))
))))
-(defun base64-internal-encode-region (beg end)
- (save-excursion
- (let* ((str (base64-encode-string (buffer-substring beg end)))
- (len (length str))
- (i 0)
- (j (if (>= len 76)
- 76
- len))
- )
- (delete-region beg end)
- (goto-char beg)
- (while (< j len)
- (insert (substring str i j))
- (insert "\n")
- (setq i j)
- (setq j (+ i 76))
- )
- (insert (substring str i))
- )))
-
(cond ((boundp 'MULE)
(define-program-coding-system
nil (car base64-external-encoder) *noconv*)
(defun base64-external-encode-region (beg end)
(save-excursion
- (let ((selective-display nil) ;Disable ^M to nl translation.
- (mc-flag nil) ;Mule
- (kanji-flag nil)) ;NEmacs
- (apply (function call-process-region)
- beg end (car base64-external-encoder)
- t t nil (cdr base64-external-encoder))
+ (save-restriction
+ (narrow-to-region beg end)
+ (let ((selective-display nil) ;Disable ^M to nl translation.
+ (mc-flag nil) ;Mule
+ (kanji-flag nil)) ;NEmacs
+ (apply (function call-process-region)
+ beg end (car 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 "")
+ )
)))
(defun base64-external-decode-region (beg end)
;;;
-;;; $Id: mel-q.el,v 2.1 1995/10/25 05:00:54 morioka Exp $
+;;; $Id: mel-q.el,v 3.0 1995/11/02 03:48:01 morioka Exp $
;;;
;;; @ constants
(let ((i 0))
(mapconcat (function
(lambda (chr)
- (cond ((or (< chr 32) (< 126 chr) (eq chr ?=))
+ (cond ((eq chr ?\n)
+ (setq i 0)
+ "\n")
+ ((or (< chr 32) (< 126 chr) (eq chr ?=))
(if (>= i 73)
(progn
- (setq i 0)
+ (setq i 3)
(concat "=\n" (quoted-printable-quote-char chr))
)
(progn
)))
(t (if (>= i 75)
(progn
- (setq i 0)
+ (setq i 1)
(concat "=\n" (char-to-string chr))
)
(progn
(save-excursion
(save-restriction
(narrow-to-region beg end)
- (goto-char (point-min))
- (catch 'tag
- (let (b e str)
- (while t
- (beginning-of-line) (setq b (point))
- (end-of-line) (setq e (point))
- (if (< b e)
- (progn
- (setq str (buffer-substring b e))
- (delete-region b e)
- (insert (quoted-printable-encode-string str))
- ))
- (if (eobp)
- (throw 'tag nil)
- )
- (forward-char 1)
- )))
+ (let ((str (buffer-substring beg end)))
+ (delete-region beg end)
+ (insert (quoted-printable-encode-string str))
+ )
+ (or (bolp)
+ (insert "=\n")
+ )
)))
(defun quoted-printable-internal-decode-region (beg end)
(defun quoted-printable-external-encode-region (beg end)
(save-excursion
- (let ((selective-display nil) ;Disable ^M to nl translation.
- (mc-flag nil) ;Mule
- (kanji-flag nil)) ;NEmacs
- (apply (function call-process-region)
- beg end (car quoted-printable-external-encoder)
- t t nil (cdr quoted-printable-external-encoder))
+ (save-restriction
+ (narrow-to-region beg end)
+ (let ((selective-display nil) ;Disable ^M to nl translation.
+ (mc-flag nil) ;Mule
+ (kanji-flag nil)) ;NEmacs
+ (apply (function call-process-region)
+ beg end (car 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 "")
+ )
)))
(defun quoted-printable-external-decode-region (beg end)
;;;
-;;; $Id: mel-u.el,v 2.0 1995/10/30 06:01:29 morioka Exp $
+;;; $Id: mel-u.el,v 2.1 1995/11/01 06:03:14 morioka Exp $
;;;
;;; @ variables
;;;
+(defvar mime/tmp-dir (or (getenv "TM_TMP_DIR") "/tmp/"))
+
(defvar uuencode-external-encoder '("uuencode" "-")
"*list of uuencode encoder program name and its arguments.")
-(defvar uuencode-external-decoder '("uudecode")
+(defvar uuencode-external-decoder
+ (list "sh" "-c" (format "(cd %s; uudecode)" mime/tmp-dir))
"*list of uuencode decoder program name and its arguments.")
-(list "sh" "-c" (format "(cd %s; uudecode)" mime/tmp-dir))
-
-(defvar mime/tmp-dir (or (getenv "TM_TMP_DIR") "/tmp/"))
;;; @ external encoder
)
(if filename
(progn
- (funcall (function call-process-region)
- beg end "sh"
- t t nil
- "-c" (format "(cd %s; %s)"
- mime/tmp-dir
- (mapconcat (function identity)
- uuencode-external-decoder
- " ")
- ))
+ (apply (function call-process-region)
+ beg end (car uuencode-external-decoder)
+ t t nil (cdr uuencode-external-decoder))
(setq filename (expand-file-name filename mime/tmp-dir))
(let ((file-coding-system-for-read
(if (boundp 'MULE) *noconv*)) ; Mule
;;;
;;; by MORIOKA Tomohiko <morioka@jaist.ac.jp>, 1995/6/25
;;;
-;;; $Id: mel.el,v 3.1 1995/10/30 06:03:37 morioka Exp $
+;;; $Id: mel.el,v 3.2 1995/11/02 04:19:47 morioka Exp $
;;;
(autoload 'base64-encode-region "mel-b" nil t)
'(("base64" . base64-encode-region)
("quoted-printable" . quoted-printable-encode-region)
("x-uue" . uuencode-encode-region)
+ ("7bit")
+ ("8bit")
+ ("binary")
))
(defvar mime-decoding-method-alist