Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the Mashines Hostname as default Name #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions uxplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <string>
#include <vector>
#include <fstream>
#include <sys/utsname.h> // uname(read hostname)

#include "log.h"
#include "lib/raop.h"
Expand Down Expand Up @@ -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();

Expand All @@ -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]);
Expand Down