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