summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt14
-rw-r--r--include/account.h14
-rw-r--r--include/anope.h14
-rw-r--r--include/bots.h10
-rw-r--r--include/channels.h14
-rw-r--r--include/commands.h2
-rw-r--r--include/config.h2
-rw-r--r--include/defs.h4
-rw-r--r--include/extensible.h2
-rw-r--r--include/extern.h13
-rw-r--r--include/modules.h2
-rw-r--r--include/protocol.h12
-rw-r--r--include/regchannel.h11
-rw-r--r--include/serialize.h2
-rw-r--r--include/services.h21
-rw-r--r--include/sockets.h8
-rw-r--r--include/uplink.h2
-rw-r--r--include/users.h19
-rw-r--r--modules/commands/ns_register.cpp5
-rw-r--r--modules/database/db_flatfile.cpp1
-rw-r--r--modules/database/db_plain.cpp1
-rw-r--r--modules/extra/m_httpd.cpp2
-rw-r--r--modules/extra/webcpanel/pages/index.cpp2
-rw-r--r--modules/extra/webcpanel/static_fileserver.cpp1
-rw-r--r--modules/extra/webcpanel/template_fileserver.cpp1
-rw-r--r--modules/pseudoclients/nickserv.cpp2
-rw-r--r--src/actions.cpp1
-rw-r--r--src/botserv.cpp1
-rw-r--r--src/chanserv.cpp1
-rw-r--r--src/dns.cpp2
-rw-r--r--src/encrypt.cpp1
-rw-r--r--src/init.cpp3
-rw-r--r--src/logger.cpp2
-rw-r--r--src/main.cpp5
-rw-r--r--src/misc.cpp2
-rw-r--r--src/modulemanager.cpp5
-rw-r--r--src/operserv.cpp6
-rw-r--r--src/socketengines/pipeengine_pipe.cpp5
-rw-r--r--src/sockets.cpp5
-rw-r--r--src/threadengine.cpp2
-rw-r--r--src/win32/anope_windows.h16
-rw-r--r--src/win32/dl/dl.cpp1
-rw-r--r--src/win32/pipe/pipe.cpp21
-rw-r--r--src/win32/socket.h1
-rw-r--r--src/win32/windows.cpp6
45 files changed, 152 insertions, 115 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a1a5c9b6b..46e853b12 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -382,25 +382,25 @@ endif(INSTDIR)
# Set default paths for various directories if not already defined
if(NOT BIN_DIR)
- set(BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin")
+ set(BIN_DIR "bin")
endif(NOT BIN_DIR)
if(NOT DB_DIR)
- set(DB_DIR "${CMAKE_INSTALL_PREFIX}/data")
+ set(DB_DIR "data")
endif(NOT DB_DIR)
if(NOT DOC_DIR)
- set(DOC_DIR "${CMAKE_INSTALL_PREFIX}/doc")
+ set(DOC_DIR "doc")
endif(NOT DOC_DIR)
if(NOT CONF_DIR)
- set(CONF_DIR "${CMAKE_INSTALL_PREFIX}/conf")
+ set(CONF_DIR "conf")
endif(NOT CONF_DIR)
if(NOT LIB_DIR)
- set(LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
+ set(LIB_DIR "lib")
endif(NOT LIB_DIR)
if(NOT LOCALE_DIR)
- set(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/locale")
+ set(LOCALE_DIR "locale")
endif(NOT LOCALE_DIR)
if(NOT LOGS_DIR)
- set(LOGS_DIR "${CMAKE_INSTALL_PREFIX}/logs")
+ set(LOGS_DIR "logs")
endif(NOT LOGS_DIR)
# Version number processing
diff --git a/include/account.h b/include/account.h
index 756c97348..ff9c70727 100644
--- a/include/account.h
+++ b/include/account.h
@@ -23,8 +23,8 @@
typedef Anope::insensitive_map<NickAlias *> nickalias_map;
typedef Anope::insensitive_map<NickCore *> nickcore_map;
-extern serialize_checker<nickalias_map> NickAliasList;
-extern serialize_checker<nickcore_map> NickCoreList;
+extern CoreExport serialize_checker<nickalias_map> NickAliasList;
+extern CoreExport serialize_checker<nickcore_map> NickCoreList;
/* NickServ nickname structures. */
@@ -309,11 +309,11 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
};
-extern void change_core_display(NickCore *nc);
-extern void change_core_display(NickCore *nc, const Anope::string &newdisplay);
+extern CoreExport void change_core_display(NickCore *nc);
+extern CoreExport void change_core_display(NickCore *nc, const Anope::string &newdisplay);
-extern NickAlias *findnick(const Anope::string &nick);
-extern NickCore *findcore(const Anope::string &nick);
-extern bool is_on_access(const User *u, const NickCore *nc);
+extern CoreExport NickAlias *findnick(const Anope::string &nick);
+extern CoreExport NickCore *findcore(const Anope::string &nick);
+extern CoreExport bool is_on_access(const User *u, const NickCore *nc);
#endif // ACCOUNT_H
diff --git a/include/anope.h b/include/anope.h
index 2ec6602ea..e67fafc8d 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -23,7 +23,7 @@ namespace Anope
* allow us to only require one type of string everywhere that can be converted
* at any time to a specific type of string.
*/
- class string
+ class CoreExport string
{
private:
/**
@@ -589,6 +589,18 @@ template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr)
#endif
}
+template<typename T, typename O> inline T anope_dynamic_reinterpret_cast(O ptr)
+{
+#ifdef DEBUG_BUILD
+ T ret = dynamic_cast<T>(ptr);
+ if (ptr != NULL && ret == NULL)
+ throw CoreException(Anope::string("anope_dynamic_reinterpret_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail");
+ return ret;
+#else
+ return reinterpret_cast<T>(ptr);
+#endif
+}
+
/*************************************************************************/
/** Class with the ability to keep flags on items, they should extend from this
diff --git a/include/bots.h b/include/bots.h
index 749e4c92d..521ab8c03 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -17,8 +17,8 @@
typedef Anope::insensitive_map<BotInfo *> botinfo_map;
typedef Anope::map<BotInfo *> botinfouid_map;
-extern serialize_checker<botinfo_map> BotListByNick;
-extern serialize_checker<botinfouid_map> BotListByUID;
+extern CoreExport serialize_checker<botinfo_map> BotListByNick;
+extern CoreExport serialize_checker<botinfouid_map> BotListByUID;
/** Flags settable on a bot
*/
@@ -132,9 +132,9 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se
CommandInfo *GetCommand(const Anope::string &cname);
};
-extern BotInfo *findbot(const Anope::string &nick);
+extern CoreExport BotInfo *findbot(const Anope::string &nick);
-extern void bot_raw_ban(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
-extern void bot_raw_kick(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
+extern CoreExport void bot_raw_ban(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
+extern CoreExport void bot_raw_kick(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
#endif // BOTS_H
diff --git a/include/channels.h b/include/channels.h
index bcde363fc..dbc71129d 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -246,15 +246,15 @@ class CoreExport Channel : public virtual Base, public Extensible, public Flags<
void Hold();
};
-extern Channel *findchan(const Anope::string &chan);
+extern CoreExport Channel *findchan(const Anope::string &chan);
-extern User *nc_on_chan(Channel *c, const NickCore *nc);
+extern CoreExport User *nc_on_chan(Channel *c, const NickCore *nc);
-extern void do_cmode(const Anope::string &source, const Anope::string &channel, const Anope::string &modes, const Anope::string &ts);
-extern void do_join(const Anope::string &source, const Anope::string &channels, const Anope::string &ts);
-extern void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason);
-extern void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason);
+extern CoreExport void do_cmode(const Anope::string &source, const Anope::string &channel, const Anope::string &modes, const Anope::string &ts);
+extern CoreExport void do_join(const Anope::string &source, const Anope::string &channels, const Anope::string &ts);
+extern CoreExport void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason);
+extern CoreExport void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason);
-extern void chan_set_correct_modes(const User *user, Channel *c, int give_modes);
+extern CoreExport void chan_set_correct_modes(const User *user, Channel *c, int give_modes);
#endif // CHANNELS_H
diff --git a/include/commands.h b/include/commands.h
index d644ea8cb..c3a412624 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -142,6 +142,6 @@ class CoreExport Command : public Service, public Flags<CommandFlag>
virtual void OnSyntaxError(CommandSource &source, const Anope::string &subcommand);
};
-extern void RunCommand(CommandSource &source, const Anope::string &message);
+extern CoreExport void RunCommand(CommandSource &source, const Anope::string &message);
#endif // COMMANDS_H
diff --git a/include/config.h b/include/config.h
index 0ab3c287b..e37028bcf 100644
--- a/include/config.h
+++ b/include/config.h
@@ -805,6 +805,6 @@ class CoreExport ConfigReader
};
extern ConfigurationFile services_conf;
-extern ServerConfig *Config;
+extern CoreExport ServerConfig *Config;
#endif // CONFIG_H
diff --git a/include/defs.h b/include/defs.h
index db3c801ed..2df0a2c15 100644
--- a/include/defs.h
+++ b/include/defs.h
@@ -21,6 +21,7 @@ class ChannelInfo;
class ChannelStatus;
class ClientSocket;
class Command;
+class CommandSource;
class ConnectionSocket;
class DNSPacket;
class dynamic_reference_base;
@@ -42,13 +43,12 @@ class ServerConfig;
class Socket;
class Thread;
class User;
+class XLine;
class XLineManager;
struct BadWord;
-struct CommandSource;
struct DNSQuery;
struct Exception;
struct MemoInfo;
struct ModeLock;
struct Oper;
-struct XLine;
diff --git a/include/extensible.h b/include/extensible.h
index 5d0cdafa5..162a2cf6f 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -95,7 +95,7 @@ class CoreExport Extensible
{
extensible_map::const_iterator it = this->extension_items.find(key);
if (it != this->extension_items.end())
- return anope_dynamic_static_cast<T>(it->second);
+ return anope_dynamic_reinterpret_cast<T>(it->second);
return NULL;
}
diff --git a/include/extern.h b/include/extern.h
index 29f84c850..5eb7dcb58 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -23,19 +23,6 @@
E bool bad_password(User *u);
E void common_unban(const ChannelInfo *ci, User *u, bool full = false);
-/**** channels.c ****/
-
-E Channel *findchan(const Anope::string &chan);
-
-E User *nc_on_chan(Channel *c, const NickCore *nc);
-
-E void do_cmode(const Anope::string &source, const Anope::string &channel, const Anope::string &modes, const Anope::string &ts);
-E void do_join(const Anope::string &source, const Anope::string &channels, const Anope::string &ts);
-E void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason);
-E void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason);
-
-E void chan_set_correct_modes(const User *user, Channel *c, int give_modes);
-
/**** encrypt.c ****/
E void enc_encrypt(const Anope::string &src, Anope::string &dest);
diff --git a/include/modules.h b/include/modules.h
index ae7ab139a..939b98b34 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -1111,7 +1111,7 @@ class CoreExport ModuleManager
/** Class used for callbacks within modules
*/
-class CallBack : public Timer
+class CoreExport CallBack : public Timer
{
private:
Module *m;
diff --git a/include/protocol.h b/include/protocol.h
index b471ce23f..5fb9da403 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -144,12 +144,12 @@ class CoreExport IRCdMessage
virtual bool OnError(const Anope::string &, const std::vector<Anope::string> &);
};
-extern IRCDVar *ircd;
-extern IRCDProto *ircdproto;
-extern IRCdMessage *ircdmessage;
+extern CoreExport IRCDVar *ircd;
+extern CoreExport IRCDProto *ircdproto;
+extern CoreExport IRCdMessage *ircdmessage;
-extern void pmodule_ircd_proto(IRCDProto *);
-extern void pmodule_ircd_var(IRCDVar *ircdvar);
-extern void pmodule_ircd_message(IRCdMessage *message);
+extern CoreExport void pmodule_ircd_proto(IRCDProto *);
+extern CoreExport void pmodule_ircd_var(IRCDVar *ircdvar);
+extern CoreExport void pmodule_ircd_message(IRCdMessage *message);
#endif // PROTOCOL_H
diff --git a/include/regchannel.h b/include/regchannel.h
index 255bcc200..9640a6735 100644
--- a/include/regchannel.h
+++ b/include/regchannel.h
@@ -16,10 +16,11 @@
#include "logger.h"
#include "modules.h"
#include "serialize.h"
+#include "bots.h"
typedef Anope::insensitive_map<ChannelInfo *> registered_channel_map;
-extern serialize_checker<registered_channel_map> RegisteredChannelList;
+extern CoreExport serialize_checker<registered_channel_map> RegisteredChannelList;
/** Flags used for the ChannelInfo class
*/
@@ -441,9 +442,9 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
void ClearLevels();
};
-extern ChannelInfo *cs_findchan(const Anope::string &chan);
-extern bool IsFounder(const User *user, const ChannelInfo *ci);
-extern void update_cs_lastseen(User *user, ChannelInfo *ci);
-extern int get_idealban(const ChannelInfo *ci, User *u, Anope::string &ret);
+extern CoreExport ChannelInfo *cs_findchan(const Anope::string &chan);
+extern CoreExport bool IsFounder(const User *user, const ChannelInfo *ci);
+extern CoreExport void update_cs_lastseen(User *user, ChannelInfo *ci);
+extern CoreExport int get_idealban(const ChannelInfo *ci, User *u, Anope::string &ret);
#endif // REGCHANNEL_H
diff --git a/include/serialize.h b/include/serialize.h
index 1b932c17d..5f8801854 100644
--- a/include/serialize.h
+++ b/include/serialize.h
@@ -27,7 +27,7 @@ namespace Serialize
};
}
-class stringstream : public std::stringstream
+class CoreExport stringstream : public std::stringstream
{
private:
Serialize::DataType type;
diff --git a/include/services.h b/include/services.h
index 31ab1cf37..4b21bac2a 100644
--- a/include/services.h
+++ b/include/services.h
@@ -28,6 +28,10 @@
# include <strings.h>
#endif
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
/* Pull in the various bits of STL */
#include <iostream>
#include <fstream>
@@ -45,14 +49,6 @@
#define _(x) x
-#ifndef _WIN32
-# define DllExport
-# define CoreExport
-# define MARK_DEPRECATED __attribute((deprecated))
-#else
-# include "anope_windows.h"
-#endif
-
#ifdef __GXX_EXPERIMENTAL_CXX0X__
# define anope_override override
# define anope_final final
@@ -61,6 +57,15 @@
# define anope_final
#endif
+#ifndef _WIN32
+# define DllExport
+# define CoreExport
+# define MARK_DEPRECATED __attribute((deprecated))
+# define anope_close close
+#else
+# include "anope_windows.h"
+#endif
+
/**
* RFC: defination of a valid nick
* nickname = ( letter / special ) *8( letter / digit / special / "-" )
diff --git a/include/sockets.h b/include/sockets.h
index 8f863b59c..8b669bbde 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -12,9 +12,11 @@
#ifndef SOCKETS_H
#define SOCKETS_H
+#ifndef _WIN32
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
+#endif
#include "anope.h"
@@ -482,8 +484,8 @@ class CoreExport Pipe : public Socket
virtual void OnNotify() = 0;
};
-extern uint32_t TotalRead;
-extern uint32_t TotalWritten;
-extern SocketIO normalSocketIO;
+extern CoreExport uint32_t TotalRead;
+extern CoreExport uint32_t TotalWritten;
+extern CoreExport SocketIO normalSocketIO;
#endif // SOCKET_H
diff --git a/include/uplink.h b/include/uplink.h
index 70b20a28b..617a8aa1a 100644
--- a/include/uplink.h
+++ b/include/uplink.h
@@ -42,7 +42,7 @@ class UplinkSocket : public ConnectionSocket, public BufferedSocket
}
};
};
-extern UplinkSocket *UplinkSock;
+extern CoreExport UplinkSocket *UplinkSock;
#endif // UPLINK_H
diff --git a/include/users.h b/include/users.h
index d0b38025e..fab5fa868 100644
--- a/include/users.h
+++ b/include/users.h
@@ -13,6 +13,7 @@
#include "extensible.h"
#include "serialize.h"
#include "commands.h"
+#include "account.h"
extern CoreExport Anope::insensitive_map<User *> UserListByNick;
extern CoreExport Anope::map<User *> UserListByUID;
@@ -303,19 +304,19 @@ class CoreExport User : public virtual Base, public Extensible, public CommandRe
void Kill(const Anope::string &source, const Anope::string &reason);
};
-extern int32_t opcnt;
-extern uint32_t maxusercnt, usercnt;
-extern time_t maxusertime;
+extern CoreExport int32_t opcnt;
+extern CoreExport uint32_t maxusercnt, usercnt;
+extern CoreExport time_t maxusertime;
-extern User *finduser(const Anope::string &nick);
+extern CoreExport User *finduser(const Anope::string &nick);
-extern User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid, const Anope::string &modes);
+extern CoreExport User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid, const Anope::string &modes);
-extern void do_umode(const Anope::string &user, const Anope::string &modes);
-extern void do_kill(User *user, const Anope::string &reason);
+extern CoreExport void do_umode(const Anope::string &user, const Anope::string &modes);
+extern CoreExport void do_kill(User *user, const Anope::string &reason);
-extern bool matches_list(Channel *c, User *user, ChannelModeName mode);
+extern CoreExport bool matches_list(Channel *c, User *user, ChannelModeName mode);
-extern Anope::string create_mask(User *u);
+extern CoreExport Anope::string create_mask(User *u);
#endif // USERS_H
diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp
index 1a219c8ba..953fd2d89 100644
--- a/modules/commands/ns_register.cpp
+++ b/modules/commands/ns_register.cpp
@@ -191,9 +191,10 @@ class CommandNSRegister : public Command
na->last_realname = u->realname;
u->Login(nc);
+
+ if (Config->NSAddAccessOnReg)
+ nc->AddAccess(create_mask(u));
}
- if (Config->NSAddAccessOnReg)
- nc->AddAccess(create_mask(u));
Log(LOG_COMMAND, source, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")";
diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp
index 185f4aef7..a4ab5ce9a 100644
--- a/modules/database/db_flatfile.cpp
+++ b/modules/database/db_flatfile.cpp
@@ -11,7 +11,6 @@
/*************************************************************************/
#include "module.h"
-#include <unistd.h>
class DBFlatFile : public Module
{
diff --git a/modules/database/db_plain.cpp b/modules/database/db_plain.cpp
index fc24ae4c7..1017db8cc 100644
--- a/modules/database/db_plain.cpp
+++ b/modules/database/db_plain.cpp
@@ -12,7 +12,6 @@
#include "module.h"
#include "../commands/os_session.h"
-#include <unistd.h>
Anope::string DatabaseFile;
Anope::string BackupFile;
diff --git a/modules/extra/m_httpd.cpp b/modules/extra/m_httpd.cpp
index aec3ce4a1..626a62e8c 100644
--- a/modules/extra/m_httpd.cpp
+++ b/modules/extra/m_httpd.cpp
@@ -12,7 +12,7 @@ static Anope::string BuildDate()
{
char timebuf[64];
struct tm *tm = localtime(&Anope::CurTime);
- strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %T %Z", tm);
+ strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S %Z", tm);
return timebuf;
}
diff --git a/modules/extra/webcpanel/pages/index.cpp b/modules/extra/webcpanel/pages/index.cpp
index 525e564f6..e0db8f8de 100644
--- a/modules/extra/webcpanel/pages/index.cpp
+++ b/modules/extra/webcpanel/pages/index.cpp
@@ -34,7 +34,7 @@ void WebCPanel::Index::OnRequest(HTTPProvider *server, const Anope::string &page
{
char c;
do
- c = 48 + (rand() % 123);
+ c = 48 + (rand() % 75);
while (!isalnum(c));
id += c;
}
diff --git a/modules/extra/webcpanel/static_fileserver.cpp b/modules/extra/webcpanel/static_fileserver.cpp
index 3f51c8b40..6e6d5ccd4 100644
--- a/modules/extra/webcpanel/static_fileserver.cpp
+++ b/modules/extra/webcpanel/static_fileserver.cpp
@@ -12,7 +12,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <unistd.h>
StaticFileServer::StaticFileServer(const Anope::string &f_n, const Anope::string &u, const Anope::string &c_t) : HTTPPage(u, c_t), file_name(f_n)
{
diff --git a/modules/extra/webcpanel/template_fileserver.cpp b/modules/extra/webcpanel/template_fileserver.cpp
index d3a974391..45dc4dadd 100644
--- a/modules/extra/webcpanel/template_fileserver.cpp
+++ b/modules/extra/webcpanel/template_fileserver.cpp
@@ -13,7 +13,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <unistd.h>
struct ForLoop
{
diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp
index 027317b7c..34b945f08 100644
--- a/modules/pseudoclients/nickserv.cpp
+++ b/modules/pseudoclients/nickserv.cpp
@@ -25,7 +25,7 @@ static nickservreleases_map NickServReleases;
/** Timer for colliding nicks to force people off of nicknames
*/
-class CoreExport NickServCollide : public Timer
+class NickServCollide : public Timer
{
dynamic_reference<User> u;
Anope::string nick;
diff --git a/src/actions.cpp b/src/actions.cpp
index 657973e3c..512a0fa52 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -14,6 +14,7 @@
#include "config.h"
#include "regchannel.h"
#include "channels.h"
+#include "extern.h"
/*************************************************************************/
diff --git a/src/botserv.cpp b/src/botserv.cpp
index 4ec6465a1..5718be81a 100644
--- a/src/botserv.cpp
+++ b/src/botserv.cpp
@@ -20,6 +20,7 @@
#include "extern.h"
#include "access.h"
#include "channels.h"
+#include "account.h"
BotInfo* findbot(const Anope::string &nick)
{
diff --git a/src/chanserv.cpp b/src/chanserv.cpp
index 67b77a432..4456ce37c 100644
--- a/src/chanserv.cpp
+++ b/src/chanserv.cpp
@@ -17,6 +17,7 @@
#include "users.h"
#include "channels.h"
#include "access.h"
+#include "account.h"
ChannelInfo* cs_findchan(const Anope::string &chan)
{
diff --git a/src/dns.cpp b/src/dns.cpp
index 25c82e24f..f21453ddd 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -15,9 +15,11 @@
#include "sockets.h"
#include "socketengine.h"
+#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
+#endif
DNSManager *DNSEngine = NULL;
diff --git a/src/encrypt.cpp b/src/encrypt.cpp
index af6a54ba8..154f600bf 100644
--- a/src/encrypt.cpp
+++ b/src/encrypt.cpp
@@ -11,6 +11,7 @@
#include "services.h"
#include "modules.h"
+#include "extern.h"
/******************************************************************************/
diff --git a/src/init.cpp b/src/init.cpp
index 45262c1dd..b1001904c 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -20,11 +20,12 @@
#include "socketengine.h"
#include "servers.h"
+#ifndef _WIN32
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
-#include <unistd.h>
#include <grp.h>
+#endif
Anope::string conf_dir = "conf", db_dir = "data", modules_dir = "lib", locale_dir = "locale", log_dir = "logs";
diff --git a/src/logger.cpp b/src/logger.cpp
index 0624509d2..f14664cdb 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -22,8 +22,10 @@
#include "uplink.h"
#include "protocol.h"
+#ifndef _WIN32
#include <sys/time.h>
#include <unistd.h>
+#endif
static Anope::string GetTimeStamp()
{
diff --git a/src/main.cpp b/src/main.cpp
index e3fcb8bb2..cdddc3163 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -35,8 +35,11 @@
#include "signals.h"
#include "socketengine.h"
-#include <unistd.h>
+#ifndef _WIN32
#include <limits.h>
+#else
+#include <process.h>
+#endif
/******** Global variables! ********/
diff --git a/src/misc.cpp b/src/misc.cpp
index ee091c249..1245656f0 100644
--- a/src/misc.cpp
+++ b/src/misc.cpp
@@ -760,7 +760,7 @@ void Anope::Unhex(const Anope::string &src, Anope::string &dest)
Anope::string rv;
for (size_t i = 0; i + 1 < len; i += 2)
{
- char h = std::tolower(src[i]), l = std::tolower(src[i + 1]);
+ char h = std::tolower(src[i], Anope::casemap), l = std::tolower(src[i + 1], Anope::casemap);
unsigned char byte = (h >= 'a' ? h - 'a' + 10 : h - '0') << 4;
byte += (l >= 'a' ? l - 'a' + 10 : l - '0');
rv += byte;
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index 57b8f850e..5e3f7b6f2 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -12,11 +12,12 @@
#include "users.h"
#include <sys/types.h>
+#include <sys/stat.h>
+#ifndef _WIN32
#include <dirent.h>
#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
#include <dlfcn.h>
+#endif
std::vector<Module *> ModuleManager::EventHandlers[I_END];
diff --git a/src/operserv.cpp b/src/operserv.cpp
index bbdeffdc8..de49c55b9 100644
--- a/src/operserv.cpp
+++ b/src/operserv.cpp
@@ -253,7 +253,7 @@ Anope::string XLineManager::GenerateUID()
{
char c;
do
- c = (random() % 75) + 48;
+ c = (rand() % 75) + 48;
while (!isupper(c) && !isdigit(c));
id += c;
}
@@ -431,9 +431,9 @@ bool XLineManager::CanAdd(CommandSource &source, const Anope::string &mask, time
*/
XLine* XLineManager::HasEntry(const Anope::string &mask)
{
- std::map<Anope::string, XLine *, ci::less>::iterator it = XLinesByUID->find(mask);
+ std::multimap<Anope::string, XLine *, ci::less>::iterator it = XLinesByUID->find(mask);
if (it != XLinesByUID->end())
- for (std::map<Anope::string, XLine *, ci::less>::iterator it2 = XLinesByUID->upper_bound(mask); it != it2; ++it)
+ for (std::multimap<Anope::string, XLine *, ci::less>::iterator it2 = XLinesByUID->upper_bound(mask); it != it2; ++it)
if (it->second->manager == NULL || it->second->manager == this)
{
it->second->QueueUpdate();
diff --git a/src/socketengines/pipeengine_pipe.cpp b/src/socketengines/pipeengine_pipe.cpp
index 985c1cf95..dbded29b4 100644
--- a/src/socketengines/pipeengine_pipe.cpp
+++ b/src/socketengines/pipeengine_pipe.cpp
@@ -13,8 +13,9 @@
#include "sockets.h"
#include "socketengine.h"
-#include <unistd.h>
+#ifndef _WIN32
#include <fcntl.h>
+#endif
Pipe::Pipe() : Socket(-1), WritePipe(-1)
{
@@ -37,7 +38,7 @@ Pipe::Pipe() : Socket(-1), WritePipe(-1)
Pipe::~Pipe()
{
if (this->WritePipe >= 0)
- close(this->WritePipe);
+ anope_close(this->WritePipe);
}
bool Pipe::ProcessRead()
diff --git a/src/sockets.cpp b/src/sockets.cpp
index ebaf8f5a3..3d2df8dc9 100644
--- a/src/sockets.cpp
+++ b/src/sockets.cpp
@@ -14,10 +14,11 @@
#include "socketengine.h"
#include "logger.h"
+#ifndef _WIN32
#include <arpa/inet.h>
#include <errno.h>
-#include <unistd.h>
#include <fcntl.h>
+#endif
std::map<int, Socket *> SocketEngine::Sockets;
@@ -421,7 +422,7 @@ Socket::Socket(int sock, bool ipv6, int type) : Flags<SocketFlag>(SocketFlagStri
Socket::~Socket()
{
SocketEngine::DelSocket(this);
- close(this->Sock);
+ anope_close(this->Sock);
this->IO->Destroy();
}
diff --git a/src/threadengine.cpp b/src/threadengine.cpp
index d45686586..c3ecdd1b5 100644
--- a/src/threadengine.cpp
+++ b/src/threadengine.cpp
@@ -13,7 +13,9 @@
#include "threadengine.h"
#include "anope.h"
+#ifndef _WIN32
#include <pthread.h>
+#endif
static inline pthread_attr_t *get_engine_attr()
{
diff --git a/src/win32/anope_windows.h b/src/win32/anope_windows.h
index e5c4d3b11..635dfb8e8 100644
--- a/src/win32/anope_windows.h
+++ b/src/win32/anope_windows.h
@@ -1,4 +1,4 @@
- /* POSIX emulation layer for Windows.
+/* POSIX emulation layer for Windows.
*
* Copyright (C) 2008-2011 Robin Burchell <w00t@inspircd.org>
* Copyright (C) 2008-2012 Anope Team <info@anope.org>
@@ -9,9 +9,11 @@
* Based on the original code of Services by Andy Church.
*/
- #ifndef WINDOWS_H
- #define WINDOWS_H
- #ifdef _WIN32
+#ifndef WINDOWS_H
+#define WINDOWS_H
+#ifdef _WIN32
+
+#define NOMINMAX
#include <winsock2.h>
#include <ws2tcpip.h>
@@ -40,6 +42,8 @@
/* VS2008 hates having this define before its own */
#define vsnprintf _vsnprintf
+#define anope_close windows_close
+
#define stat _stat
#define S_ISREG(x) ((x) & _S_IFREG)
@@ -48,6 +52,8 @@
#endif
#define EINPROGRESS WSAEWOULDBLOCK
+#include "extensible.h"
+
#include "socket.h"
#include "dir/dir.h"
#include "dl/dl.h"
@@ -71,5 +77,7 @@ extern int unsetenv(const char *name);
extern int mkstemp(char *input);
extern void getcwd(char *buf, size_t sz);
+template struct ExtensibleItemClass<Anope::string>;
+
#endif // _WIN32
#endif // WINDOWS_H
diff --git a/src/win32/dl/dl.cpp b/src/win32/dl/dl.cpp
index 93e2939d0..a6cbe48ce 100644
--- a/src/win32/dl/dl.cpp
+++ b/src/win32/dl/dl.cpp
@@ -6,6 +6,7 @@
*/
#include "services.h"
+#include "anope.h"
void *dlopen(const char *filename, int)
{
diff --git a/src/win32/pipe/pipe.cpp b/src/win32/pipe/pipe.cpp
index 36e6ef5ec..6c4a9a3f1 100644
--- a/src/win32/pipe/pipe.cpp
+++ b/src/win32/pipe/pipe.cpp
@@ -6,6 +6,7 @@
*/
#include "services.h"
+#include "sockets.h"
int pipe(int fds[2])
{
@@ -14,22 +15,22 @@ int pipe(int fds[2])
int cfd = socket(AF_INET, SOCK_STREAM, 0), lfd = socket(AF_INET, SOCK_STREAM, 0);
if (cfd == -1 || lfd == -1)
{
- close(cfd);
- close(lfd);
+ anope_close(cfd);
+ anope_close(lfd);
return -1;
}
if (bind(lfd, &localhost.sa, localhost.size()) == -1)
{
- close(cfd);
- close(lfd);
+ anope_close(cfd);
+ anope_close(lfd);
return -1;
}
if (listen(lfd, 1) == -1)
{
- close(cfd);
- close(lfd);
+ anope_close(cfd);
+ anope_close(lfd);
return -1;
}
@@ -39,16 +40,16 @@ int pipe(int fds[2])
if (connect(cfd, &lfd_addr.sa, lfd_addr.size()))
{
- close(cfd);
- close(lfd);
+ anope_close(cfd);
+ anope_close(lfd);
return -1;
}
int afd = accept(lfd, NULL, NULL);
- close(lfd);
+ anope_close(lfd);
if (afd == -1)
{
- close(cfd);
+ anope_close(cfd);
return -1;
}
diff --git a/src/win32/socket.h b/src/win32/socket.h
index 50262a708..4c1f182eb 100644
--- a/src/win32/socket.h
+++ b/src/win32/socket.h
@@ -25,7 +25,6 @@ extern CoreExport const char *windows_inet_ntop(int af, const void *src, char *d
extern CoreExport int fcntl(int fd, int cmd, int arg);
#ifndef WIN32_NO_OVERRIDE
-# define close windows_close
# define accept windows_accept
# define inet_pton windows_inet_pton
# define inet_ntop windows_inet_ntop
diff --git a/src/win32/windows.cpp b/src/win32/windows.cpp
index 1e621945e..785a38969 100644
--- a/src/win32/windows.cpp
+++ b/src/win32/windows.cpp
@@ -11,6 +11,12 @@
#ifdef _WIN32
#include "services.h"
+#include "anope.h"
+
+#include <io.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
static struct WindowsLanguage
{