Update the C++ version.

This commit is contained in:
Jonathan Naylor 2025-03-19 17:49:49 +00:00
parent b536f95e7e
commit e57b43377c
59 changed files with 687 additions and 679 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2014,2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2010-2014,2016,2017,2018,2020,2025 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
@ -106,7 +106,7 @@ bool CAPRSWriter::open()
return false;
}
::gps_stream(&m_gpsdData, WATCH_ENABLE | WATCH_JSON, NULL);
::gps_stream(&m_gpsdData, WATCH_ENABLE | WATCH_JSON, nullptr);
LogMessage("Connected to GPSD");
}
@ -125,8 +125,8 @@ bool CAPRSWriter::open()
void CAPRSWriter::write(const unsigned char* source, const char* type, unsigned char radio, float fLatitude, float fLongitude)
{
assert(source != NULL);
assert(type != NULL);
assert(source != nullptr);
assert(type != nullptr);
char callsign[15U];
::memcpy(callsign, source, YSF_CALLSIGN_LENGTH);
@ -219,7 +219,7 @@ void CAPRSWriter::close()
#if defined(USE_GPSD)
if (m_gpsdEnabled) {
::gps_stream(&m_gpsdData, WATCH_DISABLE, NULL);
::gps_stream(&m_gpsdData, WATCH_DISABLE, nullptr);
::gps_close(&m_gpsdData);
}
#endif
@ -300,7 +300,7 @@ void CAPRSWriter::sendIdFrameMobile()
return;
#if GPSD_API_MAJOR_VERSION >= 7
if (::gps_read(&m_gpsdData, NULL, 0) <= 0)
if (::gps_read(&m_gpsdData, nullptr, 0) <= 0)
return;
#else
if (::gps_read(&m_gpsdData) <= 0)

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2025 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
@ -63,7 +63,7 @@ const uint16_t CCITT16_TABLE2[] = {
void CCRC::addCCITT16(unsigned char *in, unsigned int length)
{
assert(in != NULL);
assert(in != nullptr);
assert(length > 2U);
union {
@ -84,7 +84,7 @@ void CCRC::addCCITT16(unsigned char *in, unsigned int length)
bool CCRC::checkCCITT16(const unsigned char *in, unsigned int length)
{
assert(in != NULL);
assert(in != nullptr);
assert(length > 2U);
union {
@ -104,7 +104,7 @@ bool CCRC::checkCCITT16(const unsigned char *in, unsigned int length)
unsigned char CCRC::addCRC(const unsigned char* in, unsigned int length)
{
assert(in != NULL);
assert(in != nullptr);
unsigned char crc = 0U;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015-2020,2025 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
@ -27,17 +27,17 @@
const int BUFFER_SIZE = 500;
enum SECTION {
SECTION_NONE,
SECTION_GENERAL,
SECTION_INFO,
SECTION_LOG,
SECTION_APRS,
SECTION_YSF_NETWORK,
SECTION_FCS_NETWORK,
SECTION_IMRS_NETWORK,
SECTION_DGID,
SECTION_GPSD
enum class SECTION {
NONE,
GENERAL,
INFO,
LOG,
APRS,
YSF_NETWORK,
FCS_NETWORK,
IMRS_NETWORK,
DGID,
GPSD
};
CConf::CConf(const std::string& file) :
@ -96,54 +96,54 @@ CConf::~CConf()
bool CConf::read()
{
FILE* fp = ::fopen(m_file.c_str(), "rt");
if (fp == NULL) {
if (fp == nullptr) {
::fprintf(stderr, "Couldn't open the .ini file - %s\n", m_file.c_str());
return false;
}
SECTION section = SECTION_NONE;
SECTION section = SECTION::NONE;
DGIdData* dgIdData = NULL;
DGIdData* dgIdData = nullptr;
char buffer[BUFFER_SIZE];
while (::fgets(buffer, BUFFER_SIZE, fp) != NULL) {
while (::fgets(buffer, BUFFER_SIZE, fp) != nullptr) {
if (buffer[0U] == '#')
continue;
if (buffer[0U] == '[') {
if (::strncmp(buffer, "[General]", 9U) == 0)
section = SECTION_GENERAL;
section = SECTION::GENERAL;
else if (::strncmp(buffer, "[Info]", 6U) == 0)
section = SECTION_INFO;
section = SECTION::INFO;
else if (::strncmp(buffer, "[Log]", 5U) == 0)
section = SECTION_LOG;
section = SECTION::LOG;
else if (::strncmp(buffer, "[APRS]", 6U) == 0)
section = SECTION_APRS;
section = SECTION::APRS;
else if (::strncmp(buffer, "[YSF Network]", 13U) == 0)
section = SECTION_YSF_NETWORK;
section = SECTION::YSF_NETWORK;
else if (::strncmp(buffer, "[FCS Network]", 13U) == 0)
section = SECTION_FCS_NETWORK;
section = SECTION::FCS_NETWORK;
else if (::strncmp(buffer, "[IMRS Network]", 14U) == 0)
section = SECTION_IMRS_NETWORK;
section = SECTION::IMRS_NETWORK;
else if (::strncmp(buffer, "[DGId=", 6U) == 0) {
section = SECTION_DGID;
section = SECTION::DGID;
dgIdData = new DGIdData;
dgIdData->m_dgId = (unsigned int)::atoi(buffer + 6U);
m_dgIdData.push_back(dgIdData);
} else if (::strncmp(buffer, "[GPSD]", 6U) == 0)
section = SECTION_GPSD;
section = SECTION::GPSD;
else
section = SECTION_NONE;
section = SECTION::NONE;
continue;
}
char* key = ::strtok(buffer, " \t=\r\n");
if (key == NULL)
if (key == nullptr)
continue;
char* value = ::strtok(NULL, "\r\n");
if (value == NULL)
char* value = ::strtok(nullptr, "\r\n");
if (value == nullptr)
continue;
// Remove quotes from the value
@ -155,7 +155,7 @@ bool CConf::read()
char *p;
// if value is not quoted, remove after # (to make comment)
if ((p = strchr(value, '#')) != NULL)
if ((p = strchr(value, '#')) != nullptr)
*p = '\0';
// remove trailing tab/space
@ -163,7 +163,7 @@ bool CConf::read()
*p = '\0';
}
if (section == SECTION_GENERAL) {
if (section == SECTION::GENERAL) {
if (::strcmp(key, "Callsign") == 0) {
// Convert the callsign to upper case
for (unsigned int i = 0U; value[i] != 0; i++)
@ -194,7 +194,7 @@ bool CConf::read()
m_debug = ::atoi(value) == 1;
else if (::strcmp(key, "Daemon") == 0)
m_daemon = ::atoi(value) == 1;
} else if (section == SECTION_INFO) {
} else if (section == SECTION::INFO) {
if (::strcmp(key, "TXFrequency") == 0)
m_txFrequency = (unsigned int)::atoi(value);
else if (::strcmp(key, "RXFrequency") == 0)
@ -209,7 +209,7 @@ bool CConf::read()
m_height = ::atoi(value);
else if (::strcmp(key, "Description") == 0)
m_description = value;
} else if (section == SECTION_LOG) {
} else if (section == SECTION::LOG) {
if (::strcmp(key, "FilePath") == 0)
m_logFilePath = value;
else if (::strcmp(key, "FileRoot") == 0)
@ -220,7 +220,7 @@ bool CConf::read()
m_logDisplayLevel = (unsigned int)::atoi(value);
else if (::strcmp(key, "FileRotate") == 0)
m_logFileRotate = ::atoi(value) == 1;
} else if (section == SECTION_APRS) {
} else if (section == SECTION::APRS) {
if (::strcmp(key, "Enable") == 0)
m_aprsEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Address") == 0)
@ -233,7 +233,7 @@ bool CConf::read()
m_aprsDescription = value;
else if (::strcmp(key, "Symbol") == 0)
m_aprsSymbol = value;
} else if (section == SECTION_YSF_NETWORK) {
} else if (section == SECTION::YSF_NETWORK) {
if (::strcmp(key, "Hosts") == 0)
m_ysfNetHosts = value;
else if (::strcmp(key, "RFHangTime") == 0)
@ -242,22 +242,22 @@ bool CConf::read()
m_ysfNetHangTime = (unsigned int)::atoi(value);
else if (::strcmp(key, "Debug") == 0)
m_ysfNetDebug = ::atoi(value) == 1;
} else if (section == SECTION_FCS_NETWORK) {
} else if (section == SECTION::FCS_NETWORK) {
if (::strcmp(key, "RFHangTime") == 0)
m_fcsRFHangTime = (unsigned int)::atoi(value);
else if (::strcmp(key, "NetHangTime") == 0)
m_fcsNetHangTime = (unsigned int)::atoi(value);
else if (::strcmp(key, "Debug") == 0)
m_fcsNetDebug = ::atoi(value) == 1;
} else if (section == SECTION_IMRS_NETWORK) {
} else if (section == SECTION::IMRS_NETWORK) {
if (::strcmp(key, "RFHangTime") == 0)
m_imrsRFHangTime = (unsigned int)::atoi(value);
else if (::strcmp(key, "NetHangTime") == 0)
m_imrsNetHangTime = (unsigned int)::atoi(value);
else if (::strcmp(key, "Debug") == 0)
m_imrsNetDebug = ::atoi(value) == 1;
} else if (section == SECTION_DGID) {
assert(dgIdData != NULL);
} else if (section == SECTION::DGID) {
assert(dgIdData != nullptr);
if (::strcmp(key, "Type") == 0) {
dgIdData->m_type = value;
dgIdData->m_static = false;
@ -296,14 +296,14 @@ bool CConf::read()
dgIdData->m_netDGId = (unsigned int)::atoi(value);
else if (::strcmp(key, "Destination") == 0) {
char* p1 = ::strtok(value, ",");
char* p2 = ::strtok(NULL, "\r\n");
char* p2 = ::strtok(nullptr, "\r\n");
IMRSDestination* dest = new IMRSDestination;
dest->m_dgId = (unsigned int)::atoi(p1);
dest->m_address = p2;
dgIdData->m_destinations.push_back(dest);
} else if (::strcmp(key, "Debug") == 0)
dgIdData->m_debug = ::atoi(value) == 1;
} else if (section == SECTION_GPSD) {
} else if (section == SECTION::GPSD) {
if (::strcmp(key, "Enable") == 0)
m_gpsdEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Address") == 0)

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2016-2020,2024,2025 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
@ -134,8 +134,8 @@ CDGIdGateway::CDGIdGateway(const std::string& configFile) :
m_callsign(),
m_suffix(),
m_conf(configFile),
m_writer(NULL),
m_gps(NULL)
m_writer(nullptr),
m_gps(nullptr)
{
CUDPSocket::startup();
}
@ -183,7 +183,7 @@ int CDGIdGateway::run()
// If we are currently root...
if (getuid() == 0) {
struct passwd* user = ::getpwnam("mmdvm");
if (user == NULL) {
if (user == nullptr) {
::fprintf(stderr, "Could not get the mmdvm user, exiting\n");
return -1;
}
@ -260,7 +260,7 @@ int CDGIdGateway::run()
ret = imrs->open();
if (!ret) {
delete imrs;
imrs = NULL;
imrs = nullptr;
}
unsigned int currentDGId = UNSET_DGID;
@ -268,7 +268,7 @@ int CDGIdGateway::run()
CDGIdNetwork* dgIdNetwork[100U];
for (unsigned int i = 0U; i < 100U; i++)
dgIdNetwork[i] = NULL;
dgIdNetwork[i] = nullptr;
std::vector<DGIdData*> dgIdData = m_conf.getDGIdData();
for (std::vector<DGIdData*>::const_iterator it = dgIdData.begin(); it != dgIdData.end(); ++it) {
@ -302,7 +302,7 @@ int CDGIdGateway::run()
unsigned int local = (*it)->m_local;
CYSFReflector* reflector = reflectors->findByName(name);
if (reflector != NULL) {
if (reflector != nullptr) {
dgIdNetwork[dgid] = new CYSFNetwork(local, reflector->m_name, reflector->m_addr, reflector->m_addrLen, m_callsign, statc, debug);
dgIdNetwork[dgid]->m_modes = DT_VD_MODE1 | DT_VD_MODE2 | DT_VOICE_FR_MODE | DT_DATA_FR_MODE;
dgIdNetwork[dgid]->m_static = statc;
@ -314,7 +314,7 @@ int CDGIdGateway::run()
LogWarning("Unknown YSF reflector: %s", name.c_str());
}
} else if (type == "IMRS") {
if (imrs != NULL) {
if (imrs != nullptr) {
std::vector<IMRSDestination*> destinations = (*it)->m_destinations;
std::vector<IMRSDest*> dests;
std::string name = (*it)->m_name;
@ -425,12 +425,12 @@ int CDGIdGateway::run()
}
}
if (dgIdNetwork[dgid] != NULL && dgIdNetwork[dgid] != imrs) {
if (dgIdNetwork[dgid] != nullptr && dgIdNetwork[dgid] != imrs) {
bool ret = dgIdNetwork[dgid]->open();
if (!ret) {
LogWarning("\tUnable to open connection");
delete dgIdNetwork[dgid];
dgIdNetwork[dgid] = NULL;
dgIdNetwork[dgid] = nullptr;
} else if (dgIdNetwork[dgid]->m_static) {
LogMessage("\tLinking at startup");
dgIdNetwork[dgid]->link();
@ -451,7 +451,7 @@ int CDGIdGateway::run()
LogMessage("DGIdGateway-%s is starting", VERSION);
LogMessage("Built %s %s (GitID #%.7s)", __TIME__, __DATE__, gitversion);
DGID_STATUS state = DS_NOTLINKED;
DGID_STATUS state = DGID_STATUS::NOTLINKED;
unsigned int nPips = 0U;
while (!m_killed) {
@ -468,29 +468,29 @@ int CDGIdGateway::run()
dgId = 0U;
if (currentDGId == UNSET_DGID) {
if (dgIdNetwork[dgId] != NULL && !dgIdNetwork[dgId]->m_static) {
if (dgIdNetwork[dgId] != nullptr && !dgIdNetwork[dgId]->m_static) {
dgIdNetwork[dgId]->link();
dgIdNetwork[dgId]->link();
dgIdNetwork[dgId]->link();
}
if (dgIdNetwork[dgId] != NULL) {
if (dgIdNetwork[dgId] != nullptr) {
std::string desc = dgIdNetwork[dgId]->getDesc(dgId);
LogMessage("DG-ID set to %u (%s) via RF", dgId, desc.c_str());
currentDGId = dgId;
state = DS_NOTLINKED;
state = DGID_STATUS::NOTLINKED;
} else {
LogMessage("DG-ID set to %u (None) via RF", dgId);
state = DS_NOTOPEN;
state = DGID_STATUS::NOTOPEN;
}
fromRF = true;
}
if (m_gps != NULL)
if (m_gps != nullptr)
m_gps->data(buffer + 14U, buffer + 35U, fich);
if (currentDGId != UNSET_DGID && dgIdNetwork[currentDGId] != NULL) {
if (currentDGId != UNSET_DGID && dgIdNetwork[currentDGId] != nullptr) {
// Only allow the wanted modes through
unsigned char dt = fich.getDT();
if ((dt == YSF_DT_VD_MODE1 && (dgIdNetwork[currentDGId]->m_modes & DT_VD_MODE1) != 0U) ||
@ -513,7 +513,7 @@ int CDGIdGateway::run()
}
if ((buffer[34U] & 0x01U) == 0x01U) {
if (m_gps != NULL)
if (m_gps != nullptr)
m_gps->reset();
if (nPips > 0U && fromRF)
bleepTimer.start();
@ -521,7 +521,7 @@ int CDGIdGateway::run()
}
for (unsigned int i = 0U; i < 100U; i++) {
if (dgIdNetwork[i] != NULL) {
if (dgIdNetwork[i] != nullptr) {
unsigned int len = dgIdNetwork[i]->read(i, buffer);
if (len > 0U && (i == currentDGId || currentDGId == UNSET_DGID)) {
CYSFFICH fich;
@ -542,7 +542,7 @@ int CDGIdGateway::run()
std::string desc = dgIdNetwork[i]->getDesc(i);
LogMessage("DG-ID set to %u (%s) via Network", i, desc.c_str());
currentDGId = i;
state = DS_LINKED;
state = DGID_STATUS::LINKED;
fromRF = false;
}
}
@ -556,16 +556,16 @@ int CDGIdGateway::run()
rptNetwork.clock(ms);
for (unsigned int i = 0U; i < 100U; i++) {
if (dgIdNetwork[i] != NULL)
if (dgIdNetwork[i] != nullptr)
dgIdNetwork[i]->clock(ms);
}
if (m_writer != NULL)
if (m_writer != nullptr)
m_writer->clock(ms);
inactivityTimer.clock(ms);
if (inactivityTimer.isRunning() && inactivityTimer.hasExpired()) {
if (dgIdNetwork[currentDGId] != NULL && !dgIdNetwork[currentDGId]->m_static) {
if (dgIdNetwork[currentDGId] != nullptr && !dgIdNetwork[currentDGId]->m_static) {
dgIdNetwork[currentDGId]->unlink();
dgIdNetwork[currentDGId]->unlink();
dgIdNetwork[currentDGId]->unlink();
@ -573,7 +573,7 @@ int CDGIdGateway::run()
LogMessage("DG-ID set to None via timeout");
state = DS_NOTLINKED;
state = DGID_STATUS::NOTLINKED;
currentDGId = UNSET_DGID;
inactivityTimer.stop();
@ -590,20 +590,20 @@ int CDGIdGateway::run()
nPips = 0U;
}
if (currentDGId != UNSET_DGID && dgIdNetwork[currentDGId] != NULL) {
if (currentDGId != UNSET_DGID && dgIdNetwork[currentDGId] != nullptr) {
DGID_STATUS netState = dgIdNetwork[currentDGId]->getStatus();
bool statc = dgIdNetwork[currentDGId]->m_static;
if (fromRF && state != DS_LINKED && netState != DS_LINKED && statc)
if (fromRF && state != DGID_STATUS::LINKED && netState != DGID_STATUS::LINKED && statc)
nPips = 3U;
else if (fromRF && state != DS_LINKED && netState == DS_LINKED)
else if (fromRF && state != DGID_STATUS::LINKED && netState == DGID_STATUS::LINKED)
nPips = 1U;
else if (fromRF && state == DS_LINKED && netState != DS_LINKED)
else if (fromRF && state == DGID_STATUS::LINKED && netState != DGID_STATUS::LINKED)
nPips = 3U;
state = netState;
} else {
if (fromRF && state != DS_NOTLINKED)
if (fromRF && state != DGID_STATUS::NOTLINKED)
nPips = 2U;
state = DS_NOTLINKED;
state = DGID_STATUS::NOTLINKED;
}
if (ms < 5U)
@ -613,14 +613,14 @@ int CDGIdGateway::run()
rptNetwork.unlink();
rptNetwork.close();
if (m_gps != NULL) {
if (m_gps != nullptr) {
m_writer->close();
delete m_writer;
delete m_gps;
}
for (unsigned int i = 0U; i < 100U; i++) {
if (dgIdNetwork[i] != NULL && dgIdNetwork[i] != imrs) {
if (dgIdNetwork[i] != nullptr && dgIdNetwork[i] != imrs) {
dgIdNetwork[i]->unlink();
dgIdNetwork[i]->unlink();
dgIdNetwork[i]->unlink();
@ -629,7 +629,7 @@ int CDGIdGateway::run()
}
}
if (imrs != NULL) {
if (imrs != nullptr) {
imrs->close();
delete imrs;
}
@ -675,7 +675,7 @@ void CDGIdGateway::createGPS()
bool ret = m_writer->open();
if (!ret) {
delete m_writer;
m_writer = NULL;
m_writer = nullptr;
return;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 by Jonathan Naylor G4KLX
* Copyright (C) 2020,2025 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
@ -18,6 +18,13 @@
#include "DGIdNetwork.h"
CDGIdNetwork::CDGIdNetwork() :
m_modes(0U),
m_static(false),
m_rfHangTime(0U),
m_netHangTime(0U)
{
}
CDGIdNetwork::~CDGIdNetwork()
{

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 by Jonathan Naylor G4KLX
* Copyright (C) 2020,2025 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
@ -21,15 +21,16 @@
#include <string>
enum DGID_STATUS {
DS_NOTOPEN,
DS_NOTLINKED,
DS_LINKING,
DS_LINKED
enum class DGID_STATUS {
NOTOPEN,
NOTLINKED,
LINKING,
LINKED
};
class CDGIdNetwork {
public:
CDGIdNetwork();
virtual ~CDGIdNetwork() = 0;
virtual std::string getDesc(unsigned int dgId) = 0;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2014,2016,2017,2018,2020,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2014,2016,2017,2018,2020,2021,2025 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
@ -35,8 +35,8 @@ m_debug(debug),
m_addr(),
m_addrLen(0U),
m_static(statc),
m_ping(NULL),
m_info(NULL),
m_ping(nullptr),
m_info(nullptr),
m_reflector(reflector),
m_print(),
m_buffer(1000U, "FCS Network Buffer"),
@ -44,7 +44,7 @@ m_n(0U),
m_sendPollTimer(1000U, 0U, 800U),
m_recvPollTimer(1000U, 60U),
m_resetTimer(1000U, 1U),
m_state(DS_NOTOPEN)
m_state(DGID_STATUS::NOTOPEN)
{
m_info = new unsigned char[100U];
::sprintf((char*)m_info, "%9u%9u%-6.6s%-12.12s%7u", rxFrequency, txFrequency, locator.c_str(), FCS_VERSION, id);
@ -85,7 +85,7 @@ bool CFCSNetwork::open()
{
if (m_addrLen == 0U) {
LogError("Unable to resolve the address of %s", m_reflector.c_str());
m_state = DS_NOTOPEN;
m_state = DGID_STATUS::NOTOPEN;
return false;
}
@ -93,10 +93,10 @@ bool CFCSNetwork::open()
bool ret = m_socket.open(m_addr);
if (!ret) {
m_state = DS_NOTOPEN;
m_state = DGID_STATUS::NOTOPEN;
return false;
} else {
m_state = DS_NOTLINKED;
m_state = DGID_STATUS::NOTLINKED;
return true;
}
}
@ -108,9 +108,9 @@ DGID_STATUS CFCSNetwork::getStatus()
void CFCSNetwork::write(unsigned int dgid, const unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
if (m_state != DS_LINKED)
if (m_state != DGID_STATUS::LINKED)
return;
unsigned char buffer[130U];
@ -127,10 +127,10 @@ void CFCSNetwork::write(unsigned int dgid, const unsigned char* data)
void CFCSNetwork::link()
{
if (m_state != DS_NOTLINKED)
if (m_state != DGID_STATUS::NOTLINKED)
return;
m_state = DS_LINKING;
m_state = DGID_STATUS::LINKING;
m_sendPollTimer.start();
m_recvPollTimer.start();
@ -140,7 +140,7 @@ void CFCSNetwork::link()
void CFCSNetwork::unlink()
{
if (m_state != DS_LINKED)
if (m_state != DGID_STATUS::LINKED)
return;
m_socket.write((unsigned char*)"CLOSE ", 11U, m_addr, m_addrLen);
@ -150,20 +150,20 @@ void CFCSNetwork::unlink()
LogMessage("Unlinked from %s", m_print.c_str());
m_state = DS_NOTLINKED;
m_state = DGID_STATUS::NOTLINKED;
}
void CFCSNetwork::clock(unsigned int ms)
{
if (m_state == DS_NOTOPEN)
if (m_state == DGID_STATUS::NOTOPEN)
return;
m_recvPollTimer.clock(ms);
if (m_recvPollTimer.isRunning() && m_recvPollTimer.hasExpired()) {
if (m_static) {
m_state = DS_LINKING;
m_state = DGID_STATUS::LINKING;
} else {
m_state = DS_NOTLINKED;
m_state = DGID_STATUS::NOTLINKED;
m_sendPollTimer.stop();
}
@ -194,7 +194,7 @@ void CFCSNetwork::clock(unsigned int ms)
if (m_debug)
CUtils::dump(1U, "FCS Network Data Received", buffer, length);
if (m_state == DS_NOTLINKED)
if (m_state == DGID_STATUS::NOTLINKED)
return;
if (!CUDPSocket::match(addr, m_addr))
@ -206,10 +206,10 @@ void CFCSNetwork::clock(unsigned int ms)
if (length == 7 || length == 10) {
m_recvPollTimer.start();
if (m_state == DS_LINKING) {
if (m_state == DGID_STATUS::LINKING) {
LogMessage("Linked to %s", m_print.c_str());
m_state = DS_LINKED;
m_state = DGID_STATUS::LINKED;
if (m_debug)
CUtils::dump(1U, "FCS Network Data Sent", m_info, 100U);
@ -229,7 +229,7 @@ void CFCSNetwork::clock(unsigned int ms)
unsigned int CFCSNetwork::read(unsigned int dgid, unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
if (m_buffer.isEmpty())
return 0U;
@ -261,12 +261,12 @@ void CFCSNetwork::close()
LogMessage("Closing FCS network connection");
m_state = DS_NOTOPEN;
m_state = DGID_STATUS::NOTOPEN;
}
void CFCSNetwork::writePoll()
{
if (m_state != DS_LINKING && m_state != DS_LINKED)
if (m_state != DGID_STATUS::LINKING && m_state != DGID_STATUS::LINKED)
return;
if (m_debug)

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017,2018,2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018,2020,2024,2025 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
@ -32,10 +32,10 @@ const unsigned char LONG_GPS[] = {0x47U, 0x64U};
CGPS::CGPS(CAPRSWriter* writer) :
m_writer(writer),
m_buffer(NULL),
m_buffer(nullptr),
m_sent(false)
{
assert(writer != NULL);
assert(writer != nullptr);
m_buffer = new unsigned char[300U];
}
@ -141,7 +141,7 @@ void CGPS::reset()
void CGPS::transmitGPS(const unsigned char* source)
{
assert(m_writer != NULL);
assert(m_writer != nullptr);
// We don't know who its from!
if (::memcmp(source, " ", YSF_CALLSIGN_LENGTH) == 0)

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2010,2016,2025 by Jonathan Naylor G4KLX
* Copyright (C) 2002 by Robert H. Morelos-Zaragoza. All rights reserved.
*/
@ -1096,7 +1096,7 @@ unsigned int CGolay24128::decode24128(unsigned int code)
unsigned int CGolay24128::decode24128(unsigned char* bytes)
{
assert(bytes != NULL);
assert(bytes != nullptr);
unsigned int code = bytes[0U];
code <<= 8;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2014,2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2014,2016,2017,2018,2020,2025 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
@ -31,7 +31,7 @@
CIMRSNetwork::CIMRSNetwork() :
m_socket(IMRS_PORT),
m_dgIds(),
m_state(DS_NOTOPEN)
m_state(DGID_STATUS::NOTOPEN)
{
}
@ -54,7 +54,7 @@ void CIMRSNetwork::addDGId(unsigned int dgId, const std::string& name, const std
std::string CIMRSNetwork::getDesc(unsigned int dgId)
{
IMRSDGId* ptr = find(dgId);
if (ptr == NULL)
if (ptr == nullptr)
return "IMRS: Unknown";
return "IMRS: " + ptr->m_name;
@ -71,10 +71,10 @@ bool CIMRSNetwork::open()
bool ret = m_socket.open();
if (!ret) {
m_state = DS_NOTOPEN;
m_state = DGID_STATUS::NOTOPEN;
return false;
} else {
m_state = DS_NOTLINKED;
m_state = DGID_STATUS::NOTLINKED;
return true;
}
}
@ -86,10 +86,10 @@ DGID_STATUS CIMRSNetwork::getStatus()
void CIMRSNetwork::write(unsigned int dgId, const unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
IMRSDGId* ptr = find(dgId);
if (ptr == NULL)
if (ptr == nullptr)
return;
CUtils::dump(1U, "YSF Data Received", data, 155U);
@ -112,8 +112,8 @@ void CIMRSNetwork::write(unsigned int dgId, const unsigned char* data)
bool CIMRSNetwork::writeHeaderTrailer(IMRSDGId* ptr, CYSFFICH& fich, const unsigned char* data)
{
assert(ptr != NULL);
assert(data != NULL);
assert(ptr != nullptr);
assert(data != nullptr);
unsigned char buffer[200U];
@ -158,8 +158,8 @@ bool CIMRSNetwork::writeHeaderTrailer(IMRSDGId* ptr, CYSFFICH& fich, const unsig
bool CIMRSNetwork::writeData(IMRSDGId* ptr, CYSFFICH& fich, const unsigned char* data)
{
assert(ptr != NULL);
assert(data != NULL);
assert(ptr != nullptr);
assert(data != nullptr);
unsigned char buffer[200U];
unsigned int length = 0U;
@ -253,8 +253,8 @@ bool CIMRSNetwork::writeData(IMRSDGId* ptr, CYSFFICH& fich, const unsigned char*
void CIMRSNetwork::readHeaderTrailer(IMRSDGId* ptr, CYSFFICH& fich, const unsigned char* data)
{
assert(ptr != NULL);
assert(data != NULL);
assert(ptr != nullptr);
assert(data != nullptr);
unsigned char buffer[155U];
@ -298,8 +298,8 @@ void CIMRSNetwork::readHeaderTrailer(IMRSDGId* ptr, CYSFFICH& fich, const unsign
void CIMRSNetwork::readData(IMRSDGId* ptr, CYSFFICH& fich, const unsigned char* data)
{
assert(ptr != NULL);
assert(data != NULL);
assert(ptr != nullptr);
assert(data != nullptr);
unsigned char buffer[155U];
@ -352,7 +352,7 @@ void CIMRSNetwork::readData(IMRSDGId* ptr, CYSFFICH& fich, const unsigned char*
if (fn == 0U && ft == 1U) {
// Copy the DCH
payload.writeVoiceFRModeData(data + 7U, buffer + 35U);
// NULL the unused section
// nullptr the unused section
::memset(buffer + 35U + YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES + 45U, 0x00U, 9U);
// Copy the audio
::memcpy(buffer + 35U + YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES + 54U, data + 27U + 0U, 18U);
@ -403,7 +403,7 @@ void CIMRSNetwork::clock(unsigned int ms)
CUtils::dump(1U, "IMRS Network Data Received", buffer, length);
IMRSDGId* ptr = find(addr);
if (ptr == NULL)
if (ptr == nullptr)
return;
if (ptr->m_debug)
@ -428,10 +428,10 @@ void CIMRSNetwork::clock(unsigned int ms)
unsigned int CIMRSNetwork::read(unsigned int dgId, unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
IMRSDGId* ptr = find(dgId);
if (ptr == NULL)
if (ptr == nullptr)
return 0U;
if (ptr->m_buffer.isEmpty())
@ -451,7 +451,7 @@ void CIMRSNetwork::close()
m_socket.close();
m_state = DS_NOTOPEN;
m_state = DGID_STATUS::NOTOPEN;
}
IMRSDGId* CIMRSNetwork::find(const sockaddr_storage& addr) const
@ -463,7 +463,7 @@ IMRSDGId* CIMRSNetwork::find(const sockaddr_storage& addr) const
}
}
return NULL;
return nullptr;
}
IMRSDGId* CIMRSNetwork::find(unsigned int dgId) const
@ -473,5 +473,5 @@ IMRSDGId* CIMRSNetwork::find(unsigned int dgId) const
return *it;
}
return NULL;
return nullptr;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2014,2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2014,2016,2017,2018,2020,2025 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
@ -42,8 +42,8 @@ public:
m_dgId(0U),
m_name(),
m_seqNo(0U),
m_source(NULL),
m_dest(NULL),
m_source(nullptr),
m_dest(nullptr),
m_destinations(),
m_debug(false),
m_buffer(1000U, "IMRS Buffer")

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2020,2025 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
@ -37,7 +37,7 @@ static std::string m_filePath;
static std::string m_fileRoot;
static bool m_fileRotate = true;
static FILE* m_fpLog = NULL;
static FILE* m_fpLog = nullptr;
static bool m_daemon = false;
static unsigned int m_displayLevel = 2U;
@ -59,10 +59,10 @@ static bool logOpenRotate()
struct tm* tm = ::gmtime(&now);
if (tm->tm_mday == m_tm.tm_mday && tm->tm_mon == m_tm.tm_mon && tm->tm_year == m_tm.tm_year) {
if (m_fpLog != NULL)
if (m_fpLog != nullptr)
return true;
} else {
if (m_fpLog != NULL)
if (m_fpLog != nullptr)
::fclose(m_fpLog);
}
@ -73,7 +73,7 @@ static bool logOpenRotate()
::sprintf(filename, "%s/%s-%04d-%02d-%02d.log", m_filePath.c_str(), m_fileRoot.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday);
#endif
if ((m_fpLog = ::fopen(filename, "a+t")) != NULL) {
if ((m_fpLog = ::fopen(filename, "a+t")) != nullptr) {
status = true;
#if !defined(_WIN32) && !defined(_WIN64)
@ -94,7 +94,7 @@ static bool logOpenNoRotate()
if (m_fileLevel == 0U)
return true;
if (m_fpLog != NULL)
if (m_fpLog != nullptr)
return true;
char filename[200U];
@ -104,7 +104,7 @@ static bool logOpenNoRotate()
::sprintf(filename, "%s/%s.log", m_filePath.c_str(), m_fileRoot.c_str());
#endif
if ((m_fpLog = ::fopen(filename, "a+t")) != NULL) {
if ((m_fpLog = ::fopen(filename, "a+t")) != nullptr) {
status = true;
#if !defined(_WIN32) && !defined(_WIN64)
@ -141,13 +141,13 @@ bool LogInitialise(bool daemon, const std::string& filePath, const std::string&
void LogFinalise()
{
if (m_fpLog != NULL)
if (m_fpLog != nullptr)
::fclose(m_fpLog);
}
void Log(unsigned int level, const char* fmt, ...)
{
assert(fmt != NULL);
assert(fmt != nullptr);
char buffer[501U];
#if defined(_WIN32) || defined(_WIN64)
@ -157,7 +157,7 @@ void Log(unsigned int level, const char* fmt, ...)
::sprintf(buffer, "%c: %04u-%02u-%02u %02u:%02u:%02u.%03u ", LEVELS[level], st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
#else
struct timeval now;
::gettimeofday(&now, NULL);
::gettimeofday(&now, nullptr);
struct tm* tm = ::gmtime(&now.tv_sec);
@ -167,7 +167,7 @@ void Log(unsigned int level, const char* fmt, ...)
va_list vl;
va_start(vl, fmt);
::vsnprintf(buffer + ::strlen(buffer), 500, fmt, vl);
::vsnprintf(buffer + ::strlen(buffer), 500 - ::strlen(buffer), fmt, vl);
va_end(vl);

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2009,2012,2013,2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2006-2009,2012,2013,2015,2016,2025 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
@ -30,12 +30,12 @@ public:
CRingBuffer(unsigned int length, const char* name) :
m_length(length),
m_name(name),
m_buffer(NULL),
m_buffer(nullptr),
m_iPtr(0U),
m_oPtr(0U)
{
assert(length > 0U);
assert(name != NULL);
assert(name != nullptr);
m_buffer = new T[length];

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2018,2025 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
@ -77,7 +77,7 @@ CStopWatch::~CStopWatch()
unsigned long long CStopWatch::time() const
{
struct timeval now;
::gettimeofday(&now, NULL);
::gettimeofday(&now, nullptr);
return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2025 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
@ -26,7 +26,7 @@
void CSync::add(unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
::memcpy(data, YSF_SYNC_BYTES, YSF_SYNC_LENGTH_BYTES);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2020,2025 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
@ -31,9 +31,9 @@ CThread::~CThread()
bool CThread::run()
{
m_handle = ::CreateThread(NULL, 0, &helper, this, 0, NULL);
m_handle = ::CreateThread(nullptr, 0, &helper, this, 0, nullptr);
return m_handle != NULL;
return m_handle != nullptr;
}
@ -74,13 +74,13 @@ CThread::~CThread()
bool CThread::run()
{
return ::pthread_create(&m_thread, NULL, helper, this) == 0;
return ::pthread_create(&m_thread, nullptr, helper, this) == 0;
}
void CThread::wait()
{
::pthread_join(m_thread, NULL);
::pthread_join(m_thread, nullptr);
}
@ -90,7 +90,7 @@ void* CThread::helper(void* arg)
p->entry();
return NULL;
return nullptr;
}
void CThread::sleep(unsigned int ms)
@ -100,7 +100,7 @@ void CThread::sleep(unsigned int ms)
ts.tv_sec = ms / 1000U;
ts.tv_nsec = (ms % 1000U) * 1000000U;
::nanosleep(&ts, NULL);
::nanosleep(&ts, nullptr);
}
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2016,2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2006-2016,2020,2024,2025 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
@ -94,7 +94,7 @@ int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockadd
/* Port is always digits, no needs to lookup service */
hints.ai_flags |= AI_NUMERICSERV;
int err = ::getaddrinfo(hostname.empty() ? NULL : hostname.c_str(), portstr.c_str(), &hints, &res);
int err = ::getaddrinfo(hostname.empty() ? nullptr : hostname.c_str(), portstr.c_str(), &hints, &res);
if (err != 0) {
sockaddr_in* paddr = (sockaddr_in*)&addr;
::memset(paddr, 0x00U, address_length = sizeof(sockaddr_in));
@ -119,7 +119,7 @@ bool CUDPSocket::match(const sockaddr_storage& addr1, const sockaddr_storage& ad
if (addr1.ss_family != addr2.ss_family)
return false;
if (type == IMT_ADDRESS_AND_PORT) {
if (type == IPMATCHTYPE::ADDRESS_AND_PORT) {
switch (addr1.ss_family) {
case AF_INET:
struct sockaddr_in *in_1, *in_2;
@ -134,7 +134,7 @@ bool CUDPSocket::match(const sockaddr_storage& addr1, const sockaddr_storage& ad
default:
return false;
}
} else if (type == IMT_ADDRESS_ONLY) {
} else if (type == IPMATCHTYPE::ADDRESS_ONLY) {
switch (addr1.ss_family) {
case AF_INET:
struct sockaddr_in *in_1, *in_2;
@ -233,7 +233,7 @@ bool CUDPSocket::open()
int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int& addressLength)
{
assert(buffer != NULL);
assert(buffer != nullptr);
assert(length > 0U);
#if defined(_WIN32) || defined(_WIN64)
@ -301,7 +301,7 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storag
bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int addressLength)
{
assert(buffer != NULL);
assert(buffer != nullptr);
assert(length > 0U);
#if defined(_WIN32) || defined(_WIN64)
assert(m_fd != INVALID_SOCKET);

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2011,2013,2015,2016,2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2011,2013,2015,2016,2020,2024,2025 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
@ -35,9 +35,9 @@
#include <ws2tcpip.h>
#endif
enum IPMATCHTYPE {
IMT_ADDRESS_AND_PORT,
IMT_ADDRESS_ONLY
enum class IPMATCHTYPE {
ADDRESS_AND_PORT,
ADDRESS_ONLY
};
class CUDPSocket {
@ -60,7 +60,7 @@ public:
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& addressLength);
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& addressLength, struct addrinfo& hints);
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT);
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IPMATCHTYPE::ADDRESS_AND_PORT);
static bool isNone(const sockaddr_storage& addr);

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009,2014,2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2009,2014,2015,2016,2025 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
@ -19,14 +19,14 @@
void CUtils::dump(const std::string& title, const unsigned char* data, unsigned int length)
{
assert(data != NULL);
assert(data != nullptr);
dump(2U, title, data, length);
}
void CUtils::dump(int level, const std::string& title, const unsigned char* data, unsigned int length)
{
assert(data != NULL);
assert(data != nullptr);
::Log(level, "%s", title.c_str());
@ -72,14 +72,14 @@ void CUtils::dump(int level, const std::string& title, const unsigned char* data
void CUtils::dump(const std::string& title, const bool* bits, unsigned int length)
{
assert(bits != NULL);
assert(bits != nullptr);
dump(2U, title, bits, length);
}
void CUtils::dump(int level, const std::string& title, const bool* bits, unsigned int length)
{
assert(bits != NULL);
assert(bits != nullptr);
unsigned char bytes[100U];
unsigned int nBytes = 0U;
@ -91,7 +91,7 @@ void CUtils::dump(int level, const std::string& title, const bool* bits, unsigne
void CUtils::byteToBitsBE(unsigned char byte, bool* bits)
{
assert(bits != NULL);
assert(bits != nullptr);
bits[0U] = (byte & 0x80U) == 0x80U;
bits[1U] = (byte & 0x40U) == 0x40U;
@ -105,7 +105,7 @@ void CUtils::byteToBitsBE(unsigned char byte, bool* bits)
void CUtils::byteToBitsLE(unsigned char byte, bool* bits)
{
assert(bits != NULL);
assert(bits != nullptr);
bits[0U] = (byte & 0x01U) == 0x01U;
bits[1U] = (byte & 0x02U) == 0x02U;
@ -119,7 +119,7 @@ void CUtils::byteToBitsLE(unsigned char byte, bool* bits)
void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte)
{
assert(bits != NULL);
assert(bits != nullptr);
byte = bits[0U] ? 0x80U : 0x00U;
byte |= bits[1U] ? 0x40U : 0x00U;
@ -133,7 +133,7 @@ void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte)
void CUtils::bitsToByteLE(const bool* bits, unsigned char& byte)
{
assert(bits != NULL);
assert(bits != nullptr);
byte = bits[0U] ? 0x01U : 0x00U;
byte |= bits[1U] ? 0x02U : 0x00U;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2021,2023,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2015-2021,2023,2024,2025 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
@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H
const char* VERSION = "20241218";
const char* VERSION = "20250319";
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2016 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2016,2025 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
@ -36,12 +36,12 @@ const uint32_t M = 2U;
const unsigned int K = 5U;
CYSFConvolution::CYSFConvolution() :
m_metrics1(NULL),
m_metrics2(NULL),
m_oldMetrics(NULL),
m_newMetrics(NULL),
m_decisions(NULL),
m_dp(NULL)
m_metrics1(nullptr),
m_metrics2(nullptr),
m_oldMetrics(nullptr),
m_newMetrics(nullptr),
m_decisions(nullptr),
m_dp(nullptr)
{
m_metrics1 = new uint16_t[16U];
m_metrics2 = new uint16_t[16U];
@ -98,7 +98,7 @@ void CYSFConvolution::decode(uint8_t s0, uint8_t s1)
void CYSFConvolution::chainback(unsigned char* out, unsigned int nBits)
{
assert(out != NULL);
assert(out != nullptr);
uint32_t state = 0U;
@ -115,8 +115,8 @@ void CYSFConvolution::chainback(unsigned char* out, unsigned int nBits)
void CYSFConvolution::encode(const unsigned char* in, unsigned char* out, unsigned int nBits) const
{
assert(in != NULL);
assert(out != NULL);
assert(in != nullptr);
assert(out != nullptr);
assert(nBits > 0U);
uint8_t d1 = 0U, d2 = 0U, d3 = 0U, d4 = 0U;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017,2019,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2019,2020,2025 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
@ -55,7 +55,7 @@ const unsigned int INTERLEAVE_TABLE[] = {
38U, 78U, 118U, 158U, 198U};
CYSFFICH::CYSFFICH(const CYSFFICH& fich) :
m_fich(NULL)
m_fich(nullptr)
{
m_fich = new unsigned char[6U];
@ -63,7 +63,7 @@ m_fich(NULL)
}
CYSFFICH::CYSFFICH() :
m_fich(NULL)
m_fich(nullptr)
{
m_fich = new unsigned char[6U];
@ -77,7 +77,7 @@ CYSFFICH::~CYSFFICH()
bool CYSFFICH::decode(const unsigned char* bytes)
{
assert(bytes != NULL);
assert(bytes != nullptr);
// Skip the sync bytes
bytes += YSF_SYNC_LENGTH_BYTES;
@ -116,7 +116,7 @@ bool CYSFFICH::decode(const unsigned char* bytes)
void CYSFFICH::encode(unsigned char* bytes)
{
assert(bytes != NULL);
assert(bytes != nullptr);
// Skip the sync bytes
bytes += YSF_SYNC_LENGTH_BYTES;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2014,2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2014,2016,2017,2018,2020,2025 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
@ -33,13 +33,13 @@ m_debug(debug),
m_addr(addr),
m_addrLen(addrLen),
m_static(true),
m_poll(NULL),
m_unlink(NULL),
m_poll(nullptr),
m_unlink(nullptr),
m_buffer(1000U, "YSF Network Buffer"),
m_sendPollTimer(1000U, 5U),
m_recvPollTimer(1000U, 60U),
m_name(name),
m_state(DS_NOTOPEN)
m_state(DGID_STATUS::NOTOPEN)
{
m_poll = new unsigned char[14U];
::memcpy(m_poll + 0U, "YSFP", 4U);
@ -62,13 +62,13 @@ m_debug(debug),
m_addr(addr),
m_addrLen(addrLen),
m_static(statc),
m_poll(NULL),
m_unlink(NULL),
m_poll(nullptr),
m_unlink(nullptr),
m_buffer(1000U, "YSF Network Buffer"),
m_sendPollTimer(1000U, 5U),
m_recvPollTimer(1000U, 60U),
m_name(name),
m_state(DS_NOTOPEN)
m_state(DGID_STATUS::NOTOPEN)
{
m_poll = new unsigned char[14U];
::memcpy(m_poll + 0U, "YSFP", 4U);
@ -105,7 +105,7 @@ bool CYSFNetwork::open()
{
if (m_addrLen == 0U) {
LogError("Unable to resolve the address of the YSF network");
m_state = DS_NOTOPEN;
m_state = DGID_STATUS::NOTOPEN;
return false;
}
@ -113,10 +113,10 @@ bool CYSFNetwork::open()
bool ret = m_socket.open(m_addr);
if (!ret) {
m_state = DS_NOTOPEN;
m_state = DGID_STATUS::NOTOPEN;
return false;
} else {
m_state = DS_NOTLINKED;
m_state = DGID_STATUS::NOTLINKED;
return true;
}
}
@ -128,9 +128,9 @@ DGID_STATUS CYSFNetwork::getStatus()
void CYSFNetwork::write(unsigned int dgid, const unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
if (m_state != DS_LINKED)
if (m_state != DGID_STATUS::LINKED)
return;
if (m_debug)
@ -141,10 +141,10 @@ void CYSFNetwork::write(unsigned int dgid, const unsigned char* data)
void CYSFNetwork::link()
{
if (m_state != DS_NOTLINKED)
if (m_state != DGID_STATUS::NOTLINKED)
return;
m_state = DS_LINKING;
m_state = DGID_STATUS::LINKING;
m_sendPollTimer.start();
m_recvPollTimer.start();
@ -154,7 +154,7 @@ void CYSFNetwork::link()
void CYSFNetwork::writePoll()
{
if (m_state != DS_LINKING && m_state != DS_LINKED)
if (m_state != DGID_STATUS::LINKING && m_state != DGID_STATUS::LINKED)
return;
if (m_debug)
@ -165,7 +165,7 @@ void CYSFNetwork::writePoll()
void CYSFNetwork::unlink()
{
if (m_state != DS_LINKED)
if (m_state != DGID_STATUS::LINKED)
return;
m_sendPollTimer.stop();
@ -178,20 +178,20 @@ void CYSFNetwork::unlink()
LogMessage("Unlinked from %s", m_name.c_str());
m_state = DS_NOTLINKED;
m_state = DGID_STATUS::NOTLINKED;
}
void CYSFNetwork::clock(unsigned int ms)
{
if (m_state == DS_NOTOPEN)
if (m_state == DGID_STATUS::NOTOPEN)
return;
m_recvPollTimer.clock(ms);
if (m_recvPollTimer.isRunning() && m_recvPollTimer.hasExpired()) {
if (m_static) {
m_state = DS_LINKING;
m_state = DGID_STATUS::LINKING;
} else {
m_state = DS_NOTLINKED;
m_state = DGID_STATUS::NOTLINKED;
m_sendPollTimer.stop();
}
@ -224,13 +224,13 @@ void CYSFNetwork::clock(unsigned int ms)
if (::memcmp(buffer, "YSFP", 4U) == 0) {
m_recvPollTimer.start();
if (m_state == DS_LINKING) {
if (m_state == DGID_STATUS::LINKING) {
if (strcmp(m_name.c_str(), "MMDVM") == 0)
LogMessage("Link successful to %s", m_name.c_str());
else
LogMessage("Linked to %s", m_name.c_str());
m_state = DS_LINKED;
m_state = DGID_STATUS::LINKED;
}
}
@ -246,7 +246,7 @@ void CYSFNetwork::clock(unsigned int ms)
unsigned int CYSFNetwork::read(unsigned int dgid, unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
if (m_buffer.isEmpty())
return 0U;
@ -265,5 +265,5 @@ void CYSFNetwork::close()
LogMessage("Closing YSF network connection");
m_state = DS_NOTOPEN;
m_state = DGID_STATUS::NOTOPEN;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2020 Jonathan Naylor, G4KLX
* Copyright (C) 2016,2020,2025 Jonathan Naylor, G4KLX
* Copyright (C) 2016 Mathias Weyland, HB9FRV
*
* This program is free software; you can redistribute it and/or modify
@ -86,8 +86,8 @@ CYSFPayload::~CYSFPayload()
bool CYSFPayload::readHeaderData(const unsigned char* data, unsigned char* dt)
{
assert(data != NULL);
assert(dt != NULL);
assert(data != nullptr);
assert(dt != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -154,8 +154,8 @@ bool CYSFPayload::readHeaderData(const unsigned char* data, unsigned char* dt)
bool CYSFPayload::readVDMode1Data(const unsigned char* data, unsigned char* dt)
{
assert(data != NULL);
assert(dt != NULL);
assert(data != nullptr);
assert(dt != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -195,8 +195,8 @@ bool CYSFPayload::readVDMode1Data(const unsigned char* data, unsigned char* dt)
bool CYSFPayload::readVDMode2Data(const unsigned char* data, unsigned char* dt)
{
assert(data != NULL);
assert(dt != NULL);
assert(data != nullptr);
assert(dt != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -236,8 +236,8 @@ bool CYSFPayload::readVDMode2Data(const unsigned char* data, unsigned char* dt)
bool CYSFPayload::readDataFRModeData1(const unsigned char* data, unsigned char* dt)
{
assert(data != NULL);
assert(dt != NULL);
assert(data != nullptr);
assert(dt != nullptr);
::memset(dt, ' ', 20U);
@ -279,8 +279,8 @@ bool CYSFPayload::readDataFRModeData1(const unsigned char* data, unsigned char*
bool CYSFPayload::readVoiceFRModeData(const unsigned char* data, unsigned char* dt)
{
assert(data != NULL);
assert(dt != NULL);
assert(data != nullptr);
assert(dt != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -314,8 +314,8 @@ bool CYSFPayload::readVoiceFRModeData(const unsigned char* data, unsigned char*
bool CYSFPayload::readDataFRModeData2(const unsigned char* data, unsigned char* dt)
{
assert(data != NULL);
assert(dt != NULL);
assert(data != nullptr);
assert(dt != nullptr);
::memset(dt, ' ', 20U);
@ -357,8 +357,8 @@ bool CYSFPayload::readDataFRModeData2(const unsigned char* data, unsigned char*
void CYSFPayload::writeHeaderData(const unsigned char* dt, unsigned char* data)
{
assert(dt != NULL);
assert(data != NULL);
assert(dt != nullptr);
assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -374,7 +374,7 @@ void CYSFPayload::writeHeaderData(const unsigned char* dt, unsigned char* data)
CYSFConvolution conv;
conv.encode(output, convolved, 180U);
unsigned char bytes[45U];
unsigned char bytes[45U] = { 0x00U };
unsigned int j = 0U;
for (unsigned int i = 0U; i < 180U; i++) {
unsigned int n = INTERLEAVE_TABLE_9_20[i];
@ -431,8 +431,8 @@ void CYSFPayload::writeHeaderData(const unsigned char* dt, unsigned char* data)
void CYSFPayload::writeVDMode1Data(const unsigned char* dt, unsigned char* data)
{
assert(dt != NULL);
assert(data != NULL);
assert(dt != nullptr);
assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -448,7 +448,7 @@ void CYSFPayload::writeVDMode1Data(const unsigned char* dt, unsigned char* data)
CYSFConvolution conv;
conv.encode(output, convolved, 180U);
unsigned char bytes[45U];
unsigned char bytes[45U] = { 0x00U };
unsigned int j = 0U;
for (unsigned int i = 0U; i < 180U; i++) {
unsigned int n = INTERLEAVE_TABLE_9_20[i];
@ -475,8 +475,8 @@ void CYSFPayload::writeVDMode1Data(const unsigned char* dt, unsigned char* data)
void CYSFPayload::writeVDMode2Data(const unsigned char* dt, unsigned char* data)
{
assert(dt != NULL);
assert(data != NULL);
assert(dt != nullptr);
assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -492,7 +492,7 @@ void CYSFPayload::writeVDMode2Data(const unsigned char* dt, unsigned char* data)
CYSFConvolution conv;
conv.encode(output, convolved, 100U);
unsigned char bytes[25U];
unsigned char bytes[25U] = { 0x00U };
unsigned int j = 0U;
for (unsigned int i = 0U; i < 100U; i++) {
unsigned int n = INTERLEAVE_TABLE_5_20[i];
@ -519,8 +519,8 @@ void CYSFPayload::writeVDMode2Data(const unsigned char* dt, unsigned char* data)
void CYSFPayload::writeVoiceFRModeData(const unsigned char* dt, unsigned char* data)
{
assert(dt != NULL);
assert(data != NULL);
assert(dt != nullptr);
assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -536,7 +536,7 @@ void CYSFPayload::writeVoiceFRModeData(const unsigned char* dt, unsigned char* d
CYSFConvolution conv;
conv.encode(output, convolved, 180U);
unsigned char bytes[45U];
unsigned char bytes[45U] = { 0x00U };
unsigned int j = 0U;
for (unsigned int i = 0U; i < 180U; i++) {
unsigned int n = INTERLEAVE_TABLE_9_20[i];
@ -558,8 +558,8 @@ void CYSFPayload::writeVoiceFRModeData(const unsigned char* dt, unsigned char* d
void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* data)
{
assert(dt != NULL);
assert(data != NULL);
assert(dt != nullptr);
assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -575,7 +575,7 @@ void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* d
CYSFConvolution conv;
conv.encode(output, convolved, 180U);
unsigned char bytes[45U];
unsigned char bytes[45U] = { 0x00U };
unsigned int j = 0U;
for (unsigned int i = 0U; i < 180U; i++) {
unsigned int n = INTERLEAVE_TABLE_9_20[i];
@ -602,8 +602,8 @@ void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* d
void CYSFPayload::writeDataFRModeData2(const unsigned char* dt, unsigned char* data)
{
assert(dt != NULL);
assert(data != NULL);
assert(dt != nullptr);
assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -619,7 +619,7 @@ void CYSFPayload::writeDataFRModeData2(const unsigned char* dt, unsigned char* d
CYSFConvolution conv;
conv.encode(output, convolved, 180U);
unsigned char bytes[45U];
unsigned char bytes[45U] = { 0x00U };
unsigned int j = 0U;
for (unsigned int i = 0U; i < 180U; i++) {
unsigned int n = INTERLEAVE_TABLE_9_20[i];

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016-2020,2025 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
@ -43,24 +43,24 @@ CYSFReflectors::~CYSFReflectors()
bool CYSFReflectors::load()
{
FILE* fp = ::fopen(m_hostsFile.c_str(), "rt");
if (fp != NULL) {
if (fp != nullptr) {
char buffer[100U];
while (::fgets(buffer, 100U, fp) != NULL) {
while (::fgets(buffer, 100U, fp) != nullptr) {
if (buffer[0U] == '#')
continue;
char* p1 = ::strtok(buffer, ";\r\n");
char* p2 = ::strtok(NULL, ";\r\n");
char* p3 = ::strtok(NULL, ";\r\n");
char* p4 = ::strtok(NULL, ";\r\n");
char* p5 = ::strtok(NULL, ";\r\n");
char* p6 = ::strtok(NULL, "\r\n");
char* p2 = ::strtok(nullptr, ";\r\n");
char* p3 = ::strtok(nullptr, ";\r\n");
char* p4 = ::strtok(nullptr, ";\r\n");
char* p5 = ::strtok(nullptr, ";\r\n");
char* p6 = ::strtok(nullptr, "\r\n");
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL && p5 != NULL && p6 != NULL) {
if (p1 != nullptr && p2 != nullptr && p3 != nullptr && p4 != nullptr && p5 != nullptr && p6 != nullptr) {
std::string host = std::string(p4);
unsigned short port = (unsigned short)::atoi(p5);
if (::strstr(p1, "YCS") == NULL && ::strstr(p2, "YCS") == NULL) {
if (::strstr(p1, "YCS") == nullptr && ::strstr(p2, "YCS") == nullptr) {
sockaddr_storage addr;
unsigned int addrLen;
if (CUDPSocket::lookup(host, port, addr, addrLen) == 0) {
@ -95,7 +95,7 @@ CYSFReflector* CYSFReflectors::findById(const std::string& id)
LogMessage("Trying to find non existent YSF reflector with an id of %s", id.c_str());
return NULL;
return nullptr;
}
CYSFReflector* CYSFReflectors::findByName(const std::string& name)
@ -107,6 +107,6 @@ CYSFReflector* CYSFReflectors::findByName(const std::string& name)
LogMessage("Trying to find non existent YSF reflector with a name of %s", name.c_str());
return NULL;
return nullptr;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2014,2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2010-2014,2016,2017,2018,2020,2025 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
@ -106,7 +106,7 @@ bool CAPRSWriter::open()
return false;
}
::gps_stream(&m_gpsdData, WATCH_ENABLE | WATCH_JSON, NULL);
::gps_stream(&m_gpsdData, WATCH_ENABLE | WATCH_JSON, nullptr);
LogMessage("Connected to GPSD");
}
@ -125,8 +125,8 @@ bool CAPRSWriter::open()
void CAPRSWriter::write(const unsigned char* source, const char* type, unsigned char radio, float fLatitude, float fLongitude)
{
assert(source != NULL);
assert(type != NULL);
assert(source != nullptr);
assert(type != nullptr);
char callsign[15U];
::memcpy(callsign, source, YSF_CALLSIGN_LENGTH);
@ -219,7 +219,7 @@ void CAPRSWriter::close()
#if defined(USE_GPSD)
if (m_gpsdEnabled) {
::gps_stream(&m_gpsdData, WATCH_DISABLE, NULL);
::gps_stream(&m_gpsdData, WATCH_DISABLE, nullptr);
::gps_close(&m_gpsdData);
}
#endif
@ -300,7 +300,7 @@ void CAPRSWriter::sendIdFrameMobile()
return;
#if GPSD_API_MAJOR_VERSION >= 7
if (::gps_read(&m_gpsdData, NULL, 0) <= 0)
if (::gps_read(&m_gpsdData, nullptr, 0) <= 0)
return;
#else
if (::gps_read(&m_gpsdData) <= 0)

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2025 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
@ -63,7 +63,7 @@ const uint16_t CCITT16_TABLE2[] = {
void CCRC::addCCITT16(unsigned char *in, unsigned int length)
{
assert(in != NULL);
assert(in != nullptr);
assert(length > 2U);
union {
@ -84,7 +84,7 @@ void CCRC::addCCITT16(unsigned char *in, unsigned int length)
bool CCRC::checkCCITT16(const unsigned char *in, unsigned int length)
{
assert(in != NULL);
assert(in != nullptr);
assert(length > 2U);
union {
@ -104,7 +104,7 @@ bool CCRC::checkCCITT16(const unsigned char *in, unsigned int length)
unsigned char CCRC::addCRC(const unsigned char* in, unsigned int length)
{
assert(in != NULL);
assert(in != nullptr);
unsigned char crc = 0U;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015-2020,2025 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
@ -26,17 +26,17 @@
const int BUFFER_SIZE = 500;
enum SECTION {
SECTION_NONE,
SECTION_GENERAL,
SECTION_INFO,
SECTION_LOG,
SECTION_APRS,
SECTION_NETWORK,
SECTION_YSF_NETWORK,
SECTION_FCS_NETWORK,
SECTION_GPSD,
SECTION_REMOTE_COMMANDS
enum class SECTION {
NONE,
GENERAL,
INFO,
LOG,
APRS,
NETWORK,
YSF_NETWORK,
FCS_NETWORK,
GPSD,
REMOTE_COMMANDS
};
CConf::CConf(const std::string& file) :
@ -106,49 +106,49 @@ CConf::~CConf()
bool CConf::read()
{
FILE* fp = ::fopen(m_file.c_str(), "rt");
if (fp == NULL) {
if (fp == nullptr) {
::fprintf(stderr, "Couldn't open the .ini file - %s\n", m_file.c_str());
return false;
}
SECTION section = SECTION_NONE;
SECTION section = SECTION::NONE;
char buffer[BUFFER_SIZE];
while (::fgets(buffer, BUFFER_SIZE, fp) != NULL) {
while (::fgets(buffer, BUFFER_SIZE, fp) != nullptr) {
if (buffer[0U] == '#')
continue;
if (buffer[0U] == '[') {
if (::strncmp(buffer, "[General]", 9U) == 0)
section = SECTION_GENERAL;
section = SECTION::GENERAL;
else if (::strncmp(buffer, "[Info]", 6U) == 0)
section = SECTION_INFO;
section = SECTION::INFO;
else if (::strncmp(buffer, "[Log]", 5U) == 0)
section = SECTION_LOG;
section = SECTION::LOG;
else if (::strncmp(buffer, "[APRS]", 6U) == 0)
section = SECTION_APRS;
section = SECTION::APRS;
else if (::strncmp(buffer, "[Network]", 9U) == 0)
section = SECTION_NETWORK;
section = SECTION::NETWORK;
else if (::strncmp(buffer, "[YSF Network]", 13U) == 0)
section = SECTION_YSF_NETWORK;
section = SECTION::YSF_NETWORK;
else if (::strncmp(buffer, "[FCS Network]", 13U) == 0)
section = SECTION_FCS_NETWORK;
section = SECTION::FCS_NETWORK;
else if (::strncmp(buffer, "[GPSD]", 6U) == 0)
section = SECTION_GPSD;
section = SECTION::GPSD;
else if (::strncmp(buffer, "[Remote Commands]", 17U) == 0)
section = SECTION_REMOTE_COMMANDS;
section = SECTION::REMOTE_COMMANDS;
else
section = SECTION_NONE;
section = SECTION::NONE;
continue;
}
char* key = ::strtok(buffer, " \t=\r\n");
if (key == NULL)
if (key == nullptr)
continue;
char* value = ::strtok(NULL, "\r\n");
if (value == NULL)
char* value = ::strtok(nullptr, "\r\n");
if (value == nullptr)
continue;
// Remove quotes from the value
@ -160,7 +160,7 @@ bool CConf::read()
char *p;
// if value is not quoted, remove after # (to make comment)
if ((p = strchr(value, '#')) != NULL)
if ((p = strchr(value, '#')) != nullptr)
*p = '\0';
// remove trailing tab/space
@ -168,7 +168,7 @@ bool CConf::read()
*p = '\0';
}
if (section == SECTION_GENERAL) {
if (section == SECTION::GENERAL) {
if (::strcmp(key, "Callsign") == 0) {
// Convert the callsign to upper case
for (unsigned int i = 0U; value[i] != 0; i++)
@ -197,7 +197,7 @@ bool CConf::read()
m_debug = ::atoi(value) == 1;
else if (::strcmp(key, "Daemon") == 0)
m_daemon = ::atoi(value) == 1;
} else if (section == SECTION_INFO) {
} else if (section == SECTION::INFO) {
if (::strcmp(key, "TXFrequency") == 0)
m_txFrequency = (unsigned int)::atoi(value);
else if (::strcmp(key, "RXFrequency") == 0)
@ -214,7 +214,7 @@ bool CConf::read()
m_name = value;
else if (::strcmp(key, "Description") == 0)
m_description = value;
} else if (section == SECTION_LOG) {
} else if (section == SECTION::LOG) {
if (::strcmp(key, "FilePath") == 0)
m_logFilePath = value;
else if (::strcmp(key, "FileRoot") == 0)
@ -225,7 +225,7 @@ bool CConf::read()
m_logDisplayLevel = (unsigned int)::atoi(value);
else if (::strcmp(key, "FileRotate") == 0)
m_logFileRotate = ::atoi(value) == 1;
} else if (section == SECTION_APRS) {
} else if (section == SECTION::APRS) {
if (::strcmp(key, "Enable") == 0)
m_aprsEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Address") == 0)
@ -238,7 +238,7 @@ bool CConf::read()
m_aprsDescription = value;
else if (::strcmp(key, "Symbol") == 0)
m_aprsSymbol = value;
} else if (section == SECTION_NETWORK) {
} else if (section == SECTION::NETWORK) {
if (::strcmp(key, "Startup") == 0)
m_networkStartup = value;
else if (::strcmp(key, "Options") == 0)
@ -249,7 +249,7 @@ bool CConf::read()
m_networkRevert = ::atoi(value) == 1;
else if (::strcmp(key, "Debug") == 0)
m_networkDebug = ::atoi(value) == 1;
} else if (section == SECTION_YSF_NETWORK) {
} else if (section == SECTION::YSF_NETWORK) {
if (::strcmp(key, "Enable") == 0)
m_ysfNetworkEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Port") == 0)
@ -274,21 +274,21 @@ bool CConf::read()
m_ysfNetworkYSF2P25Address = value;
else if (::strcmp(key, "YSF2P25Port") == 0)
m_ysfNetworkYSF2P25Port = (unsigned short)::atoi(value);
} else if (section == SECTION_FCS_NETWORK) {
} else if (section == SECTION::FCS_NETWORK) {
if (::strcmp(key, "Enable") == 0)
m_fcsNetworkEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Rooms") == 0)
m_fcsNetworkFile = value;
else if (::strcmp(key, "Port") == 0)
m_fcsNetworkPort = (unsigned short)::atoi(value);
} else if (section == SECTION_GPSD) {
} else if (section == SECTION::GPSD) {
if (::strcmp(key, "Enable") == 0)
m_gpsdEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Address") == 0)
m_gpsdAddress = value;
else if (::strcmp(key, "Port") == 0)
m_gpsdPort = value;
} else if (section == SECTION_REMOTE_COMMANDS) {
} else if (section == SECTION::REMOTE_COMMANDS) {
if (::strcmp(key, "Enable") == 0)
m_remoteCommandsEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Port") == 0)

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2012,2013,2015,2017,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2012,2013,2015,2017,2018,2025 by Jonathan Naylor G4KLX
* Copyright (C) 2011 by DV Developer Group. DJ0ABR
*
* This program is free software; you can redistribute it and/or modify
@ -60,17 +60,17 @@ CDTMF::~CDTMF()
WX_STATUS CDTMF::decodeVDMode2(unsigned char* payload, bool end)
{
assert(payload != NULL);
assert(payload != nullptr);
payload += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
for (unsigned int offset = 5U; offset < 90U; offset += 18U) {
WX_STATUS status = decodeVDMode2Slice(payload + offset, end);
if (status != WXS_NONE)
if (status != WX_STATUS::NONE)
return status;
}
return WXS_NONE;
return WX_STATUS::NONE;
}
WX_STATUS CDTMF::decodeVDMode2Slice(unsigned char* ambe, bool end)
@ -167,43 +167,43 @@ WX_STATUS CDTMF::decodeVDMode2Slice(unsigned char* ambe, bool end)
WX_STATUS CDTMF::validate() const
{
if (m_command.empty())
return WXS_NONE;
return WX_STATUS::NONE;
size_t length = m_command.length();
char first = m_command.at(0U);
if (length == 1U && first == '#') {
return WXS_DISCONNECT;
return WX_STATUS::DISCONNECT;
} else if (length == 3U && first == 'A') {
for (unsigned int i = 1U; i < 3U; i++) {
char c = m_command.at(i);
if (c < '0' || c > '9')
return WXS_NONE;
return WX_STATUS::NONE;
}
return WXS_CONNECT_FCS;
return WX_STATUS::CONNECT_FCS;
} else if (length == 4U && first == 'A') {
for (unsigned int i = 1U; i < 4U; i++) {
char c = m_command.at(i);
if (c < '0' || c > '9')
return WXS_NONE;
return WX_STATUS::NONE;
}
return WXS_CONNECT_FCS;
return WX_STATUS::CONNECT_FCS;
} else if (length == 6U && first == '#') {
for (unsigned int i = 1U; i < 6U; i++) {
char c = m_command.at(i);
if (c < '0' || c > '9')
return WXS_NONE;
return WX_STATUS::NONE;
}
if (m_command == "#99999")
return WXS_DISCONNECT;
return WX_STATUS::DISCONNECT;
return WXS_CONNECT_YSF;
return WX_STATUS::CONNECT_YSF;
}
return WXS_NONE;
return WX_STATUS::NONE;
}
std::string CDTMF::getReflector()

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2014,2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2014,2016,2017,2018,2020,2025 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
@ -34,17 +34,17 @@ m_socket(port),
m_debug(debug),
m_addr(),
m_addrLen(),
m_ping(NULL),
m_options(NULL),
m_ping(nullptr),
m_options(nullptr),
m_opt(),
m_info(NULL),
m_info(nullptr),
m_reflector(),
m_print(),
m_buffer(1000U, "FCS Network Buffer"),
m_n(0U),
m_pingTimer(1000U, 0U, 800U),
m_resetTimer(1000U, 1U),
m_state(FCS_UNLINKED)
m_state(FCS_STATE::UNLINKED)
{
m_info = new unsigned char[100U];
::sprintf((char*)m_info, "%9u%9u%-6.6s%-12.12s%7u", rxFrequency, txFrequency, locator.c_str(), FCS_VERSION, id);
@ -93,14 +93,14 @@ void CFCSNetwork::clearDestination()
m_pingTimer.stop();
m_resetTimer.stop();
m_state = FCS_UNLINKED;
m_state = FCS_STATE::UNLINKED;
}
void CFCSNetwork::write(const unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
if (m_state != FCS_LINKED)
if (m_state != FCS_STATE::LINKED)
return;
unsigned char buffer[130U];
@ -117,7 +117,7 @@ void CFCSNetwork::write(const unsigned char* data)
bool CFCSNetwork::writeLink(const std::string& reflector)
{
if (m_state != FCS_LINKED) {
if (m_state != FCS_STATE::LINKED) {
std::string name = reflector.substr(0U, 6U);
if (m_addresses.count(name) == 0U) {
@ -140,7 +140,7 @@ bool CFCSNetwork::writeLink(const std::string& reflector)
m_print = reflector.substr(0U, 6U) + "-" + reflector.substr(6U);
m_state = FCS_LINKING;
m_state = FCS_STATE::LINKING;
m_pingTimer.start();
@ -156,7 +156,7 @@ void CFCSNetwork::setOptions(const std::string& options)
void CFCSNetwork::writeUnlink(unsigned int count)
{
if (m_state != FCS_LINKED)
if (m_state != FCS_STATE::LINKED)
return;
for (unsigned int i = 0U; i < count; i++)
@ -185,7 +185,7 @@ void CFCSNetwork::clock(unsigned int ms)
if (length <= 0)
return;
if (m_state == FCS_UNLINKED)
if (m_state == FCS_STATE::UNLINKED)
return;
if (!CUDPSocket::match(addr, m_addr))
@ -195,16 +195,16 @@ void CFCSNetwork::clock(unsigned int ms)
CUtils::dump(1U, "FCS Network Data Received", buffer, length);
if (length == 7) {
if (m_state == FCS_LINKING)
if (m_state == FCS_STATE::LINKING)
LogMessage("Linked to %s", m_print.c_str());
m_state = FCS_LINKED;
m_state = FCS_STATE::LINKED;
writeInfo();
writeOptions(m_print);
}
if (length == 10 && m_state == FCS_LINKING) {
if (length == 10 && m_state == FCS_STATE::LINKING) {
LogMessage("Linked to %s", m_print.c_str());
m_state = FCS_LINKED;
m_state = FCS_STATE::LINKED;
writeInfo();
writeOptions(m_print);
}
@ -218,7 +218,7 @@ void CFCSNetwork::clock(unsigned int ms)
unsigned int CFCSNetwork::read(unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
if (m_buffer.isEmpty())
return 0U;
@ -264,7 +264,7 @@ void CFCSNetwork::close()
void CFCSNetwork::writeInfo()
{
if (m_state != FCS_LINKED)
if (m_state != FCS_STATE::LINKED)
return;
if (m_debug)
@ -275,7 +275,7 @@ void CFCSNetwork::writeInfo()
void CFCSNetwork::writePing()
{
if (m_state == FCS_UNLINKED)
if (m_state == FCS_STATE::UNLINKED)
return;
if (m_debug)
@ -286,7 +286,7 @@ void CFCSNetwork::writePing()
void CFCSNetwork::writeOptions(const std::string& reflector)
{
if (m_state != FCS_LINKED)
if (m_state != FCS_STATE::LINKED)
return;
if (m_opt.size() < 1)

View file

@ -28,10 +28,10 @@
#include <string>
#include <map>
enum FCS_STATE {
FCS_UNLINKED,
FCS_LINKING,
FCS_LINKED
enum class FCS_STATE {
UNLINKED,
LINKING,
LINKED
};
class CFCSNetwork {

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017,2018,2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018,2020,2024,2025 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
@ -32,10 +32,10 @@ const unsigned char LONG_GPS[] = {0x47U, 0x64U};
CGPS::CGPS(CAPRSWriter* writer) :
m_writer(writer),
m_buffer(NULL),
m_buffer(nullptr),
m_sent(false)
{
assert(writer != NULL);
assert(writer != nullptr);
m_buffer = new unsigned char[300U];
}
@ -141,7 +141,7 @@ void CGPS::reset()
void CGPS::transmitGPS(const unsigned char* source)
{
assert(m_writer != NULL);
assert(m_writer != nullptr);
// We don't know who its from!
if (::memcmp(source, " ", YSF_CALLSIGN_LENGTH) == 0)

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2010,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2010,2016,2025 by Jonathan Naylor G4KLX
* Copyright (C) 2002 by Robert H. Morelos-Zaragoza. All rights reserved.
*/
@ -1096,7 +1096,7 @@ unsigned int CGolay24128::decode24128(unsigned int code)
unsigned int CGolay24128::decode24128(unsigned char* bytes)
{
assert(bytes != NULL);
assert(bytes != nullptr);
unsigned int code = bytes[0U];
code <<= 8;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2020,2025 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
@ -37,7 +37,7 @@ static std::string m_filePath;
static std::string m_fileRoot;
static bool m_fileRotate = true;
static FILE* m_fpLog = NULL;
static FILE* m_fpLog = nullptr;
static bool m_daemon = false;
static unsigned int m_displayLevel = 2U;
@ -59,10 +59,10 @@ static bool logOpenRotate()
struct tm* tm = ::gmtime(&now);
if (tm->tm_mday == m_tm.tm_mday && tm->tm_mon == m_tm.tm_mon && tm->tm_year == m_tm.tm_year) {
if (m_fpLog != NULL)
if (m_fpLog != nullptr)
return true;
} else {
if (m_fpLog != NULL)
if (m_fpLog != nullptr)
::fclose(m_fpLog);
}
@ -73,7 +73,7 @@ static bool logOpenRotate()
::sprintf(filename, "%s/%s-%04d-%02d-%02d.log", m_filePath.c_str(), m_fileRoot.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday);
#endif
if ((m_fpLog = ::fopen(filename, "a+t")) != NULL) {
if ((m_fpLog = ::fopen(filename, "a+t")) != nullptr) {
status = true;
#if !defined(_WIN32) && !defined(_WIN64)
@ -94,7 +94,7 @@ static bool logOpenNoRotate()
if (m_fileLevel == 0U)
return true;
if (m_fpLog != NULL)
if (m_fpLog != nullptr)
return true;
char filename[200U];
@ -104,7 +104,7 @@ static bool logOpenNoRotate()
::sprintf(filename, "%s/%s.log", m_filePath.c_str(), m_fileRoot.c_str());
#endif
if ((m_fpLog = ::fopen(filename, "a+t")) != NULL) {
if ((m_fpLog = ::fopen(filename, "a+t")) != nullptr) {
status = true;
#if !defined(_WIN32) && !defined(_WIN64)
@ -141,13 +141,13 @@ bool LogInitialise(bool daemon, const std::string& filePath, const std::string&
void LogFinalise()
{
if (m_fpLog != NULL)
if (m_fpLog != nullptr)
::fclose(m_fpLog);
}
void Log(unsigned int level, const char* fmt, ...)
{
assert(fmt != NULL);
assert(fmt != nullptr);
char buffer[501U];
#if defined(_WIN32) || defined(_WIN64)
@ -157,7 +157,7 @@ void Log(unsigned int level, const char* fmt, ...)
::sprintf(buffer, "%c: %04u-%02u-%02u %02u:%02u:%02u.%03u ", LEVELS[level], st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
#else
struct timeval now;
::gettimeofday(&now, NULL);
::gettimeofday(&now, nullptr);
struct tm* tm = ::gmtime(&now.tv_sec);
@ -167,7 +167,7 @@ void Log(unsigned int level, const char* fmt, ...)
va_list vl;
va_start(vl, fmt);
::vsnprintf(buffer + ::strlen(buffer), 500, fmt, vl);
::vsnprintf(buffer + ::strlen(buffer), 500 - ::strlen(buffer), fmt, vl);
va_end(vl);

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2009,2012,2013,2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2006-2009,2012,2013,2015,2016,2025 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
@ -30,12 +30,12 @@ public:
CRingBuffer(unsigned int length, const char* name) :
m_length(length),
m_name(name),
m_buffer(NULL),
m_buffer(nullptr),
m_iPtr(0U),
m_oPtr(0U)
{
assert(length > 0U);
assert(name != NULL);
assert(name != nullptr);
m_buffer = new T[length];

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2018,2025 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
@ -77,7 +77,7 @@ CStopWatch::~CStopWatch()
unsigned long long CStopWatch::time() const
{
struct timeval now;
::gettimeofday(&now, NULL);
::gettimeofday(&now, nullptr);
return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2025 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
@ -26,7 +26,7 @@
void CSync::add(unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
::memcpy(data, YSF_SYNC_BYTES, YSF_SYNC_LENGTH_BYTES);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2020,2025 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
@ -31,9 +31,9 @@ CThread::~CThread()
bool CThread::run()
{
m_handle = ::CreateThread(NULL, 0, &helper, this, 0, NULL);
m_handle = ::CreateThread(nullptr, 0, &helper, this, 0, nullptr);
return m_handle != NULL;
return m_handle != nullptr;
}
@ -74,13 +74,13 @@ CThread::~CThread()
bool CThread::run()
{
return ::pthread_create(&m_thread, NULL, helper, this) == 0;
return ::pthread_create(&m_thread, nullptr, helper, this) == 0;
}
void CThread::wait()
{
::pthread_join(m_thread, NULL);
::pthread_join(m_thread, nullptr);
}
@ -90,7 +90,7 @@ void* CThread::helper(void* arg)
p->entry();
return NULL;
return nullptr;
}
void CThread::sleep(unsigned int ms)
@ -100,7 +100,7 @@ void CThread::sleep(unsigned int ms)
ts.tv_sec = ms / 1000U;
ts.tv_nsec = (ms % 1000U) * 1000000U;
::nanosleep(&ts, NULL);
::nanosleep(&ts, nullptr);
}
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2016,2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2006-2016,2020,2024,2025 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
@ -94,7 +94,7 @@ int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockadd
/* Port is always digits, no needs to lookup service */
hints.ai_flags |= AI_NUMERICSERV;
int err = ::getaddrinfo(hostname.empty() ? NULL : hostname.c_str(), portstr.c_str(), &hints, &res);
int err = ::getaddrinfo(hostname.empty() ? nullptr : hostname.c_str(), portstr.c_str(), &hints, &res);
if (err != 0) {
sockaddr_in* paddr = (sockaddr_in*)&addr;
::memset(paddr, 0x00U, address_length = sizeof(sockaddr_in));
@ -119,7 +119,7 @@ bool CUDPSocket::match(const sockaddr_storage& addr1, const sockaddr_storage& ad
if (addr1.ss_family != addr2.ss_family)
return false;
if (type == IMT_ADDRESS_AND_PORT) {
if (type == IPMATCHTYPE::ADDRESS_AND_PORT) {
switch (addr1.ss_family) {
case AF_INET:
struct sockaddr_in *in_1, *in_2;
@ -134,7 +134,7 @@ bool CUDPSocket::match(const sockaddr_storage& addr1, const sockaddr_storage& ad
default:
return false;
}
} else if (type == IMT_ADDRESS_ONLY) {
} else if (type == IPMATCHTYPE::ADDRESS_ONLY) {
switch (addr1.ss_family) {
case AF_INET:
struct sockaddr_in *in_1, *in_2;
@ -233,7 +233,7 @@ bool CUDPSocket::open()
int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int &addressLength)
{
assert(buffer != NULL);
assert(buffer != nullptr);
assert(length > 0U);
#if defined(_WIN32) || defined(_WIN64)
@ -301,7 +301,7 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storag
bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int addressLength)
{
assert(buffer != NULL);
assert(buffer != nullptr);
assert(length > 0U);
#if defined(_WIN32) || defined(_WIN64)
assert(m_fd != INVALID_SOCKET);

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2011,2013,2015,2016,2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2011,2013,2015,2016,2020,2024,2025 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
@ -35,9 +35,9 @@
#include <ws2tcpip.h>
#endif
enum IPMATCHTYPE {
IMT_ADDRESS_AND_PORT,
IMT_ADDRESS_ONLY
enum class IPMATCHTYPE {
ADDRESS_AND_PORT,
ADDRESS_ONLY
};
class CUDPSocket {
@ -60,7 +60,7 @@ public:
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& addressLength);
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& addressLength, struct addrinfo& hints);
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT);
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IPMATCHTYPE::ADDRESS_AND_PORT);
static bool isNone(const sockaddr_storage& addr);

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009,2014,2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2009,2014,2015,2016,2025 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
@ -19,14 +19,14 @@
void CUtils::dump(const std::string& title, const unsigned char* data, unsigned int length)
{
assert(data != NULL);
assert(data != nullptr);
dump(2U, title, data, length);
}
void CUtils::dump(int level, const std::string& title, const unsigned char* data, unsigned int length)
{
assert(data != NULL);
assert(data != nullptr);
::Log(level, "%s", title.c_str());
@ -72,14 +72,14 @@ void CUtils::dump(int level, const std::string& title, const unsigned char* data
void CUtils::dump(const std::string& title, const bool* bits, unsigned int length)
{
assert(bits != NULL);
assert(bits != nullptr);
dump(2U, title, bits, length);
}
void CUtils::dump(int level, const std::string& title, const bool* bits, unsigned int length)
{
assert(bits != NULL);
assert(bits != nullptr);
unsigned char bytes[100U];
unsigned int nBytes = 0U;
@ -91,7 +91,7 @@ void CUtils::dump(int level, const std::string& title, const bool* bits, unsigne
void CUtils::byteToBitsBE(unsigned char byte, bool* bits)
{
assert(bits != NULL);
assert(bits != nullptr);
bits[0U] = (byte & 0x80U) == 0x80U;
bits[1U] = (byte & 0x40U) == 0x40U;
@ -105,7 +105,7 @@ void CUtils::byteToBitsBE(unsigned char byte, bool* bits)
void CUtils::byteToBitsLE(unsigned char byte, bool* bits)
{
assert(bits != NULL);
assert(bits != nullptr);
bits[0U] = (byte & 0x01U) == 0x01U;
bits[1U] = (byte & 0x02U) == 0x02U;
@ -119,7 +119,7 @@ void CUtils::byteToBitsLE(unsigned char byte, bool* bits)
void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte)
{
assert(bits != NULL);
assert(bits != nullptr);
byte = bits[0U] ? 0x80U : 0x00U;
byte |= bits[1U] ? 0x40U : 0x00U;
@ -133,7 +133,7 @@ void CUtils::bitsToByteBE(const bool* bits, unsigned char& byte)
void CUtils::bitsToByteLE(const bool* bits, unsigned char& byte)
{
assert(bits != NULL);
assert(bits != nullptr);
byte = bits[0U] ? 0x01U : 0x00U;
byte |= bits[1U] ? 0x02U : 0x00U;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2021,2023,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2015-2021,2023,2024,2025 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
@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H
const char* VERSION = "20241218";
const char* VERSION = "20250319";
#endif

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017,2018,2019,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018,2019,2020,2025 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
@ -48,26 +48,26 @@ m_callsign(callsign),
m_node(),
m_network(network),
m_reflectors(reflectors),
m_reflector(NULL),
m_reflector(nullptr),
m_id(),
m_name(),
m_command(NULL),
m_command(nullptr),
m_txFrequency(0U),
m_rxFrequency(0U),
m_timer(1000U, 1U),
m_seqNo(0U),
m_header(NULL),
m_csd1(NULL),
m_csd2(NULL),
m_csd3(NULL),
m_status(WXSI_NONE),
m_header(nullptr),
m_csd1(nullptr),
m_csd2(nullptr),
m_csd3(nullptr),
m_status(WXSI_STATUS::NONE),
m_start(0U),
m_search(),
m_busy(false),
m_busyTimer(3000U, 1U),
m_bufferTX(10000U, "YSF Wires-X TX Buffer")
{
assert(network != NULL);
assert(network != nullptr);
m_node = callsign;
if (suffix.size() > 0U) {
@ -187,35 +187,35 @@ bool CWiresX::start()
WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* source, const CYSFFICH& fich, bool wiresXCommandPassthrough)
{
assert(data != NULL);
assert(source != NULL);
assert(data != nullptr);
assert(source != nullptr);
unsigned char dt = fich.getDT();
if (dt != YSF_DT_DATA_FR_MODE)
return WXS_NONE;
return WX_STATUS::NONE;
unsigned char fi = fich.getFI();
if (fi != YSF_FI_COMMUNICATIONS)
return WXS_NONE;
return WX_STATUS::NONE;
CYSFPayload payload;
unsigned char fn = fich.getFN();
if (fn == 0U)
return WXS_NONE;
return WX_STATUS::NONE;
if (fn == 1U) {
bool valid = payload.readDataFRModeData2(data, m_command + 0U);
if (!valid)
return WXS_NONE;
return WX_STATUS::NONE;
} else {
bool valid = payload.readDataFRModeData1(data, m_command + (fn - 2U) * 40U + 20U);
if (!valid)
return WXS_NONE;
return WX_STATUS::NONE;
valid = payload.readDataFRModeData2(data, m_command + (fn - 2U) * 40U + 40U);
if (!valid)
return WXS_NONE;
return WX_STATUS::NONE;
}
unsigned char ft = fich.getFT();
@ -234,52 +234,52 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc
}
if (!valid)
return WXS_NONE;
return WX_STATUS::NONE;
CUtils::dump(1U, "Received Wires-X command", m_command, cmd_len);
// If we are using WiresX Passthrough (we already know we are on a YSF2xxx room from YSFGateway
if (wiresXCommandPassthrough) {
if (::memcmp(m_command + 1U, DX_REQ, 3U) == 0) {
return WXS_NONE;
return WX_STATUS::NONE;
} else if (::memcmp(m_command + 1U, ALL_REQ, 3U) == 0) {
return WXS_NONE;
return WX_STATUS::NONE;
} else if (::memcmp(m_command + 1U, CONN_REQ, 3U) == 0) {
return WXS_NONE;
return WX_STATUS::NONE;
} else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) {
processDisconnect(source);
return WXS_DISCONNECT;
return WX_STATUS::DISCONNECT;
} else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) {
return WXS_NONE;
return WX_STATUS::NONE;
} else {
CUtils::dump("Unknown Wires-X command", m_command, cmd_len);
return WXS_NONE;
return WX_STATUS::NONE;
}
}
// Origional Code Here
else {
if (::memcmp(m_command + 1U, DX_REQ, 3U) == 0) {
processDX(source);
return WXS_NONE;
return WX_STATUS::NONE;
} else if (::memcmp(m_command + 1U, ALL_REQ, 3U) == 0) {
processAll(source, m_command + 5U);
return WXS_NONE;
return WX_STATUS::NONE;
} else if (::memcmp(m_command + 1U, CONN_REQ, 3U) == 0) {
return processConnect(source, m_command + 5U);
} else if (::memcmp(m_command + 1U, DISC_REQ, 3U) == 0) {
processDisconnect(source);
return WXS_DISCONNECT;
return WX_STATUS::DISCONNECT;
} else if (::memcmp(m_command + 1U, CAT_REQ, 3U) == 0) {
processCategory(source, m_command + 5U);
return WXS_NONE;
return WX_STATUS::NONE;
} else {
CUtils::dump("Unknown Wires-X command", m_command, cmd_len);
return WXS_NONE;
return WX_STATUS::NONE;
}
}
}
return WXS_NONE;
return WX_STATUS::NONE;
}
CYSFReflector* CWiresX::getReflector() const
@ -296,7 +296,7 @@ void CWiresX::processDX(const unsigned char* source)
{
::LogDebug("Received DX from %10.10s", source);
m_status = WXSI_DX;
m_status = WXSI_STATUS::DX;
m_timer.start();
}
@ -329,7 +329,7 @@ void CWiresX::processCategory(const unsigned char* source, const unsigned char*
m_category.push_back(refl);
}
m_status = WXSI_CATEGORY;
m_status = WXSI_STATUS::CATEGORY;
m_timer.start();
}
@ -346,7 +346,7 @@ void CWiresX::processAll(const unsigned char* source, const unsigned char* data)
if (m_start > 0U)
m_start--;
m_status = WXSI_ALL;
m_status = WXSI_STATUS::ALL;
m_timer.start();
} else if (data[0U] == '1' && data[1U] == '1') {
@ -358,7 +358,7 @@ void CWiresX::processAll(const unsigned char* source, const unsigned char* data)
m_search = std::string((char*)(data + 5U), 16U);
m_status = WXSI_SEARCH;
m_status = WXSI_STATUS::SEARCH;
m_timer.start();
}
@ -374,19 +374,19 @@ WX_STATUS CWiresX::processConnect(const unsigned char* source, const unsigned ch
std::string id = std::string((char*)data, 5U);
m_reflector = m_reflectors.findById(id);
if (m_reflector == NULL)
return WXS_NONE;
if (m_reflector == nullptr)
return WX_STATUS::NONE;
m_status = WXSI_CONNECT;
m_status = WXSI_STATUS::CONNECT;
m_timer.start();
switch (m_reflector->m_type) {
case YT_YSF:
return WXS_CONNECT_YSF;
case YT_FCS:
return WXS_CONNECT_FCS;
case YSF_TYPE::YSF:
return WX_STATUS::CONNECT_YSF;
case YSF_TYPE::FCS:
return WX_STATUS::CONNECT_FCS;
default:
return WXS_NONE;
return WX_STATUS::NONE;
}
}
@ -397,18 +397,18 @@ void CWiresX::processConnect(CYSFReflector* reflector)
m_reflector = reflector;
m_status = WXSI_CONNECT;
m_status = WXSI_STATUS::CONNECT;
m_timer.start();
}
void CWiresX::processDisconnect(const unsigned char* source)
{
if (source != NULL)
if (source != nullptr)
::LogDebug("Received Disconect from %10.10s", source);
m_reflector = NULL;
m_reflector = nullptr;
m_status = WXSI_DISCONNECT;
m_status = WXSI_STATUS::DISCONNECT;
m_timer.start();
}
@ -421,29 +421,29 @@ void CWiresX::clock(unsigned int ms)
m_timer.clock(ms);
if (m_timer.isRunning() && m_timer.hasExpired()) {
switch (m_status) {
case WXSI_DX:
case WXSI_STATUS::DX:
sendDXReply();
break;
case WXSI_ALL:
case WXSI_STATUS::ALL:
sendAllReply();
break;
case WXSI_SEARCH:
case WXSI_STATUS::SEARCH:
sendSearchReply();
break;
case WXSI_CONNECT:
case WXSI_STATUS::CONNECT:
sendConnectReply();
break;
case WXSI_DISCONNECT:
case WXSI_STATUS::DISCONNECT:
sendDisconnectReply();
break;
case WXSI_CATEGORY:
case WXSI_STATUS::CATEGORY:
sendCategoryReply();
break;
default:
break;
}
m_status = WXSI_NONE;
m_status = WXSI_STATUS::NONE;
m_timer.stop();
}
@ -468,13 +468,13 @@ void CWiresX::clock(unsigned int ms)
void CWiresX::createReply(const unsigned char* data, unsigned int length, CYSFNetwork* network)
{
assert(data != NULL);
assert(data != nullptr);
assert(length > 0U);
bool isYSF2XX = true;
// If we don't explicitly pass a network, use the default one.
if (network == NULL) {
if (network == nullptr) {
isYSF2XX = false;
network = m_network;
}
@ -642,7 +642,7 @@ void CWiresX::sendDXReply()
for (unsigned int i = 0U; i < 14U; i++)
data[i + 20U] = m_name.at(i);
if (m_reflector == NULL) {
if (m_reflector == nullptr) {
data[34U] = '1';
data[35U] = '2';
@ -718,7 +718,7 @@ void CWiresX::sendConnect(CYSFNetwork* network)
void CWiresX::sendConnectReply()
{
assert(m_reflector != NULL);
assert(m_reflector != nullptr);
unsigned char data[110U];
::memset(data, 0x00U, 110U);

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017,2018,2019,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018,2019,2020,2025 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
@ -28,21 +28,21 @@
#include <string>
enum WX_STATUS {
WXS_NONE,
WXS_CONNECT_YSF,
WXS_CONNECT_FCS,
WXS_DISCONNECT
enum class WX_STATUS {
NONE,
CONNECT_YSF,
CONNECT_FCS,
DISCONNECT
};
enum WXSI_STATUS {
WXSI_NONE,
WXSI_DX,
WXSI_CONNECT,
WXSI_DISCONNECT,
WXSI_ALL,
WXSI_SEARCH,
WXSI_CATEGORY
enum class WXSI_STATUS {
NONE,
DX,
CONNECT,
DISCONNECT,
ALL,
SEARCH,
CATEGORY
};
class CWiresX {
@ -66,7 +66,7 @@ public:
void setReflector(CYSFReflector* reflector);
void processConnect(CYSFReflector* reflector);
void processDisconnect(const unsigned char* source = NULL);
void processDisconnect(const unsigned char* source = nullptr);
void sendConnect(CYSFNetwork* network);
@ -111,7 +111,7 @@ private:
void sendSearchNotFoundReply();
void sendCategoryReply();
void createReply(const unsigned char* data, unsigned int length, CYSFNetwork* network = NULL);
void createReply(const unsigned char* data, unsigned int length, CYSFNetwork* network = nullptr);
void writeData(const unsigned char* data, CYSFNetwork* network, bool isYSF2XX);
unsigned char calculateFT(unsigned int length, unsigned int offset) const;
};

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2016 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2016,2025 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
@ -36,12 +36,12 @@ const uint32_t M = 2U;
const unsigned int K = 5U;
CYSFConvolution::CYSFConvolution() :
m_metrics1(NULL),
m_metrics2(NULL),
m_oldMetrics(NULL),
m_newMetrics(NULL),
m_decisions(NULL),
m_dp(NULL)
m_metrics1(nullptr),
m_metrics2(nullptr),
m_oldMetrics(nullptr),
m_newMetrics(nullptr),
m_decisions(nullptr),
m_dp(nullptr)
{
m_metrics1 = new uint16_t[16U];
m_metrics2 = new uint16_t[16U];
@ -98,7 +98,7 @@ void CYSFConvolution::decode(uint8_t s0, uint8_t s1)
void CYSFConvolution::chainback(unsigned char* out, unsigned int nBits)
{
assert(out != NULL);
assert(out != nullptr);
uint32_t state = 0U;
@ -115,8 +115,8 @@ void CYSFConvolution::chainback(unsigned char* out, unsigned int nBits)
void CYSFConvolution::encode(const unsigned char* in, unsigned char* out, unsigned int nBits) const
{
assert(in != NULL);
assert(out != NULL);
assert(in != nullptr);
assert(out != nullptr);
assert(nBits > 0U);
uint8_t d1 = 0U, d2 = 0U, d3 = 0U, d4 = 0U;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017,2019,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2019,2020,2025 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
@ -55,7 +55,7 @@ const unsigned int INTERLEAVE_TABLE[] = {
38U, 78U, 118U, 158U, 198U };
CYSFFICH::CYSFFICH(const CYSFFICH& fich) :
m_fich(NULL)
m_fich(nullptr)
{
m_fich = new unsigned char[6U];
@ -63,7 +63,7 @@ m_fich(NULL)
}
CYSFFICH::CYSFFICH() :
m_fich(NULL)
m_fich(nullptr)
{
m_fich = new unsigned char[6U];
@ -77,7 +77,7 @@ CYSFFICH::~CYSFFICH()
bool CYSFFICH::decode(const unsigned char* bytes)
{
assert(bytes != NULL);
assert(bytes != nullptr);
// Skip the sync bytes
bytes += YSF_SYNC_LENGTH_BYTES;
@ -116,7 +116,7 @@ bool CYSFFICH::decode(const unsigned char* bytes)
void CYSFFICH::encode(unsigned char* bytes)
{
assert(bytes != NULL);
assert(bytes != nullptr);
// Skip the sync bytes
bytes += YSF_SYNC_LENGTH_BYTES;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2016-2020,2024,2025 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
@ -121,14 +121,14 @@ CYSFGateway::CYSFGateway(const std::string& configFile) :
m_callsign(),
m_suffix(),
m_conf(configFile),
m_writer(NULL),
m_gps(NULL),
m_reflectors(NULL),
m_wiresX(NULL),
m_writer(nullptr),
m_gps(nullptr),
m_reflectors(nullptr),
m_wiresX(nullptr),
m_dtmf(),
m_ysfNetwork(NULL),
m_fcsNetwork(NULL),
m_linkType(LINK_NONE),
m_ysfNetwork(nullptr),
m_fcsNetwork(nullptr),
m_linkType(LINK_TYPE::NONE),
m_current(),
m_startup(),
m_options(),
@ -136,7 +136,7 @@ m_exclude(false),
m_inactivityTimer(1000U),
m_lostTimer(1000U, 120U),
m_fcsNetworkEnabled(false),
m_remoteSocket(NULL)
m_remoteSocket(nullptr)
{
CUDPSocket::startup();
}
@ -183,7 +183,7 @@ int CYSFGateway::run()
// If we are currently root...
if (getuid() == 0) {
struct passwd* user = ::getpwnam("mmdvm");
if (user == NULL) {
if (user == nullptr) {
::fprintf(stderr, "Could not get the mmdvm user, exiting\n");
return -1;
}
@ -293,7 +293,7 @@ int CYSFGateway::run()
ret = m_remoteSocket->open();
if (!ret) {
delete m_remoteSocket;
m_remoteSocket = NULL;
m_remoteSocket = nullptr;
}
}
@ -322,29 +322,29 @@ int CYSFGateway::run()
unsigned char dt = fich.getDT();
CYSFReflector* reflector = m_wiresX->getReflector();
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && wiresXCommandPassthrough && reflector->m_wiresX) {
if (m_ysfNetwork != nullptr && m_linkType == LINK_TYPE::YSF && wiresXCommandPassthrough && reflector->m_wiresX) {
processDTMF(buffer, dt);
processWiresX(buffer, fich, true, wiresXCommandPassthrough);
} else {
processDTMF(buffer, dt);
processWiresX(buffer, fich, false, wiresXCommandPassthrough);
reflector = m_wiresX->getReflector(); //reflector may have changed
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && reflector->m_wiresX)
if (m_ysfNetwork != nullptr && m_linkType == LINK_TYPE::YSF && reflector->m_wiresX)
m_exclude = (dt == YSF_DT_DATA_FR_MODE);
}
if (m_gps != NULL)
if (m_gps != nullptr)
m_gps->data(buffer + 14U, buffer + 35U, fich);
}
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && !m_exclude) {
if (m_ysfNetwork != nullptr && m_linkType == LINK_TYPE::YSF && !m_exclude) {
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) {
m_ysfNetwork->write(buffer);
m_inactivityTimer.start();
}
}
if (m_fcsNetwork != NULL && m_linkType == LINK_FCS && !m_exclude) {
if (m_fcsNetwork != nullptr && m_linkType == LINK_TYPE::FCS && !m_exclude) {
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0) {
m_fcsNetwork->write(buffer);
m_inactivityTimer.start();
@ -352,16 +352,16 @@ int CYSFGateway::run()
}
if ((buffer[34U] & 0x01U) == 0x01U) {
if (m_gps != NULL)
if (m_gps != nullptr)
m_gps->reset();
m_dtmf.reset();
m_exclude = false;
}
}
if (m_ysfNetwork != NULL) {
if (m_ysfNetwork != nullptr) {
while (m_ysfNetwork->read(buffer) > 0U) {
if (m_linkType == LINK_YSF) {
if (m_linkType == LINK_TYPE::YSF) {
// Only pass through YSF data packets
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0 && !m_wiresX->isBusy())
rptNetwork.write(buffer);
@ -371,9 +371,9 @@ int CYSFGateway::run()
}
}
if (m_fcsNetwork != NULL) {
if (m_fcsNetwork != nullptr) {
while (m_fcsNetwork->read(buffer) > 0U) {
if (m_linkType == LINK_FCS) {
if (m_linkType == LINK_TYPE::FCS) {
// Only pass through YSF data packets
if (::memcmp(buffer + 0U, "YSFD", 4U) == 0 && !m_wiresX->isBusy())
rptNetwork.write(buffer);
@ -383,18 +383,18 @@ int CYSFGateway::run()
}
}
if (m_remoteSocket != NULL)
if (m_remoteSocket != nullptr)
processRemoteCommands();
unsigned int ms = stopWatch.elapsed();
stopWatch.start();
rptNetwork.clock(ms);
if (m_ysfNetwork != NULL)
if (m_ysfNetwork != nullptr)
m_ysfNetwork->clock(ms);
if (m_fcsNetwork != NULL)
if (m_fcsNetwork != nullptr)
m_fcsNetwork->clock(ms);
if (m_writer != NULL)
if (m_writer != nullptr)
m_writer->clock(ms);
m_wiresX->clock(ms);
@ -402,32 +402,32 @@ int CYSFGateway::run()
if (m_inactivityTimer.isRunning() && m_inactivityTimer.hasExpired()) {
if (revert) {
if (m_current != m_startup) {
if (m_linkType == LINK_YSF) {
if (m_linkType == LINK_TYPE::YSF) {
m_wiresX->processDisconnect();
m_ysfNetwork->writeUnlink(3U);
m_ysfNetwork->clearDestination();
}
if (m_linkType == LINK_FCS) {
if (m_linkType == LINK_TYPE::FCS) {
m_fcsNetwork->writeUnlink(3U);
m_fcsNetwork->clearDestination();
}
m_current.clear();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
startupLinking();
}
} else {
if (m_linkType == LINK_YSF) {
if (m_linkType == LINK_TYPE::YSF) {
LogMessage("Disconnecting due to inactivity");
m_wiresX->processDisconnect();
m_ysfNetwork->writeUnlink(3U);
m_ysfNetwork->clearDestination();
}
if (m_linkType == LINK_FCS) {
if (m_linkType == LINK_TYPE::FCS) {
LogMessage("Disconnecting due to inactivity");
m_fcsNetwork->writeUnlink(3U);
m_fcsNetwork->clearDestination();
@ -435,7 +435,7 @@ int CYSFGateway::run()
m_current.clear();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
}
m_inactivityTimer.start();
@ -443,13 +443,13 @@ int CYSFGateway::run()
m_lostTimer.clock(ms);
if (m_lostTimer.isRunning() && m_lostTimer.hasExpired()) {
if (m_linkType == LINK_YSF) {
if (m_linkType == LINK_TYPE::YSF) {
LogWarning("Link has failed, polls lost");
m_wiresX->processDisconnect();
m_ysfNetwork->clearDestination();
}
if (m_fcsNetwork != NULL) {
if (m_fcsNetwork != nullptr) {
LogWarning("Link has failed, polls lost");
m_fcsNetwork->clearDestination();
}
@ -457,7 +457,7 @@ int CYSFGateway::run()
m_current.clear();
m_inactivityTimer.start();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
}
if (ms < 5U)
@ -466,23 +466,23 @@ int CYSFGateway::run()
rptNetwork.clearDestination();
if (m_gps != NULL) {
if (m_gps != nullptr) {
m_writer->close();
delete m_writer;
delete m_gps;
}
if (m_ysfNetwork != NULL) {
if (m_ysfNetwork != nullptr) {
m_ysfNetwork->clearDestination();
delete m_ysfNetwork;
}
if (m_fcsNetwork != NULL) {
if (m_fcsNetwork != nullptr) {
m_fcsNetwork->close();
delete m_fcsNetwork;
}
if (m_remoteSocket != NULL) {
if (m_remoteSocket != nullptr) {
m_remoteSocket->close();
delete m_remoteSocket;
}
@ -531,7 +531,7 @@ void CYSFGateway::createGPS()
bool ret = m_writer->open();
if (!ret) {
delete m_writer;
m_writer = NULL;
m_writer = nullptr;
return;
}
@ -540,7 +540,7 @@ void CYSFGateway::createGPS()
void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork)
{
assert(rptNetwork != NULL);
assert(rptNetwork != nullptr);
m_wiresX = new CWiresX(m_callsign, m_suffix, rptNetwork, *m_reflectors);
@ -580,15 +580,15 @@ void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork)
void CYSFGateway::processWiresX(const unsigned char* buffer, const CYSFFICH& fich, bool dontProcessWiresXLocal, bool wiresXCommandPassthrough)
{
assert(buffer != NULL);
assert(buffer != nullptr);
WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fich, dontProcessWiresXLocal);
switch (status) {
case WXS_CONNECT_YSF: {
if (m_linkType == LINK_YSF)
case WX_STATUS::CONNECT_YSF: {
if (m_linkType == LINK_TYPE::YSF)
m_ysfNetwork->writeUnlink(3U);
if (m_linkType == LINK_FCS) {
if (m_linkType == LINK_TYPE::FCS) {
m_fcsNetwork->writeUnlink(3U);
m_fcsNetwork->clearDestination();
}
@ -602,7 +602,7 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, const CYSFFICH& fic
m_current = reflector->m_id;
m_inactivityTimer.start();
m_lostTimer.start();
m_linkType = LINK_YSF;
m_linkType = LINK_TYPE::YSF;
// If we are linking to a YSF2xxx mode, send the YSF2xxx gateway the link command too
if (reflector->m_wiresX && wiresXCommandPassthrough) {
@ -611,19 +611,19 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, const CYSFFICH& fic
}
}
break;
case WXS_CONNECT_FCS: {
if (m_linkType == LINK_YSF) {
case WX_STATUS::CONNECT_FCS: {
if (m_linkType == LINK_TYPE::YSF) {
m_ysfNetwork->writeUnlink(3U);
m_ysfNetwork->clearDestination();
}
if (m_linkType == LINK_FCS)
if (m_linkType == LINK_TYPE::FCS)
m_fcsNetwork->writeUnlink(3U);
m_current.clear();
m_inactivityTimer.start();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
CYSFReflector* reflector = m_wiresX->getReflector();
LogMessage("Connect to %s - \"%s\" has been requested by %10.10s", reflector->m_id.c_str(), reflector->m_name.c_str(), buffer + 14U);
@ -635,14 +635,14 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, const CYSFFICH& fic
if (ok) {
m_current = name;
m_lostTimer.start();
m_linkType = LINK_FCS;
m_linkType = LINK_TYPE::FCS;
} else {
LogMessage("Unknown reflector - %s", name.c_str());
}
}
break;
case WXS_DISCONNECT:
if (m_linkType == LINK_YSF) {
case WX_STATUS::DISCONNECT:
if (m_linkType == LINK_TYPE::YSF) {
LogMessage("Disconnect has been requested by %10.10s", buffer + 14U);
if ( (wiresXCommandPassthrough) && (::memcmp(buffer + 0U, "YSFD", 4U) == 0) ) {
// Send the disconnect to the YSF2xxx gateway too
@ -655,9 +655,9 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, const CYSFFICH& fic
m_current.clear();
m_inactivityTimer.start();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
}
if (m_linkType == LINK_FCS) {
if (m_linkType == LINK_TYPE::FCS) {
LogMessage("Disconnect has been requested by %10.10s", buffer + 14U);
m_fcsNetwork->writeUnlink(3U);
@ -666,7 +666,7 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, const CYSFFICH& fic
m_current.clear();
m_inactivityTimer.start();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
}
break;
default:
@ -676,9 +676,9 @@ void CYSFGateway::processWiresX(const unsigned char* buffer, const CYSFFICH& fic
void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt)
{
assert(buffer != NULL);
assert(buffer != nullptr);
WX_STATUS status = WXS_NONE;
WX_STATUS status = WX_STATUS::NONE;
switch (dt) {
case YSF_DT_VD_MODE2:
status = m_dtmf.decodeVDMode2(buffer + 35U, (buffer[34U] & 0x01U) == 0x01U);
@ -688,16 +688,16 @@ void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt)
}
switch (status) {
case WXS_CONNECT_YSF: {
case WX_STATUS::CONNECT_YSF: {
std::string id = m_dtmf.getReflector();
CYSFReflector* reflector = m_reflectors->findById(id);
if (reflector != NULL) {
if (reflector != nullptr) {
m_wiresX->processConnect(reflector);
if (m_linkType == LINK_YSF)
if (m_linkType == LINK_TYPE::YSF)
m_ysfNetwork->writeUnlink(3U);
if (m_linkType == LINK_FCS) {
if (m_linkType == LINK_TYPE::FCS) {
m_fcsNetwork->writeUnlink(3U);
m_fcsNetwork->clearDestination();
}
@ -710,11 +710,11 @@ void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt)
m_current = id;
m_inactivityTimer.start();
m_lostTimer.start();
m_linkType = LINK_YSF;
m_linkType = LINK_TYPE::YSF;
}
}
break;
case WXS_CONNECT_FCS: {
case WX_STATUS::CONNECT_FCS: {
std::string raw = m_dtmf.getReflector();
std::string id = "FCS00";
std::string idShort = "FCS";
@ -730,18 +730,18 @@ void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt)
return;
}
if (m_linkType == LINK_YSF) {
if (m_linkType == LINK_TYPE::YSF) {
m_wiresX->processDisconnect();
m_ysfNetwork->writeUnlink(3U);
m_ysfNetwork->clearDestination();
}
if (m_linkType == LINK_FCS)
if (m_linkType == LINK_TYPE::FCS)
m_fcsNetwork->writeUnlink(3U);
m_current.clear();
m_inactivityTimer.stop();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
LogMessage("Connect via DTMF to %s has been requested by %10.10s", id.c_str(), buffer + 14U);
@ -750,14 +750,14 @@ void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt)
m_current = id;
m_inactivityTimer.start();
m_lostTimer.start();
m_linkType = LINK_FCS;
m_linkType = LINK_TYPE::FCS;
} else {
LogMessage("Unknown reflector - %s", id.c_str());
}
}
break;
case WXS_DISCONNECT:
if (m_linkType == LINK_YSF) {
case WX_STATUS::DISCONNECT:
if (m_linkType == LINK_TYPE::YSF) {
m_wiresX->processDisconnect();
LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U);
@ -768,9 +768,9 @@ void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt)
m_current.clear();
m_inactivityTimer.start();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
}
if (m_linkType == LINK_FCS) {
if (m_linkType == LINK_TYPE::FCS) {
LogMessage("Disconnect via DTMF has been requested by %10.10s", buffer + 14U);
m_fcsNetwork->writeUnlink(3U);
@ -779,7 +779,7 @@ void CYSFGateway::processDTMF(unsigned char* buffer, unsigned char dt)
m_current.clear();
m_inactivityTimer.start();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
}
break;
default:
@ -840,11 +840,11 @@ std::string CYSFGateway::calculateLocator()
void CYSFGateway::startupLinking()
{
if (!m_startup.empty()) {
if (m_startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != NULL) {
if (m_startup.substr(0U, 3U) == "FCS" && m_fcsNetwork != nullptr) {
m_current.clear();
m_inactivityTimer.stop();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
bool ok = m_fcsNetwork->writeLink(m_startup);
m_fcsNetwork->setOptions(m_options);
@ -855,18 +855,18 @@ void CYSFGateway::startupLinking()
m_current = m_startup;
m_inactivityTimer.start();
m_lostTimer.start();
m_linkType = LINK_FCS;
m_linkType = LINK_TYPE::FCS;
} else {
LogMessage("Unknown reflector - %s", m_startup.c_str());
}
} else if (m_ysfNetwork != NULL) {
} else if (m_ysfNetwork != nullptr) {
m_current.clear();
m_inactivityTimer.stop();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
CYSFReflector* reflector = m_reflectors->findByName(m_startup);
if (reflector != NULL) {
if (reflector != nullptr) {
LogMessage("Automatic (re-)connection to %5.5s - \"%s\"", reflector->m_id.c_str(), reflector->m_name.c_str());
m_ysfNetwork->setOptions(m_options);
@ -879,7 +879,7 @@ void CYSFGateway::startupLinking()
m_current = m_startup;
m_inactivityTimer.start();
m_lostTimer.start();
m_linkType = LINK_YSF;
m_linkType = LINK_TYPE::YSF;
}
}
}
@ -890,20 +890,20 @@ void CYSFGateway::startupLinking()
void CYSFGateway::readFCSRoomsFile(const std::string& filename)
{
FILE* fp = ::fopen(filename.c_str(), "rt");
if (fp == NULL)
if (fp == nullptr)
return;
unsigned int count = 0U;
char buffer[200U];
while (::fgets(buffer, 200, fp) != NULL) {
while (::fgets(buffer, 200, fp) != nullptr) {
if (buffer[0U] == '#')
continue;
char* p1 = ::strtok(buffer, ";");
char* p2 = ::strtok(NULL, ";");
char* p2 = ::strtok(nullptr, ";");
if (p1 != NULL && p2 != NULL) {
if (p1 != nullptr && p2 != nullptr) {
m_wiresX->addFCSRoom(p1, p2);
count++;
}
@ -928,15 +928,15 @@ void CYSFGateway::processRemoteCommands()
// Left trim
id.erase(id.begin(), std::find_if(id.begin(), id.end(), [](unsigned char ch) { return !std::isspace(ch); }));
CYSFReflector* reflector = m_reflectors->findById(id);
if (reflector == NULL)
if (reflector == nullptr)
reflector = m_reflectors->findByName(id);
if (reflector != NULL) {
if (reflector != nullptr) {
m_wiresX->processConnect(reflector);
if (m_linkType == LINK_YSF)
if (m_linkType == LINK_TYPE::YSF)
m_ysfNetwork->writeUnlink(3U);
if (m_linkType == LINK_FCS) {
if (m_linkType == LINK_TYPE::FCS) {
m_fcsNetwork->writeUnlink(3U);
m_fcsNetwork->clearDestination();
}
@ -949,7 +949,7 @@ void CYSFGateway::processRemoteCommands()
m_current = id;
m_inactivityTimer.start();
m_lostTimer.start();
m_linkType = LINK_YSF;
m_linkType = LINK_TYPE::YSF;
} else {
LogWarning("Invalid YSF reflector id/name - \"%s\"", id.c_str());
return;
@ -970,18 +970,18 @@ void CYSFGateway::processRemoteCommands()
return;
}
if (m_linkType == LINK_YSF) {
if (m_linkType == LINK_TYPE::YSF) {
m_wiresX->processDisconnect();
m_ysfNetwork->writeUnlink(3U);
m_ysfNetwork->clearDestination();
}
if (m_linkType == LINK_FCS)
if (m_linkType == LINK_TYPE::FCS)
m_fcsNetwork->writeUnlink(3U);
m_current.clear();
m_inactivityTimer.stop();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
LogMessage("Connect by remote command to %s", id.c_str());
@ -990,12 +990,12 @@ void CYSFGateway::processRemoteCommands()
m_current = id;
m_inactivityTimer.start();
m_lostTimer.start();
m_linkType = LINK_FCS;
m_linkType = LINK_TYPE::FCS;
} else {
LogMessage("Unknown reflector - %s", id.c_str());
}
} else if (::memcmp(buffer + 0U, "UnLink", 6U) == 0) {
if (m_linkType == LINK_YSF) {
if (m_linkType == LINK_TYPE::YSF) {
m_wiresX->processDisconnect();
LogMessage("Disconnect by remote command");
@ -1006,9 +1006,9 @@ void CYSFGateway::processRemoteCommands()
m_current.clear();
m_inactivityTimer.stop();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
}
if (m_linkType == LINK_FCS) {
if (m_linkType == LINK_TYPE::FCS) {
LogMessage("Disconnect by remote command");
m_fcsNetwork->writeUnlink(3U);
@ -1017,13 +1017,13 @@ void CYSFGateway::processRemoteCommands()
m_current.clear();
m_inactivityTimer.stop();
m_lostTimer.stop();
m_linkType = LINK_NONE;
m_linkType = LINK_TYPE::NONE;
}
} else if (::memcmp(buffer + 0U, "status", 6U) == 0) {
std::string state = std::string("ysf:") + (((m_ysfNetwork == NULL) && (m_fcsNetwork == NULL)) ? "n/a" : ((m_linkType != LINK_NONE) ? "conn" : "disc"));
std::string state = std::string("ysf:") + (((m_ysfNetwork == nullptr) && (m_fcsNetwork == nullptr)) ? "n/a" : ((m_linkType != LINK_TYPE::NONE) ? "conn" : "disc"));
m_remoteSocket->write((unsigned char*)state.c_str(), (unsigned int)state.length(), addr, addrLen);
} else if (::memcmp(buffer + 0U, "host", 4U) == 0) {
std::string ref = ((((m_ysfNetwork == NULL) && (m_fcsNetwork == NULL)) || (m_linkType == LINK_NONE)) ? "NONE" : m_current);
std::string ref = ((((m_ysfNetwork == nullptr) && (m_fcsNetwork == nullptr)) || (m_linkType == LINK_TYPE::NONE)) ? "NONE" : m_current);
std::string host = std::string("ysf:\"") + ref + "\"";
m_remoteSocket->write((unsigned char*)host.c_str(), (unsigned int)host.length(), addr, addrLen);
} else {

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018,2020,2025 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
@ -32,10 +32,10 @@
#include <string>
enum LINK_TYPE {
LINK_NONE,
LINK_YSF,
LINK_FCS
enum class LINK_TYPE {
NONE,
YSF,
FCS
};
class CYSFGateway

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2014,2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2014,2016,2017,2018,2020,2025 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
@ -32,10 +32,10 @@ m_socket(address, port),
m_debug(debug),
m_addr(),
m_addrLen(0U),
m_poll(NULL),
m_options(NULL),
m_poll(nullptr),
m_options(nullptr),
m_opt(),
m_unlink(NULL),
m_unlink(nullptr),
m_buffer(1000U, "YSF Network Buffer"),
m_pollTimer(1000U, 5U),
m_name(),
@ -65,10 +65,10 @@ m_socket(port),
m_debug(debug),
m_addr(),
m_addrLen(0U),
m_poll(NULL),
m_options(NULL),
m_poll(nullptr),
m_options(nullptr),
m_opt(),
m_unlink(NULL),
m_unlink(nullptr),
m_buffer(1000U, "YSF Network Buffer"),
m_pollTimer(1000U, 5U),
m_name(),
@ -140,7 +140,7 @@ void CYSFNetwork::clearDestination()
void CYSFNetwork::write(const unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
if (m_addrLen == 0U)
return;
@ -249,7 +249,7 @@ void CYSFNetwork::clock(unsigned int ms)
unsigned int CYSFNetwork::read(unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
if (m_buffer.isEmpty())
return 0U;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 Jonathan Naylor, G4KLX
* Copyright (C) 2016,2025 Jonathan Naylor, G4KLX
* Copyright (C) 2016 Mathias Weyland, HB9FRV
*
* This program is free software; you can redistribute it and/or modify
@ -86,8 +86,8 @@ CYSFPayload::~CYSFPayload()
bool CYSFPayload::readVDMode1Data(const unsigned char* data, unsigned char* dt)
{
assert(data != NULL);
assert(dt != NULL);
assert(data != nullptr);
assert(dt != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -131,8 +131,8 @@ bool CYSFPayload::readVDMode1Data(const unsigned char* data, unsigned char* dt)
bool CYSFPayload::readVDMode2Data(const unsigned char* data, unsigned char* dt)
{
assert(data != NULL);
assert(dt != NULL);
assert(data != nullptr);
assert(dt != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -176,8 +176,8 @@ bool CYSFPayload::readVDMode2Data(const unsigned char* data, unsigned char* dt)
bool CYSFPayload::readDataFRModeData1(const unsigned char* data, unsigned char* dt)
{
assert(data != NULL);
assert(dt != NULL);
assert(data != nullptr);
assert(dt != nullptr);
::memset(dt, ' ', 20U);
@ -223,8 +223,8 @@ bool CYSFPayload::readDataFRModeData1(const unsigned char* data, unsigned char*
bool CYSFPayload::readDataFRModeData2(const unsigned char* data, unsigned char* dt)
{
assert(data != NULL);
assert(dt != NULL);
assert(data != nullptr);
assert(dt != nullptr);
::memset(dt, ' ', 20U);
@ -270,8 +270,8 @@ bool CYSFPayload::readDataFRModeData2(const unsigned char* data, unsigned char*
void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* data)
{
assert(dt != NULL);
assert(data != NULL);
assert(dt != nullptr);
assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -287,7 +287,7 @@ void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* d
CYSFConvolution conv;
conv.encode(output, convolved, 180U);
unsigned char bytes[45U];
unsigned char bytes[45U] = { 0x00U };
unsigned int j = 0U;
for (unsigned int i = 0U; i < 180U; i++) {
unsigned int n = INTERLEAVE_TABLE_9_20[i];
@ -314,8 +314,8 @@ void CYSFPayload::writeDataFRModeData1(const unsigned char* dt, unsigned char* d
void CYSFPayload::writeDataFRModeData2(const unsigned char* dt, unsigned char* data)
{
assert(dt != NULL);
assert(data != NULL);
assert(dt != nullptr);
assert(data != nullptr);
data += YSF_SYNC_LENGTH_BYTES + YSF_FICH_LENGTH_BYTES;
@ -331,7 +331,7 @@ void CYSFPayload::writeDataFRModeData2(const unsigned char* dt, unsigned char* d
CYSFConvolution conv;
conv.encode(output, convolved, 180U);
unsigned char bytes[45U];
unsigned char bytes[45U] = { 0x00U };
unsigned int j = 0U;
for (unsigned int i = 0U; i < 180U; i++) {
unsigned int n = INTERLEAVE_TABLE_9_20[i];

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2021 by Jonathan Naylor G4KLX
* Copyright (C) 2016-2021,2025 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
@ -61,8 +61,8 @@ CYSFReflectors::~CYSFReflectors()
static bool refComparison(const CYSFReflector* r1, const CYSFReflector* r2)
{
assert(r1 != NULL);
assert(r2 != NULL);
assert(r1 != nullptr);
assert(r2 != nullptr);
std::string name1 = r1->m_name;
std::string name2 = r2->m_name;
@ -113,20 +113,20 @@ bool CYSFReflectors::load()
m_newReflectors.clear();
FILE* fp = ::fopen(m_hostsFile.c_str(), "rt");
if (fp != NULL) {
if (fp != nullptr) {
char buffer[100U];
while (::fgets(buffer, 100U, fp) != NULL) {
while (::fgets(buffer, 100U, fp) != nullptr) {
if (buffer[0U] == '#')
continue;
char* p1 = ::strtok(buffer, ";\r\n");
char* p2 = ::strtok(NULL, ";\r\n");
char* p3 = ::strtok(NULL, ";\r\n");
char* p4 = ::strtok(NULL, ";\r\n");
char* p5 = ::strtok(NULL, ";\r\n");
char* p6 = ::strtok(NULL, "\r\n");
char* p2 = ::strtok(nullptr, ";\r\n");
char* p3 = ::strtok(nullptr, ";\r\n");
char* p4 = ::strtok(nullptr, ";\r\n");
char* p5 = ::strtok(nullptr, ";\r\n");
char* p6 = ::strtok(nullptr, "\r\n");
if (p1 != NULL && p2 != NULL && p3 != NULL && p4 != NULL && p5 != NULL && p6 != NULL) {
if (p1 != nullptr && p2 != nullptr && p3 != nullptr && p4 != nullptr && p5 != nullptr && p6 != nullptr) {
std::string host = std::string(p4);
unsigned short port = (unsigned short)::atoi(p5);
@ -141,7 +141,7 @@ bool CYSFReflectors::load()
refl->m_addr = addr;
refl->m_addrLen = addrLen;
refl->m_count = std::string(p6);
refl->m_type = YT_YSF;
refl->m_type = YSF_TYPE::YSF;
refl->m_wiresX = (refl->m_name.compare(0, 3, "XLX") == 0);
refl->m_name.resize(16U, ' ');
@ -172,7 +172,7 @@ bool CYSFReflectors::load()
refl->m_addr = addr;
refl->m_addrLen = addrLen;
refl->m_count = "000";
refl->m_type = YT_YSF;
refl->m_type = YSF_TYPE::YSF;
refl->m_wiresX = false;
m_newReflectors.push_back(refl);
@ -195,7 +195,7 @@ bool CYSFReflectors::load()
refl->m_addr = addr;
refl->m_addrLen = addrLen;
refl->m_count = "000";
refl->m_type = YT_YSF;
refl->m_type = YSF_TYPE::YSF;
refl->m_wiresX = true;
m_newReflectors.push_back(refl);
@ -218,7 +218,7 @@ bool CYSFReflectors::load()
refl->m_addr = addr;
refl->m_addrLen = addrLen;
refl->m_count = "000";
refl->m_type = YT_YSF;
refl->m_type = YSF_TYPE::YSF;
refl->m_wiresX = true;
m_newReflectors.push_back(refl);
@ -241,7 +241,7 @@ bool CYSFReflectors::load()
refl->m_addr = addr;
refl->m_addrLen = addrLen;
refl->m_count = "000";
refl->m_type = YT_YSF;
refl->m_type = YSF_TYPE::YSF;
refl->m_wiresX = true;
m_newReflectors.push_back(refl);
@ -272,7 +272,7 @@ bool CYSFReflectors::load()
refl->m_desc = desc;
refl->m_addrLen = 0U;
refl->m_count = "000";
refl->m_type = YT_FCS;
refl->m_type = YSF_TYPE::FCS;
refl->m_wiresX = false;
refl->m_name.resize(16U, ' ');
@ -306,7 +306,7 @@ CYSFReflector* CYSFReflectors::findById(const std::string& id)
LogMessage("Trying to find non existent YSF reflector with an id of %s", id.c_str());
return NULL;
return nullptr;
}
bool CYSFReflectors::findById(unsigned int id) const
@ -337,7 +337,7 @@ CYSFReflector* CYSFReflectors::findByName(const std::string& name)
LogMessage("Trying to find non existent YSF reflector with a name of %s", name.c_str());
return NULL;
return nullptr;
}
std::vector<CYSFReflector*>& CYSFReflectors::current()

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2021 by Jonathan Naylor G4KLX
* Copyright (C) 2016-2021,2025 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
@ -25,9 +25,9 @@
#include <vector>
#include <string>
enum YSF_TYPE {
YT_YSF,
YT_FCS
enum class YSF_TYPE {
YSF,
FCS
};
class CYSFReflector {
@ -39,7 +39,7 @@ public:
m_count("000"),
m_addr(),
m_addrLen(0U),
m_type(YT_YSF),
m_type(YSF_TYPE::YSF),
m_wiresX(false)
{
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2014,2016,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2014,2016,2018,2020,2025 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
@ -47,7 +47,7 @@ bool CNetwork::write(const unsigned char* data)
if (m_addrLen == 0U)
return true;
assert(data != NULL);
assert(data != nullptr);
return m_socket.write(data, 155U, m_addr, m_addrLen);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2025 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,7 +23,7 @@
#include <cstring>
CParrot::CParrot(unsigned int timeout) :
m_data(NULL),
m_data(nullptr),
m_length(timeout * 1550U + 1000U),
m_used(0U),
m_ptr(0U)
@ -40,7 +40,7 @@ CParrot::~CParrot()
bool CParrot::write(const unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
if ((m_length - m_used) < 1000U)
return false;
@ -64,7 +64,7 @@ void CParrot::clear()
unsigned int CParrot::read(unsigned char* data)
{
assert(data != NULL);
assert(data != nullptr);
if (m_used == 0U)
return 0U;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2018,2025 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
@ -77,7 +77,7 @@ CStopWatch::~CStopWatch()
unsigned long long CStopWatch::time() const
{
struct timeval now;
::gettimeofday(&now, NULL);
::gettimeofday(&now, nullptr);
return now.tv_sec * 1000ULL + now.tv_usec / 1000ULL;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2025 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
@ -31,9 +31,9 @@ CThread::~CThread()
bool CThread::run()
{
m_handle = ::CreateThread(NULL, 0, &helper, this, 0, NULL);
m_handle = ::CreateThread(nullptr, 0, &helper, this, 0, nullptr);
return m_handle != NULL;
return m_handle != nullptr;
}
@ -74,13 +74,13 @@ CThread::~CThread()
bool CThread::run()
{
return ::pthread_create(&m_thread, NULL, helper, this) == 0;
return ::pthread_create(&m_thread, nullptr, helper, this) == 0;
}
void CThread::wait()
{
::pthread_join(m_thread, NULL);
::pthread_join(m_thread, nullptr);
}
@ -90,7 +90,7 @@ void* CThread::helper(void* arg)
p->entry();
return NULL;
return nullptr;
}
void CThread::sleep(unsigned int ms)

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2006-2016,2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2006-2016,2020,2024,2025 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
@ -94,7 +94,7 @@ int CUDPSocket::lookup(const std::string& hostname, unsigned short port, sockadd
/* Port is always digits, no needs to lookup service */
hints.ai_flags |= AI_NUMERICSERV;
int err = ::getaddrinfo(hostname.empty() ? NULL : hostname.c_str(), portstr.c_str(), &hints, &res);
int err = ::getaddrinfo(hostname.empty() ? nullptr : hostname.c_str(), portstr.c_str(), &hints, &res);
if (err != 0) {
sockaddr_in* paddr = (sockaddr_in*)&addr;
::memset(paddr, 0x00U, address_length = sizeof(sockaddr_in));
@ -119,7 +119,7 @@ bool CUDPSocket::match(const sockaddr_storage& addr1, const sockaddr_storage& ad
if (addr1.ss_family != addr2.ss_family)
return false;
if (type == IMT_ADDRESS_AND_PORT) {
if (type == IPMATCHTYPE::ADDRESS_AND_PORT) {
switch (addr1.ss_family) {
case AF_INET:
struct sockaddr_in *in_1, *in_2;
@ -134,7 +134,7 @@ bool CUDPSocket::match(const sockaddr_storage& addr1, const sockaddr_storage& ad
default:
return false;
}
} else if (type == IMT_ADDRESS_ONLY) {
} else if (type == IPMATCHTYPE::ADDRESS_ONLY) {
switch (addr1.ss_family) {
case AF_INET:
struct sockaddr_in *in_1, *in_2;
@ -233,7 +233,7 @@ bool CUDPSocket::open()
int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storage& address, unsigned int &addressLength)
{
assert(buffer != NULL);
assert(buffer != nullptr);
assert(length > 0U);
#if defined(_WIN32) || defined(_WIN64)
@ -301,7 +301,7 @@ int CUDPSocket::read(unsigned char* buffer, unsigned int length, sockaddr_storag
bool CUDPSocket::write(const unsigned char* buffer, unsigned int length, const sockaddr_storage& address, unsigned int addressLength)
{
assert(buffer != NULL);
assert(buffer != nullptr);
assert(length > 0U);
#if defined(_WIN32) || defined(_WIN64)
assert(m_fd != INVALID_SOCKET);

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2011,2013,2015,2016,2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2011,2013,2015,2016,2020,2024,2025 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
@ -35,9 +35,9 @@
#include <ws2tcpip.h>
#endif
enum IPMATCHTYPE {
IMT_ADDRESS_AND_PORT,
IMT_ADDRESS_ONLY
enum class IPMATCHTYPE {
ADDRESS_AND_PORT,
ADDRESS_ONLY
};
class CUDPSocket {
@ -60,7 +60,7 @@ public:
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& addressLength);
static int lookup(const std::string& hostName, unsigned short port, sockaddr_storage& address, unsigned int& addressLength, struct addrinfo& hints);
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IMT_ADDRESS_AND_PORT);
static bool match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type = IPMATCHTYPE::ADDRESS_AND_PORT);
static bool isNone(const sockaddr_storage& addr);

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2020,2024,2025 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
@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H
const char* VERSION = "20240831";
const char* VERSION = "20250319";
#endif