projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add the LBS_NOTIFY style to the list box in colouredit(), which was
[u/mdw/putty]
/
telnet.c
diff --git
a/telnet.c
b/telnet.c
index
283ea5b
..
7b6c0bf
100644
(file)
--- a/
telnet.c
+++ b/
telnet.c
@@
-1,7
+1,13
@@
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
+#ifndef AUTO_WINSOCK
+#ifdef WINSOCK_TWO
+#include <winsock2.h>
+#else
#include <winsock.h>
#include <winsock.h>
+#endif
+#endif
#include "putty.h"
#include "putty.h"
@@
-165,6
+171,11
@@
static void s_write (void *buf, int len) {
try_write();
}
try_write();
}
+static void c_write1(int c) {
+ char cc = (char)c;
+ from_backend(0, &cc, 1);
+}
+
static void log_option (char *sender, int cmd, int option) {
char buf[50];
sprintf(buf, "%s:\t%s %s", sender,
static void log_option (char *sender, int cmd, int option) {
char buf[50];
sprintf(buf, "%s:\t%s %s", sender,
@@
-583,6
+594,12
@@
static char *telnet_init (HWND hwnd, char *host, int port, char **realhost) {
* Set up SYNCH state.
*/
in_synch = FALSE;
* Set up SYNCH state.
*/
in_synch = FALSE;
+
+ /*
+ * We have no pre-session phase.
+ */
+ begin_session();
+
return NULL;
}
return NULL;
}
@@
-608,16
+625,22
@@
static int telnet_msg (WPARAM wParam, LPARAM lParam) {
if (s == INVALID_SOCKET)
return 1;
if (s == INVALID_SOCKET)
return 1;
- if (WSAGETSELECTERROR(lParam) != 0)
+ if (WSAGETSELECTERROR(lParam) != 0) {
+ closesocket(s);
+ s = INVALID_SOCKET;
return -WSAGETSELECTERROR(lParam);
return -WSAGETSELECTERROR(lParam);
+ }
switch (WSAGETSELECTEVENT(lParam)) {
case FD_READ:
case FD_CLOSE:
{
int clear_of_oob = 1;
switch (WSAGETSELECTEVENT(lParam)) {
case FD_READ:
case FD_CLOSE:
{
int clear_of_oob = 1;
- if (ioctlsocket (s, SIOCATMARK, &clear_of_oob) < 0 )
- return -20000-WSAGetLastError();
+
+ /* Don't check for error return; some shims don't support
+ * this ioctl.
+ */
+ ioctlsocket (s, SIOCATMARK, &clear_of_oob);
in_synch = !clear_of_oob;
in_synch = !clear_of_oob;
@@
-625,8
+648,11
@@
static int telnet_msg (WPARAM wParam, LPARAM lParam) {
ret = recv(s, buf, sizeof(buf), 0);
if (ret < 0 && WSAGetLastError() == WSAEWOULDBLOCK)
return 1;
ret = recv(s, buf, sizeof(buf), 0);
if (ret < 0 && WSAGetLastError() == WSAEWOULDBLOCK)
return 1;
- if (ret < 0) /* any _other_ error */
+ if (ret < 0) { /* any _other_ error */
+ closesocket(s);
+ s = INVALID_SOCKET;
return -10000-WSAGetLastError();
return -10000-WSAGetLastError();
+ }
if (ret == 0) {
s = INVALID_SOCKET;
return 0;
if (ret == 0) {
s = INVALID_SOCKET;
return 0;
@@
-729,6
+755,12
@@
static void telnet_special (Telnet_Special code) {
send_opt (o_echo.nsend, o_echo.option);
}
break;
send_opt (o_echo.nsend, o_echo.option);
}
break;
+ case TS_PING:
+ if (o_they_sga.state == ACTIVE) {
+ b[1] = NOP;
+ s_write (b, 2);
+ }
+ break;
}
}
}
}
@@
-743,5
+775,6
@@
Backend telnet_backend = {
telnet_size,
telnet_special,
telnet_socket,
telnet_size,
telnet_special,
telnet_socket,
- telnet_sendok
+ telnet_sendok,
+ 23
};
};