Fixed issue #4132: Error "Could not get next commit. libgit returns: -4" in Log Messa...
[TortoiseGit.git] / src / TortoisePlink / defs.h
blob9012a99561412140f16b9cbee2516b7934f256ce
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;
180 typedef struct RFC6979 RFC6979;
181 typedef struct RFC6979Result RFC6979Result;
183 typedef struct dlgparam dlgparam;
184 typedef struct dlgcontrol dlgcontrol;
186 typedef struct settings_w settings_w;
187 typedef struct settings_r settings_r;
188 typedef struct settings_e settings_e;
189 typedef struct ca_options ca_options;
190 typedef struct host_ca host_ca;
191 typedef struct host_ca_enum host_ca_enum;
193 typedef struct SessionSpecial SessionSpecial;
195 typedef struct StripCtrlChars StripCtrlChars;
197 typedef struct BidiContext BidiContext;
200 * A small structure wrapping up a (pointer, length) pair so that it
201 * can be conveniently passed to or from a function.
203 typedef struct ptrlen {
204 const void *ptr;
205 size_t len;
206 } ptrlen;
208 typedef struct logblank_t logblank_t;
210 typedef struct BinaryPacketProtocol BinaryPacketProtocol;
211 typedef struct PacketProtocolLayer PacketProtocolLayer;
213 struct unicode_data;
215 /* Do a compile-time type-check of 'to_check' (without evaluating it),
216 * as a side effect of returning the value 'to_return'. Note that
217 * although this macro double-*expands* to_return, it always
218 * *evaluates* exactly one copy of it, so it's side-effect safe. */
219 #define TYPECHECK(to_check, to_return) \
220 (sizeof(to_check) ? (to_return) : (to_return))
222 /* Return a pointer to the object of structure type 'type' whose field
223 * with name 'field' is pointed at by 'object'. */
224 #define container_of(object, type, field) \
225 TYPECHECK(object == &((type *)0)->field, \
226 ((type *)(((char *)(object)) - offsetof(type, field))))
228 #if defined __GNUC__ || defined __clang__
229 #define NORETURN __attribute__((__noreturn__))
230 #elif defined _MSC_VER
231 #define NORETURN __declspec(noreturn)
232 #else
233 #define NORETURN
234 #endif
237 * Standard macro definitions. STR() behaves like the preprocessor
238 * stringification # operator, and CAT() behaves like the token paste
239 * ## operator, except that each one macro-expands its argument(s)
240 * first, unlike the raw version. E.g.
242 * #__LINE__ -> "__LINE__"
243 * STR(__LINE__) -> "1234" (or whatever)
245 * and similarly,
247 * foo ## __LINE__ -> foo__LINE__
248 * CAT(foo, __LINE__) -> foo1234 (or whatever)
250 * The expansion is achieved by having each macro pass its arguments
251 * to a secondary inner macro, because parameter lists of a macro call
252 * get expanded before the called macro is invoked. So STR(__LINE__)
253 * -> STR_INNER(1234) -> #1234 -> "1234", and similarly for CAT.
255 #define STR_INNER(x) #x
256 #define STR(x) STR_INNER(x)
257 #define CAT_INNER(x,y) x ## y
258 #define CAT(x,y) CAT_INNER(x,y)
261 * Structure shared between ssh.h and storage.h, giving strictness
262 * options relating to checking of an OpenSSH certificate. It's a bit
263 * cheaty to put something so specific in here, but more painful to
264 * put it in putty.h.
266 struct ca_options {
267 bool permit_rsa_sha1, permit_rsa_sha256, permit_rsa_sha512;
270 #endif /* PUTTY_DEFS_H */