diff src/process-unix.c @ 424:11054d720c21 r21-2-20

Import from CVS: tag r21-2-20
author cvs
date Mon, 13 Aug 2007 11:26:11 +0200
parents 697ef44129c6
children
line wrap: on
line diff
--- a/src/process-unix.c	Mon Aug 13 11:25:03 2007 +0200
+++ b/src/process-unix.c	Mon Aug 13 11:26:11 2007 +0200
@@ -212,9 +212,11 @@
      end of the ptys.  */
   int failed_count = 0;
 #endif
+  int fd;
+#ifndef HAVE_GETPT
   int i;
-  int fd;
   int c;
+#endif
 
 #ifdef PTY_ITERATION
   PTY_ITERATION
@@ -261,7 +263,7 @@
 #else
             sprintf (pty_name, "/dev/tty%c%x", c, i);
 #endif /* no PTY_TTY_NAME_SPRINTF */
-#ifndef UNIPLUS
+#if !defined(UNIPLUS) && !defined(HAVE_GETPT)
 	    if (access (pty_name, 6) != 0)
 	      {
 		close (fd);
@@ -384,7 +386,7 @@
 	  else
 	    continue;
 	}
-      else if ((INTP (tail_port)) && (htons ((unsigned short) XINT (tail_port)) == port))
+      else if (INTP (tail_port) && (htons ((unsigned short) XINT (tail_port)) == port))
 	break;
     }
 
@@ -663,10 +665,9 @@
  */
 
 static void
-unix_mark_process_data (struct Lisp_Process *proc,
-			void (*markobj) (Lisp_Object))
+unix_mark_process_data (struct Lisp_Process *proc)
 {
-  markobj (UNIX_DATA(proc)->tty_name);
+  mark_object (UNIX_DATA(proc)->tty_name);
 }
 
 /*
@@ -1429,19 +1430,21 @@
 
 static void
 unix_open_network_stream (Lisp_Object name, Lisp_Object host, Lisp_Object service,
-			  Lisp_Object family, void** vinfd, void** voutfd)
+			  Lisp_Object protocol, void** vinfd, void** voutfd)
 {
   struct sockaddr_in address;
-  int s, inch, outch;
+  int inch;
+  int outch;
+  volatile int s;
   volatile int port;
   volatile int retry = 0;
   int retval;
 
   CHECK_STRING (host);
 
-  if (!EQ (family, Qtcpip))
-    error ("Unsupported protocol family \"%s\"",
-	   string_data (symbol_name (XSYMBOL (family))));
+  if (!EQ (protocol, Qtcp) && !EQ (protocol, Qudp))
+    error ("Unsupported protocol \"%s\"",
+	   string_data (symbol_name (XSYMBOL (protocol))));
 
   if (INTP (service))
     port = htons ((unsigned short) XINT (service));
@@ -1449,7 +1452,12 @@
     {
       struct servent *svc_info;
       CHECK_STRING (service);
-      svc_info = getservbyname ((char *) XSTRING_DATA (service), "tcp");
+
+      if (EQ (protocol, Qtcp))
+	  svc_info = getservbyname ((char *) XSTRING_DATA (service), "tcp");
+      else /* EQ (protocol, Qudp) */
+	  svc_info = getservbyname ((char *) XSTRING_DATA (service), "udp");
+
       if (svc_info == 0)
 	error ("Unknown service \"%s\"", XSTRING_DATA (service));
       port = svc_info->s_port;
@@ -1458,7 +1466,11 @@
   get_internet_address (host, &address, ERROR_ME);
   address.sin_port = port;
 
-  s = socket (address.sin_family, SOCK_STREAM, 0);
+  if (EQ (protocol, Qtcp))
+      s = socket (address.sin_family, SOCK_STREAM, 0);
+  else /* EQ (protocol, Qudp) */
+      s = socket (address.sin_family, SOCK_DGRAM, 0);
+
   if (s < 0)
     report_file_error ("error creating socket", list1 (name));