defs.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 TermWin TermWin;
  44. typedef struct TermWinVtable TermWinVtable;
  45. typedef struct Ssh Ssh;
  46. typedef struct SftpServer SftpServer;
  47. typedef struct SftpServerVtable SftpServerVtable;
  48. typedef struct Channel Channel;
  49. typedef struct SshChannel SshChannel;
  50. typedef struct mainchan mainchan;
  51. typedef struct ssh_sharing_state ssh_sharing_state;
  52. typedef struct ssh_sharing_connstate ssh_sharing_connstate;
  53. typedef struct share_channel share_channel;
  54. typedef struct PortFwdManager PortFwdManager;
  55. typedef struct PortFwdRecord PortFwdRecord;
  56. typedef struct ConnectionLayer ConnectionLayer;
  57. typedef struct dlgparam dlgparam;
  58. typedef struct settings_w settings_w;
  59. typedef struct settings_r settings_r;
  60. typedef struct settings_e settings_e;
  61. typedef struct SessionSpecial SessionSpecial;
  62. /*
  63. * A small structure wrapping up a (pointer, length) pair so that it
  64. * can be conveniently passed to or from a function.
  65. */
  66. typedef struct ptrlen {
  67. const void *ptr;
  68. size_t len;
  69. } ptrlen;
  70. typedef struct logblank_t logblank_t;
  71. typedef struct BinaryPacketProtocol BinaryPacketProtocol;
  72. typedef struct PacketProtocolLayer PacketProtocolLayer;
  73. /* Do a compile-time type-check of 'to_check' (without evaluating it),
  74. * as a side effect of returning the value 'to_return'. Note that
  75. * although this macro double-*expands* to_return, it always
  76. * *evaluates* exactly one copy of it, so it's side-effect safe. */
  77. #define TYPECHECK(to_check, to_return) \
  78. (sizeof(to_check) ? (to_return) : (to_return))
  79. /* Return a pointer to the object of structure type 'type' whose field
  80. * with name 'field' is pointed at by 'object'. */
  81. #define container_of(object, type, field) \
  82. TYPECHECK(object == &((type *)0)->field, \
  83. ((type *)(((char *)(object)) - offsetof(type, field))))
  84. #endif /* PUTTY_DEFS_H */