defs.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 SockAddr_tag *SockAddr;
  31. typedef struct Socket_vtable Socket_vtable;
  32. typedef struct Plug_vtable Plug_vtable;
  33. typedef struct Backend Backend;
  34. typedef struct Backend_vtable Backend_vtable;
  35. typedef struct Ldisc_tag Ldisc;
  36. typedef struct LogContext_tag LogContext;
  37. typedef struct Frontend Frontend;
  38. typedef struct ssh_tag *Ssh;
  39. typedef struct Channel Channel;
  40. typedef struct SshChannel SshChannel;
  41. typedef struct ssh_sharing_state ssh_sharing_state;
  42. typedef struct ssh_sharing_connstate ssh_sharing_connstate;
  43. typedef struct share_channel share_channel;
  44. typedef struct PortFwdManager PortFwdManager;
  45. typedef struct PortFwdRecord PortFwdRecord;
  46. typedef struct ConnectionLayer ConnectionLayer;
  47. typedef struct dlgparam dlgparam;
  48. typedef struct settings_w settings_w;
  49. typedef struct settings_r settings_r;
  50. typedef struct settings_e settings_e;
  51. typedef struct SessionSpecial SessionSpecial;
  52. /* Note indirection: for historical reasons (it used to be closer to
  53. * the OS socket type), the type that most code uses for a socket is
  54. * 'Socket', not 'Socket *'. So an implementation of Socket or Plug
  55. * has a 'const Socket *' field for the vtable pointer, and the
  56. * 'Socket' type returned to client code is a pointer to _that_ in
  57. * turn. */
  58. typedef const Socket_vtable **Socket;
  59. typedef const Plug_vtable **Plug;
  60. /*
  61. * A small structure wrapping up a (pointer, length) pair so that it
  62. * can be conveniently passed to or from a function.
  63. */
  64. typedef struct ptrlen {
  65. const void *ptr;
  66. size_t len;
  67. } ptrlen;
  68. typedef struct logblank_t logblank_t;
  69. typedef struct BinaryPacketProtocol BinaryPacketProtocol;
  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 FROMFIELD(object, type, field) \
  79. TYPECHECK(object == &((type *)0)->field, \
  80. ((type *)(((char *)(object)) - offsetof(type, field))))
  81. #endif /* PUTTY_DEFS_H */