summaryrefslogtreecommitdiff
path: root/src/socketengine.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-18 01:08:14 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-18 01:08:14 +0000
commite381b06561228aaea752deda20a62c6dc99a560e (patch)
tree2119fe8bc8895597261935f389004e3c6bafe6a8 /src/socketengine.cpp
parent3c82d2d767186dd6d386dbbe08219ad8612e299e (diff)
EventHandler class, an abstraction for raw i/o
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4941 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socketengine.cpp')
-rw-r--r--src/socketengine.cpp51
1 files changed, 30 insertions, 21 deletions
diff --git a/src/socketengine.cpp b/src/socketengine.cpp
index 3f34d75fb..71ae4fe9b 100644
--- a/src/socketengine.cpp
+++ b/src/socketengine.cpp
@@ -15,21 +15,30 @@
*/
#include "inspircd_config.h"
-#include "globals.h"
#include "inspircd.h"
-#ifdef USE_EPOLL
-#include <sys/epoll.h>
-#endif
-#ifdef USE_KQUEUE
-#include <sys/types.h>
-#include <sys/event.h>
-#include <sys/time.h>
-#endif
#include <vector>
#include <string>
#include "socketengine.h"
-#include "inspircd.h"
+int EventHandler::GetFd()
+{
+ return this->fd;
+}
+
+void EventHandler::SetFd(int FD)
+{
+ this->fd = FD;
+}
+
+bool EventHandler::Readable()
+{
+ return true;
+}
+
+bool EventHandler::Writeable()
+{
+ return false;
+}
SocketEngine::SocketEngine(InspIRCd* Instance) : ServerInstance(Instance)
{
@@ -40,27 +49,26 @@ SocketEngine::~SocketEngine()
{
}
-char SocketEngine::GetType(int fd)
+bool SocketEngine::AddFd(EventHandler* eh)
{
- if ((fd < 0) || (fd > MAX_DESCRIPTORS))
- return X_EMPTY_SLOT;
- /* Mask off the top bit used for 'read/write' state */
- return (ref[fd] & ~0x80);
+ return true;
}
-bool SocketEngine::AddFd(int fd, bool readable, char type)
+bool SocketEngine::HasFd(int fd)
{
- return true;
+ if ((fd < 0) || (fd > MAX_DESCRIPTORS))
+ return false;
+ return ref[fd];
}
-bool SocketEngine::HasFd(int fd)
+EventHandler* SocketEngine::GetRef(int fd)
{
if ((fd < 0) || (fd > MAX_DESCRIPTORS))
return false;
- return (ref[fd] != 0);
+ return ref[fd];
}
-bool SocketEngine::DelFd(int fd)
+bool SocketEngine::DelFd(EventHandler* eh)
{
return true;
}
@@ -75,7 +83,7 @@ int SocketEngine::GetRemainingFds()
return 0;
}
-int SocketEngine::Wait(int* fdlist)
+int SocketEngine::Wait(EventHandler** fdlist)
{
return 0;
}
@@ -84,3 +92,4 @@ std::string SocketEngine::GetName()
{
return "misconfigured";
}
+