1
0
Fork 0

Add an optional explicit Id.

ycs232-kbc
Jonathan Naylor 5 years ago
parent b058539a71
commit 60e70fa554

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2020 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,6 +37,7 @@ enum SECTION {
CConf::CConf(const std::string& file) :
m_file(file),
m_daemon(false),
m_id(0U),
m_name(),
m_description(),
m_logDisplayLevel(0U),
@ -91,7 +92,9 @@ bool CConf::read()
if (::strcmp(key, "Daemon") == 0)
m_daemon = ::atoi(value) == 1;
} else if (section == SECTION_INFO) {
if (::strcmp(key, "Name") == 0)
if (::strcmp(key, "Id") == 0)
m_id = (unsigned int)::atoi(value);
else if (::strcmp(key, "Name") == 0)
m_name = value;
else if (::strcmp(key, "Description") == 0)
m_description = value;
@ -122,6 +125,11 @@ bool CConf::getDaemon() const
return m_daemon;
}
unsigned int CConf::getId() const
{
return m_id;
}
std::string CConf::getName() const
{
return m_name;

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2020 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,6 +34,7 @@ public:
bool getDaemon() const;
// The Info section
unsigned int getId() const;
std::string getName() const;
std::string getDescription() const;
@ -51,6 +52,7 @@ private:
std::string m_file;
bool m_daemon;
unsigned int m_id;
std::string m_name;
std::string m_description;

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2014,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2014,2016,2020 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
@ -24,8 +24,9 @@
#include <cassert>
#include <cstring>
CNetwork::CNetwork(unsigned int port, const std::string& name, const std::string& description, bool debug) :
CNetwork::CNetwork(unsigned int port, unsigned int id, const std::string& name, const std::string& description, bool debug) :
m_socket(port),
m_id(id),
m_name(name),
m_description(description),
m_callsign(),
@ -112,18 +113,20 @@ void CNetwork::setCount(unsigned int count)
if (count > 999U)
count = 999U;
unsigned int hash = 0U;
unsigned int hash = m_id;
for (unsigned int i = 0U; i < m_name.size(); i++) {
hash += m_name.at(i);
hash += (hash << 10);
hash ^= (hash >> 6);
}
if (hash == 0U) {
for (unsigned int i = 0U; i < m_name.size(); i++) {
hash += m_name.at(i);
hash += (hash << 10);
hash ^= (hash >> 6);
}
// Final avalanche
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
// Final avalanche
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
}
::sprintf((char*)m_status, "YSFS%05u%16.16s%14.14s%03u", hash % 100000U, m_name.c_str(), m_description.c_str(), count);
}

@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2014,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2009-2014,2016,2020 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,7 +28,7 @@
class CNetwork {
public:
CNetwork(unsigned int port, const std::string& name, const std::string& description, bool debug);
CNetwork(unsigned int port, unsigned int id, const std::string& name, const std::string& description, bool debug);
~CNetwork();
bool open();
@ -44,6 +44,7 @@ public:
private:
CUDPSocket m_socket;
unsigned int m_id;
std::string m_name;
std::string m_description;
std::string m_callsign;

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2020 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 = "20161021";
const char* VERSION = "20200429";
#endif

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2018 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2018,2020 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
@ -162,7 +162,7 @@ void CYSFReflector::run()
}
#endif
CNetwork network(m_conf.getNetworkPort(), m_conf.getName(), m_conf.getDescription(), m_conf.getNetworkDebug());
CNetwork network(m_conf.getNetworkPort(), m_conf.getId(), m_conf.getName(), m_conf.getDescription(), m_conf.getNetworkDebug());
ret = network.open();
if (!ret) {

@ -4,6 +4,7 @@ Daemon=1
[Info]
# Remember to register your YSFReflector at:
# https://register.ysfreflector.de
# Id=5 digits only
Name=16 characters max
Description=14 characters max

Loading…
Cancel
Save