src/platform_unix.h
author Krista Bennett <krista@pep-project.org>
Tue, 14 Aug 2018 13:45:34 +0200
branchENGINE-451
changeset 2826 07c080d73a63
parent 2751 66c8218f81e8
child 2830 d6f044e43e1a
permissions -rw-r--r--
ENGINE-451: abandoning branch - config files to be dealt with using gpgme (and hotfix will be external to engine
vb@1513
     1
// This file is under GNU General Public License 3.0
vb@1513
     2
// see LICENSE.txt
vb@1513
     3
vb@926
     4
#ifndef __APPLE__
vb@130
     5
#define _POSIX_C_SOURCE 200809L
vb@926
     6
#endif
vb@130
     7
edouard@1261
     8
#include <time.h>
vb@130
     9
#include <unistd.h>
vb@130
    10
#include <strings.h>
vb@130
    11
#include <sys/select.h>
krista@1033
    12
#include <regex.h>
vb@130
    13
huss@1084
    14
#ifndef ANDROID
vb@948
    15
#include <uuid/uuid.h>
huss@1084
    16
#endif
huss@1084
    17
krista@1033
    18
vb@130
    19
#ifdef __cplusplus
vb@130
    20
extern "C" {
vb@130
    21
#endif
vb@130
    22
krista@2684
    23
#ifdef NDEBUG
vb@1
    24
const char *unix_local_db(void);
vb@1
    25
const char *gpg_conf(void);
krista@763
    26
const char *gpg_agent_conf(void);
Edouard@175
    27
const char *gpg_home(void);
krista@2684
    28
#else
krista@2684
    29
const char *unix_local_db(int reset);
krista@2684
    30
const char *gpg_conf(int reset);
krista@2684
    31
const char *gpg_agent_conf(int reset);
krista@2684
    32
const char *gpg_home(int reset);
krista@2684
    33
#endif
krista@2684
    34
vb@130
    35
Edouard@338
    36
#ifdef ANDROID
Edouard@380
    37
Edouard@1267
    38
time_t timegm(struct tm* const t);
Edouard@1267
    39
Edouard@348
    40
char *stpncpy(char *, const char *, size_t);
Edouard@348
    41
char *stpcpy(char *, const char *);
roker@438
    42
roker@438
    43
// Beware: predictable pseudo random with static seed!
roker@438
    44
// Only the lowest 31 bits are filled randomly.
huss@1528
    45
//long int random(void);
roker@438
    46
Edouard@348
    47
const char *android_system_db(void);
Edouard@348
    48
#define SYSTEM_DB android_system_db()
vb@2751
    49
#ifdef __APPLE__
vb@2751
    50
#define LIBGPGME "libgpgme.11.dylib"
vb@2751
    51
#else
Edouard@348
    52
#define LIBGPGME "libgpgme.so"
vb@2751
    53
#endif
Edouard@380
    54
Edouard@380
    55
#elif __APPLE__
Edouard@380
    56
#include "TargetConditionals.h"
krista@919
    57
#include <string.h>
Edouard@380
    58
#if TARGET_OS_IPHONE
Edouard@380
    59
Edouard@380
    60
extern char* SystemDB;
Edouard@380
    61
#define SYSTEM_DB SystemDB
Edouard@380
    62
    
Edouard@380
    63
#endif
Edouard@338
    64
#endif
Edouard@338
    65
vb@926
    66
#if !defined(BSD) && !defined(__APPLE__)
krista@918
    67
size_t strlcpy(char* dst, const	char* src, size_t size);
krista@918
    68
size_t strlcat(char* dst, const	char* src, size_t size);
krista@1095
    69
krista@1095
    70
// N.B. This is ifdef'd out because NDK users sometimes have trouble finding regex functions in
krista@1095
    71
//      the library in spite of the inclusion of regex.h - this is a FIXME, but since iOS is
krista@1095
    72
//      *currently* the only netpgp user, we will ifdef this so that we don't block Android.
krista@1095
    73
#ifdef USE_NETPGP
krista@1033
    74
int regnexec(const regex_t* preg, const char* string,
krista@1033
    75
             size_t len, size_t nmatch, regmatch_t pmatch[], int eflags);
krista@918
    76
#endif
krista@918
    77
krista@1095
    78
#endif
krista@1095
    79
vb@948
    80
#ifndef _UUID_STRING_T
vb@948
    81
#define _UUID_STRING_T
vb@948
    82
typedef char uuid_string_t[37];
vb@948
    83
#endif
vb@948
    84
#ifdef UUID
vb@949
    85
#undef UUID
vb@949
    86
#endif
vb@948
    87
// on *nix, uuid_t is an array and already implements pointer semantics
vb@948
    88
#define UUID uuid_t
vb@948
    89
Edouard@1119
    90
#ifdef ANDROID
markus@1226
    91
typedef char pEpUUID[16];
markus@1226
    92
void uuid_generate_random(pEpUUID out);
markus@1226
    93
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out);
markus@1226
    94
#else
markus@1226
    95
typedef uuid_t pEpUUID;
Edouard@1119
    96
#endif
Edouard@1119
    97
vb@130
    98
#ifdef __cplusplus
vb@130
    99
}
vb@130
   100
#endif