null-plug.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. .log = nullplug_log,
  23. .closing = nullplug_closing,
  24. .receive = nullplug_receive,
  25. .sent = nullplug_sent,
  26. };
  27. static Plug nullplug_plug = { &nullplug_plugvt };
  28. /*
  29. * There's a singleton instance of nullplug, because it's not
  30. * interesting enough to worry about making more than one of them.
  31. */
  32. Plug *const nullplug = &nullplug_plug;