;; Copyright (C) 1994,1995,1996,1997 Free Software Foundation, Inc.
;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Id: mime-parse.el,v 0.1 1997-02-21 07:38:26 tmorioka Exp $
-;; Keywords: MIME, multimedia, mail, news
+;; Version: $Id: mime-parse.el,v 0.13 1997-07-07 17:08:03 morioka Exp $
+;; Keywords: parse, MIME, multimedia, mail, news
;; This file is part of SEMI (SEMI is Emacs MIME Interfaces).
;;; Code:
+(require 'emu)
(require 'std11)
-(require 'tl-misc)
-(require 'tm-def)
+(require 'mime-def)
+
+(defsubst symbol-concat (&rest args)
+ "Return a symbol whose name is concatenation of arguments ARGS
+which are string or symbol."
+ (intern (apply (function concat)
+ (mapcar (function
+ (lambda (s)
+ (cond ((symbolp s) (symbol-name s))
+ ((stringp s) s)
+ )))
+ 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
;;;
+(defsubst regexp-* (regexp)
+ (concat regexp "*"))
+
(defconst rfc822/quoted-pair-regexp "\\\\.")
(defconst rfc822/qtext-regexp
(concat "[^" (char-list-to-string std11-non-qtext-char-list) "]"))
"\\|[^; \t\n]*\\)"))
(defconst mime::parameter-regexp
- (concat "^[ \t]*\;[ \t]*\\(" mime/token-regexp "\\)"
+ (concat "^[ \t]*\;[ \t]*\\(" mime-token-regexp "\\)"
"[ \t]*=[ \t]*\\(" mime/content-parameter-value-regexp "\\)"))
(defun mime-parse-parameter (str)
(substring str e)
))))
-(defconst mime::ctype-regexp (concat "^" mime/content-type-subtype-regexp))
-
(defun mime-parse-Content-Type (string)
- "Parse STRING as field-body of Content-Type field. [mime-parse.el]"
+ "Parse STRING as field-body of Content-Type field."
(setq string (std11-unfold-string string))
- (if (string-match mime::ctype-regexp string)
+ (if (string-match `,(concat "^" mime-media-type/subtype-regexp) string)
(let* ((e (match-end 0))
(ctype (downcase (substring string 0 e)))
ret dest)
(cons ctype (nreverse dest))
)))
-(defconst mime::dtype-regexp (concat "^" mime/disposition-type-regexp))
-
(defun mime-parse-Content-Disposition (string)
- "Parse STRING as field-body of Content-Disposition field. [mime-parse.el]"
+ "Parse STRING as field-body of Content-Disposition field."
(setq string (std11-unfold-string string))
- (if (string-match mime::dtype-regexp string)
+ (if (string-match `,(concat "^" mime-disposition-type-regexp) string)
(let* ((e (match-end 0))
(ctype (downcase (substring string 0 e)))
ret dest)
'("message/rfc822")
'("text/plain")
))
- cb ce ct ret ncb children (i 0))
+ cb ce ret ncb children (i 0))
(save-restriction
(narrow-to-region beg end)
(goto-char beg)