Remove pth dependency
[platform/upstream/gpg2.git] / g10 / gpg.h
1 /* gpg.h - top level include file for gpg etc.
2  * Copyright (C) 2003, 2006, 2010 Free Software Foundation, Inc.
3  *
4  * This file is part of GnuPG.
5  *
6  * GnuPG is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * GnuPG is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see <https://www.gnu.org/licenses/>.
18  */
19 #ifndef GNUPG_G10_GPG_H
20 #define GNUPG_G10_GPG_H
21
22 /* Note, that this file should be the first one after the system
23    header files.  This is required to set the error source to the
24    correct value and may be of advantage if we ever have to do
25    special things. */
26
27 #ifdef HAVE_W32_SYSTEM
28 # define WIN32_LEAN_AND_MEAN 1
29 #endif
30
31 #ifdef GPG_ERR_SOURCE_DEFAULT
32 #error GPG_ERR_SOURCE_DEFAULT already defined
33 #endif
34 #define GPG_ERR_SOURCE_DEFAULT  GPG_ERR_SOURCE_GPG
35 #define map_assuan_err(a) \
36         map_assuan_err_with_source (GPG_ERR_SOURCE_DEFAULT, (a))
37 #include <gpg-error.h>
38 #include <gcrypt.h>
39
40
41 /* Number of bits we accept when reading or writing MPIs. */
42 #define MAX_EXTERN_MPI_BITS 16384
43
44 /* The maximum length of a binary fingerprints.  This is used to
45  * provide a static buffer and will be increased if we need to support
46  * longer fingerprints.  Warning: At some places we have some
47  * assumption on a 20 byte fingerprint.
48  * Watch out for FIXME(fingerprint) */
49 #define MAX_FINGERPRINT_LEN 32
50
51 /* The maximum length of a formatted fingerprint as returned by
52  * format_hexfingerprint().  */
53 #define MAX_FORMATTED_FINGERPRINT_LEN 60
54
55
56 /*
57    Forward declarations.
58  */
59
60 /* Object used to keep state locally to server.c . */
61 struct server_local_s;
62
63 /* Object used to keep state locally to call-keyboxd.c .  */
64 struct keyboxd_local_s;
65 typedef struct keyboxd_local_s *keyboxd_local_t;
66
67 /* Object used to keep state locally to call-dirmngr.c .  */
68 struct dirmngr_local_s;
69 typedef struct dirmngr_local_s *dirmngr_local_t;
70
71 /* Object used to describe a keyblock node.  */
72 typedef struct kbnode_struct *KBNODE;   /* Deprecated use kbnode_t. */typedef struct kbnode_struct *kbnode_t;
73
74 /* The handle for keydb operations.  */
75 typedef struct keydb_handle_s *KEYDB_HANDLE;
76
77 /* TOFU database meta object.  */
78 struct tofu_dbs_s;
79 typedef struct tofu_dbs_s *tofu_dbs_t;
80
81
82 #if SIZEOF_UNSIGNED_LONG == 8
83 # define SERVER_CONTROL_MAGIC 0x53616c696e676572
84 #else
85 # define SERVER_CONTROL_MAGIC 0x53616c69
86 #endif
87
88 /* Session control object.  This object is passed to most functions to
89    convey the status of a session.  Note that the defaults are set by
90    gpg_init_default_ctrl(). */
91 struct server_control_s
92 {
93   /* Always has the value SERVER_CONTROL_MAGIC.  */
94   unsigned long magic;
95
96   /* Local data for server.c  */
97   struct server_local_s *server_local;
98
99   /* Local data for call-dirmngr.c  */
100   dirmngr_local_t dirmngr_local;
101
102   /* Local data for call-keyboxd.c  */
103   keyboxd_local_t keyboxd_local;
104
105   /* Local data for tofu.c  */
106   struct {
107     tofu_dbs_t dbs;
108     int batch_updated_wanted;
109   } tofu;
110
111   /* This is used to cache a key data base handle.  */
112   KEYDB_HANDLE cached_getkey_kdb;
113
114   /* Cached results from HAVEKEY --list.  They are used if the pointer
115    * is not NULL.  The length gives the length in bytes and is a
116    * multiple of 20.  If the no_more flag is set the list shall not
117    * anymore be refreshed even if it has been freed and NULLed. */
118   unsigned char *secret_keygrips;
119   size_t secret_keygrips_len;
120   int no_more_secret_keygrips;
121 };
122
123
124
125 #endif /*GNUPG_G10_GPG_H*/