src/pEp_internal.h
author Volker Birk <vb@pep-project.org>
Wed, 29 Apr 2015 14:51:33 +0200
changeset 229 313d152239bf
parent 216 e949c98e45e5
child 233 26383354c776
permissions -rw-r--r--
fixing preprocessor
     1 #define PEP_ENGINE_VERSION "0.5.0"
     2 
     3 // this is 20 safewords with 79 chars max
     4 #define MAX_SAFEWORDS_SPACE (20 * 80)
     5 
     6 // XML parameters string
     7 #define PARMS_MAX 32768
     8 
     9 // maximum busy wait time in ms
    10 #define BUSY_WAIT_TIME 5000
    11 
    12 // maximum line length for reading gpg.conf
    13 #define MAX_LINELENGTH 1024
    14 
    15 // default keyserver
    16 #define DEFAULT_KEYSERVER "hkp://keys.gnupg.net"
    17 
    18 #include "platform.h"
    19 
    20 #ifdef WIN32
    21 #define LOCAL_DB windoze_local_db()
    22 #define SYSTEM_DB windoze_system_db()
    23 #define LIBGPGME "libgpgme-11.dll"
    24 #else // UNIX
    25 #define _POSIX_C_SOURCE 200809L
    26 #include <dlfcn.h>
    27 #define LOCAL_DB unix_local_db()
    28 #ifndef SYSTEM_DB
    29 #define SYSTEM_DB "/usr/share/pEp/system.db"
    30 #endif
    31 #ifndef LIBGPGME
    32 #define LIBGPGME "libgpgme-pthread.so"
    33 #endif
    34 #endif
    35 
    36 #include <locale.h>
    37 #include <stdlib.h>
    38 #include <string.h>
    39 #include <assert.h>
    40 #include <stdio.h>
    41 
    42 #include "sqlite3.h"
    43 
    44 #define _EXPORT_PEP_ENGINE_DLL
    45 #include "pEpEngine.h"
    46 
    47 // If not specified, build for GPG
    48 #ifndef USE_NETPGP
    49 #ifndef USE_GPG
    50 #define USE_GPG
    51 #endif
    52 #endif
    53 
    54 #ifdef USE_GPG
    55 #include "pgp_gpg_internal.h"
    56 #elif defined(USE_NETPGP)
    57 #include "pgp_netpgp_internal.h"
    58 #endif
    59 
    60 #include "cryptotech.h"
    61 #include "transport.h"
    62 
    63 #define NOT_IMPLEMENTED assert(0); return PEP_UNKNOWN_ERROR;
    64 
    65 typedef struct _pEpSession {
    66     const char *version;
    67 #ifdef USE_GPG
    68     gpgme_ctx_t ctx;
    69 #elif defined(USE_NETPGP)
    70     netpgp_t ctx;
    71 #endif
    72 
    73     PEP_cryptotech_t *cryptotech;
    74     PEP_transport_t *transports;
    75 
    76     sqlite3 *db;
    77     sqlite3 *system_db;
    78 
    79     sqlite3_stmt *log;
    80     sqlite3_stmt *safeword;
    81     sqlite3_stmt *get_identity;
    82     sqlite3_stmt *set_person;
    83     sqlite3_stmt *set_pgp_keypair;
    84     sqlite3_stmt *set_identity;
    85     sqlite3_stmt *set_trust;
    86     sqlite3_stmt *get_trust;
    87 } pEpSession;
    88 
    89 PEP_STATUS init_transport_system(PEP_SESSION session, bool in_first);
    90 void release_transport_system(PEP_SESSION session, bool out_last);
    91 
    92 #ifdef NDEBUG
    93 #define DEBUG_LOG(TITLE, ENTITY, DESC)
    94 #else
    95 #define DEBUG_LOG(TITLE, ENTITY, DESC) \
    96     log_event(session, (TITLE), (ENTITY), (DESC), "debug");
    97 #endif
    98