|
|
@ -13,6 +13,14 @@ |
|
|
|
using namespace ATL; |
|
|
|
using namespace std; |
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
// Stuff for the JSON server follows.
|
|
|
|
#include <boost/filesystem/path.hpp>
|
|
|
|
#include <boost/program_options.hpp>
|
|
|
|
namespace po = boost::program_options; |
|
|
|
std::string logfile = ""; |
|
|
|
#endif
|
|
|
|
|
|
|
|
void CpEpCOMServerAdapterModule::gatekeeper(CpEpCOMServerAdapterModule * self) |
|
|
|
{ |
|
|
|
pEp::GateKeeper keeper(self); |
|
|
@ -27,6 +35,53 @@ CMainWindow mainWindow; |
|
|
|
extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, |
|
|
|
LPTSTR lpCmdLine, int nShowCmd) |
|
|
|
{ |
|
|
|
#ifndef NDEBUG
|
|
|
|
std::ios::sync_with_stdio(false); |
|
|
|
|
|
|
|
// Command line options and console output are for debug only.
|
|
|
|
|
|
|
|
// Some Windows acrobatics so we can use this even with a command line
|
|
|
|
// and get some output onto the console.
|
|
|
|
if (AttachConsole(ATTACH_PARENT_PROCESS)) { |
|
|
|
FILE *f; |
|
|
|
freopen_s(&f, "conout$", "w", stdout); |
|
|
|
freopen_s(&f, "conout$", "w", stderr); |
|
|
|
} |
|
|
|
|
|
|
|
po::options_description desc("Program options for the JSON Server Adapter"); |
|
|
|
desc.add_options() |
|
|
|
("help,h", "print this help messages") |
|
|
|
("debug,d", "debug,d ignored, only works in JSON mini adapter") |
|
|
|
("logfile,l", po::value<std::string>(&logfile)->default_value(logfile), |
|
|
|
"Name of the logfile. Can be \"stderr\" for log to stderr or empty for no log.") |
|
|
|
; |
|
|
|
|
|
|
|
po::variables_map vm; |
|
|
|
try { |
|
|
|
std::vector<std::wstring> args = po::split_winmain(lpCmdLine); |
|
|
|
po::store(po::wcommand_line_parser(args).options(desc).run(), vm); |
|
|
|
po::notify(vm); |
|
|
|
} catch (const po::error& e) { |
|
|
|
std::cerr << "Cannot parse command line: " << e.what() << "\n\n" << desc << std::endl; |
|
|
|
return 2; |
|
|
|
} |
|
|
|
|
|
|
|
if (vm.count("help")) { |
|
|
|
std::cout << desc << "\n"; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
if (logfile.empty()) { |
|
|
|
Logger::setDefaultTarget(Logger::Target::None); |
|
|
|
} else if (logfile == "stderr") { |
|
|
|
Logger::setDefaultTarget(Logger::Target::Console); |
|
|
|
} else { |
|
|
|
Logger::setDefaultTarget(Logger::Target::File); |
|
|
|
} |
|
|
|
|
|
|
|
Logger::start("JsonAdapter", logfile); |
|
|
|
#endif
|
|
|
|
|
|
|
|
_AtlModule.hModule(hInstance); |
|
|
|
_AtlModule.start_gatekeeper(); |
|
|
|
|
|
|
|