From aa2a3b3fc22b5156611d68b2c1871b66c79f9285 Mon Sep 17 00:00:00 2001 From: fvanroie <15969459+fvanroie@users.noreply.github.com> Date: Sun, 21 Feb 2021 00:08:07 +0100 Subject: [PATCH] Add name command line parameter --- src/main_windows.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main_windows.cpp b/src/main_windows.cpp index 35d5e478..7e4c6e4e 100644 --- a/src/main_windows.cpp +++ b/src/main_windows.cpp @@ -194,6 +194,26 @@ int main(int argc, char* argv[]) InitializeConsoleOutput(); + char hostbuffer[256]; + char* IPbuffer; + struct hostent* host_entry; + int hostname; + + // To retrieve hostname + hostname = gethostname(hostbuffer, sizeof(hostbuffer)); + // checkHostName(hostname); + + // To retrieve host information + host_entry = gethostbyname(hostbuffer); + // checkHostEntry(host_entry); + + // To convert an Internet network + // address into ASCII string + // IPbuffer = inet_ntoa(*((struct in_addr*)host_entry->h_addr_list[0])); + + printf("Hostname: %s", hostbuffer); + // printf("Host IP: %s", IPbuffer); + // Display each command-line argument. std::cout << "\nCommand-line arguments:\n"; for(count = 0; count < argc; count++) @@ -225,7 +245,7 @@ int main(int argc, char* argv[]) std::cout << " argv[" << count << "] " << argv[count] << "\n" << std::endl << std::flush; fflush(stdout); if(count + 1 < argc) { - haspDevice.set_hostname(argv[count] + 1); + haspDevice.set_hostname(argv[count + 1]); } else { showhelp = true; } @@ -247,7 +267,6 @@ int main(int argc, char* argv[]) monitor_title(haspDevice.get_hostname()); while(isRunning) { - loop(); // std::cout << "HSetup OK\n"; }