defs.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * defs.h: initial definitions for PuTTY.
  3. *
  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. */
  10. #ifndef PUTTY_DEFS_H
  11. #define PUTTY_DEFS_H
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include <stdbool.h>
  15. #if defined _MSC_VER && _MSC_VER < 1800
  16. /* Work around lack of inttypes.h in older MSVC */
  17. #define PRIx32 "x"
  18. #define PRIu64 "I64u"
  19. #define SCNu64 "I64u"
  20. #else
  21. #include <inttypes.h>
  22. #endif
  23. typedef struct conf_tag Conf;
  24. typedef struct terminal_tag Terminal;
  25. typedef struct Filename Filename;
  26. typedef struct FontSpec FontSpec;
  27. typedef struct bufchain_tag bufchain;
  28. typedef struct strbuf strbuf;
  29. struct RSAKey;
  30. typedef struct BinarySink BinarySink;
  31. typedef struct BinarySource BinarySource;
  32. typedef struct IdempotentCallback IdempotentCallback;
  33. typedef struct SockAddr SockAddr;
  34. typedef struct Socket Socket;
  35. typedef struct Plug Plug;
  36. typedef struct SocketPeerInfo SocketPeerInfo;
  37. typedef struct Backend Backend;
  38. typedef struct BackendVtable BackendVtable;
  39. typedef struct Ldisc_tag Ldisc;
  40. typedef struct LogContext LogContext;
  41. typedef struct LogPolicy LogPolicy;
  42. typedef struct LogPolicyVtable LogPolicyVtable;
  43. typedef struct Seat Seat;
  44. typedef struct SeatVtable SeatVtable;
  45. typedef struct TermWin TermWin;
  46. typedef struct TermWinVtable TermWinVtable;
  47. typedef struct Ssh Ssh;
  48. typedef struct SftpServer SftpServer;
  49. typedef struct SftpServerVtable SftpServerVtable;
  50. typedef struct Channel Channel;
  51. typedef struct SshChannel SshChannel;
  52. typedef struct mainchan mainchan;
  53. typedef struct ssh_sharing_state ssh_sharing_state;
  54. typedef struct ssh_sharing_connstate ssh_sharing_connstate;
  55. typedef struct share_channel share_channel;
  56. typedef struct PortFwdManager PortFwdManager;
  57. typedef struct PortFwdRecord PortFwdRecord;
  58. typedef struct ConnectionLayer ConnectionLayer;
  59. typedef struct dlgparam dlgparam;
  60. typedef struct settings_w settings_w;
  61. typedef struct settings_r settings_r;
  62. typedef struct settings_e settings_e;
  63. typedef struct SessionSpecial SessionSpecial;
  64. /*
  65. * A small structure wrapping up a (pointer, length) pair so that it
  66. * can be conveniently passed to or from a function.
  67. */
  68. typedef struct ptrlen {
  69. const void *ptr;
  70. size_t len;
  71. } ptrlen;
  72. typedef struct logblank_t logblank_t;
  73. typedef struct BinaryPacketProtocol BinaryPacketProtocol;
  74. typedef struct PacketProtocolLayer PacketProtocolLayer;
  75. /* Do a compile-time type-check of 'to_check' (without evaluating it),
  76. * as a side effect of returning the value 'to_return'. Note that
  77. * although this macro double-*expands* to_return, it always
  78. * *evaluates* exactly one copy of it, so it's side-effect safe. */
  79. #define TYPECHECK(to_check, to_return) \
  80. (sizeof(to_check) ? (to_return) : (to_return))
  81. /* Return a pointer to the object of structure type 'type' whose field
  82. * with name 'field' is pointed at by 'object'. */
  83. #define container_of(object, type, field) \
  84. TYPECHECK(object == &((type *)0)->field, \
  85. ((type *)(((char *)(object)) - offsetof(type, field))))
  86. #if defined __GNUC__ || defined __clang__
  87. #define NORETURN __attribute__((__noreturn__))
  88. #else
  89. #define NORETURN
  90. #endif
  91. #endif /* PUTTY_DEFS_H */