libkmime

kmime_header_parsing.h
1/*
2 kmime_header_parsing.h
3
4 This file is part of KMime, the KDE internet mail/usenet news message library.
5 Copyright (c) 2001-2002 Marc Mutz <mutz@kde.org>
6
7 KMime is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License, version 2, as
9 published by the Free Software Foundation.
10
11 KMime is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 In addition, as a special exception, the copyright holders give
21 permission to link the code of this library with any edition of
22 the TQt library by Trolltech AS, Norway (or with modified versions
23 of TQt that use the same license as TQt), and distribute linked
24 combinations including the two. You must obey the GNU General
25 Public License in all respects for all of the code used other than
26 TQt. If you modify this file, you may extend this exception to
27 your version of the file, but you are not obligated to do so. If
28 you do not wish to do so, delete this exception statement from
29 your version.
30*/
31
32#ifndef __KMIME_HEADER_PARSING_H__
33#define __KMIME_HEADER_PARSING_H__
34
35#include <tqstring.h>
36#include <tqpair.h>
37#include <tqvaluelist.h>
38
39#include <time.h>
40
41#include <tdemacros.h>
42
43template <typename K, typename V> class TQMap;
44class TQStringList;
45
46namespace KMime {
47
48namespace Types {
49
50 // for when we can't make up our mind what to use...
51 struct TDE_EXPORT TQStringOrTQPair {
52 TQStringOrTQPair() : qstring(), qpair(0,0) {}
53 TQString qstring;
54 TQPair<const char*,int> qpair;
55 };
56
57 struct TDE_EXPORT AddrSpec {
58 TQString asString() const;
59 TQString localPart;
60 TQString domain;
61 };
62 typedef TQValueList<AddrSpec> AddrSpecList;
63
64 struct TDE_EXPORT Mailbox {
65 TQString displayName;
66 AddrSpec addrSpec;
67 };
68 typedef TQValueList<Mailbox> MailboxList;
69
70 struct TDE_EXPORT Address {
71 TQString displayName;
72 MailboxList mailboxList;
73 };
74 typedef TQValueList<Address> AddressList;
75
76 struct TDE_EXPORT DateTime {
77 time_t time; // secs since 1.1.1970, 0:00 UTC/GMT
78 long int secsEastOfGMT; // timezone
79 bool timeZoneKnown; // do we know the timezone? (e.g. on -0000)
80 };
81
82} // namespace KMime::Types
83
84namespace HeaderParsing {
85
100 bool parseEncodedWord( const char* & scursor, const char * const send,
101 TQString & result, TQCString & language ) TDE_EXPORT;
102 //
103 // The parsing squad:
104 //
105
108 bool parseAtom( const char* & scursor, const char * const send,
109 TQString & result, bool allow8Bit=false ) TDE_EXPORT;
110 bool parseAtom( const char* & scursor, const char * const send,
111 TQPair<const char*,int> & result, bool allow8Bit=false ) TDE_EXPORT;
114 bool parseToken( const char* & scursor, const char * const send,
115 TQString & result, bool allow8Bit=false ) TDE_EXPORT;
116 bool parseToken( const char* & scursor, const char * const send,
117 TQPair<const char*,int> & result, bool allow8Bit=false ) TDE_EXPORT;
119 bool parseGenericQuotedString( const char* & scursor, const char* const send,
120 TQString & result, bool isCRLF,
121 const char openChar='"',
122 const char closeChar='"' ) TDE_EXPORT;
124 bool parseComment( const char* & scursor, const char * const send,
125 TQString & result, bool isCRLF=false, bool reallySave=true ) TDE_EXPORT;
131 bool parsePhrase( const char* & scursor, const char * const send,
132 TQString & result, bool isCRLF=false ) TDE_EXPORT;
135 bool parseDotAtom( const char* & scursor, const char * const send,
136 TQString & result, bool isCRLF=false ) TDE_EXPORT;
137
147 void eatCFWS( const char* & scursor, const char * const send, bool isCRLF ) TDE_EXPORT;
148
149 bool parseDomain( const char* & scursor, const char * const send,
150 TQString & result, bool isCRLF=false ) TDE_EXPORT;
151 bool parseObsRoute( const char* & scursor, const char * const send,
152 TQStringList & result,
153 bool isCRLF=false, bool save=false ) TDE_EXPORT;
154 bool parseAddrSpec( const char* & scursor, const char * const send,
155 Types::AddrSpec & result, bool isCRLF=false ) TDE_EXPORT;
156 bool parseAngleAddr( const char* & scursor, const char * const send,
157 Types::AddrSpec & result, bool isCRLF=false ) TDE_EXPORT;
158 bool parseMailbox( const char* & scursor, const char * const send,
159 Types::Mailbox & result, bool isCRLF=false ) TDE_EXPORT;
160 bool parseGroup( const char* & scursor, const char * const send,
161 Types::Address & result, bool isCRLF=false ) TDE_EXPORT;
162 bool parseAddress( const char* & scursor, const char * const send,
163 Types::Address & result, bool isCRLF=false ) TDE_EXPORT;
164 bool parseAddressList( const char* & scursor, const char * const send,
165 Types::AddressList & result, bool isCRLF=false ) TDE_EXPORT;
166
167 bool parseParameter( const char* & scursor, const char * const send,
168 TQPair<TQString,Types::TQStringOrTQPair> & result,
169 bool isCRLF=false ) TDE_EXPORT;
170 bool parseParameterList( const char* & scursor, const char * const send,
171 TQMap<TQString,TQString> & result, bool isCRLF=false ) TDE_EXPORT;
172
173 bool parseRawParameterList( const char* & scursor, const char * const send,
174 TQMap<TQString,Types::TQStringOrTQPair> & result,
175 bool isCRLF=false ) TDE_EXPORT;
176
177 bool parseTime( const char* & scursor, const char * const send,
178 int & hour, int & min, int & sec, long int & secsEastOfGMT,
179 bool & timeZoneKnown, bool isCRLF=false ) TDE_EXPORT;
180
181 bool parseDateTime( const char* & scursor, const char * const send,
182 Types::DateTime & result, bool isCRLF=false ) TDE_EXPORT;
183
184#if 0
185 bool tryToMakeAnySenseOfDateString( const char* & scursor,
186 const char * const send,
187 time_t & result, bool isCRLF=false );
188#endif
189
190} // namespace HeaderParsing
191
192} // namespace KMime
193
194
195#endif // __KMIME_HEADER_PARSING_H__
196