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