src/platform_unix.h
author Markus Schaber <markus@pep-security.net>
Fri, 30 Sep 2016 21:16:56 +0200
branchkeysync-windows
changeset 1226 a4e082c43cdd
parent 1119 97f329284202
child 1261 cf7fbb6db4e4
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@926
     1
#ifndef __APPLE__
vb@130
     2
#define _POSIX_C_SOURCE 200809L
vb@926
     3
#endif
vb@130
     4
vb@130
     5
#include <unistd.h>
vb@130
     6
#include <strings.h>
vb@130
     7
#include <sys/select.h>
krista@1033
     8
#include <regex.h>
vb@130
     9
huss@1084
    10
#ifndef ANDROID
vb@948
    11
#include <uuid/uuid.h>
huss@1084
    12
#endif
huss@1084
    13
krista@1033
    14
vb@130
    15
#ifdef __cplusplus
vb@130
    16
extern "C" {
vb@130
    17
#endif
vb@130
    18
vb@1
    19
const char *unix_local_db(void);
Edouard@347
    20
vb@1
    21
const char *gpg_conf(void);
krista@763
    22
const char *gpg_agent_conf(void);
Edouard@175
    23
const char *gpg_home(void);
vb@130
    24
Edouard@338
    25
#ifdef ANDROID
Edouard@380
    26
Edouard@348
    27
char *stpncpy(char *, const char *, size_t);
Edouard@348
    28
char *stpcpy(char *, const char *);
roker@438
    29
roker@438
    30
// Beware: predictable pseudo random with static seed!
roker@438
    31
// Only the lowest 31 bits are filled randomly.
Edouard@338
    32
long int random(void);
roker@438
    33
Edouard@348
    34
const char *android_system_db(void);
Edouard@348
    35
#define SYSTEM_DB android_system_db()
Edouard@348
    36
#define LIBGPGME "libgpgme.so"
Edouard@380
    37
Edouard@380
    38
#elif __APPLE__
Edouard@380
    39
#include "TargetConditionals.h"
krista@919
    40
#include <string.h>
Edouard@380
    41
#if TARGET_OS_IPHONE
Edouard@380
    42
Edouard@380
    43
extern char* SystemDB;
Edouard@380
    44
#define SYSTEM_DB SystemDB
Edouard@380
    45
    
Edouard@380
    46
#endif
Edouard@338
    47
#endif
Edouard@338
    48
vb@926
    49
#if !defined(BSD) && !defined(__APPLE__)
krista@918
    50
size_t strlcpy(char* dst, const	char* src, size_t size);
krista@918
    51
size_t strlcat(char* dst, const	char* src, size_t size);
krista@1095
    52
krista@1095
    53
// N.B. This is ifdef'd out because NDK users sometimes have trouble finding regex functions in
krista@1095
    54
//      the library in spite of the inclusion of regex.h - this is a FIXME, but since iOS is
krista@1095
    55
//      *currently* the only netpgp user, we will ifdef this so that we don't block Android.
krista@1095
    56
#ifdef USE_NETPGP
krista@1033
    57
int regnexec(const regex_t* preg, const char* string,
krista@1033
    58
             size_t len, size_t nmatch, regmatch_t pmatch[], int eflags);
krista@918
    59
#endif
krista@918
    60
krista@1095
    61
#endif
krista@1095
    62
vb@948
    63
#ifndef _UUID_STRING_T
vb@948
    64
#define _UUID_STRING_T
vb@948
    65
typedef char uuid_string_t[37];
vb@948
    66
#endif
vb@948
    67
#ifdef UUID
vb@949
    68
#undef UUID
vb@949
    69
#endif
vb@948
    70
// on *nix, uuid_t is an array and already implements pointer semantics
vb@948
    71
#define UUID uuid_t
vb@948
    72
Edouard@1119
    73
#ifdef ANDROID
markus@1226
    74
typedef char pEpUUID[16];
markus@1226
    75
void uuid_generate_random(pEpUUID out);
markus@1226
    76
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out);
markus@1226
    77
#else
markus@1226
    78
typedef uuid_t pEpUUID;
Edouard@1119
    79
#endif
Edouard@1119
    80
vb@130
    81
#ifdef __cplusplus
vb@130
    82
}
vb@130
    83
#endif