src/platform_unix.h
author Volker Birk <vb@pep.foundation>
Tue, 27 Dec 2016 21:13:41 +0100
changeset 1513 e7f7e42385b5
parent 1267 1b7df2133aab
child 1528 f0ed0f1f2b56
permissions -rw-r--r--
adding license info to each file
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
vb@1
    23
const char *unix_local_db(void);
Edouard@347
    24
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);
vb@130
    28
Edouard@338
    29
#ifdef ANDROID
Edouard@380
    30
Edouard@1267
    31
time_t timegm(struct tm* const t);
Edouard@1267
    32
Edouard@348
    33
char *stpncpy(char *, const char *, size_t);
Edouard@348
    34
char *stpcpy(char *, const char *);
roker@438
    35
roker@438
    36
// Beware: predictable pseudo random with static seed!
roker@438
    37
// Only the lowest 31 bits are filled randomly.
Edouard@338
    38
long int random(void);
roker@438
    39
Edouard@348
    40
const char *android_system_db(void);
Edouard@348
    41
#define SYSTEM_DB android_system_db()
Edouard@348
    42
#define LIBGPGME "libgpgme.so"
Edouard@380
    43
Edouard@380
    44
#elif __APPLE__
Edouard@380
    45
#include "TargetConditionals.h"
krista@919
    46
#include <string.h>
Edouard@380
    47
#if TARGET_OS_IPHONE
Edouard@380
    48
Edouard@380
    49
extern char* SystemDB;
Edouard@380
    50
#define SYSTEM_DB SystemDB
Edouard@380
    51
    
Edouard@380
    52
#endif
Edouard@338
    53
#endif
Edouard@338
    54
vb@926
    55
#if !defined(BSD) && !defined(__APPLE__)
krista@918
    56
size_t strlcpy(char* dst, const	char* src, size_t size);
krista@918
    57
size_t strlcat(char* dst, const	char* src, size_t size);
krista@1095
    58
krista@1095
    59
// N.B. This is ifdef'd out because NDK users sometimes have trouble finding regex functions in
krista@1095
    60
//      the library in spite of the inclusion of regex.h - this is a FIXME, but since iOS is
krista@1095
    61
//      *currently* the only netpgp user, we will ifdef this so that we don't block Android.
krista@1095
    62
#ifdef USE_NETPGP
krista@1033
    63
int regnexec(const regex_t* preg, const char* string,
krista@1033
    64
             size_t len, size_t nmatch, regmatch_t pmatch[], int eflags);
krista@918
    65
#endif
krista@918
    66
krista@1095
    67
#endif
krista@1095
    68
vb@948
    69
#ifndef _UUID_STRING_T
vb@948
    70
#define _UUID_STRING_T
vb@948
    71
typedef char uuid_string_t[37];
vb@948
    72
#endif
vb@948
    73
#ifdef UUID
vb@949
    74
#undef UUID
vb@949
    75
#endif
vb@948
    76
// on *nix, uuid_t is an array and already implements pointer semantics
vb@948
    77
#define UUID uuid_t
vb@948
    78
Edouard@1119
    79
#ifdef ANDROID
markus@1226
    80
typedef char pEpUUID[16];
markus@1226
    81
void uuid_generate_random(pEpUUID out);
markus@1226
    82
void uuid_unparse_upper(pEpUUID uu, uuid_string_t out);
markus@1226
    83
#else
markus@1226
    84
typedef uuid_t pEpUUID;
Edouard@1119
    85
#endif
Edouard@1119
    86
vb@130
    87
#ifdef __cplusplus
vb@130
    88
}
vb@130
    89
#endif