diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:17 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:17 +0300 |
commit | d3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch) | |
tree | dd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/system/hostname.cpp | |
parent | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff) | |
download | ydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system/hostname.cpp')
-rw-r--r-- | util/system/hostname.cpp | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/util/system/hostname.cpp b/util/system/hostname.cpp index 72f1265204..386f646d6b 100644 --- a/util/system/hostname.cpp +++ b/util/system/hostname.cpp @@ -1,36 +1,36 @@ -#include <util/memory/tempbuf.h> -#include <util/generic/singleton.h> +#include <util/memory/tempbuf.h> +#include <util/generic/singleton.h> #include <util/generic/yexception.h> #include <util/network/ip.h> - + #if defined(_unix_) - #include <unistd.h> - #include <ifaddrs.h> - #include <netdb.h> + #include <unistd.h> + #include <ifaddrs.h> + #include <netdb.h> #endif - -#if defined(_win_) - #include <WinSock2.h> + +#if defined(_win_) + #include <WinSock2.h> #endif #include "defaults.h" #include "yassert.h" -#include "hostname.h" - -namespace { - struct THostNameHolder { - inline THostNameHolder() { - TTempBuf hostNameBuf; - - if (gethostname(hostNameBuf.Data(), hostNameBuf.Size() - 1)) { - ythrow TSystemError() << "can not get host name"; - } - - HostName = hostNameBuf.Data(); +#include "hostname.h" + +namespace { + struct THostNameHolder { + inline THostNameHolder() { + TTempBuf hostNameBuf; + + if (gethostname(hostNameBuf.Data(), hostNameBuf.Size() - 1)) { + ythrow TSystemError() << "can not get host name"; + } + + HostName = hostNameBuf.Data(); } - + TString HostName; - }; + }; struct TFQDNHostNameHolder { inline TFQDNHostNameHolder() { @@ -62,15 +62,15 @@ namespace { TString FQDNHostName; }; -} - +} + const TString& HostName() { - return (Singleton<THostNameHolder>())->HostName; -} - -const char* GetHostName() { + return (Singleton<THostNameHolder>())->HostName; +} + +const char* GetHostName() { return HostName().data(); -} +} const TString& FQDNHostName() { return (Singleton<TFQDNHostNameHolder>())->FQDNHostName; |