src/platform_windows.h
author Volker Birk <vb@pep-project.org>
Fri, 17 May 2019 17:59:06 +0200
branchsync
changeset 3720 9ed76a79d784
parent 2830 d6f044e43e1a
child 3835 65f3c7d59eb1
child 3901 cdfe2dddb5da
permissions -rw-r--r--
...
vb@1517
     1
// This file is under GNU General Public License 3.0
vb@1517
     2
// see LICENSE.txt
vb@1517
     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@2830
    33
#ifndef MIN
vb@2830
    34
#define MIN(A, B) ((A)>(B) ? (B) : (A))
vb@2830
    35
#define MAX(A, B) ((A)>(B) ? (A) : (B))
vb@2830
    36
#endif
vb@2830
    37
vb@0
    38
void *dlopen(const char *filename, int flag);
vb@0
    39
int dlclose(void *handle);
vb@0
    40
void *dlsym(void *handle, const char *symbol);
vb@132
    41
int mkstemp(char *templ);
vb@0
    42
markus@1258
    43
time_t timegm(struct tm* tm);
markus@1258
    44
vb@86
    45
#ifndef strdup
vb@113
    46
#define strdup(A) _strdup((A))
vb@86
    47
#endif
vb@86
    48
#ifndef snprintf
Dean@971
    49
#if _MSC_VER<1900 // Includes undefined case. This is a check for VS 2015, which throws an error.
vb@89
    50
#define snprintf(...) _snprintf(__VA_ARGS__)
vb@86
    51
#endif
Dean@971
    52
#endif
vb@82
    53
#ifndef strtok_r
vb@82
    54
#define strtok_r(A, B, C) strtok_s((A), (B), (C))
vb@82
    55
#endif
vb@85
    56
#ifndef strncasecmp
vb@85
    57
#define strncasecmp(A, B, C) _strnicmp((A), (B), (C))
vb@85
    58
#endif
vb@784
    59
#ifndef strcasecmp
vb@785
    60
#define strcasecmp(A, B) _stricmp((A), (B))
vb@784
    61
#endif
vb@113
    62
#ifndef gmtime_r
vb@113
    63
#define gmtime_r(A, B) gmtime_s((B), (A))
vb@132
    64
#endif
vb@132
    65
#ifndef ftruncate
vb@132
    66
#define ftruncate(A, B) _chsize((A), (B))
vb@130
    67
#endif
vb@130
    68
#ifndef ftello
vb@130
    69
#define ftello(A) ((off_t) _ftelli64(A))
vb@113
    70
#endif
vb@113
    71
vb@82
    72
char *strndup(const char *s1, size_t n);
vb@282
    73
char *stpcpy(char *dst, const char *src);
vb@80
    74
krista@918
    75
size_t strlcpy(char* dst, const	char* src, size_t size);
krista@918
    76
size_t strlcat(char* dst, const	char* src, size_t size);
krista@918
    77
vb@0
    78
const char *windoze_local_db(void);
vb@0
    79
const char *windoze_system_db(void);
vb@0
    80
const char *gpg_conf(void);
markus@1258
    81
const char *gpg_agent_conf(void);
vb@0
    82
vb@54
    83
long random(void);
vb@54
    84
vb@948
    85
// on Windoze, uuid_t needs pointer semantics
markus@1226
    86
typedef UUID pEpUUID[1];
vb@948
    87
#define _UUID_STRING_T
vb@948
    88
typedef char uuid_string_t[37];
vb@948
    89
markus@1226
    90
void uuid_generate_random(pEpUUID out);
markus@1226
    91
int uuid_parse(char *in, pEpUUID uu);
markus@1226
    92
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out);
vb@948
    93
krista@2461
    94
#ifndef __cplusplus
vb@130
    95
#define inline __inline
vb@125
    96
#endif
vb@125
    97
vb@0
    98
#ifdef __cplusplus
vb@0
    99
}
vb@0
   100
#endif