Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

smtpnuke.cpp

Go to the documentation of this file.
00001 // smtpnuke.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 #include <stdio.h> 00021 00022 #include <ListenSocket.h> 00023 #include "SMTPSocket.h" 00024 #include "NukeHandler.h" 00025 #include "../sockio/config.h" 00026 #include <signal.h> 00027 #include <Utility.h> 00028 00029 #define DEB(x) 00030 00031 00032 static int m_quit = 0; 00033 00034 00035 #ifndef _WIN32 00036 void sigint(int s) /* save+quit */ 00037 { 00038 DEB( printf("sigint\n");) 00039 m_quit++; 00040 } 00041 00042 void sighup(int s) /* quit */ 00043 { 00044 DEB( printf("sighup\n");) 00045 m_quit++; 00046 } 00047 00048 void sigusr1(int s) /* save */ 00049 { 00050 } 00051 00052 void sigusr2(int s) /* reset all */ 00053 { 00054 } 00055 00056 void sigpipe(int s) 00057 { 00058 } 00059 00060 void siginit(void) 00061 { 00062 signal(SIGINT, (__sighandler_t)sigint); 00063 signal(SIGHUP, (__sighandler_t)sighup); 00064 signal(SIGUSR1, (__sighandler_t)sigusr1); 00065 signal(SIGUSR2, (__sighandler_t)sigusr2); 00066 signal(SIGPIPE, (__sighandler_t)sigpipe); 00067 } 00068 #endif 00069 00070 00071 void run() 00072 { 00073 size_t sz = 0; 00074 NukeHandler h; 00075 ListenSocket<SMTPSocket> l(h); 00076 00077 if (l.Bind(25, 20)) 00078 { 00079 exit(-1); 00080 } 00081 h.Add(&l); 00082 while (!m_quit) 00083 { 00084 h.Select(1, 0); 00085 if (h.GetCount() != sz) 00086 { 00087 sz = h.GetCount(); 00088 h.ViewSockets(); 00089 } 00090 } 00091 } 00092 00093 00094 int main(int argc,char *argv[]) 00095 { 00096 siginit(); 00097 parse_config(argc,argv,"nuke.cfg"); 00098 run(); 00099 } 00100 00101

Generated for C++ Sockets library example: SMTP Proxy by doxygen 1.3.6

www.TV-friendship.com
The matchmaking service with an all new twist.

Quantum 'Teleportation'
Some thoughts
Page, code, and content Copyright (C) 2004 by Anders Hedström