mirror of
https://github.com/anope/anope.git
synced 2026-06-12 19:14:47 +02:00
Fixed some Windows issues with hashing and sockets. This currently limits building to VS 2010, will look at 2008 later
This commit is contained in:
+10
-12
@@ -45,15 +45,9 @@ namespace Anope
|
||||
# define unordered_map hash_map
|
||||
# endif
|
||||
#else
|
||||
# if _MSV_VER >= 1600
|
||||
/* MSVC 2010+ has tr1. Though MSVC and GCC use different includes! */
|
||||
# include <unordered_map>
|
||||
# define unordered_map_namespace std::tr1
|
||||
# else
|
||||
# include <hash_map>
|
||||
# define unordered_map_namespace stdext
|
||||
# define unordered_map hash_map
|
||||
# endif
|
||||
# include <unordered_map>
|
||||
# define unordered_map_namespace std::tr1
|
||||
#endif
|
||||
|
||||
/*******************************************************
|
||||
@@ -247,8 +241,9 @@ namespace std
|
||||
/** An overload for std::equal_to<ci::string> that uses Anope::string, passed for the fourth temmplate
|
||||
* argument for unordered_map
|
||||
*/
|
||||
template<> struct equal_to<ci::string>
|
||||
template<> class CoreExport equal_to<ci::string>
|
||||
{
|
||||
public:
|
||||
/** Compare two Anope::strings as ci::strings
|
||||
* @paarm s1 The first string
|
||||
* @param s2 The second string
|
||||
@@ -260,8 +255,9 @@ namespace std
|
||||
/** An overload for std::equal_to<irc::string> that uses Anope::string, passed for the fourth template
|
||||
* argument for unorderd_map
|
||||
*/
|
||||
template<> struct equal_to<irc::string>
|
||||
template<> class CoreExport equal_to<irc::string>
|
||||
{
|
||||
public:
|
||||
/** Compare two Anope::strings as irc::strings
|
||||
* @param s1 The first string
|
||||
* @param s2 The second string
|
||||
@@ -273,8 +269,9 @@ namespace std
|
||||
/** An overload for std::less<ci::string> that uses Anope::string, passed for the third template argument
|
||||
* to std::map and std::multimap
|
||||
*/
|
||||
template<> struct less<ci::string>
|
||||
template<> class CoreExport less<ci::string>
|
||||
{
|
||||
public:
|
||||
/** Compare two Anope::strings as ci::strings and find which one is less
|
||||
* @param s1 The first string
|
||||
* @param s2 The second string
|
||||
@@ -286,8 +283,9 @@ namespace std
|
||||
/** An overload for std;:less<irc::string> that uses Anope::string, passed for the third tempalte argument
|
||||
* to std::map and std::multimap
|
||||
*/
|
||||
template<> struct less<irc::string>
|
||||
template<> class CoreExport less<irc::string>
|
||||
{
|
||||
public:
|
||||
/** Compare two Anope::strings as irc::strings and find which one is less
|
||||
* @param s1 The first string
|
||||
* @param s2 The second string
|
||||
|
||||
@@ -15,16 +15,20 @@
|
||||
class CoreExport SocketEngineBase
|
||||
{
|
||||
public:
|
||||
#ifdef _WIN32
|
||||
/* Windows crap */
|
||||
WSADATA wsa;
|
||||
#endif
|
||||
/* Map of sockets */
|
||||
std::map<int, Socket *> Sockets;
|
||||
|
||||
/** Default constructor
|
||||
*/
|
||||
SocketEngineBase() { }
|
||||
SocketEngineBase();
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
virtual ~SocketEngineBase() { }
|
||||
virtual ~SocketEngineBase();
|
||||
|
||||
/** Add a socket to the internal list
|
||||
* @param s The socket
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@
|
||||
/* Hash maps used for users. Note UserListByUID will not be used on non-TS6 IRCds, and should never
|
||||
* be assumed to have users
|
||||
*/
|
||||
typedef unordered_map_namespace::unordered_map<Anope::string, User *, ci::hash, std::less<ci::string> > user_map;
|
||||
typedef unordered_map_namespace::unordered_map<Anope::string, User *, ci::hash, std::less<ci::string> > user_uid_map;
|
||||
typedef unordered_map_namespace::unordered_map<Anope::string, User *, ci::hash, std::equal_to<ci::string> > user_map;
|
||||
typedef unordered_map_namespace::unordered_map<Anope::string, User *, Anope::hash> user_uid_map;
|
||||
|
||||
extern CoreExport user_map UserListByNick;
|
||||
extern CoreExport user_uid_map UserListByUID;
|
||||
|
||||
+1
-1
@@ -197,7 +197,7 @@ bool std::less<ci::string>::operator()(const Anope::string &s1, const Anope::str
|
||||
*/
|
||||
bool std::less<irc::string>::operator()(const Anope::string &s1, const Anope::string &s2) const
|
||||
{
|
||||
return s2.irc_str().compare(s2.irc_str()) < 0;
|
||||
return s1.irc_str().compare(s2.irc_str()) < 0;
|
||||
}
|
||||
|
||||
sepstream::sepstream(const Anope::string &source, char seperator) : tokens(source), sep(seperator)
|
||||
|
||||
+6
-6
@@ -84,7 +84,7 @@ static void load_lang(int index, const char *filename)
|
||||
}
|
||||
else if (num != NUM_STRINGS)
|
||||
Alog() << "Warning: Bad number of strings (" << num << " , wanted " << NUM_STRINGS << ") for language " << index << " (" << filename << ")";
|
||||
langtexts[index] = new char *[NUM_STRINGS];
|
||||
langtexts[index] = static_cast<char **>(scalloc(sizeof(char *), NUM_STRINGS));
|
||||
if (num > NUM_STRINGS)
|
||||
num = NUM_STRINGS;
|
||||
for (i = 0; i < num; ++i)
|
||||
@@ -99,7 +99,7 @@ static void load_lang(int index, const char *filename)
|
||||
if (langtexts[index][i])
|
||||
free(langtexts[index][i]); // XXX
|
||||
}
|
||||
delete [] langtexts[index];
|
||||
free(langtexts[index]);
|
||||
langtexts[index] = NULL;
|
||||
return;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ static void load_lang(int index, const char *filename)
|
||||
if (langtexts[index][i])
|
||||
free(langtexts[index][i]); // XXX
|
||||
}
|
||||
delete [] langtexts[index];
|
||||
free(langtexts[index]);
|
||||
langtexts[index] = NULL;
|
||||
return;
|
||||
}
|
||||
@@ -125,13 +125,13 @@ static void load_lang(int index, const char *filename)
|
||||
if (langtexts[index][i])
|
||||
free(langtexts[index][i]); // XXX
|
||||
}
|
||||
delete [] langtexts[index];
|
||||
free(langtexts[index]);
|
||||
langtexts[index] = NULL;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
langtexts[index][i] = new char[len + 1];
|
||||
langtexts[index][i] = static_cast<char *>(malloc(len + 1));
|
||||
fseek(f, pos, SEEK_SET);
|
||||
if (fread(langtexts[index][i], 1, len, f) != len)
|
||||
{
|
||||
@@ -141,7 +141,7 @@ static void load_lang(int index, const char *filename)
|
||||
if (langtexts[index][i])
|
||||
free(langtexts[index][i]);
|
||||
}
|
||||
delete [] langtexts[index];
|
||||
free(langtexts[index]);
|
||||
langtexts[index] = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
#include "services.h"
|
||||
#include "language.h"
|
||||
#include "hashcomp.h" // If this gets added to services.h or someplace else later, remove it from here -- CyberBotX
|
||||
|
||||
/* Cheaper than isspace() or isblank() */
|
||||
#define issp(c) ((c) == 32)
|
||||
|
||||
+15
-3
@@ -15,6 +15,21 @@ static void TrimBuf(std::string &buffer)
|
||||
buffer.erase(buffer.length() - 1);
|
||||
}
|
||||
|
||||
SocketEngineBase::SocketEngineBase()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (WSAStartup(MAKEWORD(2, 0), &wsa))
|
||||
Alog() << "Failed to initialize WinSock library";
|
||||
#endif
|
||||
}
|
||||
|
||||
SocketEngineBase::~SocketEngineBase()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Constructor
|
||||
* @param nsock The socket
|
||||
* @param nIPv6 IPv6?
|
||||
@@ -232,9 +247,6 @@ void Socket::Write(const Anope::string &message)
|
||||
*/
|
||||
ClientSocket::ClientSocket(const Anope::string &nTargetHost, int nPort, const Anope::string &nBindHost, bool nIPv6) : Socket(0, nIPv6), TargetHost(nTargetHost), Port(nPort), BindHost(nBindHost)
|
||||
{
|
||||
if (!IPv6 && (TargetHost.find(':') != Anope::string::npos || BindHost.find(':') != Anope::string::npos))
|
||||
IPv6 = true;
|
||||
|
||||
addrinfo hints;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = 0;
|
||||
|
||||
Reference in New Issue
Block a user