src/pEp_internal.h
author Volker Birk <vb@pep-project.org>
Sun, 21 Feb 2016 21:17:31 +0100
changeset 456 59be449d1aca
parent 450 ae04b9c42932
child 458 72b4da3d4e2d
permissions -rw-r--r--
DDL for blacklist_keys
     1 #define PEP_ENGINE_VERSION "0.6.0"
     2 
     3 // this is 20 trustwords with 79 chars max
     4 #define MAX_TRUSTWORDS_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 #ifndef DEFAULT_KEYSERVER
    17 #define DEFAULT_KEYSERVER "hkp://keys.gnupg.net"
    18 #endif
    19 
    20 // crashdump constants
    21 #ifndef CRASHDUMP_DEFAULT_LINES
    22 #define CRASHDUMP_DEFAULT_LINES 100
    23 #endif
    24 #define CRASHDUMP_MAX_LINES 32767
    25 
    26 #include "platform.h"
    27 
    28 #ifdef WIN32
    29 #define LOCAL_DB windoze_local_db()
    30 #define SYSTEM_DB windoze_system_db()
    31 #define LIBGPGME "libgpgme-11.dll"
    32 #else // UNIX
    33 #define _POSIX_C_SOURCE 200809L
    34 #include <dlfcn.h>
    35 #define LOCAL_DB unix_local_db()
    36 #ifndef SYSTEM_DB
    37 #define SYSTEM_DB "/usr/share/pEp/system.db"
    38 #endif
    39 #ifndef LIBGPGME
    40 #define LIBGPGME "libgpgme-pthread.so"
    41 #endif
    42 #endif
    43 
    44 #include <locale.h>
    45 #include <stdlib.h>
    46 #include <string.h>
    47 #include <assert.h>
    48 #include <stdio.h>
    49 
    50 #include "sqlite3.h"
    51 
    52 #define _EXPORT_PEP_ENGINE_DLL
    53 #include "pEpEngine.h"
    54 
    55 // If not specified, build for GPG
    56 #ifndef USE_NETPGP
    57 #ifndef USE_GPG
    58 #define USE_GPG
    59 #endif
    60 #endif
    61 
    62 #ifdef USE_GPG
    63 #include "pgp_gpg_internal.h"
    64 #elif defined(USE_NETPGP)
    65 #include "pgp_netpgp_internal.h"
    66 #endif
    67 
    68 #include "keymanagement.h"
    69 #include "cryptotech.h"
    70 #include "transport.h"
    71 
    72 #define NOT_IMPLEMENTED assert(0); return PEP_UNKNOWN_ERROR;
    73 
    74 typedef struct _pEpSession {
    75     const char *version;
    76 #ifdef USE_GPG
    77     gpgme_ctx_t ctx;
    78 #elif defined(USE_NETPGP)
    79     pEpNetPGPSession ctx;
    80 #endif
    81 
    82     PEP_cryptotech_t *cryptotech;
    83     PEP_transport_t *transports;
    84 
    85     sqlite3 *db;
    86     sqlite3 *system_db;
    87 
    88     sqlite3_stmt *log;
    89     sqlite3_stmt *trustword;
    90     sqlite3_stmt *get_identity;
    91     sqlite3_stmt *set_person;
    92     sqlite3_stmt *set_pgp_keypair;
    93     sqlite3_stmt *set_identity;
    94     sqlite3_stmt *set_trust;
    95     sqlite3_stmt *get_trust;
    96     sqlite3_stmt *least_trust;
    97     sqlite3_stmt *mark_compromized;
    98     sqlite3_stmt *reset_trust;
    99     sqlite3_stmt *crashdump;
   100     sqlite3_stmt *blacklist_keys;
   101 
   102     examine_identity_t examine_identity;
   103     void *examine_management;
   104 } pEpSession;
   105 
   106 PEP_STATUS init_transport_system(PEP_SESSION session, bool in_first);
   107 void release_transport_system(PEP_SESSION session, bool out_last);
   108 
   109 #ifdef NDEBUG
   110 #define DEBUG_LOG(TITLE, ENTITY, DESC)
   111 #else
   112 #define DEBUG_LOG(TITLE, ENTITY, DESC) \
   113     log_event(session, (TITLE), (ENTITY), (DESC), "debug");
   114 #endif
   115