From 28ac5b99918745ed6b794a81a515c5d6de2ef836 Mon Sep 17 00:00:00 2001 From: morioka Date: Mon, 11 May 1998 14:32:11 +0000 Subject: [PATCH] (mime-content-type-primary-type): New function. (mime-content-type-subtype): New function. (mime-content-type-parameters): New function. (mime-parse-message): Use 'mime-content-type-primary-type, 'mime-content-type-subtype and 'mime-content-type-parameters. --- mime-parse.el | 64 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/mime-parse.el b/mime-parse.el index c460932..72ecfe6 100644 --- a/mime-parse.el +++ b/mime-parse.el @@ -68,6 +68,10 @@ (substring str e) )))) + +;;; @ Content-Type +;;; + (defun mime-parse-Content-Type (string) "Parse STRING as field-body of Content-Type field. Return value is @@ -90,6 +94,30 @@ are string." (cons (intern type) (cons (intern subtype) (nreverse dest))) ))) +(defun mime-read-Content-Type () + "Read field-body of Content-Type field from current-buffer, +and return parsed it. Format of return value is as same as +`mime-parse-Content-Type'." + (let ((str (std11-field-body "Content-Type"))) + (if str + (mime-parse-Content-Type str) + ))) + +(defsubst mime-content-type-primary-type (content-type) + "Return primary-type of CONTENT-TYPE." + (car content-type)) + +(defsubst mime-content-type-subtype (content-type) + "Return primary-type of CONTENT-TYPE." + (cadr content-type)) + +(defsubst mime-content-type-parameters (content-type) + "Return primary-type of CONTENT-TYPE." + (cddr content-type)) + + +;;; @ Content-Disposition +;;; (defconst mime-disposition-type-regexp mime-token-regexp) @@ -108,19 +136,18 @@ are string." (cons ctype (nreverse dest)) ))) - -;;; @ field reader -;;; - -(defun mime-read-Content-Type () - "Read field-body of Content-Type field from current-buffer, -and return parsed it. Format of return value is as same as -`mime-parse-Content-Type'." - (let ((str (std11-field-body "Content-Type"))) +(defun mime/Content-Disposition () + "Read field-body of Content-Disposition field from current-buffer, +and return parsed it. [mime-parse.el]" + (let ((str (std11-field-body "Content-Disposition"))) (if str - (mime-parse-Content-Type str) + (mime-parse-Content-Disposition str) ))) + +;;; @ Content-Transfer-Encoding +;;; + (defun mime/Content-Transfer-Encoding (&optional default-encoding) "Read field-body of Content-Transfer-Encoding field from current-buffer, and return it. @@ -136,14 +163,6 @@ If is is not found, return DEFAULT-ENCODING. [mime-parse.el]" default-encoding) )) -(defun mime/Content-Disposition () - "Read field-body of Content-Disposition field from current-buffer, -and return parsed it. [mime-parse.el]" - (let ((str (std11-field-body "Content-Disposition"))) - (if str - (mime-parse-Content-Disposition str) - ))) - ;;; @ message parser ;;; @@ -222,11 +241,10 @@ DEFAULT-CTL is used when an entity does not have valid Content-Type field. Its format must be as same as return value of mime-{parse|read}-Content-Type." (setq default-ctl (or (mime-read-Content-Type) default-ctl)) - (let ((primtype (car default-ctl)) - (subtype (car (cdr default-ctl))) - (params (cdr (cdr default-ctl))) - (encoding (or (mime/Content-Transfer-Encoding) default-encoding)) - ) + (let ((primtype (mime-content-type-primary-type default-ctl)) + (subtype (mime-content-type-subtype default-ctl)) + (params (mime-content-type-parameters default-ctl)) + (encoding (or (mime/Content-Transfer-Encoding) default-encoding))) (let ((boundary (assoc "boundary" params))) (cond (boundary (setq boundary (std11-strip-quoted-string (cdr boundary))) -- 1.7.10.4