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