diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-11 12:15:03 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-11 12:15:03 +0000 |
commit | d17465716790010b6e3221f9ce49272110276ccf (patch) | |
tree | d929b9c717e789d818d0eefbfe6e018974ae48f6 /include | |
parent | 312d49abb008dccf9871b663decaa1bacf18c20a (diff) |
Now two types of log macro, log() and ilog(). log() assumes an InspIRCd object called ServerInstance, ilog() takes an InspIRCd object as first param.
TODO: Run a regexp over these, using perl, to translate them into InspIRCd::Log calls and then eliminate the macro :)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4879 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r-- | include/helperfuncs.h | 35 | ||||
-rw-r--r-- | include/inspircd.h | 29 | ||||
-rw-r--r-- | include/modules.h | 4 | ||||
-rw-r--r-- | include/socketengine.h | 5 | ||||
-rw-r--r-- | include/socketengine_epoll.h | 6 | ||||
-rw-r--r-- | include/socketengine_kqueue.h | 6 | ||||
-rw-r--r-- | include/socketengine_select.h | 6 |
7 files changed, 43 insertions, 48 deletions
diff --git a/include/helperfuncs.h b/include/helperfuncs.h index bae7f8326..ce169c3b0 100644 --- a/include/helperfuncs.h +++ b/include/helperfuncs.h @@ -14,38 +14,3 @@ * --------------------------------------------------- */ -#ifndef _HELPER_H_ -#define _HELPER_H_ - -#include "dynamic.h" -#include "base.h" -#include "ctables.h" -#include "users.h" -#include "channels.h" -#include "typedefs.h" -#include <string> -#include <deque> -#include <sstream> - -/** Debug levels for use with InspIRCd::Log() - */ -enum DebugLevel -{ - DEBUG = 10, - VERBOSE = 20, - DEFAULT = 30, - SPARSE = 40, - NONE = 50, -}; - -/* I'm not entirely happy with this, the ## before 'args' is a g++ extension. - * The problem is that if you #define log(l, x, args...) and then call it - * with only two parameters, you get do_log(l, x, ), which is a syntax error... - * The ## tells g++ to remove the trailing comma... - * If this is ever an issue, we can just have an #ifndef GCC then #define log(a...) do_log(a) - */ -#define STRINGIFY2(x) #x -#define STRINGIFY(x) STRINGIFY2(x) -#define log(l, x, args...) InspIRCd::Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args) - -#endif diff --git a/include/inspircd.h b/include/inspircd.h index 699d910dc..3800c09ab 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -36,6 +36,28 @@ /* Crucial defines */ #define ETIREDGERBILS EAGAIN +/** Debug levels for use with InspIRCd::Log() + */ +enum DebugLevel +{ + DEBUG = 10, + VERBOSE = 20, + DEFAULT = 30, + SPARSE = 40, + NONE = 50, +}; + +/* I'm not entirely happy with this, the ## before 'args' is a g++ extension. + * The problem is that if you #define log(l, x, args...) and then call it + * with only two parameters, you get do_log(l, x, ), which is a syntax error... + * The ## tells g++ to remove the trailing comma... + * If this is ever an issue, we can just have an #ifndef GCC then #define log(a...) do_log(a) + */ +#define STRINGIFY2(x) #x +#define STRINGIFY(x) STRINGIFY2(x) +#define log(l, x, args...) ServerInstance->Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args) +#define ilog(i, l, x, args...) i->Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args) + /* This define is used in place of strcmp when we * want to check if a char* string contains only one * letter. Pretty fast, its just two compares and an @@ -43,7 +65,7 @@ */ #define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) ) -#define DELETE(x) { InspIRCd::Log(DEBUG,"%s:%d: delete()",__FILE__,__LINE__); if (x) { delete x; x = NULL; } else InspIRCd::Log(DEBUG,"Attempt to delete NULL pointer!"); } +#define DELETE(x) {if (x) { delete x; x = NULL; }} template<typename T> inline std::string ConvToStr(const T &in) { @@ -177,7 +199,6 @@ class InspIRCd : public classbase bool IsChannel(const char *chname); - static void Error(int status); static void Rehash(int status); static void Exit(int status); @@ -319,8 +340,8 @@ class InspIRCd : public classbase bool UnloadModule(const char* filename); InspIRCd(int argc, char** argv); void DoOneIteration(bool process_module_sockets); - static void Log(int level, const char* text, ...); - static void Log(int level, const std::string &text); + void Log(int level, const char* text, ...); + void Log(int level, const std::string &text); int Run(); }; diff --git a/include/modules.h b/include/modules.h index 9ca7eab5e..6142af17a 100644 --- a/include/modules.h +++ b/include/modules.h @@ -111,7 +111,7 @@ typedef std::map<std::string,Module*> featurelist; } \ catch (ModuleException& modexcept) \ { \ - log(DEBUG,"Module exception caught: %s",modexcept.GetReason()); \ + ilog(z,DEBUG,"Module exception caught: %s",modexcept.GetReason()); \ } \ } \ } @@ -155,7 +155,7 @@ typedef std::map<std::string,Module*> featurelist; } \ catch (ModuleException& modexcept) \ { \ - log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \ + ilog(z,DEBUG,"Module exception cought: %s",modexcept.GetReason()); \ } \ } \ } \ diff --git a/include/socketengine.h b/include/socketengine.h index a788618a2..5ccfa801e 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -46,6 +46,8 @@ const char X_ESTAB_DNS = 4; */ const char X_READBIT = 0x80; +class InspIRCd; + /** * The actual socketengine class presents the * same interface on all operating systems, but @@ -67,6 +69,7 @@ const char X_READBIT = 0x80; class SocketEngine : public Extensible { protected: + InspIRCd* ServerInstance; int EngineHandle; /* Handle to the socket engine if needed */ int CurrentSetSize; /* Current number of descriptors in the engine */ char ref[MAX_DESCRIPTORS]; /* Reference table */ @@ -80,7 +83,7 @@ public: * epoll on a 2.4 linux kernel) then this * function may bail back to the shell. */ - SocketEngine(); + SocketEngine(InspIRCd* Instance); /** Destructor * The destructor transparently tidies up diff --git a/include/socketengine_epoll.h b/include/socketengine_epoll.h index ddbeb6f40..65d1150f7 100644 --- a/include/socketengine_epoll.h +++ b/include/socketengine_epoll.h @@ -27,12 +27,14 @@ #include <sys/epoll.h> #define EP_DELAY 5 +class InspIRCd; + class EPollEngine : public SocketEngine { private: struct epoll_event events[MAX_DESCRIPTORS]; /* Up to 64k sockets for epoll */ public: - EPollEngine(); + EPollEngine(InspIRCd* Instance); virtual ~EPollEngine(); virtual bool AddFd(int fd, bool readable, char type); virtual int GetMaxFds(); @@ -45,7 +47,7 @@ public: class SocketEngineFactory { public: - SocketEngine* Create() { return new EPollEngine(); } + SocketEngine* Create(InspIRCd* Instance) { return new EPollEngine(Instance); } }; #endif diff --git a/include/socketengine_kqueue.h b/include/socketengine_kqueue.h index 822b4740a..d7451b642 100644 --- a/include/socketengine_kqueue.h +++ b/include/socketengine_kqueue.h @@ -28,13 +28,15 @@ #include <sys/time.h> #include "socketengine.h" +class InspIRCd; + class KQueueEngine : public SocketEngine { private: struct kevent ke_list[MAX_DESCRIPTORS]; /* Up to 64k sockets for kqueue */ struct timespec ts; /* kqueue delay value */ public: - KQueueEngine(); + KQueueEngine(InspIRCd* Instance); virtual ~KQueueEngine(); virtual bool AddFd(int fd, bool readable, char type); virtual int GetMaxFds(); @@ -47,7 +49,7 @@ public: class SocketEngineFactory { public: - SocketEngine* Create() { return new KQueueEngine(); } + SocketEngine* Create(InspIRCd* Instance) { return new KQueueEngine(InspIRCd* Instance); } }; #endif diff --git a/include/socketengine_select.h b/include/socketengine_select.h index 442f8c754..b3f7479ee 100644 --- a/include/socketengine_select.h +++ b/include/socketengine_select.h @@ -26,13 +26,15 @@ #include "inspircd.h" #include "socketengine.h" +class InspIRCd; + class SelectEngine : public SocketEngine { private: std::map<int,int> fds; /* List of file descriptors being monitored */ fd_set wfdset, rfdset; /* Readable and writeable sets for select() */ public: - SelectEngine(); + SelectEngine(InspIRCd* Instance); virtual ~SelectEngine(); virtual bool AddFd(int fd, bool readable, char type); virtual int GetMaxFds(); @@ -45,7 +47,7 @@ public: class SocketEngineFactory { public: - SocketEngine* Create() { return new SelectEngine(); } + SocketEngine* Create(InspIRCd* Instance) { return new SelectEngine(InspIRCd* Instance); } }; #endif |