summaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 082f39b96..a0c46cb2f 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -23,10 +23,10 @@
#include <sys/wait.h>
#include <sys/stat.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <pwd.h>
+#include <cerrno>
#include <grp.h>
+#include <pwd.h>
+#include <sys/types.h>
#endif
Anope::string Anope::ConfigDir = "conf", Anope::DataDir = "data", Anope::ModuleDir = "lib", Anope::LocaleDir = "locale", Anope::LogDir = "logs";
@@ -57,7 +57,7 @@ static void ParseCommandLineArguments(int ac, char **av)
if (option.empty())
continue;
- CommandLineArguments.push_back(std::make_pair(option, param));
+ CommandLineArguments.emplace_back(option, param);
}
}
@@ -71,11 +71,11 @@ static bool GetCommandLineArgument(const Anope::string &name, char shortname, An
{
param.clear();
- for (std::vector<std::pair<Anope::string, Anope::string> >::iterator it = CommandLineArguments.begin(), it_end = CommandLineArguments.end(); it != it_end; ++it)
+ for (const auto &[argument, value] : CommandLineArguments)
{
- if (it->first.equals_ci(name) || (it->first.length() == 1 && it->first[0] == shortname))
+ if (argument.equals_ci(name) || (argument.length() == 1 && argument[0] == shortname))
{
- param = it->second;
+ param = argument;
return true;
}
}
@@ -258,14 +258,10 @@ static void setuidgid()
gid = g->gr_gid;
}
- for (unsigned i = 0; i < Config->LogInfos.size(); ++i)
+ for (const auto &li : Config->LogInfos)
{
- LogInfo& li = Config->LogInfos[i];
-
- for (unsigned j = 0; j < li.logfiles.size(); ++j)
+ for (const auto *lf : li.logfiles)
{
- LogFile* lf = li.logfiles[j];
-
errno = 0;
if (chown(lf->filename.c_str(), uid, gid) != 0)
Log() << "Unable to change the ownership of " << lf->filename << " to " << uid << "/" << gid << ": " << Anope::LastError();
@@ -411,7 +407,7 @@ void Anope::Init(int ac, char **av)
Anope::LogDir = arg;
}
- /* Chdir to Services data directory. */
+ /* Chdir to Anope data directory. */
if (chdir(Anope::ServicesDir.c_str()) < 0)
{
throw CoreException("Unable to chdir to " + Anope::ServicesDir + ": " + Anope::LastError());
@@ -479,7 +475,7 @@ void Anope::Init(int ac, char **av)
catch (const ConfigException &ex)
{
Log(LOG_TERMINAL) << ex.GetReason();
- Log(LOG_TERMINAL) << "*** Support resources: Read through the services.conf self-contained";
+ Log(LOG_TERMINAL) << "*** Support resources: Read through the anope.conf self-contained";
Log(LOG_TERMINAL) << "*** documentation. Read the documentation files found in the 'docs'";
Log(LOG_TERMINAL) << "*** folder. Visit our portal located at https://www.anope.org/. Join";
Log(LOG_TERMINAL) << "*** our support channel on /server irc.anope.org channel #anope.";
@@ -489,9 +485,9 @@ void Anope::Init(int ac, char **av)
/* Create me */
Configuration::Block *block = Config->GetBlock("serverinfo");
Me = new Server(NULL, block->Get<const Anope::string>("name"), 0, block->Get<const Anope::string>("description"), block->Get<const Anope::string>("id"));
- for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
+ for (const auto &[_, bi] : *BotListByNick)
{
- it->second->server = Me;
+ bi->server = Me;
++Me->users;
}
@@ -547,8 +543,8 @@ void Anope::Init(int ac, char **av)
Anope::string sid = IRCD->SID_Retrieve();
if (Me->GetSID() == Me->GetName())
Me->SetSID(sid);
- for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
- it->second->GenerateUID();
+ for (const auto &[_, bi] : *BotListByNick)
+ bi->GenerateUID();
}
/* Load up databases */
@@ -560,8 +556,8 @@ void Anope::Init(int ac, char **av)
FOREACH_MOD(OnPostInit, ());
- for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
- it->second->Sync();
+ for (const auto &[_, ci] : ChannelList)
+ ci->Sync();
Serialize::CheckTypes();
}