Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

email.h

Go to the documentation of this file.
00001 
00013 /*
00014  * Copyright (c) 2001 James Hess
00015  * All rights reserved.
00016  *
00017  * Redistribution and use in source and binary forms, with or without
00018  * modification, are permitted provided that the following conditions
00019  * are met:
00020  * 1. Redistributions of source code must retain the above copyright
00021  *    notice, this list of conditions and the following disclaimer.
00022  * 2. Redistributions in binary form must reproduce the above copyright
00023  *    notice, this list of conditions and the following disclaimer in the
00024  *    documentation and/or other materials provided with the distribution.
00025  * 3. Neither the name of the authors nor the names of its contributors
00026  *    may be used to endorse or promote products derived from this software
00027  *    without specific prior written permission.
00028  *
00029  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
00030  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00031  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00032  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
00033  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00034  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00035  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00036  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00037  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00038  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00039  * SUCH DAMAGE.
00040  */
00041 
00042 class EmailString;
00043 class EmailAddressBuf;
00044 class EmailMessage;
00045 
00062 class EmailString
00063 {
00064     friend class EmailAddressBuf;
00065     friend int main();
00066 
00067     public:
00068     EmailString() : theLength(0), theString(NULL) {
00069     }
00070 
00071     ~EmailString() {
00072        if (theString)
00073            delete theString;
00074        return;
00075     }
00076 
00077     const char *add(const char *);
00078     const char *get_string() { 
00079         if ( theString ) 
00080             return theString;
00081         return "";
00082     }
00083     const char *set_string(const char *s);
00084     const char *set_string_ptr(char *s) {
00085           theLength = s ? strlen(s) : 0;
00086           return theString = s;  
00087     }
00088     int length() { return theLength; }
00089 
00090     const char *operator=(const char *buf) { return set_string(buf); };
00091     const char *operator+=(const char *buf) { return add(buf); };
00092 
00093     char &operator[](int i) {
00094          if (i<0||i>theLength) {
00095              abort();
00096              return ((char *)0x0)[0];
00097          }
00098          return theString[i];
00099     }
00100 
00101     operator char* () {
00102         return theString;
00103     }
00104 
00105     private:
00106     int theLength;
00107     char *theString;
00108 };
00109 
00123 class EmailAddressBuf : public EmailString
00124 {
00125     public:
00126         const char *add_email(const char *);    
00127         const char *operator=(const char *buf) { return set_string(buf); };
00128         const char *operator+=(const char *buf) { return add_email(buf); };
00129 };
00130 
00142 class EmailMessage
00143 {
00144     public:
00145 
00147     EmailAddressBuf  from;
00148 
00150     EmailAddressBuf  to;
00151 
00153     EmailString      subject;
00154 
00156     EmailString      body;
00157 
00161         void reset() {
00162              from = NULL;
00163          to = NULL;
00164          subject = NULL;
00165          body = NULL;
00166         }
00167 
00169     void send();
00170 };

Generated at Sat Oct 25 20:56:07 2003 for Services using Doxygen.
Services Copyr. 1996-2001 Chip Norkus, Max Byrd, Greg Poma, Michael Graff, James Hess, Dafydd James. All rights reserved See LICENSE for licensing information.