]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Initial simple raw TCP backend
authorBen Harris <bjh21@bjh21.me.uk>
Wed, 1 Sep 1999 22:16:15 +0000 (22:16 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Wed, 1 Sep 1999 22:16:15 +0000 (22:16 +0000)
[originally from svn r211]

mac_res.r
macterm.c
testback.c

index d6183a122b676d7b8c3f7bc571f6c7a965206e21..ad93f082529a7ddb7168c94d3ba9e783ba48a48e 100644 (file)
--- a/mac_res.r
+++ b/mac_res.r
@@ -1,4 +1,4 @@
-/* $Id: mac_res.r,v 1.1.2.17 1999/04/02 12:58:02 ben Exp $ */
+/* $Id: mac_res.r,v 1.1.2.18 1999/09/01 22:16:15 ben Exp $ */
 /*
  * Copyright (c) 1999 Ben Harris
  * All rights reserved.
@@ -556,7 +556,7 @@ resource 'pSET' (PREF_settings, "settings", purgeable) {
     no_implicit_copy,
 #define PREF_strings 1024
     PREF_strings, 1,           /* host 'STR#' */
-    23, prot_telnet,           /* port, protocol */
+    7, prot_telnet,            /* port, protocol */
     PREF_strings, 2,           /* termtype 'STR#' */
     PREF_strings, 3,           /* termspeed 'STR#' */
     PREF_strings, 4,           /* environmt 'STR#' */
@@ -573,7 +573,7 @@ resource 'pSET' (PREF_settings, "settings", purgeable) {
 
 resource 'STR#' (PREF_strings, "strings", purgeable) {
     {
-       "nowhere.loopback.edu",
+       "172.17.11.11",
        "xterm",
        "38400,38400",
        "\000",
index d310ad57768ca0c559285ac7719c527c4077e506..7a44417ff9f5598a007cf85073da66af620a96b0 100644 (file)
--- a/macterm.c
+++ b/macterm.c
@@ -1,4 +1,4 @@
-/* $Id: macterm.c,v 1.1.2.35 1999/07/24 15:51:12 ben Exp $ */
+/* $Id: macterm.c,v 1.1.2.36 1999/09/01 22:16:15 ben Exp $ */
 /*
  * Copyright (c) 1999 Simon Tatham
  * Copyright (c) 1999 Ben Harris
@@ -135,7 +135,7 @@ void mac_newsession(void) {
     s = smalloc(sizeof(*s));
     memset(s, 0, sizeof(*s));
     mac_loadconfig(&s->cfg);
-    s->back = &null_backend;
+    s->back = &rawtcp_backend;
        
     /* XXX: Own storage management? */
     if (HAVE_COLOR_QD())
@@ -156,11 +156,13 @@ void mac_newsession(void) {
     }
     ShowWindow(s->window);
     s->back->init(s);
+#if 0
     starttime = TickCount();
     display_resource(s, 'pTST', 128);
     sprintf(msg, "Elapsed ticks: %d\015\012", TickCount() - starttime);
     inbuf_putstr(s, msg);
     term_out(s);
+#endif
 }
 
 static void mac_initfont(Session *s) {
index b5299a4757935eab6acf1882e7a27ce39745a823..b3f01e90e0fdbf15c3e50293b3553bdeb2821a4f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: testback.c,v 1.1.2.7 1999/08/02 08:04:31 ben Exp $ */
+/* $Id: testback.c,v 1.1.2.8 1999/09/01 22:16:15 ben Exp $ */
 /*
  * Copyright (c) 1999 Simon Tatham
  * Copyright (c) 1999 Ben Harris
@@ -40,6 +40,8 @@ static void loop_send(Session *, char *, int);
 static void hexdump_send(Session *, char *, int);
 static void null_size(Session *);
 static void null_special(Session *, Telnet_Special);
+static char *rawtcp_init(Session *);
+static int rawtcp_msg(Session *, SOCKET, Net_Event_Type);
 
 Backend null_backend = {
     null_init, null_msg, null_send, null_size, null_special
@@ -53,6 +55,10 @@ Backend hexdump_backend = {
     null_init, null_msg, hexdump_send, null_size, null_special
 };
 
+Backend rawtcp_backend = {
+    rawtcp_init, rawtcp_msg, null_send, null_size, null_special
+};
+
 static char *null_init(Session *s) {
 
     return NULL;
@@ -99,6 +105,56 @@ static void null_special(Session *s, Telnet_Special code) {
 
 }
 
+struct rawtcp_private {
+    SOCKET s;
+};
+
+static char *rawtcp_init(Session *sess) {
+    struct rawtcp_private *rp;
+
+    sess->back_priv = smalloc(sizeof(struct rawtcp_private));
+    rp = (struct rawtcp_private *)sess->back_priv;
+    rp->s = net_open(sess, sess->cfg.host, sess->cfg.port);
+    if (rp->s == INVALID_SOCKET)
+       fatalbox("Open failed");
+}
+
+static int rawtcp_msg(Session *sess, SOCKET sock, Net_Event_Type ne) {
+    struct rawtcp_private *rp = (struct rawtcp_private *)sess->back_priv;
+
+    switch (ne) {
+      case NE_NULL:
+       break;
+      case NE_OPEN:
+       break;
+      case NE_NOHOST:
+      case NE_REFUSED:
+      case NE_NOOPEN:
+       rp->s = INVALID_SOCKET;
+       fatalbox("Open failed");
+       break;
+      case NE_DATA:
+       break;
+      case NE_URGENT:
+       break;
+      case NE_CLOSING:
+       /* net_close(rp->s);*/
+       break;
+      case NE_CLOSED:
+       rp->s = INVALID_SOCKET;
+       fatalbox("Connection closed");
+       break;
+      case NE_TIMEOUT:
+      case NE_ABORT:
+      case NE_DIED:
+       fatalbox("Connection died");
+       rp->s = INVALID_SOCKET;
+       break;
+    }
+}
+
+
+
 /*
  * Emacs magic:
  * Local Variables: