]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/inspircd.h
Wahhhhhhhhhhhh bwahahaha. Mass commit to tidy up tons of messy include lists
[user/henk/code/inspircd.git] / include / inspircd.h
index f404cce80782d83d08da7b64a1d0580628459eae..dfc36a720b4b6734639c144daa9ee52f24c6738e 100644 (file)
@@ -25,9 +25,9 @@
 #include "channels.h"
 #include "socket.h"
 #include "mode.h"
-
 #include "socketengine.h"
 #include "command_parse.h"
+#include "snomasks.h"
 
 /** Returned by some functions to indicate failure,
  * and the exit code of the program if it terminates.
@@ -59,7 +59,11 @@ enum DebugLevel
 
 /** Delete a pointer, and NULL its value
  */
-#define DELETE(x) {if (x) { delete x; x = NULL; }}
+template<typename T> inline void DELETE(T* x)
+{
+       delete x;
+       x = NULL;
+}
 
 /** Template function to convert any input type to std::string
  */
@@ -125,9 +129,70 @@ class serverstats : public classbase
        }
 };
 
+class InspIRCd;
+
+/** This class implements a nonblocking log-writer.
+ * Most people writing an ircd give little thought to their disk
+ * i/o. On a congested system, disk writes can block for long
+ * periods of time (e.g. if the system is busy and/or swapping
+ * a lot). If we just use a blocking fprintf() call, this could
+ * block for undesirable amounts of time (half of a second through
+ * to whole seconds). We DO NOT want this, so we make our logfile
+ * nonblocking and hook it into the SocketEngine.
+ * NB: If the operating system does not support nonblocking file
+ * I/O (linux seems to, as does freebsd) this will default to
+ * blocking behaviour.
+ */
+class FileLogger : public EventHandler
+{
+ protected:
+       /** The creator/owner of this object
+        */
+       InspIRCd* ServerInstance;
+       /** The log file (fd is inside this somewhere,
+        * we get it out with fileno())
+        */
+       FILE* log;
+       /** Buffer of pending log lines to be written
+        */
+       std::string buffer;
+       /** Number of write operations that have occured
+        */
+       int writeops;
+ public:
+       /** The constructor takes an already opened logfile.
+        */
+       FileLogger(InspIRCd* Instance, FILE* logfile);
+       /** This returns false, logfiles are writeable.
+        */
+       virtual bool Readable();
+       /** Handle pending write events.
+        * This will flush any waiting data to disk.
+        * If any data remains after the fprintf call,
+        * another write event is scheduled to write
+        * the rest of the data when possible.
+        */
+       virtual void HandleEvent(EventType et);
+       /** Write one or more preformatted log lines.
+        * If the data cannot be written immediately,
+        * this class will insert itself into the
+        * SocketEngine, and register a write event,
+        * and when the write event occurs it will
+        * attempt again to write the data.
+        */
+       void WriteLogLine(const std::string &line);
+       /** Close the log file and cancel any events.
+        */
+       virtual void Close();
+       /** Close the log file and cancel any events.
+        * (indirectly call Close()
+        */
+       virtual ~FileLogger();
+};
+
 class XLineManager;
 
-/** The main singleton class of the irc server.
+/** The main class of the irc server.
  * This class contains instances of all the other classes
  * in this software, with the exception of the base class,
  * classbase. Amongst other things, it contains a ModeParser,
@@ -189,10 +254,6 @@ class InspIRCd : public classbase
         */
        bool DaemonSeed();
 
-       /** Build the upper/lowercase comparison table
-        */
-       void MakeLowerMap();
-
        /** Moves the given module to the last slot in the list
         * @param modulename The module name to relocate
         */
@@ -215,12 +276,6 @@ class InspIRCd : public classbase
         */
        void MoveBefore(std::string modulename, std::string before);
 
-       /** Process a user whos socket has been flagged as active
-        * @param cu The user to process
-        * @return There is no actual return value, however upon exit, the user 'cu' may have been deleted
-        */
-       void ProcessUser(userrec* cu);
-
        /** Iterate the list of InspSocket objects, removing ones which have timed out
         * @param TIME the current time
         */
@@ -289,9 +344,9 @@ class InspIRCd : public classbase
         */
        socklen_t length;
 
-       /** Used to count iterations around the mainloop
+       /** Nonblocking file writer
         */
-       int iterations;
+       FileLogger* Logger;
 
  public:
        /** Time this ircd was booted
@@ -318,17 +373,10 @@ class InspIRCd : public classbase
         */
        ServerConfig* Config;
 
-       /** Module sockets list, holds the active set of InspSocket classes
+       /** Snomask manager - handles routing of snomask messages
+        * to opers.
         */
-       std::vector<InspSocket*> module_sockets;
-
-       /** Socket reference table, provides fast lookup of fd to InspSocket*
-        */
-       InspSocket* socket_ref[MAX_DESCRIPTORS];
-
-       /** user reference table, provides fast lookup of fd to userrec*
-        */
-       userrec* fd_ref_table[MAX_DESCRIPTORS];
+       SnomaskManager* SNO;
 
        /** Client list, a hash_map containing all clients, local and remote
         */
@@ -381,6 +429,12 @@ class InspIRCd : public classbase
         */
        time_t Time();
 
+       /** Process a user whos socket has been flagged as active
+        * @param cu The user to process
+        * @return There is no actual return value, however upon exit, the user 'cu' may have been deleted
+        */
+       void ProcessUser(userrec* cu);
+
        /** Get the total number of currently loaded modules
         * @return The number of loaded modules
         */
@@ -815,21 +869,6 @@ class InspIRCd : public classbase
         */
         bool IsValidMask(const std::string &mask);
 
-       /** Add an InspSocket class to the active set
-        * @param sock A socket to add to the active set
-        */
-        void AddSocket(InspSocket* sock);
-
-       /** Remove an InspSocket class from the active set at next time around the loop
-        * @param sock A socket to remove from the active set
-        */
-        void RemoveSocket(InspSocket* sock);
-
-       /** Delete a socket immediately without waiting for the next iteration of the mainloop
-        * @param sock A socket to delete from the active set
-        */
-        void DelSocket(InspSocket* sock);
-
        /** Rehash the local server
         */
         void RehashServer();