diff options
Diffstat (limited to 'src')
38 files changed, 943 insertions, 735 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3c21ba477..a51bc3057 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,24 +1,24 @@ # Find all the *.cpp files within the current source directory, and sort the list file(GLOB SRC_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.cpp") -# If using Windows, add the windows.cpp, the win32 threading engine, and the socket engine to the list if(WIN32) + append_to_list(SRC_SRCS win32/dir/dir.cpp) + append_to_list(SRC_SRCS win32/socket.cpp) append_to_list(SRC_SRCS win32/windows.cpp) + append_to_list(SRC_SRCS win32/dl/dl.cpp) + append_to_list(SRC_SRCS win32/pipe/pipe.cpp) + append_to_list(SRC_SRCS win32/pthread/pthread.cpp) append_to_list(SRC_SRCS win32/sigaction/sigaction.cpp) - append_to_list(SRC_SRCS threadengines/threadengine_win32.cpp) - append_to_list(SRC_SRCS socketengines/pipeengine_win32.cpp) -# If not using Windows, add the pthread threading engine to the list -else(WIN32) - append_to_list(SRC_SRCS threadengines/threadengine_pthread.cpp) - # If we have eventfd, use it - if(HAVE_EVENTFD) - append_to_list(SRC_SRCS socketengines/pipeengine_eventfd.cpp) - # Else fall back to pipe - else(HAVE_EVENTFD) - append_to_list(SRC_SRCS socketengines/pipeengine_pipe.cpp) - endif(HAVE_EVENTFD) endif(WIN32) +# If we have eventfd, use it +if(HAVE_EVENTFD) + append_to_list(SRC_SRCS socketengines/pipeengine_eventfd.cpp) +# Else fall back to pipe +else(HAVE_EVENTFD) + append_to_list(SRC_SRCS socketengines/pipeengine_pipe.cpp) +endif(HAVE_EVENTFD) + if(HAVE_EPOLL) append_to_list(SRC_SRCS socketengines/socketengine_epoll.cpp) else(HAVE_EPOLL) diff --git a/src/access.cpp b/src/access.cpp index 74a376b3d..626176e7b 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -71,7 +71,7 @@ AccessProvider::~AccessProvider() { } -ChanAccess::ChanAccess(AccessProvider *p) : provider(p) +ChanAccess::ChanAccess(AccessProvider *p) : Serializable("ChanAccess"), provider(p) { } @@ -79,6 +79,40 @@ ChanAccess::~ChanAccess() { } +Serializable::serialized_data ChanAccess::serialize() +{ + serialized_data data; + + data["provider"] << this->provider->name; + data["ci"] << this->ci->name; + data["mask"] << this->mask; + data["creator"] << this->creator; + data["last_seen"].setType(Serialize::DT_INT) << this->last_seen; + data["created"].setType(Serialize::DT_INT) << this->created; + data["data"] << this->Serialize(); + + return data; +} + +void ChanAccess::unserialize(serialized_data &data) +{ + service_reference<AccessProvider> aprovider(data["provider"].astr()); + ChannelInfo *ci = cs_findchan(data["ci"].astr()); + if (!aprovider || !ci) + return; + + ChanAccess *access = aprovider->Create(); + access->provider = aprovider; + access->ci = ci; + data["mask"] >> access->mask; + data["creator"] >> access->creator; + data["last_seen"] >> access->last_seen; + data["created"] >> access->created; + access->Unserialize(data["data"].astr()); + + ci->AddAccess(access); +} + bool ChanAccess::operator>(ChanAccess &other) { const std::vector<Privilege> &privs = PrivilegeManager::GetPrivileges(); diff --git a/src/base.cpp b/src/base.cpp index e45e6365c..08d5c6e63 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -1,20 +1,17 @@ #include "services.h" #include "modules.h" +#include "oper.h" -std::vector<SerializableBase *> serialized_types; -std::list<SerializableBase *> *serialized_items; +std::vector<Anope::string> SerializeType::type_order; +Anope::map<SerializeType *> SerializeType::types; +std::list<Serializable *> Serializable::serizliable_items; void RegisterTypes() { - Serializable<NickCore>::Alloc.Register("NickCore"); - Serializable<NickAlias>::Alloc.Register("NickAlias"); - Serializable<BotInfo>::Alloc.Register("BotInfo"); - Serializable<ChannelInfo>::Alloc.Register("ChannelInfo"); - Serializable<LogSetting>::Alloc.Register("LogSetting"); - Serializable<ModeLock>::Alloc.Register("ModeLock"); - Serializable<AutoKick>::Alloc.Register("AutoKick"); - Serializable<BadWord>::Alloc.Register("BadWord"); - Serializable<Memo>::Alloc.Register("Memo"); + static SerializeType nc("NickCore", NickCore::unserialize), na("NickAlias", NickAlias::unserialize), bi("BotInfo", BotInfo::unserialize), + ci("ChannelInfo", ChannelInfo::unserialize), access("ChanAccess", ChanAccess::unserialize), logsetting("LogSetting", LogSetting::unserialize), + modelock("ModeLock", ModeLock::unserialize), akick("AutoKick", AutoKick::unserialize), badword("BadWord", BadWord::unserialize), + memo("Memo", Memo::unserialize), xline("XLine", XLine::unserialize); } Base::Base() diff --git a/src/bots.cpp b/src/bots.cpp index a10b7b147..864201f8c 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -13,7 +13,7 @@ Anope::insensitive_map<BotInfo *> BotListByNick; Anope::map<BotInfo *> BotListByUID; -BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, ts6_uid_retrieve()), Flags<BotFlag, BI_END>(BotFlagString), botmodes(bmodes) +BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, ts6_uid_retrieve()), Flags<BotFlag, BI_END>(BotFlagString), Serializable("BotInfo"), botmodes(bmodes) { this->realname = nreal; this->server = Me; @@ -64,9 +64,9 @@ BotInfo::~BotInfo() BotListByUID.erase(this->uid); } -SerializableBase::serialized_data BotInfo::serialize() +Serializable::serialized_data BotInfo::serialize() { - SerializableBase::serialized_data data; + serialized_data data; data["nick"] << this->nick; data["user"] << this->ident; @@ -79,7 +79,7 @@ SerializableBase::serialized_data BotInfo::serialize() return data; } -void BotInfo::unserialize(SerializableBase::serialized_data &data) +void BotInfo::unserialize(serialized_data &data) { BotInfo *bi = findbot(data["nick"].astr()); if (bi == NULL) diff --git a/src/encrypt.cpp b/src/encrypt.cpp index 0f3bd3d79..2f052be4e 100644 --- a/src/encrypt.cpp +++ b/src/encrypt.cpp @@ -35,7 +35,7 @@ bool enc_decrypt(const Anope::string &src, Anope::string &dest) if (pos == Anope::string::npos) { Log() << "Error: enc_decrypt() called with invalid password string (" << src << ")"; - return -1; + return false; } Anope::string hashm(src.begin(), src.begin() + pos); diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index cfffd5a10..0095ec74b 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -113,7 +113,7 @@ const char *ci::ci_char_traits::find(const char *s1, int n, char c) * @param s2 The second string * @return true if s1 < s2, else false */ -bool std::less<ci::string>::operator()(const Anope::string &s1, const Anope::string &s2) const +bool ci::less::operator()(const Anope::string &s1, const Anope::string &s2) const { return s1.ci_str().compare(s2.ci_str()) < 0; } @@ -123,7 +123,7 @@ bool std::less<ci::string>::operator()(const Anope::string &s1, const Anope::str * @param s2 The second string * @return true if s1 < s2, else false */ -bool std::less<irc::string>::operator()(const Anope::string &s1, const Anope::string &s2) const +bool irc::less::operator()(const Anope::string &s1, const Anope::string &s2) const { return s1.irc_str().compare(s2.irc_str()) < 0; } diff --git a/src/init.cpp b/src/init.cpp index 4c4d3f93e..d54ad7fa5 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -161,7 +161,11 @@ static void write_pidfile() FILE *pidfile = fopen(Config->PIDFilename.c_str(), "w"); if (pidfile) { +#ifdef _WIN32 + fprintf(pidfile, "%d\n", static_cast<int>(GetCurrentProcessId())); +#else fprintf(pidfile, "%d\n", static_cast<int>(getpid())); +#endif fclose(pidfile); atexit(remove_pidfile); } @@ -458,10 +462,6 @@ void Init(int ac, char **av) rand_init(); add_entropy_userkeys(); -#ifdef _WIN32 - OnStartup(); -#endif - /* load modules */ Log() << "Loading modules..."; for (std::list<Anope::string>::iterator it = Config->ModulesAutoLoad.begin(), it_end = Config->ModulesAutoLoad.end(); it != it_end; ++it) diff --git a/src/logger.cpp b/src/logger.cpp index d8aed5ee7..9792c9be2 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -380,7 +380,7 @@ void LogInfo::ProcessMessage(const Log *l) Anope::string oldlog = CreateLogName(target, Anope::CurTime - 86400 * this->LogAge); if (IsFile(oldlog)) { - DeleteFile(oldlog.c_str()); + unlink(oldlog.c_str()); Log(LOG_DEBUG) << "Deleted old logfile " << oldlog; } } diff --git a/src/main.cpp b/src/main.cpp index b115137ea..03920424a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,10 +27,9 @@ #include "timers.h" #include "modules.h" -// getrlimit. -#ifndef _WIN32 -# include <sys/time.h> -# include <sys/resource.h> +#ifdef _WIN32 +# include <process.h> +# define execve _execve #endif /******** Global variables! ********/ @@ -47,11 +46,6 @@ bool noexpire = false; /* -noexpire */ bool protocoldebug = false; /* -protocoldebug */ Anope::string binary_dir; /* Used to store base path for Anope */ -#ifdef _WIN32 -# include <process.h> -# define execve _execve -#endif - /* Set to 1 if we are to quit */ bool quitting = false; int return_code = 0; @@ -316,6 +310,10 @@ int main(int ac, char **av, char **envp) /* Clean out the module runtime directory prior to running, just in case files were left behind during a previous run */ ModuleManager::CleanupRuntimeDirectory(); +#ifdef _WIN32 + OnStartup(); +#endif + try { /* General initialization first */ diff --git a/src/memoserv.cpp b/src/memoserv.cpp index 602db9897..8db4f0170 100644 --- a/src/memoserv.cpp +++ b/src/memoserv.cpp @@ -13,9 +13,9 @@ #include "modules.h" #include "memoserv.h" -Memo::Memo() : Flags<MemoFlag>(MemoFlagStrings) { } +Memo::Memo() : Flags<MemoFlag>(MemoFlagStrings), Serializable("Memo") { } -SerializableBase::serialized_data Memo::serialize() +Serializable::serialized_data Memo::serialize() { serialized_data data; @@ -28,7 +28,7 @@ SerializableBase::serialized_data Memo::serialize() return data; } -void Memo::unserialize(SerializableBase::serialized_data &data) +void Memo::unserialize(serialized_data &data) { if (!memoserv) return; diff --git a/src/misc.cpp b/src/misc.cpp index 5e899effd..0941c9bbc 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -49,35 +49,6 @@ bool IsFile(const Anope::string &filename) return false; } -/** - * toupper: Like the ANSI functions, but make sure we return an - * int instead of a (signed) char. - * @param c Char - * @return int - */ -int toupper(char c) -{ - if (islower(c)) - return static_cast<int>(c) - ('a' - 'A'); - else - return static_cast<int>(c); -} - -/*************************************************************************/ - -/** - * tolower: Like the ANSI functions, but make sure we return an - * int instead of a (signed) char. - * @param c Char - * @return int - */ -int tolower(char c) -{ - if (isupper(c)) - return static_cast<int>(c) + ('a' - 'A'); - else - return static_cast<int>(c); -} /*************************************************************************/ diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index 978a5b929..17cc08a53 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -17,52 +17,24 @@ void ModuleManager::CleanupRuntimeDirectory() Log(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment please wait"; -#ifndef _WIN32 DIR *dirp = opendir(dirbuf.c_str()); if (!dirp) { Log(LOG_DEBUG) << "Cannot open directory (" << dirbuf << ")"; return; } - struct dirent *dp; - while ((dp = readdir(dirp))) + + for (dirent *dp; (dp = readdir(dirp));) { if (!dp->d_ino) continue; if (Anope::string(dp->d_name).equals_cs(".") || Anope::string(dp->d_name).equals_cs("..")) continue; Anope::string filebuf = dirbuf + "/" + dp->d_name; - DeleteFile(filebuf.c_str()); - } - closedir(dirp); -#else - Anope::string szDir = dirbuf + "/*"; - - WIN32_FIND_DATA FileData; - HANDLE hList = FindFirstFile(szDir.c_str(), &FileData); - if (hList != INVALID_HANDLE_VALUE) - { - bool fFinished = false; - while (!fFinished) - { - if (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - Anope::string filebuf = dirbuf + "/" + FileData.cFileName; - if (!DeleteFile(filebuf.c_str())) - Log(LOG_DEBUG) << "Error deleting file " << filebuf << " - GetLastError() reports " << Anope::LastError(); - } - if (!FindNextFile(hList, &FileData)) - { - if (GetLastError() == ERROR_NO_MORE_FILES) - fFinished = true; - } - } + unlink(filebuf.c_str()); } - else - Log(LOG_DEBUG) << "Invalid File Handle. GetLastError() reports "<< static_cast<int>(GetLastError()); - FindClose(hList); -#endif + closedir(dirp); } /** @@ -131,11 +103,11 @@ static ModuleReturn moduleCopyFile(const Anope::string &name, Anope::string &out * This function will take a pointer from either dlsym or GetProcAddress and cast it in * a way that won't cause C++ warnings/errors to come up. */ -template <class TYPE> TYPE function_cast(ano_module_t symbol) +template <class TYPE> TYPE function_cast(void *symbol) { union { - ano_module_t symbol; + void *symbol; TYPE function; } cast; cast.symbol = symbol; @@ -160,19 +132,18 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u) if (ret != MOD_ERR_OK) return ret; - ano_modclearerr(); - - ano_module_t handle = dlopen(pbuf.c_str(), RTLD_LAZY); - const char *err = ano_moderr(); + dlerror(); + void *handle = dlopen(pbuf.c_str(), RTLD_LAZY); + const char *err = dlerror(); if (!handle && err && *err) { Log() << err; return MOD_ERR_NOLOAD; } - ano_modclearerr(); + dlerror(); Module *(*func)(const Anope::string &, const Anope::string &) = function_cast<Module *(*)(const Anope::string &, const Anope::string &)>(dlsym(handle, "AnopeInit")); - err = ano_moderr(); + err = dlerror(); if (!func && err && *err) { Log() << "No init function found, not an Anope module"; @@ -305,15 +276,15 @@ ModuleReturn ModuleManager::DeleteModule(Module *m) if (!m || !m->handle) return MOD_ERR_PARAMS; - ano_module_t handle = m->handle; + void *handle = m->handle; Anope::string filename = m->filename; Log(LOG_DEBUG) << "Unloading module " << m->name; - ano_modclearerr(); + dlerror(); void (*destroy_func)(Module *m) = function_cast<void (*)(Module *)>(dlsym(m->handle, "AnopeFini")); - const char *err = ano_moderr(); - if (!destroy_func || err) + const char *err = dlerror(); + if (!destroy_func || (err && *err)) { Log() << "No destroy function found for " << m->name << ", chancing delete..."; delete m; /* we just have to chance they haven't overwrote the delete operator then... */ @@ -322,10 +293,10 @@ ModuleReturn ModuleManager::DeleteModule(Module *m) destroy_func(m); /* Let the module delete it self, just in case */ if (dlclose(handle)) - Log() << ano_moderr(); + Log() << dlerror(); if (!filename.empty()) - DeleteFile(filename.c_str()); + unlink(filename.c_str()); return MOD_ERR_OK; } diff --git a/src/nickalias.cpp b/src/nickalias.cpp index ed739653b..1ef03bb2b 100644 --- a/src/nickalias.cpp +++ b/src/nickalias.cpp @@ -5,7 +5,7 @@ * @param nick The nick * @param nickcore The nickcofe for this nick */ -NickAlias::NickAlias(const Anope::string &nickname, NickCore *nickcore) : Flags<NickNameFlag, NS_END>(NickNameFlagStrings) +NickAlias::NickAlias(const Anope::string &nickname, NickCore *nickcore) : Flags<NickNameFlag, NS_END>(NickNameFlagStrings), Serializable("NickAlias") { if (nickname.empty()) throw CoreException("Empty nick passed to NickAlias constructor"); @@ -103,7 +103,7 @@ void NickAlias::OnCancel(User *) } } -SerializableBase::serialized_data NickAlias::serialize() +Serializable::serialized_data NickAlias::serialize() { serialized_data data; @@ -128,7 +128,7 @@ SerializableBase::serialized_data NickAlias::serialize() return data; } -void NickAlias::unserialize(SerializableBase::serialized_data &data) +void NickAlias::unserialize(serialized_data &data) { NickCore *core = findcore(data["nc"].astr()); if (core == NULL) diff --git a/src/nickcore.cpp b/src/nickcore.cpp index 6c533fb61..05d627529 100644 --- a/src/nickcore.cpp +++ b/src/nickcore.cpp @@ -4,7 +4,7 @@ /** Default constructor * @param display The display nick */ -NickCore::NickCore(const Anope::string &coredisplay) : Flags<NickCoreFlag, NI_END>(NickCoreFlagStrings) +NickCore::NickCore(const Anope::string &coredisplay) : Flags<NickCoreFlag, NI_END>(NickCoreFlagStrings), Serializable("NickCore") { if (coredisplay.empty()) throw CoreException("Empty display passed to NickCore constructor"); @@ -45,7 +45,7 @@ NickCore::~NickCore() } } -SerializableBase::serialized_data NickCore::serialize() +Serializable::serialized_data NickCore::serialize() { serialized_data data; diff --git a/src/operserv.cpp b/src/operserv.cpp index 05d27d6ca..54230d6ab 100644 --- a/src/operserv.cpp +++ b/src/operserv.cpp @@ -15,18 +15,18 @@ /* List of XLine managers we check users against in XLineManager::CheckAll */ std::list<XLineManager *> XLineManager::XLineManagers; -std::map<Anope::string, XLine *, std::less<ci::string> > XLineManager::XLinesByUID; +std::map<Anope::string, XLine *, ci::less> XLineManager::XLinesByUID; -XLine::XLine() +XLine::XLine() : Serializable("XLine") { } -XLine::XLine(const Anope::string &mask, const Anope::string &reason, const Anope::string &uid) : Mask(mask), Created(0), Expires(0), Reason(reason), UID(uid) +XLine::XLine(const Anope::string &mask, const Anope::string &reason, const Anope::string &uid) : Serializable("XLine"), Mask(mask), Created(0), Expires(0), Reason(reason), UID(uid) { manager = NULL; } -XLine::XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason, const Anope::string &uid) : Mask(mask), By(by), Created(Anope::CurTime), Expires(expires), Reason(reason), UID(uid) +XLine::XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason, const Anope::string &uid) : Serializable("XLine"), Mask(mask), By(by), Created(Anope::CurTime), Expires(expires), Reason(reason), UID(uid) { manager = NULL; } @@ -73,7 +73,7 @@ sockaddrs XLine::GetIP() const return addr; } -SerializableBase::serialized_data XLine::serialize() +Serializable::serialized_data XLine::serialize() { serialized_data data; @@ -89,7 +89,7 @@ SerializableBase::serialized_data XLine::serialize() return data; } -void XLine::unserialize(SerializableBase::serialized_data &data) +void XLine::unserialize(serialized_data &data) { service_reference<XLineManager> xlm(data["manager"].astr()); if (!xlm) @@ -327,7 +327,7 @@ std::pair<int, XLine *> XLineManager::CanAdd(const Anope::string &mask, time_t e */ XLine *XLineManager::HasEntry(const Anope::string &mask) { - std::map<Anope::string, XLine *, std::less<ci::string> >::iterator it = XLinesByUID.find(mask); + std::map<Anope::string, XLine *, ci::less>::iterator it = XLinesByUID.find(mask); if (it != XLinesByUID.end() && (it->second->manager == NULL || it->second->manager == this)) return it->second; for (unsigned i = 0, end = this->XLines.size(); i < end; ++i) diff --git a/src/regchannel.cpp b/src/regchannel.cpp index be1562793..a7a2e2c22 100644 --- a/src/regchannel.cpp +++ b/src/regchannel.cpp @@ -12,7 +12,11 @@ #include "services.h" #include "modules.h" -SerializableBase::serialized_data BadWord::serialize() +BadWord::BadWord() : Serializable("BadWord") +{ +} + +Serializable::serialized_data BadWord::serialize() { serialized_data data; @@ -23,7 +27,7 @@ SerializableBase::serialized_data BadWord::serialize() return data; } -void BadWord::unserialize(SerializableBase::serialized_data &data) +void BadWord::unserialize(serialized_data &data) { ChannelInfo *ci = cs_findchan(data["ci"].astr()); if (!ci) @@ -35,7 +39,11 @@ void BadWord::unserialize(SerializableBase::serialized_data &data) ci->AddBadWord(data["word"].astr(), static_cast<BadWordType>(n)); } -SerializableBase::serialized_data AutoKick::serialize() +AutoKick::AutoKick() : Flags<AutoKickFlag>(AutoKickFlagString), Serializable("AutoKick") +{ +} + +Serializable::serialized_data AutoKick::serialize() { serialized_data data; @@ -53,7 +61,7 @@ SerializableBase::serialized_data AutoKick::serialize() return data; } -void AutoKick::unserialize(SerializableBase::serialized_data &data) +void AutoKick::unserialize(serialized_data &data) { ChannelInfo *ci = cs_findchan(data["ci"].astr()); if (ci == NULL) @@ -70,7 +78,15 @@ void AutoKick::unserialize(SerializableBase::serialized_data &data) ci->AddAkick(data["creator"].astr(), data["mask"].astr(), data["reason"].astr(), addtime, lastused); } -SerializableBase::serialized_data ModeLock::serialize() +ModeLock::ModeLock() : Serializable("ModeLock") +{ +} + +ModeLock::ModeLock(ChannelInfo *ch, bool s, ChannelModeName n, const Anope::string &p, const Anope::string &se, time_t c) : Serializable("ModeLock"), ci(ch), set(s), name(n), param(p), setter(se), created(c) +{ +} + +Serializable::serialized_data ModeLock::serialize() { serialized_data data; @@ -87,7 +103,7 @@ SerializableBase::serialized_data ModeLock::serialize() return data; } -void ModeLock::unserialize(SerializableBase::serialized_data &data) +void ModeLock::unserialize(serialized_data &data) { ChannelInfo *ci = cs_findchan(data["ci"].astr()); if (ci == NULL) @@ -113,7 +129,11 @@ void ModeLock::unserialize(SerializableBase::serialized_data &data) ci->mode_locks.insert(std::make_pair(ml.name, ml)); } -SerializableBase::serialized_data LogSetting::serialize() +LogSetting::LogSetting() : Serializable("LogSetting") +{ +} + +Serializable::serialized_data LogSetting::serialize() { serialized_data data; @@ -152,7 +172,7 @@ void LogSetting::unserialize(serialized_data &data) /** Default constructor * @param chname The channel name */ -ChannelInfo::ChannelInfo(const Anope::string &chname) : Flags<ChannelInfoFlag, CI_END>(ChannelInfoFlagStrings), botflags(BotServFlagStrings) +ChannelInfo::ChannelInfo(const Anope::string &chname) : Flags<ChannelInfoFlag, CI_END>(ChannelInfoFlagStrings), Serializable("ChannelInfo"), botflags(BotServFlagStrings) { if (chname.empty()) throw CoreException("Empty channel passed to ChannelInfo constructor"); @@ -197,7 +217,7 @@ ChannelInfo::ChannelInfo(const Anope::string &chname) : Flags<ChannelInfoFlag, C /** Copy constructor * @param ci The ChannelInfo to copy settings to */ -ChannelInfo::ChannelInfo(ChannelInfo &ci) : Flags<ChannelInfoFlag, CI_END>(ChannelInfoFlagStrings), botflags(BotServFlagStrings) +ChannelInfo::ChannelInfo(ChannelInfo &ci) : Flags<ChannelInfoFlag, CI_END>(ChannelInfoFlagStrings), Serializable("ChannelInfo"), botflags(BotServFlagStrings) { *this = ci; @@ -279,7 +299,7 @@ ChannelInfo::~ChannelInfo() --this->founder->channelcount; } -SerializableBase::serialized_data ChannelInfo::serialize() +Serializable::serialized_data ChannelInfo::serialize() { serialized_data data; @@ -319,7 +339,7 @@ SerializableBase::serialized_data ChannelInfo::serialize() return data; } -void ChannelInfo::unserialize(SerializableBase::serialized_data &data) +void ChannelInfo::unserialize(serialized_data &data) { ChannelInfo *ci = new ChannelInfo(data["name"].astr()); if (data.count("founder") > 0) diff --git a/src/socketengines/pipeengine_pipe.cpp b/src/socketengines/pipeengine_pipe.cpp index f2fa0876a..7901931c8 100644 --- a/src/socketengines/pipeengine_pipe.cpp +++ b/src/socketengines/pipeengine_pipe.cpp @@ -10,7 +10,7 @@ Pipe::Pipe() : Socket(-1), WritePipe(-1) flags = fcntl(fds[1], F_GETFL, 0); fcntl(fds[1], F_SETFL, flags | O_NONBLOCK); - this->~Socket(); + this->~Pipe(); this->Sock = fds[0]; this->WritePipe = fds[1]; @@ -20,13 +20,14 @@ Pipe::Pipe() : Socket(-1), WritePipe(-1) Pipe::~Pipe() { - CloseSocket(this->WritePipe); + if (this->WritePipe >= 0) + close(this->WritePipe); } bool Pipe::ProcessRead() { char dummy[512]; - while (read(this->GetFD(), &dummy, 512) == 512); + while (read(this->GetFD(), dummy, 512) == 512); this->OnNotify(); return true; } @@ -40,4 +41,3 @@ void Pipe::Notify() void Pipe::OnNotify() { } - diff --git a/src/socketengines/pipeengine_win32.cpp b/src/socketengines/pipeengine_win32.cpp deleted file mode 100644 index f34472870..000000000 --- a/src/socketengines/pipeengine_win32.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "s |
