From 57c2b65f08c9c0658003a74a32c6506829e12b0b Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 5 May 2013 03:30:08 -0400 Subject: Move module header files to include/modules to fix naming conflicts with system headers --- modules/commands/cs_fantasy_stats.cpp | 2 +- modules/commands/cs_fantasy_top.cpp | 2 +- modules/commands/cs_log.cpp | 1 - modules/commands/cs_xop.cpp | 1 - modules/commands/gl_global.cpp | 1 - modules/commands/hs_request.cpp | 1 - modules/commands/ms_cancel.cpp | 10 -- modules/commands/ms_ignore.cpp | 1 - modules/commands/ms_read.cpp | 1 - modules/commands/ms_rsend.cpp | 1 - modules/commands/ms_send.cpp | 12 +- modules/commands/ms_sendall.cpp | 14 +-- modules/commands/ms_set.cpp | 5 - modules/commands/ms_staff.cpp | 15 ++- modules/commands/ns_logout.cpp | 1 - modules/commands/ns_recover.cpp | 7 +- modules/commands/ns_register.cpp | 4 - modules/commands/os_defcon.cpp | 3 +- modules/commands/os_dns.cpp | 2 +- modules/commands/os_forbid.cpp | 2 +- modules/commands/os_forbid.h | 82 ------------ modules/commands/os_ignore.cpp | 2 +- modules/commands/os_ignore.h | 79 ------------ modules/commands/os_news.cpp | 3 +- modules/commands/os_news.h | 76 ------------ modules/commands/os_session.cpp | 2 +- modules/commands/os_session.h | 85 ------------- modules/commands/os_stats.cpp | 2 +- modules/database/db_old.cpp | 2 +- modules/database/db_plain.cpp | 2 +- modules/database/db_sql.cpp | 2 +- modules/database/db_sql_live.cpp | 3 +- modules/dns.h | 177 -------------------------- modules/httpd.h | 226 ---------------------------------- modules/ldapapi.h | 173 -------------------------- modules/m_dns.cpp | 2 +- modules/m_dnsbl.cpp | 2 +- modules/pseudoclients/chanserv.h | 18 --- modules/pseudoclients/global.cpp | 1 - modules/pseudoclients/global.h | 20 --- modules/pseudoclients/memoserv.cpp | 1 - modules/pseudoclients/memoserv.h | 34 ----- modules/pseudoclients/nickserv.cpp | 2 - modules/pseudoclients/nickserv.h | 16 --- modules/sql.h | 216 -------------------------------- modules/ssl.h | 9 -- modules/xmlrpc.h | 40 ------ 47 files changed, 37 insertions(+), 1326 deletions(-) delete mode 100644 modules/commands/os_forbid.h delete mode 100644 modules/commands/os_ignore.h delete mode 100644 modules/commands/os_news.h delete mode 100644 modules/commands/os_session.h delete mode 100644 modules/dns.h delete mode 100644 modules/httpd.h delete mode 100644 modules/ldapapi.h delete mode 100644 modules/pseudoclients/chanserv.h delete mode 100644 modules/pseudoclients/global.h delete mode 100644 modules/pseudoclients/memoserv.h delete mode 100644 modules/pseudoclients/nickserv.h delete mode 100644 modules/sql.h delete mode 100644 modules/ssl.h delete mode 100644 modules/xmlrpc.h (limited to 'modules') diff --git a/modules/commands/cs_fantasy_stats.cpp b/modules/commands/cs_fantasy_stats.cpp index 7709a38d3..381063c34 100644 --- a/modules/commands/cs_fantasy_stats.cpp +++ b/modules/commands/cs_fantasy_stats.cpp @@ -12,7 +12,7 @@ /*************************************************************************/ #include "module.h" -#include "sql.h" +#include "modules/sql.h" class MySQLInterface : public SQL::Interface { diff --git a/modules/commands/cs_fantasy_top.cpp b/modules/commands/cs_fantasy_top.cpp index ef87cd87f..a3e35eb3c 100644 --- a/modules/commands/cs_fantasy_top.cpp +++ b/modules/commands/cs_fantasy_top.cpp @@ -12,7 +12,7 @@ /*************************************************************************/ #include "module.h" -#include "sql.h" +#include "modules/sql.h" class MySQLInterface : public SQL::Interface { diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index 7e817caa9..b3ad62859 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -12,7 +12,6 @@ /*************************************************************************/ #include "module.h" -#include "memoserv.h" class CommandCSLog : public Command { diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 5d0fe9f21..1e1cd0646 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -13,7 +13,6 @@ namespace { - ServiceReference chanserv("ChanServService", "ChanServ"); std::vector order; std::map > permissions; } diff --git a/modules/commands/gl_global.cpp b/modules/commands/gl_global.cpp index fae4554d4..70dd4d324 100644 --- a/modules/commands/gl_global.cpp +++ b/modules/commands/gl_global.cpp @@ -12,7 +12,6 @@ /*************************************************************************/ #include "module.h" -#include "global.h" class CommandGLGlobal : public Command { diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index 0c29705ef..99c5a4811 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -16,7 +16,6 @@ */ #include "module.h" -#include "memoserv.h" static ServiceReference memoserv("MemoServService", "MemoServ"); diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp index e0e917b5e..2ab605f40 100644 --- a/modules/commands/ms_cancel.cpp +++ b/modules/commands/ms_cancel.cpp @@ -12,9 +12,6 @@ /*************************************************************************/ #include "module.h" -#include "memoserv.h" - -static ServiceReference MemoServService("MemoServService", "MemoServ"); class CommandMSCancel : public Command { @@ -27,10 +24,6 @@ class CommandMSCancel : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - if (!MemoServService) - return; - - const Anope::string &nname = params[0]; bool ischan; @@ -81,9 +74,6 @@ class MSCancel : public Module MSCancel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandmscancel(this) { - - if (!MemoServService) - throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index d1f33abdf..056b20128 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -13,7 +13,6 @@ #include "module.h" -#include "memoserv.h" static ServiceReference MemoServService("MemoServService", "MemoServ"); diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp index 0d269bd02..7e1e89236 100644 --- a/modules/commands/ms_read.cpp +++ b/modules/commands/ms_read.cpp @@ -12,7 +12,6 @@ /*************************************************************************/ #include "module.h" -#include "memoserv.h" static ServiceReference MemoServService("MemoServService", "MemoServ"); diff --git a/modules/commands/ms_rsend.cpp b/modules/commands/ms_rsend.cpp index 19a20a279..a9372c328 100644 --- a/modules/commands/ms_rsend.cpp +++ b/modules/commands/ms_rsend.cpp @@ -12,7 +12,6 @@ /*************************************************************************/ #include "module.h" -#include "memoserv.h" namespace { diff --git a/modules/commands/ms_send.cpp b/modules/commands/ms_send.cpp index 18a609893..d4d63a383 100644 --- a/modules/commands/ms_send.cpp +++ b/modules/commands/ms_send.cpp @@ -12,9 +12,11 @@ /*************************************************************************/ #include "module.h" -#include "memoserv.h" -static ServiceReference MemoServService("MemoServService", "MemoServ"); +namespace +{ + ServiceReference memoserv("MemoServService", "MemoServ"); +} class CommandMSSend : public Command { @@ -27,13 +29,13 @@ class CommandMSSend : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - if (!MemoServService) + if (!memoserv) return; const Anope::string &nick = params[0]; const Anope::string &text = params[1]; - MemoServService::MemoResult result = MemoServService->Send(source.GetNick(), nick, text); + MemoServService::MemoResult result = memoserv->Send(source.GetNick(), nick, text); if (result == MemoServService::MEMO_SUCCESS) source.Reply(_("Memo sent to \002%s\002."), nick.c_str()); else if (result == MemoServService::MEMO_INVALID_TARGET) @@ -65,7 +67,7 @@ class MSSend : public Module commandmssend(this) { - if (!MemoServService) + if (!memoserv) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_sendall.cpp b/modules/commands/ms_sendall.cpp index d823f7c5f..b19b96036 100644 --- a/modules/commands/ms_sendall.cpp +++ b/modules/commands/ms_sendall.cpp @@ -12,9 +12,11 @@ /*************************************************************************/ #include "module.h" -#include "memoserv.h" -static ServiceReference MemoServService("MemoServService", "MemoServ"); +namespace +{ + ServiceReference memoserv("MemoServService", "MemoServ"); +} class CommandMSSendAll : public Command { @@ -27,7 +29,7 @@ class CommandMSSendAll : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - if (!MemoServService) + if (!memoserv) return; const Anope::string &text = params[0]; @@ -43,11 +45,10 @@ class CommandMSSendAll : public Command const NickCore *nc = it->second; if (nc != source.nc) - MemoServService->Send(source.GetNick(), nc->display, text); + memoserv->Send(source.GetNick(), nc->display, text); } source.Reply(_("A massmemo has been sent to all registered users.")); - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override @@ -67,8 +68,7 @@ class MSSendAll : public Module MSSendAll(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandmssendall(this) { - - if (!MemoServService) + if (!memoserv) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_set.cpp b/modules/commands/ms_set.cpp index dafb5a857..d1edaecca 100644 --- a/modules/commands/ms_set.cpp +++ b/modules/commands/ms_set.cpp @@ -13,11 +13,6 @@ #include "module.h" -namespace -{ - ServiceReference memoserv("MemoServService", "MemoServ"); -} - class CommandMSSet : public Command { private: diff --git a/modules/commands/ms_staff.cpp b/modules/commands/ms_staff.cpp index f9d5e81e5..30ec92b16 100644 --- a/modules/commands/ms_staff.cpp +++ b/modules/commands/ms_staff.cpp @@ -12,9 +12,11 @@ /*************************************************************************/ #include "module.h" -#include "memoserv.h" -static ServiceReference MemoServService("MemoServService", "MemoServ"); +namespace +{ + ServiceReference memoserv("MemoServService", "MemoServ"); +} class CommandMSStaff : public Command { @@ -27,7 +29,7 @@ class CommandMSStaff : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - if (!MemoServService) + if (!memoserv) return; const Anope::string &text = params[0]; @@ -43,10 +45,8 @@ class CommandMSStaff : public Command const NickCore *nc = it->second; if (source.nc != nc && nc->IsServicesOper()) - MemoServService->Send(source.GetNick(), nc->display, text, true); + memoserv->Send(source.GetNick(), nc->display, text, true); } - - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override @@ -67,8 +67,7 @@ class MSStaff : public Module MSStaff(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandmsstaff(this) { - - if (!MemoServService) + if (!memoserv) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp index cdeab3add..c149dc1f2 100644 --- a/modules/commands/ns_logout.cpp +++ b/modules/commands/ns_logout.cpp @@ -12,7 +12,6 @@ /*************************************************************************/ #include "module.h" -#include "nickserv.h" static ServiceReference NickServService("NickServService", "NickServ"); diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp index 845c98915..e9455f88a 100644 --- a/modules/commands/ns_recover.cpp +++ b/modules/commands/ns_recover.cpp @@ -13,11 +13,6 @@ #include "module.h" -namespace -{ - bool restoreonrecover; -} - struct NSRecoverExtensibleInfo : ExtensibleItem, std::map { }; class NSRecoverRequest : public IdentifyRequest @@ -61,7 +56,7 @@ class NSRecoverRequest : public IdentifyRequest Log(LOG_COMMAND, source, cmd) << "and was automatically identified to " << u->Account()->display; } - if (restoreonrecover) + if (Config->GetModule("ns_recover")->Get("restoreonrecover")) { if (!u->chans.empty()) { diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index e0b8c77b5..a9dbce470 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -13,10 +13,6 @@ #include "module.h" -namespace -{ - ServiceReference nickserv("NickServService", "NickServ"); -} static bool SendRegmail(User *u, const NickAlias *na, const BotInfo *bi); class CommandNSConfirm : public Command diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index 0fd3a1700..a75d4691b 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -12,8 +12,7 @@ /*************************************************************************/ #include "module.h" -#include "global.h" -#include "os_session.h" +#include "modules/os_session.h" enum DefconLevel { diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index ebfa16227..698fa0e1a 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -6,7 +6,7 @@ */ #include "module.h" -#include "../dns.h" +#include "modules/dns.h" static ServiceReference dnsmanager("DNS::Manager", "dns/manager"); diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index 1d99d47b4..1d683a7e6 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -12,7 +12,7 @@ /*************************************************************************/ #include "module.h" -#include "os_forbid.h" +#include "modules/os_forbid.h" static ServiceReference nickserv("NickServService", "NickServ"); diff --git a/modules/commands/os_forbid.h b/modules/commands/os_forbid.h deleted file mode 100644 index 3f1fe9a7f..000000000 --- a/modules/commands/os_forbid.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef OS_FORBID_H -#define OS_FORBID_H - -enum ForbidType -{ - FT_NICK = 1, - FT_CHAN, - FT_EMAIL, - FT_REGISTER, - FT_SIZE -}; - -struct ForbidData : Serializable -{ - Anope::string mask; - Anope::string creator; - Anope::string reason; - time_t created; - time_t expires; - ForbidType type; - - ForbidData() : Serializable("ForbidData") { } - void Serialize(Serialize::Data &data) const anope_override; - static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); -}; - -class ForbidService : public Service -{ - public: - ForbidService(Module *m) : Service(m, "ForbidService", "forbid") { } - - virtual void AddForbid(ForbidData *d) = 0; - - virtual void RemoveForbid(ForbidData *d) = 0; - - virtual ForbidData *FindForbid(const Anope::string &mask, ForbidType type) = 0; - - virtual std::vector GetForbids() = 0; -}; - -static ServiceReference forbid_service("ForbidService", "forbid"); - -void ForbidData::Serialize(Serialize::Data &data) const -{ - data["mask"] << this->mask; - data["creator"] << this->creator; - data["reason"] << this->reason; - data["created"] << this->created; - data["expires"] << this->expires; - data["type"] << this->type; -} - -Serializable* ForbidData::Unserialize(Serializable *obj, Serialize::Data &data) -{ - if (!forbid_service) - return NULL; - - ForbidData *fb; - if (obj) - fb = anope_dynamic_static_cast(obj); - else - fb = new ForbidData; - - data["mask"] >> fb->mask; - data["creator"] >> fb->creator; - data["reason"] >> fb->reason; - data["created"] >> fb->created; - data["expires"] >> fb->expires; - unsigned int t; - data["type"] >> t; - fb->type = static_cast(t); - - if (t > FT_SIZE - 1) - return NULL; - - if (!obj) - forbid_service->AddForbid(fb); - return fb; -} - -#endif - diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp index 073101066..08aaeaaf3 100644 --- a/modules/commands/os_ignore.cpp +++ b/modules/commands/os_ignore.cpp @@ -12,7 +12,7 @@ /*************************************************************************/ #include "module.h" -#include "os_ignore.h" +#include "modules/os_ignore.h" class OSIgnoreService : public IgnoreService { diff --git a/modules/commands/os_ignore.h b/modules/commands/os_ignore.h deleted file mode 100644 index 6c3e237ab..000000000 --- a/modules/commands/os_ignore.h +++ /dev/null @@ -1,79 +0,0 @@ -/* OperServ ignore interface - * - * (C) 2003-2013 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - - -struct IgnoreData : Serializable -{ - Anope::string mask; - Anope::string creator; - Anope::string reason; - time_t time; /* When do we stop ignoring them? */ - - IgnoreData() : Serializable("IgnoreData") { } - void Serialize(Serialize::Data &data) const anope_override; - static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); -}; - -class IgnoreService : public Service -{ - protected: - std::list ignores; - - IgnoreService(Module *c) : Service(c, "IgnoreService", "ignore") { } - - public: - virtual IgnoreData* AddIgnore(const Anope::string &mask, const Anope::string &creator, const Anope::string &reason, time_t delta = Anope::CurTime) = 0; - - virtual bool DelIgnore(const Anope::string &mask) = 0; - - inline void ClearIgnores() { this->ignores.clear(); } - - virtual IgnoreData *Find(const Anope::string &mask) = 0; - - inline std::list &GetIgnores() { return this->ignores; } -}; - -static ServiceReference ignore_service("IgnoreService", "ignore"); - -void IgnoreData::Serialize(Serialize::Data &data) const -{ - data["mask"] << this->mask; - data["creator"] << this->creator; - data["reason"] << this->reason; - data["time"] << this->time; -} - -Serializable* IgnoreData::Unserialize(Serializable *obj, Serialize::Data &data) -{ - if (!ignore_service) - return NULL; - - if (obj) - { - IgnoreData *ign = anope_dynamic_static_cast(obj); - data["mask"] >> ign->mask; - data["creator"] >> ign->creator; - data["reason"] >> ign->reason; - data["time"] >> ign->time; - return ign; - } - - Anope::string smask, screator, sreason; - time_t t; - - data["mask"] >> smask; - data["creator"] >> screator; - data["reason"] >> sreason; - data["time"] >> t; - - return ignore_service->AddIgnore(smask, screator, sreason, t); -} - diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index 7292b6471..e9f70b693 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -12,8 +12,7 @@ /*************************************************************************/ #include "module.h" -#include "global.h" -#include "os_news.h" +#include "modules/os_news.h" /* List of messages for each news type. This simplifies message sending. */ diff --git a/modules/commands/os_news.h b/modules/commands/os_news.h deleted file mode 100644 index b1e717455..000000000 --- a/modules/commands/os_news.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef OS_NEWS -#define OS_NEWS - -enum NewsType -{ - NEWS_LOGON, - NEWS_RANDOM, - NEWS_OPER -}; - -struct NewsMessages -{ - NewsType type; - Anope::string name; - const char *msgs[10]; -}; - -struct NewsItem : Serializable -{ - NewsType type; - Anope::string text; - Anope::string who; - time_t time; - - NewsItem() : Serializable("NewsItem") { } - void Serialize(Serialize::Data &data) const anope_override; - static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); -}; - -class NewsService : public Service -{ - public: - NewsService(Module *m) : Service(m, "NewsService", "news") { } - - virtual void AddNewsItem(NewsItem *n) = 0; - - virtual void DelNewsItem(NewsItem *n) = 0; - - virtual std::vector &GetNewsList(NewsType t) = 0; -}; - -static ServiceReference news_service("NewsService", "news"); - -void NewsItem::Serialize(Serialize::Data &data) const -{ - data["type"] << this->type; - data["text"] << this->text; - data["who"] << this->who; - data["time"] << this->time; -} - -Serializable* NewsItem::Unserialize(Serializable *obj, Serialize::Data &data) -{ - if (!news_service) - return NULL; - - NewsItem *ni; - if (obj) - ni = anope_dynamic_static_cast(obj); - else - ni = new NewsItem(); - - unsigned int t; - data["type"] >> t; - ni->type = static_cast(t); - data["text"] >> ni->text; - data["who"] >> ni->who; - data["time"] >> ni->time; - - if (!obj) - news_service->AddNewsItem(ni); - return ni; -} - -#endif // OS_NEWS - diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 74f6c2f7e..42449e44b 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -12,7 +12,7 @@ /*************************************************************************/ #include "module.h" -#include "os_session.h" +#include "modules/os_session.h" namespace { diff --git a/modules/commands/os_session.h b/modules/commands/os_session.h deleted file mode 100644 index f3077d0ac..000000000 --- a/modules/commands/os_session.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef OS_SESSION_H -#define OS_SESSION_H - -struct Session -{ - cidr addr; /* A cidr (sockaddrs + len) representing this session */ - unsigned count; /* Number of clients with this host */ - unsigned hits; /* Number of subsequent kills for a host */ - - Session(const Anope::string &ip, int len) : addr(ip, len), count(1), hits(0) { } -}; - -struct Exception : Serializable -{ - Anope::string mask; /* Hosts to which this exception applies */ - unsigned limit; /* Session limit for exception */ - Anope::string who; /* Nick of person who added the exception */ - Anope::string reason; /* Reason for exception's addition */ - time_t time; /* When this exception was added */ - time_t expires; /* Time when it expires. 0 == no expiry */ - - Exception() : Serializable("Exception") { } - void Serialize(Serialize::Data &data) const anope_override; - static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); -}; - -class SessionService : public Service -{ - public: - typedef std::tr1::unordered_map SessionMap; - typedef std::vector ExceptionVector; - - SessionService(Module *m) : Service(m, "SessionService", "session") { } - - virtual void AddException(Exception *e) = 0; - - virtual void DelException(Exception *e) = 0; - - virtual Exception *FindException(User *u) = 0; - - virtual Exception *FindException(const Anope::string &host) = 0; - - virtual ExceptionVector &GetExceptions() = 0; - - virtual Session *FindSession(const Anope::string &ip) = 0; - - virtual SessionMap &GetSessions() = 0; -}; - -static ServiceReference session_service("SessionService", "session"); - -void Exception::Serialize(Serialize::Data &data) const -{ - data["mask"] << this->mask; - data["limit"] << this->limit; - data["who"] << this->who; - data["reason"] << this->reason; - data["time"] << this->time; - data["expires"] << this->expires; -} - -Serializable* Exception::Unserialize(Serializable *obj, Serialize::Data &data) -{ - if (!session_service) - return NULL; - - Exception *ex; - if (obj) - ex = anope_dynamic_static_cast(obj); - else - ex = new Exception; - data["mask"] >> ex->mask; - data["limit"] >> ex->limit; - data["who"] >> ex->who; - data["reason"] >> ex->reason; - data["time"] >> ex->time; - data["expires"] >> ex->expires; - - if (!obj) - session_service->AddException(ex); - return ex; -} - -#endif - diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index 04bd6e60d..8b975a6c7 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -12,7 +12,7 @@ /*************************************************************************/ #include "module.h" -#include "os_session.h" +#include "modules/os_session.h" struct Stats : Serializable { diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp index 52d61bfad..fd499d0cb 100644 --- a/modules/database/db_old.cpp +++ b/modules/database/db_old.cpp @@ -11,7 +11,7 @@ /*************************************************************************/ #include "module.h" -#include "../commands/os_session.h" +#include "modules/os_session.h" #define READ(x) \ if (true) \ diff --git a/modules/database/db_plain.cpp b/modules/database/db_plain.cpp index 76a2aa455..3c6324b6f 100644 --- a/modules/database/db_plain.cpp +++ b/modules/database/db_plain.cpp @@ -11,7 +11,7 @@ /*************************************************************************/ #include "module.h" -#include "../commands/os_session.h" +#include "modules/os_session.h" Anope::string DatabaseFile; Anope::string BackupFile; diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp index 400619159..145857614 100644 --- a/modules/database/db_sql.cpp +++ b/modules/database/db_sql.cpp @@ -9,7 +9,7 @@ */ #include "module.h" -#include "sql.h" +#include "modules/sql.h" using namespace SQL; diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp index a7116892d..091febda7 100644 --- a/modules/database/db_sql_live.cpp +++ b/modules/database/db_sql_live.cpp @@ -1,6 +1,5 @@ #include "module.h" -#include "sql.h" -#include "../commands/os_session.h" +#include "modules/sql.h" using namespace SQL; diff --git a/modules/dns.h b/modules/dns.h deleted file mode 100644 index 99b84098f..000000000 --- a/modules/dns.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - * - * (C) 2003-2013 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * - */ - -#ifndef DNS_H -#define DNS_H - -namespace DNS -{ - /** Valid query types - */ - enum QueryType - { - /* Nothing */ - QUERY_NONE, - /* A simple A lookup */ - QUERY_A = 1, - /* An authoritative name server */ - QUERY_NS = 2, - /* A CNAME lookup */ - QUERY_CNAME = 5, - /* Start of a zone of authority */ - QUERY_SOA = 6, - /* Reverse DNS lookup */ - QUERY_PTR = 12, - /* IPv6 AAAA lookup */ - QUERY_AAAA = 28, - /* Zone transfer */ - QUERY_AXFR = 252 - }; - - /** Flags that can be AND'd into DNSPacket::flags to receive certain values - */ - enum - { - QUERYFLAGS_QR = 0x8000, - QUERYFLAGS_OPCODE = 0x7800, - QUERYFLAGS_AA = 0x400, - QUERYFLAGS_TC = 0x200, - QUERYFLAGS_RD = 0x100, - QUERYFLAGS_RA = 0x80, - QUERYFLAGS_Z = 0x70, - QUERYFLAGS_RCODE = 0xF - }; - - enum Error - { - ERROR_NONE, - ERROR_UNKNOWN, - ERROR_UNLOADED, - ERROR_TIMEDOUT, - ERROR_NOT_AN_ANSWER, - ERROR_NONSTANDARD_QUERY, - ERROR_FORMAT_ERROR, - ERROR_SERVER_FAILURE, - ERROR_DOMAIN_NOT_FOUND, - ERROR_NOT_IMPLEMENTED, - ERROR_REFUSED, - ERROR_NO_RECORDS, - ERROR_INVALIDTYPE - }; - - struct Question - { - Anope::string name; - QueryType type; - unsigned short qclass; - - Question() : type(QUERY_NONE), qclass(0) { } - Question(const Anope::string &n, QueryType t, unsigned short c = 1) : name(n), type(t), qclass(c) { } - inline bool operator==(const Question & other) const { return name == other.name && type == other.type && qclass == other.qclass; } - - struct hash - { - size_t operator()(const Question &q) const - { - return Anope::hash_ci()(q.name); - } - }; - }; - - struct ResourceRecord : Question - { - unsigned int ttl; - Anope::string rdata; - time_t created; - - ResourceRecord(const Anope::string &n, QueryType t, unsigned short c = 1) : Question(n, t, c), ttl(0), created(Anope::CurTime) { } - ResourceRecord(const Question &q) : Question(q), ttl(0), created(Anope::CurTime) { } - }; - - struct Query - { - std::vector questions; - std::vector answers, authorities, additional; - Error error; - - Query() : error(ERROR_NONE) { } - Query(const Question &q) : error(ERROR_NONE) { questions.push_back(q); } - }; - - class ReplySocket; - class Request; - - /** DNS manager - */ - class Manager : public Service - { - public: - Manager(Module *creator) : Service(creator, "DNS::Manager", "dns/manager") { } - virtual ~Manager() { } - - virtual void Process(Request *req) = 0; - virtual void RemoveRequest(Request *req) = 0; - - virtual bool HandlePacket(ReplySocket *s, const unsigned char *const data, int len, sockaddrs *from) = 0; - - virtual void UpdateSerial() = 0; - virtual uint32_t GetSerial() const = 0; - }; - - /** A DNS query. - */ - class Request : public Timer, public Question - { - Manager *manager; - public: - /* Use result cache if available */ - bool use_cache; - /* Request id */ - unsigned short id; - /* Creator of this request */ - Module *creator; - - Request(Manager *mgr, Module *c, const Anope::string &addr, QueryType qt, bool cache = false) : Timer(0), Question(addr, qt), manager(mgr), - use_cache(cache), id(0), creator(c) { } - - virtual ~Request() - { - manager->RemoveRequest(this); - } - - /** Called when this request succeeds - * @param r The query sent back from the nameserver - */ - virtual void OnLookupComplete(const Query *r) = 0; - - /** Called when this request fails or times out. - * @param r The query sent back from the nameserver, check the error code. - */ - virtual void OnError(const Query *r) { } - - /** Used to time out the query, xalls OnError and lets the TimerManager - * delete this request. - */ - void Tick(time_t) anope_override - { - Log(LOG_DEBUG_2) << "Resolver: timeout for query " << this->name; - Query rr(*this); - rr.error = ERROR_TIMEDOUT; - this->OnError(&rr); - } - }; - -} // namespace DNS - -#endif // DNS_H - - diff --git a/modules/httpd.h b/modules/httpd.h deleted file mode 100644 index 6127a51e0..000000000 --- a/modules/httpd.h +++ /dev/null @@ -1,226 +0,0 @@ -#ifndef ANOPE_HTTPD_H -#define ANOPE_HTTPD_H - -enum HTTPError -{ - HTTP_ERROR_OK = 200, - HTTP_FOUND = 302, - HTTP_BAD_REQUEST = 400, - HTTP_PAGE_NOT_FOUND = 404, - HTTP_NOT_SUPPORTED = 505 -}; - -/* A message to someone */ -struct HTTPReply -{ - HTTPError error; - Anope::string content_type; - std::map headers; - typedef std::list > cookie; - std::vector cookies; - - HTTPReply() : error(HTTP_ERROR_OK), length(0) { } - - HTTPReply(const HTTPReply& other) : error(other.error), length(other.length) - { - content_type = other.content_type; - headers = other.headers; - cookies = other.cookies; - - for (unsigned i = 0; i < other.out.size(); ++i) - out.push_back(new Data(other.out[i]->buf, other.out[i]->len)); - } - - ~HTTPReply() - { - for (unsigned i = 0; i < out.size(); ++i) - delete out[i]; - out.clear(); - } - - struct Data - { - char *buf; - size_t len; - - Data(const char *b, size_t l) - { - this->buf = new char[l]; - memcpy(this->buf, b, l); - this->len = l; - } - - ~Data() - { - delete [] buf; - } - }; - - std::deque out; - size_t length; - - void Write(const Anope::string &message) - { - this->out.push_back(new Data(message.c_str(), message.length())); - this->length += message.length(); - } - - void Write(const char *b, size_t l) - { - this->out.push_back(new Data(b, l)); - this->length += l; - } -}; - -/* A message from soneone */ -struct HTTPMessage -{ - std::map headers; - std::map cookies; - std::map get_data; - std::map post_data; - Anope::string content; -}; - -class HTTPClient; -class HTTPProvider; - -class HTTPPage : public Base -{ - Anope::string url; - Anope::string content_type; - - public: - HTTPPage(const Anope::string &u, const Anope::string &ct = "text/html") : url(u), content_type(ct) { } - - const Anope::string &GetURL() const { return this->url; } - - const Anope::string &GetContentType() const { return this->content_type; } - - /** Called when this page is requested - * @param The server this page is on - * @param The page name - * @param The client requesting the page - * @param The HTTP header sent from the client to request the page - * @param The HTTP header that will be sent back to the client - */ - virtual bool OnRequest(HTTPProvider *, const Anope::string &, HTTPClient *, HTTPMessage &, HTTPReply &) = 0; -}; - -class HTTPClient : public ClientSocket, public BinarySocket, public Base -{ - protected: - void WriteClient(const Anope::string &message) - { - BinarySocket::Write(message + "\r\n"); - } - - public: - HTTPClient(ListenSocket *l, int f, const sockaddrs &a) : ClientSocket(l, a), BinarySocket() { } - - virtual const Anope::string GetIP() - { - return this->clientaddr.addr(); - } - - virtual void SendError(HTTPError err, const Anope::string &msg) = 0; - virtual void SendReply(HTTPReply *) = 0; -}; - -class HTTPProvider : public ListenSocket, public Service -{ - Anope::string ip; - unsigned short port; - public: - Anope::string ext_ip; - std::vector ext_headers; - - HTTPProvider(Module *c, const Anope::string &n, const Anope::string &i, const unsigned short p) : ListenSocket(i, p, i.find(':') != Anope::string::npos), Service(c, "HTTPProvider", n), ip(i), port(p) { } - - const Anope::string &GetIP() const - { - return this->ip; - } - - unsigned short GetPort() const - { - return this->port; - } - - virtual bool RegisterPage(HTTPPage *page) = 0; - virtual void UnregisterPage(HTTPPage *page) = 0; - virtual HTTPPage* FindPage(const Anope::string &name) = 0; -}; - -namespace HTTPUtils -{ - inline Anope::string URLDecode(const Anope::string &url) - { - Anope::string decoded; - - for (unsigned i = 0; i < url.length(); ++i) - { - const char& c = url[i]; - - if (c == '%' && i + 2 < url.length()) - { - Anope::string dest; - Anope::Unhex(url.substr(i + 1, 2), dest); - decoded += dest; - i += 2; - } - else if (c == '+') - decoded += ' '; - else - decoded += c; - } - - return decoded; - } - - inline Anope::string URLEncode(const Anope::string &url) - { - Anope::string encoded; - - for (unsigned i = 0; i < url.length(); ++i) - { - const char& c = url[i]; - - if (isalnum(c) || c == '.' || c == '-' || c == '*' || c == '_') - encoded += c; - else if (c == ' ') - encoded += '+'; - else - encoded += "%" + Anope::Hex(c); - } - - return encoded; - } - - inline Anope::string Escape(const Anope::string &src) - { - Anope::string dst; - - for (unsigned i = 0; i < src.length(); ++i) - { - switch (src[i]) - { - case '<': - dst += "<"; - break; - case '>': - dst += ">"; - break; - case '"': - dst += """; - break; - default: - dst += src[i]; - } - } - - return dst; - } -} - -#endif // ANOPE_HTTPD_H diff --git a/modules/ldapapi.h b/modules/ldapapi.h deleted file mode 100644 index 65be27687..000000000 --- a/modules/ldapapi.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef ANOPE_LDAP_H -#define ANOPE_LDAP_H - -typedef int LDAPQuery; - -class LDAPException : public ModuleException -{ - public: - LDAPException(const Anope::string &reason) : ModuleException(reason) { } - - virtual ~LDAPException() throw() { } -}; - -struct LDAPModification -{ - enum LDAPOperation - { - LDAP_ADD, - LDAP_DEL, - LDAP_REPLACE - }; - - LDAPOperation op; - Anope::string name; - std::vector values; -}; -typedef std::vector LDAPMods; - -struct LDAPAttributes : public std::map > -{ - size_t size(const Anope::string &attr) const - { - const std::vector& array = this->getArray(attr); - return array.size(); - } - - const std::vector keys() const - { - std::vector k; - for (const_iterator it = this->begin(), it_end = this->end(); it != it_end; ++it) - k.push_back(it->first); - return k; - } - - const Anope::string &get(const Anope::string &attr) const - { - const std::vector& array = this->getArray(attr); - if (array.empty()) - throw LDAPException("Empty attribute " + attr + " in LDAPResult::get"); - return array[0]; - } - - const std::vector& getArray(const Anope::string &attr) const - { - const_iterator it = this->find(attr); - if (it == this->end()) - throw LDAPException("Unknown attribute " + attr + " in LDAPResult::getArray"); - return it->second; - } -}; - -struct LDAPResult -{ - std::vector messages; - Anope::string error; - - enum QueryType - { - QUERY_UNKNOWN, - QUERY_BIND, - QUERY_SEARCH, - QUERY_ADD, - QUERY_DELETE, - QUERY_MODIFY - }; - - QueryType type; - LDAPQuery id; - - LDAPResult() - { - this->type = QUERY_UNKNOWN; - this->id = -1; - } - - size_t size() const - { - return this->messages.size(); - } - - bool empty() const - { - return this->messages.empty(); - } - - const LDAPAttributes &get(size_t sz) const - { - if (sz >= this->messages.size()) - throw LDAPException("Index out of range"); - return this->messages[sz]; - } - - const Anope::string &getError() const - { - return this->error; - } -}; - -class LDAPInterface -{ - public: - Module *owner; - - LDAPInterface(Module *m) : owner(m) { } - virtual ~LDAPInterface() { } - - virtual void OnResult(const LDAPResult &r) = 0; - virtual void OnError(const LDAPResult &err) = 0; - virtual void OnDelete() { } -}; - -class LDAPProvider : public Service -{ - public: - LDAPProvider(Module *c, const Anope::string &n) : Service(c, "LDAPProvider", n) { } - - /** Attempt to bind to the LDAP server as an admin - * @param i The LDAPInterface the result is sent to - * @return The query ID - */ - virtual LDAPQuery BindAsAdmin(LDAPInterface *i) = 0; - - /** Bind to LDAP - * @param i The LDAPInterface the result is sent to - * @param who The binddn - * @param pass The password - * @return The query ID - */ - virtual LDAPQuery Bind(LDAPInterface *i, const Anope::string &who, const Anope::string &pass) = 0; - - /** Search ldap for the specified filter - * @param i The LDAPInterface the result is sent to - * @param base The base DN to search - * @param filter The filter to apply - * @return The query ID - */ - virtual LDAPQuery Search(LDAPInterface *i, const Anope::string &base, const Anope::string &filter) = 0; - - /** Add an entry to LDAP - * @param i The LDAPInterface the result is sent to - * @param dn The dn of the entry to add - * @param attributes The attributes - * @return The query ID - */ - virtual LDAPQuery Add(LDAPInterface *i, const Anope::string &dn, LDAPMods &attributes) = 0; - - /** Delete an entry from LDAP - * @param i The LDAPInterface the result is sent to - * @param dn The dn of the entry to delete - * @return The query ID - */ - virtual LDAPQuery Del(LDAPInterface *i, const Anope::string &dn) = 0; - - /** Modify an existing entry in LDAP - * @param i The LDAPInterface the result is sent to - * @param base The base DN to modify - * @param attributes The attributes to modify - * @return The query ID - */ - virtual LDAPQuery Modify(LDAPInterface *i, const Anope::string &base, LDAPMods &attributes) = 0; -}; - -#endif // ANOPE_LDAP_H diff --git a/modules/m_dns.cpp b/modules/m_dns.cpp index 6bcccc3e1..4dc419d7c 100644 --- a/modules/m_dns.cpp +++ b/modules/m_dns.cpp @@ -11,7 +11,7 @@ */ #include "module.h" -#include "dns.h" +#include "modules/dns.h" using namespace DNS; diff --git a/modules/m_dnsbl.cpp b/modules/m_dnsbl.cpp index 1f5a9b984..9e30c49ce 100644 --- a/modules/m_dnsbl.cpp +++ b/modules/m_dnsbl.cpp @@ -6,7 +6,7 @@ */ #include "module.h" -#include "dns.h" +#include "modules/dns.h" using namespace DNS; diff --git a/modules/pseudoclients/chanserv.h b/modules/pseudoclients/chanserv.h deleted file mode 100644 index e1c3849fd..000000000 --- a/modules/pseudoclients/chanserv.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CHANSERV_H -#define CHANSERV_H - -class ChanServService : public Service -{ - public: - ChanServService(Module *m) : Service(m, "ChanServService", "ChanServ") - { - } - - /* Have ChanServ hold the channel, that is, join and set +nsti and wait - * for a few minutes so no one can join or rejoin. - */ - virtual void Hold(Channel *c) = 0; -}; - -#endif // CHANSERV_H - diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp index 837200e5d..501b02194 100644 --- a/modules/pseudoclients/global.cpp +++ b/modules/pseudoclients/global.cpp @@ -12,7 +12,6 @@ /*************************************************************************/ #include "module.h" -#include "global.h" class MyGlobalService : public GlobalService { diff --git a/modules/pseudoclients/global.h b/modules/pseudoclients/global.h deleted file mode 100644 index 52afc4a23..000000000 --- a/modules/pseudoclients/global.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef GLOBAL_H -#define GLOBAL_H - -class GlobalService : public Service -{ - public: - GlobalService(Module *m) : Service(m, "GlobalService", "Global") - { - } - - /** Send out a global message to all users - * @param sender Our client which should send the global - * @param source The sender of the global - * @param message The message - */ - virtual void SendGlobal(const BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0; -}; - -#endif // GLOBAL_H - diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp index 46ad82194..499722686 100644 --- a/modules/pseudoclients/memoserv.cpp +++ b/modules/pseudoclients/memoserv.cpp @@ -12,7 +12,6 @@ /*************************************************************************/ #include "module.h" -#include "memoserv.h" static bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m) { diff --git a/modules/pseudoclients/memoserv.h b/modules/pseudoclients/memoserv.h deleted file mode 100644 index d35d3f8a0..000000000 --- a/modules/pseudoclients/memoserv.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef MEMOSERV_H -#define MEMOSERV_H - -class MemoServService : public Service -{ - public: - enum MemoResult - { - MEMO_SUCCESS, - MEMO_INVALID_TARGET, - MEMO_TOO_FAST, - MEMO_TARGET_FULL - }; - - MemoServService(Module *m) : Service(m, "MemoServService", "MemoServ") - { - } - - /** Sends a memo. - * @param source The source of the memo, can be anythin. - * @param target The target of the memo, nick or channel. - * @param message Memo text - * @param force true to force the memo, restrictions/delays etc are not checked - */ - virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) = 0; - - /** Check for new memos and notify the user if there are any - * @param u The user - */ - virtual void Check(User *u) = 0; -}; - -#endif // MEMOSERV_H - diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index 3f4250fb6..1177f9327 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -12,13 +12,11 @@ /*************************************************************************/ #include "module.h" -#include "nickserv.h" class NickServCollide; typedef std::map nickservcollides_map; -static ServiceReference nickserv("NickServService", "NickServ"); static nickservcollides_map NickServCollides; /** Timer for colliding nicks to force people off of nicknames diff --git a/modules/pseudoclients/nickserv.h b/modules/pseudoclients/nickserv.h deleted file mode 100644 index b20d6ebd1..000000000 --- a/modules/pseudoclients/nickserv.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NICKSERV_H -#define NICKSERV_H - -class NickServService : public Service -{ - public: - NickServService(Module *m) : Service(m, "NickServService", "NickServ") - { - } - - virtual void Validate(User *u) = 0; - virtual void Login(User *u, NickAlias *na) = 0; -}; - -#endif // NICKSERV_H - diff --git a/modules/sql.h b/modules/sql.h deleted file mode 100644 index 1c8fdd3aa..000000000 --- a/modules/sql.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * (C) 2003-2013 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - */ - -namespace SQL -{ - - class Data : public Serialize::Data - { - public: - typedef std::map Map; - Map data; - std::map types; - - ~Data() - { - Clear(); - } - - std::iostream& operator[](const Anope::string &key) anope_override - { - std::stringstream *&ss = data[key]; - if (!ss) - ss = new std::stringstream(); - return *ss; - } - - std::set KeySet() const anope_override - { - std::set keys; - for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it) - keys.insert(it->first); - return keys; - } - - size_t Hash() const anope_override - { - size_t hash = 0; - for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it) - if (!it->second->str().empty()) - hash ^= Anope::hash_cs()(it->second->str()); - return hash; - } - - std::map GetData() const - { - std::map d; - for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it) - d[it->first] = it->second; - return d; - } - - void Clear() - { - for (Map::const_iterator it = this->data.begin(), it_end = this->data.end(); it != it_end; ++it) - delete it->second; - this->data.clear(); - } - - void SetType(const Anope::string &key, Type t) anope_override - { - this->types[key] = t; - } - - Type GetType(const Anope::string &key) const anope_override - { - std::map::const_iterator it = this->types.find(key); - if (it != this->types.end()) - return it->second; - return DT_TEXT; - } - }; - - /** A SQL exception, can be thrown at various points - */ - class Exception : public ModuleException - { - public: - Exception(const Anope::string &reason) : ModuleException(reason) { } - - virtual ~Exception() throw() { } - }; - - /** A SQL query - */ - - struct QueryData - { - Anope::string data; - bool escape; - }; - - struct Query - { - Anope::string query; - std::map parameters; - - Query() { } - Query(const Anope::string &q) : query(q) { } - - Query& operator=(const Anope::string &q) - { - this->query = q; - this->parameters.clear(); - return *this; - } - - bool operator==(const Query &other) const - { - return this->query == other.query; - } - - inline bool operator!=(const Query &other) const - { - return !(*this == other); - } - - template void SetValue(const Anope::string &key, const T& value, bool escape = true) - { - try - { - Anope::string string_value = stringify(value); - this->parameters[key].data = string_value; - this->parameters[key].escape = escape; - } - catch (const ConvertException &ex) { } - } - }; - - /** A result from a SQL query - */ - class Result - { - protected: - /* Rows, column, item */ - std::vector > entries; - Query query; - Anope::string error; - public: - unsigned int id; - Anope::string finished_query; - - Result() : id(0) { } - Result(unsigned int i, const Query &q, const Anope::string &fq, const Anope::string &err = "") : query(q), error(err), id(i), finished_query(fq) { } - - inline operator bool() const { return this->error.empty(); } - - inline const unsigned int GetID() const { return this->id; } - inline const Query &GetQuery() const { return this->query; } - inline const Anope::string &GetError() const { return this->error; } - - int Rows() const { return this->entries.size(); } - - const std::map &Row(size_t index) const - { - try - { - return this->entries.at(index); - } - catch (const std::out_of_range &) - { - throw Exception("Out of bounds access to SQLResult"); - } - } - - const Anope::string Get(size_t index, const Anope::string &col) const - { - const std::map rows = this->Row(index); - - std::map::const_iterator it = rows.find(col); - if (it == rows.end()) - throw Exception("Unknown column name in SQLResult: " + col); - - return it->second; - } - }; - - /* An interface used by modules to retrieve the results - */ - class Interface - { - public: - Module *owner; - - Interface(Module *m) : owner(m) { } - virtual ~Interface() { } - - virtual void OnResult(const Result &r) = 0; - virtual void OnError(const Result &r) = 0; - }; - - /** Class providing the SQL service, modules call this to execute queries - */ - class Provider : public Service - { - public: - Provider(Module *c, const Anope::string &n) : Service(c, "SQL::Provider", n) { } - - virtual void Run(Interface *i, const Query &query) = 0; - - virtual Result RunQuery(const Query &query) = 0; - - virtual std::vector CreateTable(const Anope::string &table, const Data &data) = 0; - - virtual Query BuildInsert(const Anope::string &table, unsigned int id, Data &data) = 0; - - virtual Query GetTables(const Anope::string &prefix) = 0; - - virtual Anope::string FromUnixtime(time_t) = 0; - }; - -} - diff --git a/modules/ssl.h b/modules/ssl.h deleted file mode 100644 index 6eb97582c..000000000 --- a/modules/ssl.h +++ /dev/null @@ -1,9 +0,0 @@ - -class SSLService : public Service -{ - public: - SSLService(Module *o, const Anope::string &n) : Service(o, "SSLService", n) { } - - virtual void Init(Socket *s) = 0; -}; - diff --git a/modules/xmlrpc.h b/modules/xmlrpc.h deleted file mode 100644 index d5a5ea4a7..000000000 --- a/modules/xmlrpc.h +++ /dev/null @@ -1,40 +0,0 @@ -#include "httpd.h" - -class XMLRPCRequest -{ - std::map replies; - - public: - Anope::string name; - Anope::string id; - std::deque data; - HTTPReply& r; - - XMLRPCRequest(HTTPReply &_r) : r(_r) { } - inline void reply(const Anope::string &dname, const Anope::string &ddata) { this->replies.insert(std::make_pair(dname, ddata)); } - inline const std::map &get_replies() { return this->replies; } -}; - -class XMLRPCServiceInterface; - -class XMLRPCEvent -{ - public: - virtual ~XMLRPCEvent() { } - virtual bool Run(XMLRPCServiceInterface *iface, HTTPClient *client, XMLRPCRequest &request) = 0; -}; - -class XMLRPCServiceInterface : public Service -{ - public: - XMLRPCServiceInterface(Module *creator, const Anope::string &sname) : Service(creator, "XMLRPCServiceInterface", sname) { } - - virtual void Register(XMLRPCEvent *event) = 0; - - virtual void Unregister(XMLRPCEvent *event) = 0; - - virtual Anope::string Sanitize(const Anope::string &string) = 0; - - virtual void Reply(XMLRPCRequest &request) = 0; -}; - -- cgit