diff options
| author | Adam <Adam@anope.org> | 2012-02-14 15:13:27 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2012-02-14 15:13:27 -0500 |
| commit | a9772cde21407c89abd161d51aff45267f87b1fb (patch) | |
| tree | 9e57ba6c121d3843888917d968dd4f5d030b57cf /src | |
| parent | 086790d6331357022f4da17c76b26b9fc6e2ad90 (diff) | |
Clean up and reorganize our header files
Diffstat (limited to 'src')
50 files changed, 816 insertions, 299 deletions
diff --git a/src/access.cpp b/src/access.cpp index 32c648857..4ed19c7fe 100644 --- a/src/access.cpp +++ b/src/access.cpp @@ -9,8 +9,11 @@ * Based on the original code of Services by Andy Church. */ -#include "services.h" -#include "modules.h" +#include "service.h" +#include "access.h" +#include "regchannel.h" +#include "users.h" +#include "account.h" Privilege::Privilege(const Anope::string &n, const Anope::string &d, int r) : name(n), desc(d), rank(r) { diff --git a/src/actions.cpp b/src/actions.cpp index 01c8bf918..5536596e6 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -10,6 +10,10 @@ */ #include "services.h" +#include "users.h" +#include "config.h" +#include "regchannel.h" +#include "channels.h" /*************************************************************************/ diff --git a/src/base.cpp b/src/base.cpp index f8b393774..492ef4628 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -1,10 +1,10 @@ #include "services.h" #include "modules.h" #include "oper.h" - -std::vector<Anope::string> SerializeType::type_order; -Anope::map<SerializeType *> SerializeType::types; -std::list<Serializable *> *Serializable::serizliable_items; +#include "account.h" +#include "regchannel.h" +#include "access.h" +#include "bots.h" Anope::map<Anope::map<Service *> > Service::services; diff --git a/src/base64.cpp b/src/base64.cpp index b8f4b9de6..df4189547 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -10,6 +10,7 @@ */ #include "services.h" +#include "anope.h" static const Anope::string Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static const char Pad64 = '='; diff --git a/src/bots.cpp b/src/bots.cpp index a6cc1c06f..30df962d8 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -6,9 +6,16 @@ */ #include "services.h" -#include "modules.h" -#include "commands.h" +#include "anope.h" +#include "bots.h" +#include "servers.h" +#include "protocol.h" #include "oper.h" +#include "regchannel.h" +#include "channels.h" +#include "config.h" +#include "language.h" +#include "extern.h" Anope::insensitive_map<BotInfo *> BotListByNick; Anope::map<BotInfo *> BotListByUID; diff --git a/src/botserv.cpp b/src/botserv.cpp index 4007bb355..962f2b80e 100644 --- a/src/botserv.cpp +++ b/src/botserv.cpp @@ -12,7 +12,14 @@ /*************************************************************************/ #include "services.h" -#include "modules.h" +#include "anope.h" +#include "protocol.h" +#include "bots.h" +#include "regchannel.h" +#include "language.h" +#include "extern.h" +#include "access.h" +#include "channels.h" BotInfo *findbot(const Anope::string &nick) { diff --git a/src/channels.cpp b/src/channels.cpp index ef74edcec..a04abff52 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -10,7 +10,19 @@ */ #include "services.h" +#include "channels.h" +#include "regchannel.h" +#include "logger.h" #include "modules.h" +#include "users.h" +#include "bots.h" +#include "servers.h" +#include "protocol.h" +#include "users.h" +#include "config.h" +#include "access.h" +#include "extern.h" +#include "sockets.h" channel_map ChannelList; @@ -91,7 +103,7 @@ void Channel::Sync() { if (!this->HasMode(CMODE_PERM) && (this->users.empty() || (this->users.size() == 1 && this->ci && this->ci->bi == this->users.front()->user))) { - new ChanServTimer(this); + this->Hold(); } if (this->ci) { @@ -863,6 +875,56 @@ void Channel::ChangeTopic(const Anope::string &user, const Anope::string &newtop } } +/** A timer used to keep the BotServ bot/ChanServ in the channel + * after kicking the last user in a channel + */ +class CoreExport ChanServTimer : public Timer +{ + private: + dynamic_reference<Channel> c; + + public: + /** Default constructor + * @param chan The channel + */ + ChanServTimer(Channel *chan) : Timer(Config->CSInhabit), c(chan) + { + BotInfo *bi = findbot(Config->ChanServ); + if (!bi || !c) + return; + c->SetFlag(CH_INHABIT); + if (!c->ci || !c->ci->bi) + bi->Join(c); + else if (!c->FindUser(c->ci->bi)) + c->ci->bi->Join(c); + } + + /** Called when the delay is up + * @param The current time + */ + void Tick(time_t) + { + if (!c) + return; + + c->UnsetFlag(CH_INHABIT); + + if (!c->ci || !c->ci->bi) + { + BotInfo *bi = findbot(Config->ChanServ); + if (bi) + bi->Part(c); + } + else if (c->users.size() == 1 || c->users.size() < Config->BSMinUsers) + c->ci->bi->Part(c); + } +}; + +void Channel::Hold() +{ + new ChanServTimer(this); +} + /*************************************************************************/ Channel *findchan(const Anope::string &chan) @@ -1198,9 +1260,7 @@ Entry::Entry(ChannelModeName mode, const Anope::string &_host) : Flags<EntryType { try { - sockaddrs addr; - bool ipv6 = _realhost.substr(0, sl).find(':') != Anope::string::npos; - addr.pton(ipv6 ? AF_INET6 : AF_INET, _realhost.substr(0, sl)); + sockaddrs addr(_realhost.substr(0, sl)); /* If we got here, _realhost is a valid IP */ Anope::string cidr_range = _realhost.substr(sl + 1); @@ -1248,11 +1308,15 @@ bool Entry::Matches(User *u, bool full) const { try { - cidr cidr_mask(this->host, this->cidr_len); - if (!u->ip() || !cidr_mask.match(u->ip)) - ret = false; + if (full) + { + cidr cidr_mask(this->host, this->cidr_len); + sockaddrs addr(u->ip); + if (!cidr_mask.match(addr)) + ret = false; + } /* If we're not matching fully and their displayed host isnt their IP */ - else if (!full && u->ip.addr() != u->GetDisplayedHost()) + else if (u->ip != u->GetDisplayedHost()) ret = false; } catch (const SocketException &) @@ -1267,7 +1331,7 @@ bool Entry::Matches(User *u, bool full) const ret = false; if (this->HasFlag(ENTRYTYPE_HOST) && !this->host.equals_ci(u->GetDisplayedHost()) && (!full || (!this->host.equals_ci(u->host) && !this->host.equals_ci(u->chost) && !this->host.equals_ci(u->vhost) && - (!u->ip() || !this->host.equals_ci(u->ip.addr()))))) + !this->host.equals_ci(u->ip)))) ret = false; if (this->HasFlag(ENTRYTYPE_NICK_WILD) && !Anope::Match(u->nick, this->nick)) ret = false; @@ -1276,7 +1340,7 @@ bool Entry::Matches(User *u, bool full) const ret = false; if (this->HasFlag(ENTRYTYPE_HOST_WILD) && !Anope::Match(u->GetDisplayedHost(), this->host) && (!full || (!Anope::Match(u->host, this->host) && !Anope::Match(u->chost, this->host) && - !Anope::Match(u->vhost, this->host) && (!u->ip() || !Anope::Match(u->ip.addr(), this->host))))) + !Anope::Match(u->vhost, this->host) && !Anope::Match(u->ip, this->host)))) ret = false; ChannelMode *cm = ModeManager::FindChannelModeByName(this->modename); diff --git a/src/chanserv.cpp b/src/chanserv.cpp index 398617fb5..f18c919cc 100644 --- a/src/chanserv.cpp +++ b/src/chanserv.cpp @@ -12,7 +12,11 @@ /*************************************************************************/ #include "services.h" -#include "modules.h" +#include "anope.h" +#include "regchannel.h" +#include "users.h" +#include "channels.h" +#include "access.h" registered_channel_map RegisteredChannelList; @@ -184,32 +188,3 @@ int get_idealban(ChannelInfo *ci, User *u, Anope::string &ret) } } -ChanServTimer::ChanServTimer(Channel *chan) : Timer(Config->CSInhabit), c(chan) -{ - BotInfo *bi = findbot(Config->ChanServ); - if (!bi || !c) - return; - c->SetFlag(CH_INHABIT); - if (!c->ci || !c->ci->bi) - bi->Join(c); - else if (!c->FindUser(c->ci->bi)) - c->ci->bi->Join(c); -} - -void ChanServTimer::Tick(time_t) -{ - if (!c) - return; - - c->UnsetFlag(CH_INHABIT); - - if (!c->ci || !c->ci->bi) - { - BotInfo *bi = findbot(Config->ChanServ); - if (bi) - bi->Part(c); - } - else if (c->users.size() == 1 || c->users.size() < Config->BSMinUsers) - c->ci->bi->Part(c); -} - diff --git a/src/command.cpp b/src/command.cpp index 75271867b..309611a92 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -6,8 +6,12 @@ */ #include "services.h" -#include "modules.h" #include "commands.h" +#include "extern.h" +#include "users.h" +#include "language.h" +#include "config.h" +#include "bots.h" void CommandSource::Reply(const char *message, ...) { diff --git a/src/config.cpp b/src/config.cpp index d35399896..784142556 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -12,6 +12,11 @@ #include "services.h" #include "config.h" #include "module.h" +#include "extern.h" +#include "bots.h" +#include "access.h" +#include "opertype.h" +#include "channels.h" /*************************************************************************/ @@ -510,7 +515,7 @@ bool InitUplinks(ServerConfig *config, const Anope::string &) { if (!config->Uplinks.empty()) { - std::vector<Uplink *>::iterator curr_uplink = config->Uplinks.begin(), end_uplink = config->Uplinks.end(); + std::vector<ServerConfig::Uplink *>::iterator curr_uplink = config->Uplinks.begin(), end_uplink = config->Uplinks.end(); for (; curr_uplink != end_uplink; ++curr_uplink) delete *curr_uplink; } @@ -535,7 +540,7 @@ static bool DoUplink(ServerConfig *config, const Anope::string &, const Anope::s if (!ValidateNotEmpty(config, "uplink", "password", vi_password)) throw ConfigException("One or more values in your configuration file failed to validate. Please see your log for more information."); // If we get here, all the values are valid, we'll add it to the Uplinks list - config->Uplinks.push_back(new Uplink(host, port, password, ipv6)); + config->Uplinks.push_back(new ServerConfig::Uplink(host, port, password, ipv6)); return true; } diff --git a/src/configreader.cpp b/src/configreader.cpp index 9d6d49c2b..0bbdb0e49 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -24,6 +24,7 @@ */ #include "services.h" +#include "config.h" ConfigReader::ConfigReader() : error(CONF_NO_ERROR) { diff --git a/src/dns.cpp b/src/dns.cpp index fc1ab37df..d9010b8f9 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -1,4 +1,23 @@ +/* + * + * (C) 2003-2012 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. + */ + #include "services.h" +#include "anope.h" +#include "dns.h" +#include "sockets.h" +#include "socketengine.h" + +#include <sys/types.h> +#include <sys/socket.h> +#include <netdb.h> DNSManager *DNSEngine = NULL; @@ -320,11 +339,10 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size if (q.type == DNS_QUERY_PTR) { + sockaddrs ip(q.name); + if (q.name.find(':') != Anope::string::npos) { - sockaddrs ip; - ip.pton(AF_INET6, q.name); - static const char *const hex = "0123456789abcdef"; char reverse_ip[128]; unsigned reverse_ip_count = 0; @@ -342,9 +360,6 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size } else { - sockaddrs ip; - ip.pton(AF_INET, q.name); - unsigned long forward = ip.sa4.sin_addr.s_addr; in_addr reverse; reverse.s_addr = forward << 24 | (forward & 0xFF00) << 8 | (forward & 0xFF0000) >> 8 | forward >> 24; @@ -399,8 +414,7 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size if (pos + 6 > output_size) throw SocketException("Unable to pack packet"); - sockaddrs addr; - addr.pton(AF_INET, rr.rdata); + sockaddrs addr(rr.rdata); s = htons(4); memcpy(&output[pos], &s, 2); @@ -415,8 +429,7 @@ unsigned short DNSPacket::Pack(unsigned char *output, unsigned short output_size if (pos + 18 > output_size) throw SocketException("Unable to pack packet"); - sockaddrs addr; - addr.pton(AF_INET6, rr.rdata); + sockaddrs addr(rr.rdata); s = htons(16); memcpy(&output[pos], &s, 2); diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 94b899536..84773b369 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -9,6 +9,8 @@ */ #include "services.h" +#include "hashcomp.h" +#include "anope.h" /* * diff --git a/src/hostserv.cpp b/src/hostserv.cpp deleted file mode 100644 index dde6d44ce..000000000 --- a/src/hostserv.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* HostServ functions - * - * (C) 2003-2012 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. - */ - -#include "services.h" -#include "modules.h" - - -/** Set a vhost for the user - * @param ident The ident - * @param host The host - * @param creator Who created the vhost - * @param time When the vhost was craated - */ -void HostInfo::SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created) -{ - Ident = ident; - Host = host; - Creator = creator; - Time = created; -} - -/** Remove a users vhost - **/ -void HostInfo::RemoveVhost() -{ - Ident.clear(); - Host.clear(); - Creator.clear(); - Time = 0; -} - -/** Check if the user has a vhost - * @return true or false - */ -bool HostInfo::HasVhost() const -{ - return !Host.empty(); -} - -/** Retrieve the vhost ident - * @return the ident - */ -const Anope::string &HostInfo::GetIdent() const -{ - return Ident; -} - -/** Retrieve the vhost host - * @return the host - */ -const Anope::string &HostInfo::GetHost() const -{ - return Host; -} - -/** Retrieve the vhost creator - * @return the creator - */ -const Anope::string &HostInfo::GetCreator() const -{ - return Creator; -} - -/** Retrieve when the vhost was crated - * @return the time it was created - */ -time_t HostInfo::GetTime() const -{ - return Time; -} - diff --git a/src/init.cpp b/src/init.cpp index 2a87ade9c..a161f9c6f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -10,10 +10,21 @@ */ #include "services.h" -#include "modules.h" +#include "config.h" +#include "extern.h" +#include "users.h" +#include "protocol.h" +#include "bots.h" #include "oper.h" +#include "signals.h" +#include "socketengine.h" +#include "servers.h" -Uplink *uplink_server; +#include <sys/types.h> +#include <sys/wait.h> +#include <sys/stat.h> + +ServerConfig::Uplink *uplink_server; void introduce_user(const Anope::string &user) { diff --git a/src/language.cpp b/src/language.cpp index 222008b8c..1a374c0bc 100644 --- a/src/language.cpp +++ b/src/language.cpp @@ -1,6 +1,23 @@ +/* + * + * (C) 2003-2012 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. + */ + #include "services.h" #include "modules.h" #include "commands.h" +#include "config.h" +#include "extern.h" + +#if GETTEXT_FOUND +# include <libintl.h> +#endif std::vector<Anope::string> languages; std::vector<Anope::string> domains; diff --git a/src/logger.cpp b/src/logger.cpp index 978c9cd44..508fa7b0c 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -12,6 +12,17 @@ #include "services.h" #include "modules.h" #include "commands.h" +#include "channels.h" +#include "users.h" +#include "logger.h" +#include "extern.h" +#include "config.h" +#include "bots.h" +#include "servers.h" +#include "uplink.h" +#include "protocol.h" + +#include <sys/time.h> static Anope::string GetTimeStamp() { diff --git a/src/mail.cpp b/src/mail.cpp index dcf9dea5e..cc1541640 100644 --- a/src/mail.cpp +++ b/src/mail.cpp @@ -1,4 +1,18 @@ +/* + * + * (C) 2003-2012 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. + */ + + #include "services.h" +#include "mail.h" +#include "config.h" MailThread::MailThread(const Anope::string &mailto, const Anope::string &addr, const Anope::string &subject, const Anope::string &message) : Thread(), MailTo(mailto), Addr(addr), Subject(subject), Message(message), DontQuoteAddresses(Config->DontQuoteAddresses), Success(false) { diff --git a/src/main.cpp b/src/main.cpp index 87cf8532c..55f185057 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,12 +25,18 @@ #include "services.h" #include "timers.h" -#include "modules.h" - -#ifdef _WIN32 -# include <process.h> -# define execve _execve -#endif +#include "extern.h" +#include "uplink.h" +#include "config.h" +#include "protocol.h" +#include "servers.h" +#include "bots.h" +#include "dns.h" +#include "signals.h" +#include "socketengine.h" + +#include <unistd.h> +#include <limits.h> /******** Global variables! ********/ @@ -229,7 +235,7 @@ static void Connect() if (static_cast<unsigned>(++CurrentUplink) >= Config->Uplinks.size()) CurrentUplink = 0; - Uplink *u = Config->Uplinks[CurrentUplink]; + ServerConfig::Uplink *u = Config->Uplinks[CurrentUplink]; new UplinkSocket(); if (!Config->LocalHost.empty()) @@ -340,9 +346,9 @@ int main(int ac, char **av, char **envp) /* If we're root, issue a warning now */ if (!getuid() && !getgid()) { - std::cout << "WARNING: You are currently running Anope as the root superuser. Anope does not" << std::endl; - std::cout << " require root privileges to run, and it is discouraged that you run Anope" << std::endl; - std::cout << " as the root superuser." << std::endl; + std::cerr << "WARNING: You are currently running Anope as the root superuser. Anope does not" << std::endl; + std::cerr << " require root privileges to run, and it is discouraged that you run Anope" << std::endl; + std::cerr << " as the root superuser." << std::endl; sleep(3); } #endif diff --git a/src/memoserv.cpp b/src/memoserv.cpp index bb168b939..1407e8521 100644 --- a/src/memoserv.cpp +++ b/src/memoserv.cpp @@ -9,9 +9,14 @@ * Based on the original code of Services by Andy Church. */ + #include "services.h" #include "modules.h" +#include "service.h" #include "memoserv.h" +#include "memo.h" +#include "users.h" +#include "account.h" Memo::Memo() : Flags<MemoFlag>(MemoFlagStrings) { } diff --git a/src/messages.cpp b/src/messages.cpp index a3032e79a..fa93e528c 100644 --- a/src/messages.cpp +++ b/ |
