1998-10-16 Jason Molenda (jsm@bugshack.cygnus.com)
[deliverable/binutils-gdb.git] / gdb / ser-tcp.c
index 282da11c23b0dbcd48311b177485ffaf111fb8ab..c55133760faddb8850d0bac6feb45ebdd6966906 100644 (file)
@@ -1,5 +1,5 @@
 /* Serial interface for raw TCP connections on Un*x like systems
-   Copyright 1992, 1993 Free Software Foundation, Inc.
+   Copyright 1992, 1993, 1998 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -25,8 +25,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <sys/socket.h>
+
+#ifndef __CYGWIN32__
 #include <netinet/tcp.h>
+#endif
+
 #include "signals.h"
+#include "gdb_string.h"
 
 struct tcp_ttystate
 {
@@ -44,6 +49,12 @@ static int tcp_write PARAMS ((serial_t scb, const char *str, int len));
 static void tcp_close PARAMS ((serial_t scb));
 static serial_ttystate tcp_get_tty_state PARAMS ((serial_t scb));
 static int tcp_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
+static int tcp_return_0 PARAMS ((serial_t));
+static int tcp_noflush_set_tty_state PARAMS ((serial_t, serial_ttystate,
+                                             serial_ttystate));
+static void tcp_print_tty_state PARAMS ((serial_t, serial_ttystate));
+
+void _initialize_ser_tcp PARAMS ((void));
 
 /* Open up a raw tcp socket */
 
@@ -66,7 +77,7 @@ tcp_open(scb, name)
   if (!port_str)
     error ("tcp_open: No colon in host name!"); /* Shouldn't ever happen */
 
-  tmp = min (port_str - name, sizeof hostname - 1);
+  tmp = min (port_str - name, (int) sizeof hostname - 1);
   strncpy (hostname, name, tmp); /* Don't want colon */
   hostname[tmp] = '\000';      /* Tie off host name */
   port = atoi (port_str + 1);
@@ -174,7 +185,7 @@ tcp_raw(scb)
  */
 
 static int
-wait_for(scb, timeout)
+wait_for (scb, timeout)
      serial_t scb;
      int timeout;
 {
@@ -199,12 +210,14 @@ wait_for(scb, timeout)
        numfds = select(scb->fd+1, &readfds, 0, &exceptfds, 0);
 
       if (numfds <= 0)
-       if (numfds == 0)
-         return SERIAL_TIMEOUT;
-       else if (errno == EINTR)
-         continue;
-       else
-         return SERIAL_ERROR;  /* Got an error from select or poll */
+        {
+         if (numfds == 0)
+           return SERIAL_TIMEOUT;
+         else if (errno == EINTR)
+           continue;
+         else
+           return SERIAL_ERROR;        /* Got an error from select or poll */
+        }
 
       return 0;
     }
@@ -216,7 +229,7 @@ wait_for(scb, timeout)
    dead, or -3 for any other error (see errno in that case). */
 
 static int
-tcp_readchar(scb, timeout)
+tcp_readchar (scb, timeout)
      serial_t scb;
      int timeout;
 {
@@ -238,12 +251,14 @@ tcp_readchar(scb, timeout)
     }
 
   if (scb->bufcnt <= 0)
-    if (scb->bufcnt == 0)
-      return SERIAL_TIMEOUT;   /* 0 chars means timeout [may need to
-                                  distinguish between EOF & timeouts
-                                  someday] */
-    else
-      return SERIAL_ERROR;     /* Got an error from read */
+    {
+      if (scb->bufcnt == 0)
+        return SERIAL_TIMEOUT; /* 0 chars means timeout [may need to
+                                    distinguish between EOF & timeouts
+                                    someday] */
+      else
+        return SERIAL_ERROR;   /* Got an error from read */
+    }
 
   scb->bufcnt--;
   scb->bufp = scb->buf;
@@ -333,6 +348,7 @@ static struct serial_ops tcp_ops =
   tcp_noflush_set_tty_state,
   tcp_setbaudrate,
   tcp_setstopbits,
+  tcp_return_0,        /* wait for output to drain */
 };
 
 void
This page took 0.027228 seconds and 4 git commands to generate.