Browse Source

Make the pEp Engine keysync branch compile on Windows again.

Warning: The changes are not yet tested. Especially the ones in platform_unix.*.
keysync-windows
Markus Schaber 6 years ago
parent
commit
e5699a1b52
7 changed files with 52 additions and 20 deletions
  1. +8
    -2
      pEpEngine.vcxproj
  2. +12
    -0
      pEpEngine.vcxproj.filters
  3. +5
    -3
      src/platform_unix.c
  4. +5
    -3
      src/platform_unix.h
  5. +7
    -7
      src/platform_windows.cpp
  6. +12
    -4
      src/platform_windows.h
  7. +3
    -1
      src/sync_impl.c

+ 8
- 2
pEpEngine.vcxproj View File

@ -65,7 +65,7 @@
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>$(TargetDir)\pEpEngineASN1.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>$(TargetDir)\pEpEngineASN1.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>
@ -84,13 +84,15 @@
<TreatWarningAsError>false</TreatWarningAsError>
<AdditionalIncludeDirectories>C:\Users\vb\share\asn1c;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ControlFlowGuard>Guard</ControlFlowGuard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>$(TargetDir)\pEpEngineASN1.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>$(TargetDir)\pEpEngineASN1.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>
@ -98,6 +100,7 @@
</PreBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\asn1_helper.c" />
<ClCompile Include="src\baseprotocol.c" />
<ClCompile Include="src\blacklist.c" />
<ClCompile Include="src\bloblist.c" />
@ -121,12 +124,14 @@
<ClCompile Include="src\sync_actions.c" />
<ClCompile Include="src\sync_driver.c" />
<ClCompile Include="src\sync_fsm.c" />
<ClCompile Include="src\sync_impl.c" />
<ClCompile Include="src\sync_send_actions.c" />
<ClCompile Include="src\timestamp.c" />
<ClCompile Include="src\transport.c" />
<ClCompile Include="src\trans_auto.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\asn1_helper.h" />
<ClInclude Include="src\baseprotocol.h" />
<ClInclude Include="src\blacklist.h" />
<ClInclude Include="src\bloblist.h" />
@ -153,6 +158,7 @@
<ClInclude Include="src\stringpair.h" />
<ClInclude Include="src\sync.h" />
<ClInclude Include="src\sync_fsm.h" />
<ClInclude Include="src\sync_impl.h" />
<ClInclude Include="src\timestamp.h" />
<ClInclude Include="src\transport.h" />
<ClInclude Include="src\trans_auto.h" />


+ 12
- 0
pEpEngine.vcxproj.filters View File

@ -96,6 +96,12 @@
<ClCompile Include="src\openpgp_compat.c">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="src\asn1_helper.c">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="src\sync_impl.c">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\keymanagement.h">
@ -188,6 +194,12 @@
<ClInclude Include="src\openpgp_compat.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="src\asn1_helper.h">
<Filter>Headerdateien</Filter>
</ClInclude>
<ClInclude Include="src\sync_impl.h">
<Filter>Headerdateien</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="LICENSE.txt" />


+ 5
- 3
src/platform_unix.c View File

@ -98,7 +98,8 @@ const char *android_system_db(void)
return buffer;
}
void uuid_generate_random(uuid__t out)
// TODO: Check and possibly fix this function if necessary
void uuid_generate_random(pEpUUID out)
{
uuid_t *uuid;
uuid_rc_t rc_create;
@ -107,7 +108,7 @@ void uuid_generate_random(uuid__t out)
uuid_make(uuid, UUID_MAKE_V1) != UUID_RC_OK ||
uuid_export(uuid, UUID_FMT_BIN, out, NULL) != UUID_RC_OK)
{
memset(out, 0, sizeof(uuid__t));
memset(out, 0, sizeof(pEpUUID));
}
if (rc_create == UUID_RC_OK)
@ -116,7 +117,8 @@ void uuid_generate_random(uuid__t out)
}
}
void uuid_unparse_upper(uuid__t uu, uuid_string_t out)
// TODO: Check and possibly fix this function if necessary
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out)
{
uuid_t *uuid;
uuid_rc_t rc_create;


+ 5
- 3
src/platform_unix.h View File

@ -71,9 +71,11 @@ typedef char uuid_string_t[37];
#define UUID uuid_t
#ifdef ANDROID
typedef char uuid__t[16];
void uuid_generate_random(uuid__t out);
void uuid_unparse_upper(uuid__t uu, uuid_string_t out);
typedef char pEpUUID[16];
void uuid_generate_random(pEpUUID out);
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out);
#else
typedef uuid_t pEpUUID;
#endif
#ifdef __cplusplus


+ 7
- 7
src/platform_windows.cpp View File

@ -267,32 +267,32 @@ int mkstemp(char *templ)
return _open(pathname, _O_RDWR | _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE);
}
void uuid_generate_random(uuid_t out)
void uuid_generate_random(pEpUUID out)
{
RPC_STATUS rpc_status = UuidCreate(out);
assert(rpc_status == RPC_S_OK);
}
int uuid_parse(char *in, uuid_t uu)
int uuid_parse(char *in, pEpUUID uu)
{
unsigned char *_in = (unsigned char *) in;
RPC_STATUS rpc_status = UuidFromString(_in, &uu);
RPC_STATUS rpc_status = UuidFromStringA(_in, uu);
assert(rpc_status == RPC_S_OK);
if (rpc_status == RPC_S_INVALID_STRING_UUID)
return -1;
return 0;
}
void uuid_unparse_upper(uuid_t uu, uuid_string_t out)
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out)
{
unsigned char *_out = out;
unsigned char *_out = (unsigned char*)out;
RPC_CSTR str;
RPC_STATUS rpc_status = UuidToString(uu, &str);
RPC_STATUS rpc_status = UuidToStringA(uu, &str);
assert(rpc_status == RPC_S_OK);
if (rpc_status == RPC_S_OK) {
memcpy(out, str, 36);
out[36] = 0;
RpcStringFree(str);
RpcStringFreeA(&str);
}
else { // if (rpc_status == RPC_S_OUT_OF_MEMORY)
memset(out, 0, 37);


+ 12
- 4
src/platform_windows.h View File

@ -4,6 +4,14 @@
#pragma warning(disable : 4996)
// We need to make sure winsock2 is included before windows.h, or we will get redefinitions of symbols
// as windows.h includes winsock1.h, so we will have duplicate symbols if windows.h is included first.
// It seems some of our code includes sync.h before including winsock.h, leading to the failure.
// Including winsock2.h here fixes the problem for now...
#ifdef WIN32
#include <winsock2.h>
#endif // WIN32
#include <Rpc.h>
#include <string.h>
#include <io.h>
@ -62,13 +70,13 @@ const char *gpg_conf(void);
long random(void);
// on Windoze, uuid_t needs pointer semantics
typedef UUID *uuid_t;
typedef UUID pEpUUID[1];
#define _UUID_STRING_T
typedef char uuid_string_t[37];
void uuid_generate_random(uuid_t out);
int uuid_parse(char *in, uuid_t uu);
void uuid_unparse_upper(uuid_t uu, uuid_string_t out);
void uuid_generate_random(pEpUUID out);
int uuid_parse(char *in, pEpUUID uu);
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out);
#ifndef inline
#define inline __inline


+ 3
- 1
src/sync_impl.c View File

@ -104,7 +104,9 @@ error:
return status;
}
DYNAMIC_API void free_sync_msg(sync_msg_t *sync_msg)
// TODO: DYNAMIC_API was here, but broke the windows build.
// We need to check whether it belongs here or it's a bug.
/* DYNAMIC_API */ void free_sync_msg(sync_msg_t *sync_msg)
{
assert(sync_msg);
if (!(sync_msg))


Loading…
Cancel
Save