home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libmime / mimemult.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.2 KB  |  115 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /* mimemult.h --- definition of the MimeMultipart class (see mimei.h)
  20.    Created: Jamie Zawinski <jwz@netscape.com>, 15-May-96.
  21.  */
  22.  
  23. #ifndef _MIMEMULT_H_
  24. #define _MIMEMULT_H_
  25.  
  26. #include "mimecont.h"
  27.  
  28. /* The MimeMultipart class class implements the objects representing all of
  29.    the "multipart/" MIME types.  In addition to the methods inherited from
  30.    MimeContainer, it provides the following methods and class variables:
  31.  
  32.    int create_child (MimeObject *obj)
  33.  
  34.      When it has been determined that a new sub-part should be created,
  35.      this method is called to do that.  The default value for this method
  36.      does it in the usual multipart/mixed way.  The headers of the object-
  37.      to-be-created may be found in the `hdrs' slot of the `MimeMultipart'
  38.      object.
  39.  
  40.    XP_Bool output_child_p (MimeObject *parent, MimeObject *child)
  41.  
  42.      Whether this child should be output.  Default method always says `yes'.
  43.  
  44.    int parse_child_line (MimeObject *obj, char *line, int32 length,
  45.                          XP_Bool first_line_p)
  46.  
  47.      When we have a line which should be handed off to the currently-active
  48.      child object, this method is called to do that.  The `first_line_p'
  49.      variable will be true only for the very first line handed off to this
  50.      sub-part.  The default method simply passes the line to the most-
  51.      recently-added child object.
  52.  
  53.    int close_child (MimeObject *self)
  54.  
  55.      When we reach the end of a sub-part (a separator line) this method is
  56.      called to shut down the currently-active child.  The default method
  57.      simply calls `parse_eof' on the most-recently-added child object.
  58.  
  59.    MimeMultipartBoundaryType check_boundary (MimeObject *obj, 
  60.                                             const char *line, int32 length)
  61.  
  62.      This method is used to examine a line and determine whether it is a
  63.      part boundary, and if so, what kind.  It should return a member of 
  64.      the MimeMultipartBoundaryType describing the line.
  65.  
  66.    const char *default_part_type
  67.  
  68.      This is the type which should be assumed for sub-parts which have
  69.      no explicit type specified.  The default is "text/plain", but the
  70.      "multipart/digest" subclass overrides this to "message/rfc822".
  71.  */
  72.  
  73. typedef struct MimeMultipartClass MimeMultipartClass;
  74. typedef struct MimeMultipart      MimeMultipart;
  75.  
  76. typedef enum {
  77.   MimeMultipartPreamble,
  78.   MimeMultipartHeaders,
  79.   MimeMultipartPartFirstLine,
  80.   MimeMultipartPartLine,
  81.   MimeMultipartEpilogue
  82. } MimeMultipartParseState;
  83.  
  84. typedef enum {
  85.   MimeMultipartBoundaryTypeNone,
  86.   MimeMultipartBoundaryTypeSeparator,
  87.   MimeMultipartBoundaryTypeTerminator
  88. } MimeMultipartBoundaryType;
  89.  
  90.  
  91. struct MimeMultipartClass {
  92.   MimeContainerClass container;
  93.   const char *default_part_type;
  94.  
  95.   int (*create_child) (MimeObject *);
  96.   XP_Bool (*output_child_p) (MimeObject *self, MimeObject *child);
  97.   int (*close_child) (MimeObject *);
  98.   int (*parse_child_line) (MimeObject *, char *line, int32 length,
  99.                            XP_Bool first_line_p);
  100.   MimeMultipartBoundaryType (*check_boundary) (MimeObject *, const char *line,
  101.                                                int32 length);
  102. };
  103.  
  104. extern MimeMultipartClass mimeMultipartClass;
  105.  
  106. struct MimeMultipart {
  107.   MimeContainer container;            /* superclass variables */
  108.   char *boundary;                    /* Inter-part delimiter string */
  109.   MimeHeaders *hdrs;                /* headers of the part currently
  110.                                        being parsed, if any */
  111.   MimeMultipartParseState state;    /* State of parser */
  112. };
  113.  
  114. #endif /* _MIMEMULT_H_ */
  115.