Logo
~Sockets~
~Examples~
~Contact~


FwdSocket.cpp

Go to the documentation of this file.
00001 // FwdSocket.cpp
00002 /*
00003 Copyright (C) 2004  Anders Hedstrom
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 */
00019 
00020 #ifdef _WIN32
00021 #pragma warning(disable:4786)
00022 #endif
00023 //#include <assert.h>
00024 //#include <stdio.h>
00025 #ifdef _WIN32
00026 #define strcasecmp stricmp
00027 #endif
00028 
00029 #include "socket_include.h"
00030 #include "ISocketHandler.h"
00031 #include "Parse.h"
00032 #include "SMTPSocket.h"
00033 #include "FwdSocket.h"
00034 
00035 /*
00036 #ifdef _DEBUG
00037 #define DEB(x) x
00038 #else
00039 #define DEB(x)
00040 #endif
00041 */
00042 /*
00043 #define DEB(x) { \
00044         FILE *fil = fopen("C:\\deb.log","at"); \
00045         x; \
00046         fclose(fil); \
00047 }
00048 */
00049 #define DEB(x)
00050 
00051 
00052 FwdSocket::FwdSocket(ISocketHandler& h)
00053 :TcpSocket(h)
00054 ,m_remote(NULL)
00055 {
00056         SetLineProtocol();
00057 }
00058 
00059 
00060 FwdSocket::~FwdSocket()
00061 {
00062         if (m_remote && Handler().Valid(m_remote) )
00063         {
00064 //              m_remote -> SetCloseAndDelete();
00065         }
00066 }
00067 
00068 
00069 void FwdSocket::OnLine(const std::string& line)
00070 {
00071         Parse pa(line,"-");
00072         long status = pa.getvalue();
00073         if (status == 550)
00074         {
00075                 if (m_remote && Handler().Valid(m_remote) )
00076                 {
00077                         m_remote -> SetFake();
00078                 }
00079                 m_remote -> Send("250 Ok\r\n");
00080                 SetCloseAndDelete();
00081         }
00082         else
00083         if (status != 250)
00084         {
00085                 printf("<%s\n",line.c_str());
00086         }
00087         if (m_remote && Handler().Valid(m_remote) )
00088         {
00089                 m_remote -> Send(line + "\r\n");
00090         }
00091 }
00092 
00093 
00094 void FwdSocket::OnDelete()
00095 {
00096         if (m_remote && Handler().Valid(m_remote) )
00097         {
00098 //              m_remote -> SetCloseAndDelete();
00099         }
00100 }
00101 
00102 
Page, code, and content Copyright (C) 2006 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4