mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
Add name command line parameter
This commit is contained in:
parent
578ab09318
commit
aa2a3b3fc2
@ -194,6 +194,26 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
InitializeConsoleOutput();
|
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.
|
// Display each command-line argument.
|
||||||
std::cout << "\nCommand-line arguments:\n";
|
std::cout << "\nCommand-line arguments:\n";
|
||||||
for(count = 0; count < argc; count++)
|
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;
|
std::cout << " argv[" << count << "] " << argv[count] << "\n" << std::endl << std::flush;
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if(count + 1 < argc) {
|
if(count + 1 < argc) {
|
||||||
haspDevice.set_hostname(argv[count] + 1);
|
haspDevice.set_hostname(argv[count + 1]);
|
||||||
} else {
|
} else {
|
||||||
showhelp = true;
|
showhelp = true;
|
||||||
}
|
}
|
||||||
@ -247,7 +267,6 @@ int main(int argc, char* argv[])
|
|||||||
monitor_title(haspDevice.get_hostname());
|
monitor_title(haspDevice.get_hostname());
|
||||||
|
|
||||||
while(isRunning) {
|
while(isRunning) {
|
||||||
|
|
||||||
loop();
|
loop();
|
||||||
// std::cout << "HSetup OK\n";
|
// std::cout << "HSetup OK\n";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user