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