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