null-plug.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. void nullplug_log(Plug *plug, Socket *s, PlugLogType type, SockAddr *addr,
  9. int port, const char *err_msg, int err_code)
  10. {
  11. }
  12. void nullplug_closing(Plug *plug, PlugCloseType type, const char *error_msg)
  13. {
  14. }
  15. void nullplug_receive(Plug *plug, int urgent, const char *data, size_t len)
  16. {
  17. }
  18. void nullplug_sent(Plug *plug, size_t bufsize)
  19. {
  20. }
  21. static const PlugVtable nullplug_plugvt = {
  22. // WINSCP
  23. /*.log =*/ nullplug_log,
  24. /*.closing =*/ nullplug_closing,
  25. /*.receive =*/ nullplug_receive,
  26. /*.sent =*/ nullplug_sent,
  27. NULL, // WINSCP
  28. };
  29. static Plug nullplug_plug = { &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 *const nullplug = &nullplug_plug;