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 #include <kdepimmacros.h>
00042
00043 template <typename K, typename V> class QMap;
00044 class QStringList;
00045
00046 namespace KMime {
00047
00048 namespace Types {
00049
00050
00051 struct KDE_EXPORT QStringOrQPair {
00052 QStringOrQPair() : qstring(), qpair(0,0) {}
00053 QString qstring;
00054 QPair<const char*,int> qpair;
00055 };
00056
00057 struct KDE_EXPORT AddrSpec {
00058 QString asString() const;
00059 QString localPart;
00060 QString domain;
00061 };
00062 typedef QValueList<AddrSpec> AddrSpecList;
00063
00064 struct KDE_EXPORT Mailbox {
00065 QString displayName;
00066 AddrSpec addrSpec;
00067 };
00068 typedef QValueList<Mailbox> MailboxList;
00069
00070 struct KDE_EXPORT Address {
00071 QString displayName;
00072 MailboxList mailboxList;
00073 };
00074 typedef QValueList<Address> AddressList;
00075
00076 struct KDE_EXPORT DateTime {
00077 time_t time;
00078 long int secsEastOfGMT;
00079 bool timeZoneKnown;
00080 };
00081
00082 }
00083
00084 namespace HeaderParsing {
00085
00100 bool parseEncodedWord( const char* & scursor, const char * const send,
00101 QString & result, QCString & language ) KDE_EXPORT;
00102
00103
00104
00105
00108 bool parseAtom( const char* & scursor, const char * const send,
00109 QString & result, bool allow8Bit=false ) KDE_EXPORT;
00110 bool parseAtom( const char* & scursor, const char * const send,
00111 QPair<const char*,int> & result, bool allow8Bit=false ) KDE_EXPORT;
00114 bool parseToken( const char* & scursor, const char * const send,
00115 QString & result, bool allow8Bit=false ) KDE_EXPORT;
00116 bool parseToken( const char* & scursor, const char * const send,
00117 QPair<const char*,int> & result, bool allow8Bit=false ) KDE_EXPORT;
00119 bool parseGenericQuotedString( const char* & scursor, const char* const send,
00120 QString & result, bool isCRLF,
00121 const char openChar='"',
00122 const char closeChar='"' ) KDE_EXPORT;
00124 bool parseComment( const char* & scursor, const char * const send,
00125 QString & result, bool isCRLF=false, bool reallySave=true ) KDE_EXPORT;
00131 bool parsePhrase( const char* & scursor, const char * const send,
00132 QString & result, bool isCRLF=false ) KDE_EXPORT;
00135 bool parseDotAtom( const char* & scursor, const char * const send,
00136 QString & result, bool isCRLF=false ) KDE_EXPORT;
00137
00147 void eatCFWS( const char* & scursor, const char * const send, bool isCRLF ) KDE_EXPORT;
00148
00149 bool parseDomain( const char* & scursor, const char * const send,
00150 QString & result, bool isCRLF=false ) KDE_EXPORT;
00151 bool parseObsRoute( const char* & scursor, const char * const send,
00152 QStringList & result,
00153 bool isCRLF=false, bool save=false ) KDE_EXPORT;
00154 bool parseAddrSpec( const char* & scursor, const char * const send,
00155 Types::AddrSpec & result, bool isCRLF=false ) KDE_EXPORT;
00156 bool parseAngleAddr( const char* & scursor, const char * const send,
00157 Types::AddrSpec & result, bool isCRLF=false ) KDE_EXPORT;
00158 bool parseMailbox( const char* & scursor, const char * const send,
00159 Types::Mailbox & result, bool isCRLF=false ) KDE_EXPORT;
00160 bool parseGroup( const char* & scursor, const char * const send,
00161 Types::Address & result, bool isCRLF=false ) KDE_EXPORT;
00162 bool parseAddress( const char* & scursor, const char * const send,
00163 Types::Address & result, bool isCRLF=false ) KDE_EXPORT;
00164 bool parseAddressList( const char* & scursor, const char * const send,
00165 Types::AddressList & result, bool isCRLF=false ) KDE_EXPORT;
00166
00167 bool parseParameter( const char* & scursor, const char * const send,
00168 QPair<QString,Types::QStringOrQPair> & result,
00169 bool isCRLF=false ) KDE_EXPORT;
00170 bool parseParameterList( const char* & scursor, const char * const send,
00171 QMap<QString,QString> & result, bool isCRLF=false ) KDE_EXPORT;
00172
00173 bool parseRawParameterList( const char* & scursor, const char * const send,
00174 QMap<QString,Types::QStringOrQPair> & result,
00175 bool isCRLF=false ) KDE_EXPORT;
00176
00177 bool parseTime( const char* & scursor, const char * const send,
00178 int & hour, int & min, int & sec, long int & secsEastOfGMT,
00179 bool & timeZoneKnown, bool isCRLF=false ) KDE_EXPORT;
00180
00181 bool parseDateTime( const char* & scursor, const char * const send,
00182 Types::DateTime & result, bool isCRLF=false ) KDE_EXPORT;
00183
00184 #if 0
00185 bool tryToMakeAnySenseOfDateString( const char* & scursor,
00186 const char * const send,
00187 time_t & result, bool isCRLF=false );
00188 #endif
00189
00190 }
00191
00192 }
00193
00194
00195 #endif // __KMIME_HEADER_PARSING_H__
00196