nullplug.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. bool calling_back)
  14. {
  15. }
  16. static void nullplug_receive(
  17. Plug *plug, int urgent, const char *data, size_t len)
  18. {
  19. }
  20. static void nullplug_sent(Plug *plug, size_t bufsize)
  21. {
  22. }
  23. static const PlugVtable nullplug_plugvt = {
  24. nullplug_socket_log,
  25. nullplug_closing,
  26. nullplug_receive,
  27. nullplug_sent,
  28. NULL
  29. };
  30. static Plug nullplug_plug = { &nullplug_plugvt };
  31. /*
  32. * There's a singleton instance of nullplug, because it's not
  33. * interesting enough to worry about making more than one of them.
  34. */
  35. Plug *const nullplug = &nullplug_plug;