defs.h 3.5 KB

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