src/platform_windows.h
author Markus Schaber <markus@pep-security.net>
Fri, 30 Sep 2016 21:16:56 +0200
branchkeysync-windows
changeset 1226 a4e082c43cdd
parent 1001 42e0841b71f0
child 1258 9c376b153898
permissions -rw-r--r--
Make the pEp Engine keysync branch compile on Windows again.

Warning: The changes are not yet tested. Especially the ones in platform_unix.*.
vb@0
     1
#pragma once
vb@0
     2
vb@0
     3
// Windows platform specifica
vb@0
     4
vb@24
     5
#pragma warning(disable : 4996)
vb@0
     6
markus@1226
     7
// We need to make sure winsock2 is included before windows.h, or we will get redefinitions of symbols
markus@1226
     8
// as windows.h includes winsock1.h, so we will have duplicate symbols if windows.h is included first.
markus@1226
     9
// It seems some of our code includes sync.h before including winsock.h, leading to the failure.
markus@1226
    10
// Including winsock2.h here fixes the problem for now...
markus@1226
    11
#ifdef WIN32 
markus@1226
    12
#include <winsock2.h>
markus@1226
    13
#endif // WIN32 
markus@1226
    14
vb@948
    15
#include <Rpc.h>
vb@125
    16
#include <string.h>
vb@130
    17
#include <io.h>
vb@219
    18
#include <basetsd.h>
vb@125
    19
vb@0
    20
#ifdef __cplusplus
vb@0
    21
extern "C" {
vb@0
    22
#endif
vb@0
    23
vb@219
    24
#define ssize_t SSIZE_T
vb@86
    25
#define RTLD_LAZY 1
vb@130
    26
#define mode_t int
vb@86
    27
vb@0
    28
void *dlopen(const char *filename, int flag);
vb@0
    29
int dlclose(void *handle);
vb@0
    30
void *dlsym(void *handle, const char *symbol);
vb@132
    31
int mkstemp(char *templ);
vb@0
    32
vb@86
    33
#ifndef strdup
vb@113
    34
#define strdup(A) _strdup((A))
vb@86
    35
#endif
vb@86
    36
#ifndef snprintf
Dean@971
    37
#if _MSC_VER<1900 // Includes undefined case. This is a check for VS 2015, which throws an error.
vb@89
    38
#define snprintf(...) _snprintf(__VA_ARGS__)
vb@86
    39
#endif
Dean@971
    40
#endif
vb@82
    41
#ifndef strtok_r
vb@82
    42
#define strtok_r(A, B, C) strtok_s((A), (B), (C))
vb@82
    43
#endif
vb@85
    44
#ifndef strncasecmp
vb@85
    45
#define strncasecmp(A, B, C) _strnicmp((A), (B), (C))
vb@85
    46
#endif
vb@784
    47
#ifndef strcasecmp
vb@785
    48
#define strcasecmp(A, B) _stricmp((A), (B))
vb@784
    49
#endif
vb@113
    50
#ifndef gmtime_r
vb@113
    51
#define gmtime_r(A, B) gmtime_s((B), (A))
vb@132
    52
#endif
vb@132
    53
#ifndef ftruncate
vb@132
    54
#define ftruncate(A, B) _chsize((A), (B))
vb@130
    55
#endif
vb@130
    56
#ifndef ftello
vb@130
    57
#define ftello(A) ((off_t) _ftelli64(A))
vb@113
    58
#endif
vb@113
    59
vb@82
    60
char *strndup(const char *s1, size_t n);
vb@282
    61
char *stpcpy(char *dst, const char *src);
vb@80
    62
krista@918
    63
size_t strlcpy(char* dst, const	char* src, size_t size);
krista@918
    64
size_t strlcat(char* dst, const	char* src, size_t size);
krista@918
    65
vb@0
    66
const char *windoze_local_db(void);
vb@0
    67
const char *windoze_system_db(void);
vb@0
    68
const char *gpg_conf(void);
vb@0
    69
vb@54
    70
long random(void);
vb@54
    71
vb@948
    72
// on Windoze, uuid_t needs pointer semantics
markus@1226
    73
typedef UUID pEpUUID[1];
vb@948
    74
#define _UUID_STRING_T
vb@948
    75
typedef char uuid_string_t[37];
vb@948
    76
markus@1226
    77
void uuid_generate_random(pEpUUID out);
markus@1226
    78
int uuid_parse(char *in, pEpUUID uu);
markus@1226
    79
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out);
vb@948
    80
vb@125
    81
#ifndef inline
vb@130
    82
#define inline __inline
vb@125
    83
#endif
vb@125
    84
vb@0
    85
#ifdef __cplusplus
vb@0
    86
}
vb@0
    87
#endif