Allow the programs to build on Windows again.

This commit is contained in:
Jonathan Naylor
2024-04-22 13:36:44 +01:00
parent eb26a6233e
commit 512f53e05f
8 changed files with 137 additions and 19 deletions
+26 -15
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2018,2020,2024 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +23,7 @@
#include "Version.h"
#include "Thread.h"
#include "Timer.h"
#include "GitVersion.h"
#include <cstdio>
#include <cstdlib>
@@ -30,21 +31,31 @@
int main(int argc, char** argv)
{
if (argc == 1) {
::fprintf(stderr, "Usage: P25Parrot <port>\n");
return 1;
if (argc > 1) {
for (int currentArg = 1; currentArg < argc; ++currentArg) {
std::string arg = argv[currentArg];
if ((arg == "-v") || (arg == "--version")) {
::fprintf(stdout, "P25Parrot version %s git #%.7s\n", VERSION, gitversion);
return 0;
}
else if (arg.substr(0, 1) == "-") {
::fprintf(stderr, "Usage: P25Parrot [-v|--version] [-d|--debug] <port>\n");
return 1;
}
else {
unsigned short port = (unsigned short)::atoi(argv[1U]);
if (port == 0U) {
::fprintf(stderr, "P25Parrot: invalid port number - %s\n", argv[1U]);
return 1;
}
CP25Parrot parrot(port);
parrot.run();
return 0;
}
}
}
unsigned short port = (unsigned short)::atoi(argv[1U]);
if (port == 0U) {
::fprintf(stderr, "P25Parrot: invalid port number - %s\n", argv[1U]);
return 1;
}
CP25Parrot parrot(port);
parrot.run();
return 0;
}
CP25Parrot::CP25Parrot(unsigned short port) :