This commit is contained in:
y4my4my4m 2023-05-02 03:54:36 +09:00
parent 7beb6c69a4
commit f212ff574a

View file

@ -70,7 +70,6 @@ U0 SendTerminalType(I64 sock, U8 *terminal_type) {
response[len + 5] = 0xF0; // SE response[len + 5] = 0xF0; // SE
response[len + 6] = '\0'; response[len + 6] = '\0';
TCPSocketSendString(sock, response); TCPSocketSendString(sock, response);
// Free(response); ??
} }
U0 HandleControlCodes(U8 ch) { U0 HandleControlCodes(U8 ch) {
@ -112,6 +111,12 @@ U0 HandleControlCodes(U8 ch) {
} }
} else { } else {
// SysLog("Code: 0x%02X\n", ch); // SysLog("Code: 0x%02X\n", ch);
// FIXME
// Need to escape the dollar sign
if (ch == 0x24) {
ch = "//$$$$";
}
"%c", ch; "%c", ch;
} }
} }
@ -125,6 +130,7 @@ U0 HandleMCICode(U8 *ptr, I64 *index) {
// // Handle ET1 MCI code here // // Handle ET1 MCI code here
// } // }
// SysLog("MCI code: %s\n", code); // SysLog("MCI code: %s\n", code);
SysLog("MCI Code not implemented\n");
// Add support for other MCI codes if needed // Add support for other MCI codes if needed
} }
@ -168,7 +174,7 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
U8 option_code = *(ptr + 2); U8 option_code = *(ptr + 2);
// Send a response to the server // Send a response to the server
U8 response[3]; U8 response[4];
response[0] = 0xFF; // IAC response[0] = 0xFF; // IAC
if (negotiation_code == 0xFD || negotiation_code == 0xFE) { // DO or DONT if (negotiation_code == 0xFD || negotiation_code == 0xFE) { // DO or DONT
@ -190,11 +196,8 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
response[2] = option_code; response[2] = option_code;
response[3] = '\0'; response[3] = '\0';
TCPSocketSendString(sock, response); TCPSocketSendString(sock, response);
Sleep(5000);
SendTerminalType(sock, "ANSI"); SendTerminalType(sock, "ANSI");
// Sleep(1000); SendWindowSize(sock, 25, 80);
// SendWindowSize(sock, 25, 80);
ptr += 3;
} else { } else {
response[1] = 0xFC; // WONT response[1] = 0xFC; // WONT
} }
@ -300,7 +303,8 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
"\n$$RED$$$BK,1$Input$BK,0$$$BLACK$$: "; "\n$$RED$$$BK,1$Input$BK,0$$$BLACK$$: ";
U8 *line = input_buffer; U8 *line = input_buffer;
U8 *end_of_line = line; // U8 *end_of_line = line;
input_len = 0;
while (1) { while (1) {
// switch (KeyGet(&sc)) // switch (KeyGet(&sc))
// { // {
@ -351,19 +355,18 @@ U0 Telnet(U8 *host, U16 port=TELNET_PORT) {
// } // }
// } // }
// *line++ = ch; // *line++ = ch;
input_buffer[input_len++] = ch;
"%c", ch; "%c", ch;
} }
input_buffer[input_len] = '\0';
// *line++ = '\r'; // *line++ = '\r';
// *line++ = '\n'; // *line++ = '\n';
// *line = '\0'; // *line = '\0';
if (!force_disconnect) { if (!force_disconnect) {
// SysLog("Sending: %s\n", input_buffer); input_buffer[input_len++] = '\r';
TCPSocketSendString(sock, input_buffer); input_buffer[input_len++] = '\n';
// input_buffer[BUF_SIZE] = 0; TCPSocketSend(sock, input_buffer, input_len);
// cant send line? its not a string but input_buffer is?
// TCPSocketSendString(sock, line);
// TCPSocketSend(sock, line, 16);
} else { } else {
"Force disconnecting...\n"; "Force disconnecting...\n";
goto disconnect; goto disconnect;
@ -397,10 +400,13 @@ U0 TelnetPrompt() {
} }
// Dev auto-connect to test server // Dev auto-connect to test server
// Telnet("mbrserver.com"); Telnet("mbrserver.com");
// Telnet("freechess.org"); // Telnet("freechess.org");
// Telnet("dura-bbs.net", 6359); // Telnet("dura-bbs.net", 6359);
// Telnet("darkrealms.ca"); // Telnet("darkrealms.ca");
// good to test refresh, line feed, etc
// Telnet("20forbeers.com", 1337);
// ZealBBS dev server // ZealBBS dev server
Telnet("localhost", 8888); // Telnet("localhost", 8888);