Upgrade libgit2
[TortoiseGit.git] / src / TortoisePlink / defs.h
blobaf16d0eacf0f23e98a35f614c752c1b298f836b9
1 /*
2 * defs.h: initial definitions for PuTTY.
4 * The rule about this header file is that it can't depend on any
5 * other header file in this code base. This is where we define
6 * things, as much as we can, that other headers will want to refer
7 * to, such as opaque structure types and their associated typedefs,
8 * or macros that are used by other headers.
9 */
11 #ifndef PUTTY_DEFS_H
12 #define PUTTY_DEFS_H
14 #ifdef NDEBUG
16 * PuTTY is a security project, so assertions are important - if an
17 * assumption is violated, proceeding anyway may have far worse
18 * consequences than simple program termination. This check and #error
19 * should arrange that we don't ever accidentally compile assertions
20 * out.
22 #error Do not compile this code base with NDEBUG defined!
23 #endif
25 #if HAVE_CMAKE_H
26 #include "cmake.h"
27 #endif
29 #include <stddef.h>
30 #include <stdint.h>
31 #include <stdio.h> /* for __MINGW_PRINTF_FORMAT */
32 #include <stdbool.h>
34 #if defined _MSC_VER && _MSC_VER < 1800
35 /* Work around lack of inttypes.h and strtoumax in older MSVC */
36 #define PRIx32 "x"
37 #define PRIu32 "u"
38 #define PRIu64 "I64u"
39 #define PRIdMAX "I64d"
40 #define PRIXMAX "I64X"
41 #define SCNu64 "I64u"
42 #define SIZEx "Ix"
43 #define SIZEu "Iu"
44 uintmax_t strtoumax(const char *nptr, char **endptr, int base);
45 /* Also, define a LEGACY_WINDOWS flag to enable other workarounds */
46 #define LEGACY_WINDOWS
47 #else
48 #include <inttypes.h>
49 /* Because we still support older MSVC libraries which don't recognise the
50 * standard C "z" modifier for size_t-sized integers, we must use an
51 * inttypes.h-style macro for those */
52 #define SIZEx "zx"
53 #define SIZEu "zu"
54 #endif
56 #if defined __GNUC__ || defined __clang__
58 * On MinGW, the correct compiler format checking for vsnprintf() etc
59 * can depend on compile-time flags; these control whether you get
60 * ISO C or Microsoft's non-standard format strings.
61 * We sometimes use __attribute__ ((format)) for our own printf-like
62 * functions, which are ultimately interpreted by the toolchain-chosen
63 * printf, so we need to take that into account to get correct warnings.
65 #ifdef __MINGW_PRINTF_FORMAT
66 #define PRINTF_LIKE(fmt_index, ellipsis_index) \
67 __attribute__ ((format (__MINGW_PRINTF_FORMAT, fmt_index, ellipsis_index)))
68 #else
69 #define PRINTF_LIKE(fmt_index, ellipsis_index) \
70 __attribute__ ((format (printf, fmt_index, ellipsis_index)))
71 #endif
72 #else /* __GNUC__ */
73 #define PRINTF_LIKE(fmt_index, ellipsis_index)
74 #endif /* __GNUC__ */
76 typedef struct conf_tag Conf;
77 typedef struct terminal_tag Terminal;
78 typedef struct term_utf8_decode term_utf8_decode;
80 typedef struct Filename Filename;
81 typedef struct FontSpec FontSpec;
83 typedef struct bufchain_tag bufchain;
85 typedef struct strbuf strbuf;
86 typedef struct LoadedFile LoadedFile;
88 typedef struct RSAKey RSAKey;
90 typedef struct BinarySink BinarySink;
91 typedef struct BinarySource BinarySource;
92 typedef struct stdio_sink stdio_sink;
93 typedef struct bufchain_sink bufchain_sink;
94 typedef struct handle_sink handle_sink;
96 typedef struct IdempotentCallback IdempotentCallback;
98 typedef struct SockAddr SockAddr;
100 typedef struct Socket Socket;
101 typedef struct Plug Plug;
102 typedef struct SocketPeerInfo SocketPeerInfo;
103 typedef struct DeferredSocketOpener DeferredSocketOpener;
104 typedef struct DeferredSocketOpenerVtable DeferredSocketOpenerVtable;
106 typedef struct Backend Backend;
107 typedef struct BackendVtable BackendVtable;
108 typedef struct Interactor Interactor;
109 typedef struct InteractorVtable InteractorVtable;
110 typedef struct InteractionReadySeat InteractionReadySeat;
112 typedef struct Ldisc_tag Ldisc;
113 typedef struct LogContext LogContext;
114 typedef struct LogPolicy LogPolicy;
115 typedef struct LogPolicyVtable LogPolicyVtable;
117 typedef struct Seat Seat;
118 typedef struct SeatVtable SeatVtable;
119 typedef struct SeatDialogText SeatDialogText;
120 typedef struct SeatDialogTextItem SeatDialogTextItem;
121 typedef struct SeatDialogPromptDescriptions SeatDialogPromptDescriptions;
122 typedef struct SeatPromptResult SeatPromptResult;
124 typedef struct cmdline_get_passwd_input_state cmdline_get_passwd_input_state;
126 typedef struct TermWin TermWin;
127 typedef struct TermWinVtable TermWinVtable;
129 typedef struct Ssh Ssh;
131 typedef struct mp_int mp_int;
132 typedef struct MontyContext MontyContext;
134 typedef struct WeierstrassCurve WeierstrassCurve;
135 typedef struct WeierstrassPoint WeierstrassPoint;
136 typedef struct MontgomeryCurve MontgomeryCurve;
137 typedef struct MontgomeryPoint MontgomeryPoint;
138 typedef struct EdwardsCurve EdwardsCurve;
139 typedef struct EdwardsPoint EdwardsPoint;
141 typedef struct SshServerConfig SshServerConfig;
142 typedef struct SftpServer SftpServer;
143 typedef struct SftpServerVtable SftpServerVtable;
145 typedef struct Channel Channel;
146 typedef struct SshChannel SshChannel;
147 typedef struct mainchan mainchan;
149 typedef struct CertExprBuilder CertExprBuilder;
151 typedef struct ssh_sharing_state ssh_sharing_state;
152 typedef struct ssh_sharing_connstate ssh_sharing_connstate;
153 typedef struct share_channel share_channel;
155 typedef struct PortFwdManager PortFwdManager;
156 typedef struct PortFwdRecord PortFwdRecord;
157 typedef struct ConnectionLayer ConnectionLayer;
159 typedef struct prng prng;
160 typedef struct ssh_hashalg ssh_hashalg;
161 typedef struct ssh_hash ssh_hash;
162 typedef struct ssh_kex ssh_kex;
163 typedef struct ssh_kexes ssh_kexes;
164 typedef struct ssh_keyalg ssh_keyalg;
165 typedef struct ssh_key ssh_key;
166 typedef struct ssh_compressor ssh_compressor;
167 typedef struct ssh_decompressor ssh_decompressor;
168 typedef struct ssh_compression_alg ssh_compression_alg;
169 typedef struct ssh2_userkey ssh2_userkey;
170 typedef struct ssh2_macalg ssh2_macalg;
171 typedef struct ssh2_mac ssh2_mac;
172 typedef struct ssh_cipheralg ssh_cipheralg;
173 typedef struct ssh_cipher ssh_cipher;
174 typedef struct ssh2_ciphers ssh2_ciphers;
175 typedef struct dh_ctx dh_ctx;
176 typedef struct ecdh_key ecdh_key;
177 typedef struct ecdh_keyalg ecdh_keyalg;
178 typedef struct NTRUKeyPair NTRUKeyPair;
179 typedef struct NTRUEncodeSchedule NTRUEncodeSchedule;
181 typedef struct dlgparam dlgparam;
182 typedef struct dlgcontrol dlgcontrol;
184 typedef struct settings_w settings_w;
185 typedef struct settings_r settings_r;
186 typedef struct settings_e settings_e;
187 typedef struct ca_options ca_options;
188 typedef struct host_ca host_ca;
189 typedef struct host_ca_enum host_ca_enum;
191 typedef struct SessionSpecial SessionSpecial;
193 typedef struct StripCtrlChars StripCtrlChars;
195 typedef struct BidiContext BidiContext;
198 * A small structure wrapping up a (pointer, length) pair so that it
199 * can be conveniently passed to or from a function.
201 typedef struct ptrlen {
202 const void *ptr;
203 size_t len;
204 } ptrlen;
206 typedef struct logblank_t logblank_t;
208 typedef struct BinaryPacketProtocol BinaryPacketProtocol;
209 typedef struct PacketProtocolLayer PacketProtocolLayer;
211 struct unicode_data;
213 /* Do a compile-time type-check of 'to_check' (without evaluating it),
214 * as a side effect of returning the value 'to_return'. Note that
215 * although this macro double-*expands* to_return, it always
216 * *evaluates* exactly one copy of it, so it's side-effect safe. */
217 #define TYPECHECK(to_check, to_return) \
218 (sizeof(to_check) ? (to_return) : (to_return))
220 /* Return a pointer to the object of structure type 'type' whose field
221 * with name 'field' is pointed at by 'object'. */
222 #define container_of(object, type, field) \
223 TYPECHECK(object == &((type *)0)->field, \
224 ((type *)(((char *)(object)) - offsetof(type, field))))
226 #if defined __GNUC__ || defined __clang__
227 #define NORETURN __attribute__((__noreturn__))
228 #elif defined _MSC_VER
229 #define NORETURN __declspec(noreturn)
230 #else
231 #define NORETURN
232 #endif
235 * Standard macro definitions. STR() behaves like the preprocessor
236 * stringification # operator, and CAT() behaves like the token paste
237 * ## operator, except that each one macro-expands its argument(s)
238 * first, unlike the raw version. E.g.
240 * #__LINE__ -> "__LINE__"
241 * STR(__LINE__) -> "1234" (or whatever)
243 * and similarly,
245 * foo ## __LINE__ -> foo__LINE__
246 * CAT(foo, __LINE__) -> foo1234 (or whatever)
248 * The expansion is achieved by having each macro pass its arguments
249 * to a secondary inner macro, because parameter lists of a macro call
250 * get expanded before the called macro is invoked. So STR(__LINE__)
251 * -> STR_INNER(1234) -> #1234 -> "1234", and similarly for CAT.
253 #define STR_INNER(x) #x
254 #define STR(x) STR_INNER(x)
255 #define CAT_INNER(x,y) x ## y
256 #define CAT(x,y) CAT_INNER(x,y)
259 * Structure shared between ssh.h and storage.h, giving strictness
260 * options relating to checking of an OpenSSH certificate. It's a bit
261 * cheaty to put something so specific in here, but more painful to
262 * put it in putty.h.
264 struct ca_options {
265 bool permit_rsa_sha1, permit_rsa_sha256, permit_rsa_sha512;
268 #endif /* PUTTY_DEFS_H */