X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=mime-parse.el;h=493bbcb59943f553b04729fcabf870ac4f5e3b0d;hb=4e31f5213308fa82ca6280dc5a7a2b888fd918c7;hp=65e03c5c7ffe70c443899753b72d340117eaf955;hpb=4f1be3645b92f9626f566f9f81c86a042ee0f84a;p=elisp%2Fsemi.git diff --git a/mime-parse.el b/mime-parse.el index 65e03c5..493bbcb 100644 --- a/mime-parse.el +++ b/mime-parse.el @@ -1,12 +1,11 @@ ;;; mime-parse.el --- MIME message parser -;; Copyright (C) 1994,1995,1996,1997 Free Software Foundation, Inc. +;; Copyright (C) 1994,1995,1996,1997,1998 Free Software Foundation, Inc. ;; Author: MORIOKA Tomohiko -;; Version: $Id: mime-parse.el,v 0.21 1997-09-05 11:26:49 morioka Exp $ ;; Keywords: parse, MIME, multimedia, mail, news -;; This file is part of SEMI (SEMI is Emacs MIME Interfaces). +;; This file is part of SEMI (Spadework for Emacs MIME Interfaces). ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as @@ -39,36 +38,6 @@ which are string or symbol." ))) args ""))) -(defmacro define-structure (name &rest slots) - (let ((pred (symbol-concat name '-p))) - (cons 'progn - (nconc - (list - (` (defun (, pred) (obj) - (and (vectorp obj) - (eq (elt obj 0) '(, name)) - )) - ) - (` (defun (, (symbol-concat name '/create)) (, slots) - (, (cons 'vector (cons (list 'quote name) slots))) - ) - )) - (let ((i 1)) - (mapcar (function - (lambda (slot) - (prog1 - (` (defun (, (symbol-concat name '/ slot)) (obj) - (if ((, pred) obj) - (elt obj (, i)) - )) - ) - (setq i (+ i 1)) - ) - )) slots) - ) - (list (list 'quote name)) - )))) - ;;; @ field parser ;;; @@ -186,36 +155,32 @@ and return parsed it. [mime-parse.el]" ;;; @ message parser ;;; -(define-structure mime::content-info - rcnum point-min point-max type parameters encoding children) - -(defsubst make-mime-entity-info (rcnum - point-min point-max - media-type media-subtype - parameters encoding children) - (let ((ctype (if media-type - (if media-subtype - (format "%s/%s" media-type media-subtype) - (symbol-name media-type))))) - (mime::content-info/create rcnum point-min point-max - ctype params encoding - children) - )) - -(defsubst mime-entity-info-rnum (entity-info) - (mime::content-info/rcnum entity-info)) - -(defsubst mime-entity-info-point-min (entity-info) - (mime::content-info/point-min entity-info)) - -(defsubst mime-entity-info-point-max (entity-info) - (mime::content-info/point-max entity-info)) - -(defsubst mime-entity-info-type/subtype (entity-info) - (mime::content-info/type entity-info)) - -(defsubst mime-entity-info-parameters (entity-info) - (mime::content-info/parameters entity-info)) +(defsubst make-mime-entity (node-id + point-min point-max + media-type media-subtype parameters + encoding children) + (vector node-id point-min point-max + media-type media-subtype parameters encoding children)) + +(defsubst mime-entity-node-id (entity-info) (aref entity-info 0)) +(defsubst mime-entity-point-min (entity-info) (aref entity-info 1)) +(defsubst mime-entity-point-max (entity-info) (aref entity-info 2)) +(defsubst mime-entity-media-type (entity-info) (aref entity-info 3)) +(defsubst mime-entity-media-subtype (entity-info) (aref entity-info 4)) +(defsubst mime-entity-parameters (entity-info) (aref entity-info 5)) +(defsubst mime-entity-encoding (entity-info) (aref entity-info 6)) +(defsubst mime-entity-children (entity-info) (aref entity-info 7)) + +(defsubst mime-type/subtype-string (type &optional subtype) + "Return type/subtype string from TYPE and SUBTYPE." + (if type + (if subtype + (format "%s/%s" type subtype) + (format "%s" type)))) + +(defsubst mime-entity-type/subtype (entity-info) + (mime-type/subtype-string (mime-entity-media-type entity-info) + (mime-entity-media-subtype entity-info))) (defun mime-parse-multipart (boundary primtype subtype params encoding rcnum) (goto-char (point-min)) @@ -249,7 +214,7 @@ and return parsed it. [mime-parse.el]" (setq ret (mime-parse-message dc-ctl "7bit" (cons i rcnum))) ) (setq children (cons ret children)) - (goto-char (mime-entity-info-point-max ret)) + (goto-char (mime-entity-point-max ret)) (goto-char (setq cb ncb)) (setq i (1+ i)) ) @@ -260,9 +225,9 @@ and return parsed it. [mime-parse.el]" ) (setq children (cons ret children)) ) - (make-mime-entity-info rcnum beg (point-max) - primtype subtype params encoding - (nreverse children)) + (make-mime-entity rcnum beg (point-max) + primtype subtype params encoding + (nreverse children)) )) (defun mime-parse-message (&optional default-ctl default-encoding rcnum) @@ -287,28 +252,35 @@ mime-{parse|read}-Content-Type." (memq subtype '(rfc822 news)) ) (goto-char (point-min)) - (make-mime-entity-info rcnum - (point-min) (point-max) - primtype subtype params encoding - (save-restriction - (narrow-to-region - (if (re-search-forward "^$" nil t) - (1+ (match-end 0)) - (point-min) - ) - (point-max)) - (list (mime-parse-message - nil nil (cons 0 rcnum))) - )) + (make-mime-entity rcnum (point-min) (point-max) + primtype subtype params encoding + (save-restriction + (narrow-to-region + (if (re-search-forward "^$" nil t) + (1+ (match-end 0)) + (point-min) + ) + (point-max)) + (list (mime-parse-message + nil nil (cons 0 rcnum))) + )) ) (t - (make-mime-entity-info rcnum (point-min) (point-max) - primtype subtype params encoding - nil) + (make-mime-entity rcnum (point-min) (point-max) + primtype subtype params encoding + nil) )) ))) +;;; @ utilities +;;; + +(defsubst mime-root-entity-p (entity) + "Return t if ENTITY is root-entity (message)." + (null (mime-entity-node-id entity))) + + ;;; @ end ;;;