Consequences of Simon's recent deglobalisation changes.
[u/mdw/putty] / mac / otnet.c
index 4c9ec4b..eb24b85 100644 (file)
@@ -74,12 +74,14 @@ void ot_cleanup(void)
     CloseOpenTransport();
 }
 
-SockAddr ot_namelookup(char *host, char **canonicalname)
+SockAddr ot_namelookup(char const *host, char **canonicalname)
 {
     SockAddr ret = smalloc(sizeof(struct SockAddr_tag));
     char *realhost;
-    
-    ret->error = OTInetStringToAddress(ot.inetsvc, host, &ret->hostinfo);
+
+    /* Casting away const -- hope OTInetStringToAddress is sensible */
+    ret->error = OTInetStringToAddress(ot.inetsvc, (char *)host,
+                                      &ret->hostinfo);
     ret->resolved = TRUE;
 
     if (ret->error == kOTNoError)
@@ -91,7 +93,7 @@ SockAddr ot_namelookup(char *host, char **canonicalname)
     return ret;
 }
 
-SockAddr ot_nonamelookup(char *host)
+SockAddr ot_nonamelookup(char const *host)
 {
     SockAddr ret = smalloc(sizeof(struct SockAddr_tag));
     
@@ -313,6 +315,8 @@ Socket ot_new(SockAddr addr, int port, int privport, int oobinline,
     /* Add this to the list of all sockets */
     ret->next = ot.socklist;
     ret->prev = &ot.socklist;
+    if (ret->next != NULL)
+       ret->next->prev = &ret->next;
     ot.socklist = ret;
 
     return (Socket) ret;
@@ -462,9 +466,13 @@ void ot_recv(Actual_Socket s)
 
     if (s->frozen) return;
 
-    while ((o = OTRcv(s->ep, buf, sizeof(buf), &flags)) != kOTNoDataErr) {
-       plug_receive(s->plug, 0, buf, sizeof(buf));
-    }
+    do {
+       o = OTRcv(s->ep, buf, sizeof(buf), &flags);
+       if (o > 0)
+           plug_receive(s->plug, 0, buf, o);
+       if (o < 0 && o != kOTNoDataErr)
+           plug_closing(s->plug, NULL, 0, 0); /* XXX Error msg */
+    } while (o > 0);
 }