Merge branch 'master' into mqtt

This commit is contained in:
Jonathan Naylor 2024-08-28 16:10:16 +01:00
commit 870de67a2d
4 changed files with 48 additions and 8 deletions

View file

@ -77,7 +77,7 @@ static CDMRGateway* gateway = NULL;
const char* HEADER1 = "This software is for use on amateur radio networks only,";
const char* HEADER2 = "it is to be used for educational purposes only. Its use on";
const char* HEADER3 = "commercial networks is strictly prohibited.";
const char* HEADER4 = "Copyright(C) 2017-2023 by Jonathan Naylor, G4KLX and others";
const char* HEADER4 = "Copyright(C) 2017-2024 by Jonathan Naylor, G4KLX and others";
int main(int argc, char** argv)
{
@ -109,6 +109,7 @@ int main(int argc, char** argv)
do {
m_killed = false;
m_signal = 0;
m_killed = false; // restart, don't exit, if looping from SIGHUP (1)
gateway = new CDMRGateway(std::string(iniFile));
ret = gateway->run();

View file

@ -94,6 +94,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>prebuild.cmd</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
@ -109,10 +112,11 @@
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>"$(ProjectDir)prebuild.cmd" $(ProjectDir)</Command>
<Command>prebuild.cmd</Command>
</PreBuildEvent>
<PreBuildEvent>
<Message>prebuild.cmd generates GitVersion.h from git refs heads master</Message>
<Message>
</Message>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -132,6 +136,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>prebuild.cmd</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
@ -150,6 +157,9 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>prebuild.cmd</Command>
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="APRSWriter.h" />

View file

@ -36,7 +36,11 @@
CUDPSocket::CUDPSocket(const std::string& address, unsigned short port) :
m_localAddress(address),
m_localPort(port),
#if defined(_WIN32) || defined(_WIN64)
m_fd(INVALID_SOCKET),
#else
m_fd(-1),
#endif
m_af(AF_UNSPEC)
{
}
@ -44,7 +48,11 @@ m_af(AF_UNSPEC)
CUDPSocket::CUDPSocket(unsigned short port) :
m_localAddress(),
m_localPort(port),
#if defined(_WIN32) || defined(_WIN64)
m_fd(INVALID_SOCKET),
#else
m_fd(-1),
#endif
m_af(AF_UNSPEC)
{
}
@ -97,7 +105,9 @@ int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockadd
return err;
}
::memcpy(&addr, res->ai_addr, address_length = res->ai_addrlen);
address_length = (unsigned int)res->ai_addrlen;
::memcpy(&addr, res->ai_addr, address_length);
::freeaddrinfo(res);
@ -160,7 +170,11 @@ bool CUDPSocket::open(const sockaddr_storage& address)
bool CUDPSocket::open()
{
#if defined(_WIN32) || defined(_WIN64)
assert(m_fd == INVALID_SOCKET);
#else
assert(m_fd == -1);
#endif
sockaddr_storage addr;
unsigned int addrlen;
@ -221,7 +235,14 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storag
{
assert(buffer != NULL);
assert(length > 0U);
assert(m_fd >= 0);
#if defined(_WIN32) || defined(_WIN64)
if (m_fd == INVALID_SOCKET)
return 0;
#else
if (m_fd == -1)
return 0;
#endif
// Check that the readfrom() won't block
struct pollfd pfd;
@ -282,7 +303,11 @@ bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const s
{
assert(buffer != NULL);
assert(length > 0U);
#if defined(_WIN32) || defined(_WIN64)
assert(m_fd != INVALID_SOCKET);
#else
assert(m_fd >= 0);
#endif
bool result = false;
@ -313,13 +338,16 @@ bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const s
void CUDPSocket::close()
{
if (m_fd >= 0) {
#if defined(_WIN32) || defined(_WIN64)
if (m_fd != INVALID_SOCKET) {
::closesocket(m_fd);
m_fd = INVALID_SOCKET;
}
#else
if (m_fd >= 0) {
::close(m_fd);
#endif
m_fd = -1;
}
#endif
}

View file

@ -69,10 +69,11 @@ private:
unsigned short m_localPort;
#if defined(_WIN32) || defined(_WIN64)
SOCKET m_fd;
int m_af;
#else
int m_fd;
#endif
sa_family_t m_af;
#endif
};
#endif