1
0

nullplug.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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, PlugLogType type, SockAddr *addr,
  9. int port, const char *err_msg, int err_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. // WINSCP
  25. /*.log =*/ nullplug_socket_log,
  26. /*.closing =*/ nullplug_closing,
  27. /*.receive =*/ nullplug_receive,
  28. /*.sent =*/ nullplug_sent,
  29. NULL, // WINSCP
  30. };
  31. static Plug nullplug_plug = { &nullplug_plugvt };
  32. /*
  33. * There's a singleton instance of nullplug, because it's not
  34. * interesting enough to worry about making more than one of them.
  35. */
  36. Plug *const nullplug = &nullplug_plug;