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