src/platform_windows.h
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 04 Jun 2020 11:18:45 +0200
changeset 4729 3df9a2a67597
parent 4575 9f2c553f0412
child 4792 7056435ab9e7
child 4901 eff424b70088
permissions -rw-r--r--
forgot test files
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@4457
    16
// winsock2.h includes windows.h and that leads to the definition of `min` and `max`
krista@4457
    17
// which causes compile errors elsewhere.
krista@4457
    18
#define NOMINMAX
krista@2461
    19
#include <winsock2.h>
krista@2461
    20
#endif // WIN32 
markus@1226
    21
vb@948
    22
#include <Rpc.h>
vb@125
    23
#include <string.h>
vb@130
    24
#include <io.h>
vb@219
    25
#include <basetsd.h>
markus@1258
    26
#include <time.h>
vb@4551
    27
#include "timestamp.h"
vb@125
    28
vb@4003
    29
// pEp files and directories
vb@4003
    30
vb@4003
    31
#ifndef PER_USER_DIRECTORY
vb@4003
    32
#define PER_USER_DIRECTORY "%LOCALAPPDATA%\\pEp"
vb@4003
    33
#endif
vb@4003
    34
vb@4003
    35
#ifndef PER_MACHINE_DIRECTORY
vb@4003
    36
#define PER_MACHINE_DIRECTORY "%ALLUSERSPROFILE%\\pEp"
vb@4003
    37
#endif
vb@4003
    38
vb@0
    39
#ifdef __cplusplus
vb@0
    40
extern "C" {
vb@0
    41
#endif
vb@0
    42
vb@219
    43
#define ssize_t SSIZE_T
vb@86
    44
#define RTLD_LAZY 1
vb@130
    45
#define mode_t int
vb@86
    46
vb@2830
    47
#ifndef MIN
vb@2830
    48
#define MIN(A, B) ((A)>(B) ? (B) : (A))
vb@2830
    49
#define MAX(A, B) ((A)>(B) ? (A) : (B))
vb@2830
    50
#endif
vb@2830
    51
vb@0
    52
void *dlopen(const char *filename, int flag);
vb@0
    53
int dlclose(void *handle);
vb@0
    54
void *dlsym(void *handle, const char *symbol);
vb@132
    55
int mkstemp(char *templ);
vb@0
    56
vb@4552
    57
DYNAMIC_API time_t timegm(timestamp *timeptr);
markus@1258
    58
vb@86
    59
#ifndef strdup
vb@113
    60
#define strdup(A) _strdup((A))
vb@86
    61
#endif
vb@86
    62
#ifndef snprintf
Dean@971
    63
#if _MSC_VER<1900 // Includes undefined case. This is a check for VS 2015, which throws an error.
vb@89
    64
#define snprintf(...) _snprintf(__VA_ARGS__)
vb@86
    65
#endif
Dean@971
    66
#endif
vb@82
    67
#ifndef strtok_r
vb@82
    68
#define strtok_r(A, B, C) strtok_s((A), (B), (C))
vb@82
    69
#endif
vb@85
    70
#ifndef strncasecmp
vb@85
    71
#define strncasecmp(A, B, C) _strnicmp((A), (B), (C))
vb@85
    72
#endif
vb@784
    73
#ifndef strcasecmp
vb@785
    74
#define strcasecmp(A, B) _stricmp((A), (B))
vb@784
    75
#endif
vb@113
    76
#ifndef gmtime_r
vb@113
    77
#define gmtime_r(A, B) gmtime_s((B), (A))
vb@132
    78
#endif
vb@132
    79
#ifndef ftruncate
vb@132
    80
#define ftruncate(A, B) _chsize((A), (B))
vb@130
    81
#endif
vb@130
    82
#ifndef ftello
vb@130
    83
#define ftello(A) ((off_t) _ftelli64(A))
vb@113
    84
#endif
vb@113
    85
vb@82
    86
char *strndup(const char *s1, size_t n);
vb@282
    87
char *stpcpy(char *dst, const char *src);
vb@80
    88
krista@918
    89
size_t strlcpy(char* dst, const	char* src, size_t size);
krista@918
    90
size_t strlcat(char* dst, const	char* src, size_t size);
krista@3901
    91
char *strnstr(const char *big, const char *little, size_t len);
krista@3901
    92
krista@918
    93
Thomas@3835
    94
const char *windoze_keys_db(void);
vb@0
    95
const char *windoze_local_db(void);
vb@0
    96
const char *windoze_system_db(void);
vb@0
    97
Thomas@3843
    98
void log_output_debug(const char *title, const char *entity, const char *description, const char *comment);
Thomas@3843
    99
vb@54
   100
long random(void);
vb@54
   101
vb@948
   102
// on Windoze, uuid_t needs pointer semantics
markus@1226
   103
typedef UUID pEpUUID[1];
vb@948
   104
#define _UUID_STRING_T
vb@948
   105
typedef char uuid_string_t[37];
vb@948
   106
markus@1226
   107
void uuid_generate_random(pEpUUID out);
markus@1226
   108
int uuid_parse(char *in, pEpUUID uu);
markus@1226
   109
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out);
vb@948
   110
krista@2461
   111
#ifndef __cplusplus
vb@130
   112
#define inline __inline
vb@125
   113
#endif
vb@125
   114
vb@0
   115
#ifdef __cplusplus
vb@0
   116
}
vb@0
   117
#endif