testback.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (c) 1999 Simon Tatham
  3. * Copyright (c) 1999 Ben Harris
  4. * All rights reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person
  7. * obtaining a copy of this software and associated documentation
  8. * files (the "Software"), to deal in the Software without
  9. * restriction, including without limitation the rights to use,
  10. * copy, modify, merge, publish, distribute, sublicense, and/or
  11. * sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following
  13. * conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be
  16. * included in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  21. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  22. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  23. * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  25. * SOFTWARE.
  26. */
  27. /* PuTTY test backends */
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30. #include "putty.h"
  31. static const char *null_init(void *, void **, Conf *, char *, int, char **,
  32. int, int);
  33. static const char *loop_init(void *, void **, Conf *, char *, int, char **,
  34. int, int);
  35. static void null_free(void *);
  36. static void loop_free(void *);
  37. static void null_reconfig(void *, Conf *);
  38. static int null_send(void *, char *, int);
  39. static int loop_send(void *, char *, int);
  40. static int null_sendbuffer(void *);
  41. static void null_size(void *, int, int);
  42. static void null_special(void *, Telnet_Special);
  43. static const struct telnet_special *null_get_specials(void *handle);
  44. static int null_connected(void *);
  45. static int null_exitcode(void *);
  46. static int null_sendok(void *);
  47. static int null_ldisc(void *, int);
  48. static void null_provide_ldisc(void *, void *);
  49. static void null_provide_logctx(void *, void *);
  50. static void null_unthrottle(void *, int);
  51. static int null_cfg_info(void *);
  52. Backend null_backend = {
  53. null_init, null_free, null_reconfig, null_send, null_sendbuffer, null_size,
  54. null_special, null_get_specials, null_connected, null_exitcode, null_sendok,
  55. null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle,
  56. null_cfg_info, NULL /* test_for_upstream */, "null", -1, 0
  57. };
  58. Backend loop_backend = {
  59. loop_init, loop_free, null_reconfig, loop_send, null_sendbuffer, null_size,
  60. null_special, null_get_specials, null_connected, null_exitcode, null_sendok,
  61. null_ldisc, null_provide_ldisc, null_provide_logctx, null_unthrottle,
  62. null_cfg_info, NULL /* test_for_upstream */, "loop", -1, 0
  63. };
  64. struct loop_state {
  65. Terminal *term;
  66. };
  67. static const char *null_init(void *frontend_handle, void **backend_handle,
  68. Conf *conf, char *host, int port,
  69. char **realhost, int nodelay, int keepalive) {
  70. return NULL;
  71. }
  72. static const char *loop_init(void *frontend_handle, void **backend_handle,
  73. Conf *conf, char *host, int port,
  74. char **realhost, int nodelay, int keepalive) {
  75. struct loop_state *st = snew(struct loop_state);
  76. st->term = frontend_handle;
  77. *backend_handle = st;
  78. return NULL;
  79. }
  80. static void null_free(void *handle)
  81. {
  82. }
  83. static void loop_free(void *handle)
  84. {
  85. sfree(handle);
  86. }
  87. static void null_reconfig(void *handle, Conf *conf) {
  88. }
  89. static int null_send(void *handle, char *buf, int len) {
  90. return 0;
  91. }
  92. static int loop_send(void *handle, char *buf, int len) {
  93. struct loop_state *st = handle;
  94. return from_backend(st->term, 0, buf, len);
  95. }
  96. static int null_sendbuffer(void *handle) {
  97. return 0;
  98. }
  99. static void null_size(void *handle, int width, int height) {
  100. }
  101. static void null_special(void *handle, Telnet_Special code) {
  102. }
  103. static const struct telnet_special *null_get_specials (void *handle) {
  104. return NULL;
  105. }
  106. static int null_connected(void *handle) {
  107. return 0;
  108. }
  109. static int null_exitcode(void *handle) {
  110. return 0;
  111. }
  112. static int null_sendok(void *handle) {
  113. return 1;
  114. }
  115. static void null_unthrottle(void *handle, int backlog) {
  116. }
  117. static int null_ldisc(void *handle, int option) {
  118. return 0;
  119. }
  120. static void null_provide_ldisc (void *handle, void *ldisc) {
  121. }
  122. static void null_provide_logctx(void *handle, void *logctx) {
  123. }
  124. static int null_cfg_info(void *handle)
  125. {
  126. return 0;
  127. }
  128. /*
  129. * Emacs magic:
  130. * Local Variables:
  131. * c-file-style: "simon"
  132. * End:
  133. */