tools/hexnet: add server/client concept to arguments parser
parent
b3cd8709fb
commit
6a5096dfa3
|
@ -18,7 +18,7 @@
|
|||
#include <cstdint>
|
||||
#include <cctype>
|
||||
|
||||
#define usage std::cerr << "Usage: " << argv[0] << " [-4|-6] [-t|-u] <port>" << std::endl << "<port> may be hexadecimal (prefixed with 0x) or binary (prefixed with 0b)." << std::endl
|
||||
#define usage std::cerr << "Usage: " << argv[0] << " [-4|-6] [-t|-u] <<host> <port> | -l <port>>" << std::endl << "<port> may be hexadecimal (prefixed with 0x) or binary (prefixed with 0b)." << std::endl
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
|
||||
|
@ -27,6 +27,7 @@ int main(int argc, char* argv[]){
|
|||
bool ipv6 = true;
|
||||
bool tcp = true;
|
||||
bool udp = true;
|
||||
bool server = false;
|
||||
uint16_t port;
|
||||
if (argc<2) {
|
||||
usage;
|
||||
|
@ -54,6 +55,10 @@ int main(int argc, char* argv[]){
|
|||
udp = true;
|
||||
continue;
|
||||
}
|
||||
if (argument=="-l") {
|
||||
server = true;
|
||||
continue;
|
||||
}
|
||||
if (argument=="-h") {
|
||||
usage;
|
||||
return 0;
|
||||
|
@ -62,6 +67,11 @@ int main(int argc, char* argv[]){
|
|||
usage;
|
||||
return 0;
|
||||
}
|
||||
if (!server && i==argc-2) {
|
||||
//TODO: check if valid host
|
||||
std::cerr << "Host argument parsing is not yet implemented." << std::endl;
|
||||
return 3;
|
||||
}
|
||||
if (i==argc-1) {
|
||||
if (argument.substr(0, 2)=="0b" || argument.substr(0, 2)=="0B") {
|
||||
// check for 16 bit binary number
|
||||
|
|
Loading…
Reference in New Issue