Skip to content

Commit 9264866

Browse files
committed
Update the C++ version.
1 parent cb126fc commit 9264866

17 files changed

+99
-99
lines changed

NXDNGateway/Conf.cpp

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
2+
* Copyright (C) 2015,2016,2017,2018,2020,2025 by Jonathan Naylor G4KLX
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -26,17 +26,17 @@
2626

2727
const int BUFFER_SIZE = 500;
2828

29-
enum SECTION {
30-
SECTION_NONE,
31-
SECTION_GENERAL,
32-
SECTION_INFO,
33-
SECTION_ID_LOOKUP,
34-
SECTION_VOICE,
35-
SECTION_LOG,
36-
SECTION_APRS,
37-
SECTION_NETWORK,
38-
SECTION_GPSD,
39-
SECTION_REMOTE_COMMANDS
29+
enum class SECTION {
30+
NONE,
31+
GENERAL,
32+
INFO,
33+
ID_LOOKUP,
34+
VOICE,
35+
LOG,
36+
APRS,
37+
NETWORK,
38+
GPSD,
39+
REMOTE_COMMANDS
4040
};
4141

4242
CConf::CConf(const std::string& file) :
@@ -105,7 +105,7 @@ bool CConf::read()
105105
return false;
106106
}
107107

108-
SECTION section = SECTION_NONE;
108+
SECTION section = SECTION::NONE;
109109

110110
char buffer[BUFFER_SIZE];
111111
while (::fgets(buffer, BUFFER_SIZE, fp) != NULL) {
@@ -114,25 +114,25 @@ bool CConf::read()
114114

115115
if (buffer[0U] == '[') {
116116
if (::strncmp(buffer, "[General]", 9U) == 0)
117-
section = SECTION_GENERAL;
117+
section = SECTION::GENERAL;
118118
else if (::strncmp(buffer, "[Info]", 6U) == 0)
119-
section = SECTION_INFO;
119+
section = SECTION::INFO;
120120
else if (::strncmp(buffer, "[Id Lookup]", 11U) == 0)
121-
section = SECTION_ID_LOOKUP;
121+
section = SECTION::ID_LOOKUP;
122122
else if (::strncmp(buffer, "[Voice]", 7U) == 0)
123-
section = SECTION_VOICE;
123+
section = SECTION::VOICE;
124124
else if (::strncmp(buffer, "[Log]", 5U) == 0)
125-
section = SECTION_LOG;
125+
section = SECTION::LOG;
126126
else if (::strncmp(buffer, "[APRS]", 6U) == 0)
127-
section = SECTION_APRS;
127+
section = SECTION::APRS;
128128
else if (::strncmp(buffer, "[Network]", 9U) == 0)
129-
section = SECTION_NETWORK;
129+
section = SECTION::NETWORK;
130130
else if (::strncmp(buffer, "[GPSD]", 6U) == 0)
131-
section = SECTION_GPSD;
131+
section = SECTION::GPSD;
132132
else if (::strncmp(buffer, "[Remote Commands]", 17U) == 0)
133-
section = SECTION_REMOTE_COMMANDS;
133+
section = SECTION::REMOTE_COMMANDS;
134134
else
135-
section = SECTION_NONE;
135+
section = SECTION::NONE;
136136

137137
continue;
138138
}
@@ -162,7 +162,7 @@ bool CConf::read()
162162
*p = '\0';
163163
}
164164

165-
if (section == SECTION_GENERAL) {
165+
if (section == SECTION::GENERAL) {
166166
if (::strcmp(key, "Callsign") == 0) {
167167
// Convert the callsign to upper case
168168
for (unsigned int i = 0U; value[i] != 0; i++)
@@ -185,7 +185,7 @@ bool CConf::read()
185185
m_debug = ::atoi(value) == 1;
186186
else if (::strcmp(key, "Daemon") == 0)
187187
m_daemon = ::atoi(value) == 1;
188-
} else if (section == SECTION_INFO) {
188+
} else if (section == SECTION::INFO) {
189189
if (::strcmp(key, "TXFrequency") == 0)
190190
m_txFrequency = (unsigned int)::atoi(value);
191191
else if (::strcmp(key, "RXFrequency") == 0)
@@ -202,19 +202,19 @@ bool CConf::read()
202202
m_name = value;
203203
else if (::strcmp(key, "Description") == 0)
204204
m_description = value;
205-
} else if (section == SECTION_ID_LOOKUP) {
205+
} else if (section == SECTION::ID_LOOKUP) {
206206
if (::strcmp(key, "Name") == 0)
207207
m_lookupName = value;
208208
else if (::strcmp(key, "Time") == 0)
209209
m_lookupTime = (unsigned int)::atoi(value);
210-
} else if (section == SECTION_VOICE) {
210+
} else if (section == SECTION::VOICE) {
211211
if (::strcmp(key, "Enabled") == 0)
212212
m_voiceEnabled = ::atoi(value) == 1;
213213
else if (::strcmp(key, "Language") == 0)
214214
m_voiceLanguage = value;
215215
else if (::strcmp(key, "Directory") == 0)
216216
m_voiceDirectory = value;
217-
} else if (section == SECTION_LOG) {
217+
} else if (section == SECTION::LOG) {
218218
if (::strcmp(key, "FilePath") == 0)
219219
m_logFilePath = value;
220220
else if (::strcmp(key, "FileRoot") == 0)
@@ -225,7 +225,7 @@ bool CConf::read()
225225
m_logDisplayLevel = (unsigned int)::atoi(value);
226226
else if (::strcmp(key, "FileRotate") == 0)
227227
m_logFileRotate = ::atoi(value) == 1;
228-
} else if (section == SECTION_APRS) {
228+
} else if (section == SECTION::APRS) {
229229
if (::strcmp(key, "Enable") == 0)
230230
m_aprsEnabled = ::atoi(value) == 1;
231231
else if (::strcmp(key, "Address") == 0)
@@ -238,7 +238,7 @@ bool CConf::read()
238238
m_aprsDescription = value;
239239
else if (::strcmp(key, "Symbol") == 0)
240240
m_aprsSymbol = value;
241-
} else if (section == SECTION_NETWORK) {
241+
} else if (section == SECTION::NETWORK) {
242242
if (::strcmp(key, "Port") == 0)
243243
m_networkPort = (unsigned short)::atoi(value);
244244
else if (::strcmp(key, "HostsFile1") == 0)
@@ -268,14 +268,14 @@ bool CConf::read()
268268
m_networkNetHangTime = (unsigned int)::atoi(value);
269269
else if (::strcmp(key, "Debug") == 0)
270270
m_networkDebug = ::atoi(value) == 1;
271-
} else if (section == SECTION_GPSD) {
271+
} else if (section == SECTION::GPSD) {
272272
if (::strcmp(key, "Enable") == 0)
273273
m_gpsdEnabled = ::atoi(value) == 1;
274274
else if (::strcmp(key, "Address") == 0)
275275
m_gpsdAddress = value;
276276
else if (::strcmp(key, "Port") == 0)
277277
m_gpsdPort = value;
278-
} else if (section == SECTION_REMOTE_COMMANDS) {
278+
} else if (section == SECTION::REMOTE_COMMANDS) {
279279
if (::strcmp(key, "Enable") == 0)
280280
m_remoteCommandsEnabled = ::atoi(value) == 1;
281281
else if (::strcmp(key, "Port") == 0)

NXDNGateway/GPSHandler.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018,2020 by Jonathan Naylor G4KLX
2+
* Copyright (C) 2018,2020,2025 by Jonathan Naylor G4KLX
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -169,27 +169,27 @@ bool CGPSHandler::checkXOR() const
169169

170170
bool CGPSHandler::processKenwood()
171171
{
172-
enum {
173-
GPS_FULL,
174-
GPS_SHORT,
175-
GPS_VERY_SHORT
172+
enum class GPS {
173+
FULL,
174+
SHORT,
175+
VERY_SHORT
176176
} type;
177177

178178
switch (m_data[0U]) {
179179
case 0x00U:
180180
if (m_length < 38U)
181181
return false;
182-
type = GPS_FULL;
182+
type = GPS::FULL;
183183
break;
184184
case 0x01U:
185185
if (m_length < 17U)
186186
return false;
187-
type = GPS_SHORT;
187+
type = GPS::SHORT;
188188
break;
189189
case 0x02U:
190190
if (m_length < 15U)
191191
return false;
192-
type = GPS_VERY_SHORT;
192+
type = GPS::VERY_SHORT;
193193
break;
194194
default:
195195
return true;
@@ -201,7 +201,7 @@ bool CGPSHandler::processKenwood()
201201
unsigned char east = 'E';
202202
unsigned int lonAfter = 0x7FFFU;
203203
unsigned int lonBefore = 0xFFFFU;
204-
if (type == GPS_VERY_SHORT) {
204+
if (type == GPS::VERY_SHORT) {
205205
north = (m_data[7U] & 0x01U) == 0x00U ? 'N' : 'S';
206206
latAfter = ((m_data[7U] & 0xFEU) >> 1) | (m_data[8U] << 7);
207207
latBefore = (m_data[10U] << 8) | m_data[9U];
@@ -225,7 +225,7 @@ bool CGPSHandler::processKenwood()
225225
unsigned int course = 0xFFFFU;
226226
unsigned int speedBefore = 0x3FFU;
227227
unsigned int speedAfter = 0x0FU;
228-
if (type == GPS_FULL) {
228+
if (type == GPS::FULL) {
229229
course = (m_data[23U] << 4) | (m_data[24U] & 0x0FU);
230230
speedBefore = ((m_data[25U] & 0xF0U) << 2) | (m_data[26U] & 0x3FU);
231231
speedAfter = m_data[25U] & 0x0FU;

NXDNGateway/IcomNetwork.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2009-2014,2016,2018,2020 by Jonathan Naylor G4KLX
2+
* Copyright (C) 2009-2014,2016,2018,2020,2025 by Jonathan Naylor G4KLX
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -102,7 +102,7 @@ unsigned int CIcomNetwork::read(unsigned char* data)
102102
if (length <= 0)
103103
return 0U;
104104

105-
if (!CUDPSocket::match(m_addr, addr, IMT_ADDRESS_ONLY)) {
105+
if (!CUDPSocket::match(m_addr, addr, IPMATCHTYPE::ADDRESS_ONLY)) {
106106
LogWarning("Icom Data received from an unknown address");
107107
return 0U;
108108
}

NXDNGateway/KenwoodNetwork.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ unsigned int CKenwoodNetwork::readRTP(unsigned char* data)
567567
return 0U;
568568

569569
// Check if the data is for us
570-
if (!CUDPSocket::match(m_rtpAddr, addr, IMT_ADDRESS_ONLY)) {
570+
if (!CUDPSocket::match(m_rtpAddr, addr, IPMATCHTYPE::ADDRESS_ONLY)) {
571571
LogMessage("Kenwood RTP packet received from an invalid source");
572572
return 0U;
573573
}
@@ -593,7 +593,7 @@ unsigned int CKenwoodNetwork::readRTCP(unsigned char* data)
593593
return 0U;
594594

595595
// Check if the data is for us
596-
if (!CUDPSocket::match(m_rtcpAddr, addr, IMT_ADDRESS_ONLY)) {
596+
if (!CUDPSocket::match(m_rtcpAddr, addr, IPMATCHTYPE::ADDRESS_ONLY)) {
597597
LogMessage("Kenwood RTCP packet received from an invalid source");
598598
return 0U;
599599
}

NXDNGateway/Log.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX
2+
* Copyright (C) 2015,2016,2020,2025 by Jonathan Naylor G4KLX
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -167,7 +167,7 @@ void Log(unsigned int level, const char* fmt, ...)
167167
va_list vl;
168168
va_start(vl, fmt);
169169

170-
::vsnprintf(buffer + ::strlen(buffer), 500, fmt, vl);
170+
::vsnprintf(buffer + ::strlen(buffer), 500 - ::strlen(buffer), fmt, vl);
171171

172172
va_end(vl);
173173

NXDNGateway/UDPSocket.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2006-2016,2020,2024 by Jonathan Naylor G4KLX
2+
* Copyright (C) 2006-2016,2020,2024,2025 by Jonathan Naylor G4KLX
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -119,7 +119,7 @@ bool CUDPSocket::match(const sockaddr_storage& addr1, const sockaddr_storage& ad
119119
if (addr1.ss_family != addr2.ss_family)
120120
return false;
121121

122-
if (type == IMT_ADDRESS_AND_PORT) {
122+
if (type == IPMATCHTYPE::ADDRESS_AND_PORT) {
123123
switch (addr1.ss_family) {
124124
case AF_INET:
125125
struct sockaddr_in *in_1, *in_2;
@@ -134,7 +134,7 @@ bool CUDPSocket::match(const sockaddr_storage& addr1, const sockaddr_storage& ad
134134
default:
135135
return false;
136136
}
137-
} else if (type == IMT_ADDRESS_ONLY) {
137+
} else if (type == IPMATCHTYPE::ADDRESS_ONLY) {
138138
switch (addr1.ss_family) {
139139
case AF_INET:
140140
struct sockaddr_in *in_1, *in_2;

NXDNGateway/UDPSocket.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2009-2011,2013,2015,2016,2020,2024 by Jonathan Naylor G4KLX
2+
* Copyright (C) 2009-2011,2013,2015,2016,2020,2024,2025 by Jonathan Naylor G4KLX
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -35,9 +35,9 @@
3535
#include <ws2tcpip.h>
3636
#endif
3737

38-
enum IPMATCHTYPE {
39-
IMT_ADDRESS_AND_PORT,
40-
IMT_ADDRESS_ONLY
38+
enum class IPMATCHTYPE {
39+
ADDRESS_AND_PORT,
40+
ADDRESS_ONLY
4141
};
4242

4343
class CUDPSocket {
@@ -60,7 +60,7 @@ class CUDPSocket {
6060
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& addressLength);
6161
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& addressLength, struct addrinfo& hints);
6262

63-
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT);
63+
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IPMATCHTYPE::ADDRESS_AND_PORT);
6464

6565
static bool isNone(const sockaddr_storage& addr);
6666

NXDNGateway/Version.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015-2018,2020,2023,2024 by Jonathan Naylor G4KLX
2+
* Copyright (C) 2015-2018,2020,2023,2024,2025 by Jonathan Naylor G4KLX
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,6 @@
1919
#if !defined(VERSION_H)
2020
#define VERSION_H
2121

22-
const char* VERSION = "20240831";
22+
const char* VERSION = "20250319";
2323

2424
#endif

0 commit comments

Comments
 (0)