From b56565eac2d7207c88c53054cb1096519ec7fba9 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 8 Apr 2011 03:48:43 -0400 Subject: Fixed Windows build on VS 2010 --- include/base.h | 5 ++- include/dns.h | 2 +- include/hashcomp.h | 20 ++++----- src/hashcomp.cpp | 2 +- src/inspircd.cpp | 2 +- src/inspsocket.cpp | 3 +- src/listensocket.cpp | 2 +- src/modules/m_filter.cpp | 7 +++- src/modules/m_spanningtree/idle.cpp | 78 ++++++++++++++++++++++++++++++++++++ src/modules/m_spanningtree/link.h | 1 - src/modules/m_spanningtree/whois.cpp | 78 ------------------------------------ src/modules/m_watch.cpp | 2 +- win/inspircdVC90.vcxproj | 12 +++--- win/inspircd_namedpipe.cpp | 2 +- win/inspircd_win32wrapper.cpp | 50 ++++++++++++++++++++++- win/inspircd_win32wrapper.h | 13 +++++- win/m_spanningtreeVC90.vcproj | 8 ++-- win/m_spanningtreeVC90.vcxproj | 35 +++++----------- 18 files changed, 186 insertions(+), 136 deletions(-) create mode 100644 src/modules/m_spanningtree/idle.cpp delete mode 100644 src/modules/m_spanningtree/whois.cpp diff --git a/include/base.h b/include/base.h index 7926779eb..385907887 100644 --- a/include/base.h +++ b/include/base.h @@ -112,7 +112,7 @@ class CoreExport usecountbase }; template -class reference +class CoreExport reference { T* value; public: @@ -141,8 +141,10 @@ class reference inline bool operator>(const reference& other) const { return value > other.value; } static inline void* operator new(size_t, void* m) { return m; } private: +#ifndef WIN32 static void* operator new(size_t); static void operator delete(void*); +#endif }; /** This class can be used on its own to represent an exception, or derived to represent a module-specific exception. @@ -189,6 +191,7 @@ class CoreExport CoreException : public std::exception } }; +class Module; class CoreExport ModuleException : public CoreException { public: diff --git a/include/dns.h b/include/dns.h index 528490015..b22a2032e 100644 --- a/include/dns.h +++ b/include/dns.h @@ -97,7 +97,7 @@ class CoreExport CachedQuery #if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED) typedef nspace::hash_map > dnscache; #else -typedef nspace::hash_map > dnscache; +typedef nspace::hash_map dnscache; #endif /** diff --git a/include/hashcomp.h b/include/hashcomp.h index bb3321161..07ec49a66 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -92,7 +92,7 @@ namespace irc * Case sensitivity is ignored, and the RFC 'character set' * is adhered to */ - struct StrHashComp + struct CoreExport StrHashComp { /** The operator () does the actual comparison in hash_map */ @@ -479,6 +479,15 @@ namespace irc * @return The new value with _ translated to space. */ CoreExport const char* Spacify(const char* n); + + struct hash + { + /** Hash an irc::string using RFC1459 case sensitivity rules + * @param s A string to hash + * @return The hash value + */ + size_t CoreExport operator()(const irc::string &s) const; + }; } /* Define operators for using >> and << with irc::string to an ostream on an istream. */ @@ -622,15 +631,6 @@ BEGIN_HASHMAP_NAMESPACE }; #else - template<> struct hash - { - /** Hash an irc::string using RFC1459 case sensitivity rules - * @param s A string to hash - * @return The hash value - */ - size_t CoreExport operator()(const irc::string &s) const; - }; - /* XXX FIXME: Implement a hash function overriding std::string's that works with TR1! */ #ifdef HASHMAP_DEPRECATED diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 0ef8d025f..b3b00248f 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -144,7 +144,7 @@ void nspace::strlower(char *n) #if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED) size_t nspace::hash_compare >::operator()(const irc::string &s) const #else - size_t CoreExport nspace::hash::operator()(const irc::string &s) const + size_t CoreExport irc::hash::operator()(const irc::string &s) const #endif { register size_t t = 0; diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 47a9fabba..2ac844bb6 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -615,7 +615,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : } #else WindowsIPC = new IPC; - if(!Config->nofork) + if(!Config->cmdline.nofork) { WindowsForkKillOwner(); FreeConsole(); diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 92625ac29..b872ea7e6 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -18,10 +18,11 @@ #ifndef DISABLE_WRITEV #include +#endif + #ifndef IOV_MAX #define IOV_MAX 1024 #endif -#endif BufferedSocket::BufferedSocket() { diff --git a/src/listensocket.cpp b/src/listensocket.cpp index 0bd6cb92b..df27a9c48 100644 --- a/src/listensocket.cpp +++ b/src/listensocket.cpp @@ -41,7 +41,7 @@ ListenSocket::ListenSocket(ConfigTag* tag, const irc::sockets::sockaddrs& bind_t if (bind_to.sa.sa_family == AF_INET6) { std::string addr = tag->getString("address"); - int enable = (addr.empty() || addr == "*") ? 0 : 1; + const char enable = (addr.empty() || addr == "*") ? 0 : 1; setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &enable, sizeof(enable)); // errors ignored intentionally } diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 69117ae55..e4b2645f9 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -165,7 +165,8 @@ CmdResult CommandFilter::Handle(const std::vector ¶meters, User if (parameters.size() == 1) { /* Deleting a filter */ - if (static_cast(*creator).DeleteFilter(parameters[0])) + Module *me = creator; + if (static_cast(me)->DeleteFilter(parameters[0])) { user->WriteServ("NOTICE %s :*** Removed filter '%s'", user->nick.c_str(), parameters[0].c_str()); ServerInstance->SNO->WriteToSnoMask(IS_LOCAL(user) ? 'a' : 'A', std::string("FILTER: ")+user->nick+" removed filter '"+parameters[0]+"'"); @@ -212,7 +213,9 @@ CmdResult CommandFilter::Handle(const std::vector ¶meters, User { reason = parameters[3]; } - std::pair result = static_cast(*creator).AddFilter(freeform, type, reason, duration, flags); + + Module *me = creator; + std::pair result = static_cast(me)->AddFilter(freeform, type, reason, duration, flags); if (result.first) { user->WriteServ("NOTICE %s :*** Added filter '%s', type '%s'%s%s, flags '%s', reason: '%s'", user->nick.c_str(), freeform.c_str(), diff --git a/src/modules/m_spanningtree/idle.cpp b/src/modules/m_spanningtree/idle.cpp new file mode 100644 index 000000000..59dc83985 --- /dev/null +++ b/src/modules/m_spanningtree/idle.cpp @@ -0,0 +1,78 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2010 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +#include "inspircd.h" +#include "socket.h" +#include "xline.h" +#include "socketengine.h" + +#include "main.h" +#include "utils.h" +#include "treeserver.h" +#include "treesocket.h" + +bool TreeSocket::Whois(const std::string &prefix, parameterlist ¶ms) +{ + if (params.size() < 1) + return true; + User* u = ServerInstance->FindNick(prefix); + if (u) + { + // an incoming request + if (params.size() == 1) + { + User* x = ServerInstance->FindNick(params[0]); + if ((x) && (IS_LOCAL(x))) + { + long idle = abs((long)((x->idle_lastmsg) - ServerInstance->Time())); + parameterlist par; + par.push_back(prefix); + par.push_back(ConvToStr(x->signon)); + par.push_back(ConvToStr(idle)); + // ours, we're done, pass it BACK + Utils->DoOneToOne(params[0], "IDLE", par, u->server); + } + else + { + // not ours pass it on + if (x) + Utils->DoOneToOne(prefix, "IDLE", params, x->server); + } + } + else if (params.size() == 3) + { + std::string who_did_the_whois = params[0]; + User* who_to_send_to = ServerInstance->FindNick(who_did_the_whois); + if ((who_to_send_to) && (IS_LOCAL(who_to_send_to))) + { + // an incoming reply to a whois we sent out + std::string nick_whoised = prefix; + unsigned long signon = atoi(params[1].c_str()); + unsigned long idle = atoi(params[2].c_str()); + if ((who_to_send_to) && (IS_LOCAL(who_to_send_to))) + { + ServerInstance->DoWhois(who_to_send_to, u, signon, idle, nick_whoised.c_str()); + } + } + else + { + // not ours, pass it on + if (who_to_send_to) + Utils->DoOneToOne(prefix, "IDLE", params, who_to_send_to->server); + } + } + } + return true; +} + + diff --git a/src/modules/m_spanningtree/link.h b/src/modules/m_spanningtree/link.h index 0ff2593cc..c60cb0bb7 100644 --- a/src/modules/m_spanningtree/link.h +++ b/src/modules/m_spanningtree/link.h @@ -45,5 +45,4 @@ class Autoconnect : public refcountbase Autoconnect(ConfigTag* Tag) : tag(Tag) {} }; - #endif diff --git a/src/modules/m_spanningtree/whois.cpp b/src/modules/m_spanningtree/whois.cpp deleted file mode 100644 index 59dc83985..000000000 --- a/src/modules/m_spanningtree/whois.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ - * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits - * - * This program is free but copyrighted software; see - * the file COPYING for details. - * - * --------------------------------------------------- - */ - -#include "inspircd.h" -#include "socket.h" -#include "xline.h" -#include "socketengine.h" - -#include "main.h" -#include "utils.h" -#include "treeserver.h" -#include "treesocket.h" - -bool TreeSocket::Whois(const std::string &prefix, parameterlist ¶ms) -{ - if (params.size() < 1) - return true; - User* u = ServerInstance->FindNick(prefix); - if (u) - { - // an incoming request - if (params.size() == 1) - { - User* x = ServerInstance->FindNick(params[0]); - if ((x) && (IS_LOCAL(x))) - { - long idle = abs((long)((x->idle_lastmsg) - ServerInstance->Time())); - parameterlist par; - par.push_back(prefix); - par.push_back(ConvToStr(x->signon)); - par.push_back(ConvToStr(idle)); - // ours, we're done, pass it BACK - Utils->DoOneToOne(params[0], "IDLE", par, u->server); - } - else - { - // not ours pass it on - if (x) - Utils->DoOneToOne(prefix, "IDLE", params, x->server); - } - } - else if (params.size() == 3) - { - std::string who_did_the_whois = params[0]; - User* who_to_send_to = ServerInstance->FindNick(who_did_the_whois); - if ((who_to_send_to) && (IS_LOCAL(who_to_send_to))) - { - // an incoming reply to a whois we sent out - std::string nick_whoised = prefix; - unsigned long signon = atoi(params[1].c_str()); - unsigned long idle = atoi(params[2].c_str()); - if ((who_to_send_to) && (IS_LOCAL(who_to_send_to))) - { - ServerInstance->DoWhois(who_to_send_to, u, signon, idle, nick_whoised.c_str()); - } - } - else - { - // not ours, pass it on - if (who_to_send_to) - Utils->DoOneToOne(prefix, "IDLE", params, who_to_send_to->server); - } - } - } - return true; -} - - diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 78da2799b..9a9e12bb1 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -90,7 +90,7 @@ #if defined(WINDOWS) && !defined(HASHMAP_DEPRECATED) typedef nspace::hash_map, nspace::hash_compare > > watchentries; #else - typedef nspace::hash_map, nspace::hash > watchentries; + typedef nspace::hash_map, irc::hash> watchentries; #endif typedef std::map watchlist; diff --git a/win/inspircdVC90.vcxproj b/win/inspircdVC90.vcxproj index 22682a09a..2b711e35f 100644 --- a/win/inspircdVC90.vcxproj +++ b/win/inspircdVC90.vcxproj @@ -1,4 +1,5 @@ - + + Debug @@ -484,6 +485,7 @@ nmake -f modules.mak true + @@ -498,7 +500,6 @@ nmake -f modules.mak - @@ -513,12 +514,14 @@ nmake -f modules.mak + + @@ -527,6 +530,7 @@ nmake -f modules.mak + @@ -995,9 +999,6 @@ nmake -f modules.mak true - - $(IntDir) - @@ -1130,7 +1131,6 @@ nmake -f modules.mak - diff --git a/win/inspircd_namedpipe.cpp b/win/inspircd_namedpipe.cpp index 76d16037b..46f462832 100644 --- a/win/inspircd_namedpipe.cpp +++ b/win/inspircd_namedpipe.cpp @@ -165,7 +165,7 @@ void IPC::Check() /* Toggle debug */ thread->SetResult(0); thread->ClearStatus(); - ServerInstance->Config->forcedebug = !ServerInstance->Config->forcedebug; + ServerInstance->Config->cmdline.forcedebug = !ServerInstance->Config->cmdline.forcedebug; break; } } diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp index d82c90a61..88ea338c6 100644 --- a/win/inspircd_win32wrapper.cpp +++ b/win/inspircd_win32wrapper.cpp @@ -238,7 +238,7 @@ int printf_c(const char * format, ...) int optind = 1; char optarg[514]; -int getopt_long_only(int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind) +int getopt_long(int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind) { // burlex todo: handle the shortops, at the moment it only works with longopts. @@ -556,7 +556,7 @@ int clock_gettime(int clock, struct timespec * tv) DWORD mstime = timeGetTime(); tv->tv_sec = time(NULL); - tv->tv_usec = (mstime - (tv->tv_sec * 1000)) * 1000000; + tv->tv_nsec = (mstime - (tv->tv_sec * 1000)) * 1000000; return 0; } @@ -696,3 +696,49 @@ int getcpu() return cpu; } + +int random() +{ + return rand(); +} + +void srandom(unsigned int seed) +{ + srand(seed); +} + +int gettimeofday(timeval *tv, void *) +{ + SYSTEMTIME st; + GetSystemTime(&st); + + tv->tv_sec = ServerInstance->Time(); + tv->tv_usec = st.wMilliseconds; + + return 0; +} + +/* World's largest hack to make m_spanningtree work */ +#include "../src/modules/m_spanningtree/link.h" +static void unused_Function() +{ + reference unused_Link; + reference unused_Autoconnect; + + if (unused_Link) + unused_Link->Port = -1; + if (unused_Autoconnect) + unused_Autoconnect->NextConnectTime = -1; + + Autoconnect *a = unused_Autoconnect; + Link *l = unused_Link; + + unused_Link = reference(unused_Link); + unused_Autoconnect = reference(unused_Autoconnect); + + unused_Link = reference(l); + unused_Autoconnect = reference(a); + + delete unused_Link; + delete unused_Autoconnect; +} diff --git a/win/inspircd_win32wrapper.h b/win/inspircd_win32wrapper.h index 3f16280fd..36307ee00 100644 --- a/win/inspircd_win32wrapper.h +++ b/win/inspircd_win32wrapper.h @@ -140,6 +140,8 @@ CoreExport const char * insp_inet_ntop(int af, const void * src, char * dst, soc /* Since when does the ISO C++ standard *remove* C functions?! */ #define mkdir(file,mode) _mkdir(file) +#define strncasecmp strnicmp + /* Unix-style sleep (argument is in seconds) */ __inline void sleep(int seconds) { Sleep(seconds * 1000); } @@ -165,7 +167,7 @@ struct option }; extern int optind; extern char optarg[514]; -int getopt_long_only (int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind); +int getopt_long(int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind); /* Module Loading */ #define dlopen(path, state) (void*)LoadLibrary(path) @@ -189,6 +191,12 @@ struct DIR bool first; }; +struct timespec +{ + time_t tv_sec; + long tv_nsec; +}; + CoreExport DIR * opendir(const char * path); CoreExport dirent * readdir(DIR * handle); CoreExport void closedir(DIR * handle); @@ -246,6 +254,9 @@ CoreExport void FindDNS(std::string& server); CoreExport bool initwmi(); CoreExport void donewmi(); CoreExport int getcpu(); +CoreExport int random(); +CoreExport void srandom(unsigned seed); +CoreExport int gettimeofday(timeval *tv, void *); #endif diff --git a/win/m_spanningtreeVC90.vcproj b/win/m_spanningtreeVC90.vcproj index 785416986..294d81146 100644 --- a/win/m_spanningtreeVC90.vcproj +++ b/win/m_spanningtreeVC90.vcproj @@ -66,7 +66,7 @@ /> + + Debug @@ -113,7 +114,7 @@ true - ws2_32.lib;inspircd.lib;cmd_whois.lib;cmd_stats.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;%(AdditionalDependencies) + ws2_32.lib;inspircd.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;%(AdditionalDependencies) ..\bin\debug\bin;..\bin\debug\lib;%(AdditionalLibraryDirectories) true $(OutDir)m_spanningtree.pdb @@ -142,7 +143,7 @@ ProgramDatabase - ws2_32.lib;inspircd.lib;cmd_whois.lib;cmd_stats.lib;%(AdditionalDependencies) + ws2_32.lib;inspircd.lib;%(AdditionalDependencies) ..\bin\debug_x64\bin;..\bin\debug_x64\lib;%(AdditionalLibraryDirectories) true $(OutDir)m_spanningtree.pdb @@ -159,7 +160,7 @@ /MP %(AdditionalOptions) MinSpace true - ..\include;..\win;..\src\modules\m_spanningtree;.;..\src\modules;%(AdditionalIncludeDirectories) + ..\include;..\win;.;..\src\modules;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;M_SPANNINGTREE_EXPORTS;DLL_BUILD;%(PreprocessorDefinitions) false MultiThreadedDLL @@ -169,7 +170,7 @@ ProgramDatabase - ws2_32.lib;inspircd.lib;cmd_whois.lib;cmd_stats.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;%(AdditionalDependencies) + ws2_32.lib;inspircd.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;%(AdditionalDependencies) ..\bin\release\bin;..\bin\release\lib;%(AdditionalLibraryDirectories) true Windows @@ -205,7 +206,7 @@ ProgramDatabase - ws2_32.lib;inspircd.lib;cmd_whois.lib;cmd_stats.lib;%(AdditionalDependencies) + ws2_32.lib;inspircd.lib;%(AdditionalDependencies) ..\bin\release_x64\bin;..\bin\release_x64\lib;%(AdditionalLibraryDirectories) true Windows @@ -220,67 +221,53 @@ - + + - - - - + - - $(IntDir)modules_spanningtree.obj - - - - - - - + $(IntDir)servers_spanningtree.obj - - - - -- cgit v1.2.3