src/platform_unix.h
author us@chu.huenfield.org
Tue, 25 Dec 2018 14:46:45 +0100
branchsync
changeset 3209 c15b4ca2b52a
parent 2830 d6f044e43e1a
child 3638 4ba9bd8b80c1
child 3901 cdfe2dddb5da
permissions -rw-r--r--
Replace use of Sequoia's backend with a custom key store.

- Sequoia's key store doesn't meet pep's needs (in particular, the
ability to search on a key's user id) and trying to shoehorn pep's
needs onto Sequoia's key store abstractions is just introducing
overhead with no appreciable gain in functionality.

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