xref: /openbmc/bmcweb/include/identity.hpp (revision 4025211cd2c60a0caa5537171cf4b902f7566835)
1 #include <unistd.h>
2 
3 #include <array>
4 #include <climits>
5 #include <string>
6 
7 inline std::string getHostName()
8 {
9     std::string hostName;
10 
11     std::array<char, HOST_NAME_MAX> hostNameCStr{};
12     if (gethostname(hostNameCStr.data(), hostNameCStr.size()) == 0)
13     {
14         hostName = hostNameCStr.data();
15     }
16     return hostName;
17 }
18