1
/** Interface for MIME parsing classes
3
Copyright (C) 2000 Free Software Foundation, Inc.
5
Written by: Richard frith-Macdonald <rfm@gnu.org>
9
This file is part of the GNUstep Base Library.
11
This library is free software; you can redistribute it and/or
12
modify it under the terms of the GNU Library General Public
13
License as published by the Free Software Foundation; either
14
version 2 of the License, or (at your option) any later version.
16
This library is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
Library General Public License for more details.
21
You should have received a copy of the GNU Library General Public
22
License along with this library; if not, write to the Free
23
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
25
AutogsdocSource: Additions/GSMime.m
31
#ifdef NeXT_Foundation_LIBRARY
32
#include <Foundation/Foundation.h>
34
#include <Foundation/NSObject.h>
35
#include <Foundation/NSString.h>
39
@class NSMutableArray;
43
@class NSMutableDictionary;
47
* A trivial class for mantaining state while decoding/encoding data.
48
* Each encoding type requires its own subclass.
50
@interface GSMimeCodingContext : NSObject
52
BOOL atEnd; /* Flag to say that data has ended. */
55
- (BOOL) decodeData: (const void*)sData
56
length: (unsigned)length
57
intoData: (NSMutableData*)dData;
58
- (void) setAtEnd: (BOOL)flag;
61
@interface GSMimeHeader : NSObject <NSCopying>
65
NSMutableDictionary *objects;
66
NSMutableDictionary *params;
68
+ (NSString*) makeQuoted: (NSString*)v always: (BOOL)flag;
69
+ (NSString*) makeToken: (NSString*)t;
70
- (id) copyWithZone: (NSZone*)z;
71
- (id) initWithName: (NSString*)n
73
- (id) initWithName: (NSString*)n
75
parameters: (NSDictionary*)p;
77
- (id) objectForKey: (NSString*)k;
78
- (NSDictionary*) objects;
79
- (NSString*) parameterForKey: (NSString*)k;
80
- (NSDictionary*) parameters;
81
- (NSMutableData*) rawMimeData;
82
- (void) setName: (NSString*)s;
83
- (void) setObject: (id)o forKey: (NSString*)k;
84
- (void) setParameter: (NSString*)v forKey: (NSString*)k;
85
- (void) setParameters: (NSDictionary*)d;
86
- (void) setValue: (NSString*)s;
92
@interface GSMimeDocument : NSObject <NSCopying>
94
NSMutableArray *headers;
98
+ (NSString*) charsetFromEncoding: (NSStringEncoding)enc;
99
+ (NSData*) decodeBase64: (NSData*)source;
100
+ (NSString*) decodeBase64String: (NSString*)source;
101
+ (GSMimeDocument*) documentWithContent: (id)newContent
102
type: (NSString*)type
103
name: (NSString*)name;
104
+ (NSData*) encodeBase64: (NSData*)source;
105
+ (NSString*) encodeBase64String: (NSString*)source;
106
+ (NSStringEncoding) encodingFromCharset: (NSString*)charset;
108
- (void) addContent: (id)newContent;
109
- (void) addHeader: (GSMimeHeader*)info;
110
- (GSMimeHeader*) addHeader: (NSString*)name
111
value: (NSString*)value
112
parameters: (NSDictionary*)parameters;
113
- (NSArray*) allHeaders;
115
- (id) contentByID: (NSString*)key;
116
- (id) contentByLocation: (NSString*)key;
117
- (id) contentByName: (NSString*)key;
118
- (id) copyWithZone: (NSZone*)z;
119
- (NSString*) contentFile;
120
- (NSString*) contentID;
121
- (NSString*) contentLocation;
122
- (NSString*) contentName;
123
- (NSString*) contentSubtype;
124
- (NSString*) contentType;
125
- (NSArray*) contentsByName: (NSString*)key;
126
- (NSData*) convertToData;
127
- (NSString*) convertToText;
128
- (void) deleteContent: (GSMimeDocument*)aPart;
129
- (void) deleteHeader: (GSMimeHeader*)aHeader;
130
- (void) deleteHeaderNamed: (NSString*)name;
131
- (GSMimeHeader*) headerNamed: (NSString*)name;
132
- (NSArray*) headersNamed: (NSString*)name;
133
- (NSString*) makeBoundary;
134
- (GSMimeHeader*) makeContentID;
135
- (GSMimeHeader*) makeHeader: (NSString*)name
136
value: (NSString*)value
137
parameters: (NSDictionary*)parameters;
138
- (GSMimeHeader*) makeMessageID;
139
- (NSMutableData*) rawMimeData;
140
- (NSMutableData*) rawMimeData: (BOOL)isOuter;
141
- (void) setContent: (id)newContent;
142
- (void) setContent: (id)newContent
143
type: (NSString*)type;
144
- (void) setContent: (id)newContent
145
type: (NSString*)type
146
name: (NSString*)name;
147
- (void) setContentType: (NSString*)newType;
148
- (void) setHeader: (GSMimeHeader*)info;
149
- (GSMimeHeader*) setHeader: (NSString*)name
150
value: (NSString*)value
151
parameters: (NSDictionary*)parameters;
155
@interface GSMimeParser : NSObject
158
unsigned char *bytes;
160
unsigned sectionStart;
165
unsigned rawBodyLength;
167
unsigned int inBody:1;
168
unsigned int isHttp:1;
169
unsigned int complete:1;
170
unsigned int hadErrors:1;
171
unsigned int buggyQuotes:1;
172
unsigned int wantEndOfLine:1;
175
GSMimeDocument *document;
177
GSMimeCodingContext *context;
178
NSStringEncoding _defaultEncoding;
181
+ (GSMimeDocument*) documentFromData: (NSData*)mimeData;
182
+ (GSMimeParser*) mimeParser;
184
- (GSMimeCodingContext*) contextFor: (GSMimeHeader*)info;
186
- (BOOL) decodeData: (NSData*)sData
187
fromRange: (NSRange)aRange
188
intoData: (NSMutableData*)dData
189
withContext: (GSMimeCodingContext*)con;
190
- (void) expectNoHeaders;
194
- (BOOL) isInHeaders;
195
- (GSMimeDocument*) mimeDocument;
196
- (BOOL) parse: (NSData*)d;
197
- (BOOL) parseHeader: (NSString*)aHeader;
198
- (BOOL) scanHeaderBody: (NSScanner*)scanner into: (GSMimeHeader*)info;
199
- (NSString*) scanName: (NSScanner*)scanner;
200
- (BOOL) scanPastSpace: (NSScanner*)scanner;
201
- (NSString*) scanSpecial: (NSScanner*)scanner;
202
- (NSString*) scanToken: (NSScanner*)scanner;
203
- (void) setBuggyQuotes: (BOOL)flag;
204
- (void) setDefaultCharset: (NSString*)aName;