Alexander Hansen | 1060065 | 2025-08-07 17:48:24 +0200 | [diff] [blame] | 1 | #pragma once |
2 | |||||
Malik Akbar Hashemi Rafsanjani | 4d7b5dd | 2025-02-26 13:14:30 -0800 | [diff] [blame] | 3 | #include <unistd.h> |
4 | |||||
5 | #include <array> | ||||
6 | #include <climits> | ||||
7 | #include <string> | ||||
8 | |||||
9 | inline std::string getHostName() | ||||
10 | { | ||||
11 | std::string hostName; | ||||
12 | |||||
13 | std::array<char, HOST_NAME_MAX> hostNameCStr{}; | ||||
14 | if (gethostname(hostNameCStr.data(), hostNameCStr.size()) == 0) | ||||
15 | { | ||||
16 | hostName = hostNameCStr.data(); | ||||
17 | } | ||||
18 | return hostName; | ||||
19 | } |