defs.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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_tag *SockAddr;
  32. typedef struct Socket_vtable Socket_vtable;
  33. typedef struct Plug_vtable Plug_vtable;
  34. typedef struct Backend Backend;
  35. typedef struct Backend_vtable Backend_vtable;
  36. typedef struct Ldisc_tag Ldisc;
  37. typedef struct LogContext_tag LogContext;
  38. typedef struct Frontend Frontend;
  39. typedef struct ssh_tag *Ssh;
  40. typedef struct Channel Channel;
  41. typedef struct SshChannel SshChannel;
  42. typedef struct ssh_sharing_state ssh_sharing_state;
  43. typedef struct ssh_sharing_connstate ssh_sharing_connstate;
  44. typedef struct share_channel share_channel;
  45. typedef struct PortFwdManager PortFwdManager;
  46. typedef struct PortFwdRecord PortFwdRecord;
  47. typedef struct ConnectionLayer ConnectionLayer;
  48. typedef struct dlgparam dlgparam;
  49. typedef struct settings_w settings_w;
  50. typedef struct settings_r settings_r;
  51. typedef struct settings_e settings_e;
  52. typedef struct SessionSpecial SessionSpecial;
  53. /* Note indirection: for historical reasons (it used to be closer to
  54. * the OS socket type), the type that most code uses for a socket is
  55. * 'Socket', not 'Socket *'. So an implementation of Socket or Plug
  56. * has a 'const Socket *' field for the vtable pointer, and the
  57. * 'Socket' type returned to client code is a pointer to _that_ in
  58. * turn. */
  59. typedef const Socket_vtable **Socket;
  60. typedef const Plug_vtable **Plug;
  61. /*
  62. * A small structure wrapping up a (pointer, length) pair so that it
  63. * can be conveniently passed to or from a function.
  64. */
  65. typedef struct ptrlen {
  66. const void *ptr;
  67. size_t len;
  68. } ptrlen;
  69. typedef struct logblank_t logblank_t;
  70. typedef struct BinaryPacketProtocol BinaryPacketProtocol;
  71. typedef struct PacketProtocolLayer PacketProtocolLayer;
  72. /* Do a compile-time type-check of 'to_check' (without evaluating it),
  73. * as a side effect of returning the value 'to_return'. Note that
  74. * although this macro double-*expands* to_return, it always
  75. * *evaluates* exactly one copy of it, so it's side-effect safe. */
  76. #define TYPECHECK(to_check, to_return) \
  77. (sizeof(to_check) ? (to_return) : (to_return))
  78. /* Return a pointer to the object of structure type 'type' whose field
  79. * with name 'field' is pointed at by 'object'. */
  80. #define FROMFIELD(object, type, field) \
  81. TYPECHECK(object == &((type *)0)->field, \
  82. ((type *)(((char *)(object)) - offsetof(type, field))))
  83. #endif /* PUTTY_DEFS_H */