summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-11-23 10:06:54 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-11-23 10:06:54 +0000
commitd066a23b4d2904717e3b5099dd02d25f7fd9d07a (patch)
tree603e03c34c314faf43fce66669db1643b91477f7
parentb1d95a4725b3f1aaf609abbd67eb2a87efad4dca (diff)
Added start of socket classes used by modular linking
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1927 e03df62e-2008-0410-955e-edbf42e46eb7
-rwxr-xr-xconfigure15
-rw-r--r--include/socket.h38
-rw-r--r--src/socket.cpp67
3 files changed, 116 insertions, 4 deletions
diff --git a/configure b/configure
index d604b3a14..5717d46c8 100755
--- a/configure
+++ b/configure
@@ -953,8 +953,8 @@ CXXFLAGS = -I../include \${FLAGS}
all: hashcomp.o channels.o mode.o xline.o inspstring.o dns.o base.o inspircd_util.o inspircd_io.o connection.o message.o commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o servers.o helperfuncs.o \$(MODULES) inspircd.exe
-inspircd.exe: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h
- \$(CC) -I../include \$(FLAGS) inspircd.cpp -o inspircd.exe \$(LDLIBS) channels.o mode.o xline.o inspstring.o dns.o base.o inspircd_util.o inspircd_io.o connection.o message.o commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o servers.o helperfuncs.o hashcomp.o \$(MODULES)
+inspircd.exe: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h ../include/base.h
+ \$(CC) -I../include \$(FLAGS) inspircd.cpp -o inspircd.exe \$(LDLIBS) channels.o mode.o xline.o inspstring.o dns.o base.o inspircd_util.o inspircd_io.o connection.o message.o commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o servers.o helperfuncs.o hashcomp.o socket.o \$(MODULES)
hashcomp.o: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
@@ -1013,6 +1013,9 @@ wildcard.o: wildcard.cpp ../include/base.h ../include/wildcard.h ../include/insp
servers.o: servers.cpp ../include/base.h ../include/servers.h ../include/inspircd.h ../include/channels.h ../include/users.h ../include/globals.h ../include/inspircd_config.h ../include/connection.h
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c servers.cpp
+socket.o: socket.cpp ../include/base.h ../include/servers.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
+ \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socket.cpp
+
EOM
close(FH);
@@ -1034,8 +1037,8 @@ CXXFLAGS = -I../include \${FLAGS}
all: libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDutil.so libIRCDio.so libIRCDconnection.so libIRCDmessage.so libIRCDcommands.so libIRCDdnsqueue.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDservers.so libIRCDhelper.so inspircd
-inspircd: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h
- \$(CC) -I../include \$(FLAGS) -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDutil.so libIRCDio.so libIRCDconnection.so libIRCDmessage.so libIRCDcommands.so libIRCDdnsqueue.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDservers.so libIRCDhelper.so libIRCDhash.so
+inspircd: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h ../include/socket.h
+ \$(CC) -I../include \$(FLAGS) -rdynamic -L. inspircd.cpp -o inspircd \$(LDLIBS) libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDutil.so libIRCDio.so libIRCDconnection.so libIRCDmessage.so libIRCDcommands.so libIRCDdnsqueue.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDservers.so libIRCDhelper.so libIRCDhash.so libIRCDsocket.so
libIRCDhash.so: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
@@ -1113,6 +1116,10 @@ libIRCDservers.so: servers.cpp ../include/base.h ../include/servers.h ../include
\$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c servers.cpp
\$(CC) -shared -o libIRCDservers.so servers.o
+libIRCDsocket.so: socket.cpp ../include/base.h ../include/inspircd.h ../include/globals.h ../include/inspircd_config.h
+ \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c socket.cpp
+ \$(CC) -shared -o libIRCDsocket.so socket.o
+
EOM
close(FH);
}
diff --git a/include/socket.h b/include/socket.h
new file mode 100644
index 000000000..3e681f1c4
--- /dev/null
+++ b/include/socket.h
@@ -0,0 +1,38 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+#include <sstream>
+#include <string>
+
+enum InspSocketState { I_DISCONNECTED, I_CONNECTING, I_CONNECTED, I_LISTENING };
+
+class InspSocket
+{
+private:
+ int fd;
+ std::string host;
+ int port;
+ InspSocketState state;
+public:
+ InspSocket();
+ InspSocket(std::string host, int port, bool listening);
+ void Poll();
+ virtual int OnConnected();
+ virtual int OnError();
+ virtual int OnDisconnect();
+ virtual int OnIncomingConnection();
+ ~InspSocket();
+};
diff --git a/src/socket.cpp b/src/socket.cpp
new file mode 100644
index 000000000..920713566
--- /dev/null
+++ b/src/socket.cpp
@@ -0,0 +1,67 @@
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+
+#include "inspircd_config.h"
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <string>
+#include <unistd.h>
+#include <sstream>
+#include <iostream>
+#include <fstream>
+#include "socket.h"
+#include "inspircd.h"
+#include "inspircd_io.h"
+#include "inspircd_util.h"
+#include "inspstring.h"
+#include "helperfuncs.h"
+
+extern FILE *log_file;
+extern int boundPortCount;
+extern int openSockfd[MAXSOCKS];
+extern time_t TIME;
+extern bool unlimitcore;
+extern int MaxConn;
+
+InspSocket::InspSocket()
+{
+ this->state = I_DISCONNECTED;
+}
+
+InspSocket::InspSocket(std::string host, int port, bool listening)
+{
+}
+
+void InspSocket::Poll()
+{
+}
+
+int InspSocket::OnConnected() { }
+int InspSocket::OnError() { }
+int InspSocket::OnDisconnect() { }
+int InspSocket::OnIncomingConnection() { }
+
+InspSocket::~InspSocket()
+{
+}
+
+/*
+int BindSocket (int sockfd, struct sockaddr_in client, struct sockaddr_in server, int port, char* addr)
+int OpenTCPSocket (void)
+*/