diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-19 15:56:42 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-05-19 15:56:42 +0000 |
commit | 9cf56d917d92959701694477f7944d45ad2c38ed (patch) | |
tree | a379ee905e7485c2ee825790720ed2b69ba127d1 /include | |
parent | 3bbb36695383badf5b3ba0ecba070f16094ae51d (diff) |
Windows support. Tested and working to compile on freebsd and linux. Next step is to make sure it actually works in windows too. ;p. Add Burlex to contributors.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7043 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r-- | include/base.h | 6 | ||||
-rw-r--r-- | include/channels.h | 2 | ||||
-rw-r--r-- | include/command_parse.h | 2 | ||||
-rw-r--r-- | include/commands/cmd_stats.h | 2 | ||||
-rw-r--r-- | include/commands/cmd_whois.h | 2 | ||||
-rw-r--r-- | include/commands/cmd_whowas.h | 8 | ||||
-rw-r--r-- | include/configreader.h | 4 | ||||
-rw-r--r-- | include/connection.h | 2 | ||||
-rw-r--r-- | include/ctables.h | 2 | ||||
-rw-r--r-- | include/cull_list.h | 4 | ||||
-rw-r--r-- | include/dns.h | 16 | ||||
-rw-r--r-- | include/dynamic.h | 6 | ||||
-rw-r--r-- | include/exitcodes.h | 20 | ||||
-rw-r--r-- | include/hash_map.h | 6 | ||||
-rw-r--r-- | include/hashcomp.h | 145 | ||||
-rw-r--r-- | include/inspircd.h | 14 | ||||
-rw-r--r-- | include/inspsocket.h | 4 | ||||
-rw-r--r-- | include/inspstring.h | 16 | ||||
-rw-r--r-- | include/mode.h | 6 | ||||
-rw-r--r-- | include/modules.h | 25 | ||||
-rw-r--r-- | include/snomasks.h | 2 | ||||
-rw-r--r-- | include/socket.h | 36 | ||||
-rw-r--r-- | include/socketengine.h | 23 | ||||
-rw-r--r-- | include/timer.h | 4 | ||||
-rw-r--r-- | include/typedefs.h | 7 | ||||
-rw-r--r-- | include/users.h | 12 | ||||
-rw-r--r-- | include/wildcard.h | 8 | ||||
-rw-r--r-- | include/xline.h | 14 |
28 files changed, 256 insertions, 142 deletions
diff --git a/include/base.h b/include/base.h index bea7075a0..2259953b8 100644 --- a/include/base.h +++ b/include/base.h @@ -27,7 +27,7 @@ class InspIRCd; /** The base class for all inspircd classes */ -class classbase +class CoreExport classbase { public: /** Time that the object was instantiated (used for TS calculation etc) @@ -48,7 +48,7 @@ class classbase * a flags variable, and each module defining bits within the flag as 'theirs' as it is less prone to conflict and * supports arbitary data storage). */ -class Extensible : public classbase +class CoreExport Extensible : public classbase { /** Private data store */ @@ -153,7 +153,7 @@ public: * Use BoolSet::Set and BoolSet::Get to set and get bools in the bitmask, * and Unset and Invert for special operations upon them. */ -class BoolSet : public classbase +class CoreExport BoolSet : public classbase { char bits; diff --git a/include/channels.h b/include/channels.h index f68f83889..8cee75b9c 100644 --- a/include/channels.h +++ b/include/channels.h @@ -110,7 +110,7 @@ typedef std::map<userrec*, std::vector<prefixtype> > prefixlist; * This class represents a channel, and contains its name, modes, time created, topic, topic set time, * etc, and an instance of the BanList type. */ -class chanrec : public Extensible +class CoreExport chanrec : public Extensible { private: diff --git a/include/command_parse.h b/include/command_parse.h index 5750416db..2ffb30ee6 100644 --- a/include/command_parse.h +++ b/include/command_parse.h @@ -28,7 +28,7 @@ typedef std::map<std::string, void*> SharedObjectList; * call command handlers by name, and chop up comma seperated * parameters into multiple calls. */ -class CommandParser : public classbase +class CoreExport CommandParser : public classbase { private: /** The creator of this class diff --git a/include/commands/cmd_stats.h b/include/commands/cmd_stats.h index 6b090ef60..0aa98e359 100644 --- a/include/commands/cmd_stats.h +++ b/include/commands/cmd_stats.h @@ -23,7 +23,7 @@ #include "users.h" #include "channels.h" -void DoStats(InspIRCd* Instance, char statschar, userrec* user, string_list &results); +DllExport void DoStats(InspIRCd* Instance, char statschar, userrec* user, string_list &results); /** Handle /STATS */ diff --git a/include/commands/cmd_whois.h b/include/commands/cmd_whois.h index ab6778877..cd1f75c51 100644 --- a/include/commands/cmd_whois.h +++ b/include/commands/cmd_whois.h @@ -23,7 +23,7 @@ #include "channels.h" const char* Spacify(char* n); -void do_whois(InspIRCd* Instance, userrec* user, userrec* dest,unsigned long signon, unsigned long idle, const char* nick); +DllExport void do_whois(InspIRCd* Instance, userrec* user, userrec* dest,unsigned long signon, unsigned long idle, const char* nick); /** Handle /WHOIS */ diff --git a/include/commands/cmd_whowas.h b/include/commands/cmd_whowas.h index ccbe40493..8b31c3e7a 100644 --- a/include/commands/cmd_whowas.h +++ b/include/commands/cmd_whowas.h @@ -33,14 +33,14 @@ enum Internals }; /* Forward ref for timer */ -class MaintainTimer; +class WhoWasMaintainTimer; /* Forward ref for typedefs */ class WhoWasGroup; /** InspTimer that is used to maintain the whowas list, called once an hour */ -MaintainTimer* timer; +extern WhoWasMaintainTimer* timer; /** A group of users related by nickname */ @@ -110,12 +110,12 @@ class WhoWasGroup : public classbase ~WhoWasGroup(); }; -class MaintainTimer : public InspTimer +class WhoWasMaintainTimer : public InspTimer { private: InspIRCd* ServerInstance; public: - MaintainTimer(InspIRCd* Instance, long interval) + WhoWasMaintainTimer(InspIRCd* Instance, long interval) : InspTimer(interval, Instance->Time(), true), ServerInstance(Instance) { } diff --git a/include/configreader.h b/include/configreader.h index 772de2177..096d1843a 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -180,7 +180,7 @@ typedef std::map<irc::string,char*> operclass_t; * and storage of the configuration data needed to run the ircd, such as * the servername, connect classes, /ADMIN data, MOTDs and filenames etc. */ -class ServerConfig : public Extensible +class CoreExport ServerConfig : public Extensible { private: /** Creator/owner @@ -663,7 +663,7 @@ class ServerConfig : public Extensible }; -bool InitializeDisabledCommands(const char* data, InspIRCd* ServerInstance); +CoreExport bool InitializeDisabledCommands(const char* data, InspIRCd* ServerInstance); bool InitTypes(ServerConfig* conf, const char* tag); bool InitClasses(ServerConfig* conf, const char* tag); diff --git a/include/connection.h b/include/connection.h index 5f72fbde0..65d342447 100644 --- a/include/connection.h +++ b/include/connection.h @@ -22,7 +22,7 @@ /** connection is the base class of userrec, and holds basic user properties. * This can be extended for holding other user-like objects in the future. */ -class connection : public EventHandler +class CoreExport connection : public EventHandler { public: /** Hostname of connection. diff --git a/include/ctables.h b/include/ctables.h index 92a0659af..affef58d9 100644 --- a/include/ctables.h +++ b/include/ctables.h @@ -44,7 +44,7 @@ enum CmdResult /** A structure that defines a command. Every command available * in InspIRCd must be defined as derived from command_t. */ -class command_t : public Extensible +class CoreExport command_t : public Extensible { protected: /** Owner/Creator object diff --git a/include/cull_list.h b/include/cull_list.h index bea75c86d..8901c5ea4 100644 --- a/include/cull_list.h +++ b/include/cull_list.h @@ -29,7 +29,7 @@ class InspIRCd; * a list of users which are to be culled when a long * operation (such as a netsplit) has completed. */ -class CullItem : public classbase +class CoreExport CullItem : public classbase { private: /** Holds a pointer to the user, @@ -84,7 +84,7 @@ class CullItem : public classbase * you attempt to add the same user twice, then the second * attempt will be ignored. */ -class CullList : public classbase +class CoreExport CullList : public classbase { private: /** Creator of this CullList diff --git a/include/dns.h b/include/dns.h index f12dbdb1e..d823a04a8 100644 --- a/include/dns.h +++ b/include/dns.h @@ -52,7 +52,7 @@ class Module; /** * Result status, used internally */ -class DNSResult : public classbase +class CoreExport DNSResult : public classbase { public: /** Result ID @@ -84,7 +84,7 @@ typedef std::pair<unsigned char*, std::string> DNSInfo; /** Cached item stored in the query cache. */ -class CachedQuery +class CoreExport CachedQuery { public: /** The cached result data, an IP or hostname @@ -108,14 +108,18 @@ class CachedQuery */ int CalcTTLRemaining() { - int n = expires - time(NULL); + int n = (int)expires - (int)time(NULL); return (n < 0 ? 0 : n); } }; /** DNS cache information. Holds IPs mapped to hostnames, and hostnames mapped to IPs. */ +#ifndef WIN32 typedef nspace::hash_map<irc::string, CachedQuery, nspace::hash<irc::string> > dnscache; +#else +typedef nspace::hash_map<irc::string, CachedQuery, nspace::hash_compare<irc::string> > dnscache; +#endif /** * Error types that class Resolver can emit to its error method. @@ -144,7 +148,7 @@ class DNSHeader; /** * A DNS Resource Record (rr) */ -class ResourceRecord; +struct ResourceRecord; /** * Query and resource record types @@ -189,7 +193,7 @@ enum ForceProtocol * can occur by calling virtual methods, one is a success situation, and the other * an error situation. */ -class Resolver : public Extensible +class CoreExport Resolver : public Extensible { protected: /** @@ -319,7 +323,7 @@ class Resolver : public Extensible * back to Resolver objects, based upon the request ID. You * should never use this class yourself. */ -class DNS : public EventHandler +class CoreExport DNS : public EventHandler { private: diff --git a/include/dynamic.h b/include/dynamic.h index f2efce0f0..e4d1b4a05 100644 --- a/include/dynamic.h +++ b/include/dynamic.h @@ -27,7 +27,7 @@ class InspIRCd; /** The DLLManager class is able to load a module file by filename, * and locate its init_module symbol. */ -class DLLManager +class CoreExport DLLManager { public: /** This constructor loads the module using dlopen() @@ -82,7 +82,7 @@ class DLLManager /** This class is a specialized form of DLLManager designed to load InspIRCd modules. * It's job is to call the init_module function and receive a factory pointer. */ -class DLLFactoryBase : public DLLManager +class CoreExport DLLFactoryBase : public DLLManager { public: /** Default constructor. @@ -111,7 +111,7 @@ class DLLFactoryBase : public DLLManager * This template is a container for ModuleFactory itself, so that it may 'plug' into ModuleFactory * and provide module loading capabilities transparently. */ -template <class T> class DLLFactory : public DLLFactoryBase +template <class T> class CoreExport DLLFactory : public DLLFactoryBase { public: /** Default constructor. diff --git a/include/exitcodes.h b/include/exitcodes.h index 65329c47c..692e731e0 100644 --- a/include/exitcodes.h +++ b/include/exitcodes.h @@ -38,24 +38,6 @@ enum ExitStatus /** Array that maps exit codes (ExitStatus types) to * human-readable strings to be shown on shutdown. */ -const char* ExitCodes[] = -{ - "No error", /* 0 */ - "DIE command", /* 1 */ - "execv() failed", /* 2 */ - "Internal error", /* 3 */ - "Config file error", /* 4 */ - "Logfile error", /* 5 */ - "Fork failed", /* 6 */ - "Bad commandline parameters", /* 7 */ - "No ports could be bound", /* 8 */ - "Can't write PID file", /* 9 */ - "SocketEngine could not initialize", /* 10 */ - "Refusing to start up as root", /* 11 */ - "Found a <die> tag!", /* 12 */ - "Couldn't load module on startup", /* 13 */ - "", /* 14 */ - "Received SIGTERM", /* 15 */ -}; +extern const char * ExitCodes[]; #endif diff --git a/include/hash_map.h b/include/hash_map.h index 01646d71a..ad38d426a 100644 --- a/include/hash_map.h +++ b/include/hash_map.h @@ -16,7 +16,13 @@ #include "inspircd_config.h" +#ifndef WIN32 #include <ext/hash_map> #define nspace __gnu_cxx +#else +#include <hash_map> +#define nspace stdext +using stdext::hash_map; +#endif #endif diff --git a/include/hashcomp.h b/include/hashcomp.h index b903f7748..aa3504994 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -58,28 +58,6 @@ unsigned const char lowermap[256] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, }; #endif -/** Because of weirdness in g++, before 3.x this was namespace std. It's now __gnu_cxx. - * This is a #define'd alias. - */ -namespace nspace -{ - /** Convert a string to lower case respecting RFC1459 - * @param n A string to lowercase - */ - void strlower(char *n); - - /** Hashing function to hash std::string without respect to case - */ - template<> struct hash<std::string> - { - /** Hash a std::string using RFC1459 case sensitivity rules - * @param s A string to hash - * @return The hash value - */ - size_t operator()(const string &s) const; - }; -} - /** The irc namespace contains a number of helper classes. */ namespace irc @@ -103,7 +81,7 @@ namespace irc * std::string, or a const char** array, using overloaded * constructors. */ - class stringjoiner + class CoreExport stringjoiner { private: /** Output string @@ -142,7 +120,7 @@ namespace irc * It can then reproduce this list, clamped to a maximum of MAXMODES * values per line. */ - class modestacker + class CoreExport modestacker { private: /** The mode sequence and its parameters @@ -213,7 +191,7 @@ namespace irc * list will be ":item". This is to allow for parsing 'source' fields * from data. */ - class tokenstream + class CoreExport tokenstream { private: /** Original string @@ -245,7 +223,7 @@ namespace irc * the next token, until none remain, at which point the method returns * an empty string. */ - class sepstream : public classbase + class CoreExport sepstream : public classbase { private: /** Original string @@ -284,7 +262,7 @@ namespace irc /** A derived form of sepstream, which seperates on commas */ - class commasepstream : public sepstream + class CoreExport commasepstream : public sepstream { public: commasepstream(const std::string &source) : sepstream(source, ',') @@ -294,7 +272,7 @@ namespace irc /** A derived form of sepstream, which seperates on spaces */ - class spacesepstream : public sepstream + class CoreExport spacesepstream : public sepstream { public: spacesepstream(const std::string &source) : sepstream(source, ' ') @@ -310,7 +288,7 @@ namespace irc * start or end < 0) then GetToken() will return the first element * of the pair of numbers. */ - class portparser : public classbase + class CoreExport portparser : public classbase { private: /** Used to split on commas @@ -414,7 +392,7 @@ namespace irc * }; * \endcode */ - class dynamicbitmask : public classbase + class CoreExport dynamicbitmask : public classbase { private: /** Data bits. We start with four of these, @@ -503,48 +481,129 @@ namespace irc /** Compare two strings of size n */ - static int compare(const char* str1, const char* str2, size_t n); + static CoreExport int compare(const char* str1, const char* str2, size_t n); /** Find a char within a string up to position n */ - static const char* find(const char* s1, int n, char c); + static CoreExport const char* find(const char* s1, int n, char c); }; - std::string hex(const unsigned char *raw, size_t rawsz); + CoreExport std::string hex(const unsigned char *raw, size_t rawsz); /** This typedef declares irc::string based upon irc_char_traits */ typedef basic_string<char, irc_char_traits, allocator<char> > string; - const char* Spacify(const char* n); + CoreExport const char* Spacify(const char* n); } /* Define operators for using >> and << with irc::string to an ostream on an istream. */ /* This was endless fun. No. Really. */ /* It was also the first core change Ommeh made, if anyone cares */ -std::ostream& operator<<(std::ostream &os, const irc::string &str); -std::istream& operator>>(std::istream &is, irc::string &str); +inline std::ostream& operator<<(std::ostream &os, const irc::string &str) { return os << str.c_str(); } +inline std::istream& operator>>(std::istream &is, irc::string &str) +{ + std::string tmp; + is >> tmp; + str = tmp.c_str(); + return is; +} /* Define operators for + and == with irc::string to std::string for easy assignment * and comparison - Brain */ -std::string operator+ (std::string& leftval, irc::string& rightval); -irc::string operator+ (irc::string& leftval, std::string& rightval); -bool operator== (const std::string& leftval, const irc::string& rightval); -bool operator== (const irc::string& leftval, const std::string& rightval); +inline std::string operator+ (std::string& leftval, irc::string& rightval) +{ + return leftval + std::string(rightval.c_str()); +} + +inline irc::string operator+ (irc::string& leftval, std::string& rightval) +{ + return leftval + irc::string(rightval.c_str()); +} + +inline bool operator== (const std::string& leftval, const irc::string& rightval) +{ + return (leftval.c_str() == rightval); +} + +inline bool operator== (const irc::string& leftval, const std::string& rightval) +{ + return (leftval == rightval.c_str()); +} + +inline std::string assign(const irc::string &other) { return other.c_str(); } +inline irc::string assign(const std::string &other) { return other.c_str(); } +inline std::string& trim(std::string &str) +{ + std::string::size_type start = str.find_first_not_of(" "); + std::string::size_type end = str.find_last_not_of(" "); + if (start == std::string::npos || end == std::string::npos) + str = ""; + else + str = str.substr(start, end-start+1); + + return str; +} -std::string assign(const irc::string &other); -irc::string assign(const std::string &other); -std::string& trim(std::string &str); +/* Hashing stuff is totally different on vc++'s hash_map implementation, so to save a buttload of #ifdefs we'll just + do it all at once - Burlex */ namespace nspace { /** Hashing function to hash irc::string */ +#ifdef WINDOWS + template<> class CoreExport hash_compare<irc::string, std::less<irc::string> > + { + public: + enum { bucket_size = 4, min_buckets = 8 }; // Got these numbers from the CRT source, + // if anyone wants to change them feel free. + bool operator()(const irc::string & s1, const irc::string & s2) const + { + if(s1.length() != s2.length()) return true; + return (irc::irc_char_traits::compare(s1.c_str(), s2.c_str(), s1.length()) < 0); + } + + size_t operator()(const irc::string & s) const; + }; + + template<> class CoreExport hash_compare<std::string, std::less<std::string> > + { + public: + enum { bucket_size = 4, min_buckets = 8 }; + bool operator()(const std::string & s1, const std::string & s2) const + { + if(s1.length() != s2.length()) return true; + return (irc::irc_char_traits::compare(s1.c_str(), s2.c_str(), s1.length()) < 0); + } + + /** Hash a std::string using RFC1459 case sensitivity rules + * @param s A string to hash + * @return The hash value + */ + size_t operator()(const std::string & s) const; + }; +#else template<> struct hash<irc::string> { size_t operator()(const irc::string &s) const; }; + + template<> struct hash<std::string> + { + /** Hash a std::string using RFC1459 case sensitivity rules + * @param s A string to hash + * @return The hash value + */ + size_t operator()(const string &s) const; + }; +#endif + + /** Convert a string to lower case respecting RFC1459 + * @param n A string to lowercase + */ + void strlower(char *n); } #endif diff --git a/include/inspircd.h b/include/inspircd.h index d81116a1d..fa9b8ed56 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -14,6 +14,16 @@ #ifndef __INSPIRCD_H__ #define __INSPIRCD_H__ +#ifndef WIN32 +#define DllExport +#define CoreExport +#define printf_c printf +#else +#include "inspircd_win32wrapper.h" +#undef DELETE +#undef ERROR +#endif + #include <time.h> #include <string> #include <sstream> @@ -216,7 +226,7 @@ class InspIRCd; * I/O (linux seems to, as does freebsd) this will default to * blocking behaviour. */ -class FileLogger : public EventHandler +class CoreExport FileLogger : public EventHandler { protected: /** The creator/owner of this object @@ -284,7 +294,7 @@ class XLineManager; * program in terms of ram usage (basically, you could create * an obese forkbomb built from recursively spawning irc servers!) */ -class InspIRCd : public classbase +class CoreExport InspIRCd : public classbase { private: /** Holds a string describing the last module error to occur diff --git a/include/inspsocket.h b/include/inspsocket.h index 03b674b7a..03acad4a1 100644 --- a/include/inspsocket.h +++ b/include/inspsocket.h @@ -43,7 +43,7 @@ using irc::sockets::insp_aton; /** Used to time out socket connections */ -class SocketTimeout : public InspTimer +class CoreExport SocketTimeout : public InspTimer { private: InspSocket* sock; @@ -65,7 +65,7 @@ class SocketTimeout : public InspTimer * and use the InspSocket constructors to establish connections * and bindings. */ -class InspSocket : public EventHandler +class CoreExport InspSocket : public EventHandler { public: diff --git a/include/inspstring.h b/include/inspstring.h index 5562b3d77..1e6ba68e6 100644 --- a/include/inspstring.h +++ b/include/inspstring.h @@ -15,14 +15,22 @@ #define __IN_INSPSTRING_H #include "inspircd_config.h" +#include <string.h> #include <cstddef> #ifndef HAS_STRLCPY -size_t strlcpy(char *dst, const char *src, size_t siz); -size_t strlcat(char *dst, const char *src, size_t siz); +CoreExport size_t strlcpy(char *dst, const char *src, size_t siz); +CoreExport size_t strlcat(char *dst, const char *src, size_t siz); #endif -int charlcat(char* x,char y,int z); -bool charremove(char* mp, char remove); +CoreExport int charlcat(char* x,char y,int z); +CoreExport bool charremove(char* mp, char remove); +inline char * strnewdup(const char * s1) +{ + size_t len = strlen(s1) + 1; + char * p = new char[len]; + memcpy(p, s1, len); + return p; +} #endif diff --git a/include/mode.h b/include/mode.h index 2875d853e..8e5c105ce 100644 --- a/include/mode.h +++ b/include/mode.h @@ -90,7 +90,7 @@ typedef std::pair<bool,std::string> ModePair; * mode is expected to have a parameter, then this is * equivalent to returning MODEACTION_DENY. */ -class ModeHandler : public Extensible +class CoreExport ModeHandler : public Extensible { protected: InspIRCd* ServerInstance; @@ -279,7 +279,7 @@ class ModeHandler : public Extensible * and attach it to the mode using Server::AddModeWatcher and Server::DelModeWatcher. * A ModeWatcher will be called both before and after the mode change. */ -class ModeWatcher : public Extensible +class CoreExport ModeWatcher : public Extensible { protected: InspIRCd* ServerInstance; @@ -347,7 +347,7 @@ typedef std::vector<ModeWatcher*>::iterator ModeWatchIter; * parses client to server MODE strings for user and channel modes, and performs * processing for the 004 mode list numeric, amongst other things. */ -class ModeParser : public classbase +class CoreExport ModeParser : public classbase { private: InspIRCd* ServerInstance; diff --git a/include/modules.h b/include/modules.h index c873111ad..bba71365d 100644 --- a/include/modules.h +++ b/include/modules.h @@ -187,8 +187,11 @@ typedef std::map<std::string, std::pair<int, modulelist> > interfacelist; #define FD_MAGIC_NUMBER -42 // useful macros - +#ifdef WINDOWS +#define IS_LOCAL(x) ((x->GetFd() > -1)) +#else #define IS_LOCAL(x) ((x->GetFd() > -1) && (x->GetFd() <= MAX_DESCRIPTORS)) +#endif #define IS_REMOTE(x) (x->GetFd() < 0) #define IS_MODULE_CREATED(x) (x->GetFd() == FD_MAGIC_NUMBER) #define IS_OPER(x) (*x->oper) @@ -198,7 +201,7 @@ typedef std::map<std::string, std::pair<int, modulelist> > interfacelist; * The four members (set by the constructor only) indicate details as to the version number * of a module. A class of type Version is returned by the GetVersion method of the Module class. */ -class Version : public classbase +class CoreExport Version : public classbase { public: const int Major, Minor, Revision, Build, Flags, API; @@ -209,7 +212,7 @@ class Version : public classbase * This class is used to represent a basic data structure which is passed * between modules for safe inter-module communications. */ -class ModuleMessage : public Extensible +class CoreExport ModuleMessage : public Extensible { public: virtual ~ModuleMessage() {}; @@ -220,7 +223,7 @@ class ModuleMessage : public Extensible * using the Send() method, which will call the given module's OnRequest * method with this class as its parameter. */ -class Request : public ModuleMessage +class CoreExport Request : public ModuleMessage { protected: /** This member holds a pointer to arbitary data set by the emitter of the message @@ -282,7 +285,7 @@ class Request : public ModuleMessage * using the Send() method, which will trigger the OnEvent method in * all modules passing the object as its parameter. */ -class Event : public ModuleMessage +class CoreExport Event : public ModuleMessage { protected: /** This member holds a pointer to arbitary data set by the emitter of the message @@ -324,7 +327,7 @@ class Event : public ModuleMessage * be loaded. If this happens, the error message returned by ModuleException::GetReason will be displayed to the user * attempting to load the module, or dumped to the console if the ircd is currently loading for the first time. */ -class CoreException : public std::exception +class CoreExport CoreException : public std::exception { protected: /** Holds the error message to be displayed @@ -361,7 +364,7 @@ class CoreException : public std::exception } }; -class ModuleException : public CoreException +class CoreExport ModuleException : public CoreException { public: /** Default constructor, just uses the error mesage 'Module threw an exception'. @@ -403,7 +406,7 @@ enum Implementation { I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUse * its methods will be called when irc server events occur. class inherited from module must be * instantiated by the ModuleFactory class (see relevent section) for the module to be initialised. */ -class Module : public Extensible +class CoreExport Module : public Extensible { protected: InspIRCd* ServerInstance; @@ -1389,7 +1392,7 @@ class Module : public Extensible * Constructing the class using one parameter allows you to specify a path to your own configuration * file, otherwise, inspircd.conf is read. */ -class ConfigReader : public classbase +class CoreExport ConfigReader : public classbase { protected: InspIRCd* ServerInstance; @@ -1506,7 +1509,7 @@ class ConfigReader : public classbase * Either use the constructor type with one parameter to load a file into memory * at construction, or use the LoadFile method to load a file. */ -class FileReader : public classbase +class CoreExport FileReader : public classbase { InspIRCd* ServerInstance; /** The file contents @@ -1577,7 +1580,7 @@ class FileReader : public classbase * In most cases, the simple class shown in the example module m_foobar.so will suffice for most * modules. */ -class ModuleFactory : public classbase +class CoreExport ModuleFactory : public classbase { public: /** The default constructor does nothing. diff --git a/include/snomasks.h b/include/snomasks.h index 676309541..db8be55f8 100644 --- a/include/snomasks.h +++ b/include/snomasks.h @@ -28,7 +28,7 @@ typedef std::map<char, std::string> SnoList; * Modules and the core can enable and disable snomask characters. If they do, * then sending snomasks using these characters becomes possible. */ -class SnomaskManager : public Extensible +class CoreExport SnomaskManager : public Extensible { private: /** Creator/owner diff --git a/include/socket.h b/include/socket.h index 88478f2e3..de0b0510b 100644 --- a/include/socket.h +++ b/include/socket.h @@ -14,6 +14,8 @@ #ifndef INSPIRCD_SOCKET_H #define INSPIRCD_SOCKET_H +#ifndef WIN32 + #include <arpa/inet.h> #include <sys/time.h> #include <sys/resource.h> @@ -24,10 +26,26 @@ #include <unistd.h> #include <fcntl.h> #include <netdb.h> + +#else + +#include "inspircd_win32wrapper.h" + +#endif + #include <errno.h> #include "inspircd_config.h" #include "socketengine.h" +/* Accept Define */ +#ifdef CONFIG_USE_IOCP +#define _accept(s, addr, addrlen) __accept_socket(s, addr, addrlen, m_acceptEvent) +#define _getsockname(fd, sockptr, socklen) __getsockname(fd, sockptr, socklen, m_acceptEvent) +#else +#define _accept accept +#define _getsockname getsockname +#endif + namespace irc { /** This namespace contains various protocol-independent helper classes. @@ -72,7 +90,7 @@ namespace irc * @returns True if the first mask_bits of address matches the first * mask_bits of mask. */ - bool MatchCIDRBits(unsigned char* address, unsigned char* mask, unsigned int mask_bits); + CoreExport bool MatchCIDRBits(unsigned char* address, unsigned char* mask, unsigned int mask_bits); /** Match CIDR, without matching username/nickname parts. * @@ -83,7 +101,7 @@ namespace irc * @param cidr_mask The human readable mask, e.g. 1.2.0.0/16 * @return True if the mask matches the address */ - bool MatchCIDR(const char* address, const char* cidr_mask); + CoreExport bool MatchCIDR(const char* address, const char* cidr_mask); /** Match CIDR, including an optional username/nickname part. * @@ -96,7 +114,7 @@ namespace irc * @param cidr_mask The human readable mask, e.g. *\@1.2.0.0/16 * @return True if the mask matches the address */ - bool MatchCIDR(const char* address, const char* cidr_mask, bool match_with_username); + CoreExport bool MatchCIDR(const char* address, const char* cidr_mask, bool match_with_username); /** Convert an insp_inaddr into human readable form. * @@ -104,7 +122,7 @@ namespace irc * @return A human-readable address. IPV6 addresses * will be shortened to remove fields which are 0. */ - const char* insp_ntoa(insp_inaddr n); + CoreExport const char* insp_ntoa(insp_inaddr n); /** Convert a human-readable address into an insp_inaddr. * @@ -119,24 +137,24 @@ namespace irc * or any other number upon failure. */ - int insp_aton(const char* a, insp_inaddr* n); + CoreExport int insp_aton(const char* a, insp_inaddr* n); /** Make a socket file descriptor a blocking socket * @param s A valid file descriptor */ - void Blocking(int s); + CoreExport void Blocking(int s); /** Make a socket file descriptor into a nonblocking socket * @param s A valid file descriptor */ - void NonBlocking(int s); + CoreExport void NonBlocking(int s); /** Create a new valid file descriptor using socket() * @return On return this function will return a value >= 0 for success, * or a negative value upon failure (negative values are invalid file * descriptors) */ - int OpenTCPSocket(char* addr, int socktype = SOCK_STREAM); + CoreExport int OpenTCPSocket(char* addr, int socktype = SOCK_STREAM); }; }; @@ -144,7 +162,7 @@ namespace irc * It will create a new userrec for every valid connection * and assign it a file descriptor. */ -class ListenSocket : public EventHandler +class CoreExport ListenSocket : public EventHandler { protected: /** The creator/owner of this object diff --git a/include/socketengine.h b/include/socketengine.h index 729f5e090..0ff6e89ed 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -54,7 +54,7 @@ class InspIRCd; * must have a file descriptor. What this file descriptor * is actually attached to is completely up to you. */ -class EventHandler : public Extensible +class CoreExport EventHandler : public Extensible { protected: /** File descriptor. @@ -129,6 +129,21 @@ class EventHandler : public Extensible * and EVENT_WRITE for write events. */ virtual void HandleEvent(EventType et, int errornum = 0) = 0; + +#ifdef WINDOWS + + /** "Fake" file descriptor. This is windows-specific. + */ + int m_internalFd; + + /** Pointer to read event. We delete this so the buffer can't be used + * after the socket is deleted, and so it doesn't leak memory + */ + void * m_readEvent; + void * m_writeEvent; + void * m_acceptEvent; + +#endif }; /** Provides basic file-descriptor-based I/O support. @@ -149,7 +164,7 @@ class EventHandler : public Extensible * have to be aware of which SocketEngine derived * class they are using. */ -class SocketEngine : public Extensible +class CoreExport SocketEngine : public Extensible { protected: /** Owner/Creator @@ -242,14 +257,14 @@ public: * @param fd The event handler to look for * @return True if this fd has an event handler */ - bool HasFd(int fd); + virtual bool HasFd(int fd); /** Returns the EventHandler attached to a specific fd. * If the fd isnt in the socketengine, returns NULL. * @param fd The event handler to look for * @return A pointer to the event handler, or NULL */ - EventHandler* GetRef(int fd); + virtual EventHandler* GetRef(int fd); /** Waits for events and dispatches them to handlers. * Please note that this doesnt wait long, only diff --git a/include/timer.h b/include/timer.h index 46ad5f439..3fb2ed32b 100644 --- a/include/timer.h +++ b/include/timer.h @@ -26,7 +26,7 @@ class InspIRCd; * your object (which you should override) will be called * at the given time. */ -class InspTimer : public Extensible +class CoreExport InspTimer : public Extensible { private: /** The triggering time @@ -104,7 +104,7 @@ class InspTimer : public Extensible * This will ensure timers are not missed, as well as removing timers that have * expired and allowing the addition of new ones. */ -class TimerManager : public Extensible +class CoreExport TimerManager : public Extensible { protected: /** A group of timers all set to trigger at the same time diff --git a/include/typedefs.h b/include/typedefs.h index 840c840cf..d59c6ad7f 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -25,10 +25,15 @@ #include "modules.h" #include "globals.h" +#ifndef WIN32 typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash; typedef nspace::hash_map<std::string, chanrec*, nspace::hash<string>, irc::StrHashComp> chan_hash; +#else +typedef nspace::hash_map<std::string, userrec*, nspace::hash_compare<string, less<string> > > user_hash; +typedef nspace::hash_map<std::string, chanrec*, nspace::hash_compare<string, less<string> > > chan_hash; +#endif -typedef std::vector<std::string> servernamelist; +typedef std::vector<std::string*> servernamelist; typedef std::deque<std::string> file_cache; #endif diff --git a/include/users.h b/include/users.h index e12079315..e76c88676 100644 --- a/include/users.h +++ b/include/users.h @@ -46,7 +46,11 @@ enum UserModes { }; enum RegistrationState { + +#ifndef WIN32 // Burlex: This is already defined in win32, luckily it is still 0. REG_NONE = 0, /* Has sent nothing */ +#endif + REG_USER = 1, /* Has sent USER */ REG_NICK = 2, /* Has sent NICK */ REG_NICKUSER = 3, /* Bitwise combination of REG_NICK and REG_USER */ @@ -57,7 +61,7 @@ class InspIRCd; /** Derived from Resolver, and performs user forward/reverse lookups. */ -class UserResolver : public Resolver +class CoreExport UserResolver : public Resolver { private: /** User this class is 'attached' to. @@ -75,7 +79,7 @@ class UserResolver : public Resolver /** Holds information relevent to <connect allow> and <connect deny> tags in the config file. */ -class ConnectClass : public classbase +class CoreExport ConnectClass : public classbase { private: /** Type of line, either CC_ALLOW or CC_DENY @@ -249,7 +253,7 @@ typedef UserChanList::iterator UCListIter; class userrec; -class VisData +class CoreExport VisData { public: VisData(); @@ -264,7 +268,7 @@ class VisData * by nickname, or the FindDescriptor method of the InspIRCd class to find a specific user by their * file descriptor value. */ -class userrec : public connection +class CoreExport userrec : public connection { private: /** Pointer to creator. diff --git a/include/wildcard.h b/include/wildcard.h index 90660c6ef..196350134 100644 --- a/include/wildcard.h +++ b/include/wildcard.h @@ -13,7 +13,7 @@ #include "inspircd_config.h" -bool match(const char *str, const char *mask); -bool match(const char *str, const char *mask, bool use_cidr_match); -bool match(bool case_sensitive, const char *str, const char *mask); -bool match(bool case_sensitive, const char *str, const char *mask, bool use_cidr_match); +CoreExport bool match(const char *str, const char *mask); +CoreExport bool match(const char *str, const char *mask, bool use_cidr_match); +CoreExport bool match(bool case_sensitive, const char *str, const char *mask); +CoreExport bool match(bool case_sensitive, const char *str, const char *mask, bool use_cidr_match); diff --git a/include/xline.h b/include/xline.h index 0aa831670..0b4ef6e12 100644 --- a/include/xline.h +++ b/include/xline.h @@ -31,7 +31,7 @@ const int APPLY_ALL = APPLY_GLINES | APPLY_KLINES | APPLY_QLINES | APPLY_ZLINES /** XLine is the base class for ban lines such as G lines and K lines. */ -class XLine : public classbase +class CoreExport XLine : public classbase { public: @@ -71,7 +71,7 @@ class XLine : public classbase /** KLine class */ -class KLine : public XLine +class CoreExport KLine : public XLine { public: /** Hostmask (ident@host) to match against @@ -95,7 +95,7 @@ class KLine : public XLine /** GLine class */ -class GLine : public XLine +class CoreExport GLine : public XLine { public: /** Hostmask (ident@host) to match against @@ -119,7 +119,7 @@ class GLine : public XLine /** ELine class */ -class ELine : public XLine +class CoreExport ELine : public XLine { public: /** Hostmask (ident@host) to match against @@ -143,7 +143,7 @@ class ELine : public XLine /** ZLine class */ -class ZLine : public XLine +class CoreExport ZLine : public XLine { public: /** IP Address (xx.yy.zz.aa) to match against @@ -164,7 +164,7 @@ class ZLine : public XLine /** QLine class */ -class QLine : public XLine +class CoreExport QLine : public XLine { public: /** Nickname to match against. @@ -202,7 +202,7 @@ typedef std::pair<std::string, std::string> IdentHostPair; /** XLineManager is a class used to manage glines, klines, elines, zlines and qlines. */ -class XLineManager +class CoreExport XLineManager { protected: /** The owner/creator of this class |