diff --git a/uxplay.cpp b/uxplay.cpp index c1e6b8ae..b91151d8 100755 --- a/uxplay.cpp +++ b/uxplay.cpp @@ -24,6 +24,7 @@ #include #include #include +#include // uname(read hostname) #include "log.h" #include "lib/raop.h" @@ -102,6 +103,18 @@ void print_info(char *name) { printf("-v/-h Displays this help and version information\n"); } +/* read the mashines hostname an write it into name */ +void get_hostname(std::string& name) { + struct utsname buf; + int res = uname(&buf); + if(res) { + //error + printf("could not read hostname: %d %s\n", res, strerror(res)); + return; + } + name = buf.nodename; +} + int main(int argc, char *argv[]) { init_signals(); @@ -112,6 +125,8 @@ int main(int argc, char *argv[]) { bool low_latency = DEFAULT_LOW_LATENCY; bool debug_log = DEFAULT_DEBUG_LOG; + get_hostname(server_name); + // Parse arguments for (int i = 1; i < argc; i++) { std::string arg(argv[i]);