Skip to content

Commit

Permalink
make quiet be more quiet
Browse files Browse the repository at this point in the history
  • Loading branch information
wwiv committed Sep 1, 2018
1 parent 5d43aaf commit 9058798
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 71 deletions.
2 changes: 1 addition & 1 deletion bbs/netsup.cpp
Expand Up @@ -121,7 +121,7 @@ void cleanup_net() {
ss << " --process_instance=" << a()->instance_number();
ss << " ." << a()->net_num();
const auto networkc_cmd = ss.str();
LOG(INFO) << "Executing Network Command: '" << networkc_cmd << "'";
VLOG(1) << "Executing Network Command: '" << networkc_cmd << "'";
if (ExecuteExternalProgram(networkc_cmd, EFLAG_NETPROG) < 0) {
break;
}
Expand Down
2 changes: 1 addition & 1 deletion bbs/qwk.cpp
Expand Up @@ -97,7 +97,7 @@ void build_qwk_packet() {
bool save_conf = false;
SaveQScanPointers save_qscan;

remove_from_temp("*.*", QWK_DIRECTORY, 0);
remove_from_temp("*.*", QWK_DIRECTORY, false);

if ((a()->uconfsub[1].confnum != -1) && (okconf(a()->user()))) {
save_conf = true;
Expand Down
85 changes: 40 additions & 45 deletions bbs/utility.cpp
Expand Up @@ -24,33 +24,32 @@

#else
#include <utime.h>
#endif // WIN32
#endif // WIN32

#include <string>
#include <vector>

#include "bbs/bbsovl3.h"
#include "bbs/bbs.h"
#include "bbs/bbsovl3.h"
#include "bbs/bbsutl.h"
#include "bbs/bgetch.h"
#include "bbs/com.h"
#include "bbs/common.h"
#include "bbs/connect1.h"
#include "bbs/events.h"
#include "bbs/bbsutl.h"
#include "bbs/utility.h"
#include "bbs/wqscn.h"
#include "bbs/instmsg.h"
#include "bbs/datetime.h"
#include "bbs/events.h"
#include "bbs/input.h"
#include "bbs/instmsg.h"
#include "bbs/common.h"
#include "bbs/utility.h"
#include "bbs/workspace.h"
#include "bbs/wqscn.h"
#include "local_io/keycodes.h"
#include "local_io/wconstants.h"
#include "bbs/workspace.h"

#include "core/findfiles.h"
#include "core/os.h"
#include "core/stl.h"
#include "core/strings.h"
#include "core/findfiles.h"
#include "core/wwivassert.h"
#include "sdk/config.h"

Expand All @@ -61,9 +60,10 @@ using namespace wwiv::core;
using namespace wwiv::os;
using namespace wwiv::strings;

extern const unsigned char *translate_letters[];
extern const unsigned char* translate_letters[];

template<class _Ty> inline const _Ty& in_range(const _Ty& minValue, const _Ty& maxValue, const _Ty& value);
template <class _Ty>
inline const _Ty& in_range(const _Ty& minValue, const _Ty& maxValue, const _Ty& value);

/**
* Deletes files from a directory. This is meant to be used only in the temp
Expand All @@ -73,16 +73,16 @@ template<class _Ty> inline const _Ty& in_range(const _Ty& minValue, const _Ty& m
* @param pszDirectoryName Name of the directory to delete files from
* @param bPrintStatus Print out locally as files are deleted
*/
void remove_from_temp(const std::string& file_name, const std::string& directory_name, bool bPrintStatus) {
void remove_from_temp(const std::string& file_name, const std::string& directory_name,
bool bPrintStatus) {
const string filespec = StrCat(directory_name, stripfn(file_name.c_str()));
FindFiles ff(filespec, FindFilesType::any);
bout.nl();
for (const auto& f : ff) {
// We don't want to delete ".", "..".
if (bPrintStatus) {
std::clog << "Deleting TEMP file: " << directory_name << f.name << std::endl;
}
File::Remove(directory_name, f.name);
auto fullpath = FilePath(directory_name, f.name);
LOG_IF(bPrintStatus, INFO) << "Deleting TEMP file: '" << fullpath << "'";
File::Remove(fullpath);
}
}

Expand All @@ -92,9 +92,7 @@ void remove_from_temp(const std::string& file_name, const std::string& directory
*
* @return true if the user wants ANSI, false otherwise.
*/
bool okansi() {
return a()->user()->HasAnsi();
}
bool okansi() { return a()->user()->HasAnsi(); }

/**
* Should be called after a user is logged off, and will initialize
Expand All @@ -112,7 +110,7 @@ void frequent_init() {
read_qscn(1, a()->context().qsc, false);
set_language(a()->user()->GetLanguage());
reset_disable_conf();

// Output context
bout.reset();
bout.okskey(true);
Expand All @@ -122,7 +120,6 @@ void frequent_init() {
File::Remove(a()->dsz_logfile_name_);
}


/**
* Gets the current users upload/download ratio.
*/
Expand Down Expand Up @@ -159,8 +156,8 @@ long nsl() {
auto tpd = minutes(a()->effective_slrec().time_per_day);
auto extra_time = duration_cast<seconds>(a()->user()->extra_time() + a()->extratimecall());
auto tlc = tpl - tot + extra_time;
auto tlt = tpd - tot -
seconds(std::lround(a()->user()->GetTimeOnToday() + a()->user()->GetExtraTime()));
auto tlt = tpd - tot -
seconds(std::lround(a()->user()->GetTimeOnToday() + a()->user()->GetExtraTime()));

tlt = std::min(tlc, tlt);
rtn = in_range<int64_t>(0, 32767, duration_cast<seconds>(tlt).count());
Expand All @@ -170,13 +167,11 @@ long nsl() {
return static_cast<long>(in_range<int64_t>(0, 32767, rtn));
}

void send_net(net_header_rec* nh, std::vector<uint16_t> list, const std::string& text, const std::string& byname) {
void send_net(net_header_rec* nh, std::vector<uint16_t> list, const std::string& text,
const std::string& byname) {
WWIV_ASSERT(nh);

const string filename = StrCat(
a()->network_directory(),
"p1",
a()->network_extension());
const string filename = StrCat(a()->network_directory(), "p1", a()->network_extension());
File file(filename);
if (!file.Open(File::modeReadWrite | File::modeBinary | File::modeCreateFile)) {
return;
Expand Down Expand Up @@ -223,11 +218,11 @@ void giveup_timeslice() {
}
}

std::string stripfn(const std::string& file_name) {
std::string stripfn(const std::string& file_name) {
return std::string(stripfn(file_name.c_str()));
}

char *stripfn(const char *file_name) {
char* stripfn(const char* file_name) {
static char szStaticFileName[15];
char szTempFileName[MAX_PATH];

Expand Down Expand Up @@ -261,11 +256,9 @@ char *stripfn(const char *file_name) {
return szStaticFileName;
}

void stripfn_inplace(char *file_name) {
strcpy(file_name, stripfn(file_name));
}
void stripfn_inplace(char* file_name) { strcpy(file_name, stripfn(file_name)); }

char *get_wildlist(char *file_mask) {
char* get_wildlist(char* file_mask) {
int mark = 0;
char *pszPath, t;

Expand All @@ -276,7 +269,7 @@ char *get_wildlist(char *file_mask) {
bout << "No files found\r\n";
file_mask[0] = '\0';
return file_mask;
}
}
auto f = ff.begin();
bout.bprintf("%12.12s ", f->name.c_str());

Expand Down Expand Up @@ -328,7 +321,8 @@ char *get_wildlist(char *file_mask) {
return pszPath;
}

int side_menu(int *menu_pos, bool bNeedsRedraw, const vector<string>& menu_items, int xpos, int ypos, side_menu_colors * smc) {
int side_menu(int* menu_pos, bool bNeedsRedraw, const vector<string>& menu_items, int xpos,
int ypos, side_menu_colors* smc) {
static int positions[20], amount = 1;

WWIV_ASSERT(menu_pos);
Expand All @@ -340,7 +334,7 @@ int side_menu(int *menu_pos, bool bNeedsRedraw, const vector<string>& menu_items
amount = 1;
positions[0] = xpos;
for (const string& menu_item : menu_items) {
positions[amount] = positions[amount-1] + menu_item.length() + 2;
positions[amount] = positions[amount - 1] + menu_item.length() + 2;
++amount;
}

Expand Down Expand Up @@ -374,7 +368,8 @@ int side_menu(int *menu_pos, bool bNeedsRedraw, const vector<string>& menu_items
if (event < 128) {
int x = 0;
for (const string& menu_item : menu_items) {
if (event == to_upper_case<int>(menu_item[0]) || event == to_lower_case<int>(menu_item[0])) {
if (event == to_upper_case<int>(menu_item[0]) ||
event == to_lower_case<int>(menu_item[0])) {
bout.GotoXY(positions[*menu_pos], ypos);
bout.SystemColor(smc->normal_highlight);
bout.bputch(menu_items[*menu_pos][0]);
Expand Down Expand Up @@ -403,7 +398,7 @@ int side_menu(int *menu_pos, bool bNeedsRedraw, const vector<string>& menu_items
if (!*menu_pos) {
*menu_pos = menu_items.size() - 1;
} else {
--* menu_pos;
--*menu_pos;
}
bout.SystemColor(smc->current_highlight);
bout.GotoXY(positions[*menu_pos], ypos);
Expand All @@ -422,7 +417,7 @@ int side_menu(int *menu_pos, bool bNeedsRedraw, const vector<string>& menu_items
if (*menu_pos == static_cast<int>(menu_items.size() - 1)) {
*menu_pos = 0;
} else {
++* menu_pos;
++*menu_pos;
}
bout.SystemColor(smc->current_highlight);
bout.GotoXY(positions[*menu_pos], ypos);
Expand All @@ -440,11 +435,11 @@ int side_menu(int *menu_pos, bool bNeedsRedraw, const vector<string>& menu_items
}

bool okfsed() {
return okansi()
&& a()->user()->GetDefaultEditor() > 0
&& a()->user()->GetDefaultEditor() <= wwiv::stl::size_int(a()->editors);
return okansi() && a()->user()->GetDefaultEditor() > 0 &&
a()->user()->GetDefaultEditor() <= wwiv::stl::size_int(a()->editors);
}
template<class _Ty> inline const _Ty& in_range(const _Ty& minValue, const _Ty& maxValue, const _Ty& value) {
template <class _Ty>
inline const _Ty& in_range(const _Ty& minValue, const _Ty& maxValue, const _Ty& value) {
return std::max(std::min(maxValue, value), minValue);
}

Expand Down
4 changes: 2 additions & 2 deletions bbs/xinit.cpp
Expand Up @@ -768,8 +768,8 @@ void Application::InitializeBBS() {
frequent_init();
if (!user_already_on_) {
TempDisablePause disable_pause;
remove_from_temp("*.*", temp_directory(), true);
remove_from_temp("*.*", batch_directory(), true);
remove_from_temp("*.*", temp_directory(), false);
remove_from_temp("*.*", batch_directory(), false);
cleanup_net();
}

Expand Down
2 changes: 1 addition & 1 deletion networkb/binkp.cpp
Expand Up @@ -78,7 +78,7 @@ static int System(const string& bbsdir, const string& cmd) {
const auto path = FilePath(bbsdir, cmd);

auto err = system(path.c_str());
LOG(INFO) << " executed: '" << path << "' with an error code: " << err;
VLOG(1) << " executed: '" << path << "' with an error code: " << err;
return err;
}

Expand Down
43 changes: 22 additions & 21 deletions networkc/networkc.cpp
Expand Up @@ -32,26 +32,26 @@
#include "core/command_line.h"
#include "core/file.h"
#include "core/log.h"
#include "core/os.h"
#include "core/scope_exit.h"
#include "core/stl.h"
#include "core/semaphore_file.h"
#include "core/stl.h"
#include "core/strings.h"
#include "core/os.h"
#include "core/version.h"
#include "networkb/net_util.h"
#include "sdk/fido/fido_util.h"

#include "sdk/callout.h"
#include "sdk/connect.h"
#include "sdk/config.h"
#include "core/datetime.h"
#include "core/findfiles.h"
#include "sdk/callout.h"
#include "sdk/config.h"
#include "sdk/connect.h"
#include "sdk/fido/fido_address.h"
#include "sdk/filenames.h"
#include "sdk/net/packets.h"
#include "sdk/networks.h"
#include "sdk/status.h"
#include "sdk/subscribers.h"
#include "sdk/fido/fido_address.h"
#include "sdk/net/packets.h"

using std::cout;
using std::endl;
Expand All @@ -70,16 +70,15 @@ using namespace wwiv::os;
using namespace wwiv::sdk::fido;

static void ShowHelp(const CommandLine& cmdline) {
cout << cmdline.GetHelp()
<< ".#### Network number (as defined in wwivconfig)" << endl
<< endl;
cout << cmdline.GetHelp() << ".#### Network number (as defined in wwivconfig)" << endl
<< endl;

exit(1);
}

static void rename_bbs_instance_files(const string& dir, int instance_number) {
static void rename_bbs_instance_files(const string& dir, int instance_number, bool quiet) {
const auto pattern = StringPrintf("p*.%03d", instance_number);
LOG(INFO) << "Processing pending bbs instance files: " << pattern;
LOG_IF(!quiet, INFO) << "Processing pending bbs instance files: '" << pattern << "'";
FindFiles ff(dir, pattern, FindFilesType::files);
for (const auto& f : ff) {
rename_pend(dir, f.name, 'c');
Expand All @@ -92,9 +91,12 @@ string create_network_cmdline(const NetworkCommandLine& net_cmdline, char num, c
std::ostringstream ss;
ss << path;
ss << " --v=" << net_cmdline.cmdline().verbose();
if (net_cmdline.quiet()) {
ss << " --quiet";
}
ss << " --bbsdir=" << net_cmdline.cmdline().bbsdir();
ss << " --bindir=" << net_cmdline.cmdline().bindir();
ss << " --configdir="<< net_cmdline.cmdline().configdir();
ss << " --configdir=" << net_cmdline.cmdline().configdir();
ss << " --logdir=" << net_cmdline.cmdline().logdir();
ss << " ." << net_cmdline.network_number();
if (num == '3') {
Expand All @@ -107,7 +109,7 @@ string create_network_cmdline(const NetworkCommandLine& net_cmdline, char num, c
}

static int System(const string& cmd) {
LOG(INFO) << "Command: " << cmd;
VLOG(1) << "Command: " << cmd;
return system(cmd.c_str());
}

Expand Down Expand Up @@ -135,8 +137,8 @@ static bool need_network3(const string& dir, int network_version) {

if (network_version != wwiv_net_version) {
// always need network3 if the versions do not match.
LOG(INFO) << "Need to run network3 since current network_version: "
<< network_version << " != our network_version: " << wwiv_net_version;
LOG(INFO) << "Need to run network3 since current network_version: " << network_version
<< " != our network_version: " << wwiv_net_version;
return true;
}
File bbsdataNet(FilePath(dir, BBSDATA_NET));
Expand All @@ -147,12 +149,11 @@ static bool need_network3(const string& dir, int network_version) {
time_t bbsdata_time = bbsdataNet.last_write_time();
bbsdataNet.Close();

return checkup2(bbsdata_time, dir, BBSLIST_NET)
|| checkup2(bbsdata_time, dir, CONNECT_NET)
|| checkup2(bbsdata_time, dir, CALLOUT_NET);
return checkup2(bbsdata_time, dir, BBSLIST_NET) || checkup2(bbsdata_time, dir, CONNECT_NET) ||
checkup2(bbsdata_time, dir, CALLOUT_NET);
}

int networkc_main(const NetworkCommandLine & net_cmdline) {
int networkc_main(const NetworkCommandLine& net_cmdline) {
try {
const auto process_instance = net_cmdline.cmdline().iarg("process_instance");
const auto& net = net_cmdline.network();
Expand All @@ -167,7 +168,7 @@ int networkc_main(const NetworkCommandLine & net_cmdline) {
if (process_instance > 0) {
// We need to process pending bbs instance file, these are
// of the form p1.###. These will get renamed into p*.net
rename_bbs_instance_files(net.dir, process_instance);
rename_bbs_instance_files(net.dir, process_instance, net_cmdline.quiet());
}

// Pending files, call network1 to put them into s* or local.net.
Expand Down

0 comments on commit 9058798

Please sign in to comment.