no-network.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Stub version of the whole networking abstraction.
  3. */
  4. #include "putty.h"
  5. #include "network.h"
  6. struct SockAddr {
  7. int dummy;
  8. };
  9. void sk_init(void)
  10. {
  11. }
  12. void sk_cleanup(void)
  13. {
  14. }
  15. SockAddr *sk_namelookup(const char *host, char **canonicalname,
  16. int address_family)
  17. {
  18. return snew(SockAddr);
  19. }
  20. SockAddr *sk_nonamelookup(const char *host)
  21. {
  22. return snew(SockAddr);
  23. }
  24. void sk_getaddr(SockAddr *addr, char *buf, int buflen)
  25. {
  26. strncpy(buf, "nonsense", buflen);
  27. }
  28. bool sk_addr_needs_port(SockAddr *addr)
  29. {
  30. return true;
  31. }
  32. bool sk_hostname_is_local(const char *name)
  33. {
  34. return false;
  35. }
  36. bool sk_address_is_local(SockAddr *addr)
  37. {
  38. return false;
  39. }
  40. bool sk_address_is_special_local(SockAddr *addr)
  41. {
  42. return false;
  43. }
  44. int sk_addrtype(SockAddr *addr)
  45. {
  46. return ADDRTYPE_UNSPEC;
  47. }
  48. void sk_addrcopy(SockAddr *addr, char *buf)
  49. {
  50. }
  51. void sk_addr_free(SockAddr *addr)
  52. {
  53. sfree(addr);
  54. }
  55. SockAddr *sk_addr_dup(SockAddr *addr)
  56. {
  57. return snew(SockAddr);
  58. }
  59. Socket *sk_new(SockAddr *addr, int port, bool privport, bool oobinline,
  60. bool nodelay, bool keepalive, Plug *plug)
  61. {
  62. return new_error_socket_fmt(
  63. plug, "no actual networking in this application");
  64. }
  65. Socket *sk_newlistener(const char *srcaddr, int port, Plug *plug,
  66. bool local_host_only, int orig_address_family)
  67. {
  68. return new_error_socket_fmt(
  69. plug, "no actual networking in this application");
  70. }
  71. void *(sk_getxdmdata)(Socket *sock, int *lenp)
  72. {
  73. return NULL;
  74. }
  75. void plug_closing_errno(Plug *plug, int error)
  76. {
  77. plug_closing(plug, PLUGCLOSE_ERROR, "dummy");
  78. }
  79. const char *sk_addr_error(SockAddr *addr)
  80. {
  81. return "no actual network addresses in this application";
  82. }
  83. int net_service_lookup(const char *service)
  84. {
  85. return 0;
  86. }
  87. char *get_hostname(void)
  88. {
  89. return dupstr("dummy-hostname");
  90. }
  91. SockAddr *platform_get_x11_unix_address(const char *sockpath, int displaynum)
  92. {
  93. return snew(SockAddr);
  94. }
  95. SockAddr *unix_sock_addr(const char *path)
  96. {
  97. return snew(SockAddr);
  98. }
  99. SockAddr *sk_namedpipe_addr(const char *pipename)
  100. {
  101. return snew(SockAddr);
  102. }
  103. Socket *new_unix_listener(SockAddr *listenaddr, Plug *plug)
  104. {
  105. return new_error_socket_fmt(
  106. plug, "no actual networking in this application");
  107. }
  108. Socket *platform_start_subprocess(const char *cmd, Plug *plug,
  109. const char *prefix)
  110. {
  111. return new_error_socket_fmt(
  112. plug, "no actual networking in this application");
  113. }
  114. #ifdef PUTTY_WINDOWS_PLATFORM_H
  115. void plug_closing_system_error(Plug *plug, DWORD error) {}
  116. void plug_closing_winsock_error(Plug *plug, DWORD error) {}
  117. #endif