fix usage of m_pname and rename to m_exename

This commit is contained in:
walker0643 2018-05-12 17:32:26 -04:00
parent f299558cdf
commit f4301a7618
7 changed files with 18 additions and 28 deletions

View File

@ -79,18 +79,9 @@ App::~App()
void
App::version()
{
char buffer[500];
sprintf(
buffer,
"%s %s, protocol version %d.%d\n%s",
argsBase().m_pname,
kVersion,
kProtocolMajorVersion,
kProtocolMinorVersion,
kCopyright
);
std::cout << argsBase().m_exename << " " << kVersion << ", protocol version " << kProtocolMajorVersion << "." << kProtocolMinorVersion << std::endl;
std::cout << kCopyright << std::endl;
std::cout << buffer << std::endl;
}
int
@ -178,7 +169,7 @@ App::initApp(int argc, const char** argv)
// set log filter
if (!CLOG->setFilter(argsBase().m_logFilter)) {
LOG((CLOG_PRINT "%s: unrecognized log level `%s'" BYE,
argsBase().m_pname, argsBase().m_logFilter, argsBase().m_pname));
argsBase().m_exename.c_str(), argsBase().m_logFilter, argsBase().m_exename.c_str()));
m_bye(kExitArgs);
}
loggingFilterWarning();

View File

@ -62,7 +62,7 @@ ArgParser::parseServerArgs(ServerArgs& args, int argc, const char* const* argv)
args.m_configFile = argv[++i];
}
else {
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname));
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_exename.c_str(), argv[i], args.m_exename.c_str()));
return false;
}
}
@ -107,7 +107,7 @@ ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv)
return true;
}
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_pname, argv[i], args.m_pname));
LOG((CLOG_PRINT "%s: unrecognized option `%s'" BYE, args.m_exename.c_str(), argv[i], args.m_exename.c_str()));
return false;
}
}
@ -118,7 +118,7 @@ ArgParser::parseClientArgs(ClientArgs& args, int argc, const char* const* argv)
// exactly one non-option argument (server-address)
if (i == argc) {
LOG((CLOG_PRINT "%s: a server address or name is required" BYE,
args.m_pname, args.m_pname));
args.m_exename.c_str(), args.m_exename.c_str()));
return false;
}
@ -313,7 +313,7 @@ ArgParser::isArg(
// match. check args left.
if (argi + minRequiredParameters >= argc) {
LOG((CLOG_PRINT "%s: missing arguments for `%s'" BYE,
argsBase().m_pname, argv[argi], argsBase().m_pname));
argsBase().m_exename.c_str(), argv[argi], argsBase().m_exename.c_str()));
argsBase().m_shouldExit = true;
return false;
}
@ -456,7 +456,7 @@ void
ArgParser::updateCommonArgs(const char* const* argv)
{
argsBase().m_name = ARCH->getHostName();
argsBase().m_pname = PathUtilities::basename(argv[0]).c_str();
argsBase().m_exename = PathUtilities::basename(argv[0]);
}
bool
@ -470,7 +470,7 @@ ArgParser::checkUnexpectedArgs()
LOG((CLOG_ERR
"the --daemon argument is not supported on windows. "
"instead, install %s as a service (--service install)",
argsBase().m_pname));
argsBase().m_exename.c_str()));
return true;
}
#endif

View File

@ -33,7 +33,6 @@ m_disableXInitThreads(false),
m_backend(false),
m_restartable(true),
m_noHooks(false),
m_pname(NULL),
m_logFilter(NULL),
m_logFile(NULL),
m_display(NULL),

View File

@ -30,7 +30,7 @@ public:
bool m_backend;
bool m_restartable;
bool m_noHooks;
const char* m_pname;
std::string m_exename;
const char* m_logFilter;
const char* m_logFile;
const char* m_display;

View File

@ -95,7 +95,7 @@ ClientApp::parseArgs(int argc, const char* const* argv)
// Priddy.
if (!args().m_restartable || e.getError() == XSocketAddress::kBadPort) {
LOG((CLOG_PRINT "%s: %s" BYE,
args().m_pname, e.what(), args().m_pname));
args().m_exename.c_str(), e.what(), args().m_exename.c_str()));
m_bye(kExitFailed);
}
}
@ -120,7 +120,7 @@ ClientApp::help()
std::ostringstream buffer;
buffer << "Start the barrier client and connect to a remote server component." << std::endl
<< std::endl
<< "Usage: " << args().m_pname << " [--yscroll <delta>]" << WINAPI_ARG << HELP_SYS_ARGS
<< "Usage: " << args().m_exename << " [--yscroll <delta>]" << WINAPI_ARG << HELP_SYS_ARGS
<< HELP_COMMON_ARGS << " <server-address>" << std::endl
<< std::endl
<< "Options:" << std::endl
@ -516,7 +516,7 @@ ClientApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc
{
// general initialization
m_serverAddress = new NetworkAddress;
args().m_pname = PathUtilities::basename(argv[0]).c_str();
args().m_exename = PathUtilities::basename(argv[0]);
// install caller's output filter
if (outputter != NULL) {

View File

@ -101,7 +101,7 @@ ServerApp::parseArgs(int argc, const char* const* argv)
}
catch (XSocketAddress& e) {
LOG((CLOG_PRINT "%s: %s" BYE,
args().m_pname, e.what(), args().m_pname));
args().m_exename.c_str(), e.what(), args().m_exename.c_str()));
m_bye(kExitArgs);
}
}
@ -126,7 +126,7 @@ ServerApp::help()
std::ostringstream buffer;
buffer << "Start the barrier server component." << std::endl
<< std::endl
<< "Usage: " << args().m_pname
<< "Usage: " << args().m_exename
<< " [--address <address>]"
<< " [--config <pathname>]"
<< WINAPI_ARGS << HELP_SYS_ARGS << HELP_COMMON_ARGS << std::endl
@ -207,7 +207,7 @@ ServerApp::loadConfig()
}
if (!loaded) {
LOG((CLOG_PRINT "%s: no configuration available", args().m_pname));
LOG((CLOG_PRINT "%s: no configuration available", args().m_exename.c_str()));
m_bye(kExitConfig);
}
}
@ -780,7 +780,7 @@ ServerApp::runInner(int argc, char** argv, ILogOutputter* outputter, StartupFunc
// general initialization
m_barrierAddress = new NetworkAddress;
args().m_config = new Config(m_events);
args().m_pname = PathUtilities::basename(argv[0]).c_str();
args().m_exename = PathUtilities::basename(argv[0]);
// install caller's output filter
if (outputter != NULL) {

View File

@ -404,7 +404,7 @@ MSWindowsWatchdog::getCommand() const
}
// seems like a fairly convoluted way to get the process name
const char* launchName = App::instance().argsBase().m_pname;
const char* launchName = App::instance().argsBase().m_exename.c_str();
std::string args = ARCH->commandLine();
// build up a full command line