00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __KMIME_HEADER_PARSING_H__
00033 #define __KMIME_HEADER_PARSING_H__
00034
00035 #include <qstring.h>
00036 #include <qpair.h>
00037 #include <qvaluelist.h>
00038
00039 #include <time.h>
00040
00041 template <typename K, typename V> class QMap;
00042 class QStringList;
00043
00044 namespace KMime {
00045
00046 namespace Types {
00047
00048
00049 struct QStringOrQPair {
00050 QStringOrQPair() : qstring(), qpair(0,0) {}
00051 QString qstring;
00052 QPair<const char*,int> qpair;
00053 };
00054
00055 struct AddrSpec {
00056 QString asString() const;
00057 QString localPart;
00058 QString domain;
00059 };
00060 typedef QValueList<AddrSpec> AddrSpecList;
00061
00062 struct Mailbox {
00063 QString displayName;
00064 AddrSpec addrSpec;
00065 };
00066 typedef QValueList<Mailbox> MailboxList;
00067
00068 struct Address {
00069 QString displayName;
00070 MailboxList mailboxList;
00071 };
00072 typedef QValueList<Address> AddressList;
00073
00074 struct DateTime {
00075 time_t time;
00076 long int secsEastOfGMT;
00077 bool timeZoneKnown;
00078 };
00079
00080 }
00081
00082 namespace HeaderParsing {
00083
00098 bool parseEncodedWord( const char* & scursor, const char * const send,
00099 QString & result, QCString & language );
00100
00101
00102
00103
00106 bool parseAtom( const char* & scursor, const char * const send,
00107 QString & result, bool allow8Bit=false );
00108 bool parseAtom( const char* & scursor, const char * const send,
00109 QPair<const char*,int> & result, bool allow8Bit=false );
00112 bool parseToken( const char* & scursor, const char * const send,
00113 QString & result, bool allow8Bit=false );
00114 bool parseToken( const char* & scursor, const char * const send,
00115 QPair<const char*,int> & result, bool allow8Bit=false );
00117 bool parseGenericQuotedString( const char* & scursor, const char* const send,
00118 QString & result, bool isCRLF,
00119 const char openChar='"',
00120 const char closeChar='"' );
00122 bool parseComment( const char* & scursor, const char * const send,
00123 QString & result, bool isCRLF=false, bool reallySave=true );
00129 bool parsePhrase( const char* & scursor, const char * const send,
00130 QString & result, bool isCRLF=false );
00133 bool parseDotAtom( const char* & scursor, const char * const send,
00134 QString & result, bool isCRLF=false );
00135
00145 void eatCFWS( const char* & scursor, const char * const send, bool isCRLF );
00146
00147 bool parseDomain( const char* & scursor, const char * const send,
00148 QString & result, bool isCRLF=false );
00149 bool parseObsRoute( const char* & scursor, const char * const send,
00150 QStringList & result,
00151 bool isCRLF=false, bool save=false );
00152 bool parseAddrSpec( const char* & scursor, const char * const send,
00153 Types::AddrSpec & result, bool isCRLF=false );
00154 bool parseAngleAddr( const char* & scursor, const char * const send,
00155 Types::AddrSpec & result, bool isCRLF=false );
00156 bool parseMailbox( const char* & scursor, const char * const send,
00157 Types::Mailbox & result, bool isCRLF=false );
00158 bool parseGroup( const char* & scursor, const char * const send,
00159 Types::Address & result, bool isCRLF=false );
00160 bool parseAddress( const char* & scursor, const char * const send,
00161 Types::Address & result, bool isCRLF=false );
00162 bool parseAddressList( const char* & scursor, const char * const send,
00163 Types::AddressList & result, bool isCRLF=false );
00164
00165 bool parseParameter( const char* & scursor, const char * const send,
00166 QPair<QString,Types::QStringOrQPair> & result,
00167 bool isCRLF=false );
00168 bool parseParameterList( const char* & scursor, const char * const send,
00169 QMap<QString,QString> & result, bool isCRLF=false );
00170
00171 bool parseRawParameterList( const char* & scursor, const char * const send,
00172 QMap<QString,Types::QStringOrQPair> & result,
00173 bool isCRLF=false );
00174
00175 bool parseTime( const char* & scursor, const char * const send,
00176 int & hour, int & min, int & sec, long int & secsEastOfGMT,
00177 bool & timeZoneKnown, bool isCRLF=false );
00178
00179 bool parseDateTime( const char* & scursor, const char * const send,
00180 Types::DateTime & result, bool isCRLF=false );
00181
00182 #if 0
00183 bool tryToMakeAnySenseOfDateString( const char* & scursor,
00184 const char * const send,
00185 time_t & result, bool isCRLF=false );
00186 #endif
00187
00188 }
00189
00190 }
00191
00192
00193 #endif // __KMIME_HEADER_PARSING_H__
00194