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