summaryrefslogtreecommitdiffstats
path: root/mimelib/mimelib
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /mimelib/mimelib
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'mimelib/mimelib')
-rw-r--r--mimelib/mimelib/Makefile.am39
-rw-r--r--mimelib/mimelib/address.h155
-rw-r--r--mimelib/mimelib/addrlist.h214
-rw-r--r--mimelib/mimelib/binhex.h159
-rw-r--r--mimelib/mimelib/body.h275
-rw-r--r--mimelib/mimelib/bodypart.h156
-rw-r--r--mimelib/mimelib/boyermor.h84
-rw-r--r--mimelib/mimelib/config.h170
-rw-r--r--mimelib/mimelib/datetime.h350
-rw-r--r--mimelib/mimelib/debug.h51
-rw-r--r--mimelib/mimelib/disptype.h219
-rw-r--r--mimelib/mimelib/entity.h184
-rw-r--r--mimelib/mimelib/enum.h193
-rw-r--r--mimelib/mimelib/field.h269
-rw-r--r--mimelib/mimelib/fieldbdy.h167
-rw-r--r--mimelib/mimelib/group.h204
-rw-r--r--mimelib/mimelib/headers.h453
-rw-r--r--mimelib/mimelib/mailbox.h216
-rw-r--r--mimelib/mimelib/mboxlist.h226
-rw-r--r--mimelib/mimelib/mechansm.h172
-rw-r--r--mimelib/mimelib/mediatyp.h279
-rw-r--r--mimelib/mimelib/message.h130
-rw-r--r--mimelib/mimelib/mimepp.h150
-rw-r--r--mimelib/mimelib/msgcmp.h311
-rw-r--r--mimelib/mimelib/msgid.h180
-rw-r--r--mimelib/mimelib/nntp.h376
-rw-r--r--mimelib/mimelib/param.h173
-rw-r--r--mimelib/mimelib/pop.h300
-rw-r--r--mimelib/mimelib/protocol.h268
-rw-r--r--mimelib/mimelib/string.h772
-rw-r--r--mimelib/mimelib/text.h151
-rw-r--r--mimelib/mimelib/token.h150
-rw-r--r--mimelib/mimelib/utility.h50
-rw-r--r--mimelib/mimelib/uuencode.h122
34 files changed, 7368 insertions, 0 deletions
diff --git a/mimelib/mimelib/Makefile.am b/mimelib/mimelib/Makefile.am
new file mode 100644
index 00000000..c3e23c2d
--- /dev/null
+++ b/mimelib/mimelib/Makefile.am
@@ -0,0 +1,39 @@
+# $Id$
+
+mimelibdir = $(includedir)/mimelib
+
+mimelib_HEADERS= \
+ address.h \
+ addrlist.h \
+ body.h \
+ bodypart.h \
+ boyermor.h \
+ config.h \
+ datetime.h \
+ debug.h \
+ disptype.h \
+ entity.h \
+ enum.h \
+ field.h \
+ fieldbdy.h \
+ group.h \
+ headers.h \
+ mailbox.h \
+ mboxlist.h \
+ mechansm.h \
+ mediatyp.h \
+ message.h \
+ mimepp.h \
+ msgcmp.h \
+ msgid.h \
+ nntp.h \
+ param.h \
+ pop.h \
+ protocol.h \
+ string.h \
+ text.h \
+ token.h \
+ utility.h \
+ uuencode.h \
+ binhex.h
+
diff --git a/mimelib/mimelib/address.h b/mimelib/mimelib/address.h
new file mode 100644
index 00000000..c384b949
--- /dev/null
+++ b/mimelib/mimelib/address.h
@@ -0,0 +1,155 @@
+//=============================================================================
+// File: address.h
+// Contents: Declarations for DwAddress
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_ADDRESS_H
+#define DW_ADDRESS_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_FIELDBDY_H
+#include <mimelib/fieldbdy.h>
+#endif
+
+#ifndef DW_TOKEN_H
+#include <mimelib/token.h>
+#endif
+
+class DwAddressList;
+class DwMailboxList;
+
+//=============================================================================
+//+ Name DwAddress -- Abstract class representing an RFC-822 address
+//+ Description
+//. {\tt DwAddress} represents an {\it address} as described in RFC-822.
+//. You may not instantiate objects of type {\tt DwAddress}, since
+//. {\tt DwAddress} is an abstract base class. Instead, you must instantiate
+//. objects of type {\tt DwMailbox} or {\tt DwGroup}, which are subclasses
+//. of {\tt DwAddress}.
+//.
+//. To determine the actual type of a {\tt DwAddress} object, you can use
+//. the member functions {\tt IsMailbox()} and {\tt IsGroup()}.
+//.
+//. If the string representation assigned to a {\tt DwAddress} is improperly
+//. formed, the parse method will fail. To determine if the parse method
+//. failed, call the member function {\tt IsValid()}.
+//.
+//. A {\tt DwAddress} object can be contained in list. To get the next
+//. {\tt DwAddress} object in the list, call the member function {\tt Next()}.
+//=============================================================================
+// Last modified 1997-08-23
+//+ Noentry ~DwAddress mNext mIsValid sClassName _PrintDebugInfo
+
+
+class DW_EXPORT DwAddress : public DwFieldBody {
+
+ friend class DwAddressList;
+
+public:
+
+ virtual ~DwAddress();
+
+ DwBool IsMailbox() const;
+ //. Returns true value if this object is a {\tt DwMailbox}.
+
+ DwBool IsGroup() const;
+ //. Returns true value if this object is a {\tt DwGroup}.
+
+ inline DwBool IsValid() const;
+ //. Returns true value if the last parse was successful.
+ //. Returns false if the last parse failed (bad address) or
+ //. the {\tt Parse()} member function was never called.
+
+ DwAddress* Next() const;
+ //. Returns the next {\tt DwAddress} object in the list when the object
+ //. is included in a list of addresses. The function is used when
+ //. iterating a list.
+
+ void SetNext(DwAddress* aAddress);
+ //. Sets the next {\tt DwAddress} object in the list. This member function
+ //. generally should not be used, since {\tt DwAddressList} has member
+ //. functions to manage its list of {\tt DwAddress} objects.
+
+protected:
+
+ DwAddress();
+ DwAddress(const DwAddress& aAddr);
+ DwAddress(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwAddress} object's string representation to the empty string
+ //. and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which copies the
+ //. string representation and all attributes from {\tt aAddress}.
+ //. The parent of the new {\tt DwAddress} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwAddress}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwField}.
+
+ const DwAddress& operator = (const DwAddress& aAddr);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aAddr}. The parent node of the {\tt DwAddress} object
+ //. is not changed.
+
+ int mIsValid;
+ //. This data member is set to true if the parse method was successful.
+
+private:
+
+ DwAddress* mNext;
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+inline DwBool DwAddress::IsValid() const
+{
+ return mIsValid;
+}
+
+#endif
diff --git a/mimelib/mimelib/addrlist.h b/mimelib/mimelib/addrlist.h
new file mode 100644
index 00000000..5d26736a
--- /dev/null
+++ b/mimelib/mimelib/addrlist.h
@@ -0,0 +1,214 @@
+//=============================================================================
+// File: addrlist.h
+// Contents: Declarations for DwAddressList
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_ADDRLIST_H
+#define DW_ADDRLIST_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+//=============================================================================
+//+ Name DwAddressList -- Class representing a list of RFC-822 addresses
+//+ Description
+//. {\tt DwAddressList} represents a list of {\it addresses} as described
+//. in RFC-822. In MIME++, {\tt DwAddressList} is a container for objects
+//. of type {\tt DwAddress}, and it contains various member functions
+//. to manage its contained objects. {\tt DwAddressList} is also a
+//. {\tt DwFieldBody}. This reflects the fact that certain RFC-822 header
+//. fields, such as the ``To'' header field, have a list of addresses
+//. as their field bodies.
+//=============================================================================
+// Last modified 1997-08-23
+//+ Noentry ~DwAddressList sClassName CopyList _PrintDebugInfo
+
+
+class DW_EXPORT DwAddressList : public DwFieldBody {
+
+public:
+
+ DwAddressList();
+ DwAddressList(const DwAddressList& aList);
+ DwAddressList(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwAddressList} object's string representation to the empty string
+ //. and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which copies the
+ //. string representation and all {\tt DwAddress} objects from {\tt aList}.
+ //. The parent of the new {\tt DwAddressList} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwAddressList}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwField}.
+
+ virtual ~DwAddressList();
+
+ const DwAddressList& operator = (const DwAddressList& aList);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aList}. The parent node of the {\tt DwAddressList} object
+ //. is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwAddressList} objects. The parse
+ //. method creates or updates the broken-down representation from the
+ //. string representation. For {\tt DwAddressList} objects, the parse
+ //. method parses the string representation to create a list of
+ //. {\tt DwAddress} objects. This member function also calls the
+ //. {\tt Parse()} member function of each {\tt DwAddress} object in
+ //. its list.
+ //.
+ //. You should call this member function after you set or modify the
+ //. string representation, and before you access any of the contained
+ //. {\tt DwAddress} objects.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwAddressList} objects. The
+ //. assemble method creates or updates the string representation from
+ //. the broken-down representation. That is, the assemble method
+ //. builds the string representation from its list of {\tt DwAddress}
+ //. objects. Before it builds the string representation for the
+ //. {\tt DwAddressList} object, this function first calls the
+ //. {\tt Assemble()} member function of each {\tt DwAddress} object
+ //. in its list.
+ //.
+ //. You should call this member function after you set or modify any
+ //. of the contained {\tt DwAddress} objects, and before you retrieve
+ //. the string representation.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwAddressList} on the free store that has the same
+ //. value as this {\tt DwAddressList} object. The basic idea is that of
+ //. a virtual copy constructor.
+
+ DwAddress* FirstAddress() const;
+ //. Gets the first {\tt DwAddress} object in the list.
+ //. Use the member function {\tt DwAddress::Next()} to iterate.
+ //. Returns {\tt NULL} if the list is empty.
+
+ void Add(DwAddress* aAddr);
+ //. Adds {\tt aAddr} to the end of the list of {\tt DwAddress} objects
+ //. maintained by this {\tt DwAddressList} object.
+
+ void Remove(DwAddress* aAddr);
+ //. Removes {\tt aAddr} from the list of {\tt DwAddress} objects
+ //. maintained by this {\tt DwAddressList} object. The {\tt DwAddress}
+ //. object is not deleted by this member function.
+
+ void DeleteAll();
+ //. Removes and deletes all {\tt DwAddress} objects from the list
+ //. maintained by this {\tt DwAddressList} object.
+
+ static DwAddressList* NewAddressList(const DwString& aStr,
+ DwMessageComponent* aParent);
+ //. Creates a new {\tt DwAddressList} object on the free store.
+ //. If the static data member {\tt sNewAddressList} is {\tt NULL},
+ //. this member function will create a new {\tt DwAddressList}
+ //. and return it. Otherwise, {\tt NewAddressList()} will call
+ //. the user-supplied function pointed to by {\tt sNewAddressList},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwAddressList}, and return that object.
+
+ //+ Var sNewAddressList
+ static DwAddressList* (*sNewAddressList)(const DwString&,
+ DwMessageComponent*);
+ //. If {\tt sNewAddressList} is not {\tt NULL}, it is assumed to point
+ //. to a user-supplied function that returns a pointer to an object
+ //. from a class derived from {\tt DwAddressList}.
+
+protected:
+
+ DwAddress* mFirstAddress;
+ //. Points to first {\tt DwMailbox} object in list.
+
+private:
+
+ static const char* const sClassName;
+
+ void CopyList(const DwAddress* aFirstAddr);
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+
+class DW_EXPORT DwAddressListParser {
+public:
+ enum {
+ eAddrError,
+ eAddrGroup,
+ eAddrMailbox,
+ eAddrNull,
+ eAddrEnd
+ };
+ DwAddressListParser(const DwString& aStr);
+ virtual ~DwAddressListParser();
+ const DwString& AddrString() { return mAddrString.Tokens(); }
+ int AddrType() { return mAddrType; }
+ int IsGroup() { return (mAddrType == eAddrGroup) ? 1 : 0; }
+ int IsMailbox() { return (mAddrType == eAddrMailbox) ? 1 : 0; }
+ int IsNull() { return (mAddrType == eAddrNull) ? 1 : 0; }
+ int IsEnd() { return (mAddrType == eAddrEnd) ? 1 : 0; }
+ int Restart();
+ int operator ++ (); // prefix increment operator
+protected:
+ void ParseNextAddress();
+ DwRfc822Tokenizer mTokenizer;
+ DwTokenString mAddrString;
+ int mAddrType;
+private:
+ DwAddressListParser();
+ DwAddressListParser(const DwAddressListParser&);
+ const DwAddressListParser& operator = (const DwAddressListParser&);
+};
+
+#endif
diff --git a/mimelib/mimelib/binhex.h b/mimelib/mimelib/binhex.h
new file mode 100644
index 00000000..468dcfd7
--- /dev/null
+++ b/mimelib/mimelib/binhex.h
@@ -0,0 +1,159 @@
+//=============================================================================
+// File: binhex.h
+// Contents: Declarations for DwBinhex
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_BINHEX_H
+#define DW_BINHEX_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+//=============================================================================
+//+ Name DwBinhex -- Class for converting files to or from Binhex 4.0 format
+//+ Description
+//. {\tt DwBinhex} converts data to or from Binhex 4.0 format. Binhex is a
+//. format used almost exclusively on Macintosh computers for encoding
+//. files into text characters for transmission through the mail transport
+//. system or for archiving on non-Macintosh systems. The format includes
+//. the file name, file type, file creator, Macintosh Finder flags, data fork,
+//. resource fork, and checksums. In MIME, the use of Binhex is deprecated;
+//. applesingle and appledouble are the preferred format for encoding
+//. Macintosh files. The Binhex 4.0 format is described in RFC-1741.
+//. Binhex is a widely used, {\it de facto} standard, but it is not an
+//. official Internet standard.
+//.
+//. To use {\tt DwBinhex} for converting a Macintosh file to Binex format,
+//. call the member functions {\tt SetFileName()}, {\tt SetFileType()},
+//. {\tt SetFileCreator()}, {\tt SetFlag1()}, {\tt SetFlag2()},
+//. {\tt SetDataFork()}, and {\tt SetResourceFork()} to set the elements
+//. to be encoded. Any elements that are not set by calling one of the
+//. member functions are assigned reasonable defaults. Then call the
+//. {\tt Encode()} member function to actually perform the conversion to
+//. Binhex. Finally, call {\tt BinhexChars()} to retrieve the Binhex
+//. characters.
+//.
+//. To use {\tt DwBinhex} for converting a Macintosh file from Binhex format,
+//. call the member function {\tt SetBinhexChars()} to assign the Binhex
+//. characters to be converted. Then call {\tt Decode()} to actually
+//. perform the conversion. Finally, call {\tt FileName()}, {\tt FileType()},
+//. {\tt FileCreator()}, {\tt Flag1()}, {\tt Flag2()}, {\tt DataFork()},
+//. and {\tt ResourceFork()} to extract the decoded elements.
+//.
+//. Note: {\tt DwBinhex} does not change the file name in any way. When you
+//. you are dealing with file names, you should be aware of the fact that
+//. some filenames that are valid on a Macintosh may cause problems or
+//. unexpected results on a non-Macintosh system, and vice versa. Such
+//. problem characters include slash ('/'), colon (':'), space and possibly
+//. other characters.
+//=============================================================================
+// Last modified 1997-08-25
+//+ Noentry ~DwBinhex
+
+
+class DW_EXPORT DwBinhex {
+
+public:
+
+ DwBinhex();
+ //. This is the default constructor.
+
+ virtual ~DwBinhex();
+
+ void Initialize();
+ //. Resets the object's internal state to its initial state. Call
+ //. this member function to reuse the object for more than one encode
+ //. or decode operation.
+
+ const char* FileName() const;
+ void SetFileName(const char* aName);
+ //. Gets or sets the file name. The file name is restricted
+ //. to a maximum length of 63 characters.
+
+ void FileType(char* aBuf) const;
+ void SetFileType(const char* aType);
+ //. Gets or sets the file type. All Macintosh files have a file type,
+ //. which is represented by four bytes. Some examples include "TEXT"
+ //. for a text file, or "APPL" for an application. {\tt aBuf} should
+ //. point to an array of at least four characters.
+
+ void FileCreator(char* aBuf) const;
+ void SetFileCreator(const char* aType);
+ //. Gets or sets the file creator. Most Macintosh files have a creator,
+ //. which is represented by a signature of four bytes. The creator
+ //. specifies which application to launch when a file's icon is double
+ //. clicked. {\tt aBuf} should point to an array of at least four
+ //. characters.
+
+ DwUint8 Flag1() const;
+ void SetFlag1(DwUint8 aFlag);
+ //. Gets or sets the first byte of the Macintosh Finder flags. For
+ //. files that originate on non-Macintosh systems, this byte should
+ //. be set to zero (the default).
+
+ DwUint8 Flag2() const;
+ void SetFlag2(DwUint8 aFlag);
+ //. Gets or sets the second byte of the Macintosh Finder flags. For
+ //. files that originate on non-Macintosh systems, this byte should
+ //. be set to zero (the default).
+
+ const DwString& DataFork() const;
+ void SetDataFork(const DwString& aStr);
+ //. Gets or sets the data fork for the file. For files that originate
+ //. on non-Macintosh systems, such as a GIF or JPEG file, the file data
+ //. should be set as the data fork.
+
+ const DwString& ResourceFork() const;
+ void SetResourceFork(const DwString& aStr);
+ //. Gets or sets the resource fork for the file. For files that originate
+ //. on non-Macintosh systems, such as a GIF or JPEG file, the resource
+ //. should be normally be empty.
+
+ const DwString& BinhexChars() const;
+ void SetBinhexChars(const DwString& aStr);
+ //. Gets or sets the characters of the Binhex encoded file.
+
+ void Encode();
+ //. Converts the Macintosh file information to Binhex format.
+
+ int Decode();
+ //. Converts the Macintosh file information from Binhex format. Returns
+ //. zero if the decode operation completes successufully; otherwise,
+ //. the function returns -1.
+
+private:
+
+ char mFileName[64];
+ char mFileType[8];
+ char mFileCreator[8];
+ DwUint8 mFlag1;
+ DwUint8 mFlag2;
+ DwString mDataFork;
+ DwString mResourceFork;
+ DwString mBinhexChars;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/body.h b/mimelib/mimelib/body.h
new file mode 100644
index 00000000..2133a724
--- /dev/null
+++ b/mimelib/mimelib/body.h
@@ -0,0 +1,275 @@
+//=============================================================================
+// File: body.h
+// Contents: Declarations for DwBody
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_BODY_H
+#define DW_BODY_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_ENTITY_H
+#include <mimelib/entity.h>
+#endif
+
+class DwMessage;
+class DwEntity;
+class DwBodyPart;
+
+//=============================================================================
+//+ Name DwBody -- Class representing a MIME message body
+//+ Description
+//. {\tt DwBody} represents a {\it body}, as described in RFC-2045. A body
+//. is always part of an {\it entity}, which could be either a {\it message}
+//. or a {\it body part}. An entity has a collection of {\it header fields}
+//. and a body. If the content type of a body is ``multipart,'' then the
+//. body contains one or more body parts. If the content type is ``message,''
+//. then the body contains an encapsulated message. In all content types,
+//. the body contains a string of characters.
+//.
+//. In MIME++, a {\tt DwBody} object is contained in a {\tt DwEntity} object.
+//. The {\tt DwBody} object may contain a discrete body consisting only of a
+//. string of characters, or it may be a composite body, consisting of several
+//. contained {\tt DwBodyPart} objects or a single contained {\tt DwMessage}
+//. object. The only reliable way to determine the type of {\tt DwBody} is
+//. to access the Content-Type header field from the {\tt DwHeaders} object
+//. of the {\tt DwEntity} that contains it. For this reason, a {\tt DwBody}
+//. should always be part of a {\tt DwEntity}.
+//.
+//. In the tree (broken-down) representation of a message, a {\tt DwBody}
+//. object can be an intermediate node, having both a parent node and
+//. one or more child nodes, or a leaf node, having a parent but no child
+//. nodes. In either case, the parent node is the {\tt DwEntity} object
+//. that contains it. If it is an intermediate node, it must be of type
+//. multipart with {\tt DwBodyPart} objects as child nodes, or of type
+//. message with a single {\tt DwMessage} object as its child node.
+//.
+//. Normally, you do not create a {\tt DwBody} object directly, but you
+//. access it through the {\tt Body()} member function of {\tt DwEntity},
+//. which creates the {\tt DwBody} object for you.
+//.
+//. To add a {\tt DwBodyPart} to a multipart {\tt DwBody}, use the member
+//. function {\tt AddBodyPart()}. To iterate over the {\tt DwBodyParts}
+//. contained in multipart {\tt DwBody}, get the first {\tt DwBodyPart}
+//. by calling {\tt FirstBodyPart()}. Then get the following {\tt DwBodyParts}
+//. by calling {\tt DwBodyPart::Next()} on the current {\tt DwBodyPart}.
+//. To get the {\tt DwMessage} contained in a {\tt Body} with message
+//. content type, call {\tt Message()}.
+//=============================================================================
+// Last modified 1997-08-23
+//+ Noentry ~DwBody sClassName DeleteBodyParts CopyBodyParts _PrintDebugInfo
+
+
+class DW_EXPORT DwBody : public DwMessageComponent {
+
+ friend class DwHeaders;
+ friend class DwEntity;
+ friend class DwBodyPart;
+
+public:
+
+ DwBody();
+ DwBody(const DwBody& aBody);
+ DwBody(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwBody} object's string representation to the empty string
+ //. and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which performs
+ //. a deep copy of {\tt aBody}.
+ //. The parent of the new {\tt DwBody} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwBody}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwEntity}.
+
+ virtual ~DwBody();
+
+ const DwBody& operator = (const DwBody& aBody);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aBody}. The parent node of the {\tt DwBody} object
+ //. is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwBody} objects. The parse
+ //. method creates or updates the broken-down representation from the
+ //. string representation. For a multipart {\tt DwBody} object, the
+ //. parse method creates a collection of {\tt DwBodyPart} objects.
+ //. For a message {\tt DwBody}, the parse method creates a single
+ //. {\tt DwMessage} object. For any other type of {\tt DwBody},
+ //. the parse method does nothing. This member function calls the
+ //. {\tt Parse()} member function of any objects it creates.
+ //.
+ //. Note: If the {\tt DwBody} object has no parent node -- that is,
+ //. it is not contained by a {\tt DwEntity} object -- then the parse
+ //. method does nothing, since it is unable to determine the type of
+ //. body.
+ //.
+ //. You should call this member function after you set or modify the
+ //. string representation, and before you access a contained
+ //. {\tt DwBodyPart} or {\tt DwMessage}.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwBody} objects. The
+ //. assemble method creates or updates the string representation
+ //. from the broken-down representation. Only {\tt DwBody} objects
+ //. with content type of multipart or message require assembling.
+ //. In either case, the {\tt DwBody} object must be able to find the
+ //. headers of the message or body part that contains it. Therefore,
+ //. if the {\tt DwBody} object is not the child of a {\tt DwEntity}
+ //. ({\it i.e.}, {\tt DwMessage} or {\tt DwBodyPart}) object, the
+ //. {\tt DwBody} cannot be assembled because the content type cannot
+ //. be determined.
+ //.
+ //. This function calls the {\tt Parse()} member function of any
+ //. {\tt DwBodyPart} or {\tt DwMessage} object it contains.
+ //.
+ //. You should call this member function after you add a {\tt DwBodyPart}
+ //. object to a multipart body, or add a {\tt DwMessage} object to a
+ //. message body, and before you access the object's string representation.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwBody} on the free store that has the same
+ //. value as this {\tt DwBody} object. The basic idea is that of
+ //. a virtual copy constructor.
+
+ DwBodyPart* FirstBodyPart() const;
+ //. For a multipart {\tt DwBody}, this member function returns the
+ //. first contained {\tt DwBodyPart} object.
+ //. Use {\tt DwBodyPart::Next()} to iterate through the list of
+ //. {\tt DwBodyPart}s.
+
+ void AddBodyPart(DwBodyPart* aPart);
+ //. For a multipart {\tt DwBody}, this member function appends a
+ //. {\tt DwBodyPart} object to the list. Any {\tt DwBodyPart} objects
+ //. added to a {\tt DwBody} object's list will be deleted by the
+ //. {\tt DwBody} object's destructor.
+
+ void RemoveBodyPart(DwBodyPart* aPart);
+ //. For a multipart {\tt DwBody}, this member function removes a
+ //. {\tt DwBodyPart} object from the list. The caller is responsible
+ //. for deleting the bodypart afterwards!
+
+ DwMessage* Message() const;
+ //. For a {\tt DwBody} with content type of message, this member function
+ //. returns the {\tt DwMessage} encapsulated in it.
+
+ void SetMessage(DwMessage* aMessage);
+ //. For a {\tt DwBody} with content type of message, this member function
+ //. sets the {\tt DwMessage} object it contains.
+
+ static DwBody* NewBody(const DwString& aStr, DwMessageComponent* aParent);
+ //. Creates a new {\tt DwBody} object on the free store.
+ //. If the static data member {\tt sNewBody} is {\tt NULL},
+ //. this member function will create a new {\tt DwBody}
+ //. and return it. Otherwise, {\tt NewBody()} will call
+ //. the user-supplied function pointed to by {\tt sNewBody},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwBody}, and return that object.
+
+ //+ Var sNewBody
+ static DwBody* (*sNewBody)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewBody} is not {\tt NULL}, it is assumed to point to a
+ //. user-supplied function that returns an object from a class
+ //. derived from {\tt DwBody}.
+
+protected:
+
+ DwString mBoundaryStr;
+ //. A cache for the boundary string, which is obtained from the
+ //. headers associated with this body.
+
+ DwString mPreamble;
+ //. Contains the preamble -- the text preceding the first boundary --
+ //. in a ``multipart/*'' media type.
+
+ DwString mEpilogue;
+ //. Contains the epilogue -- the text following the last boundary --
+ //. in a ``multipart/*'' media type.
+
+ DwBodyPart* mFirstBodyPart;
+ //. Points to the first body part in a ``multipart/*'' media type.
+ //. Is {\tt NULL} if there are no body parts.
+
+ DwMessage* mMessage;
+ //. Points to the contained message, in a ``message/*'' media type.
+
+ static const char* const sClassName;
+
+ void _AddBodyPart(DwBodyPart*);
+ //. Adds a body part to a multipart body. This function differs
+ //. from {\tt AddBodyPart} in that it does not set the is-modified
+ //. flag.
+
+ void _RemoveBodyPart(DwBodyPart*);
+ //. Removes a body part from a multipart body. This function differs
+ //. from {\tt RemoveBodyPart} in that it does not set the is-modified
+ //. flag.
+
+ void _SetMessage(DwMessage*);
+ //. Sets a message to a body. This function differs from
+ //. {\tt SetMessage()} in that it does not set the is-modified
+ //. flag.
+
+ void CopyBodyParts(const DwBodyPart* aFirst);
+
+public:
+ void DeleteBodyParts();
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
+
diff --git a/mimelib/mimelib/bodypart.h b/mimelib/mimelib/bodypart.h
new file mode 100644
index 00000000..9ed7f672
--- /dev/null
+++ b/mimelib/mimelib/bodypart.h
@@ -0,0 +1,156 @@
+//=============================================================================
+// File: bodypart.h
+// Contents: Declarations for DwBodyPart
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_BODYPART_H
+#define DW_BODYPART_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_ENTITY_H
+#include <mimelib/entity.h>
+#endif
+
+class DwMessage;
+class DwEntity;
+class DwBody;
+
+
+//=============================================================================
+//+ Name DwBodyPart -- Class representing a MIME body-part
+//+ Description
+//. {\tt DwBodyPart} represents a {\it body part}, as described in RFC-2045
+//. and RFC-2046. A body part is an {\it entity}, so it has a collection
+//. of headers and a {\it body}. A body part is different from a {\it message}
+//. in that a body part is part of a multipart body.
+//.
+//. In MIME++, a {\tt DwBodyPart} is a subclass of {\tt DwEntity}; therefore,
+//. it contains both a {\tt DwHeaders} object and a {\tt DwBody} object,
+//. and it is contained in a multipart {\tt DwBody} object.
+//.
+//. As with {\tt DwMessage}, most of the functionality of {\tt DwBodyPart} is
+//. implemented by the abstract class {\tt DwEntity}.
+//=============================================================================
+// Last modified 1997-08-23
+//+ Noentry ~DwBodyPart _PrintDebugInfo mNext sClassName
+
+
+class DW_EXPORT DwBodyPart : public DwEntity {
+
+public:
+
+ DwBodyPart();
+ DwBodyPart(const DwBodyPart& aPart);
+ DwBodyPart(const DwEntity& aPart);
+ DwBodyPart(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwBodyPart} object's string representation to the empty string
+ //. and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which performs
+ //. a deep copy of {\tt aPart}.
+ //. The parent of the new {\tt DwBodyPart} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwBodyPart}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwBody}.
+
+ virtual ~DwBodyPart();
+
+ const DwBodyPart& operator = (const DwBodyPart& aPart);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aPart}. The parent node of the {\tt DwBodyPart} object
+ //. is not changed.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwBodyPart} on the free store that has the same
+ //. value as this {\tt DwBodyPart} object. The basic idea is that of
+ //. a virtual copy constructor.
+
+ static DwBodyPart* NewBodyPart(const DwString& aStr,
+ DwMessageComponent* aParent);
+ //. Creates a new {\tt DwBodyPart} on the free store.
+ //. If the static data member {\tt sNewBodyPart} is {\tt NULL},
+ //. this member function will create a new {\tt DwBodyPart}
+ //. and return it. Otherwise, {\tt NewBodyPart()} will call
+ //. the user-supplied function pointed to by {\tt sNewBodyPart},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwBodyPart}, and return that object.
+
+ DwBodyPart* Next() const;
+ //. This member function returns the next {\tt DwBodyPart} object
+ //. following this {\tt DwBodyPart} in the list of {\tt DwBodyPart}
+ //. objects contained in a multipart {\tt DwBody}.
+
+ void SetNext(const DwBodyPart* aPart);
+ //. This advanced function sets {\tt aPart} as the next {\tt DwBodyPart}
+ //. object following this {\tt DwBodyPart} in the list of {\tt DwBodyPart}
+ //. objects contained in a multipart {\tt DwBody}. Since {\tt DwBody}
+ //. contains a member function for adding a {\tt DwBodyPart} object to
+ //. its list, this function should be avoided for most applications.
+
+ //+ Var sNewBodyPart
+ static DwBodyPart* (*sNewBodyPart)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewBodyPart} is not {\tt NULL}, it is assumed to point to a
+ //. user-supplied function that returns an object from a class
+ //. derived from {\tt DwBodyPart}.
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+private:
+
+ const DwBodyPart* mNext;
+ static const char* const sClassName;
+
+};
+
+#endif
+
diff --git a/mimelib/mimelib/boyermor.h b/mimelib/mimelib/boyermor.h
new file mode 100644
index 00000000..f04e573b
--- /dev/null
+++ b/mimelib/mimelib/boyermor.h
@@ -0,0 +1,84 @@
+//=============================================================================
+// File: boyermor.h
+// Contents: Declarations for DwBoyerMoore
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_BOYERMOR_H
+#define DW_BOYERMOR_H
+
+#include <stddef.h>
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+
+//=============================================================================
+//+ Name DwBoyerMoore -- Class for executing Boyer-Moore string search algorithm
+//+ Description
+//. {\tt DwBoyerMoore} implements the Boyer-Moore algorithm for searching
+//. for a string. The Boyer-Moore algorithm is fast, but requires a bit
+//. of start-up overhead compared to a brute force algorithm.
+//=============================================================================
+// Last modified 1997-08-23
+//+ Noentry ~DwBoyerMoore
+
+
+class DW_EXPORT DwBoyerMoore {
+
+public:
+
+ DwBoyerMoore(const char* aCstr);
+ DwBoyerMoore(const DwString& aStr);
+ DwBoyerMoore(const DwBoyerMoore& other);
+ //. Constructs a {\tt DwBoyerMoore} object for searching for a particular
+ //. string.
+
+ virtual ~DwBoyerMoore();
+
+ const DwBoyerMoore & operator=( const DwBoyerMoore & other );
+
+ void Assign(const char* aCstr);
+ void Assign(const DwString& aStr);
+ //. Sets the string to search for.
+
+ size_t FindIn(const DwString& aStr, size_t aPos, bool aCs = true) const;
+ //. Searches for the search string in {\tt aStr} starting at position
+ //. {\tt aPos}. If found, the function returns the first position in
+ //. {\tt aStr} where the search string was found. If not found, the
+ //. function returns {\tt DwString::npos}. Search is case sensitive iff
+ //. {\tt aCs} is true.
+
+private:
+
+ size_t mPatLen;
+ char* mPat;
+ char* mCiPat;
+ unsigned char mSkipAmt[256];
+ unsigned char mCiSkipAmt[256]; // case insensitive skip table
+
+ void _Assign(const char* aPat, size_t aPatLen);
+};
+
+#endif
diff --git a/mimelib/mimelib/config.h b/mimelib/mimelib/config.h
new file mode 100644
index 00000000..529f3ff2
--- /dev/null
+++ b/mimelib/mimelib/config.h
@@ -0,0 +1,170 @@
+//=============================================================================
+// File: config.h
+// Contents: Declarations of macros for configuring the library
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_CONFIG_H
+#define DW_CONFIG_H
+
+//-----------------------------------------------------------------------------
+// Platform
+//
+// Make sure that the following lines define either DW_UNIX or DW_WIN32.
+//-----------------------------------------------------------------------------
+
+#if defined(_WIN32) || defined(__WIN32__)
+# define DW_WIN32
+#endif
+
+#if defined(__unix__) || defined(__unix) || defined(_AIX) || defined(__NetBSD__) || defined(__APPLE__)
+# define DW_UNIX
+#endif
+
+//-----------------------------------------------------------------------------
+// End of line characters
+//
+// Uncomment one of the following to indicate whether you want the library to
+// use LF or CR LF as the end of line characters.
+//
+// I strongly recommend using LF ('\n') alone as the end of line character,
+// since that is the normal end of line character for C and C++ libraries.
+// Then you can do the conversion to and from the CR LF end of line
+// characters at the interface to the transport system.
+//-----------------------------------------------------------------------------
+
+#define DW_EOL_LF
+//#define DW_EOL_CRLF
+
+#if defined(DW_EOL_CRLF)
+# define DW_EOL "\r\n"
+#elif defined(DW_EOL_LF)
+# define DW_EOL "\n"
+#else
+# error "Must define DW_EOL_CRLF, DW_EOL_LF"
+#endif
+
+//-----------------------------------------------------------------------------
+// C++ namespaces
+//
+// Uncomment the following line if you want the DwMime namespace to be defined.
+// If the namespace is not defined, then enums are specified as part of a
+// DwMime class.
+//-----------------------------------------------------------------------------
+
+//#define DW_USE_NAMESPACES
+
+
+//-----------------------------------------------------------------------------
+// C++ library string class
+//
+// Uncomment the following line if you want DwString typedef-ed to the
+// ANSI/ISO string class.
+//
+// *** Important: This option is not working or not fully tested yet ***
+//-----------------------------------------------------------------------------
+
+//#define DW_USE_ANSI_STRING
+
+
+//-----------------------------------------------------------------------------
+// bool type
+//
+// Uncomment the following line if you want DwBool typedef-ed to int instead
+// of bool.
+//-----------------------------------------------------------------------------
+
+//#define DW_NO_BOOL
+
+#if defined(DW_NO_BOOL)
+
+typedef int DwBool;
+#define DwFalse 0
+#define DwTrue 1
+
+#else
+
+typedef bool DwBool;
+#define DwFalse false
+#define DwTrue true
+
+#endif
+
+
+//-----------------------------------------------------------------------------
+// DLL vs static library
+//
+// Win32 users: Uncomment out the following line to create a static library
+// instead of a DLL.
+//-----------------------------------------------------------------------------
+
+// #define DW_NO_DLL
+
+#if defined(DW_WIN32) && !defined(DW_NO_DLL)
+# ifdef DW_IMPLEMENTATION
+# define DW_EXPORT __declspec(dllexport)
+# else
+# define DW_EXPORT __declspec(dllimport)
+# endif
+#else
+# include <kdepimmacros.h>
+# define DW_EXPORT KDE_EXPORT
+#endif
+
+//-----------------------------------------------------------------------------
+// Type definitions
+//
+// Make sure the following types are accurate for your machine.
+//-----------------------------------------------------------------------------
+
+#if defined(__BCPLUSPLUS__) && !defined(__WIN32__)
+# define DW_STD_16_BIT
+#endif
+
+#if defined(__alpha) || defined(__sgi)
+# define DW_STD_64_BIT
+#endif
+
+#if !defined(DW_STD_16_BIT) && !defined(DW_STD_64_BIT)
+# define DW_STD_32_BIT
+#endif
+
+typedef char DwChar7; // type for ASCII characters
+typedef unsigned char DwChar8; // type for 8-bit characters
+typedef signed char DwInt8; // type for 8-bit signed integers
+typedef unsigned char DwUint8; // type for 8-bit unsigned integers
+
+#if defined(DW_STD_16_BIT)
+typedef int DwInt16; // 16-bit signed integers
+typedef unsigned int DwUint16; // 16-bit unsigned integers
+typedef long DwInt32; // 32-bit signed integers
+typedef unsigned long DwUint32; // 32-bit unsigned integers
+#elif defined(DW_STD_32_BIT)
+typedef short DwInt16;
+typedef unsigned short DwUint16;
+typedef int DwInt32;
+typedef unsigned int DwUint32;
+#elif defined(DW_STD_64_BIT)
+typedef short DwInt16;
+typedef unsigned short DwUint16;
+typedef int DwInt32;
+typedef unsigned int DwUint32;
+#endif
+
+#endif
diff --git a/mimelib/mimelib/datetime.h b/mimelib/mimelib/datetime.h
new file mode 100644
index 00000000..d23eba0b
--- /dev/null
+++ b/mimelib/mimelib/datetime.h
@@ -0,0 +1,350 @@
+//=============================================================================
+// File: datetime.h
+// Contents: Declarations for DwDateTime
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_DATETIME_H
+#define DW_DATETIME_H
+
+#include <time.h>
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_FIELDBDY_H
+#include <mimelib/fieldbdy.h>
+#endif
+
+//=============================================================================
+//+ Name DwDateTime -- Class representing an RFC-822 date-time
+//+ Description
+//. {\tt DwDatetime} represents a {\it date-time} as described in RFC-822
+//. and RFC-1123. The parse method for {\tt DwDateTime} parses the
+//. string representation to extract the year, month, day, hour, minute,
+//. second, and time zone. {\tt DwDateTime} provides member functions
+//. to set or get the individual components of the date-time.
+//=============================================================================
+// Last modified 1997-08-23
+//+ Noentry ~DwDateTime mYear mMonth mDay mHour mMinute mSecond mZone
+//+ Noentry sDefaultZone sIsDefaultZoneSet _PrintDebugInfo
+
+
+class DW_EXPORT DwDateTime : public DwFieldBody {
+
+public:
+
+ DwDateTime();
+ DwDateTime(const DwDateTime& aDateTime);
+ DwDateTime(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which assigns
+ //. the current date and time as reported by the operating system.
+ //.
+ //. The second constructor is the copy constructor. The parent of
+ //. the new {\tt DwDateTime} object is set to {\tt NULL}.
+ //.
+ //. The third constructor sets {\tt aStr} as the {\tt DwDateTime}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called after
+ //. this constructor to extract the date and time information from the
+ //. string representation. Unless it is {\tt NULL}, {\tt aParent} should
+ //. point to an object of a class derived from {\tt DwField}.
+
+ virtual ~DwDateTime();
+
+ const DwDateTime& operator = (const DwDateTime& aDateTime);
+ //. This is the assignment operator, which sets this {\tt DwDateTime}
+ //. object to the same value as {\tt aDateTime}.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwDateTime} objects. The parse
+ //. method creates or updates the broken-down representation from the
+ //. string representation. For {\tt DwDateTime} objects, the parse
+ //. method parses the string representation to extract the year,
+ //. month, day, hour, minute, second, and time zone.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwDateTime} objects.
+ //. It should be called whenever one of the object's attributes
+ //. is changed in order to assemble the string representation from
+ //. its broken-down representation. It will be called
+ //. automatically for this object by the parent object's
+ //. {\tt Assemble()} member function if the is-modified flag is set.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwDateTime} on the free store that has the same
+ //. value as this {\tt DwDateTime} object. The basic idea is that of
+ //. a virtual copy constructor.
+
+ DwUint32 AsUnixTime() const;
+ //. Returns the date and time as a UNIX (POSIX) time, defined as the
+ //. number of seconds elapsed since 1 Jan 1970 00:00:00 UTC.
+
+ void FromUnixTime(DwUint32 aTime);
+ //. Sets the date and time from {\tt aTime}, interpreted as the number of
+ //. of seconds elapsed since 1 Jan 1970 00:00:00 UTC.
+
+ void FromCalendarTime(time_t aTime);
+ //. Sets the date and time from {\tt aTime}, which is assumed to be in a
+ //. format compatible with the native {\tt time()} ANSI C function.
+ //. For most UNIX systems, this function is the same as the function
+ //. {\tt FromUnixTime()}. (For efficiency, use {\tt FromUnixTime()}
+ //. instead of {\tt FromCalendarTime()} if possible).
+
+ DwInt32 DateAsJulianDayNum() const;
+ //. Returns the Julian Day Number, defined as the number of days elapsed
+ //. since 1 Jan 4713 BC. The JDN is calculated directly from the values
+ //. of the year, month, and day; time zone information is ignored.
+
+ void DateFromJulianDayNum(DwInt32 aJdn);
+ //. Sets the year, month, and day from {\tt aJdn}, interpreted as a Julian
+ //. Day Number. By definition, the JDN is the number of days elapsed
+ //. since 1 Jan 4713 BC. This member function ignores time zone
+ //. information.
+
+ DwInt32 TimeAsSecsPastMidnight() const;
+ //. Returns the number of seconds past midnight. The value is
+ //. calculated directly from the values of the hour, minute, and
+ //. second; time zone information is ignored.
+
+ void TimeFromSecsPastMidnight(DwInt32 aSecs);
+ //. Sets the hour, minute, and second from {\tt aSecs}, interpreted as the
+ //. number of seconds elapsed since midnight. This member function
+ //. ignores time zone information. The argument {\tt aSecs} should be in
+ //. the range 0 to 86399, inclusive.
+
+ int Year() const;
+ //. Returns the four digit year, e.g. 1997.
+
+ void SetYear(int aYear);
+ //. Sets the year from {\tt aYear}, which should be a four digit year.
+
+ int Month() const;
+ //. Returns the month. Values range from 1 to 12.
+
+ void SetMonth(int aMonth);
+ //. Sets the month from {\tt aMonth}, which should be in the range 1
+ //. to 12.
+
+ int Day() const;
+ //. Returns the day of the month. Values range from 1 to 31.
+
+ void SetDay(int aDay);
+ //. Sets the day of the month from {\tt aDay}.
+
+ int Hour() const;
+ //. Returns the hour according to the 24 hour clock.
+ //. Values range from 0 to 23.
+
+ void SetHour(int aHour);
+ //. Sets the hour from {\tt aHour} based on the 24-hour clock. {\tt aHour}
+ //. should be in the range 0 to 23.
+
+ int Minute() const;
+ //. Returns the minute. Values range from 0 to 59.
+
+ void SetMinute(int aMinute);
+ //. Sets the minute from {\tt aMinute}, which should be in the range 0
+ //. to 59.
+
+ int Second() const;
+ //. Returns the second. Values range from 0 to 59.
+
+ void SetSecond(int aSecond);
+ //. Sets the second from {\tt aSecond}, which should be in the range 0
+ //. to 59.
+
+ int Zone() const;
+ //. Returns the time zone as the diffence in minutes between local time
+ //. and Coordinated Universal Time (UTC or GMT).
+
+ void SetZone(int aZone);
+ //. Sets the time zone from {\tt aZone}, interpreted as the time difference
+ //. in minutes between local time and Coordinated Universal Time
+ //. (UTC, or GMT).
+
+ static void SetDefaultZone(int aZone);
+ //. Sets the default time zone. {\tt aZone} should be the time difference
+ //. in minutes between local time and Coordinated Universal Time
+ //. (UTC, or GMT). The value is used to set the time zone for any
+ //. objects created using the default constructor.
+
+ static DwDateTime* NewDateTime(const DwString&, DwMessageComponent*);
+ //. Creates a new {\tt DwDateTime} object on the free store.
+ //. If the static data member {\tt sNewDateTime} is {\tt NULL},
+ //. this member function will create a new {\tt DwDateTime}
+ //. and return it. Otherwise, {\tt NewDateTime()} will call
+ //. the user-supplied function pointed to by {\tt sNewDateTime},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwDateTime}, and return that object.
+
+ //+ Var sNewDateTime
+ static DwDateTime* (*sNewDateTime)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewDateTime} is not {\tt NULL}, it is assumed to point to a
+ //. user-supplied function that returns an object from a class derived
+ //. from {\tt DwDateTime}.
+
+protected:
+
+ void _FromUnixTime(DwUint32 aTime);
+ //. Like {\tt FromUnixTime()}, but doesn't set the is-modified flag.
+
+ void _FromCalendarTime(time_t aTime);
+ //. Like {\tt FromCalendarTime()}, but doesn't set the is-modified flag.
+
+ int mYear;
+ int mMonth;
+ int mDay;
+ int mHour;
+ int mMinute;
+ int mSecond;
+ int mZone;
+
+ static int sDefaultZone;
+ static int sIsDefaultZoneSet;
+
+private:
+
+ static const char* const sClassName;
+
+ void Init();
+ //. Initialization code common to all constructors.
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+
+inline int DwDateTime::Year() const
+{
+ return mYear;
+}
+
+
+inline int DwDateTime::Month() const
+{
+ return mMonth;
+}
+
+
+inline int DwDateTime::Day() const
+{
+ return mDay;
+}
+
+
+inline int DwDateTime::Hour() const
+{
+ return mHour;
+}
+
+
+inline int DwDateTime::Minute() const
+{
+ return mMinute;
+}
+
+
+inline int DwDateTime::Second() const
+{
+ return mSecond;
+}
+
+
+inline int DwDateTime::Zone() const
+{
+ return mZone;
+}
+
+
+inline void DwDateTime::SetYear(int aYear)
+{
+ mYear = aYear;
+ SetModified();
+}
+
+
+inline void DwDateTime::SetMonth(int aMonth)
+{
+ mMonth = aMonth;
+ SetModified();
+}
+
+
+inline void DwDateTime::SetDay(int aDay)
+{
+ mDay = aDay;
+ SetModified();
+}
+
+
+inline void DwDateTime::SetHour(int aHour)
+{
+ mHour = aHour;
+ SetModified();
+}
+
+
+inline void DwDateTime::SetMinute(int aMinute)
+{
+ mMinute = aMinute;
+ SetModified();
+}
+
+
+inline void DwDateTime::SetSecond(int aSecond)
+{
+ mSecond = aSecond;
+ SetModified();
+}
+
+
+inline void DwDateTime::SetZone(int aZone)
+{
+ mZone = aZone;
+ SetModified();
+}
+
+#endif
diff --git a/mimelib/mimelib/debug.h b/mimelib/mimelib/debug.h
new file mode 100644
index 00000000..95325af5
--- /dev/null
+++ b/mimelib/mimelib/debug.h
@@ -0,0 +1,51 @@
+//=============================================================================
+// File: dw_debug.h
+// Contents: Macros for debugging
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_DEBUG_H
+#define DW_DEBUG_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#if !defined (DW_DEBUG_VERSION) && !defined (DW_DEVELOPMENT_VERSION)
+#define NDEBUG
+#endif
+
+#if defined (DW_DEBUG_VERSION)
+#define DBG_STMT(x) x;
+#else
+#define DBG_STMT(x) ;
+#endif
+
+#if defined (DW_DEBUG_VERSION) || defined (DW_DEVELOPMENT_VERSION)
+#define DEV_STMT(x) x;
+#else
+#define DEV_STMT(x) ;
+#endif
+
+#include <assert.h>
+
+#define ASSERT assert
+
+#endif
+
diff --git a/mimelib/mimelib/disptype.h b/mimelib/mimelib/disptype.h
new file mode 100644
index 00000000..59c740cb
--- /dev/null
+++ b/mimelib/mimelib/disptype.h
@@ -0,0 +1,219 @@
+//=============================================================================
+// File: disptype.h
+// Contents: Declarations for DwDispositionType
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_DISPTYPE_H
+#define DW_DISPTYPE_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_FIELDBDY_H
+#include <mimelib/fieldbdy.h>
+#endif
+
+class DwParameter;
+
+//=============================================================================
+//+ Name DwDispositionType -- Class representing a MIME content-disposition field body
+//+ Description
+//. {\tt DwDispositionType} represents a field body for the
+//. Content-Disposition header field as described in RFC-1806. This header
+//. field specifies whether the content of a message or body part should
+//. be displayed automatically to a user. A disposition-type of inline
+//. indicates that the content should be displayed; a disposition-type
+//. of attachment indicates that it should not be. RFC-1806 specifies
+//. that a filename parameter may be optionally included in the field
+//. body; the filename parameter suggests a file name for saving the
+//. message or body part's content.
+//.
+//. {\tt DwDispositionType} provides convenience functions that allow you
+//. to set or get the disposition-type as an enumerated value, to set or
+//. get the filename parameter, or to manage a list of parameters.
+//.
+//. RFC-1806 specifically states that the Content-Disposition header field
+//. is experimental and not a proposed standard.
+//=============================================================================
+// Last modified 1997-08-23
+//+ Noentry ~DwDispositionType _AddParameter EnumToStr StrToEnum
+//+ Noentry DeleteParameterList CopyParameterList mDispositionType
+//+ Noentry mDispositionTypeStr mFilenameStr mFirstParameter
+//+ Noentry PrintDebugInfo _PrintDebugInfo CheckInvariants
+
+
+class DW_EXPORT DwDispositionType : public DwFieldBody {
+
+public:
+
+ DwDispositionType();
+ DwDispositionType(const DwDispositionType& aDispType);
+ DwDispositionType(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwDispositionType} object's string representation to the empty
+ //. string and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which performs
+ //. deep copy of {\tt aDispType}.
+ //. The parent of the new {\tt DwDispositionType} object is set to
+ //. {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwDispositionType}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwField}.
+
+ virtual ~DwDispositionType();
+
+ const DwDispositionType& operator = (const DwDispositionType& aDispType);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aDispType}. The parent node of the {\tt DwDipositionType}
+ //. object is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwDispositionType} objects.
+ //. It should be called immediately after the string representation
+ //. is modified and before the parts of the broken-down
+ //. representation are accessed.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwDispositionType} objects.
+ //. It should be called whenever one of the object's attributes
+ //. is changed in order to assemble the string representation from
+ //. its broken-down representation. It will be called
+ //. automatically for this object by the parent object's
+ //. {\tt Assemble()} member function if the is-modified flag is set.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwDispositionType} object on the free store that
+ //. has the same value as this {\tt DwDispositionType} object. The basic
+ //. idea is that of a virtual copy constructor.
+
+ int DispositionType() const;
+ //. Returns the disposition-type as an enumerated value. Valid
+ //. enumerated types, which are defined in enum.h, include
+ //. {\tt DwMime::kDispTypeNull}, {\tt DwMime::kDispTypeUnknown},
+ //. {\tt DwMime::kDispTypeInline}, and {\tt DwMime::kDispTypeAttachment}.
+
+ void SetDispositionType(int aType);
+ //. Sets the disposition-type from the enumerated value {\tt aType}.
+ //. Valid enumerated types, which are defined in enum.h, include
+ //. {\tt DwMime::kDispTypeNull}, {\tt DwMime::kDispTypeUnknown},
+ //. {\tt DwMime::kDispTypeInline}, and {\tt DwMime::kDispTypeAttachment}.
+
+ const DwString& DispositionTypeStr() const;
+ //. Returns the disposition-type as a string.
+
+ void SetDispositionTypeStr(const DwString& aStr);
+ //. Sets the disposition-type from a string.
+
+ const DwString& Filename() const;
+ //. This convenience function returns the value from the filename
+ //. parameter, if present. If no filename parameter is present,
+ //. an empty string is returned.
+
+ void SetFilename(const DwString& aStr);
+ //. This convenience function sets the value of the filename parameter
+ //. to {\tt aStr}.
+
+ DwParameter* FirstParameter() const;
+ //. Returns the first {\tt DwParameter} object in the list managed by
+ //. this {\tt DwDispositionType} object, or {\tt NULL} if no parameters are
+ //. present. Use {\tt DwParameter::Next()} to iterate through the list.
+
+ void AddParameter(DwParameter* aParam);
+ //. Adds a {\tt DwParameter} object to the list managed by this
+ //. {\tt DwDispositionType} object.
+
+ static DwDispositionType* NewDispositionType(const DwString& aStr,
+ DwMessageComponent* aParent);
+ //. Creates a new {\tt DwDispositionType} object on the free store.
+ //. If the static data member {\tt sNewDispositionType} is {\tt NULL},
+ //. this member function will create a new {\tt DwDispositionType}
+ //. and return it. Otherwise, {\tt NewDispositionType()} will call
+ //. the user-supplied function pointed to by {\tt sNewDispositionType},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwDispositionType}, and return that object.
+
+ //+ Var sNewDispositionType
+ static DwDispositionType* (*sNewDispositionType)(const DwString&,
+ DwMessageComponent*);
+ //. If {\tt sNewDispositionType} is not {\tt NULL}, it is assumed to
+ //. point to a user-supplied function that returns an object from a
+ //. class derived from {\tt DwDispositionType}.
+
+protected:
+
+ void _AddParameter(DwParameter* aParam);
+ //. Adds a parameter to the list without setting the is-modified flag.
+
+ virtual void EnumToStr();
+ virtual void StrToEnum();
+ void DeleteParameterList();
+ void CopyParameterList(DwParameter* aFirst);
+
+ int mDispositionType;
+ DwString mDispositionTypeStr;
+ DwString mFilenameStr;
+ DwParameter* mFirstParameter;
+
+private:
+
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/entity.h b/mimelib/mimelib/entity.h
new file mode 100644
index 00000000..e809c282
--- /dev/null
+++ b/mimelib/mimelib/entity.h
@@ -0,0 +1,184 @@
+//=============================================================================
+// File: entity.h
+// Contents: Declarations for DwEntity
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_ENTITY_H
+#define DW_ENTITY_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_MSGCMP_H
+#include <mimelib/msgcmp.h>
+#endif
+
+class DwHeaders;
+class DwBody;
+
+//=============================================================================
+//+ Name DwEntity -- Abstract class representing a MIME entity
+//+ Description
+//. RFC-2045 defines an {\it entity} as either a {\it message} or a
+//. {\it body part}, both of which have a collection of headers and
+//. a {\it body}. In MIME++, an entity is represented by the class
+//. {\tt DwEntity}, which contains both a {\tt DwHeaders} object and
+//. a {\tt DwBody} object.
+//.
+//. In the tree (broken-down) representation of message, a {\tt DwEntity}
+//. object may be either a root node, having child nodes but no parent
+//. node, or an intermediate node, having both a parent node and child nodes.
+//. A {\tt DwEntity} object that is a root node must also be a {\tt DwMessage}
+//. object. If a {\tt DwEntity} object is an intermediate node, its parent
+//. must be a {\tt DwBody} object. The child nodes of a {\tt DwEntity}
+//. object are the {\tt DwHeaders} and {\tt DwBody} objects it contains.
+//.
+//. Since {\tt DwEntity} is an abstract base class, you cannot create
+//. instances of it directly. {\tt DwEntity} has two derived classes,
+//. {\tt DwMessage} and {\tt DwBodyPart}, which are concrete classes.
+//.
+//. To access the contained {\tt DwHeaders} object, use the member function
+//. {\tt Headers()}. To access the contained {\tt DwBody} object, use the
+//. member function {\tt Body()}.
+//=============================================================================
+// Last updated 1997-08-23
+//+ Noentry ~DwEntity mHeaders mBody _PrintDebugInfo
+
+class DW_EXPORT DwEntity : public DwMessageComponent {
+
+public:
+
+ DwEntity();
+ DwEntity(const DwEntity& aEntity);
+ DwEntity(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwEntity} object's string representation to the empty string
+ //. and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which performs
+ //. a deep copy of {\tt aEntity}.
+ //. The parent of the new {\tt DwEntity} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwEntity}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwBody}.
+
+ virtual ~DwEntity();
+
+ const DwEntity& operator = (const DwEntity& aEntity);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aEntity}. The parent node of the {\tt DwEntity} object
+ //. is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwEntity} objects. The parse
+ //. method creates or updates the broken-down representation from the
+ //. string representation. For {\tt DwEntity} objects, the parse
+ //. method parses the string representation and sets the values of
+ //. the {\tt DwHeaders} and {\tt DwBody} objects it contains. This
+ //. member function also calls the {\tt Parse()} member functions
+ //. of the contained {\tt DwHeaders} and {\tt DwBody} objects.
+ //.
+ //. You should call this member function after you set or modify the
+ //. string representation, and before you access either the contained
+ //. headers or body.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble(DwHeaders& aHeaders, DwBody& aBody);
+ // Assemble *without* first assembling the Header and the Body.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwEntity} objects. The
+ //. assemble method creates or updates the string representation from
+ //. the broken-down representation. In more concrete terms, the
+ //. assemble method builds the string representation from the string
+ //. representations of the contained {\tt DwHeaders} and {\tt DwBody}
+ //. objects. This member function calls the {\tt Assemble()} member
+ //. functions of its {\tt DwHeaders} and {\tt DwBody} objects.
+ //.
+ //. You should call this member function after you modify either the
+ //. contained headers or body, and before you retrieve the string
+ //. representation.
+ //.
+ //. This function clears the is-modified flag.
+
+ bool hasHeaders() const { return 0 != mHeaders; }
+
+ DwHeaders& Headers() const;
+ //. This function returns the {\tt DwHeaders} object contained by
+ //. this object.
+
+ DwBody& Body() const;
+ //. This function returns the {\tt DwBody} object contained by this object.
+
+ int BodySize() const;
+ //. Get the size of the Body
+
+ void SetBodySize( int size ) { mBodySize = size; }
+ //. Explicitly set the size of the Body
+ //. This is needed if the body is empty but you know the size and others
+ //. should be able to access it
+
+protected:
+
+ DwHeaders* mHeaders;
+ DwBody* mBody;
+
+private:
+
+ static const char* const sClassName;
+ int mBodySize; // normally mBody->AsString().length()
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/enum.h b/mimelib/mimelib/enum.h
new file mode 100644
index 00000000..9e2d0ee3
--- /dev/null
+++ b/mimelib/mimelib/enum.h
@@ -0,0 +1,193 @@
+//=============================================================================
+// File: enum.h
+// Contents: Declarations of global constants and function prototypes
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_ENUM_H
+#define DW_ENUM_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+//-----------------------------------------------------------------------------
+// Enumerated values
+//-----------------------------------------------------------------------------
+
+#if defined(DW_USE_NAMESPACES)
+namespace DwMime {
+#else
+struct DwMime {
+#endif
+
+// Content transfer encoding
+
+enum {
+ kCteNull,
+ kCteUnknown,
+ kCte7bit,
+ kCte8bit,
+ kCteBinary,
+ kCteQuotedPrintable,
+ kCteQp = kCteQuotedPrintable,
+ kCteBase64,
+ kCteLast
+};
+
+// Content types
+
+enum {
+ kTypeNull,
+ kTypeUnknown,
+ kTypeText,
+ kTypeMultipart,
+ kTypeMessage,
+ kTypeApplication,
+ kTypeImage,
+ kTypeAudio,
+ kTypeVideo,
+ kTypeModel,
+ kTypeLast
+};
+
+// Content subtypes
+
+enum {
+ kSubtypeNull,
+ kSubtypeUnknown,
+ // Text
+ kSubtypePlain, // RFC-1521
+ kSubtypeRichtext, // RFC-1341
+ kSubtypeEnriched,
+ kSubtypeHtml,
+ kSubtypeXVCard,
+ kSubtypeVCal,
+ kSubtypeRtf,
+ kSubtypeXDiff,
+ // Multipart
+ kSubtypeMixed,
+ kSubtypeAlternative,
+ kSubtypeDigest,
+ kSubtypeParallel,
+ kSubtypeSigned,
+ kSubtypeEncrypted,
+ kSubtypeReport,
+ kSubtypeRelated,
+ // Message
+ kSubtypeRfc822,
+ kSubtypeDispositionNotification,
+ // Signed content
+ kSubtypePartial,
+ kSubtypeExternalBody,
+ // Application
+ kSubtypePostscript,
+ kSubtypeOctetStream,
+ kSubtypePgpSignature,
+ kSubtypePgpEncrypted,
+ kSubtypePgpClearsigned,
+ kSubtypePkcs7Signature,
+ kSubtypePkcs7Mime,
+ kSubtypeMsTNEF,
+ kSubtypeChiasmusText,
+ // Image
+ kSubtypeJpeg,
+ kSubtypeGif,
+ // Audio
+ kSubtypeBasic,
+ // Video
+ kSubtypeMpeg,
+ // Last
+ kSubtypeLast
+};
+
+// Well-known header fields
+
+enum {
+ kFldNull,
+ kFldUnknown,
+ // RFC-822
+ kFldBcc,
+ kFldCc,
+ kFldComments,
+ kFldDate,
+ kFldEncrypted,
+ kFldFrom,
+ kFldInReplyTo,
+ kFldKeywords,
+ kFldMessageId,
+ kFldReceived,
+ kFldReferences,
+ kFldReplyTo,
+ kFldResentBcc,
+ kFldResentCc,
+ kFldResentDate,
+ kFldResentFrom,
+ kFldResentMessageId,
+ kFldResentReplyTo,
+ kFldResentSender,
+ kFldResentTo,
+ kFldReturnPath,
+ kFldSender,
+ kFldTo,
+ kFldSubject,
+ // RFC-1036
+ kFldApproved,
+ kFldControl,
+ kFldDistribution,
+ kFldExpires,
+ kFldFollowupTo,
+ kFldLines,
+ kFldNewsgroups,
+ kFldOrganization,
+ kFldPath,
+ kFldSummary,
+ kFldXref,
+ // RFC-1521
+ kFldContentDescription,
+ kFldContentId,
+ kFldContentTransferEncoding,
+ kFldCte = kFldContentTransferEncoding,
+ kFldContentType,
+ kFldMimeVersion,
+ // RFC-1544
+ kFldContentMd5,
+ // RFC-1806
+ kFldContentDisposition,
+ // Last
+ kFldLast
+};
+
+
+// Disposition type (Content-Disposition header field, see RFC-1806)
+enum {
+ kDispTypeNull,
+ kDispTypeUnknown,
+ kDispTypeInline,
+ kDispTypeAttachment
+};
+
+
+#if defined(DW_USE_NAMESPACES)
+} // end namespace DwMime
+#else
+}; // end DwMime class declaration
+#endif
+
+#endif
diff --git a/mimelib/mimelib/field.h b/mimelib/mimelib/field.h
new file mode 100644
index 00000000..9ada823c
--- /dev/null
+++ b/mimelib/mimelib/field.h
@@ -0,0 +1,269 @@
+//=============================================================================
+// File: field.h
+// Contents: Declarations for DwField
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_FIELD_H
+#define DW_FIELD_H
+
+#include <iostream>
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_MSGCMP_H
+#include <mimelib/msgcmp.h>
+#endif
+
+class DwHeaders;
+class DwFieldBody;
+
+//=============================================================================
+//+ Name DwField -- Class representing a MIME header field
+//+ Description
+//. {\tt DwField} represents a header field as described in RFC-822.
+//. According to RFC-822, a field contains a field name and a field body.
+//. In MIME++, a {\tt DwField} contains three elements: a {\tt DwString}
+//. that contains its field name, a {\tt DwString} that contains its
+//. field body, and a {\tt DwFieldBody} object that contains a broken-down
+//. (that is, parsed) version of its field body.
+//.
+//. In the tree (broken-down) representation of message, a {\tt DwField}
+//. object is always an intermediate node, having a parent node and a single
+//. child node. The parent node is the {\tt DwHeaders} object that contains
+//. it. The child node is the {\tt DwFieldBody} object it contains.
+//.
+//. To get and set the field name, use the member functions
+//. {\tt FieldNameStr()} and {\tt SetFieldNameStr()}.
+//. To get and set the field body, use the member functions
+//. {\tt FieldBodyStr()} and {\tt SetFieldBodyStr()}.
+//. To get and set the {\tt DwFieldBody} object, use {\tt FieldBody()}
+//. and {\tt SetFieldBody()}.
+//.
+//. A {\tt DwField} object can be included in a list of {\tt DwField}
+//. objects; usually this is the list of {\tt DwField} objects maintained
+//. by its parent {\tt DwHeaders} object. To get the next {\tt DwField}
+//. object in a list, use the member function {\tt Next()}.
+//=============================================================================
+// Last updated 1997-08-23
+//+ Noentry ~DwField _CreateFieldBody mFieldNameStr mFieldBodyStr
+//+ Noentry mFieldBody _PrintDebugInfo
+
+class DW_EXPORT DwField : public DwMessageComponent {
+
+ friend class DwHeaders;
+
+public:
+
+ DwField();
+ DwField(const DwField& aField);
+ DwField(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwField} object's field name and field body to the empty
+ //. string, set its parent to {\tt NULL}, and sets its {\tt DwFieldBody}
+ //. object to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which performs
+ //. a deep copy of {\tt aField}.
+ //. The parent of the new {\tt DwField} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwField}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwHeaders}.
+
+ virtual ~DwField();
+
+ const DwField& operator = (const DwField& aField);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aField}. The parent node of the {\tt DwField} object
+ //. is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwField} objects. The parse
+ //. method creates or updates the broken-down representation from the
+ //. string representation. For {\tt DwField} objects, the parse method
+ //. parses the string representation, sets the values of the field
+ //. name string and the field body string, and creates an instance
+ //. of the appropriate subclass of {\tt DwFieldBody}. This member
+ //. function also calls the {\tt Parse()} member function of its
+ //. contained {\tt DwFieldBody} object.
+ //.
+ //. You should call this member function after you set or modify the
+ //. string representation, and before you access the field name, the
+ //. field body, or the contained {\tt DwFieldBody} object.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwField} objects. The
+ //. assemble method creates or updates the string representation from
+ //. the broken-down representation. In more concrete terms, the
+ //. assemble method builds the string representation from the field
+ //. name and the string representation of the contained {\tt DwFieldBody}
+ //. object. This member function calls the {\tt Assemble()} member
+ //. function of its contained {\tt DwFieldBody} object.
+ //.
+ //. You should call this member function after you modify either the
+ //. field name or the contained {\tt DwFieldBody} object, and before
+ //. you retrieve the string representation.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwField} on the free store that has the same
+ //. value as this {\tt DwField} object. The basic idea is that of
+ //. a virtual copy constructor.
+
+ DwFieldBody* FieldBody() const;
+ //. Returns the {\tt DwFieldBody} object contained by this {\tt DwField}
+ //. object. If there is no field body, {\tt NULL} will be returned.
+
+ const DwString& FieldNameStr() const;
+ //. Returns the field name of this header field as a string.
+
+ const DwString& FieldBodyStr() const;
+ //. Returns the field body of this header field as a string.
+
+ DwField* Next() const;
+ //. Returns the next {\tt DwField} object following this
+ //. {\tt DwField} object in the list contained in a {\tt DwHeaders}.
+ //. Returns {\tt NULL} if this object is last in the list.
+
+ void SetFieldBody(DwFieldBody* aFieldBody);
+ //. Sets the {\tt DwFieldBody} object contained by this object.
+
+ void SetFieldNameStr(const DwString& aStr);
+ //. Sets the field name of this header field.
+
+ void SetFieldBodyStr(const DwString& aStr);
+ //. Sets the field body of this header field.
+
+ void SetNext(const DwField* aField);
+ //. This {\it advanced} function sets {\tt aField} as the next field
+ //. following this field in the list of fields contained in the headers.
+ //. Since {\tt DwHeaders} contains member functions for adding
+ //. {\tt DwField} objects to its list, this function should be
+ //. avoided for most applications.
+
+ static DwField* NewField(const DwString& aStr,
+ DwMessageComponent* aParent);
+ //. Creates a new {\tt DwField} object on the free store.
+ //. If the static data member {\tt sNewField} is {\tt NULL},
+ //. this member function will create a new {\tt DwField}
+ //. and return it. Otherwise, {\tt NewField()} will call
+ //. the user-supplied function pointed to by {\tt sNewField},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwField}, and return that object.
+
+ static DwFieldBody* CreateFieldBody(const DwString& aFieldName,
+ const DwString& aFieldBody, DwMessageComponent* aParent);
+ //. The static member function {\tt CreateFieldBody()} is called from
+ //. the {\tt Parse()} member function and is responsible for creating a
+ //. {\tt DwFieldBody} object for this particular field. A typical
+ //. scenario might go as follows:
+ //. This member function examines the field name for this field,
+ //. finds that it contains "To", creates a {\tt DwAddressList} object
+ //. to contain the field body, calls the {\tt Parse()} member
+ //. function for the {\tt DwAddressList}, and sets the {\tt DwAddressList}
+ //. object as this {\tt DwField} object's {\tt DwFieldBody}.
+ //.
+ //. If you want to override the behavior of {\tt CreateFieldBody()},
+ //. you can do so by setting the public data member
+ //. {\tt sCreateFieldBody} to point to your own function.
+ //. {\tt CreateFieldBody()} first checks to see if
+ //. {\tt sCreateFieldBody} is {\tt NULL}. If it is not,
+ //. {\tt CreateFieldBody()} will assume that it points to a user-supplied
+ //. function and will call that function. If it is {\tt NULL},
+ //. {\tt CreateFieldBody()} will call {\tt _CreateFieldBody()}, which
+ //. actually creates the {\tt DwFieldBody} object. You may call
+ //. {\tt _CreateFieldBody()} from your own function for fields you
+ //. do not wish to handle.
+
+ static DwFieldBody* _CreateFieldBody(const DwString& aFieldName,
+ const DwString& aFieldBody, DwMessageComponent* aParent);
+
+ //+ Var sNewField
+ static DwField* (*sNewField)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewField} is not {\tt NULL}, it is assumed to point
+ //. to a user-supplied function that returns an object from a class
+ //. derived from {\tt DwField}.
+
+ //+ Var sCreateFieldBody
+ static DwFieldBody* (*sCreateFieldBody)(const DwString& aFieldName,
+ const DwString& aFieldBody, DwMessageComponent* aParent);
+ //. See {\tt CreateFieldBody()}.
+
+protected:
+
+ DwString mFieldNameStr;
+ // the {\it field-name}
+
+ DwString mFieldBodyStr;
+ // the {\it field-body}
+
+ DwFieldBody* mFieldBody;
+ // pointer to the {\tt DwFieldBody} object
+
+ void _SetFieldBody(DwFieldBody* aFieldBody);
+ //. Sets the {\tt DwFieldBody} object contained by this object. This
+ //. function differs from {\tt SetFieldBody()} in that it does not
+ //. set the is-modified flag.
+
+private:
+
+ const DwField* mNext;
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/fieldbdy.h b/mimelib/mimelib/fieldbdy.h
new file mode 100644
index 00000000..e5f3243a
--- /dev/null
+++ b/mimelib/mimelib/fieldbdy.h
@@ -0,0 +1,167 @@
+//=============================================================================
+// File: fieldbdy.h
+// Contents: Declarations for DwFieldBody
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_FIELDBDY_H
+#define DW_FIELDBDY_H
+
+#include <iostream>
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_MSGCMP_H
+#include <mimelib/msgcmp.h>
+#endif
+
+//=============================================================================
+//+ Name DwFieldBody -- Class representing a MIME header field body
+//+ Description
+//. {\tt DwFieldBody} represents the field-body element in the BNF grammar
+//. specified by RFC-822. It is an abstract base class that defines the
+//. interface common to all structured field bodies.
+//.
+//. In the tree (broken-down) representation of a message, a {\tt DwFieldBody}
+//. object may be either a leaf node, having a parent but no child nodes, or
+//. an intermediate node, having a parent and one or more child nodes. The
+//. parent node is the {\tt DwField} object that contains it. Child nodes,
+//. if present, depend on the particular subclass of {\tt DwFieldBody} that
+//. is instantiated. A {\tt DwAddressList} object, for example, has
+//. {\tt DwAddress} objects as its child nodes.
+//.
+//. Since {\tt DwFieldBody} is an abstract base class, you cannot create
+//. instances of it directly. Normally, objects of classes derived from
+//. {\tt DwFieldBody} are obtained by calling convenience member functions
+//. in the class {\tt DwHeaders}.
+//.
+//. Some MIME parsers are broken in that they do not handle the folding of
+//. some fields properly. {\tt DwFieldBody} folds its string representation
+//. by default. You can disable folding, however, by calling the
+//. {\tt SetFolding()} member function. To determine if folding is enabled,
+//. call {\tt IsFolding()}.
+//=============================================================================
+// Last updated 1997-08-24
+//+ Noentry ~DwFieldBody mLineOffset mDoFolding _PrintDebugInfo
+
+
+class DW_EXPORT DwFieldBody : public DwMessageComponent {
+
+ friend class DwField;
+
+public:
+
+ DwFieldBody();
+ DwFieldBody(const DwFieldBody& aFieldBody);
+ DwFieldBody(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwFieldBody} object's string representation to the empty
+ //. string and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which performs a
+ //. deep copy of {\tt aFieldBody}.
+ //. The parent of the new {\tt DwFieldBody} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwFieldBody}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwField}.
+
+ virtual ~DwFieldBody();
+
+ const DwFieldBody& operator = (const DwFieldBody& aFieldBody);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aFieldBody}. The parent node of the {\tt DwFieldBody} object
+ //. is not changed.
+
+ void SetOffset(int aOffset);
+ //. Sets the offset to {\tt aOffset}. The offset is used when folding
+ //. lines. It indicates how much the first line should be offset to
+ //. account for the field name, colon, and initial white space.
+
+ void SetFolding(DwBool aTrueOrFalse);
+ //. Enables ({\tt aTrueOrFalse = DwTrue}) or disables
+ //. ({\tt aTrueOrFalse = DwFalse}) the folding of fields. The default
+ //. is to fold fields. Unfortunately, some parsers are broke and
+ //. do not handle folded lines properly. This function allows a kludge
+ //. to deal with these broken parsers.
+
+ DwBool IsFolding() const;
+ //. Returns a boolean indicating if folding of fields is enabled.
+
+protected:
+
+ int mLineOffset;
+ DwBool mDoFolding;
+
+private:
+
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+
+inline void DwFieldBody::SetOffset(int aOffset)
+{
+ mLineOffset = aOffset;
+}
+
+
+inline void DwFieldBody::SetFolding(DwBool aTrueOrFalse)
+{
+ mDoFolding = aTrueOrFalse;
+}
+
+
+inline DwBool DwFieldBody::IsFolding() const
+{
+ return mDoFolding;
+}
+
+#endif
diff --git a/mimelib/mimelib/group.h b/mimelib/mimelib/group.h
new file mode 100644
index 00000000..21cf930b
--- /dev/null
+++ b/mimelib/mimelib/group.h
@@ -0,0 +1,204 @@
+//=============================================================================
+// File: group.h
+// Contents: Declarations for DwGroup
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_GROUP_H
+#define DW_GROUP_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_MAILBOX_H
+#include <mimelib/mailbox.h>
+#endif
+
+#ifndef DW_MBOXLIST_H
+#include <mimelib/mboxlist.h>
+#endif
+
+#ifndef DW_ADDRESS_H
+#include <mimelib/address.h>
+#endif
+
+//=============================================================================
+//+ Name DwGroup -- Class representing an RFC-822 address group
+//+ Description
+//. {\tt DwGroup} represents a {\it group} as described in RFC-822. A group
+//. contains a group name and a (possibly empty) list of {\it mailboxes}.
+//. In MIME++, a {\tt DwGroup} object contains a string for the group name
+//. and a {\tt DwMailboxList} object for the list of mailboxes.
+//.
+//. In the tree (broken-down) representation of message, a {\tt DwGroup}
+//. object may be only an intermediate node, having both a parent and a single
+//. child node. Its parent node must be a {\tt DwField} or a
+//. {\tt DwAddressList}. Its child is a {\tt DwMailboxList}.
+//.
+//. A {\tt DwGroup} is a {\tt DwAddress}, and therefore it can be included
+//. in a list of {\tt DwAddress} objects. To get the next {\tt DwAddress}
+//. object in a list, use the inherited member function
+//. {\tt DwAddress::Next()}.
+//=============================================================================
+// Last updated 1997-08-24
+//+ Noentry ~DwGroup _PrintDebugInfo
+
+
+class DW_EXPORT DwGroup : public DwAddress {
+
+public:
+
+ DwGroup();
+ DwGroup(const DwGroup& aGroup);
+ DwGroup(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwGroup} object's string representation to the empty string
+ //. and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which performs
+ //. a deep copy of {\tt aGroup}.
+ //. The parent of the new {\tt DwGroup} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwGroup}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwField} or {\tt DwAddressList}.
+
+ virtual ~DwGroup();
+
+ const DwGroup& operator = (const DwGroup& aGroup);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aGroup}. The parent node of the {\tt DwGroup} object
+ //. is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwGroup} objects. The parse
+ //. method creates or updates the broken-down representation from the
+ //. string representation. For {\tt DwGroup} objects, the parse method
+ //. parses the string representation to extract the group name and to
+ //. create a {\tt DwMailboxList} object from the list of mailboxes. This
+ //. member function also calls the {\tt Parse()} member function of
+ //. the {\tt DwMailboxList} object it creates.
+ //.
+ //. You should call this member function after you set or modify the
+ //. string representation, and before you access the group name or the
+ //. mailbox list.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwGroup} objects. The
+ //. assemble method creates or updates the string representation from
+ //. the broken-down representation. That is, the assemble method
+ //. builds the string representation from its group name and mailbox
+ //. list. Before it builds the string representation, this function
+ //. calls the {\tt Assemble()} member function of its contained
+ //. {\tt DwMailboxList} object.
+ //.
+ //. You should call this member function after you set or modify either
+ //. the group name or the contained {\tt DwMailboxList} object, and
+ //. before you retrieve the string representation.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwGroup} on the free store that has the same
+ //. value as this {\tt DwGroup} object. The basic idea is that of
+ //. a virtual copy constructor.
+
+ const DwString& GroupName() const;
+ //. Returns the name of the group.
+
+ const DwString& Phrase() const;
+ //. Returns the name of the phrase part of a group as described in
+ //. RFC-822. The phrase is the same as the group name.
+
+ void SetGroupName(const DwString& aName);
+ //. Sets the name of the group.
+
+ void SetPhrase(const DwString& aPhrase);
+ //. Sets the name of the phrase part of a group as described in RFC-822.
+ //. The phrase is the same as the group name.
+
+ DwMailboxList& MailboxList() const;
+ //. Provides access to the list of mailboxes that is part of a group as
+ //. described in RFC-822.
+
+ static DwGroup* NewGroup(const DwString& aStr,
+ DwMessageComponent* aParent);
+ //. Creates a new {\tt DwGroup} object on the free store.
+ //. If the static data member {\tt sNewGroup} is {\tt NULL},
+ //. this member function will create a new {\tt DwGroup}
+ //. and return it. Otherwise, {\tt NewGroup()} will call
+ //. the user-supplied function pointed to by {\tt sNewGroup},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwGroup}, and return that object.
+
+ //+ Var sNewGroup
+ static DwGroup* (*sNewGroup)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewGroup} is not {\tt NULL}, it is assumed to point to a
+ //. user-supplied function that returns an object from a class derived from
+ //. {\tt DwGroup}.
+
+protected:
+
+ DwMailboxList* mMailboxList;
+ //. Points to the {\tt DwMailboxList} object.
+
+
+private:
+
+ DwString mGroupName;
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/headers.h b/mimelib/mimelib/headers.h
new file mode 100644
index 00000000..8f802ce5
--- /dev/null
+++ b/mimelib/mimelib/headers.h
@@ -0,0 +1,453 @@
+//=============================================================================
+// File: headers.h
+// Contents: Declarations for DwHeaders
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_HEADERS_H
+#define DW_HEADERS_H
+
+#include <iostream>
+#include <vector>
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_MSGCMP_H
+#include <mimelib/msgcmp.h>
+#endif
+
+#ifndef DW_ENTITY_H
+#include <mimelib/entity.h>
+#endif
+
+#ifndef DW_MSGID_H
+#include <mimelib/msgid.h>
+#endif
+
+#ifndef DW_MAILBOX_H
+#include <mimelib/mailbox.h>
+#endif
+
+#ifndef DW_MEDIATYP_H
+#include <mimelib/mediatyp.h>
+#endif
+
+#ifndef DW_DATETIME_H
+#include <mimelib/datetime.h>
+#endif
+
+#ifndef DW_MECHANSM_H
+#include <mimelib/mechansm.h>
+#endif
+
+#ifndef DW_DISPTYPE_H
+#include <mimelib/disptype.h>
+#endif
+
+class DwMessage;
+class DwBodyPart;
+class DwField;
+class DwFieldBody;
+class DwDateTime;
+class DwMailboxList;
+class DwAddressList;
+class DwMediaType;
+class DwMechanism;
+class DwText;
+
+//=============================================================================
+//+ Name DwHeaders -- Class representing the collection of header fields in a message or body part
+//+ Description
+//. {\tt DwHeaders} represents the collection of {\it header fields} (often
+//. called just {\it headers}) in an {\it entity} (either a message or body
+//. part), as described in RFC-822 and RFC-2045. A {\tt DwHeaders} object
+//. manages a list of {\tt DwField} objects, which represent the individual
+//. header fields.
+//.
+//. In the tree (broken-down) representation of a message, a {\tt DwHeaders}
+//. object is an intermediate node, having both a parent node and several
+//. child nodes. The parent node is the {\tt DwEntity} object that contains
+//. it. The child nodes are the {\tt DwField} objects in the list it manages.
+//. (See the man page for {\tt DwMessageComponent} for a discussion of
+//. the tree representation of a message.)
+//.
+//. Normally, you do not create a {\tt DwHeaders} object directly, but you
+//. access it through the {\tt Headers()} member function of {\tt DwEntity},
+//. which creates the {\tt DwHeaders} object for you.
+//.
+//. While {\tt DwHeaders} has public member functions for managing the list
+//. of {\tt DwField} objects it contains, you will normally use convenience
+//. functions to access the field bodies of the header fields directly.
+//. You can access the field body for a specific well-known header field
+//. by using the member function {\tt <Field>()}, where {\tt <Field>} is
+//. the field name of the header field with hyphens removed and the first
+//. word following a hyphen capitalized. For example, to access the field
+//. body for the "MIME-version" header field, use {\tt MimeVersion()}.
+//. The member function {\tt <Field>()} will create a header field with
+//. field name {\tt <Field>} if such a header field does not already exist.
+//. You can check for the existence of a particular well-known header field
+//. by using the member function {\tt Has<Field>()}. For example, to check
+//. for the existence of the MIME-version header field, use
+//. {\tt HasMimeVersion()}. Well-known header fields are those documented in
+//. RFC-822 (standard email), RFC-1036 (USENET messages), RFC-2045 (MIME
+//. messages), and possibly other RFCs.
+//.
+//. In the case of an extension field or user-defined field, you can access
+//. the field body of the header field by calling the member function
+//. {\tt FieldBody()} with the field name as its argument. If the extension
+//. field or user-defined field does not exist, {\tt FieldBody()} will
+//. create it. You can check for the existence of an extension field or
+//. user-defined field by using the member function {\tt HasField()} with
+//. the field name as its argument.
+//.
+//. {\tt DwHeaders} has several other member functions provided for the
+//. sake of completeness that are not required for most applications.
+//. These functions are documented below.
+//=============================================================================
+// Last updated 1997-08-26
+//+ Noentry ~DwHeaders sClassName CopyFields mFirstField _AddField
+
+
+class DW_EXPORT DwHeaders : public DwMessageComponent {
+
+public:
+
+ DwHeaders();
+ DwHeaders(const DwHeaders& aHeaders);
+ DwHeaders(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwHeaders} object's string representation to the empty string
+ //. and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which performs a
+ //. deep copy of {\tt aHeaders}.
+ //. The parent of the new {\tt DwHeaders} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwHeaders}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of a class
+ //. derived from {\tt DwEntity}.
+
+ virtual ~DwHeaders();
+
+ const DwHeaders& operator = (const DwHeaders& aHeaders);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aHeaders}. The parent node of the {\tt DwHeaders} object
+ //. is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwHeaders} objects. The parse
+ //. method creates or updates the broken-down representation from the
+ //. string representation. For {\tt DwHeaders} objects,
+ //. {\tt DwHeaders::Parse()} parses the string representation to create
+ //. a list of {\tt DwField} objects. This member function also calls
+ //. the {\tt Parse()} member function of each {\tt DwField} object in
+ //. its list.
+ //.
+ //. You should call this member function after you set or modify the
+ //. string representation, and before you access any of the header fields.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwHeaders} objects. The
+ //. assemble method creates or updates the string representation from
+ //. the broken-down representation. That is, the assemble method
+ //. builds the string representation from its list of {\tt DwField}
+ //. objects. Before it builds the string representation, this function
+ //. first calls the {\tt Assemble()} member function of each {\tt DwField}
+ //. object in its list.
+ //.
+ //. You should call this member function after you set or modify any
+ //. of the header fields, and before you retrieve the string
+ //. representation.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwHeaders} on the free store that has the same
+ //. value as this {\tt DwHeaders} object. The basic idea is that of
+ //. a virtual copy constructor.
+
+ DwBool HasBcc() const;
+ DwBool HasCc() const;
+ DwBool HasComments() const;
+ DwBool HasDate() const;
+ DwBool HasEncrypted() const;
+ DwBool HasFrom() const;
+ DwBool HasInReplyTo() const;
+ DwBool HasKeywords() const;
+ DwBool HasMessageId() const;
+ DwBool HasReceived() const;
+ DwBool HasReferences() const;
+ DwBool HasReplyTo() const;
+ DwBool HasResentBcc() const;
+ DwBool HasResentCc() const;
+ DwBool HasResentDate() const;
+ DwBool HasResentFrom() const;
+ DwBool HasResentMessageId() const;
+ DwBool HasResentReplyTo() const;
+ DwBool HasResentSender() const;
+ DwBool HasResentTo() const;
+ DwBool HasReturnPath() const;
+ DwBool HasSender() const;
+ DwBool HasSubject() const;
+ DwBool HasTo() const;
+ // RFC-822 fields
+ //
+ DwBool HasApproved() const;
+ DwBool HasControl() const;
+ DwBool HasDistribution() const;
+ DwBool HasExpires() const;
+ DwBool HasFollowupTo() const;
+ DwBool HasLines() const;
+ DwBool HasNewsgroups() const;
+ DwBool HasOrganization() const;
+ DwBool HasPath() const;
+ DwBool HasSummary() const;
+ DwBool HasXref() const;
+ // RFC-1036 fields
+ //
+ DwBool HasContentDescription() const;
+ DwBool HasContentId() const;
+ DwBool HasContentTransferEncoding() const;
+ DwBool HasCte() const;
+ DwBool HasContentType() const;
+ DwBool HasMimeVersion() const;
+ // RFC-2045 fields
+ //
+ DwBool HasContentDisposition() const;
+ // RFC-1806
+ //
+ //. Each member function in this group returns a boolean value indicating
+ //. whether a particular well-known header field is present in this
+ //. object's collection of header fields.
+
+ DwBool HasField(const char* aFieldName) const;
+ DwBool HasField(const DwString& aFieldName) const;
+ //. Returns true if the header field specified by {\tt aFieldName} is
+ //. present in this object's collection of header fields. These member
+ //. functions are used for extension fields or user-defined fields.
+
+ DwAddressList& Bcc();
+ DwAddressList& Cc();
+ DwText& Comments();
+ DwDateTime& Date();
+ DwText& Encrypted();
+ DwMailboxList& From();
+ DwText& InReplyTo();
+ DwText& Keywords();
+ DwMsgId& MessageId();
+ DwText& Received();
+ DwText& References();
+ DwAddressList& ReplyTo();
+ DwAddressList& ResentBcc();
+ DwAddressList& ResentCc();
+ DwDateTime& ResentDate();
+ DwMailboxList& ResentFrom();
+ DwMsgId& ResentMessageId();
+ DwAddressList& ResentReplyTo();
+ DwMailbox& ResentSender();
+ DwAddressList& ResentTo();
+ DwAddress& ReturnPath();
+ DwMailbox& Sender();
+ DwText& Subject();
+ DwAddressList& To();
+ // RFC-822 fields
+ //
+ DwText& Approved();
+ DwText& Control();
+ DwText& Distribution();
+ DwText& Expires();
+ DwText& FollowupTo();
+ DwText& Lines();
+ DwText& Newsgroups();
+ DwText& Organization();
+ DwText& Path();
+ DwText& Summary();
+ DwText& Xref();
+ // RFC-1036 fields (USENET messages)
+ //
+ DwText& ContentDescription();
+ DwMsgId& ContentId();
+ DwMechanism& ContentTransferEncoding();
+ DwMechanism& Cte();
+ DwMediaType& ContentType();
+ DwText& MimeVersion();
+ // RFC-2045 fields
+ //
+ DwDispositionType& ContentDisposition();
+ // RFC-1806 Content-Disposition field
+ //
+ //. Each member function in this group returns a reference to a
+ //. {\tt DwFieldBody} object for a particular header field. If the
+ //. header field does not already exist, it is created. Use the
+ //. corresponding {\tt Has<Field>()} function to test if the header
+ //. field already exists without creating it.
+
+ DwFieldBody& FieldBody(const DwString& aFieldName);
+ //. Returns a reference to the {\tt DwFieldBody} object for a particular
+ //. header field with field name {\tt aFieldName}. If the header field
+ //. does not already exist, it is created. Use {\tt HasField()}
+ //. to test if the header field already exists without creating it.
+ //. This member function allows access to extension fields or
+ //. user-defined fields.
+
+ std::vector<DwFieldBody*> AllFieldBodies(const DwString& aFieldName);
+ //. Returns a vector of pointers to the {\tt DwFieldBody} objects for
+ //. all header fields with field name {\tt aFieldName}. If the header
+ //. field does not already exist, it is created. Use {\tt HasField()}
+ //. to test if the header field already exists without creating it.
+ //. This member function allows access to extension fields or
+ //. user-defined fields.
+
+ int NumFields() const;
+ //. Returns the number of {\tt DwField} objects contained by this
+ //. {\tt DwHeaders} object.
+
+ DwField* FirstField() const;
+ //. Returns a pointer to the first {\tt DwField} object contained by
+ //. this {\tt DwHeaders} object. Use this member function to begin an
+ //. iteration over the entire list of {\tt DwField} objects.
+ //. Continue the iteration by calling {\tt DwField::Next()} on each
+ //. {\tt DwField} object.
+
+ DwField* FindField(const char* aFieldName) const;
+ DwField* FindField(const DwString& aFieldName) const;
+ //. Searches for a header field by its field name. Returns {\tt NULL}
+ //. if the field is not found. This is an {\it advanced} function:
+ //. most applications should use the {\tt <Field>()} or
+ //. {\tt Has<Field>()} family of functions.
+
+ void AddOrReplaceField(DwField* aField);
+ //. Adds a {\tt DwField} object to the list. If a header field with
+ //. the same field name already exists, it is replaced by the new
+ //. header field.
+ //.
+ //. {\tt DwHeaders} takes responsibility for deleting the added
+ //. {\tt DwField} object.
+ //.
+ //. This is an advanced function. Consider using the member functions
+ //. {\tt <Field>()} (e.g. {\tt To()}, {\tt ContentType()}, and so on)
+ //. and {\tt FieldBody()} to add header fields.
+
+ void AddField(DwField* aField);
+ //. Adds a {\tt DwField} object to the list. If a header field with
+ //. the same field name already exists, it is {\it not} replaced;
+ //. thus, duplicate header fields may occur when using this member
+ //. function. (This is what you want for some header fields, such as
+ //. the "Received" header field).
+ //.
+ //. {\tt DwHeaders} takes responsibility for deleting the added
+ //. {\tt DwField} object.
+ //.
+ //. This is an advanced function. Consider using the member functions
+ //. {\tt <Field>()} (e.g. {\tt To()}, {\tt ContentType()}, and so on)
+ //. and {\tt FieldBody()} for adding header fields.
+
+ void AddFieldAt(int aPos, DwField* aField);
+ //. This member functions follows the semantics of {\tt AddField()}
+ //. except that {\tt aPos} specifies a position for adding the field.
+ //. A position of 1 indicates the beginning of the list. A position of
+ //. 0 indicates the end of the list.
+ //.
+ //. This is an advanced function. Consider using the member functions
+ //. {\tt <Field>()} (e.g. {\tt To()}, {\tt ContentType()}, and so on)
+ //. and {\tt FieldBody()} for adding header fields.
+
+ void RemoveField(DwField* aField);
+ //. Removes the {\tt DwField} object from the list. The {\tt DwField}
+ //. object is not deleted.
+
+ void DeleteAllFields();
+ //. Removes all {\tt DwField} objects from the list and deletes them.
+
+ static DwHeaders* NewHeaders(const DwString& aStr,
+ DwMessageComponent* aParent);
+ //. Creates a new {\tt DwHeaders} object on the free store.
+ //. If the static data member {\tt sNewHeaders} is {\tt NULL},
+ //. this member function will create a new {\tt DwHeaders}
+ //. and return it. Otherwise, {\tt NewHeaders()} will call
+ //. the user-supplied function pointed to by {\tt sNewHeaders},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwHeaders}, and return that object.
+
+ //+ Var sNewHeaders
+ static DwHeaders* (*sNewHeaders)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewHeaders} is not {\tt NULL}, it is assumed to point to a
+ //. user-supplied function that returns an object from a class derived from
+ //. {\tt DwHeaders}.
+
+protected:
+
+ void _AddField(DwField* aField);
+ //. Add field but don't set the is-modified flag
+
+ DwField* mFirstField;
+ DwField* mLastField;
+
+protected:
+
+ static const char* const sClassName;
+
+ void CopyFields(DwField* aFirst);
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+private:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+
+inline DwField* DwHeaders::FirstField() const
+{
+ return mFirstField;
+}
+
+#endif
+
diff --git a/mimelib/mimelib/mailbox.h b/mimelib/mimelib/mailbox.h
new file mode 100644
index 00000000..d5d376f2
--- /dev/null
+++ b/mimelib/mimelib/mailbox.h
@@ -0,0 +1,216 @@
+//=============================================================================
+// File: mailbox.h
+// Contents: Declarations for DwMailbox
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_MAILBOX_H
+#define DW_MAILBOX_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_ADDRESS_H
+#include <mimelib/address.h>
+#endif
+
+class DwGroup;
+
+//=============================================================================
+//+ Name DwMailbox -- Class representing an RFC-822 mailbox
+//+ Description
+//. RFC-822 defines a {\it mailbox} as an entity that can be the recipient
+//. of a message. A mailbox is more specific than an {\it address}, which
+//. may be either a mailbox or a {\it group}. An RFC-822 mailbox contains
+//. a full name, a {\it local-part}, an optional {\it route}, and a
+//. {\it domain}. For example, in the mailbox
+//.
+//. Joe Schmoe <jschmoe@aol.com>
+//.
+//. "Joe Schmoe" is the full name, "jschmoe" is the local-part, and
+//. "aol.com" is the domain. The optional route is rarely seen in current
+//. usage, and is deprecated according to RFC-1123.
+//.
+//. In MIME++, an RFC-822 mailbox is represented by a {\tt DwMailbox} object.
+//. {\tt DwMailbox} is a subclass of {\tt DwAddress}, which reflects the
+//. fact that a mailbox is also an address. A {\tt DwMailbox} contains
+//. strings representing the full name, local-part, route, and domain
+//. of a mailbox.
+//.
+//. In the tree (broken-down) representation of message, a {\tt DwMailbox}
+//. object may be only a leaf node, having a parent but no child nodes.
+//. Its parent node must be a {\tt DwField}, a {\tt DwAddressList}, or a
+//. {\tt DwMailboxList} object.
+//.
+//. {\tt DwMailbox} has member functions for getting or setting the strings
+//. it contains.
+//.
+//. {\tt DwMailbox} object can be included in a list of {\tt DwMailbox}
+//. objects. To get the next {\tt DwMailbox} object in a list, use the
+//. inherited member function {\tt DwAddress::Next()}.
+//=============================================================================
+// Last updated 1997-08-30
+//+ Noentry ~DwMailbox
+//+ Noentry mFullName mRoute mLocalPart mDomain sClassName _PrintDebugInfo
+
+
+class DW_EXPORT DwMailbox : public DwAddress {
+
+ friend class DwMailboxList;
+
+public:
+
+ DwMailbox();
+ DwMailbox(const DwMailbox& aMailbox);
+ DwMailbox(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwMailbox} object's string representation to the empty string
+ //. and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which performs
+ //. a deep copy of {\tt aMailbox}.
+ //. The parent of the new {\tt DwMailbox} is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwMailbox}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of a class
+ //. derived from {\tt DwField}.
+
+ virtual ~DwMailbox();
+
+ const DwMailbox& operator = (const DwMailbox& aMailbox);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aMailbox}. The parent node of the {\tt DwMailbox} object
+ //. is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwMailbox} objects. The parse
+ //. method creates or updates the broken-down representation from the
+ //. string representation. For {\tt DwMailbox} objects, the parse
+ //. method parses the string representation into the substrings for
+ //. the full name, local-part, route, and domain.
+ //.
+ //. You should call this member function after you set or modify the
+ //. string representation, and before you retrieve the full name,
+ //. local-part, route, or domain.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwMailbox} objects. The
+ //. assemble method creates or updates the string representation from
+ //. the broken-down representation. For {\tt DwMailbox} objects, the
+ //. assemble method builds the string representation from the full
+ //. name, local-part, route, and domain strings.
+ //.
+ //. You should call this member function after you modify the full
+ //. name, local-part, route, or domain, and before you retrieve the
+ //. string representation.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwMailbox} on the free store that has the same
+ //. value as this {\tt DwMailbox} object. The basic idea is that of
+ //. a virtual copy constructor.
+
+ const DwString& FullName() const;
+ //. Returns the full name for this {\tt DwMailbox} object.
+
+ void SetFullName(const DwString& aFullName);
+ //. Sets the full name for this {\tt DwMailbox} object.
+
+
+ const DwString& Route() const;
+ //. Returns the route for this {\tt DwMailbox} object.
+
+ void SetRoute(const DwString& aRoute);
+ //. Sets the route for this {\tt DwMailbox} object.
+
+ const DwString& LocalPart() const;
+ //. Returns the local-part for this {\tt DwMailbox} object.
+
+ void SetLocalPart(const DwString& aLocalPart);
+ //. Sets the local-part for this {\tt DwMailbox} object.
+
+ const DwString& Domain() const;
+ //. Returns the domain for this {\tt DwMailbox} object.
+
+ void SetDomain(const DwString& aDomain);
+ //. Sets the domain for this {\tt DwMailbox} object.
+
+ static DwMailbox* NewMailbox(const DwString& aStr, DwMessageComponent*
+ aParent);
+ //. Creates a new {\tt DwMailbox} object on the free store.
+ //. If the static data member {\tt sNewMailbox} is {\tt NULL},
+ //. this member function will create a new {\tt DwMailbox}
+ //. and return it. Otherwise, {\tt NewMailbox()} will call
+ //. the user-supplied function pointed to by {\tt sNewMailbox},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwMailbox}, and return that object.
+
+ //+ Var sNewMailbox
+ static DwMailbox* (*sNewMailbox)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewMailbox} is not {\tt NULL}, it is assumed to point to a
+ //. user-supplied function that returns an object from a class derived
+ //. from {\tt DwMailbox}.
+
+private:
+
+ DwString mFullName;
+ DwString mRoute;
+ DwString mLocalPart;
+ DwString mDomain;
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/mboxlist.h b/mimelib/mimelib/mboxlist.h
new file mode 100644
index 00000000..0487d751
--- /dev/null
+++ b/mimelib/mimelib/mboxlist.h
@@ -0,0 +1,226 @@
+//=============================================================================
+// File: mboxlist.h
+// Contents: Declarations for DwMailboxList
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_MBOXLIST_H
+#define DW_MBOXLIST_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_ADDRESS_H
+#include <mimelib/address.h>
+#endif
+
+class DwGroup;
+
+
+//=============================================================================
+//+ Name DwMailboxList -- Class representing a list of RFC-822 mailboxes
+//+ Description
+//. {\tt DwMailboxList} represents a list of {\it mailboxes} as described
+//. in RFC-822. In MIME++, {\tt DwMailboxList} is a container for objects
+//. of type {\tt DwMailbox}, and it contains various member functions to
+//. manage its contained objects. {\tt DwAddressList} is also a
+//. {\tt DwFieldBody}. This reflects the fact that certain RFC-822 header
+//. fields, such as the "From" header field, have a list of mailboxes as
+//. their field bodies.
+//=============================================================================
+// Last modified 1997-08-30
+//+ Noentry ~DwMailboxList _PrintDebugInfo
+
+class DW_EXPORT DwMailboxList : public DwFieldBody {
+
+public:
+
+ DwMailboxList();
+ DwMailboxList(const DwMailboxList& aList);
+ DwMailboxList(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwMailboxList} object's string representation to the empty string
+ //. and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which copies the
+ //. string representation and all {\tt DwMailbox} objects from {\tt aList}.
+ //. The parent of the new {\tt DwMailboxList} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwMailboxList}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwField}.
+
+ virtual ~DwMailboxList();
+
+ const DwMailboxList& operator = (const DwMailboxList& aList);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aList}. The parent node of the {\tt DwMailboxList} object
+ //. is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwMailboxList} objects. The parse
+ //. method creates or updates the broken-down representation from the
+ //. string representation. For {\tt DwMailboxList} objects, the parse
+ //. method parses the string representation to create a list of
+ //. {\tt DwMailbox} objects. This member function also calls the
+ //. {\tt Parse()} member function of each {\tt DwMailbox} object in
+ //. its list.
+ //.
+ //. You should call this member function after you set or modify the
+ //. string representation, and before you access any of the contained
+ //. {\tt DwMailbox} objects.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwMailboxList} objects. The
+ //. assemble method creates or updates the string representation from
+ //. the broken-down representation. For {\tt DwMailboxList} objects,
+ //. the assemble method builds the string representation from its list
+ //. of {\tt DwMailbox} objects. Before it builds the string representation
+ //. for the {\tt DwMailboxList} object, this function first calls the
+ //. {\tt Assemble()} member function of each {\tt DwMailbox} object
+ //. in its list.
+ //.
+ //. You should call this member function after you set or modify any
+ //. of the contained {\tt DwMailbox} objects, and before you retrieve
+ //. the string representation.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwMailboxList} on the free store that has the same
+ //. value as this {\tt DwMailboxList} object. The basic idea is that of
+ //. a virtual copy constructor.
+
+ DwMailbox* FirstMailbox() const;
+ //. Gets the first {\tt DwMailbox} object in the list.
+ //. Use the member function {\tt DwMailbox::Next()} to iterate.
+ //. Returns {\tt NULL} if the list is empty.
+
+ void Add(DwMailbox* aMailbox);
+ //. Adds {\tt aMailbox} to the end of the list of {\tt DwMailbox} objects
+ //. maintained by this {\tt DwMailboxList} object.
+
+ void Remove(DwMailbox* aMailbox);
+ //. Removes {\tt aMailbox} from the list of {\tt DwMailbox} objects
+ //. maintained by this {\tt DwMailboxList} object. The {\tt DwMailbox}
+ //. object is not deleted by this member function.
+
+ void DeleteAll();
+ //. Removes and deletes all {\tt DwMailbox} objects from the list
+ //. maintained by this {\tt DwMailboxList} object.
+
+ static DwMailboxList* NewMailboxList(const DwString& aStr,
+ DwMessageComponent* aParent);
+ //. Creates a new {\tt DwMailboxList} object on the free store.
+ //. If the static data member {\tt sNewMailboxList} is {\tt NULL},
+ //. this member function will create a new {\tt DwMailboxList}
+ //. and return it. Otherwise, {\tt NewMailboxList()} will call
+ //. the user-supplied function pointed to by {\tt sNewMailboxList},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwMailboxList}, and return that object.
+
+ //+ Var sNewMailboxList
+ static DwMailboxList* (*sNewMailboxList)(const DwString&,
+ DwMessageComponent*);
+ //. If {\tt sNewMailboxList} is not {\tt NULL}, it is assumed to point
+ //. to a user-supplied function that returns an object from a class
+ //. derived from {\tt DwMailboxList}.
+
+protected:
+
+ DwMailbox* mFirstMailbox;
+ //. Points to first {\tt DwMailbox} object in list.
+
+ void _AddMailbox(DwMailbox* aMailbox);
+ //. Adds a mailbox, but does not set the is-modified flag.
+
+ void _DeleteAll();
+ //. Removes and deletes all {\tt DwMailbox} objects from the list
+ //. maintained by this {\tt DwMailboxList} object. Doesn't set the
+ //. is-modified flag.
+
+private:
+
+ static const char* const sClassName;
+
+ void CopyList(const DwMailbox* aFirst);
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+
+class DW_EXPORT DwMailboxListParser {
+public:
+ enum {
+ eMbError,
+ eMbGroup,
+ eMbMailbox,
+ eMbNull,
+ eMbEnd
+ };
+ DwMailboxListParser(const DwString& aStr);
+ virtual ~DwMailboxListParser();
+ const DwString& MbString() { return mMbString.Tokens(); }
+ int MbType() { return mMbType; }
+ int IsNull() { return (mMbType == eMbNull) ? 1 : 0; }
+ int IsEnd() { return (mMbType == eMbEnd) ? 1 : 0; }
+ int Restart();
+ int operator ++ (); // prefix increment operator
+protected:
+ void ParseNextMailbox();
+ DwRfc822Tokenizer mTokenizer;
+ DwTokenString mMbString;
+ int mMbType;
+};
+
+#endif
diff --git a/mimelib/mimelib/mechansm.h b/mimelib/mimelib/mechansm.h
new file mode 100644
index 00000000..05a80fe9
--- /dev/null
+++ b/mimelib/mimelib/mechansm.h
@@ -0,0 +1,172 @@
+//=============================================================================
+// File: mechansm.h
+// Contents: Declarations for DwMechanism
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_MECHANSM_H
+#define DW_MECHANSM_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_FIELDBDY_H
+#include <mimelib/fieldbdy.h>
+#endif
+
+
+//=============================================================================
+//+ Name DwMechanism -- Class representing a MIME content-transfer-encoding field-body
+//+ Description
+//. {\tt DwMechanism} represents a field body for the
+//. Content-Transfer-Encoding header field as described in RFC-2045.
+//. {\tt DwMechanism} provides convenience functions that allow you to
+//. set or get the content-transfer-encoding attribute as an enumerated
+//. value.
+//=============================================================================
+// Last updated 1997-08-30
+//+ Noentry ~DwMechanism _PrintDebugInfo
+
+
+class DW_EXPORT DwMechanism : public DwFieldBody {
+
+public:
+
+ DwMechanism();
+ DwMechanism(const DwMechanism& aCte);
+ DwMechanism(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwMechanism} object's string representation to the empty
+ //. string and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which copies the
+ //. string representation from {\tt aCte}.
+ //. The parent of the new {\tt DwMechanism} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwMechanism}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwField}.
+
+ virtual ~DwMechanism();
+
+ const DwMechanism& operator = (const DwMechanism& aCte);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aCte}. The parent node of the {\tt DwMechanism} object
+ //. is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwMechanism} objects.
+ //. It should be called immediately after the string representation
+ //. is modified and before any of the object's attributes are retrieved.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwMechanism} objects.
+ //. It should be called whenever one of the object's attributes
+ //. is changed in order to assemble the string representation.
+ //. It will be called automatically for this object by the parent
+ //. object's {\tt Assemble()} member function if the is-modified
+ //. flag is set.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwMechanism} object on the free store that has
+ //. the same value as this {\tt DwMechanism} object. The basic idea
+ //. is that of a virtual copy constructor.
+
+ int AsEnum() const;
+ //. Returns the content transfer encoding as an enumerated value.
+ //. Enumerated values are defined for all standard content transfer
+ //. encodings in the file enum.h. If the content transfer encoding
+ //. is non-standard {\tt DwMime::kCteUnknown} is returned. The
+ //. inherited member function {\tt DwMessageComponent::AsString()}
+ //. may be used to get the content transfer encoding, standard or
+ //. non-standard, as a string.
+
+ void FromEnum(int aCte);
+ //. Sets the content transfer encoding from an enumerated value.
+ //. Enumerated values are defined for all standard content transfer
+ //. encodings in the file enum.h. You may set the content transfer
+ //. encoding to any string value, standard or non-standard, by using the
+ //. inherited member function {\tt DwMessageComponent::FromString()}.
+
+ static DwMechanism*
+ NewMechanism(const DwString& aStr, DwMessageComponent* aParent);
+ //. Creates a new {\tt DwMechanism} object on the free store.
+ //. If the static data member {\tt sNewMechanism} is {\tt NULL},
+ //. this member function will create a new {\tt DwMechanism}
+ //. and return it. Otherwise, {\tt NewMechanism()} will call
+ //. the user-supplied function pointed to by
+ //. {\tt sNewMechanism}, which is assumed to return an
+ //. object from a class derived from {\tt DwMechanism}, and
+ //. return that object.
+
+ //+ Var sNewMechanism
+ static DwMechanism*
+ (*sNewMechanism)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewMechanism} is not {\tt NULL}, it is assumed
+ //. to point to a user-supplied function that returns an object from
+ //. a class derived from {\tt DwMechanism}.
+
+private:
+
+ int mCteEnum;
+ static const char* const sClassName;
+
+ void EnumToString();
+ void StringToEnum();
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/mediatyp.h b/mimelib/mimelib/mediatyp.h
new file mode 100644
index 00000000..f57b9aa3
--- /dev/null
+++ b/mimelib/mimelib/mediatyp.h
@@ -0,0 +1,279 @@
+//=============================================================================
+// File: mediatyp.h
+// Contents: Declarations for DwMediaType
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_MEDIATYP_H
+#define DW_MEDIATYP_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_FIELDBDY_H
+#include <mimelib/fieldbdy.h>
+#endif
+
+class DwParameter;
+
+//=============================================================================
+//+ Name DwMediaType -- Class representing a MIME media-type
+//+ Description
+//. {\tt DwMediaType} represents a field body for the Content-Type header
+//. field as described in RFC-2045. This field body specifies the kind of
+//. data contained in the body of a message or a body part. A media type
+//. is described by two keywords: a primary type (or just {\it type}) and
+//. a {\it subtype}. RFC-2046 specifies the seven primary types text,
+//. multipart, message, image, audio, video, and application. RFC-2077
+//. adds the new primary type model.
+//.
+//. {\tt DwMediaType} has member functions that allow you to set or get
+//. the type and subtype as either enumerated values or as strings. It
+//. also contains a list of {\tt DwParameter} objects that represent the
+//. parameters of the field body. You can use convenience functions to
+//. directly access the boundary parameter of a multipart media type, or
+//. to access the name parameter that is often used with several media
+//. types, such as application/octet-stream.
+//.
+//. Some MIME parsers have problems with folded header fields, and this
+//. especially seems to be a problem with the Content-Type field.
+//. To disable folding when the {\tt DwMediaType} object is assembled,
+//. call the inherited member function {\tt DwFieldBody::SetFolding()}
+//. with an argument of {\tt DwFalse}.
+//=============================================================================
+// Last updated 1997-08-30
+//+ Noentry ~DwMediaType
+//+ Noentry _AddParameter TypeEnumToStr TypeStrToEnum SubtypeEnumToStr
+//+ Noentry SubtypeStrToEnum DeleteParameterList CopyParameterList
+//+ Noentry mType mSubtype mTypeStr mSubtypeStr mBoundaryStr mFirstParameter
+//+ Noentry _PrintDebugInfo mNameStr
+
+
+class DW_EXPORT DwMediaType : public DwFieldBody {
+
+public:
+
+ DwMediaType();
+ DwMediaType(const DwMediaType& aMediaType);
+ DwMediaType(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwMediaType} object's string representation to the empty string
+ //. and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which performs
+ //. deep copy of {\tt aMediaType}.
+ //. The parent of the new {\tt DwMediaType} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwMediaType}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
+ //. a class derived from {\tt DwField}.
+
+ virtual ~DwMediaType();
+
+ const DwMediaType& operator = (const DwMediaType& aMediaType);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aMediaType}. The parent node of the {\tt DwMediaType}
+ //. object is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwMediaType} objects.
+ //. It should be called immediately after the string representation
+ //. is modified and before the parts of the broken-down
+ //. representation are accessed.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwMediaType} objects.
+ //. It should be called whenever one of the object's attributes
+ //. is changed in order to assemble the string representation from
+ //. its broken-down representation. It will be called
+ //. automatically for this object by the parent object's
+ //. {\tt Assemble()} member function if the is-modified flag is set.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwMediaType} object on the free store that
+ //. has the same value as this {\tt DwMediaType} object. The basic
+ //. idea is that of a virtual copy constructor.
+
+ int Type() const;
+ //. Returns the primary type as an enumerated value. Enumerated values
+ //. are defined for all standard types in the file enum.h. If the type
+ //. is non-standard, {\tt DwMime::kTypeUnknown} is returned. The member
+ //. function {\tt TypeStr()} may be used to get the value of any type,
+ //. standard or non-standard, as a string.
+
+ void SetType(int aType);
+ //. Sets the primary type from the enumerated value {\tt aType}.
+ //. Enumerated values are defined for all standard types in the file
+ //. enum.h. The member function {\tt SetTypeStr()} may be used to
+ //. set the value of any type, standard or non-standard, from a string.
+
+ const DwString& TypeStr() const;
+ //. Returns the primary type as a string.
+
+ void SetTypeStr(const DwString& aStr);
+ //. Sets the primary type from a string.
+
+ int Subtype() const;
+ //. Returns the subtype as an enumerated value. Enumerated values
+ //. are defined for all standard subtypes in the file enum.h. If
+ //. the subtype is non-standard, {\tt DwMime::kSubtypeUnknown} is
+ //. returned. The member function {\tt SubtypeStr()} may be used
+ //. to get the value of any subtype, standard or non-standard, as
+ //. a string.
+
+ void SetSubtype(int aSubtype);
+ //. Sets the subtype from the enumerated value {\tt aSubtype}.
+ //. Enumerated values are defined for all standard subtypes in the
+ //. file enum.h. The member function {\tt SetSubtypeStr()} may be
+ //. used to set the value of any subtype, standard or non-standard,
+ //. from a string.
+
+ const DwString& SubtypeStr() const;
+ //. Returns the subtype as a string.
+
+ void SetSubtypeStr(const DwString& aStr);
+ //. Sets the subtype from a string.
+
+ const DwString& Boundary() const;
+ //. For the multipart type only, returns the value of the boundary
+ //. parameter. This member function is a convenience function
+ //. that searches the list of {\tt DwParameter} objects.
+
+ void SetBoundary(const DwString& aStr);
+ //. For the multipart type only, sets the value of the boundary
+ //. parameter.
+ //. This member function is a convenience function that accesses the
+ //. list of {\tt DwParameter} objects.
+
+ virtual void CreateBoundary(unsigned aLevel=0);
+ //. For the multipart type only, creates a boundary string. {\tt aLevel}
+ //. indicates the level of a nested multipart body part; if it is
+ //. positive, it is used to form part of the created boundary string.
+ //. This member function is a convenience function that accesses the
+ //. list of child {\tt DwParameter} objects.
+
+ const DwString& Name() const;
+ //. Returns the value of the "name" parameter, if such a parameter
+ //. is present. The name parameter is often found in several media
+ //. types, including the application/octet-stream media type; it
+ //. suggests a file name for saving to a disk file. (The filename
+ //. parameter in the Content-Disposition header field is an alternative
+ //. way to indicate a file name.) This member function is a convenience
+ //. function that searches the list of {\tt DwParameter} objects.
+
+ void SetName(const DwString& aStr);
+ //. Sets the value of the "name" parameter. If a name parameter is
+ //. not already present, it is added. The name parameter is often
+ //. found in several media types, including the application/octet-stream
+ //. media type; it suggests a file name for saving to a disk file.
+ //. (The filename parameter in the Content-Disposition header field
+ //. is an alternative way to indicate a file name.) This member
+ //. function is a convenience function that accesses the list of
+ //. {\tt DwParameter} objects.
+
+ DwParameter* FirstParameter() const;
+ //. Returns the first {\tt DwParameter} object in the list managed by
+ //. this {\tt DwMediaType} object. Use {\tt DwParameter::Next()} to
+ //. iterate through the list.
+
+ void AddParameter(DwParameter* aParam);
+ //. Adds a {\tt DwParameter} object to the list managed by this
+ //. {\tt DwMediaType} object.
+
+ static DwMediaType* NewMediaType(const DwString& aStr,
+ DwMessageComponent* aParent);
+ //. Creates a new {\tt DwMediaType} object on the free store.
+ //. If the static data member {\tt sNewMediaType} is {\tt NULL},
+ //. this member function will create a new {\tt DwMediaType}
+ //. and return it. Otherwise, {\tt NewMediaType()} will call
+ //. the user-supplied function pointed to by {\tt sNewMediaType},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwMediaType}, and return that object.
+
+ //+ Var sNewMediaType
+ static DwMediaType* (*sNewMediaType)(const DwString&,
+ DwMessageComponent*);
+ //. If {\tt sNewMediaType} is not {\tt NULL}, it is assumed to point to a
+ //. user-supplied function that returns an object from a class derived
+ //. from {\tt DwMediaType}.
+
+protected:
+
+ void _AddParameter(DwParameter* aParam);
+ //. Adds a parameter without setting the is-modified flag.
+
+ virtual void TypeEnumToStr();
+ virtual void TypeStrToEnum();
+ virtual void SubtypeEnumToStr();
+ virtual void SubtypeStrToEnum();
+ void DeleteParameterList();
+ void CopyParameterList(DwParameter* aFirst);
+
+ int mType;
+ int mSubtype;
+ DwString mTypeStr;
+ DwString mSubtypeStr;
+ DwString mBoundaryStr;
+ DwString mNameStr;
+ DwParameter* mFirstParameter;
+
+private:
+
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/message.h b/mimelib/mimelib/message.h
new file mode 100644
index 00000000..5dbd7cc4
--- /dev/null
+++ b/mimelib/mimelib/message.h
@@ -0,0 +1,130 @@
+//=============================================================================
+// File: message.h
+// Contents: Declarations for DwMessage
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_MESSAGE_H
+#define DW_MESSAGE_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_ENTITY_H
+#include <mimelib/entity.h>
+#endif
+
+//=============================================================================
+//+ Name DwMessage -- Class representing an RFC-822/MIME message
+//+ Description
+//. {\tt DwMessage} represents an RFC-822/MIME {\it message}.
+//.
+//. A {\it message} contains both a collection of {\it header fields} and
+//. a {\it body}. In the terminology of RFC-2045, the general term for the
+//. headers-body combination is {\it entity}. In MIME++, {\tt DwMessage}
+//. is a direct subclass of {\tt DwEntity}, and therefore contains both
+//. a {\tt DwHeaders} object and a {\tt DwBody} object.
+//.
+//. In the tree (broken-down) representation of message, a {\tt DwMessage}
+//. object is almost always a root node, having child nodes but no parent node.
+//. The child nodes are the {\tt DwHeaders} object and the {\tt DwBody} object
+//. it contains. A {\tt DwMessage} may sometimes be an intermediate node. In
+//. this special case, the parent node is a {\tt DwBody} object of type
+//. "message/*" and the {\tt DwMessage} object represents an encapsulated
+//. message.
+//.
+//. To access the contained {\tt DwHeaders} object, use the inherited member
+//. function {\tt DwEntity::Headers()}. To access the contained {\tt DwBody}
+//. object, use the inherited member function {\tt DwEntity::Body()}.
+//=============================================================================
+// Last modified 1997-08-30
+//+ Noentry ~DwMessage _PrintDebugInfo
+
+class DW_EXPORT DwMessage : public DwEntity {
+
+public:
+
+ DwMessage();
+ DwMessage(const DwMessage& aMessage);
+ DwMessage(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwMessage} object's string representation to the empty string
+ //. and sets its parent to {\tt NULL}.
+ //.
+ //. The second constructor is the copy constructor, which performs
+ //. a deep copy of {\tt aMessage}.
+ //. The parent of the new {\tt DwMessage} object is set to {\tt NULL}.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwMessage}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+
+ virtual ~DwMessage();
+
+ const DwMessage& operator = (const DwMessage& aMessage);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aMessage}. The parent node of the {\tt DwMessage} object
+ //. is not changed.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwMessage} on the free store that has the same
+ //. value as this {\tt DwMessage} object. The basic idea is that of
+ //. a ``virtual copy constructor.''
+
+ static DwMessage* NewMessage(const DwString& aStr,
+ DwMessageComponent* aParent);
+ //. Creates a new {\tt DwMessage} object on the free store.
+ //. If the static data member {\tt sNewMessage} is {\tt NULL},
+ //. this member function will create a new {\tt DwMessage}
+ //. and return it. Otherwise, {\tt NewMessage()} will call
+ //. the user-supplied function pointed to by {\tt sNewMessage},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwMessage}, and return that object.
+
+ //+ Var sNewMessage
+ static DwMessage* (*sNewMessage)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewMessage} is not {\tt NULL}, it is assumed to point
+ //. to a user supplied function that returns an object from a class
+ //. derived from {\tt DwMessage}.
+
+private:
+
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/mimepp.h b/mimelib/mimelib/mimepp.h
new file mode 100644
index 00000000..cecb2044
--- /dev/null
+++ b/mimelib/mimelib/mimepp.h
@@ -0,0 +1,150 @@
+//=============================================================================
+// File: mimepp.h
+// Contents: MIME++ library include file
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_MIMEPP_H
+#define DW_MIMEPP_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_ENUM_H
+#include <mimelib/enum.h>
+#endif
+
+#ifndef DW_ADDRESS_H
+#include <mimelib/address.h>
+#endif
+
+#ifndef DW_ADDRLIST_H
+#include <mimelib/addrlist.h>
+#endif
+
+#ifndef DW_BODY_H
+#include <mimelib/body.h>
+#endif
+
+#ifndef DW_BODYPART_H
+#include <mimelib/bodypart.h>
+#endif
+
+#ifndef DW_BOYERMOR_H
+#include <mimelib/boyermor.h>
+#endif
+
+#ifndef DW_DATETIME_H
+#include <mimelib/datetime.h>
+#endif
+
+#ifndef DW_DISPTYPE_H
+#include <mimelib/disptype.h>
+#endif
+
+#ifndef DW_DWSTRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_ENTITY_H
+#include <mimelib/entity.h>
+#endif
+
+#ifndef DW_FIELD_H
+#include <mimelib/field.h>
+#endif
+
+#ifndef DW_FIELDBDY_H
+#include <mimelib/fieldbdy.h>
+#endif
+
+#ifndef DW_GROUP_H
+#include <mimelib/group.h>
+#endif
+
+#ifndef DW_HEADER_H
+#include <mimelib/headers.h>
+#endif
+
+#ifndef DW_MAILBOX_H
+#include <mimelib/mailbox.h>
+#endif
+
+#ifndef DW_MBOXLIST_H
+#include <mimelib/mboxlist.h>
+#endif
+
+#ifndef DW_MECHANSM_H
+#include <mimelib/mechansm.h>
+#endif
+
+#ifndef DW_MEDIATYP_H
+#include <mimelib/mediatyp.h>
+#endif
+
+#ifndef DW_MESSAGE_H
+#include <mimelib/message.h>
+#endif
+
+#ifndef DW_MSGCMP_H
+#include <mimelib/msgcmp.h>
+#endif
+
+#ifndef DW_MSGID_H
+#include <mimelib/msgid.h>
+#endif
+
+#ifndef DW_NNTP_H
+#include <mimelib/nntp.h>
+#endif
+
+#ifndef DW_PARAM_H
+#include <mimelib/param.h>
+#endif
+
+#ifndef DW_POP_H
+#include <mimelib/pop.h>
+#endif
+
+#ifndef DW_PROTOCOL_H
+#include <mimelib/protocol.h>
+#endif
+
+//#ifndef DW_SMTP_H
+//#include <mimelib/smtp.h>
+//#endif
+
+#ifndef DW_TEXT_H
+#include <mimelib/text.h>
+#endif
+
+#ifndef DW_TOKEN_H
+#include <mimelib/token.h>
+#endif
+
+#ifndef DW_UUENCODE_H
+#include <mimelib/uuencode.h>
+#endif
+
+#ifndef DW_UTILITY_H
+#include <mimelib/utility.h>
+#endif
+
+#endif
diff --git a/mimelib/mimelib/msgcmp.h b/mimelib/mimelib/msgcmp.h
new file mode 100644
index 00000000..f1b28495
--- /dev/null
+++ b/mimelib/mimelib/msgcmp.h
@@ -0,0 +1,311 @@
+//=============================================================================
+// File: msgcmp.h
+// Contents: Declarations for DwMessageComponent
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_MSGCMP_H
+#define DW_MSGCMP_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#if !(defined(__DECCXX) && defined(__linux__))
+#include <iosfwd>
+#endif
+
+
+//=============================================================================
+//+ Name DwMessageComponent -- Abstract base class for all message components
+//+ Description
+//. {\tt DwMessageComponent} is the root of an inheritance hierarchy from
+//. which all MIME message components are derived. Thus,
+//. {\tt DwMessageComponent} defines important features that are inherited by
+//. nearly all other classes that represent components of a MIME message.
+//. These features are the following:
+//.
+//. \begin{enumerate}
+//. \item
+//. A string representation. The {\tt DwMessageComponent} class provides
+//. a member function {\tt FromString(const DwString&)} to set the string
+//. representation and a member function {\tt AsString()} to get the
+//. string representation.
+//.
+//. \item
+//. A broken-down, or parsed, representation. An RFC-822 date-time,
+//. for example, has a year, month, day, hour, minute, second, and
+//. time zone as elements of its broken-down representation.
+//. {\tt DwMessageComponent} does not deal directly with the
+//. broken-down representation, since it is component-specific.
+//. Derived classes bear all the responsibility for their broken-down
+//. representations.
+//.
+//. \item
+//. A parse method to extract the broken-down representation from
+//. the string representation. In the {\tt DwDateTime} class, for
+//. example, the parse method extracts the year, month, day, hour,
+//. minute, second, and time zone from the RFC-822 {\it date-time}
+//. contained in the string representation. {\tt DwMessageComponent}
+//. provides a pure virtual function {\tt Parse()}, which executes
+//. the parse method for a derived class.
+//.
+//. \item
+//. An assemble method to convert the broken-down representation to
+//. a string representation. This is the opposite of the parse method.
+//. In the {\tt DwDateTime} class, for example, the assemble method
+//. creates an RFC-822 {\it date-time} string from values of the
+//. year, month, day, hour, minute, second, and time zone.
+//. {\tt DwMessageComponent} provides a pure virtual function
+//. {\tt Assemble()}, which executes the assemble method for
+//. a derived class.
+//.
+//. \item
+//. An is-modified flag. When the string representation and the
+//. broken-down representation are consistent, the assemble
+//. method does not need to be executed. The is-modified flag is
+//. cleared when the two representations are consistent, and is set
+//. when they are inconsistent. The flag is set automatically
+//. whenever a {\tt DwMessageComponent} object's broken-down
+//. representation is changed by calling one of the object's member
+//. functions, and it is cleared when the assemble or parse method
+//. is executed. {\tt DwMessageComponent} also provides a member
+//. function {\tt SetModified()} which forces the is-modified flag
+//. to be set.
+//.
+//. \item
+//. A parent. Most message components are part of another component.
+//. A collection of headers is part of a message or body part, a header
+//. field is part of a collection of headers, a field-body is part
+//. of a header field, and so on. The parent of
+//. a component is the component that contains it. This tree structure
+//. is important, since a component's parent must be parsed before the
+//. component can be. Also, a component's string representation must
+//. be assembled before its parent's. To maintain consistency in the
+//. tree, whenever a component's is-modified flag is set,
+//. the component notifies its parent to also set its is-modified flag.
+//. In this way, an is-modified flag set anywhere in the tree always
+//. propagates up to the root component.
+//.
+//. \item
+//. Children. The preceding discussion about a component's parent is
+//. relevant to an understanding of a component's children. A component's
+//. parse method calls the parse methods of its children
+//. after it has executed its own parse method (and, in some cases, created
+//. all of its children).
+//. Also, a component typically calls the assemble method of its
+//. children before it executes its own. A component's child may request
+//. that the component set its is-modified flag.
+//. {\tt DwMessageComponent} does not deal directly with children.
+//. Derived classes bear all the responsibility for handling their
+//. children.
+//. \end{enumerate}
+//=============================================================================
+//+ Noentry ~DwMessageComponent _PrintDebugInfo mString mIsModified mParent
+//+ Noentry mClassId mClassName
+
+class DW_EXPORT DwMessageComponent {
+
+private:
+
+ DwUint32 mMagicNumber;
+
+public:
+
+ enum componentType {
+ kCidError=-1,
+ kCidUnknown=0,
+ kCidAddress,
+ kCidAddressList,
+ kCidBody,
+ kCidBodyPart,
+ kCidDispositionType,
+ kCidMechanism,
+ kCidMediaType,
+ kCidParameter,
+ kCidDateTime,
+ kCidEntity,
+ kCidField,
+ kCidFieldBody,
+ kCidGroup,
+ kCidHeaders,
+ kCidMailbox,
+ kCidMailboxList,
+ kCidMessage,
+ kCidMessageComponent,
+ kCidMsgId,
+ kCidText
+ };
+ //. Class identifier enumeration
+
+ DwMessageComponent();
+ DwMessageComponent(const DwMessageComponent& aCmp);
+ DwMessageComponent(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwMessageComponent} object's string representation to the
+ //. empty string and sets its parent to NULL.
+ //.
+ //. The second constructor is the copy constructor, which performs
+ //. a deep copy of {\tt aCmp}. The parent of the new
+ //. {\tt DwMessageComponent} object is set to NULL.
+ //.
+ //. The third constructor copies {\tt aStr} to the new
+ //. {\tt DwMessageComponent} object's string representation and sets
+ //. {\tt aParent} as its parent. In typical cases, the virtual
+ //. member function {\tt Parse()} should be called immediately after
+ //. this constructor to parse the new {\tt DwMessageComponent} object
+ //. and all of its children into their broken-down representations.
+
+ virtual ~DwMessageComponent();
+
+ const DwMessageComponent& operator = (const DwMessageComponent& aCmp);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aCmp}.
+
+ virtual void Parse() = 0;
+ //. A pure virtual function which provides an interface to the parse
+ //. method. The parse method, implemented in derived classes, is
+ //. responsible for extracting the broken-down representation from
+ //. the string representation. In some derived classes, such as
+ //. {\tt DwHeaders}, the parse method is also responsible for creating the
+ //. children of the object. (In the case of {\tt DwHeaders}, the children
+ //. created are the {\tt DwField} objects that represent the {\it field}s
+ //. contained in the {\it headers}.) The {\tt Parse()} function always
+ //. calls the {\tt Parse()} function of all of its children.
+
+ virtual void Assemble() = 0;
+ //. A pure virtual function which provides an interface to the
+ //. assemble method. The assemble method, implemented in derived
+ //. classes, is responsible for creating the string representation
+ //. from the broken-down representation. In other words, the
+ //. assemble method is the opposite of the parse method. Before
+ //. assembling its string representation, the assemble method calls
+ //. the assemble method of each of its children. In this way, the
+ //. entire tree structure that represents a message may be traversed.
+ //. If the is-modifed flag for a {\tt DwMessageComponent} is cleared,
+ //. the {\tt Assemble()} function will return immediately without
+ //. calling the {\tt Assemble()} function of any of its children.
+
+ virtual DwMessageComponent* Clone() const = 0;
+ //. Creates a new {\tt DwMessageComponent} on the free store that is of
+ //. the same type as, and has the same value as, this object. The
+ //. basic idea is that of a ``virtual copy constructor.''
+
+ void FromString(const DwString& aStr);
+ void FromString(const char* aCstr);
+ //. Sets the object's string representation. {\tt aCstr} must be
+ //. NUL-terminated. This member function does not invoke the parse
+ //. method. Typically, the virtual member function {\tt Parse()}
+ //. should be called immediately after this member function to parse
+ //. the {\tt DwMessageComponent} object and all of its children into
+ //. their broken-down representations. See also
+ //. {\tt DwMessageComponent::Parse()}
+
+ const DwString& AsString();
+ //. Returns the {\tt DwMessageComponent} object's string representation.
+ //. The assemble method is not called automatically. Typically, the
+ //. {\tt Assemble()} member function should be called immediately before
+ //. this member function to insure that the broken-down representation
+ //. and the string representation are consistent. See also
+ //. {\tt DwMessageComponent::Assemble()}.
+
+ DwMessageComponent* Parent();
+ //. Returns the {\tt DwMessageComponent} object that is the parent
+ //. of this object.
+
+ void SetParent(DwMessageComponent* aParent);
+ //. Sets {\tt aParent} as the {\tt DwMessageComponent} object's parent.
+
+ DwBool IsModified() const;
+ //. Returns 1 if the is-modified flag is set for this
+ //. {\tt DwMessageComponent} object.
+
+ void SetModified();
+ //. Sets the is-modified (dirty) flag for this {\tt DwMessageComponent}
+ //. object and notifies the object's parent to also set its is-modified
+ //. flag.
+
+ int ClassId() const;
+ //. Returns an integer id for the object's class.
+
+ const char* ClassName() const;
+ //. Returns the name of the class as a NUL-terminated
+ //. char string.
+
+ int ObjectId() const;
+ //. Returns a object id that is unique among all DwMessageComponent
+ //. objects.
+
+ const char* partId() const { return mId.c_str(); };
+ void SetPartId( DwString id ) { mId = id; };
+ // set or get a unique string for that part
+
+protected:
+
+ DwString mString;
+ // String representation
+
+ DwBool mIsModified;
+ // Is-modified flag
+
+ DwMessageComponent* mParent;
+ // Component that contains this component
+
+ componentType mClassId;
+ // Class identifier for runtime type identification
+
+ const char* mClassName;
+ // Class name for runtime type identification
+
+ DwString mId;
+ // unique indentifier
+
+private:
+
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/msgid.h b/mimelib/mimelib/msgid.h
new file mode 100644
index 00000000..de066cdb
--- /dev/null
+++ b/mimelib/mimelib/msgid.h
@@ -0,0 +1,180 @@
+//=============================================================================
+// File: msgid.h
+// Contents: Declarations for DwMsgId
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_MSGID_H
+#define DW_MSGID_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_FIELDBDY_H
+#include <mimelib/fieldbdy.h>
+#endif
+
+//=============================================================================
+//+ Name DwMsgId -- Class representing an RFC-822 msg-id
+//+ Description
+//. {\tt DwMsgId} represents a {\it msg-id} as described in RFC-822. In
+//. the BNF grammar in RFC-822, a msg-id has a {\it local-part} and a
+//. {\it domain}. In MIME++, a {\tt DwMsgId} contains strings that
+//. contain the local-part and the domain.
+//.
+//. In the tree (broken-down) representation of message, a {\tt DwMsgId}
+//. object may only be a leaf node, having a parent but no child nodes.
+//. Its parent node must be a {\tt DwField} object.
+//.
+//. {\tt DwMsgId} has member functions for getting or setting its local-part
+//. and its domain. You can have the library to create the contents of a
+//. {\tt DwMsgId} object for you by calling the member function
+//. {\tt CreateDefault()}.
+//=============================================================================
+// Last modified 1997-07-28
+//+ Noentry ~DwMsgId mLocalPart mDomain sClassName _PrintDebugInfo
+
+
+class DW_EXPORT DwMsgId : public DwFieldBody {
+
+public:
+
+ DwMsgId();
+ DwMsgId(const DwMsgId& aMsgId);
+ DwMsgId(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwMsgId} object's string representation to the empty string
+ //. and sets its parent to NULL.
+ //.
+ //. The second constructor is the copy constructor, which performs
+ //. a deep copy of {\tt aMsgId}.
+ //. The parent of the new {\tt DwMsgId} object is set to NULL.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwMsgId}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is NULL, {\tt aParent} should point to an object of a class
+ //. derived from {\tt DwField}.
+
+ virtual ~DwMsgId();
+
+ const DwMsgId& operator = (const DwMsgId& aMsgId);
+ //. This is the assignment operator, which performs a deep copy of
+ //. {\tt aMsgId}. The parent node of the {\tt DwMsgId} object
+ //. is not changed.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwMsgId} objects. The parse
+ //. method parses the local-part and the domain from the string
+ //. representation.
+ //.
+ //. You should call this member function after you set or modify the
+ //. string representation, and before you retrieve local-part or
+ //. domain.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwMsgId} objects. The
+ //. assemble method creates or updates the string representation
+ //. from the local-part and the domain.
+ //.
+ //. You should call this member function after you modify the
+ //. local-part or the domain, and before you retrieve the string
+ //. representation.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwMsgId} on the free store that has the same
+ //. value as this {\tt DwMsgId} object. The basic idea is that of
+ //. a ``virtual copy constructor.''
+
+ virtual void CreateDefault();
+ //. Creates a value for the msg-id. Uses the current time,
+ //. process id, and fully qualified domain name for the host.
+
+ const DwString& LocalPart() const;
+ //. Returns the local-part of the msg-id.
+
+ void SetLocalPart(const DwString& aLocalPart);
+ //. Sets the local-part of the msg-id.
+
+ const DwString& Domain() const;
+ //. Returns the domain of the msg-id.
+
+ void SetDomain(const DwString& aDomain);
+ //. Sets the domain of the msg-id.
+
+ static DwMsgId* NewMsgId(const DwString& aStr,
+ DwMessageComponent* aParent);
+ //. Creates a new {\tt DwMsgId} object on the free store.
+ //. If the static data member {\tt sNewMsgId} is NULL,
+ //. this member function will create a new {\tt DwMsgId}
+ //. and return it. Otherwise, {\tt NewMsgId()} will call
+ //. the user-supplied function pointed to by {\tt sNewMsgId},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwMsgId}, and return that object.
+
+ //+ Var sNewMsgId
+ static DwMsgId* (*sNewMsgId)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewMsgId} is not NULL, it is assumed to point to a
+ //. user-supplied function that returns an object from a class derived from
+ //. {\tt DwMsgId}.
+
+ static const char* sHostName;
+ //. Host name of machine, used to create msg-id string. This data member
+ //. is ignored if the platform supports a gethostname() function call.
+
+private:
+
+ DwString mLocalPart;
+ DwString mDomain;
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/nntp.h b/mimelib/mimelib/nntp.h
new file mode 100644
index 00000000..a2c17b78
--- /dev/null
+++ b/mimelib/mimelib/nntp.h
@@ -0,0 +1,376 @@
+//=============================================================================
+// File: nntp.h
+// Contents: Declarations for DwNntpClient
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_NNTP_H
+#define DW_NNTP_H
+
+#include <stdio.h>
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_PROTOCOL_H
+#include <mimelib/protocol.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+
+//=============================================================================
+//+ Name DwNntpClient -- Class for handling the client side of an NNTP session
+//+ Description
+//. {\tt DwNntpClient} is a class that handles the client side of an NNTP
+//. session. Specifically, {\tt DwNntpClient} provides facilities for
+//. opening a connection to an NNTP server, sending commands and data to
+//. the server, receiving responses and data from the server, and closing
+//. the connection. The protocol implemented is the Network News Transport
+//. Protocol, as specified in RFC-977.
+//.
+//. {\tt DwNntpClient} is derived from {\tt DwProtocolClient}. For information
+//. about inherited member functions, especially member functions for detecting
+//. failures or errors, see the man page for {\tt DwProtocolClient}.
+//.
+//. In an NNTP session, the client sends commands to the server and receives
+//. responses from the server. A client command consists of a command word
+//. and zero or more argument words. A server response consists of a status
+//. line and possibly some additional lines of text. The status line consists
+//. of a three-digit numeric reply code followed by additional information.
+//. The reply code indicates a success or failure condition. In some cases,
+//. the server sends lines of text immediately after the status line.
+//. {\tt DwNntpClient} provides facilities for you to send commands to the
+//. server and receive responses from the server.
+//.
+//. {\tt DwNntpClient} has only a default constructor. On Win32 platforms,
+//. it is possible for the constructor to fail. (It calls WSAStartup().)
+//. You should verify that the constructor succeeded by calling the inherited
+//. member function {\tt DwProtocolClient::LastError()} and checking for a zero
+//. return value.
+//.
+//. To open a connection to the server, call the member function {\tt Open()}
+//. with the name of the server as an argument. {\tt Open()} accepts an
+//. optional argument that specifies the TCP port that the server listens to.
+//. The default port is the standard NNTP port (119). {\tt Open()} may fail,
+//. so you should check the return value to verify that it succeeded. To
+//. close the connection, call the inherited member function
+//. {\tt DwProtocolClient::Close()}. To check if a connection is open, call
+//. the inherited member function {\tt DwProtocolClient::IsOpen()}.
+//. {\tt IsOpen()} returns a boolean value that indicates whether or not
+//. a call to {\tt Open()} was successful; it will not detect failure in
+//. the network or a close operation by the remote host.
+//.
+//. For each NNTP command, {\tt DwNntpClient} has a member function that sends
+//. that command and receives the server's response. If the command takes any
+//. arguments, then those arguments are passed as function arguments to the
+//. command function. The command functions return the numeric value of the
+//. three-digit reply code returned by the server. Your program must check
+//. the reply code to determine whether or not the command was accepted and
+//. performed by the server.
+//. In some cases, because of a communications error or some other error,
+//. it is not possible for the command function to send the command or
+//. receive the response. When this happens, the command function will
+//. return 0. You can determine the precise error or failure by calling
+//. the inherited member functions {\tt DwProtocolClient::LastError()} or
+//. {\tt DwProtocolClient::LastFailure()}.
+//.
+//. After each command is sent, {\tt DwNntpClient} receives the server's
+//. response and remembers it. The member function {\tt ReplyCode()}
+//. returns the numeric value of the reply code received in response to
+//. the last command. {\tt StatusResponse()} returns the entire status
+//. response from the server, including the reply code. If no status
+//. response is received, possibly because of a communications error
+//. or failure, {\tt ReplyCode()} returns zero and {\tt StatusResponse()}
+//. returns an empty string.
+//.
+//. The server sends a status response, including a reply code, for all
+//. all NNTP commands. For some commands, such as when the client requests
+//. an article body, the server sends a multi-line text response immediately
+//. following the status response. Multi-line text responses
+//. can be received in either of two ways. The simplest way is to call the
+//. member function {\tt TextResponse()} after a command completes
+//. successfully. This simple method works fine for non-interactive
+//. applications. It can be a problem in interactive applications, however,
+//. because there is no data to display to a user until the entire text
+//. response is retrieved. An alternative method allows your program to
+//. retrieve the text response one line at a time as it is received.
+//. To use this method, you must define a subclass of {\tt DwObserver}
+//. and assign an object of that class to the {\tt DwNntpClient} object
+//. using the member function {\tt SetObserver()}. {\tt DwObserver} is an
+//. abstract class, declared in protocol.h, that has just one pure virtual
+//. member function {\tt Notify()}. After each line of the text response
+//. is received, {\tt DwNntpClient} will call the {\tt Notify()} member
+//. function of its assigned {\tt DwObserver} object. Each invocation of
+//. {\tt Notify()} should call the {\tt DwNntpClient} member function
+//. {\tt TextResponse()} to retrieve the next line of the text response.
+//. Note that you cannot use both of these methods at the same time: if
+//. an observer is assigned, {\tt TextResponse()} returns only the last
+//. line received, not the entire multi-line text response.
+//.
+//. Certain NNTP commands, such as the POST command, require the NNTP client
+//. to send multiple lines of text to the server. To perform this bulk data
+//. transfer, {\tt DwNntpClient} provides the member function
+//. {\tt SendData()}. In the current implementation, {\tt SendData()} does
+//. not convert end of line characters, so it is your responsibility to
+//. convert the end of line characters to CR LF, if necessary. (You may
+//. use the utility function {\tt DwToCrLfEol()} to do the conversion.)
+//. {\tt SendData()} will perform the character stuffing to protect '.' at
+//. the beginning of a line, and it will append the final [CR LF] '.' CR LF.
+//. It is possible to divide data and make multiple calls to {\tt SendData()};
+//. however, if you do so, please note the following paragraph.
+//.
+//. Note: Because of a feature (some might say bug) in the current
+//. implementation, {\tt SendData()} will not detect a '.' at the beginning
+//. of a line if the CR LF '.' sequence is split between two calls to
+//. {\tt SendData()}. This problem will probably be resolved in a future
+//. version, but be aware that such a change will require a change in
+//. {\tt DwNntpClient}'s interface.
+//=============================================================================
+
+//+ Noentry ~DwNntpClient
+
+
+class DW_EXPORT DwNntpClient : public DwProtocolClient {
+
+friend class NNTP;
+friend class NNTPObserver;
+
+public:
+
+ enum {
+ kCmdNoCommand=0,
+ kCmdArticle,
+ kCmdBody,
+ kCmdHead,
+ kCmdStat,
+ kCmdGroup,
+ kCmdHelp,
+ kCmdIhave,
+ kCmdLast,
+ kCmdList,
+ kCmdNewgroups,
+ kCmdNewnews,
+ kCmdNext,
+ kCmdPost,
+ kCmdQuit,
+ kCmdSlave
+ };
+
+ DwNntpClient();
+ //. Initializes the {\tt DwNntpClient} object.
+ //. It is possible for the constructor to fail. To verify that the
+ //. constructor succeeded, call the member function {\tt LastError()}
+ //. and check that it returns zero. (In the Win32 implementation, the
+ //. constructor calls the Winsock function {\tt WSAStartup()}, which
+ //. may fail.)
+
+ virtual ~DwNntpClient();
+
+ virtual int Open(const char* aServer, DwUint16 aPort=119);
+ //. Opens a TCP connection to the server {\tt aServer} at port {\tt aPort}.
+ //. {\tt aServer} may be either a host name, such as "news.acme.com" or
+ //. an IP number in dotted decimal format, such as "147.81.64.60". The
+ //. default value for {\tt aPort} is 119, the well-known port for NNTP
+ //. assigned by the Internet Assigned Numbers Authority (IANA).
+ //.
+ //. If the connection attempt succeeds, the server sends a response.
+ //. {\tt Open()} returns the server's numeric reply code. The full
+ //. response from the server can be retrieved by calling
+ //. {\tt StatusResponse()}.
+ //.
+ //. If the connection attempt fails, {\tt Open()} returns 0. To determine
+ //. what error occurred when a connection attempt fails, call the inherited
+ //. member function {\tt DwProtocolClient::LastError()}. To determine if
+ //. a failure also occurred, call the inherited member function
+ //. {\tt DwProtocolClient::LastFailure()}.
+
+ DwObserver* SetObserver(DwObserver* aObserver);
+ //. Sets the observer object that interacts with the {\tt DwNntpClient}
+ //. object to retrieve a multi-line text response. If an observer is set,
+ //. {\tt DwNntpClient} will call the observer's {\tt Notify()} method
+ //. after each line of the text response is received. To remove
+ //. an observer, call {\tt SetObserver()} with a NULL argument.
+ //. {\tt SetObserver()} returns the previously set observer, or NULL if
+ //. no observer was previously set.
+
+ int ReplyCode() const;
+ //. Returns the numeric value of the three-digit reply code received
+ //. from the server in response to the last client command. If no
+ //. response was received, {\tt ReplyCode()} returns zero.
+
+ const DwString& StatusResponse() const;
+ //. Returns the entire status response last received from the server.
+ //. If no response was received, perhaps because of a communications
+ //. failure, {\tt StatusResponse()} returns an empty string.
+
+ const DwString& TextResponse() const;
+ //. If no observer is set for this object, {\tt TextResponse()} returns
+ //. a string that comprises the entire sequence of lines received from
+ //. the server. Otherwise, if an observer {\tt is} set for this object,
+ //. {\tt TextResponse()} returns only the most recent line received.
+
+ int Article(int aNumber=(-1));
+ int Article(const char* aMsgid);
+ //. Sends the NNTP ARTICLE command and returns the reply code received
+ //. from the server. If no response is received, the function returns
+ //. zero.
+ //. The optional argument {\tt aNumber} specifies the number of an
+ //. article to retrieve. If {\tt Article()} is called with the default
+ //. argument, the ARTICLE command is sent to the server with no argument.
+ //. {\tt aMsgId} specifies the message id of an article to retrieve.
+
+ int Body(int aNumber=(-1));
+ int Body(const char* aMsgid);
+ //. Sends the NNTP BODY command and returns the reply code received
+ //. from the server. If no response is received, the function returns
+ //. zero.
+ //. The optional argument {\tt aNumber} specifies the number of an
+ //. article whose body should be retrieved. If {\tt Body()} is called
+ //. with the default argument, the BODY command is sent to the server
+ //. with no argument. {\tt aMsgId} specifies the message id of the
+ //. article to access.
+
+ int Head(int aNumber=(-1));
+ int Head(const char* aMsgid);
+ //. Sends the NNTP HEAD command and returns the reply code received
+ //. from the server. If no response is received, the function returns
+ //. zero.
+ //. The optional argument {\tt aNumber} specifies the number of an
+ //. article whose header lines should be retrieved. If {\tt Head()}
+ //. is called with the default argument, the HEAD command is sent to
+ //. the server with no argument. {\tt aMsgId} specifies the message id
+ //. of the article to access.
+
+ int Stat(int aNumber=(-1));
+ int Stat(const char* aMsgid);
+ //. Sends the NNTP STAT command and returns the reply code received
+ //. from the server. If no response is received, the function returns
+ //. zero.
+ //. The optional argument {\tt aNumber} specifies the number of an
+ //. article to access. If {\tt Stat()} is called with the default
+ //. argument, the STAT command is sent to the server with no argument.
+ //. {\tt aMsgId} specifies the message id of the article to access.
+
+ int Group(const char* aNewsgroupName);
+ //. Sends the NNTP GROUP command and returns the reply code received from
+ //. the server. The argument {\tt aNewsgroupName} specifies the newgroup
+ //. to be selected. If no response is received, the function returns zero.
+
+ int Help();
+ //. Sends the NNTP HELP command and returns the reply code received from
+ //. the server. If no response is received, the function returns zero.
+
+ int Ihave(const char* aMsgId);
+ //. Sends the NNTP IHAVE command and returns the reply code received from
+ //. the server. {\tt aMsgId} specifies the message id of the article
+ //. to be sent. If no response is received, the function returns zero.
+
+ int Last();
+ //. Sends the NNTP LAST command and returns the reply code received from
+ //. the server. If no response is received, the function returns zero.
+
+ int List();
+ //. Sends the NNTP LIST command and returns the reply code received from
+ //. the server. If no response is received, the function returns zero.
+
+ int Newgroups(const char* aDate, const char* aTime,
+ DwBool aIsGmt=DwFalse, const char* aDistributions=0);
+ //. Sends the NNTP NEWGROUPS command and returns the reply code received
+ //. from the server. If no response is received, the function returns
+ //. zero.
+ //. {\tt aDate} is the date in the form YYMMDD, where YY is the two
+ //. digit year, MM is the month, and DD is the day of the month.
+ //. {\tt aTime} is the time in the form HHMMSS, where HH is hours,
+ //. MM is minutes, and SS is seconds. If {\tt aIsGmt} is true,
+ //. the optional GMT argument will be sent. {\tt aDistributions}
+ //. specifies the optional list of distribution groups.
+
+ int Newnews(const char* aNewsgroups, const char* aDate,
+ const char* aTime, DwBool aIsGmt=DwFalse, const char* aDistribution=0);
+ //. Sends the NNTP NEWNEWS command and returns the reply code received
+ //. from the server. If no response is received, the function returns
+ //. zero.
+ //. {\tt aNewsgroups} is the newsgroups argument for the command.
+ //. {\tt aDate} is the date in the form YYMMDD, where YY is the two
+ //. digit year, MM is the month, and DD is the day of the month.
+ //. {\tt aTime} is the time in the form HHMMSS, where HH is hours,
+ //. MM is minutes, and SS is seconds. If {\tt aIsGmt} is true,
+ //. the optional GMT argument will be sent. {\tt aDistributions}
+ //. specifies the optional list of distribution groups.
+
+ int Next();
+ //. Sends the NNTP NEXT command and returns the reply code received from
+ //. the server. If no response is received, perhaps because of an error,
+ //. the function returns zero.
+
+ int Post();
+ //. Sends the NNTP POST command and returns the reply code received from
+ //. the server. If no response is received, perhaps because of an error,
+ //. the function returns zero.
+
+ int Quit();
+ //. Sends the NNTP QUIT command and returns the reply code received from
+ //. the server. If no response is received, perhaps because of an error,
+ //. the function returns zero.
+
+ int Slave();
+ //. Sends the NNTP SLAVE command and returns the reply code received from
+ //. the server. If no response is received, perhaps because of an error,
+ //. the function returns zero.
+
+ int SendData(const DwString& aStr);
+ int SendData(const char* aBuf, int aBufLen);
+ //. Sends bulk data to the server and returns the reply code received.
+ //. A bulk data transfer follows a POST or IHAVE command and is used to
+ //. send a complete article to the server.
+ //.
+ //. In the current implementation, {\tt SendData()} does not convert end
+ //. of line characters, so it is your responsibility to convert the end
+ //. of line characters to CR LF, if necessary. (You may use the utility
+ //. function {\tt DwToCrLfEol()} to do the conversion.) {\tt SendData()}
+ //. will perform the character stuffing to protect '.' at the beginning of
+ //. a line, and it will append the final [CR LF] '.' CR LF. It is possible
+ //. to divide the data and make multiple calls to {\tt SendData()}; however,
+ //. this may cause problems in the current implementation if a CR LF '.'
+ //. sequence is split between calls.
+
+private:
+
+ char* mSendBuffer;
+ char* mRecvBuffer;
+ int mLastChar;
+ int mLastLastChar;
+ int mNumRecvBufferChars;
+ int mRecvBufferPos;
+ int mReplyCode;
+ DwString mStatusResponse;
+ DwString mTextResponse;
+ DwObserver* mObserver;
+
+ virtual int PGetLine(char** aPtr, int* aLen);
+ virtual void PGetStatusResponse();
+ virtual void PGetTextResponse();
+
+};
+
+#endif
diff --git a/mimelib/mimelib/param.h b/mimelib/mimelib/param.h
new file mode 100644
index 00000000..94458a7a
--- /dev/null
+++ b/mimelib/mimelib/param.h
@@ -0,0 +1,173 @@
+//=============================================================================
+// File: param.h
+// Contents: Declarations for DwParameter
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_PARAM_H
+#define DW_PARAM_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_MSGCMP_H
+#include <mimelib/msgcmp.h>
+#endif
+
+
+//=============================================================================
+//+ Name DwParameter -- Class representing a MIME field body parameter
+//+ Description
+//. {\tt DwParameter} represents the {\it parameter} component of the
+//. Content-Type header field as described in RFC-2045. A parameter
+//. consists of an attribute/value pair. {\tt DwParameter} has member
+//. functions for getting or setting a parameter's attribute and value.
+//.
+//. A {\tt DwParameter} object may be included in a list of {\tt DwParameter}
+//. objects. You can get the next {\tt DwParameter} object in the list by
+//. calling the member function {\tt Next()}.
+//=============================================================================
+// Last modified 1997-08-13
+//+ Noentry ~DwParameter _PrintDebugInfo
+
+class DW_EXPORT DwParameter : public DwMessageComponent {
+
+ friend class DwMediaType;
+
+public:
+
+ DwParameter();
+ DwParameter(const DwParameter& aParam);
+ DwParameter(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwParameter} object's string representation to the empty string
+ //. and sets its parent to NULL.
+ //.
+ //. The second constructor is the copy constructor, which copies the
+ //. string representation, attribute, and value from {\tt aParam}.
+ //. The parent of the new {\tt DwParameter} object is set to NULL.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwParameter}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is NULL, {\tt aParent} should point to an object of a class
+ //. derived from {\tt DwMediaType}.
+
+ virtual ~DwParameter();
+
+ const DwParameter& operator = (const DwParameter& aParam);
+ //. This is the assignment operator.
+
+ virtual void Parse();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the parse method for {\tt DwParameter} objects.
+ //. It should be called immediately after the string representation
+ //. is modified and before the parts of the broken-down
+ //. representation are accessed.
+
+ virtual void Assemble();
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. executes the assemble method for {\tt DwParameter} objects.
+ //. It should be called whenever one of the object's attributes
+ //. is changed in order to assemble the string representation from
+ //. its broken-down representation. It will be called
+ //. automatically for this object by the parent object's
+ //. {\tt Assemble()} member function if the is-modified flag is set.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwParameter} on the free store that has the same
+ //. value as this {\tt DwParameter} object. The basic idea is that of
+ //. a ``virtual copy constructor.''
+
+ const DwString& Attribute() const;
+ //. Returns the attribute contained by this parameter.
+
+ void SetAttribute(const DwString& aAttribute);
+ //. Sets the attribute contained by this parameter.
+
+ const DwString& Value() const;
+ //. Returns the value contained by this parameter.
+
+ void SetValue(const DwString& aValue, bool forceNoQuotes=false);
+ //. Sets the value contained by this parameter.
+
+ DwParameter* Next() const ;
+ //. Returns the next {\tt DwParameter} object in the list.
+
+ void SetNext(DwParameter* aParam);
+ //. Returns the next {\tt DwParameter} object in the list. Since
+ //. {\tt DwMediaType} has member functions for adding {\tt DwParameter}
+ //. objects to its list, you should avoid using this function.
+
+ static DwParameter* NewParameter(const DwString& aStr,
+ DwMessageComponent* aParent);
+ //. Creates a new {\tt DwParameter} object on the free store.
+ //. If the static data member {\tt sNewParameter} is NULL,
+ //. this member function will create a new {\tt DwParameter}
+ //. and return it. Otherwise, {\tt NewParameter()} will call
+ //. the user-supplied function pointed to by {\tt sNewParameter},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwParameter}, and return that object.
+
+ //+ Var sNewParameter
+ static DwParameter* (*sNewParameter)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewParameter} is not NULL, it is assumed to point to a
+ //. user-supplied function that returns an object from a class derived from
+ //. {\tt DwParameter}.
+
+private:
+
+ DwString mAttribute;
+ DwString mValue;
+ bool mForceNoQuotes;
+ DwParameter* mNext;
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/pop.h b/mimelib/mimelib/pop.h
new file mode 100644
index 00000000..5bd90ea7
--- /dev/null
+++ b/mimelib/mimelib/pop.h
@@ -0,0 +1,300 @@
+//=============================================================================
+// File: pop.h
+// Contents: Declarations for DwPopClient
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_POP_H
+#define DW_POP_H
+
+#include <stdio.h>
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_PROTOCOL_H
+#include <mimelib/protocol.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+
+//=============================================================================
+//+ Name DwPopClient -- Class for handling the client side of a POP session
+//+ Description
+//. {\tt DwPopClient} is a class that handles the client side of a POP
+//. session. Specifically, {\tt DwPopClient} provides facilities for
+//. opening a connection to a POP server, sending commands to the server,
+//. receiving responses from the server, and closing the connection. The
+//. protocol implemented is the Post Office Protocol version 3, as specified
+//. in RFC-1939.
+//.
+//. {\tt DwPopClient} is derived from {\tt DwProtocolClient}. For information
+//. about inherited member functions, especially member functions for detecting
+//. failures or errors, see the man page for {\tt DwProtocolClient}.
+//.
+//. In a POP session, the client sends commands to the server and receives
+//. responses from the server. A client command consists of a command word
+//. and zero or more argument words. A server response consists of a single
+//. line status response, which may be followed immediately by a multi-line
+//. response. The first word of the status response is either +OK or -ERR,
+//. indicating the success or failure of the command. The status line may
+//. also contain other information requested by the client.
+//.
+//. {\tt DwPopClient} has only a default constructor. On Win32 platforms,
+//. it is possible for the constructor to fail. (It calls WSAStartup().)
+//. You should verify that the constructor succeeded by calling the inherited
+//. member function {\tt DwProtocolClient::LastError()} and checking for a zero
+//. return value.
+//.
+//. To open a connection to the server, call the member function {\tt Open()}
+//. with the name of the server as an argument. {\tt Open()} accepts an
+//. optional argument that specifies the TCP port that the server listens to.
+//. The default port is the standard POP port (110). {\tt Open()} may fail,
+//. so you should check the return value to verify that it succeeded. To
+//. close the connection, call the inherited member function
+//. {\tt DwProtocolClient::Close()}. To check if a connection is open, call
+//. the inherited member function {\tt DwProtocolClient::IsOpen()}.
+//. {\tt IsOpen()} returns a boolean value that indicates whether or not
+//. a call to {\tt Open()} was successful; it will not detect failure in
+//. the network or a close operation by the remote host.
+//.
+//. For each POP command, {\tt DwPopClient} has a member function that sends
+//. that command and receives the server's response. If the command takes any
+//. arguments, then those arguments are passed as function arguments to the
+//. command function. The command functions return the first character
+//. of the server's response, which will be '+' if the command succeeded
+//. or '-' if the command failed.
+//. In some cases, because of a communications error or some other error,
+//. it is not possible for the command function to send the command or
+//. receive the response. When this happens, the command function will
+//. return 0. You can determine the precise error or failure by calling
+//. the inherited member functions {\tt DwProtocolClient::LastError()} or
+//. {\tt DwProtocolClient::LastFailure()}.
+//.
+//. After each command is sent, {\tt DwPopClient} receives the server's
+//. response and remembers it. The member function {\tt StatusCode()}
+//. returns the first character of the server's status response; it will be
+//. '+' or '-', indicating success or failure, or zero if no response was
+//. received from the server. {\tt SingleLineResponse()} returns the entire
+//. single line status response from the server, including the initial
+//. "+OK" or "-ERR" status word.
+//.
+//. The server sends a single-line response, including a status code, for all
+//. POP commands. For some commands, such as when the client requests a
+//. mail message, the server sends a multi-line text response immediately
+//. following the single-line status response. Multi-line text responses
+//. can be received in either of two ways. The simplest way is to call
+//. the member function {\tt MultiLineResponse()} after a command completes
+//. successfully. This simple method works fine for non-interactive
+//. applications. It can be a problem in interactive applications, however,
+//. because there is no data to display to a user until the entire multi-line
+//. response is retrieved. An alternative method allows your program to
+//. retrieve the multi-line response one line at a time as it is received.
+//. To use this method, you must define a subclass of {\tt DwObserver}
+//. and assign an object of that class to the {\tt DwPopClient} object
+//. using the member function {\tt SetObserver()}. {\tt DwObserver} is an
+//. abstract class, declared in protocol.h, that has just one pure virtual
+//. member function {\tt Notify()}. After each line of the multi-line response
+//. is received, {\tt DwPopClient} will call the {\tt Notify()} member
+//. function of its assigned {\tt DwObserver} object. Each invocation of
+//. {\tt Notify()} should call the {\tt DwPopClient} member function
+//. {\tt MultiLineResponse()} to retrieve the next line of the text response.
+//. Note that you cannot use both of these methods at the same time: if
+//. an observer is assigned, {\tt MultiLineResponse()} returns only the last
+//. line received, not the entire multi-line response.
+//=============================================================================
+
+//+ Noentry ~DwPopClient
+
+
+class DW_EXPORT DwPopClient : public DwProtocolClient {
+
+public:
+
+ enum {
+ kCmdNoCommand=0,
+ kCmdUser,
+ kCmdPass,
+ kCmdQuit,
+ kCmdStat,
+ kCmdList,
+ kCmdRetr,
+ kCmdDele,
+ kCmdNoop,
+ kCmdRset,
+ kCmdApop,
+ kCmdTop,
+ kCmdUidl
+ };
+
+ DwPopClient();
+ //. Initializes the {\tt DwPopClient} object.
+ //. It is possible for the constructor to fail. To verify that the
+ //. constructor succeeded, call the member function {\tt LastError()}
+ //. and check that it returns zero. (In the Win32 implementation, the
+ //. constructor calls the Winsock function {\tt WSAStartup()}, which
+ //. may fail.)
+
+ virtual ~DwPopClient();
+
+ virtual int Open(const char* aServer, DwUint16 aPort=110);
+ //. Opens a TCP connection to the server {\tt aServer} at port {\tt aPort}.
+ //. {\tt aServer} may be either a host name, such as "news.acme.com" or
+ //. an IP number in dotted decimal format, such as "147.81.64.60". The
+ //. default value for {\tt aPort} is 110, the well-known port for POP3
+ //. assigned by the Internet Assigned Numbers Authority (IANA).
+ //.
+ //. If the connection attempt succeeds, the server sends a response.
+ //. {\tt Open()} returns the server's status code ('+' or '-'). The full
+ //. response from the server can be retrieved by calling
+ //. {\tt SingleLineResponse()}.
+ //.
+ //. If the connection attempt fails, {\tt Open()} returns 0. To determine
+ //. what error occurred when a connection attempt fails, call the inherited
+ //. member function {\tt DwProtocolClient::LastError()}. To determine if
+ //. a failure also occurred, call the inherited member function
+ //. {\tt DwProtocolClient::LastFailure()}.
+
+ DwObserver* SetObserver(DwObserver* aObserver);
+ //. Sets the observer object that interacts with the {\tt DwPopClient}
+ //. object to retrieve a multi-line response. If an observer is set,
+ //. {\tt DwPopClient} will call the observer's {\tt Notify()} method
+ //. after each line of the multi-line response is received. To remove
+ //. an observer, call {\tt SetObserver()} with a NULL argument.
+ //. {\tt SetObserver()} returns the previously set observer, or NULL if
+ //. no observer was previously set.
+
+ int StatusCode() const;
+ //. Returns the status code received from the server in response to the
+ //. last client command. The status codes in POP3 are '+', indicating
+ //. success, and '-', indicating failure. If no response was received,
+ //. {\tt StatusCode()} returns zero.
+
+ const DwString& SingleLineResponse() const;
+ //. Returns the single line status response last received from the server.
+ //. If no response was received, perhaps because of a communications
+ //. failure, {\tt SingleLineResponse()} returns an empty string.
+
+ const DwString& MultiLineResponse() const;
+ //. If no observer is set for this object, {\tt MultiLineResponse()}
+ //. returns a string that comprises the entire sequence of lines
+ //. received from the server. Otherwise, if an observer {\it is} set
+ //. for this object, {\tt MultiLineResponse()} returns only the most
+ //. recent line received.
+
+ int User(const char* aName);
+ //. Sends the USER command and returns the status code received from
+ //. the server. If no response is received, the function returns zero.
+ //. {\tt aName} is the name of the user, which is sent in the command.
+
+ int Pass(const char* aPasswd);
+ //. Sends the PASS command and returns the status code received from
+ //. the server. If no response is received, the function returns zero.
+ //. {\tt aPasswd} is the password, which is sent in the command.
+
+ int Quit();
+ //. Sends the QUIT command and returns the status code received from
+ //. the server. If no response is received, the function returns zero.
+
+ int Stat();
+ //. Sends the STAT command and returns the status code received from
+ //. the server. If no response is received, the function returns zero.
+
+ int List();
+ int List(int aMsg);
+ //. Sends the LIST command, with or without a message number, and
+ //. returns the status code received from the server. If no response
+ //. is received, the function returns zero.
+
+ int Retr(int aMsg);
+ //. Sends the RETR command and returns the status code received from
+ //. the server. If no response is received, the function returns zero.
+ //. {\tt aMsg} is the message number, which is sent in the command.
+
+ int Dele(int aMsg);
+ //. Sends the DELE command and returns the status code received from
+ //. the server. If no response is received, the function returns zero.
+ //. {\tt aMsg} is the message number, which is sent in the command.
+
+ int Noop();
+ //. Sends the NOOP command and returns the status code received from
+ //. the server. If no response is received, the function returns zero.
+
+ int Rset();
+ //. Sends the RSET command and returns the status code received from
+ //. the server. If no response is received, the function returns zero.
+
+ int Apop(const char* aName, const char* aDigest);
+ //. Sends the APOP command and returns the status code received from
+ //. the server. If no response is received, the function returns zero.
+ //. {\tt aName} is the name of the user, which is sent in the command.
+ //. {\tt aDigest} is the digest argument for the command.
+
+ int Top(int aMsg, int aNumLines);
+ //. Sends the TOP command and returns the status code received from
+ //. the server. If no response is received, the function returns zero.
+ //. {\tt aMsg} is the message number. {\tt aNumLines} is the number
+ //. of lines to send.
+
+ int Uidl();
+ int Uidl(int aMsg);
+ //. Sends the TOP command, with or without a message number, and
+ //. returns the status code received from the server. If no response
+ //. is received, the function returns zero.
+
+ int Last();
+ //. Sends the LAST command and returns the status code received from
+ //. the server. If no response is received, the function returns zero.
+
+private:
+
+ char* mSendBuffer;
+ char* mRecvBuffer;
+ int mNumRecvBufferChars;
+ int mRecvBufferPos;
+ int mStatusCode;
+ DwString mSingleLineResponse;
+ DwString mMultiLineResponse;
+ DwObserver* mObserver;
+
+ int PGetLine(char** aPtr, int* aLen);
+ // Tries to get one complete line of input from the socket. On success,
+ // the function sets {\tt *aPtr} to point to the beginning of the line in
+ // the object's internal buffer, sets {\tt *aLen} to the length of the
+ // line, including the CR LF, and returns 0. On failure, the function
+ // returns -1.
+
+ void PGetSingleLineResponse();
+ // Gets a single line of input, assigns that line {\tt mSingleLineResponse}, and
+ // sets {\tt mStatusCode}. On failure, clears {\tt mSingleLineResonse}
+ // and sets {\tt mStatusCode} to -1.
+
+ void PGetMultiLineResponse();
+ // Gets a complete multiline response and assigns it to {\tt mMultiLineResponse},
+ // or interacts with the {\tt DwObserver} object to deliver a multiline response
+ // one line at a time.
+ // If an error occurs, its sets {\tt mStatusCode} to -1.
+
+};
+
+#endif
diff --git a/mimelib/mimelib/protocol.h b/mimelib/mimelib/protocol.h
new file mode 100644
index 00000000..151a68c5
--- /dev/null
+++ b/mimelib/mimelib/protocol.h
@@ -0,0 +1,268 @@
+//=============================================================================
+// File: proto_un.h
+// Contents: Declarations for DwClientProtocol
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_PROTOCOL_H
+#define DW_PROTOCOL_H
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+
+class DwObserver {
+public:
+ virtual void Notify()=0;
+};
+
+
+//=============================================================================
+//+ Name DwProtocolClient -- Base class for all protocol clients
+//+ Description
+//. {\tt DwProtocolClient} is the base class for other classes that implement
+//. specific protocols, such as SMTP, POP, and NNTP. {\tt DwProtocolClient}
+//. serves two purposes. First, It combines operations common to all its
+//. derived classes, such as opening a TCP connection to the server. Second,
+//. it provides a platform-independent interface to the network services
+//. required by its subclasses.
+//.
+//. There are two separate implementations of {\tt DwProtocolClient}: one for
+//. Berkeley sockets under UNIX, and one for Winsock under Win32. The
+//. interface is the same for both implementations, thus providing platform
+//. independence.
+//.
+//. There are two platform-specific details that you should be aware of.
+//. First, if you are writing a UNIX program, you should be sure to handle
+//. the SIGPIPE signal. This signal is raised when a program tries to write
+//. to a TCP connection that was shutdown by the remote host. The default
+//. action for this signal is to terminate the program. To prevent this
+//. from happening in your program, you should either catch the signal or
+//. tell the operating system to ignore it. Second, if you are writing a
+//. Win32 application for Windows NT or Windows95, you should be aware of
+//. the fact that the constructor calls the Winsock function
+//. {\tt WSAStartup()} to initialize the Winsock DLL. (The destructor
+//. calls {\tt WSACleanup()}.) Because it is possible for {\tt WSAStartup()}
+//. to fail, it is also possible that the constructor may fail. To verify
+//. that the constructor has succeeded, call the member function
+//. {\tt LastError()} and check that it returns zero.
+//.
+//. To open a connection to a server, call {\tt Open()} with the server name
+//. and TCP port number as arguments. {\tt Open()} is declared virtual;
+//. derived classes may override this member function. {\tt Open()} may fail,
+//. so you should check the return value to verify that it succeeded. To close
+//. the connection, call {\tt Close()}. To check if a connection is open,
+//. call {\tt IsOpen()}. {\tt IsOpen()} returns a value that indicates whether
+//. or not a call to {\tt Open()} was successful; it will not detect failure
+//. in the network or a close operation by the remote host.
+//.
+//. {\tt DwProtocolClient} sets a timeout on receive operations on the TCP
+//. connection. The default value of the timeout period is 90 seconds. To
+//. change the default value, call {\tt SetReceiveTimeout()} and pass the
+//. new value as an argument.
+//.
+//. Whenever {\tt DwProtocolClient} cannot complete an operation, it is because
+//. an error has occurred. Most member functions indicate that an error has
+//. occurred via their return values. For most member functions, a return
+//. value of -1 indicates an error. To get the specific error that has
+//. occurred, call {\tt LastError()}, which returns either the system error
+//. code or a MIME++ defined error code. To get a text string that describes
+//. the error, call {\tt LastErrorStr()}.
+//.
+//. Some errors are also considered "failures." A failure occurs when an
+//. operation cannot be completed because of conditions external to the
+//. program. For example, a failure occurs when the network is down or
+//. when an application's user enters bad input. Errors that occur because
+//. of programmer error are not considered failures. If an error occurs,
+//. you should call {\tt LastError()} to determine the error, but you should
+//. also call {\tt LastFailure()} to determine if a failure occurred. In
+//. interactive applications, failures should always be reported to the
+//. application's user. To get a text string that describes a failure,
+//. call {\tt LastFailureStr()}.
+//.
+//. It is possible to translate the error and failure message strings to a
+//. language other than English. To do this, you may override the virtual
+//. function {\tt HandleError()}.
+//=============================================================================
+
+//+ Noentry mFailureCode mFailureStr mErrorCode mErrorStr mLastCommand
+//+ Noentry mIsDllOpen mIsOpen mSocket mPort mServerName mReceiveTimeout
+
+
+class DwProtocolClient {
+
+public:
+
+ enum Failure {
+ kFailNoFailure = 0, // No failure
+ kFailNoWinsock = 1, // A usable Winsock DLL could not be found
+ kFailNetDown = 2, // The network is down
+ kFailHostNotFound = 3, // The server was not found
+ kFailConnReset = 4, // The connection was reset
+ kFailNetUnreachable = 5, // The network is unreachable
+ kFailTimedOut = 6, // Timed out while waiting for an operation
+ // to complete
+ kFailConnDropped = 7,
+ kFailConnRefused = 8,
+ kFailNoResources = 9
+ };
+ //. Enumerated values for failures.
+
+ enum Error {
+ kErrNoError = 0,
+ kErrUnknownError = 0x4000,
+ kErrBadParameter = 0x4001,
+ kErrBadUsage = 0x4002,
+ kErrNoWinsock = 0x4003, // Win32
+ kErrHostNotFound = 0x5000, // UNIX
+ kErrTryAgain = 0x5001, // UNIX
+ kErrNoRecovery = 0x5002, // UNIX
+ kErrNoData = 0x5003, // UNIX
+ kErrNoAddress = 0x5004 // UNIX
+ };
+ //. MIME++-defined error codes.
+
+protected:
+
+ DwProtocolClient();
+ //. Initializes the {\tt DwProtocolClient} object.
+ //. In a Win32 environment, this constructor calls {\tt WSAStartup()}
+ //. to initialize the Winsock DLL. To verify that the DLL was initialized
+ //. successfully, call the member function {\tt LastError()} and verify
+ //. that it returns zero.
+
+public:
+
+ virtual ~DwProtocolClient();
+ //. Frees the resources used by this object.
+ //. In a Win32 environment, the destructor calls {\tt WSACleanup()}.
+
+ virtual int Open(const char* aServer, DwUint16 aPort);
+ //. Opens a TCP connection to the server {\tt aServer} at port {\tt aPort}.
+ //. {\tt aServer} may be either a host name, such as "smtp.acme.com" or an
+ //. IP number in dotted decimal format, such as "147.81.64.59". If the
+ //. connection attempt succeeds, {\tt Open()} returns 0; othewise, it
+ //. returns -1. To determine what error occurred when the connection
+ //. attempt fails, call the member function {\tt LastError()}. To
+ //. determine if a failure also occurred, call the member function
+ //. {\tt LastFailure()}.
+
+ DwBool IsOpen() const;
+ //. Returns true value if a connection to the server is open.
+ //. {\tt IsOpen()} will return a true value if a call to {\tt Open()} was
+ //. successful; it will not detect failure in the network or a close
+ //. operation by the remote host.
+
+ int Close();
+ //. Closes the connection to the server. Returns 0 if successful, or
+ //. returns -1 if unsuccessful.
+
+ int SetReceiveTimeout(int aSecs);
+ //. Changes the default timeout for receive operations on the socket to
+ //. {\tt aSecs} seconds.
+ //. The default value is 90 seconds.
+
+ int LastCommand() const;
+ //. Returns an enumerated value indicating the last command sent to
+ //. the server. Enumerated values are defined in subclasses of
+ //. {\tt DwProtocolClient}.
+
+ int LastFailure() const;
+ //. Returns an enumerated value indicating what failure last occurred.
+
+ const char* LastFailureStr() const;
+ //. Returns a failure message string associated with the failure code
+ //. returned by {\tt LastFailure()}.
+
+ int LastError() const;
+ //. Returns an error code for the last error that occurred. Normally, the
+ //. error code returned is an error code returned by a system call;
+ //. {\tt DwProtocolClient} does no translation of error codes returned
+ //. by system calls. In some cases, an error code defined by MIME++ may
+ //. returned to indicate improper use of the {\tt DwProtocolClient} class.
+
+ const char* LastErrorStr() const;
+ //. Returns an error message string associated with the error code returned
+ //. by {\tt LastError()}.
+
+protected:
+
+ enum {
+ kWSAStartup=1, // Win32
+ kgethostbyname,
+ ksocket,
+ ksetsockopt,
+ kconnect,
+ ksend,
+ krecv,
+ kclose, // UNIX
+ kclosesocket, // Win32
+ kselect
+ };
+ // Enumerated values that indicate the system call that detected
+ // an error
+
+ DwBool mIsDllOpen;
+ DwBool mIsOpen;
+ int mSocket;
+ DwUint16 mPort;
+ char* mServerName;
+ int mReceiveTimeout;
+ int mLastCommand;
+ int mFailureCode;
+ const char* mFailureStr;
+ int mErrorCode;
+ const char* mErrorStr;
+
+ virtual void HandleError(int aErrorCode, int aSystemCall);
+ //. Interprets error codes. {\tt aErrorCode} is an error code,
+ //. which may be a system error code, or an error code defined by
+ //. {\tt DwProtocolClient}. {\tt aSystemCall} is an enumerated value
+ //. defined by {\tt DwProtocolClient} that indicates the last system
+ //. call made, which should be the system call that set the error code.
+ //. {\tt HandleError()} sets values for {\tt mErrorStr},
+ //. {\tt mFailureCode}, and {\tt mFailureStr}.
+
+ int PSend(const char* aBuf, int aBufLen);
+ //. Sends {\tt aBufLen} characters from the buffer {\tt aBuf}. Returns
+ //. the number of characters sent. If the number of characters sent
+ //. is less than the number of characters specified in {\tt aBufLen},
+ //. the caller should call {\tt LastError()} to determine what, if any,
+ //. error occurred. To determine if a failure also occurred, call the
+ //. member function {\tt LastFailure()}.
+
+ int PReceive(char* aBuf, int aBufSize);
+ //. Receives up to {\tt aBufSize} characters into the buffer {\tt aBuf}.
+ //. Returns the number of characters received. If zero is returned, the
+ //. caller should call the member function {\tt LastError()} to determine
+ //. what, if any, error occurred. To determine if a failure also occurred,
+ //. call the member function {\tt LastFailure()}.
+
+};
+
+#endif
diff --git a/mimelib/mimelib/string.h b/mimelib/mimelib/string.h
new file mode 100644
index 00000000..35be8e0b
--- /dev/null
+++ b/mimelib/mimelib/string.h
@@ -0,0 +1,772 @@
+//=============================================================================
+// File: dwstring.h
+// Contents: Declarations for DwString
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_STRING_H
+#define DW_STRING_H
+
+#include <assert.h>
+#include <stddef.h>
+#include <iostream>
+#include <stdio.h>
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#if defined(DW_USE_ANSI_STRING)
+
+#include <string>
+typedef std::string DwString;
+
+#else // ! defined(DW_USE_ANSI_STRING)
+
+//=============================================================================
+// DwStringRep is an implementation class that should not be used externally.
+//=============================================================================
+
+struct DW_EXPORT DwStringRep {
+ DwStringRep(char* aBuf, size_t aSize);
+ DwStringRep(FILE* aFile, size_t aSize);
+ ~DwStringRep();
+ // void* operator new(size_t);
+ // void operator delete(void*, size_t);
+ size_t mSize;
+ char* mBuffer;
+ int mRefCount, mPageMod;
+//private:
+ // memory management
+ // DwStringRep* mNext;
+ // static DwStringRep* theirPool;
+ // static int theirPoolCount;
+public:
+ void CheckInvariants() const;
+};
+
+
+//=============================================================================
+//+ Name DwString -- String class
+//+ Description
+//. {\tt DwString} is the workhorse of the MIME++ library. Creating, parsing,
+//. or otherwise manipulating MIME messages is basically a matter of
+//. manipulating strings. {\tt DwString} provides all the basic functionality
+//. required of a string object, including copying, comparing, concatenating,
+//. and so on.
+//.
+//. {\tt DwString} is similar to the {\tt string} class that is part of
+//. the proposed ANSI standard C++ library. Some of the member functions
+//. present in the ANSI {\tt string} are not present in {\tt DwString}:
+//. mostly these are the functions that deal with iterators. {\tt DwString}
+//. also includes some member functions and class utility functions that
+//. are not a part of the ANSI {\tt string} class. These non-ANSI
+//. functions are easy to distinguish: they all begin with upper-case
+//. letters, and all ANSI functions begin with lower-case letters. The
+//. library classes themselves use only the ANSI {\tt string} functions.
+//. At some point in the future, MIME++ will probably allow the option to
+//. substitute the ANSI {\tt string} class for {\tt DwString}.
+//.
+//. {\tt DwString} makes extensive use of copy-on-write, even when extracting
+//. substrings. It is this feature that distiguishes {\tt DwString} from most
+//. other string classes. {\tt DwString} also handles binary data, which can
+//. contain embedded NUL characters.
+//=============================================================================
+//+ Noentry _copy _replace Length AsCharBuf Substring Prefix Suffix Prepend
+//+ Noentry Append Insert Replace Delete mRep mStart mLength sEmptyString
+//+ Noentry ~DwString
+
+
+class DW_EXPORT DwString {
+
+public:
+
+ static const size_t npos;
+ //. {\tt npos} is assigned the value (size_t)-1.
+
+ DwString();
+ DwString(const DwString& aStr, size_t aPos=0, size_t aLen=npos);
+ DwString(const char* aBuf, size_t aLen);
+ DwString(FILE* aFile , size_t aLen);
+ DwString(const char* aCstr);
+ DwString(size_t aLen, char aChar);
+ DwString(char* aBuf, size_t aSize, size_t aStart, size_t aLen);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwString} object's contents to be empty.
+ //.
+ //. The second constructor is the copy constructor, which copies at most
+ //. {\tt aLen} characters beginning at position
+ //. {\tt aPos} from {\tt aStr} to the new {\tt DwString} object. It will
+ //. not copy more characters than what are available in {\tt aStr}.
+ //. {\tt aPos} must be less than or equal to {\tt aStr.size()}.
+ //.
+ //. The third constructor copies {\tt aLen} characters from the buffer
+ //. {\tt aBuf} into the new {\tt DwString} object. {\tt aBuf} need not be
+ //. NUL-terminated and may contain NUL characters.
+ //.
+ //. The fourth constructor copies the contents of the NUL-terminated string
+ //. {\tt aCstr} into the new {\tt DwString} object.
+ //.
+ //. The fifth constructor sets the contents of the new {\tt DwString}
+ //. object to be the character {\tt aChar} repeated {\tt aLen} times.
+ //.
+ //. The sixth constructor is an {\it advanced} constructor that sets
+ //. the contents of the new {\tt DwString} object to the {\tt aLen}
+ //. characters starting at offset {\tt aStart} in the buffer {\tt aBuf}.
+ //. {\tt aSize} is the allocated size of {\tt aBuf}.
+ //. This constructor is provided for efficiency in setting a new
+ //. {\tt DwString}'s contents from a large buffer. It is efficient
+ //. because no copying takes place. Instead, {\tt aBuf} becomes the
+ //. buffer used internally by the {\tt DwString} object, which
+ //. takes responsibility for deleting the buffer.
+ //. Because {\tt DwString} will free the buffer using {\tt delete []},
+ //. the buffer should have been allocated using {\tt new}.
+ //. See also: TakeBuffer(), and ReleaseBuffer().
+
+ virtual ~DwString();
+
+ DwString& operator = (const DwString& aStr);
+ DwString& operator = (const char* aCstr);
+ DwString& operator = (char aChar);
+ //. Assigns the contents of the operand to this string.
+ //. {\tt aCstr} must point to a NUL-terminated array of characters
+ //. (a C string).
+ //. Returns {\tt *this}.
+
+ size_t size() const;
+ //. Returns the number of characters in this string's contents. This
+ //. member function is identical to {\tt length()}
+
+ size_t length() const;
+ //. Returns the number of characters in this string's contents. This
+ //. member function is identical to {\tt size()}
+
+ size_t max_size() const;
+ //. Returns the maximum length that this string can ever attain.
+
+ void resize(size_t aLen, char aChar);
+ void resize(size_t aLen);
+ //. Changes the length of this string. If the string shortened, the final
+ //. characters are truncated. If the string is expanded, the added
+ //. characters will be NULs or the character specified by {\tt aChar}.
+
+ size_t capacity() const;
+ //. Returns the size of the internal buffer used for this string, which
+ //. will always be greater than or equal to the length of the string.
+
+ void reserve(size_t aSize);
+ //. If {\tt aSize} is greater than the current capacity of this string,
+ //. this member function will increase the capacity to be at least
+ //. {\tt aSize}.
+
+ void clear();
+ //. Sets this string's contents to be empty.
+
+ DwBool empty() const;
+ //. Returns a true value if and only if the contents of this string
+ //. are empty.
+
+ const char& operator [] (size_t aPos) const;
+ char& operator [] (size_t aPos);
+ //. Returns {\tt DwString::at(aPos) const} or {\tt DwString::at(aPos)}.
+ //. Note that the non-const version always assumes that the contents
+ //. will be modified and therefore always copies a shared internal
+ //. buffer before it returns.
+
+ const char& at(size_t aPos) const;
+ char& at(size_t aPos);
+ //. Returns the character at position {\tt aPos} in the string's contents.
+ //. The non-const version returns an lvalue that may be assigned to.
+ //. Note that the non-const version always assumes that the contents
+ //. will be modified and therefore always copies a shared internal
+ //. buffer before it returns.
+
+ DwString& operator += (const DwString& aStr);
+ DwString& operator += (const char* aCstr);
+ DwString& operator += (char aChar);
+ //. Appends the contents of the operand to this string.
+ //. {\tt aCstr} must point to a NUL-terminated array of characters
+ //. (a C string).
+ //. Returns {\tt *this}.
+
+ DwString& append(const DwString& aStr);
+ DwString& append(const DwString& aStr, size_t aPos, size_t aLen);
+ DwString& append(const char* aBuf, size_t aLen);
+ DwString& append(const char* aCstr);
+ DwString& append(size_t aLen, char aChar);
+ //. Appends characters to (the end of) this string.
+ //. Returns {\tt *this}.
+ //.
+ //. The first version appends all of the characters from {\tt aStr}.
+ //.
+ //. The second version appends at most {\tt aLen} characters from
+ //. {\tt aStr} beginning at position {\tt aPos}. {\tt aPos} must be
+ //. less than or equal to {\tt aStr.size()}. The function will not
+ //. append more characters than what are available in {\tt aStr}.
+ //.
+ //. The third version appends {\tt aLen} characters from {\tt aBuf},
+ //. which is not assumed to be NUL-terminated and can contain embedded
+ //. NULs.
+ //.
+ //. The fourth version appends characters from the NUL-terminated
+ //. string {\tt aCstr}.
+ //.
+ //. The fifth version appends {\tt aChar} repeated {\tt aLen} times.
+
+ DwString& assign(const DwString& aStr);
+ DwString& assign(const DwString& aStr, size_t aPos, size_t aLen);
+ DwString& assign(const char* aBuf, size_t aLen);
+ DwString& assign(const char* aCstr);
+ DwString& assign(size_t aLen, char aChar);
+ //. Assigns characters to this string.
+ //. Returns {\tt *this}.
+ //.
+ //. The first version assigns all of the characters from {\tt aStr}.
+ //.
+ //. The second version assigns at most {\tt aLen} characters from
+ //. {\tt aStr} beginning at position {\tt aPos}. {\tt aPos} must be
+ //. less than or equal to {\tt aStr.size()}. The function will not
+ //. assign more characters than what are available in {\tt aStr}.
+ //.
+ //. The third version assigns {\tt aLen} characters from {\tt aBuf},
+ //. which is not assumed to be NUL-terminated and can contain embedded
+ //. NULs.
+ //.
+ //. The fourth version assigns characters from the NUL-terminated
+ //. string {\tt aCstr}.
+ //.
+ //. The fifth version assigns {\tt aChar} repeated {\tt aLen} times.
+
+ DwString& insert(size_t aPos1, const DwString& aStr);
+ DwString& insert(size_t aPos1, const DwString& aStr, size_t aPos2,
+ size_t aLen2);
+ DwString& insert(size_t aPos1, const char* aBuf, size_t aLen2);
+ DwString& insert(size_t aPos1, const char* aCstr);
+ DwString& insert(size_t aPos1, size_t aLen2, char aChar);
+ //. Inserts characters into this string beginning at position {\tt aPos1}.
+ //. Returns {\tt *this}.
+ //.
+ //. The first version inserts all of the characters from {\tt aStr}.
+ //.
+ //. The second version inserts at most {\tt aLen2} characters from
+ //. {\tt aStr} beginning at position {\tt aPos2}. {\tt aPos1} must be
+ //. less than or equal to {\tt aStr.size()}. The function will not
+ //. assign more characters than what are available in {\tt aStr}.
+ //.
+ //. The third version inserts {\tt aLen2} characters from {\tt aBuf},
+ //. which is not assumed to be NUL-terminated and can contain embedded
+ //. NULs.
+ //.
+ //. The fourth version inserts characters from the NUL-terminated
+ //. string {\tt aCstr}.
+ //.
+ //. The fifth version inserts {\tt aChar} repeated {\tt aLen2} times.
+
+ DwString& erase(size_t aPos=0, size_t aLen=npos);
+ //. Erases (removes) at most {\tt aLen} characters beginning at position
+ //. {\tt aPos} from this string.
+ //. The function will not erase more characters than what are
+ //. available.
+ //. Returns {\tt *this}.
+
+ DwString& replace(size_t aPos1, size_t aLen1, const DwString& aStr);
+ DwString& replace(size_t aPos1, size_t aLen1, const DwString& aStr,
+ size_t aPos2, size_t aLen2);
+ DwString& replace(size_t aPos1, size_t aLen1, const char* aBuf,
+ size_t aLen2);
+ DwString& replace(size_t aPos1, size_t aLen1, const char* aCstr);
+ DwString& replace(size_t aPos1, size_t aLen1, size_t aLen2, char aChar);
+ //. Removes {\tt aLen1} characters beginning at position {\tt aPos1}
+ //. and inserts other characters.
+ //. Returns {\tt *this}.
+ //.
+ //. The first version inserts all of the characters from {\tt aStr}.
+ //.
+ //. The second version inserts at most {\tt aLen2} characters from
+ //. {\tt aStr} beginning at position {\tt aPos2}. {\tt aPos1} must be
+ //. less than or equal to {\tt aStr.size()}. The function will not
+ //. assign more characters than what are available in {\tt aStr}.
+ //.
+ //. The third version inserts {\tt aLen2} characters from {\tt aBuf},
+ //. which is not assumed to be NUL-terminated and can contain embedded
+ //. NULs.
+ //.
+ //. The fourth version inserts characters from the NUL-terminated
+ //. string {\tt aCstr}.
+ //.
+ //. The fifth version inserts {\tt aChar} repeated {\tt aLen2} times.
+
+ size_t copy(char* aBuf, size_t aLen, size_t aPos=0) const;
+ //. Copies at most {\tt aLen} characters beginning at position {\tt aPos}
+ //. from this string to the buffer pointed to by {\tt aBuf}.
+ //. Returns the number of characters copied.
+
+ void swap(DwString& aStr);
+ //. Swaps the contents of this string and {\tt aStr}.
+
+ const char* c_str() const;
+ const char* data() const;
+ //. These member functions permit access to the internal buffer used
+ //. by the {\tt DwString} object. {\tt c_str()} returns a NUL-terminated
+ //. string suitable for use in C library functions. {\tt data()}
+ //. returns a pointer to the internal buffer, which may not be
+ //. NUL-terminated.
+ //.
+ //. {\tt c_str()} may copy the internal buffer in order to place the
+ //. terminating NUL. This is not a violation of the const declaration:
+ //. it is a logical const, not a bit-representation const. It could
+ //. have the side effect of invalidating a pointer previously returned
+ //. by {\tt c_str()} or {\tt data()}.
+ //.
+ //. The characters in the returned string should not be modified, and
+ //. should be considered invalid after any call to a non-const member
+ //. function or another call to {\tt c_str()}.
+
+ size_t find(const DwString& aStr, size_t aPos=0) const;
+ size_t find(const char* aBuf, size_t aPos, size_t aLen) const;
+ size_t find(const char* aCstr, size_t aPos=0) const;
+ size_t find(char aChar, size_t aPos=0) const;
+ //. Performs a forward search for a sequence of characters in the
+ //. {\tt DwString} object. The return value is the position of the
+ //. sequence in the string if found, or {\tt DwString::npos} if not
+ //. found.
+ //.
+ //. The first version searches beginning at position {\tt aPos} for
+ //. the sequence of characters in {\tt aStr}.
+ //.
+ //. The second version searches beginning at position {\tt aPos} for
+ //. the sequence of {\tt aLen} characters in {\tt aBuf}, which need not
+ //. be NUL-terminated and can contain embedded NULs.
+ //.
+ //. The third version searches beginning at position {\tt aPos} for
+ //. the sequence of characters in the NUL-terminated string {\tt aCstr}.
+ //.
+ //. The fourth version searches beginning at position {\tt aPos} for
+ //. the character {\tt aChar}.
+
+ size_t rfind(const DwString& aStr, size_t aPos=npos) const;
+ size_t rfind(const char* aBuf, size_t aPos, size_t aLen) const;
+ size_t rfind(const char* aCstr, size_t aPos=npos) const;
+ size_t rfind(char aChar, size_t aPos=npos) const;
+ //. Performs a reverse search for a sequence of characters in the
+ //. {\tt DwString} object. The return value is the position of the
+ //. sequence in the string if found, or {\tt DwString::npos} if not
+ //. found.
+ //.
+ //. The first version searches beginning at position {\tt aPos} for
+ //. the sequence of characters in {\tt aStr}.
+ //.
+ //. The second version searches beginning at position {\tt aPos} for
+ //. the sequence of {\tt aLen} characters in {\tt aBuf}, which need not
+ //. be NUL-terminated and can contain embedded NULs.
+ //.
+ //. The third version searches beginning at position {\tt aPos} for
+ //. the sequence of characters in the NUL-terminated string {\tt aCstr}.
+ //.
+ //. The fourth version searches beginning at position {\tt aPos} for
+ //. the character {\tt aChar}.
+
+ size_t find_first_of(const DwString& aStr, size_t aPos=0) const;
+ size_t find_first_of(const char* aBuf, size_t aPos, size_t aLen) const;
+ size_t find_first_of(const char* aCstr, size_t aPos=0) const;
+ //. Performs a forward search beginning at position {\tt aPos} for
+ //. the first occurrence of any character from a specified set of
+ //. characters. The return value is the position of the character
+ //. if found, or {\tt DwString::npos} if not found.
+ //.
+ //. The first version searches for any character in the string {\tt aStr}.
+ //.
+ //. The second version searches for any of the {\tt aLen} characters in
+ //. {\tt aBuf}.
+ //.
+ //. The third version searches for any character in the NUL-terminated
+ //. string {\tt aCstr}.
+
+ size_t find_last_of(const DwString& aStr, size_t aPos=npos) const;
+ size_t find_last_of(const char* aBuf, size_t aPos, size_t aLen) const;
+ size_t find_last_of(const char* aCstr, size_t aPos=npos) const;
+ //. Performs a reverse search beginning at position {\tt aPos} for
+ //. the first occurrence of any character from a specified set of
+ //. characters. If {\tt aPos} is greater than or equal to the number
+ //. of characters in the string, then the search starts at the end
+ //. of the string. The return value is the position of the character
+ //. if found, or {\tt DwString::npos} if not found.
+ //.
+ //. The first version searches for any character in the string {\tt aStr}.
+ //.
+ //. The second version searches for any of the {\tt aLen} characters in
+ //. {\tt aBuf}.
+ //.
+ //. The third version searches for any character in the NUL-terminated
+ //. string {\tt aCstr}.
+
+ size_t find_first_not_of(const DwString& aStr, size_t aPos=0) const;
+ size_t find_first_not_of(const char* aBuf, size_t aPos, size_t aLen) const;
+ size_t find_first_not_of(const char* aCstr, size_t aPos=0) const;
+ //. Performs a forward search beginning at position {\tt aPos} for
+ //. the first occurrence of any character {\it not} in a specified set
+ //. of characters. The return value is the position of the character
+ //. if found, or {\tt DwString::npos} if not found.
+ //.
+ //. The first version searches for any character not in the string
+ //. {\tt aStr}.
+ //.
+ //. The second version searches for any character not among the
+ //. {\tt aLen} characters in {\tt aBuf}.
+ //.
+ //. The third version searches for any character not in the NUL-terminated
+ //. string {\tt aCstr}.
+
+ size_t find_last_not_of(const DwString& aStr, size_t aPos=npos) const;
+ size_t find_last_not_of(const char* aBuf, size_t aPos, size_t aLen) const;
+ size_t find_last_not_of(const char* aCstr, size_t aPos=npos) const;
+ //. Performs a reverse search beginning at position {\tt aPos} for
+ //. the first occurrence of any character {\it not} in a specified set
+ //. of characters. If {\tt aPos} is greater than or equal to the number
+ //. of characters in the string, then the search starts at the end
+ //. of the string. The return value is the position of the character
+ //. if found, or {\tt DwString::npos} if not found.
+ //.
+ //. The first version searches for any character not in the string
+ //. {\tt aStr}.
+ //.
+ //. The second version searches for any character not among the
+ //. {\tt aLen} characters in {\tt aBuf}.
+ //.
+ //. The third version searches for any character not in the NUL-terminated
+ //. string {\tt aCstr}.
+
+ DwString substr(size_t aPos=0, size_t aLen=npos) const;
+ //. Returns a string that contains at most {\tt aLen} characters from
+ //. the {\tt DwString} object beginning at position {\tt aPos}. The
+ //. returned substring will not contain more characters than what are
+ //. available in the superstring {\tt DwString} object.
+
+ int compare(const DwString& aStr) const;
+ int compare(size_t aPos1, size_t aLen1, const DwString& aStr) const;
+ int compare(size_t aPos1, size_t aLen1, const DwString& aStr,
+ size_t aPos2, size_t aLen2) const;
+ int compare(const char* aCstr) const;
+ int compare(size_t aPos1, size_t aLen1, const char* aBuf,
+ size_t aLen2=npos) const;
+ //. These member functions compare a sequence of characters to this
+ //. {\tt DwString} object, or a segment of this {\tt DwString} object.
+ //. They return -1, 0, or 1, depending on whether this {\tt DwString}
+ //. object is less than, equal to, or greater than the compared sequence
+ //. of characters, respectively.
+ //.
+ //. The first version compares {\tt aStr} to this string.
+ //.
+ //. The second version compares {\tt aStr} with the {\tt aLen1} characters
+ //. beginning at position {\tt aPos1} in this {\tt DwString} object.
+ //.
+ //. The third version compares the {tt aLen2} characters beginning at
+ //. position {\tt aPos2} in {\tt aStr} with the {\tt aLen1} characters
+ //. beginning at position {\tt aPos1} in this {\tt DwString} object.
+ //.
+ //. The fourth version compares the NUL-terminated string {\tt aCstr}
+ //. to this {\tt DwString}.
+ //.
+ //. The fifth version compares the {\tt aLen2} characters in {\tt aBuf}
+ //. with the {\tt aLen1} characters beginning at position {\tt aPos1} in
+ //. this {\tt DwString} object.
+
+ // Non-ANSI member functions
+
+ virtual const char* ClassName() const;
+ //. This virtual function returns the name of the class as a NUL-terminated
+ //. char string.
+
+ int ObjectId() const;
+ //. Returns the unique object id for this {\tt DwString}.
+
+ void ConvertToLowerCase();
+ void ConvertToUpperCase();
+ //. Converts this {\tt DwString} object's characters to all lower case or
+ //. all upper case.
+
+ void Trim();
+ //. Removes all white space from the beginning and the end of this
+ //. {\tt DwString} object. White space characters include ASCII HT,
+ //. LF, and SPACE.
+
+ void WriteTo(std::ostream& aStrm) const;
+ //. Writes the contents of this {\tt DwString} object to the stream
+ //. {\tt aStrm}.
+
+ int RefCount() const;
+ //. This {\it advanced} member function returns the number of
+ //. references to the internal buffer used by the {\tt DwString} object.
+
+ void TakeBuffer(char* aBuf, size_t aSize, size_t aStart, size_t aLen);
+ //. This {\it advanced} member function sets the contents of the
+ //. {\tt DwString} object to the {\tt aLen} characters starting at
+ //. offset {\tt aStart} in the buffer {\tt aBuf}. {\tt aSize} is
+ //. the allocated size of {\tt aBuf}.
+ //. This member function is provided for efficiency in setting a
+ //. {\tt DwString}'s contents from a large buffer. It is efficient
+ //. because no copying takes place. Instead, {\tt aBuf} becomes the
+ //. buffer used internally by the {\tt DwString} object, which
+ //. takes responsibility for deleting the buffer.
+ //. Because DwString will free the buffer using {\tt delete []}, the
+ //. buffer should have been allocated using {\tt new}.
+ //. See also: ReleaseBuffer().
+
+ void ReleaseBuffer(char** aBuf, size_t* aSize, size_t* aStart, size_t* aLen);
+ //. This {\it advanced} member function is the symmetric opposite of
+ //. {\tt TakeBuffer()}, to the extent that such an opposite is possible.
+ //. It provides a way to ``export'' the buffer used internally by the
+ //. {\tt DwString} object.
+ //. Note, however, that because of the copy-on-modify feature of
+ //. {\tt DwString}, the {\tt DwString} object may not have sole
+ //. ownership of its internal buffer. When that is case,
+ //. {\tt ReleaseBuffer()} will return a copy of the buffer. You can check
+ //. to see if the internal buffer is shared by calling {\tt RefCount()}.
+ //. On return from this member function, the {\tt DwString} object will
+ //. have valid, but empty, contents.
+ //. It is recommended that you use this function only on rare occasions
+ //. where you need to export efficiently a large buffer.
+
+ void CopyTo(DwString* aStr) const;
+ //. This {\it advanced} member function copies this {\tt DwString}
+ //. object to {\tt aStr}. This member
+ //. function is different from the assignment operator, because it
+ //. physically copies the buffer instead of just duplicating a reference
+ //. to it.
+
+protected:
+
+ DwStringRep* mRep;
+ size_t mStart;
+ size_t mLength;
+
+ void _copy();
+ void _replace(size_t aPos1, size_t aLen1, const char* aBuf, size_t aLen2);
+ void _replace(size_t aPos1, size_t aLen1, size_t aLen2, char aChar);
+
+private:
+ static const size_t kEmptyBufferSize;
+ static char sEmptyBuffer[];
+ static DwStringRep* sEmptyRep;
+ friend void mem_free(char*);
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm) const;
+ //. Prints debugging information about the object to {\tt aStrm}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+};
+
+
+//---------------------------------------------------------------------------
+// inline functions
+//---------------------------------------------------------------------------
+
+inline size_t DwString::size() const
+{
+ return mLength;
+}
+
+inline size_t DwString::length() const
+{
+ return mLength;
+}
+
+inline size_t DwString::capacity() const
+{
+ return mRep->mSize - 1;
+}
+
+inline DwBool DwString::empty() const
+{
+ return mLength == 0;
+}
+
+inline int DwString::RefCount() const
+{
+ return mRep->mRefCount;
+}
+
+inline const char* DwString::c_str() const
+{
+ if (mRep->mRefCount > 1 && mRep != sEmptyRep) {
+ DwString* xthis = (DwString*) this;
+ xthis->_copy();
+ }
+ return &mRep->mBuffer[mStart];
+}
+
+inline const char* DwString::data() const
+{
+ return &mRep->mBuffer[mStart];
+}
+
+// Returning const char& instead of char will allow us to use DwString::at()
+// in the following way:
+// if (&s.at(1) == ' ') { /* ... */ }
+inline const char& DwString::at(size_t aPos) const
+{
+ assert(aPos <= mLength);
+ if (aPos < mLength) {
+ return data()[aPos];
+ }
+ else if (aPos == mLength) {
+ return sEmptyRep->mBuffer[0];
+ }
+ else {
+ // This "undefined behavior"
+ // Normally, this will not occur. The assert() macro will catch it,
+ // or at some point we may throw an exception.
+ return data()[0];
+ }
+}
+
+inline char& DwString::at(size_t aPos)
+{
+ assert(aPos < mLength);
+ if (aPos < mLength) {
+ return (char&) c_str()[aPos];
+ }
+ else {
+ // This is "undefined behavior"
+ assert(0);
+ return (char&) c_str()[0];
+ }
+}
+
+// Returning const char& instead of char will allow us to use operator[]
+// in the following way:
+// if (&s[1] == ' ') { /* ... */ }
+inline const char& DwString::operator [] (size_t aPos) const
+{
+ return at(aPos);
+}
+
+inline char& DwString::operator [] (size_t aPos)
+{
+ return at(aPos);
+}
+
+inline DwString& DwString::operator = (const DwString& aStr)
+{
+ return assign(aStr);
+}
+
+inline DwString& DwString::operator = (const char* aCstr)
+{
+ return assign(aCstr);
+}
+
+inline DwString& DwString::operator = (char aChar)
+{
+ return assign(1, aChar);
+}
+
+inline DwString& DwString::operator += (const DwString& aStr)
+{
+ return append(aStr);
+}
+
+inline DwString& DwString::operator += (const char* aCstr)
+{
+ return append(aCstr);
+}
+
+inline DwString& DwString::operator += (char aChar)
+{
+ return append(1, aChar);
+}
+
+#endif // ! defined(DW_USE_ANSI_STRING)
+
+DW_EXPORT DwString operator + (const DwString& aStr1, const DwString& aStr2);
+DW_EXPORT DwString operator + (const char* aCstr, const DwString& aStr2);
+DW_EXPORT DwString operator + (char aChar, const DwString& aStr2);
+DW_EXPORT DwString operator + (const DwString& aStr1, const char* aCstr);
+DW_EXPORT DwString operator + (const DwString& aStr1, char aChar);
+
+DW_EXPORT DwBool operator == (const DwString& aStr1, const DwString& aStr2);
+DW_EXPORT DwBool operator == (const DwString& aStr1, const char* aCstr);
+DW_EXPORT DwBool operator == (const char* aCstr, const DwString& aStr2);
+
+DW_EXPORT DwBool operator != (const DwString& aStr1, const DwString& aStr2);
+DW_EXPORT DwBool operator != (const DwString& aStr1, const char* aCstr);
+DW_EXPORT DwBool operator != (const char* aCstr, const DwString& aStr2);
+
+DW_EXPORT DwBool operator < (const DwString& aStr1, const DwString& aStr2);
+DW_EXPORT DwBool operator < (const DwString& aStr1, const char* aCstr);
+DW_EXPORT DwBool operator < (const char* aCstr, const DwString& aStr2);
+
+DW_EXPORT DwBool operator > (const DwString& aStr1, const DwString& aStr2);
+DW_EXPORT DwBool operator > (const DwString& aStr1, const char* aCstr);
+DW_EXPORT DwBool operator > (const char* aCstr, const DwString& aStr2);
+
+DW_EXPORT DwBool operator <= (const DwString& aStr1, const DwString& aStr2);
+DW_EXPORT DwBool operator <= (const DwString& aStr1, const char* aCstr);
+DW_EXPORT DwBool operator <= (const char* aCstr, const DwString& aStr2);
+
+DW_EXPORT DwBool operator >= (const DwString& aStr1, const DwString& aStr2);
+DW_EXPORT DwBool operator >= (const DwString& aStr1, const char* aCstr);
+DW_EXPORT DwBool operator >= (const char* aCstr, const DwString& aStr2);
+
+DW_EXPORT std::ostream& operator << (std::ostream& aOstrm, const DwString& aStr);
+//. Writes the contents of {\tt aStr} to the stream {\tt aOstrm}.
+
+DW_EXPORT std::istream& getline (std::istream& aIstrm, DwString& aStr, char aDelim);
+DW_EXPORT std::istream& getline (std::istream& aIstrm, DwString& aStr);
+
+DW_EXPORT int DwStrcasecmp(const DwString& aStr1, const DwString& aStr2);
+DW_EXPORT int DwStrcasecmp(const DwString& aStr1, const char* aCstr);
+DW_EXPORT int DwStrcasecmp(const char* aCstr, const DwString& aStr2);
+
+DW_EXPORT int DwStrncasecmp(const DwString& aStr1, const DwString& aStr2,
+ size_t aLen);
+DW_EXPORT int DwStrncasecmp(const DwString& aStr, const char* aCstr, size_t aLen);
+DW_EXPORT int DwStrncasecmp(const char* aCstr, const DwString& aStr, size_t aLen);
+
+DW_EXPORT int DwStrcmp(const DwString& aStr1, const DwString& aStr2);
+DW_EXPORT int DwStrcmp(const DwString& aStr, const char* aCstr);
+DW_EXPORT int DwStrcmp(const char* aCstr, const DwString& aStr);
+
+DW_EXPORT int DwStrncmp(const DwString& aStr1, const DwString& aStr2, size_t aLen);
+DW_EXPORT int DwStrncmp(const DwString& aStr, const char* aCstr, size_t aLen);
+DW_EXPORT int DwStrncmp(const char* aCstr, const DwString& aStr, size_t aLen);
+
+DW_EXPORT void DwStrcpy(DwString& aStrDest, const DwString& aStrSrc);
+DW_EXPORT void DwStrcpy(DwString& aStrDest, const char* aCstrSrc);
+DW_EXPORT void DwStrcpy(char* aCstrDest, const DwString& aStrSrc);
+
+DW_EXPORT void DwStrncpy(DwString& aStrDest, const DwString& aStrSrc, size_t aLen);
+DW_EXPORT void DwStrncpy(DwString& aStrDest, const char* aCstrSrc, size_t aLen);
+DW_EXPORT void DwStrncpy(char* aCstrDest, const DwString& aStrSrc, size_t aLen);
+
+DW_EXPORT char* DwStrdup(const DwString& aStr);
+
+#endif
+
diff --git a/mimelib/mimelib/text.h b/mimelib/mimelib/text.h
new file mode 100644
index 00000000..89b908ad
--- /dev/null
+++ b/mimelib/mimelib/text.h
@@ -0,0 +1,151 @@
+//=============================================================================
+// File: text.h
+// Contents: Declarations for DwText
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_TEXT_H
+#define DW_TEXT_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+#ifndef DW_FIELDBDY_H
+#include <mimelib/fieldbdy.h>
+#endif
+
+//=============================================================================
+//+ Name DwText -- Class representing text in a RFC-822 header field-body
+//+ Description
+//. {\tt DwText} represents an unstructured field body in a header field.
+//. It roughly corresponds to the {\it text} element of the BNF grammar
+//. defined in RFC-822.
+//=============================================================================
+// Last modified 1997-07-30
+//+ Noentry ~DwText sClassName _PrintDebugInfo
+
+
+class DW_EXPORT DwText : public DwFieldBody {
+
+public:
+
+ DwText();
+ DwText(const DwText& aText);
+ DwText(const DwString& aStr, DwMessageComponent* aParent=0);
+ //. The first constructor is the default constructor, which sets the
+ //. {\tt DwText} object's string representation to the empty string
+ //. and sets its parent to NULL.
+ //.
+ //. The second constructor is the copy constructor, which copies the
+ //. string representation from {\tt aText}.
+ //. The parent of the new {\tt DwText} object is set to NULL.
+ //.
+ //. The third constructor copies {\tt aStr} to the {\tt DwText}
+ //. object's string representation and sets {\tt aParent} as its parent.
+ //. The virtual member function {\tt Parse()} should be called immediately
+ //. after this constructor in order to parse the string representation.
+ //. Unless it is NULL, {\tt aParent} should point to an object of a class
+ //. derived from {\tt DwField}.
+
+ virtual ~DwText();
+
+ const DwText& operator = (const DwText& aText);
+ //. This is the assignment operator.
+
+ virtual void Parse();
+ //. This virtual member function is inherited from
+ //. {\tt DwMessageComponent}, where it is declared a pure virtual
+ //. function. For a {\tt DwText} object, this member function does
+ //. nothing, since {\tt DwText} represents an unstructured field body
+ //. (like the Subject header field) that does not have a broken-down
+ //. form.
+ //.
+ //. Note, however, that this function should still be called consistently,
+ //. since a subclass of {\tt DwText} may implement a parse method.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual void Assemble();
+ //. This virtual member function is inherited from
+ //. {\tt DwMessageComponent}, where it is declared a pure virtual
+ //. function. For a {\tt DwText} object, this member function does
+ //. nothing, since {\tt DwText} represents an unstructured field body
+ //. (like the Subject header field) that does not have a broken-down
+ //. form.
+ //.
+ //. Note, however, that this function should still be called consistently,
+ //. since a subclass of {\tt DwText} may implement an assemble method.
+ //.
+ //. This function clears the is-modified flag.
+
+ virtual DwMessageComponent* Clone() const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. creates a new {\tt DwText} on the free store that has the same
+ //. value as this {\tt DwText} object. The basic idea is that of
+ //. a ``virtual copy constructor.''
+
+ static DwText* NewText(const DwString& aStr, DwMessageComponent* aParent);
+ //. Creates a new {\tt DwText} object on the free store.
+ //. If the static data member {\tt sNewText} is NULL,
+ //. this member function will create a new {\tt DwText}
+ //. and return it. Otherwise, {\tt NewText()} will call
+ //. the user-supplied function pointed to by {\tt sNewText},
+ //. which is assumed to return an object from a class derived from
+ //. {\tt DwText}, and return that object.
+
+ //+ Var sNewText
+ static DwText* (*sNewText)(const DwString&, DwMessageComponent*);
+ //. If {\tt sNewText} is not NULL, it is assumed to point to a
+ //. user-supplied function that returns an object from a class derived from
+ //. {\tt DwText}.
+
+private:
+
+ static const char* const sClassName;
+
+public:
+
+ virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
+ //. This virtual function, inherited from {\tt DwMessageComponent},
+ //. prints debugging information about this object to {\tt aStrm}.
+ //. It will also call {\tt PrintDebugInfo()} for any of its child
+ //. components down to a level of {\tt aDepth}.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+ virtual void CheckInvariants() const;
+ //. Aborts if one of the invariants of the object fails. Use this
+ //. member function to track down bugs.
+ //.
+ //. This member function is available only in the debug version of
+ //. the library.
+
+protected:
+
+ void _PrintDebugInfo(std::ostream& aStrm) const;
+
+};
+
+#endif
diff --git a/mimelib/mimelib/token.h b/mimelib/mimelib/token.h
new file mode 100644
index 00000000..7168ea09
--- /dev/null
+++ b/mimelib/mimelib/token.h
@@ -0,0 +1,150 @@
+//=============================================================================
+// File: token.h
+// Contents: Declarations for DwTokenizer, DwRfc822Tokenizer
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_TOKEN_H
+#define DW_TOKEN_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+// RFC 822 and RFC 1521 define slightly different grammars for the field
+// bodies they define. The differences are that RFC 822 defines a basic
+// type 'atom' while RFC 1521 defines a basic type 'token', and RFC 822
+// defines a character class 'special' while RFC 1521 defines a character
+// class 'tspecial'. For this reason, we have two tokenizer classes:
+// Rfc822Tokenizer and Rfc1521Tokenizer. Since the basic types
+// quoted string, comment, and domain literal are common to both RFC 822
+// and RFC 1521, the common code of both tokenizer classes is
+// combined into a Tokenizer base class. The Tokenizer class has no public
+// constructors, since only objects of class Rfc822Tokenizer or
+// Rfc1521Tokenizer will ever be instantiated.
+//
+// Note that we do not use polymorphism here: Tokenizer has no virtual
+// functions. We do this for efficiency, since there is some overhead
+// involved with virtual functions. If the classes were more complicated
+// than they currently are, then virtual functions would be justified in
+// order to reduce the duplication of code. As it stands, though, the
+// classes are fairly simple and efficient.
+// In addition, polymorphism is not needed to use the tokenizer classes.
+
+#if !(defined(__DECCXX) && defined(__linux__))
+#include <iosfwd>
+#endif
+
+enum {
+ eTkError=-1,
+ eTkNull=0,
+ eTkSpecial,
+ eTkAtom,
+ eTkComment,
+ eTkQuotedString,
+ eTkDomainLiteral,
+ eTkTspecial,
+ eTkToken
+};
+
+
+class DW_EXPORT DwTokenizer {
+ friend class DwTokenString;
+public:
+ const DwString& Token() const { return mToken; }
+ int Type() const { return mTkType; }
+ void StripDelimiters();
+ static std::ostream* mDebugOut;
+protected:
+ DwTokenizer(const DwString& aStr);
+ DwTokenizer(const char* aCStr);
+ virtual ~DwTokenizer();
+ void PrintToken(std::ostream*);
+ // Quoted strings, comments, and domain literals are parsed
+ // identically in RFC822 and RFC1521
+ void ParseQuotedString();
+ void ParseComment();
+ void ParseDomainLiteral();
+ // Data members
+ const DwString mString;
+ DwString mToken;
+ size_t mTokenStart;
+ size_t mTokenLength;
+ size_t mNextStart;
+ int mTkType;
+};
+
+
+class DW_EXPORT DwRfc822Tokenizer : public DwTokenizer {
+ friend class DwAddressParser;
+public:
+ DwRfc822Tokenizer(const DwString& aStr);
+ DwRfc822Tokenizer(const char* aCStr);
+ virtual ~DwRfc822Tokenizer();
+ int Restart();
+ int operator ++ (); // prefix increment operator
+private:
+ DwRfc822Tokenizer();
+ DwRfc822Tokenizer(const DwRfc822Tokenizer&);
+ void ParseToken();
+ void ParseAtom();
+};
+
+
+class DW_EXPORT DwRfc1521Tokenizer : public DwTokenizer {
+public:
+ DwRfc1521Tokenizer(const DwString& aStr);
+ DwRfc1521Tokenizer(const char* aCStr);
+ virtual ~DwRfc1521Tokenizer();
+ int Restart();
+ int operator ++ (); // prefix increment operator
+private:
+ DwRfc1521Tokenizer();
+ DwRfc1521Tokenizer(const DwRfc1521Tokenizer&);
+ void ParseToken();
+ void ParseAtom();
+};
+
+
+// DwTokenString allows us to build a DwString of tokens by concatenating
+// them. This is not the normal string concatenation: the tokens are
+// assumed to have the same string rep, and the concatenated string shares
+// the rep.
+
+class DW_EXPORT DwTokenString {
+public:
+ DwTokenString(const DwString&);
+ virtual ~DwTokenString();
+ const DwString& Tokens() const { return mTokens; }
+ void SetFirst(const DwTokenizer&);
+ void SetLast(const DwTokenizer&);
+ void ExtendTo(const DwTokenizer&);
+ // void Concatenate(const DwTokenizer&);
+protected:
+ const DwString mString;
+ DwString mTokens;
+ size_t mTokensStart;
+ size_t mTokensLength;
+};
+
+#endif
diff --git a/mimelib/mimelib/utility.h b/mimelib/mimelib/utility.h
new file mode 100644
index 00000000..8cda35ea
--- /dev/null
+++ b/mimelib/mimelib/utility.h
@@ -0,0 +1,50 @@
+//=============================================================================
+// File: utility.h
+// Contents: Declarations of utility functions for MIME++
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_UTILITY_H
+#define DW_UTILITY_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+class DwString;
+
+
+void DW_EXPORT DwInitialize();
+void DW_EXPORT DwFinalize();
+int DW_EXPORT DwCteStrToEnum(const DwString& aStr);
+void DW_EXPORT DwCteEnumToStr(int aEnum, DwString& aStr);
+int DW_EXPORT DwTypeStrToEnum(const DwString& aStr);
+void DW_EXPORT DwTypeEnumToStr(int aEnum, DwString& aStr);
+int DW_EXPORT DwSubtypeStrToEnum(const DwString& aStr);
+void DW_EXPORT DwSubtypeEnumToStr(int aEnum, DwString& aStr);
+int DW_EXPORT DwToCrLfEol(const DwString& aSrcStr, DwString& aDestStr);
+int DW_EXPORT DwToLfEol(const DwString& aSrcStr, DwString& aDestStr);
+int DW_EXPORT DwToCrEol(const DwString& aSrcStr, DwString& aDestStr);
+int DW_EXPORT DwToLocalEol(const DwString& aSrcStr, DwString& aDestStr);
+int DW_EXPORT DwEncodeBase64(const DwString& aSrcStr, DwString& aDestStr);
+int DW_EXPORT DwDecodeBase64(const DwString& aSrcStr, DwString& aDestStr);
+int DW_EXPORT DwEncodeQuotedPrintable(const DwString& aSrcStr, DwString& aDestStr);
+int DW_EXPORT DwDecodeQuotedPrintable(const DwString& aSrcStr, DwString& aDestStr);
+
+#endif
diff --git a/mimelib/mimelib/uuencode.h b/mimelib/mimelib/uuencode.h
new file mode 100644
index 00000000..c87efbda
--- /dev/null
+++ b/mimelib/mimelib/uuencode.h
@@ -0,0 +1,122 @@
+//=============================================================================
+// File: uuencode.h
+// Contents: Declarations for DwUuencode
+// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
+// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
+//
+// Copyright (c) 1996, 1997 Douglas W. Sauder
+// All rights reserved.
+//
+// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
+// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
+// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
+// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+// PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+//
+//=============================================================================
+
+#ifndef DW_UUENCODE_H
+#define DW_UUENCODE_H
+
+#ifndef DW_CONFIG_H
+#include <mimelib/config.h>
+#endif
+
+#ifndef DW_STRING_H
+#include <mimelib/string.h>
+#endif
+
+//=============================================================================
+//+ Name DwUuencode -- Class for performing uuencode or uudecode operations
+//+ Description
+//. {\tt DwUuencode} performs uuencode or uudecode operations. Uuencode
+//. is a format for encoding binary data into text characters for transmission
+//. through the mail system. The format also includes the file name and the
+//. file mode. (Note: The file mode is significant only in UNIX.) In MIME,
+//. the use of uuencode is deprecated; base64 is the preferred encoding
+//. for sending binary data.
+//.
+//. To use {\tt DwUuencode} for encoding binary data into uuencode format,
+//. set the file name, file mode, and binary data string using the member
+//. functions {\tt SetFileName()}, {\tt SetFileMode()}, and
+//. {\tt SetBinaryChars()}. Then call the member function {\tt Encode()}.
+//. Finally, retrieve the uuencoded text characters by calling
+//. {\tt AsciiChars()}.
+//.
+//. To use {\tt DwUuencode} to decode uuencoded data, set the ASCII characters
+//. using the member function {\tt SetAsciiChars()}, then call {\tt Decode()}.
+//. Finally, retrieve the file name, file mode, and binary characters by
+//. calling {\tt FileName()}, {\tt FileMode()}, and {\tt BinaryChars()}.
+//=============================================================================
+// Last modified 1997-07-29
+//+ Noentry ~DwUuencode mFileName mMode mBinaryChars mAsciiChars
+
+
+class DW_EXPORT DwUuencode {
+
+public:
+
+ DwUuencode();
+ //. This is the default constructor.
+
+ virtual ~DwUuencode();
+
+ void Initialize();
+ //. Resets the object's internal state to its initial state. Call
+ //. this member function to reuse the object for more than one encode
+ //. or decode operation.
+
+ void SetFileName(const char* aName);
+ //. Sets the file name to be included in the uuencoded output. The
+ //. implementation limits the file name to 255 characters.
+
+ const char* FileName() const;
+ //. Returns the file name extracted while uudecoding. The implementation
+ //. limits the file name to 255 characters.
+
+ void SetFileMode(DwUint16 aMode);
+ //. Sets the file mode to be included in the uuencoded output. If
+ //. the file mode is not explicitly set using this member function,
+ //. a default value of 0644 (octal) is assumed.
+
+ DwUint16 FileMode() const;
+ //. Returns the file mode extracted while uudecoding.
+
+ void SetBinaryChars(const DwString& aStr);
+ //. Sets the string of binary data to be used in the uuencode operation.
+
+ const DwString& BinaryChars() const;
+ //. Returns the string of binary data extracted during a uudecode
+ //. operation.
+
+ void SetAsciiChars(const DwString& aStr);
+ //. Sets the string of ASCII characters to used in the decode operation.
+
+ const DwString& AsciiChars() const;
+ //. Returns the string of ASCII characters created during a uuencode
+ //. operation.
+
+ void Encode();
+ //. Creates an ASCII string of characters by uuencoding the file name,
+ //. file mode, and binary data.
+
+ int Decode();
+ //. Extracts the file name, file mode, and binary data from the ASCII
+ //. characters via a uudecode operation.
+
+private:
+
+ char mFileName[256];
+ DwUint16 mMode;
+
+ DwString mBinaryChars;
+ DwString mAsciiChars;
+
+};
+
+#endif