/usr/include/thunderbird-11.0.1/mimeobj.h is in thunderbird-dev 11.0.1+build1-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _MIMEOBJ_H_
#define _MIMEOBJ_H_
#include "mimei.h"
#include "prio.h"
/* MimeObject is the base-class for the objects representing all other
MIME types. It provides several methods:
int initialize (MimeObject *obj)
This is called from mime_new() when a new instance is allocated.
Subclasses should do whatever setup is necessary from this method,
and should call the superclass's initialize method, unless there's
a specific reason not to.
void finalize (MimeObject *obj)
This is called from mime_free() and should free all data associated
with the object. If the object points to other MIME objects, they
should be finalized as well (by calling mime_free(), not by calling
their finalize() methods directly.)
int parse_buffer (const char *buf, PRInt32 size, MimeObject *obj)
This is the method by which you feed arbitrary data into the parser
for this object. Most subclasses will probably inherit this method
from the MimeObject base-class, which line-buffers the data and then
hands it off to the parse_line() method.
If this object uses a Content-Transfer-Encoding (base64, qp, uue)
then the data may be decoded by parse_buffer() before parse_line()
is called. (The MimeLeaf class provides this functionality.)
int parse_begin (MimeObject *obj)
Called after `init' but before `parse_line' or `parse_buffer'.
Can be used to initialize various parsing machinery.
int parse_line (const char *line, PRInt32 length, MimeObject *obj)
This method is called (by parse_buffer()) for each complete line of
data handed to the parser, and is the method which most subclasses
will override to implement their parsers.
When handing data off to a MIME object for parsing, one should always
call the parse_buffer() method, and not call the parse_line() method
directly, since the parse_buffer() method may do other transformations
on the data (like base64 decoding.)
One should generally not call parse_line() directly, since that could
bypass decoding. One should call parse_buffer() instead.
int parse_eof (MimeObject *obj, bool abort_p)
This is called when there is no more data to be handed to the object:
when the parent object is done feeding data to an object being parsed.
Implementors of this method should be sure to also call the parse_eof()
methods of any sub-objects to which they have pointers.
This is also called by the finalize() method, just before object
destruction, if it has not already been called.
The `closed_p' instance variable is used to prevent multiple calls to
`parse_eof'.
int parse_end (MimeObject *obj)
Called after `parse_eof' but before `finalize'.
This can be used to free up any memory no longer needed now that parsing
is done (to avoid surprises due to unexpected method combination, it's
best to free things in this method in preference to `parse_eof'.)
Implementors of this method should be sure to also call the parse_end()
methods of any sub-objects to which they have pointers.
This is also called by the finalize() method, just before object
destruction, if it has not already been called.
The `parsed_p' instance variable is used to prevent multiple calls to
`parse_end'.
bool displayable_inline_p (MimeObjectClass *class, MimeHeaders *hdrs)
This method should return true if this class of object will be displayed
directly, as opposed to being displayed as a link. This information is
used by the "multipart/alternative" parser to decide which of its children
is the ``best'' one to display. Note that this is a class method, not
an object method -- there is not yet an instance of this class at the time
that it is called. The `hdrs' provided are the headers of the object that
might be instantiated -- from this, the method may extract additional
infomation that it might need to make its decision.
*/
/* this one is typdedef'ed in mimei.h, since it is the base-class. */
struct MimeObjectClass {
/* Note: the order of these first five slots is known by MimeDefClass().
Technically, these are part of the object system, not the MIME code.
*/
const char *class_name;
int instance_size;
struct MimeObjectClass *superclass;
int (*class_initialize) (MimeObjectClass *clazz);
bool class_initialized;
/* These are the methods shared by all MIME objects. See comment above.
*/
int (*initialize) (MimeObject *obj);
void (*finalize) (MimeObject *obj);
int (*parse_begin) (MimeObject *obj);
int (*parse_buffer) (const char *buf, PRInt32 size, MimeObject *obj);
int (*parse_line) (const char *line, PRInt32 length, MimeObject *obj);
int (*parse_eof) (MimeObject *obj, bool abort_p);
int (*parse_end) (MimeObject *obj, bool abort_p);
bool (*displayable_inline_p) (MimeObjectClass *clazz, MimeHeaders *hdrs);
#if defined(DEBUG) && defined(XP_UNIX)
int (*debug_print) (MimeObject *obj, PRFileDesc *stream, PRInt32 depth);
#endif
};
extern "C" MimeObjectClass mimeObjectClass;
/* this one is typdedef'ed in mimei.h, since it is the base-class. */
struct MimeObject {
MimeObjectClass *clazz; /* Pointer to class object, for `type-of' */
MimeHeaders *headers; /* The header data associated with this object;
this is where the content-type, disposition,
description, and other meta-data live.
For example, the outermost message/rfc822 object
would have NULL here (since it has no parent,
thus no headers to describe it.) However, a
multipart/mixed object, which was the sole
child of that message/rfc822 object, would have
here a copy of the headers which began the
parent object (the headers which describe the
child.)
*/
char *content_type; /* The MIME content-type and encoding. */
char *encoding; /* In most cases, these will be the same as the
values to be found in the `headers' object,
but in some cases, the values in these slots
will be more correct than the headers.
*/
MimeObject *parent; /* Backpointer to a MimeContainer object. */
MimeDisplayOptions *options; /* Display preferences set by caller. */
bool closed_p; /* Whether it's done being written to. */
bool parsed_p; /* Whether the parser has been shut down. */
bool output_p; /* Whether it should be written. */
bool dontShowAsAttachment; /* Force an object to not be shown as attachment,
but when is false, it doesn't mean it will be
shown as attachment */
/* Read-buffer and write-buffer (on input, `parse_buffer' uses ibuffer to
compose calls to `parse_line'; on output, `obuffer' is used in various
ways by various routines.) These buffers are created and grow as needed.
`ibuffer' should be generally be considered hands-off, and `obuffer'
should generally be considered fair game.
*/
char *ibuffer, *obuffer;
PRInt32 ibuffer_size, obuffer_size;
PRInt32 ibuffer_fp, obuffer_fp;
};
#define MimeObject_grow_obuffer(obj, desired_size) \
(((desired_size) >= (obj)->obuffer_size) ? \
mime_GrowBuffer ((PRUint32)(desired_size), (PRUint32)sizeof(char), 1024, \
&(obj)->obuffer, (PRInt32*)&(obj)->obuffer_size) \
: 0)
#endif /* _MIMEOBJ_H_ */
|