Synch with Oort Gnus.
[elisp/gnus.git-] / lisp / mm-uu.el
index f36a5fd..0ff83a9 100644 (file)
@@ -1,5 +1,5 @@
 ;;; mm-uu.el --- Return uu stuff as mm handles
-;; Copyright (c) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+;; Copyright (c) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
 ;; Keywords: postscript uudecode binhex shar forward gnatsweb pgp
@@ -29,7 +29,7 @@
 (require 'mail-parse)
 (require 'nnheader)
 (require 'mm-decode)
-(require 'mailcap)
+(require 'gnus-mailcap)
 (require 'mml2015)
 
 (autoload 'uudecode-decode-region "uudecode")
@@ -40,6 +40,9 @@
 (autoload 'binhex-decode-region-external "binhex")
 (autoload 'binhex-decode-region-internal "binhex")
 
+(autoload 'yenc-decode-region "yenc")
+(autoload 'yenc-extract-filename "yenc")
+
 (defcustom mm-uu-decode-function 'uudecode-decode-region
   "*Function to uudecode.
 Internal function is done in Lisp by default, therefore decoding may
@@ -61,8 +64,10 @@ decoder, such as hexbin."
                 (function-item :tag "External" binhex-decode-region-external))
   :group 'gnus-article-mime)
 
+(defvar mm-uu-yenc-decode-function 'yenc-decode-region)
+
 (defvar mm-uu-pgp-beginning-signature
-     "^-----BEGIN PGP SIGNATURE-----")
+  "^-----BEGIN PGP SIGNATURE-----")
 
 (defvar mm-uu-beginning-regexp nil)
 
@@ -80,7 +85,7 @@ This can be either \"inline\" or \"attachment\".")
      mm-uu-postscript-extract
      nil)
     (uu
-     "^begin[ \t]+[0-7][0-7][0-7][ \t]+"
+     "^begin[ \t]+0?[0-7][0-7][0-7][ \t]+"
      "^end[ \t]*$"
      mm-uu-uu-extract
      mm-uu-uu-filename)
@@ -90,6 +95,11 @@ This can be either \"inline\" or \"attachment\".")
      mm-uu-binhex-extract
      nil
      mm-uu-binhex-filename)
+    (yenc
+     "^=ybegin.*size=[0-9]+.*name=.*$"
+     "^=yend.*size=[0-9]+"
+     mm-uu-yenc-extract
+     mm-uu-yenc-filename)
     (shar
      "^#! */bin/sh"
      "^exit 0$"
@@ -177,12 +187,12 @@ Return that buffer."
   (if symbol (set-default symbol value))
   (setq mm-uu-beginning-regexp nil)
   (mapcar (lambda (entry)
-            (if (mm-uu-configure-p (mm-uu-type entry) 'disabled)
-                nil
-              (setq mm-uu-beginning-regexp
-                    (concat mm-uu-beginning-regexp
-                            (if mm-uu-beginning-regexp "\\|")
-                            (mm-uu-beginning-regexp entry)))))
+           (if (mm-uu-configure-p (mm-uu-type entry) 'disabled)
+               nil
+             (setq mm-uu-beginning-regexp
+                   (concat mm-uu-beginning-regexp
+                           (if mm-uu-beginning-regexp "\\|")
+                           (mm-uu-beginning-regexp entry)))))
          mm-uu-type-alist))
 
 (mm-uu-configure)
@@ -205,6 +215,12 @@ Return that buffer."
        (ignore-errors
          (binhex-decode-region start-point end-point t))))
 
+(defun mm-uu-yenc-filename ()
+  (goto-char start-point)
+  (setq file-name
+       (ignore-errors
+         (yenc-extract-filename))))
+
 (defun mm-uu-forward-test ()
   (save-excursion
     (goto-char start-point)
@@ -262,6 +278,19 @@ Return that buffer."
                      (list mm-dissect-disposition
                            (cons 'filename file-name)))))
 
+(defun mm-uu-yenc-extract ()
+  (mm-make-handle (mm-uu-copy-to-buffer start-point end-point)
+                 (list (or (and file-name
+                                (string-match "\\.[^\\.]+$" file-name)
+                                (mailcap-extension-to-mime
+                                 (match-string 0 file-name)))
+                           "application/octet-stream"))
+                 'x-yenc nil
+                 (if (and file-name (not (equal file-name "")))
+                     (list mm-dissect-disposition
+                           (cons 'filename file-name)))))
+
+
 (defun mm-uu-shar-extract ()
   (mm-make-handle (mm-uu-copy-to-buffer start-point end-point)
                  '("application/x-shar")))