diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/system/hostname.cpp | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 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 386f646d6b..72f1265204 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; |