nullplug.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * nullplug.c: provide a null implementation of the Plug vtable which
  3. * ignores all calls. Occasionally useful in cases where we want to
  4. * make a network connection just to see if it works, but not do
  5. * anything with it afterwards except close it again.
  6. */
  7. #include "putty.h"
  8. static void nullplug_socket_log(Plug plug, int type, SockAddr addr, int port,
  9. const char *error_msg, int error_code)
  10. {
  11. }
  12. static void nullplug_closing(Plug plug, const char *error_msg, int error_code,
  13. int calling_back)
  14. {
  15. }
  16. static void nullplug_receive(Plug plug, int urgent, char *data, int len)
  17. {
  18. }
  19. static void nullplug_sent(Plug plug, int bufsize)
  20. {
  21. }
  22. static const Plug_vtable nullplug_plugvt = {
  23. nullplug_socket_log,
  24. nullplug_closing,
  25. nullplug_receive,
  26. nullplug_sent,
  27. NULL
  28. };
  29. static const Plug_vtable *nullplug_plugvt_ptr = &nullplug_plugvt;
  30. /*
  31. * There's a singleton instance of nullplug, because it's not
  32. * interesting enough to worry about making more than one of them.
  33. */
  34. Plug nullplug = &nullplug_plugvt_ptr;