Back to index

lightning-sunbird  0.9+nobinonly
mimemult.h
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef _MIMEMULT_H_
00039 #define _MIMEMULT_H_
00040 
00041 #include "mimecont.h"
00042 
00043 /* The MimeMultipart class class implements the objects representing all of
00044    the "multipart/" MIME types.  In addition to the methods inherited from
00045    MimeContainer, it provides the following methods and class variables:
00046 
00047    int create_child (MimeObject *obj)
00048 
00049      When it has been determined that a new sub-part should be created,
00050      this method is called to do that.  The default value for this method
00051      does it in the usual multipart/mixed way.  The headers of the object-
00052      to-be-created may be found in the `hdrs' slot of the `MimeMultipart'
00053      object.
00054 
00055    PRBool output_child_p (MimeObject *parent, MimeObject *child)
00056 
00057      Whether this child should be output.  Default method always says `yes'.
00058 
00059    int parse_child_line (MimeObject *obj, char *line, PRInt32 length,
00060                                            PRBool first_line_p)
00061 
00062      When we have a line which should be handed off to the currently-active
00063      child object, this method is called to do that.  The `first_line_p'
00064      variable will be true only for the very first line handed off to this
00065      sub-part.  The default method simply passes the line to the most-
00066         recently-added child object.
00067 
00068    int close_child (MimeObject *self)
00069 
00070      When we reach the end of a sub-part (a separator line) this method is
00071         called to shut down the currently-active child.  The default method
00072         simply calls `parse_eof' on the most-recently-added child object.
00073 
00074    MimeMultipartBoundaryType check_boundary (MimeObject *obj, 
00075                                                                              const char *line, PRInt32 length)
00076 
00077      This method is used to examine a line and determine whether it is a
00078      part boundary, and if so, what kind.  It should return a member of 
00079      the MimeMultipartBoundaryType describing the line.
00080 
00081    const char *default_part_type
00082 
00083      This is the type which should be assumed for sub-parts which have
00084      no explicit type specified.  The default is "text/plain", but the
00085      "multipart/digest" subclass overrides this to "message/rfc822".
00086  */
00087 
00088 typedef struct MimeMultipartClass MimeMultipartClass;
00089 typedef struct MimeMultipart      MimeMultipart;
00090 
00091 typedef enum {
00092   MimeMultipartPreamble,
00093   MimeMultipartHeaders,
00094   MimeMultipartPartFirstLine,
00095   MimeMultipartPartLine,
00096   MimeMultipartSkipPartLine,
00097   MimeMultipartEpilogue
00098 } MimeMultipartParseState;
00099 
00100 typedef enum {
00101   MimeMultipartBoundaryTypeNone,
00102   MimeMultipartBoundaryTypeSeparator,
00103   MimeMultipartBoundaryTypeTerminator
00104 } MimeMultipartBoundaryType;
00105 
00106 
00107 struct MimeMultipartClass {
00108   MimeContainerClass container;
00109   const char *default_part_type;
00110 
00111   int (*create_child) (MimeObject *);
00112   PRBool (*output_child_p) (MimeObject *self, MimeObject *child);
00113   int (*close_child) (MimeObject *);
00114   int (*parse_child_line) (MimeObject *, char *line, PRInt32 length,
00115                                              PRBool first_line_p);
00116   MimeMultipartBoundaryType (*check_boundary) (MimeObject *, const char *line,
00117                                                                                 PRInt32 length);
00118 };
00119 
00120 extern MimeMultipartClass mimeMultipartClass;
00121 
00122 struct MimeMultipart {
00123   MimeContainer container;                /* superclass variables */
00124   char *boundary;                                /* Inter-part delimiter string */
00125   MimeHeaders *hdrs;                      /* headers of the part currently
00126                                                                   being parsed, if any */
00127   MimeMultipartParseState state;   /* State of parser */
00128 };
00129 
00130 #endif /* _MIMEMULT_H_ */