diff options
Diffstat (limited to 'src/session.cc')
-rw-r--r-- | src/session.cc | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/src/session.cc b/src/session.cc index b6a0834..41192cb 100644 --- a/src/session.cc +++ b/src/session.cc @@ -1,7 +1,8 @@ -/** -------------------------------------------------------------------- +/** * @file session.cc * @brief Implementation of the Session class. - * ------------------------------------------------------------------ **/ + */ + #include "session.h" #include "argparser.h" @@ -15,12 +16,11 @@ #include <syslog.h> #include <unistd.h> -using namespace ::std; using namespace Binc; +using std::string; extern char **environ; -//---------------------------------------------------------------------- Session::Session(void) { readbytes = 0; @@ -31,110 +31,92 @@ Session::Session(void) logfacility = LOG_DAEMON; } -//---------------------------------------------------------------------- Session &Session::getInstance(void) { static Session session; return session; } -//---------------------------------------------------------------------- -const int Session::getState(void) const +int Session::getState(void) const { return state; } -//---------------------------------------------------------------------- void Session::setState(int n) { state = n; } -//---------------------------------------------------------------------- const string &Session::getUserID(void) const { return userid; } -//---------------------------------------------------------------------- void Session::setUserID(const string &s) { userid = s; } -//---------------------------------------------------------------------- const string &Session::getIP(void) const { return ip; } -//---------------------------------------------------------------------- void Session::setIP(const string &s) { ip = s; } -//---------------------------------------------------------------------- void Session::setLogFacility(int facility) { logfacility = facility; } -//---------------------------------------------------------------------- int Session::getLogFacility(void) const { return logfacility; } -//---------------------------------------------------------------------- void Session::addBody(void) { ++bodies; } -//---------------------------------------------------------------------- void Session::addStatement(void) { ++statements; } -//---------------------------------------------------------------------- void Session::addReadBytes(int i) { readbytes += i; } -//---------------------------------------------------------------------- void Session::addWriteBytes(int i) { writebytes += i; } -//---------------------------------------------------------------------- int Session::getBodies(void) const { return bodies; } -//---------------------------------------------------------------------- int Session::getStatements(void) const { return statements; } -//---------------------------------------------------------------------- int Session::getWriteBytes(void) const { return writebytes; } -//---------------------------------------------------------------------- int Session::getReadBytes(void) const { return readbytes; } -//---------------------------------------------------------------------- bool Session::parseCommandLine(int argc, char *argv[]) { args.addOptional("h|help", "Display this help screen", true); @@ -158,7 +140,6 @@ bool Session::parseCommandLine(int argc, char *argv[]) return true; } -//---------------------------------------------------------------------- void Session::assignCommandLineArgs(void) { if (args.hasArg("allow-plain")) setEnv("ALLOW_NONSSL_PLAINTEXT_LOGINS", "yes"); @@ -172,37 +153,31 @@ void Session::assignCommandLineArgs(void) if (args.hasArg("delimiter")) setEnv("DELIMITER", args["delimiter"]); } -//---------------------------------------------------------------------- const string &Session::getLastError(void) const { return lastError; } -//---------------------------------------------------------------------- void Session::setLastError(const string &error) const { lastError = error; } -//---------------------------------------------------------------------- const string &Session::getResponseCode(void) const { return responseCode; } -//---------------------------------------------------------------------- void Session::setResponseCode(const string &code) const { responseCode = "[" + code + "] "; } -//---------------------------------------------------------------------- void Session::clearResponseCode(void) const { responseCode = ""; } -//---------------------------------------------------------------------- pid_t Session::getPid(void) { if (pid == 0) pid = getpid(); @@ -210,26 +185,22 @@ pid_t Session::getPid(void) return pid; } -//---------------------------------------------------------------------- int Session::timeout() const { return state == NONAUTHENTICATED ? AUTH_TIMEOUT : IDLE_TIMEOUT; } -//---------------------------------------------------------------------- bool Session::hasEnv(const string &key) const { - return getenv(key.c_str()) != 0; + return getenv(key.c_str()) != nullptr; } -//---------------------------------------------------------------------- string Session::getEnv(const string &key) { char *c = getenv(key.c_str()); return c ? c : ""; } -//---------------------------------------------------------------------- void Session::setEnv(const string &key, const string &value) { string env = key + "=" + value; |