libkdenetwork Library API Documentation

kmime_header_parsing.h

00001 /*  -*- c++ -*-
00002     kmime_header_parsing.h
00003 
00004     This file is part of KMime, the KDE internet mail/usenet news message library.
00005     Copyright (c) 2001-2002 Marc Mutz <mutz@kde.org>
00006 
00007     KMime is free software; you can redistribute it and/or modify it
00008     under the terms of the GNU General Public License, version 2, as
00009     published by the Free Software Foundation.
00010 
00011     KMime is distributed in the hope that it will be useful, but
00012     WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this library; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020     In addition, as a special exception, the copyright holders give
00021     permission to link the code of this library with any edition of
00022     the Qt library by Trolltech AS, Norway (or with modified versions
00023     of Qt that use the same license as Qt), and distribute linked
00024     combinations including the two.  You must obey the GNU General
00025     Public License in all respects for all of the code used other than
00026     Qt.  If you modify this file, you may extend this exception to
00027     your version of the file, but you are not obligated to do so.  If
00028     you do not wish to do so, delete this exception statement from
00029     your version.
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   // for when we can't make up our mind what to use...
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;            // secs since 1.1.1970, 0:00 UTC/GMT
00076     long int secsEastOfGMT; // timezone
00077     bool timeZoneKnown;     // do we know the timezone? (e.g. on -0000)
00078   };
00079 
00080 } // namespace KMime::Types
00081 
00082 namespace HeaderParsing {
00083 
00098   bool parseEncodedWord( const char* & scursor, const char * const send,
00099              QString & result, QCString & language );
00100   //
00101   // The parsing squad:
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 } // namespace HeaderParsing
00189 
00190 } // namespace KMime
00191 
00192 
00193 #endif // __KMIME_HEADER_PARSING_H__
00194 
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu May 3 20:16:59 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003