Upgrade the C++ version.

This commit is contained in:
Jonathan Naylor 2025-03-18 13:52:17 +00:00
parent 8c6fa22730
commit dde4c01a45
15 changed files with 168 additions and 148 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018,2020,2024 by Jonathan Naylor G4KLX
* Copyright (C) 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
@ -146,11 +146,11 @@ int main(int argc, char** argv)
CDAPNETGateway::CDAPNETGateway(const std::string& configFile) :
m_conf(configFile),
m_dapnetNetwork(NULL),
m_pocsagNetwork(NULL),
m_dapnetNetwork(nullptr),
m_pocsagNetwork(nullptr),
m_queue(),
m_slotTimer(),
m_schedule(NULL),
m_schedule(nullptr),
m_allSlots(false),
m_currentSlot(0U),
m_sentCodewords(0U),
@ -208,7 +208,7 @@ int CDAPNETGateway::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;
}
@ -351,7 +351,7 @@ int CDAPNETGateway::run()
recover();
CPOCSAGMessage* message = m_dapnetNetwork->readMessage();
if (message != NULL) {
if (message != nullptr) {
bool found = true;
bool blackListRIC = false;
bool blacklistRegexmatch = false;
@ -419,7 +419,7 @@ int CDAPNETGateway::run()
if (slot != m_currentSlot) {
// LogDebug("Start of slot %u", slot);
m_currentSlot = slot;
if (m_schedule == NULL || m_currentSlot == 0U)
if (m_schedule == nullptr || m_currentSlot == 0U)
loadSchedule();
m_sentCodewords = 0U;
m_slotTimer.start();
@ -446,7 +446,7 @@ void CDAPNETGateway::sendMessages()
return;
// Do we have a schedule?
if (m_schedule == NULL)
if (m_schedule == nullptr)
return;
// Check to see if we're allowed to send within a slot.
@ -458,7 +458,7 @@ void CDAPNETGateway::sendMessages()
return;
CPOCSAGMessage* message = m_queue.back();
assert(message != NULL);
assert(message != nullptr);
// Special case, only test if slots are being used.
if (m_allSlots) {
@ -522,7 +522,7 @@ bool CDAPNETGateway::isTimeMessage(const CPOCSAGMessage* message) const
unsigned int CDAPNETGateway::calculateCodewords(const CPOCSAGMessage* message) const
{
assert(message != NULL);
assert(message != nullptr);
unsigned int len = 0U;
switch (message->m_functional) {
@ -551,7 +551,7 @@ unsigned int CDAPNETGateway::calculateCodewords(const CPOCSAGMessage* message) c
void CDAPNETGateway::loadSchedule()
{
bool* schedule = m_dapnetNetwork->readSchedule();
if (schedule == NULL)
if (schedule == nullptr)
return;
delete[] m_schedule;
@ -577,7 +577,7 @@ void CDAPNETGateway::loadSchedule()
bool CDAPNETGateway::sendMessage(CPOCSAGMessage* message) const
{
assert(message != NULL);
assert(message != nullptr);
bool ret = isTimeMessage(message);
if (ret && message->m_timeQueued.elapsed() >= MAX_TIME_TO_HOLD_TIME_MESSAGES) {