defs.h 3.1 KB

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