From 27f39dbb4a2c3dd01e0ee97f62217c0f972a4d93 Mon Sep 17 00:00:00 2001 From: morioka Date: Fri, 26 Jun 1998 07:24:51 +0000 Subject: [PATCH] Sync up with chao-1_6_1. --- ChangeLog | 87 +++++++++++++++++++++++++++++++++++ FLIM-VERSION | 3 +- eword-decode.el | 77 ------------------------------- mime-def.el | 68 +++++++++++---------------- mime-parse.el | 45 +++++++----------- mime.el | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 266 insertions(+), 152 deletions(-) diff --git a/ChangeLog b/ChangeLog index b352973..3707749 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,90 @@ +1998-06-26 MORIOKA Tomohiko + + * mime.el (mime-entity-encoding): New implementation. + + * mime-parse.el (mime-parse-message): Abolish argument `encoding'. + + * mime-def.el (make-mime-entity-internal): Abolish argument + `encoding'. + (mime-entity-set-encoding-internal): New function. + +1998-06-26 MORIOKA Tomohiko + + * mime.el (mime-entity-content-disposition): New implementation. + + * mime-parse.el (mime-parse-message): Don't parse + Content-Disposition. + + * mime-def.el (make-mime-entity-internal): Delete argument + `content-disposition'. + (mime-entity-set-content-disposition-internal): New function. + +1998-06-25 MORIOKA Tomohiko + + * eword-decode.el: Move function `eword-visible-field-p' and + `mime-insert-decoded-header' to mime.el. + + * mime-parse.el: Use internal functions of mime-entity. + + * mime.el (mime-entity-children): Moved from mime-def.el; use + `mime-entity-children-internal'. + (mime-entity-node-id): Moved from mime-def.el; use + `mime-entity-node-id-internal'. + (mime-entity-number): Moved from mime-def.el; use + `mime-entity-node-id-internal'. + (mime-entity-buffer): Moved from mime-def.el; use + `mime-entity-buffer-internal'. + (mime-entity-point-min): Moved from mime-def.el; use + `mime-entity-header-start-internal'. + (mime-entity-point-max): Moved from mime-def.el; use + `mime-entity-body-end-internal'. + (mime-entity-header-start): Moved from mime-def.el; use + `mime-entity-header-start-internal'. + (mime-entity-header-end): Moved from mime-def.el; use + `mime-entity-header-end-internal'. + (mime-entity-content-type): Moved from mime-def.el; use + `mime-entity-content-type-internal'. + (mime-entity-content-disposition): Moved from mime-def.el; use + `mime-entity-content-disposition-internal'. + (mime-entity-encoding): Moved from mime-def.el; use + `mime-entity-encoding-internal'. + (mime-fetch-field): Use `mime-entity-original-header-internal' and + `mime-entity-set-original-header-internal'. + (mime-read-field): Use `mime-entity-parsed-header-internal' and + `mime-entity-set-parsed-header-internal'. + (eword-visible-field-p): Moved from eword-decode.el. + (mime-insert-decoded-header): Moved from eword-decode.el. + (mime-entity-body-start): Moved from mime-def.el; use + `mime-entity-body-start-internal'. + (mime-entity-body-end): Moved from mime-def.el; use + `mime-entity-body-end-internal'. + (mime-entity-media-type): Moved from mime-def.el. + (mime-entity-media-subtype): Moved from mime-def.el. + (mime-entity-parameters): Moved from mime-def.el. + (mime-entity-type/subtype): Moved from mime-def.el. + + * mime-def.el (make-mime-entity-internal): Renamed from + `make-mime-entity'. + (mime-entity-buffer-internal): New function. + (mime-entity-header-start-internal): New function. + (mime-entity-header-end-internal): New function. + (mime-entity-body-start-internal): New function. + (mime-entity-body-end-internal): New function. + (mime-entity-node-id-internal): New function. + (mime-entity-content-type-internal): New function. + (mime-entity-content-disposition-internal): New function. + (mime-entity-encoding-internal): New function. + (mime-entity-original-header-internal): New function. + (mime-entity-children-internal): New function. + (mime-entity-parsed-header-internal): New function. + (mime-entity-set-original-header-internal): Renamed from + `mime-entity-set-original-header'. + (mime-entity-set-children-internal): Renamed from + `mime-entity-set-children'. + (mime-entity-set-parsed-header-internal): Renamed from + `mime-entity-set-parsed-header'. Move `mime-entity-SLOT' + functions to mime.el. + 1998-06-25 MORIOKA Tomohiko * mime-ja.sgml (CVS): Fix typo. diff --git a/FLIM-VERSION b/FLIM-VERSION index 881bd0d..fa299a3 100644 --- a/FLIM-VERSION +++ b/FLIM-VERSION @@ -6,7 +6,7 @@ ;; Kinki Nippon Railway $(B6a5&F|K\E4F;(B http://www.kintetsu.co.jp/ ;; Ky-Dòto-A Line $(B5~ET@~(B ;;------------------------------------------------------------------------- -1.0.1 Ky-Dòto-A $(B5~ET(B ; <=> JR +1.0.1 Ky-Dòto-A $(B5~ET(B ; <=> JR, $(B5~ET;T8rDL6I(B 1.1.0 T-Dòji-A $(BEl;{(B 1.2.0 J-Dþjò-A $(B==>r(B 1.2.1 Kamitobaguchi $(B>eD;1)8}(B @@ -31,3 +31,4 @@ 1.3.0 Kuinabashi $(B$/$$$J66(B 1.4.0 J-Dþjò-A $(B==>r(B 1.6.0 Kuj-Dò-A $(B6e>r(B +1.6.1 Ky-Dòto-A $(B5~ET(B ; <=> JR, $(B6aE4(B diff --git a/eword-decode.el b/eword-decode.el index 5280aeb..f0e74e5 100644 --- a/eword-decode.el +++ b/eword-decode.el @@ -254,83 +254,6 @@ If SEPARATOR is not nil, it is used as header separator." )) ))) -(defun eword-visible-field-p (field-name visible-fields invisible-fields) - (or (catch 'found - (while visible-fields - (let ((regexp (car visible-fields))) - (if (string-match regexp field-name) - (throw 'found t) - )) - (setq visible-fields (cdr visible-fields)) - )) - (catch 'found - (while invisible-fields - (let ((regexp (car invisible-fields))) - (if (string-match regexp field-name) - (throw 'found nil) - )) - (setq invisible-fields (cdr invisible-fields)) - ) - t))) - -(defun mime-insert-decoded-header (entity - &optional invisible-fields visible-fields - code-conversion) - "Insert before point a decoded header of ENTITY." - (let ((default-charset - (if code-conversion - (if (mime-charset-to-coding-system code-conversion) - code-conversion - default-mime-charset)))) - (save-restriction - (narrow-to-region (point)(point)) - (let ((the-buf (current-buffer)) - (src-buf (mime-entity-buffer entity)) - (h-end (mime-entity-header-end entity)) - beg p end field-name len field) - (save-excursion - (set-buffer src-buf) - (goto-char (mime-entity-header-start entity)) - (save-restriction - (narrow-to-region (point) h-end) - (while (re-search-forward std11-field-head-regexp nil t) - (setq beg (match-beginning 0) - p (match-end 0) - field-name (buffer-substring beg (1- p)) - len (string-width field-name) - end (std11-field-end)) - (when (eword-visible-field-p field-name - visible-fields invisible-fields) - (setq field (intern (capitalize field-name))) - (save-excursion - (set-buffer the-buf) - (insert field-name) - (insert ":") - (cond ((memq field eword-decode-ignored-field-list) - ;; Don't decode - (insert-buffer-substring src-buf p end) - ) - ((memq field eword-decode-structured-field-list) - ;; Decode as structured field - (let ((body (save-excursion - (set-buffer src-buf) - (buffer-substring p end))) - (default-mime-charset default-charset)) - (insert (eword-decode-and-fold-structured-field - body (1+ len))) - )) - (t - ;; Decode as unstructured field - (let ((body (save-excursion - (set-buffer src-buf) - (buffer-substring p end))) - (default-mime-charset default-charset)) - (insert (eword-decode-unstructured-field-body - body (1+ len))) - ))) - (insert "\n") - ))))))))) - ;;; @ encoded-word decoder ;;; diff --git a/mime-def.el b/mime-def.el index 7cb0f7b..a7509d5 100644 --- a/mime-def.el +++ b/mime-def.el @@ -182,52 +182,38 @@ ;;; @ MIME entity ;;; -(defsubst make-mime-entity (buffer - header-start header-end body-start body-end - &optional node-id - content-type content-disposition - encoding children) +(defsubst make-mime-entity-internal (buffer + header-start header-end + body-start body-end + &optional node-id + content-type children) (vector buffer header-start header-end body-start body-end - node-id content-type content-disposition encoding nil - children nil)) - -(defsubst mime-entity-buffer (entity) (aref entity 0)) -(defsubst mime-entity-header-start (entity) (aref entity 1)) -(defsubst mime-entity-header-end (entity) (aref entity 2)) -(defsubst mime-entity-body-start (entity) (aref entity 3)) -(defsubst mime-entity-body-end (entity) (aref entity 4)) -(defsubst mime-entity-node-id (entity) (aref entity 5)) -(defsubst mime-entity-content-type (entity) (aref entity 6)) -(defsubst mime-entity-content-disposition (entity) (aref entity 7)) -(defsubst mime-entity-encoding (entity) (aref entity 8)) -(defsubst mime-entity-original-header (entity) (aref entity 9)) -(defsubst mime-entity-children (entity) (aref entity 10)) -(defsubst mime-entity-parsed-header (entity) (aref entity 11)) - -(defsubst mime-entity-set-original-header (entity header) + node-id content-type nil nil nil children nil)) + +(defsubst mime-entity-buffer-internal (entity) (aref entity 0)) +(defsubst mime-entity-header-start-internal (entity) (aref entity 1)) +(defsubst mime-entity-header-end-internal (entity) (aref entity 2)) +(defsubst mime-entity-body-start-internal (entity) (aref entity 3)) +(defsubst mime-entity-body-end-internal (entity) (aref entity 4)) +(defsubst mime-entity-node-id-internal (entity) (aref entity 5)) +(defsubst mime-entity-content-type-internal (entity) (aref entity 6)) +(defsubst mime-entity-content-disposition-internal (entity) (aref entity 7)) +(defsubst mime-entity-encoding-internal (entity) (aref entity 8)) +(defsubst mime-entity-original-header-internal (entity) (aref entity 9)) +(defsubst mime-entity-children-internal (entity) (aref entity 10)) +(defsubst mime-entity-parsed-header-internal (entity) (aref entity 11)) + +(defsubst mime-entity-set-content-disposition-internal (entity disposition) + (aset entity 7 disposition)) +(defsubst mime-entity-set-encoding-internal (entity encoding) + (aset entity 8 encoding)) +(defsubst mime-entity-set-original-header-internal (entity header) (aset entity 9 header)) -(defsubst mime-entity-set-children (entity children) +(defsubst mime-entity-set-children-internal (entity children) (aset entity 10 children)) -(defsubst mime-entity-set-parsed-header (entity header) +(defsubst mime-entity-set-parsed-header-internal (entity header) (aset entity 11 header)) -(defsubst mime-entity-number (entity) - (reverse (mime-entity-node-id entity))) - -(defalias 'mime-entity-point-min 'mime-entity-header-start) -(defalias 'mime-entity-point-max 'mime-entity-body-end) - -(defsubst mime-entity-media-type (entity) - (mime-content-type-primary-type (mime-entity-content-type entity))) -(defsubst mime-entity-media-subtype (entity) - (mime-content-type-subtype (mime-entity-content-type entity))) -(defsubst mime-entity-parameters (entity) - (mime-content-type-parameters (mime-entity-content-type entity))) - -(defsubst mime-entity-type/subtype (entity-info) - (mime-type/subtype-string (mime-entity-media-type entity-info) - (mime-entity-media-subtype entity-info))) - ;;; @ message structure ;;; diff --git a/mime-parse.el b/mime-parse.el index 87df395..3201a9f 100644 --- a/mime-parse.el +++ b/mime-parse.el @@ -152,7 +152,7 @@ If is is not found, return DEFAULT-ENCODING." (defun mime-parse-multipart (entity) (goto-char (point-min)) - (let* ((content-type (mime-entity-content-type entity)) + (let* ((content-type (mime-entity-content-type-internal entity)) (dash-boundary (concat "--" (mime-content-type-parameter content-type "boundary"))) (delimiter (concat "\n" (regexp-quote dash-boundary))) @@ -163,9 +163,9 @@ If is is not found, return DEFAULT-ENCODING." (make-mime-content-type 'message 'rfc822) (make-mime-content-type 'text 'plain) )) - (header-end (mime-entity-header-end entity)) - (body-end (mime-entity-body-end entity)) - (node-id (mime-entity-node-id entity)) + (header-end (mime-entity-header-end-internal entity)) + (body-end (mime-entity-body-end-internal entity)) + (node-id (mime-entity-node-id-internal entity)) cb ce ret ncb children (i 0)) (save-restriction (goto-char body-end) @@ -181,7 +181,7 @@ If is is not found, return DEFAULT-ENCODING." (setq ncb (match-end 0)) (save-restriction (narrow-to-region cb ce) - (setq ret (mime-parse-message dc-ctl "7bit" (cons i node-id))) + (setq ret (mime-parse-message dc-ctl (cons i node-id))) ) (setq children (cons ret children)) (goto-char (setq cb ncb)) @@ -190,26 +190,26 @@ If is is not found, return DEFAULT-ENCODING." (setq ce (point-max)) (save-restriction (narrow-to-region cb ce) - (setq ret (mime-parse-message dc-ctl "7bit" (cons i node-id))) + (setq ret (mime-parse-message dc-ctl (cons i node-id))) ) (setq children (cons ret children)) ) - (mime-entity-set-children entity (nreverse children)) + (mime-entity-set-children-internal entity (nreverse children)) entity)) (defun mime-parse-encapsulated (entity) - (mime-entity-set-children + (mime-entity-set-children-internal entity (save-restriction - (narrow-to-region (mime-entity-body-start entity) - (mime-entity-body-end entity)) + (narrow-to-region (mime-entity-body-start-internal entity) + (mime-entity-body-end-internal entity)) (list (mime-parse-message - nil nil (cons 0 (mime-entity-node-id entity)))) + nil (cons 0 (mime-entity-node-id-internal entity)))) )) entity) ;;;###autoload -(defun mime-parse-message (&optional default-ctl default-encoding node-id) +(defun mime-parse-message (&optional default-ctl node-id) "Parse current-buffer as a MIME message. DEFAULT-CTL is used when an entity does not have valid Content-Type field. Its format must be as same as return value of @@ -218,9 +218,7 @@ mime-{parse|read}-Content-Type." header-end body-start (body-end (point-max)) - content-type content-disposition encoding - primary-type - entity) + content-type primary-type entity) (goto-char header-start) (if (re-search-forward "^$" nil t) (setq header-end (match-end 0) @@ -236,23 +234,12 @@ mime-{parse|read}-Content-Type." (mime-parse-Content-Type str) )) default-ctl) - content-disposition (let ((str (std11-fetch-field - "Content-Disposition"))) - (if str - (mime-parse-Content-Disposition str) - )) - encoding (let ((str (std11-fetch-field - "Content-Transfer-Encoding"))) - (if str - (mime-parse-Content-Transfer-Encoding str) - default-encoding)) primary-type (mime-content-type-primary-type content-type)) ) (setq entity - (make-mime-entity (current-buffer) - header-start header-end body-start body-end - node-id - content-type content-disposition encoding nil)) + (make-mime-entity-internal + (current-buffer) header-start header-end body-start body-end + node-id content-type)) (cond ((eq primary-type 'multipart) (mime-parse-multipart entity) ) diff --git a/mime.el b/mime.el index 8e3615b..0ba74c9 100644 --- a/mime.el +++ b/mime.el @@ -63,6 +63,13 @@ current-buffer, and return it.") ;;; @ Entity as node of message ;;; +(defalias 'mime-entity-children 'mime-entity-children-internal) + +(defalias 'mime-entity-node-id 'mime-entity-node-id-internal) + +(defsubst mime-entity-number (entity) + (reverse (mime-entity-node-id-internal entity))) + (defun mime-find-entity-from-number (entity-number &optional message) "Return entity from ENTITY-NUMBER in MESSAGE. If MESSAGE is not specified, `mime-message-structure' is used." @@ -98,15 +105,26 @@ ENTITY is used." (null (mime-entity-node-id entity))) +;;; @ Entity Buffer +;;; + +(defalias 'mime-entity-buffer 'mime-entity-buffer-internal) +(defalias 'mime-entity-point-min 'mime-entity-header-start-internal) +(defalias 'mime-entity-point-max 'mime-entity-body-end-internal) + + ;;; @ Entity Header ;;; +(defalias 'mime-entity-header-start 'mime-entity-header-start-internal) +(defalias 'mime-entity-header-end 'mime-entity-header-end-internal) + (defun mime-fetch-field (field-name &optional entity) (or (symbolp field-name) (setq field-name (intern (capitalize (capitalize field-name))))) (or entity (setq entity mime-message-structure)) - (let* ((header (mime-entity-original-header entity)) + (let* ((header (mime-entity-original-header-internal entity)) (field-body (cdr (assq field-name header)))) (or field-body (progn @@ -118,11 +136,32 @@ ENTITY is used." (setq field-body (std11-fetch-field (symbol-name field-name))) )) - (mime-entity-set-original-header + (mime-entity-set-original-header-internal entity (put-alist field-name field-body header)) ) field-body)))) +(defalias 'mime-entity-content-type 'mime-entity-content-type-internal) + +(defun mime-entity-content-disposition (entity) + (or (mime-entity-content-disposition-internal entity) + (let ((ret (mime-fetch-field 'Content-Disposition entity))) + (if ret + (let ((disposition (mime-parse-Content-Disposition ret))) + (when disposition + (mime-entity-set-content-disposition-internal + entity disposition) + disposition)))))) + +(defun mime-entity-encoding (entity) + (or (mime-entity-encoding-internal entity) + (let ((ret (mime-fetch-field 'Content-Transfer-Encoding entity))) + (if ret + (let ((encoding (mime-parse-Content-Transfer-Encoding ret))) + (when encoding + (mime-entity-set-encoding-internal entity encoding) + encoding)))))) + (defun mime-read-field (field-name &optional entity) (or (symbolp field-name) (setq field-name (capitalize (capitalize field-name)))) @@ -138,7 +177,7 @@ ENTITY is used." (mime-entity-encoding entity) ) (t - (let* ((header (mime-entity-parsed-header entity)) + (let* ((header (mime-entity-parsed-header-internal entity)) (field (cdr (assq field-name header)))) (or field (let ((field-body (mime-fetch-field field-name entity))) @@ -164,14 +203,94 @@ ENTITY is used." (setq field (eword-decode-unstructured-field-body field-body)) )) - (mime-entity-set-parsed-header + (mime-entity-set-parsed-header-internal entity (put-alist field-name field header)) field))))))) +(defun eword-visible-field-p (field-name visible-fields invisible-fields) + (or (catch 'found + (while visible-fields + (let ((regexp (car visible-fields))) + (if (string-match regexp field-name) + (throw 'found t) + )) + (setq visible-fields (cdr visible-fields)) + )) + (catch 'found + (while invisible-fields + (let ((regexp (car invisible-fields))) + (if (string-match regexp field-name) + (throw 'found nil) + )) + (setq invisible-fields (cdr invisible-fields)) + ) + t))) + +(defun mime-insert-decoded-header (entity + &optional invisible-fields visible-fields + code-conversion) + "Insert before point a decoded header of ENTITY." + (let ((default-charset + (if code-conversion + (if (mime-charset-to-coding-system code-conversion) + code-conversion + default-mime-charset)))) + (save-restriction + (narrow-to-region (point)(point)) + (let ((the-buf (current-buffer)) + (src-buf (mime-entity-buffer entity)) + (h-end (mime-entity-header-end entity)) + beg p end field-name len field) + (save-excursion + (set-buffer src-buf) + (goto-char (mime-entity-header-start entity)) + (save-restriction + (narrow-to-region (point) h-end) + (while (re-search-forward std11-field-head-regexp nil t) + (setq beg (match-beginning 0) + p (match-end 0) + field-name (buffer-substring beg (1- p)) + len (string-width field-name) + end (std11-field-end)) + (when (eword-visible-field-p field-name + visible-fields invisible-fields) + (setq field (intern (capitalize field-name))) + (save-excursion + (set-buffer the-buf) + (insert field-name) + (insert ":") + (cond ((memq field eword-decode-ignored-field-list) + ;; Don't decode + (insert-buffer-substring src-buf p end) + ) + ((memq field eword-decode-structured-field-list) + ;; Decode as structured field + (let ((body (save-excursion + (set-buffer src-buf) + (buffer-substring p end))) + (default-mime-charset default-charset)) + (insert (eword-decode-and-fold-structured-field + body (1+ len))) + )) + (t + ;; Decode as unstructured field + (let ((body (save-excursion + (set-buffer src-buf) + (buffer-substring p end))) + (default-mime-charset default-charset)) + (insert (eword-decode-unstructured-field-body + body (1+ len))) + ))) + (insert "\n") + ))))))))) + ;;; @ Entity Content ;;; +(defalias 'mime-entity-body-start 'mime-entity-body-start-internal) +(defalias 'mime-entity-body-end 'mime-entity-body-end-internal) + (defun mime-entity-content (entity) (save-excursion (set-buffer (mime-entity-buffer entity)) @@ -206,6 +325,17 @@ ENTITY is used." )))) +(defsubst mime-entity-media-type (entity) + (mime-content-type-primary-type (mime-entity-content-type entity))) +(defsubst mime-entity-media-subtype (entity) + (mime-content-type-subtype (mime-entity-content-type entity))) +(defsubst mime-entity-parameters (entity) + (mime-content-type-parameters (mime-entity-content-type entity))) +(defsubst mime-entity-type/subtype (entity-info) + (mime-type/subtype-string (mime-entity-media-type entity-info) + (mime-entity-media-subtype entity-info))) + + ;;; @ end ;;; -- 1.7.10.4