From 1a7c572099edf744d6bb67318cff215de3fcd897 Mon Sep 17 00:00:00 2001 From: "Jannis M. Hoffmann" Date: Tue, 10 Oct 2023 23:40:00 +0200 Subject: turned Tools class into a namespace use Tools::get/setenv in more places --- src/session-initialize-bincimapd.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/session-initialize-bincimapd.cc') diff --git a/src/session-initialize-bincimapd.cc b/src/session-initialize-bincimapd.cc index 871510b..e98f0af 100644 --- a/src/session-initialize-bincimapd.cc +++ b/src/session-initialize-bincimapd.cc @@ -32,8 +32,6 @@ using namespace Binc; using std::endl; using std::string; -extern char **environ; - bool Session::initialize(int argc, char *argv[]) { IOFactory &ioFactory = IOFactory::getInstance(); @@ -65,9 +63,8 @@ bool Session::initialize(int argc, char *argv[]) session.assignCommandLineArgs(); // log settings - string ip = getenv("TCP6REMOTEIP") ? getenv("TCP6REMOTEIP") - : getenv("TCPREMOTEIP") ? getenv("TCPREMOTEIP") - : "?"; + string ip = Tools::getenv("TCP6REMOTEIP") + .value_or(Tools::getenv("TCPREMOTEIP").value_or("?")); session.setIP(ip); string logtype = session.getEnv("LOG_TYPE"); @@ -116,8 +113,8 @@ bool Session::initialize(int argc, char *argv[]) string pid = std::to_string(session.getPid()); - char *logindetails = getenv("BINCIMAP_LOGIN"); - if (logindetails == nullptr) { + auto logindetails = Tools::getenv("BINCIMAP_LOGIN"); + if (!logindetails) { bincLog << "bincimapd: pid " << pid << " BINCIMAP_LOGIN missing from environment (are you sure you invoked " << argv[0] << " properly?)\n"; @@ -199,7 +196,7 @@ bool Session::initialize(int argc, char *argv[]) session.setState(Session::AUTHENTICATED); - const string details = logindetails; + const string details = *logindetails; string::size_type det = details.find('+'); if (det == string::npos) { bincLog << "bincimapd: pid " << pid -- cgit v1.2.3