Skip to content

Commit

Permalink
rename net_networks_rec to Network.
Browse files Browse the repository at this point in the history
Add try_parse_nodelist to Network.
  • Loading branch information
wwiv committed Apr 1, 2021
1 parent ee8fdd2 commit 219c198
Show file tree
Hide file tree
Showing 72 changed files with 277 additions and 212 deletions.
8 changes: 4 additions & 4 deletions bbs/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,16 +1256,16 @@ const Instances& Application::instances() const {
return *instances_;
}

const wwiv::sdk::net::net_networks_rec& Application::current_net() const {
const static wwiv::sdk::net::net_networks_rec empty_rec{};
const Network& Application::current_net() const {
const static Network empty_rec(network_type_t::unknown, "(Unknown)");
if (nets_->empty()) {
return empty_rec;
}
return nets_->at(net_num());
}

wwiv::sdk::net::net_networks_rec& Application::mutable_current_net() {
static wwiv::sdk::net::net_networks_rec empty_rec{};
wwiv::sdk::net::Network& Application::mutable_current_net() {
static wwiv::sdk::net::Network empty_rec{};
if (nets_->empty()) {
return empty_rec;
}
Expand Down
6 changes: 3 additions & 3 deletions bbs/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class WWIVMessageApi;
} // namespace msgapi

namespace net {
struct net_networks_rec;
class Network;
}

} // namespace sdk
Expand Down Expand Up @@ -231,8 +231,8 @@ class Application final : public Runnable {
[[nodiscard]] const wwiv::sdk::subboard_t& current_sub() const;
[[nodiscard]] const wwiv::sdk::files::directory_t& current_dir() const;

[[nodiscard]] const wwiv::sdk::net::net_networks_rec& current_net() const;
[[nodiscard]] wwiv::sdk::net::net_networks_rec& mutable_current_net();
[[nodiscard]] const wwiv::sdk::net::Network& current_net() const;
[[nodiscard]] wwiv::sdk::net::Network& mutable_current_net();

[[nodiscard]] bool IsUseInternalZmodem() const { return internal_zmodem_; }
[[nodiscard]] bool IsUseInternalFsed() const;
Expand Down
7 changes: 3 additions & 4 deletions bbs/diredit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ static void showdirs() {
}
}

std::optional<net_networks_rec> select_network() {
std::map<int, net_networks_rec> nets;
std::optional<Network> select_network() {
std::map<int, Network> nets;
auto num = 0;
for (const auto& n : a()->nets().networks()) {
if (n.type == network_type_t::ftn) {
Expand Down Expand Up @@ -112,8 +112,7 @@ static void list_area_tags(const std::vector<wwiv::sdk::files::dir_area_t>& area
bout << "|#6(None)" << wwiv::endl;
return;
}
net_networks_rec empty{};
empty.name = "(Unknown)";
Network empty(network_type_t::unknown, "(Unknown)");

auto nn = 0;
auto first{true};
Expand Down
4 changes: 2 additions & 2 deletions bbs/netsup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void cleanup_net() {
a()->Cls();
}

static void do_callout(const net_networks_rec& net, int sn) {
static void do_callout(const Network& net, int sn) {
const Callout callout(net, a()->config()->max_backups());
Contact contact(net, false);
Binkp binkp(net.dir);
Expand Down Expand Up @@ -430,7 +430,7 @@ static std::string to_difftime_string(daten_t now, daten_t then) {
return fmt::format("{:<16}", s);
}

static void print_call(uint16_t sn, const net_networks_rec& net) {
static void print_call(uint16_t sn, const Network& net) {
static int color;
auto now = daten_t_now();

Expand Down
10 changes: 5 additions & 5 deletions bbs/readmail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ bool read_same_email(std::vector<tmpmailrec>& mloc, int mw, int rec, mailrec& m,
return mloc[rec].index != -1;
}

static void add_netsubscriber(const net_networks_rec& net, int network_number, int system_number) {
static void add_netsubscriber(const Network& net, int network_number, int system_number) {
if (!valid_system(system_number)) {
system_number = 0;
}
Expand Down Expand Up @@ -307,7 +307,7 @@ void delete_attachment(unsigned long daten, int forceit) {
}
}

static std::string from_name(const mailrec& m, const net_networks_rec& net, const slrec& sl, int nn) {
static std::string from_name(const mailrec& m, const Network& net, const slrec& sl, int nn) {
if (m.anony & anony_sender && (sl.ability & ability_read_email_anony) == 0) {
return ">UNKNOWN<";
}
Expand Down Expand Up @@ -343,14 +343,14 @@ static std::string from_name(const mailrec& m, const net_networks_rec& net, cons
return fmt::format("#{} @{} ({})", m.fromuser, m.fromsys, system_name);
}

static std::tuple<net_networks_rec, int> network_and_num(const mailrec& m) {
net_networks_rec net{};
static std::tuple<Network, int> network_and_num(const mailrec& m) {
Network net{};
auto nn = network_number_from(&m);
if (nn <= a()->nets().size()) {
net = a()->nets()[nn];
} else {
net.sysnum = static_cast<uint16_t>(-1);
net.type = network_type_t::wwivnet;
net.type = network_type_t::unknown;
net.name = fmt::format("<deleted network #{}>", nn);
nn = 255;
}
Expand Down
2 changes: 1 addition & 1 deletion bbs/shortmsg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static void SendLocalShortMessage(int usernum, const std::string& messageText) {
}

static void SendRemoteShortMessage(int user_num, int system_num, const std::string& text,
const net_networks_rec& net) {
const Network& net) {
net_header_rec nh{};
nh.tosys = static_cast<uint16_t>(system_num);
nh.touser = static_cast<uint16_t>(user_num);
Expand Down
6 changes: 3 additions & 3 deletions bbs/shortmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace sdk {
class User;

namespace net {
struct net_networks_rec;
class Network;
}
}
}
Expand All @@ -34,7 +34,7 @@ struct net_networks_rec;
class ssm {
public:
explicit ssm(int un) : ssm(un, 0, nullptr) {}
ssm(int un, int sn, const wwiv::sdk::net::net_networks_rec* net) : un_(un), sn_(sn), net_(net) {}
ssm(int un, int sn, const wwiv::sdk::net::Network* net) : un_(un), sn_(sn), net_(net) {}
~ssm();

template <typename T> ssm& operator<<(T const& value) {
Expand All @@ -46,7 +46,7 @@ class ssm {
std::ostringstream stream_;
const int un_;
const int sn_{0};
const wwiv::sdk::net::net_networks_rec* net_;
const wwiv::sdk::net::Network* net_;
};

void rsm(int nUserNum, wwiv::sdk::User* pUser, bool bAskToSaveMsgs);
Expand Down
6 changes: 3 additions & 3 deletions bbs/subreq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static void maybe_netmail(subboard_network_data_t* ni, bool bAdd) {
}
}

static bool display_sub_categories(const net_networks_rec& net) {
static bool display_sub_categories(const Network& net) {
if (!net.sysnum) {
return false;
}
Expand All @@ -79,7 +79,7 @@ static bool display_sub_categories(const net_networks_rec& net) {
}

static void sub_req(uint16_t main_type, int tosys, const std::string& stype,
const net_networks_rec& net) {
const Network& net) {
net_header_rec nh{};

nh.tosys = static_cast<uint16_t>(tosys);
Expand Down Expand Up @@ -113,7 +113,7 @@ static constexpr short OPTION_GATED = 0x0004;
static constexpr short OPTION_NETVAL = 0x0008;
static constexpr short OPTION_ANSI = 0x0010;

static int find_hostfor(const net_networks_rec& net, const std::string& type, short* ui,
static int find_hostfor(const Network& net, const std::string& type, short* ui,
char* description, short* opt) {
int rc = 0;

Expand Down
4 changes: 2 additions & 2 deletions bbs/sysopf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ enum class net_search_type_t {
NET_SEARCH_AC, NET_SEARCH_GC, NET_SEARCH_NC, NET_SEARCH_PHSUBSTR,
NET_SEARCH_NOCONNECT, NET_SEARCH_ALL };

bool print_wwivnet_net_listing(const net_networks_rec& net) {
bool print_wwivnet_net_listing(const Network& net) {
int gn = 0;
char s2[101], bbstype;

Expand Down Expand Up @@ -565,7 +565,7 @@ bool print_wwivnet_net_listing(const net_networks_rec& net) {
return false;
}

static bool print_ftn_net_listing(net_networks_rec& net) {
static bool print_ftn_net_listing(Network& net) {
if (!try_load_nodelist(net)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion bbs/test/SIZE.DOS
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ sizeof (filestatusrec) = 23
sizeof (phonerec) = 15
sizeof (ext_desc_rec) = 17
sizeof (instancerec) = 100
sizeof (net_networks_rec) = 100
sizeof (Network) = 100
12 changes: 5 additions & 7 deletions binkp/binkp_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ BinkConfig::BinkConfig(const std::string& callout_network_name, const Config& co
gfiles_directory_ = config.gfilesdir();

if (networks.contains(callout_network_name)) {
const net_networks_rec& net = networks[callout_network_name];
const Network& net = networks[callout_network_name];
if (net.type == network_type_t::wwivnet) {
callout_wwivnet_node_ = net.sysnum;
if (callout_wwivnet_node_ == 0) {
Expand All @@ -74,11 +74,11 @@ BinkConfig::BinkConfig(const std::string& callout_network_name, const Config& co
}
}

const net_networks_rec& BinkConfig::network(const std::string& network_name) const {
const Network& BinkConfig::network(const std::string& network_name) const {
return networks_[network_name];
}

const net_networks_rec& BinkConfig::callout_network() const {
const Network& BinkConfig::callout_network() const {
return network(callout_network_name_);
}

Expand All @@ -96,11 +96,9 @@ std::string BinkConfig::receive_dir(const std::string& network_name) const {
return dir;
}

static net_networks_rec test_net(const std::string& network_dir) {
net_networks_rec net{};
static Network test_net(const std::string& network_dir) {
Network net(network_type_t::wwivnet, "WWIVnet");
net.sysnum = 1;
net.name = "wwivnet";
net.type = network_type_t::wwivnet;
net.dir = network_dir;
return net;
}
Expand Down
4 changes: 2 additions & 2 deletions binkp/binkp_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class BinkConfig final {
/** Get the directory to receive files into for network named network_name */
[[nodiscard]] std::string receive_dir(const std::string& network_name) const;

[[nodiscard]] const sdk::net::net_networks_rec& network(const std::string& network_name) const;
[[nodiscard]] const sdk::net::net_networks_rec& callout_network() const;
[[nodiscard]] const sdk::net::Network& network(const std::string& network_name) const;
[[nodiscard]] const sdk::net::Network& callout_network() const;
[[nodiscard]] const wwiv::sdk::Networks& networks() { return networks_; }
/*
* Key/Value mapping of domain to callout class.
Expand Down
2 changes: 1 addition & 1 deletion binkp/file_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ std::vector<TransferFile*> FileManager::CreateFtnTransferFileList(const std::str
return result;
}

FileManager::FileManager(const wwiv::sdk::Config& config, const net_networks_rec& net,
FileManager::FileManager(const wwiv::sdk::Config& config, const Network& net,
const std::string& receive_dir)
: config_(config), net_(net), dirs_(config.root_directory(), net, receive_dir) {
const auto dir = dirs_.receive_dir();
Expand Down
4 changes: 2 additions & 2 deletions binkp/file_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace wwiv::net {

class FileManager final {
public:
FileManager(const wwiv::sdk::Config& config, const sdk::net::net_networks_rec& net,
FileManager(const wwiv::sdk::Config& config, const sdk::net::Network& net,
const std::string& receive_dir);
~FileManager() = default;

Expand All @@ -47,7 +47,7 @@ class FileManager final {
[[nodiscard]] std::vector<TransferFile*> CreateFtnTransferFileList(const std::string& address) const;

const wwiv::sdk::Config& config_;
const sdk::net::net_networks_rec net_;
const sdk::net::Network net_;
const wwiv::sdk::fido::FtnDirectories dirs_;
const std::string network_directory_;
std::vector<std::string> received_files_;
Expand Down
4 changes: 2 additions & 2 deletions binkp/remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ uint16_t wwivnet_node_number_from_ftn_address(const std::string& address) {
return WWIVNET_NO_NODE;
}

std::string fixup_address(const std::string& addr, const net_networks_rec& net, const std::string& default_domain) {
std::string fixup_address(const std::string& addr, const Network& net, const std::string& default_domain) {
if (auto o = sdk::fido::try_parse_fidoaddr(addr)) {
if (o->has_domain()) {
return o->as_string(true, true);
Expand Down Expand Up @@ -182,7 +182,7 @@ void Remote::set_domain(const std::string& d) {
}
}

const net_networks_rec& Remote::network() const {
const Network& Remote::network() const {
return config_->network(network_name());
}

Expand Down
2 changes: 1 addition & 1 deletion binkp/remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Remote final {
[[nodiscard]] std::string network_name() const;
[[nodiscard]] std::string domain() const;
void set_domain(const std::string& d);
[[nodiscard]] const sdk::net::net_networks_rec& network() const;
[[nodiscard]] const sdk::net::Network& network() const;

[[nodiscard]] int wwivnet_node() const { return wwivnet_node_; }
void set_wwivnet_node(int n, const std::string& domain) { wwivnet_node_ = static_cast<uint16_t>(n); domain_ = domain; }
Expand Down
5 changes: 1 addition & 4 deletions binkp_test/binkp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ class BinkTest : public testing::Test {
wwiv_config_.sysopname = "Test Sysop";
wwiv::sdk::Config config(File::current_directory(), wwiv_config_);
config.gfilesdir(gfiles_dir);
net_networks_rec net{};
Network net(network_type_t::wwivnet, "Dummy Network");
net.dir = network_dir;
net.name = "Dummy Network";
net.type = network_type_t::wwivnet;
net.sysnum = 0;
binkp_config_ = std::make_unique<BinkConfig>(ORIGINATING_ADDRESS, config, network_dir);
auto dummy_callout = std::make_unique<Callout>(net, 0);
BinkP::received_transfer_file_factory_t null_factory = [](const std::string&, const std::string& filename) {
Expand Down
2 changes: 1 addition & 1 deletion binkp_test/file_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class FileManagerTest : public testing::Test {
}

FileHelper file_helper_;
net_networks_rec net{};
Network net{};
std::unique_ptr<FileManager> fm;
std::unique_ptr<wwiv::sdk::Config> config_;
std::unique_ptr<BinkConfig> bink_config_;
Expand Down
4 changes: 2 additions & 2 deletions net_core/net_cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class NetworkCommandLine {
[[nodiscard]] const sdk::Networks& networks() const noexcept { return *networks_; }
[[nodiscard]] std::string network_name() const noexcept { return network_name_; }
[[nodiscard]] int network_number() const noexcept { return network_number_; }
[[nodiscard]] const sdk::net::net_networks_rec& network() const noexcept { return network_; }
[[nodiscard]] const sdk::net::Network& network() const noexcept { return network_; }
[[nodiscard]] const core::CommandLine& cmdline() const noexcept { return cmdline_; }
[[nodiscard]] char net_cmd() const noexcept { return net_cmd_; }
[[nodiscard]] std::filesystem::path semaphore_path() const noexcept;
Expand All @@ -63,7 +63,7 @@ class NetworkCommandLine {
std::string network_name_;
int network_number_{0};
bool initialized_{true};
sdk::net::net_networks_rec network_;
sdk::net::Network network_;
core::CommandLine& cmdline_;
char net_cmd_;
};
Expand Down
2 changes: 1 addition & 1 deletion net_core/netdat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ char NetDat::NetDatMsgType(netdat_msgtype_t t) {
}

NetDat::NetDat(std::filesystem::path gfiles, std::filesystem::path logs,
const net_networks_rec& net, char net_cmd, Clock& clock)
const Network& net, char net_cmd, Clock& clock)
: gfiles_(std::move(gfiles)), logs_(std::move(logs)), net_(net), net_cmd_(net_cmd),
clock_(clock) {
rollover();
Expand Down
6 changes: 3 additions & 3 deletions net_core/netdat.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


namespace wwiv::sdk::net {
struct net_networks_rec;
class Network;
}

namespace wwiv::net {
Expand Down Expand Up @@ -56,7 +56,7 @@ class NetDat final {
static char NetDatMsgType(netdat_msgtype_t t);

NetDat(std::filesystem::path gfiles, std::filesystem::path logs,
const sdk::net::net_networks_rec& net, char net_cmd, core::Clock& clock);
const sdk::net::Network& net, char net_cmd, core::Clock& clock);

~NetDat();

Expand All @@ -77,7 +77,7 @@ class NetDat final {

std::filesystem::path gfiles_;
std::filesystem::path logs_;
const sdk::net::net_networks_rec& net_;
const sdk::net::Network& net_;
const char net_cmd_;
core::Clock& clock_;
std::unique_ptr<TextFile> file_;
Expand Down
2 changes: 1 addition & 1 deletion net_core_test/netdat_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class NetDatTest: public testing::Test {
std::filesystem::path gfiles_;
std::filesystem::path logs_;
tm t_{};
net_networks_rec net{};
Network net{};
};

TEST_F(NetDatTest, Smoke) {
Expand Down
2 changes: 1 addition & 1 deletion network1/network1.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Network1 final {
const wwiv::net::NetworkCommandLine& net_cmdline_;
const wwiv::sdk::BbsListNet& bbslist_;
wwiv::core::Clock& clock_;
const wwiv::sdk::net::net_networks_rec& net_;
const wwiv::sdk::net::Network& net_;
wwiv::net::NetDat netdat_;
};

Expand Down
Loading

0 comments on commit 219c198

Please sign in to comment.