Merge with COM-113 COM-115
authorVolker Birk <vb@pep.foundation>
Thu, 02 Jul 2020 07:47:56 +0200
branchCOM-115
changeset 42602815463ba92
parent 425 161a68f99058
parent 422 c6d629fddb0b
child 427 d75ea8a802a7
Merge with COM-113
pEpCOMServerAdapter.cpp
pEpCOMServerAdapter.vcxproj
pEpCOMServerAdapter.vcxproj.filters
     1.1 --- a/pEpCOMServerAdapter.cpp	Thu Jul 02 07:46:18 2020 +0200
     1.2 +++ b/pEpCOMServerAdapter.cpp	Thu Jul 02 07:47:56 2020 +0200
     1.3 @@ -13,6 +13,14 @@
     1.4  using namespace ATL;
     1.5  using namespace std;
     1.6  
     1.7 +#ifndef NDEBUG
     1.8 +// Stuff for the JSON server follows.
     1.9 +#include <boost/filesystem/path.hpp>
    1.10 +#include <boost/program_options.hpp>
    1.11 +namespace po = boost::program_options;
    1.12 +std::string logfile = "";
    1.13 +#endif
    1.14 +
    1.15  void CpEpCOMServerAdapterModule::gatekeeper(CpEpCOMServerAdapterModule * self)
    1.16  {
    1.17      pEp::GateKeeper keeper(self);
    1.18 @@ -27,6 +35,53 @@
    1.19  extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, 
    1.20                                  LPTSTR lpCmdLine, int nShowCmd)
    1.21  {
    1.22 +#ifndef NDEBUG
    1.23 +    std::ios::sync_with_stdio(false);
    1.24 +
    1.25 +    // Command line options and console output are for debug only.
    1.26 +
    1.27 +    // Some Windows acrobatics so we can use this even with a command line
    1.28 +    // and get some output onto the console.
    1.29 +    if (AttachConsole(ATTACH_PARENT_PROCESS)) {
    1.30 +        FILE *f;
    1.31 +        freopen_s(&f, "conout$", "w", stdout);
    1.32 +        freopen_s(&f, "conout$", "w", stderr);
    1.33 +    }
    1.34 +
    1.35 +    po::options_description desc("Program options for the JSON Server Adapter");
    1.36 +    desc.add_options()
    1.37 +        ("help,h", "print this help messages")
    1.38 +        ("debug,d", "debug,d ignored, only works in JSON mini adapter")
    1.39 +        ("logfile,l", po::value<std::string>(&logfile)->default_value(logfile),
    1.40 +            "Name of the logfile. Can be \"stderr\" for log to stderr or empty for no log.")
    1.41 +    ;
    1.42 +
    1.43 +    po::variables_map vm;
    1.44 +    try {
    1.45 +        std::vector<std::wstring> args = po::split_winmain(lpCmdLine);
    1.46 +        po::store(po::wcommand_line_parser(args).options(desc).run(), vm);
    1.47 +        po::notify(vm);
    1.48 +    } catch (const po::error& e) {
    1.49 +        std::cerr << "Cannot parse command line: " << e.what() << "\n\n" << desc << std::endl;
    1.50 +        return 2;
    1.51 +    }
    1.52 +
    1.53 +    if (vm.count("help")) {
    1.54 +        std::cout << desc << "\n";
    1.55 +        return 0;
    1.56 +    }
    1.57 +
    1.58 +    if (logfile.empty()) {
    1.59 +        Logger::setDefaultTarget(Logger::Target::None);
    1.60 +    } else if (logfile == "stderr") {
    1.61 +        Logger::setDefaultTarget(Logger::Target::Console);
    1.62 +    } else {
    1.63 +        Logger::setDefaultTarget(Logger::Target::File);
    1.64 +    }
    1.65 +
    1.66 +    Logger::start("JsonAdapter", logfile);
    1.67 +#endif
    1.68 +
    1.69      _AtlModule.hModule(hInstance);
    1.70      _AtlModule.start_gatekeeper();
    1.71  
     2.1 --- a/pEpCOMServerAdapter.vcxproj	Thu Jul 02 07:46:18 2020 +0200
     2.2 +++ b/pEpCOMServerAdapter.vcxproj	Thu Jul 02 07:47:56 2020 +0200
     2.3 @@ -202,11 +202,12 @@
     2.4      <ProjectReference Include="..\pEpEngine\build-windows\pEpEngine.vcxproj">
     2.5        <Project>{146e69f8-e1da-456a-b048-6dd29d9acf6b}</Project>
     2.6      </ProjectReference>
     2.7 -  </ItemGroup>
     2.8 -  <ItemGroup>
     2.9 -    <Library Include="..\Debug\libpEpAdapter.lib" />
    2.10 -    <Library Include="..\Debug\libpEpWebserver.lib" />
    2.11 -    <Library Include="..\Debug\pEpJSONServerAdapterLibrary.lib" />
    2.12 +    <ProjectReference Include="..\pEpJSONServerAdapter\build-windows\pEpJSONServerAdapter\pEpJSONServerAdapterLibrary.vcxproj">
    2.13 +      <Project>{644d1ba4-084c-47b2-8a9e-00a8d9f9a35c}</Project>
    2.14 +    </ProjectReference>
    2.15 +    <ProjectReference Include="..\pEpJSONServerAdapter\build-windows\pEp\libpEpWebserver\libpEpWebserver.vcxproj">
    2.16 +      <Project>{0d25734e-a71b-4536-8dc4-60e945382fc5}</Project>
    2.17 +    </ProjectReference>
    2.18    </ItemGroup>
    2.19    <ItemGroup>
    2.20      <Image Include="logo.ico" />
    2.21 @@ -219,6 +220,7 @@
    2.22      <Import Project="..\packages\boost_filesystem-vc142.1.72.0.0\build\boost_filesystem-vc142.targets" Condition="Exists('..\packages\boost_filesystem-vc142.1.72.0.0\build\boost_filesystem-vc142.targets')" />
    2.23      <Import Project="..\packages\boost_thread-vc142.1.72.0.0\build\boost_thread-vc142.targets" Condition="Exists('..\packages\boost_thread-vc142.1.72.0.0\build\boost_thread-vc142.targets')" />
    2.24      <Import Project="..\packages\boost_chrono-vc142.1.72.0.0\build\boost_chrono-vc142.targets" Condition="Exists('..\packages\boost_chrono-vc142.1.72.0.0\build\boost_chrono-vc142.targets')" />
    2.25 +    <Import Project="..\packages\boost_program_options-vc142.1.72.0.0\build\boost_program_options-vc142.targets" Condition="Exists('..\packages\boost_program_options-vc142.1.72.0.0\build\boost_program_options-vc142.targets')" />
    2.26    </ImportGroup>
    2.27    <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    2.28      <PropertyGroup>
    2.29 @@ -230,5 +232,6 @@
    2.30      <Error Condition="!Exists('..\packages\boost_filesystem-vc142.1.72.0.0\build\boost_filesystem-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost_filesystem-vc142.1.72.0.0\build\boost_filesystem-vc142.targets'))" />
    2.31      <Error Condition="!Exists('..\packages\boost_thread-vc142.1.72.0.0\build\boost_thread-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost_thread-vc142.1.72.0.0\build\boost_thread-vc142.targets'))" />
    2.32      <Error Condition="!Exists('..\packages\boost_chrono-vc142.1.72.0.0\build\boost_chrono-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost_chrono-vc142.1.72.0.0\build\boost_chrono-vc142.targets'))" />
    2.33 +    <Error Condition="!Exists('..\packages\boost_program_options-vc142.1.72.0.0\build\boost_program_options-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\boost_program_options-vc142.1.72.0.0\build\boost_program_options-vc142.targets'))" />
    2.34    </Target>
    2.35  </Project>
    2.36 \ No newline at end of file
     3.1 --- a/pEpCOMServerAdapter.vcxproj.filters	Thu Jul 02 07:46:18 2020 +0200
     3.2 +++ b/pEpCOMServerAdapter.vcxproj.filters	Thu Jul 02 07:47:56 2020 +0200
     3.3 @@ -46,9 +46,6 @@
     3.4      <ClCompile Include="LocalJSONAdapter.cpp">
     3.5        <Filter>Source Files</Filter>
     3.6      </ClCompile>
     3.7 -    <ClCompile Include="CMainWindow.cpp">
     3.8 -      <Filter>Source Files</Filter>
     3.9 -    </ClCompile>
    3.10    </ItemGroup>
    3.11    <ItemGroup>
    3.12      <ClInclude Include="stdafx.h">
    3.13 @@ -87,9 +84,6 @@
    3.14      <ClInclude Include="..\pEpJSONServerAdapter\server\adapter-library.hh">
    3.15        <Filter>Header Files</Filter>
    3.16      </ClInclude>
    3.17 -    <ClInclude Include="CMainWindow.h">
    3.18 -      <Filter>Header Files</Filter>
    3.19 -    </ClInclude>
    3.20    </ItemGroup>
    3.21    <ItemGroup>
    3.22      <ResourceCompile Include="pEpCOMServerAdapter.rc">
    3.23 @@ -118,14 +112,4 @@
    3.24        <Filter>Source Files</Filter>
    3.25      </Midl>
    3.26    </ItemGroup>
    3.27 -  <ItemGroup>
    3.28 -    <Library Include="..\Debug\pEpJSONServerAdapterLibrary.lib" />
    3.29 -    <Library Include="..\Debug\libpEpWebserver.lib" />
    3.30 -    <Library Include="..\Debug\libpEpAdapter.lib" />
    3.31 -  </ItemGroup>
    3.32 -  <ItemGroup>
    3.33 -    <Image Include="logo.ico">
    3.34 -      <Filter>Resource Files</Filter>
    3.35 -    </Image>
    3.36 -  </ItemGroup>
    3.37  </Project>
    3.38 \ No newline at end of file
     4.1 --- a/packages.config	Thu Jul 02 07:46:18 2020 +0200
     4.2 +++ b/packages.config	Thu Jul 02 07:47:56 2020 +0200
     4.3 @@ -4,6 +4,7 @@
     4.4    <package id="boost_chrono-vc142" version="1.72.0.0" targetFramework="native" />
     4.5    <package id="boost_date_time-vc142" version="1.72.0.0" targetFramework="native" />
     4.6    <package id="boost_filesystem-vc142" version="1.72.0.0" targetFramework="native" />
     4.7 +  <package id="boost_program_options-vc142" version="1.72.0.0" targetFramework="native" />
     4.8    <package id="boost_regex-vc142" version="1.72.0.0" targetFramework="native" />
     4.9    <package id="boost_thread-vc142" version="1.72.0.0" targetFramework="native" />
    4.10  </packages>
    4.11 \ No newline at end of file